Commit Graph

29 Commits

Author SHA1 Message Date
Roland C. Dowdeswell
56a32a8dbd krb5_storage: normalise truncate behaviour w.r.t. file offset
We choose a semantic for the file offset during truncate operations
which is to leave the offset as is unless it is off the end of the
file in which case we pull it back in to the end.  We update fd and
stdio handling to match the {,e}mem behaviour.
2019-03-21 11:23:39 -05:00
Nicolas Williams
c01c48e0f4 Add stdio-based krb5_storage 2017-05-26 23:24:30 -04:00
Nicolas Williams
3fb30ff0a6 Fix fd_store() return value for short writes 2017-05-26 23:24:30 -04:00
Nicolas Williams
e17cbff0ae Fix fd_fetch() return value for short reads 2017-05-26 23:24:30 -04:00
Nicolas Williams
abafa0a0a0 krb5_storage_free(): preserve errno 2016-02-26 00:55:30 -06:00
Jeffrey Altman
dba026b5ef Introduce and apply krb5_storage_from_socket
On Windows a file descriptor is an int value allocated by the
local module instance of the C Run Time Library.  A socket handle is a
SOCKET value allocated by a Winsock Provider for the requested family and
protocol.   These two values cannot be mixed and there is no mechanism for
converting between the two.   The _get_osfhandle() and _open_osfhandle()
functions can work with a standard HANDLE (file, pipe, etc) but cannot be
used for a SOCKET.

The Heimdal krb5_storage_from_fd() routine counted on the osf conversion
functions working on SOCKET values.  Since they do not any attempt to call
krb5_storage_from_fd() on a socket resulted in an assertion being thrown
by the C RTL.

Another problem is SOCKET value truncation when storing a 64-bit value
into a 32-bit int.

To address these problems a new krb5_storage_from_socket() routine is
introduced.  This routine setups a krb5_storage that stores a socket value
as a rk_socket_t and provides a set of helper routines that always use
network ready functions.

The krb5_storage_from_fd() routines no longer use net_read() and
net_write() but provide helpers that follow their logic so that pipes can
be processed.

All call sites that allocate a socket now store the socket as rk_socket_t
and call krb5_storage_from_socket().

All locations that previously called the bare close() on a socket value
now call rk_closesocket().

Change-Id: I045f775b2a5dbf5cf803751409490bc27fffe597
2014-02-04 23:20:08 -05:00
Roland C. Dowdeswell
df42274d96 Add krb5_storage_fsync().
We add a function to cause krb5_storage's to be sync'd to their backing
store.  For memory backed storages, this is a NOP.  For files, it calls
fsync on the file descriptor.
2012-05-28 13:14:55 +01:00
Roland C. Dowdeswell
7af81533ef Don't clobber errno during error cleanup in krb5_storage_from_fd(). 2012-05-22 11:07:19 +01:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Love Hornquist Astrand
bd2d4c2f79 ->max_alloc to krb5_storage and use it 2011-05-08 00:16:02 -07:00
Love Hornquist Astrand
687db64c56 Patch from Secure Endpoints/Asanka Herath for windows support 2009-12-21 08:45:28 +01:00
Love Hornquist Astrand
e5c42ba42f rename krb5_storage_from_emem in documentation 2009-07-28 17:51:53 +02:00
Love Hörnquist Åstrand
942a821fab remove RCSID
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25171 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-05-04 06:17:40 +00:00
Love Hörnquist Åstrand
77d0314d51 fixup krb5_storage_truncate return value, add krb5_{store,ret}_data_xdr, doxygen
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24234 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-11 21:41:04 +00:00
Love Hörnquist Åstrand
a54887f054 Add krb5_storage_truncate
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24226 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-11 21:39:41 +00:00
Love Hörnquist Åstrand
e172367898 switch to utf8 encoding of all files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23814 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 08:53:55 +00:00
Love Hörnquist Åstrand
0af8ebf043 (krb5_storage_from_fd): don't leak fd on malloc failure
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17779 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-06-30 21:23:19 +00:00
Love Hörnquist Åstrand
91351971f7 add KRB5_LIB_FUNCTION to all exported functions
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13863 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-05-25 21:46:46 +00:00
Johan Danielsson
f3dc346f5d (krb5_storage_from_fd): dup the file descriptor so we don't have to
keep track of it in two places


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13795 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-04-25 21:27:34 +00:00
Johan Danielsson
ce19f448ae make the krb5_storage opaque, and add function wrappers for
store/fetch/seek, and also make the eof-code configurable


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10931 ec53bebd-3082-4978-b11e-865c3cabbd6b
2002-04-18 14:00:44 +00:00
Assar Westerlund
b2848e8199 (krb5_storage_from_fd): check malloc returns
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10190 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-06-24 05:39:51 +00:00
Assar Westerlund
68f0dcb65c (fd_fetch, fd_store): use net_{read,write} to make sure of not
dropping data when doing it over a socket.  (this might break when
used with ordinary files on win32)


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9564 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-01-29 02:32:35 +00:00
Assar Westerlund
6789dbdca2 (fd_store): make it write-compatible
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8272 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-05-19 14:39:27 +00:00
Johan Danielsson
c5b916ca6f remove advertising clause
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7464 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-12-02 17:05:13 +00:00
Assar Westerlund
99da56bf7a lots of changes from size_t to ssize_t
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6554 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-07-26 00:50:43 +00:00
Johan Danielsson
7de75b60e8 (krb5_storage_from_fd): zero flags
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6028 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-04-24 16:35:20 +00:00
Johan Danielsson
6dc689c324 (krb5_storage_from_fd): initialize host_byteorder
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5961 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-04-15 15:43:01 +00:00
Johan Danielsson
5a32a5c8e7 Add copyright notice.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2389 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-07-16 21:40:05 +00:00
Johan Danielsson
2e846c7099 Split of store.c
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1359 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-03-12 07:28:36 +00:00