mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-11-27 20:49:51 +01:00
GUnixSocketAddress: handle abstract sockets with non-0-padded names
There are apparently two incompatible ways of naming abstract sockets: pad the sockaddr with 0s and use the entire thing as the name, or else don't, and just pass a shorter length value to the relevant functions. We previously only supported the former method. Add support for the latter. Also correctly handle "anonymous" unix sockaddrs (eg, the client side of a connection, or a socketpair() socket), and add unix domain socket support to the socket-client and socket-server test programs to make sure this all works. https://bugzilla.gnome.org/show_bug.cgi?id=615960
This commit is contained in:
@@ -698,6 +698,40 @@ typedef enum {
|
||||
G_ZLIB_COMPRESSOR_FORMAT_RAW
|
||||
} GZlibCompressorFormat;
|
||||
|
||||
/**
|
||||
* GUnixSocketAddressType:
|
||||
* @G_UNIX_SOCKET_ADDRESS_INVALID: invalid
|
||||
* @G_UNIX_SOCKET_ADDRESS_ANONYMOUS: anonymous
|
||||
* @G_UNIX_SOCKET_ADDRESS_PATH: a filesystem path
|
||||
* @G_UNIX_SOCKET_ADDRESS_ABSTRACT: an abstract name
|
||||
* @G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED: an abstract name, 0-padded
|
||||
* to the full length of a unix socket name
|
||||
*
|
||||
* The type of name used by a #GUnixSocketAddress.
|
||||
* %G_UNIX_SOCKET_ADDRESS_PATH indicates a traditional unix domain
|
||||
* socket bound to a filesystem path. %G_UNIX_SOCKET_ADDRESS_ANONYMOUS
|
||||
* indicates a socket not bound to any name (eg, a client-side socket,
|
||||
* or a socket created with socketpair()).
|
||||
*
|
||||
* For abstract sockets, there are two incompatible ways of naming
|
||||
* them: the man pages suggest using the entire <literal>struct
|
||||
* sockaddr_un</literal> as the name, padding the unused parts of the
|
||||
* %sun_path field with zeroes; this corresponds to
|
||||
* %G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED. However, many programs
|
||||
* instead just use a portion of %sun_path, and pass an appropriate
|
||||
* smaller length to bind() or connect(). This is
|
||||
* %G_UNIX_SOCKET_ADDRESS_ABSTRACT.
|
||||
*
|
||||
* Since: 2.26
|
||||
*/
|
||||
typedef enum {
|
||||
G_UNIX_SOCKET_ADDRESS_INVALID,
|
||||
G_UNIX_SOCKET_ADDRESS_ANONYMOUS,
|
||||
G_UNIX_SOCKET_ADDRESS_PATH,
|
||||
G_UNIX_SOCKET_ADDRESS_ABSTRACT,
|
||||
G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED
|
||||
} GUnixSocketAddressType;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIO_ENUMS_H__ */
|
||||
|
||||
Reference in New Issue
Block a user