socket-util: add new sockaddr_un_unlink() helper

The helper is supposed to properly handle cases where .sun_path does not
contain a NUL byte, and thus copies out the path suffix a NUL as
necessary.

This also reworks the more specific socket_address_unlink() to be a
wrapper around the more generic sockaddr_un_unlink()
This commit is contained in:
Lennart Poettering
2018-10-15 19:35:00 +02:00
parent 242c41b850
commit 9f20fc28f0
2 changed files with 30 additions and 16 deletions
+6 -1
View File
@@ -71,7 +71,12 @@ int socket_address_parse_and_warn(SocketAddress *a, const char *s);
int socket_address_parse_netlink(SocketAddress *a, const char *s);
int socket_address_print(const SocketAddress *a, char **p);
int socket_address_verify(const SocketAddress *a) _pure_;
int socket_address_unlink(SocketAddress *a);
int sockaddr_un_unlink(const struct sockaddr_un *sa);
static inline int socket_address_unlink(const SocketAddress *a) {
return socket_address_family(a) == AF_UNIX ? sockaddr_un_unlink(&a->sockaddr.un) : 0;
}
bool socket_address_can_accept(const SocketAddress *a) _pure_;