diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-06-04 13:10:43 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-06-04 13:12:34 +0200 |
commit | bd1fe7c79de3d81325afecb7ded46c1627f6c1df (patch) | |
tree | 85cf71bda8b14c84037c150aaba2fe5c28202af0 /src/shared/socket-util.c | |
parent | edf029b7fd9a5853a87d3ca99aac2922bb8a277e (diff) |
socket: optionally remove sockets/FIFOs in the file system after use
Diffstat (limited to 'src/shared/socket-util.c')
-rw-r--r-- | src/shared/socket-util.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c index 997a1ceba3..92564e3193 100644 --- a/src/shared/socket-util.c +++ b/src/shared/socket-util.c @@ -625,6 +625,21 @@ int getsockname_pretty(int fd, char **ret) { return sockaddr_pretty(&sa.sa, salen, false, ret); } +int socket_address_unlink(SocketAddress *a) { + assert(a); + + if (socket_address_family(a) != AF_UNIX) + return 0; + + if (a->sockaddr.un.sun_path[0] == 0) + return 0; + + if (unlink(a->sockaddr.un.sun_path) < 0) + return -errno; + + return 1; +} + static const char* const netlink_family_table[] = { [NETLINK_ROUTE] = "route", [NETLINK_FIREWALL] = "firewall", |