diff options
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", |