From: Alan T. DeKok Date: Mon, 26 Jul 2010 14:59:27 +0000 (+0200) Subject: Better fix for unlinking control sockets X-Git-Tag: release_3_0_0_beta0~1343 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=freeradius.git;a=commitdiff_plain;h=c7176394a4a5cc70620eea8f35228cbc459237e5 Better fix for unlinking control sockets --- diff --git a/src/main/command.c b/src/main/command.c index 60afa5c..650f5cd 100644 --- a/src/main/command.c +++ b/src/main/command.c @@ -66,6 +66,7 @@ struct fr_command_table_t { typedef struct fr_command_socket_t { char *path; + char *copy; /* */ uid_t uid; gid_t gid; int mode; @@ -254,6 +255,7 @@ static int fr_server_domain_socket(const char *path) return sockfd; } + static void command_close_socket(rad_listen_t *this) { this->status = RAD_LISTEN_STATUS_CLOSED; @@ -1831,6 +1833,16 @@ static fr_command_table_t command_table[] = { }; +static void command_socket_free(rad_listen_t *this) +{ + fr_command_socket_t *sock = this->data; + + unlink(sock->copy); + free(sock->copy); + sock->copy = NULL; +} + + /* * Parse the unix domain sockets. * @@ -1846,6 +1858,9 @@ static int command_socket_parse(CONF_SECTION *cs, rad_listen_t *this) return -1; } + sock->copy = NULL; + if (sock->path) sock->copy = strdup(sock->path); + #if defined(HAVE_GETPEEREID) || defined (SO_PEERCRED) if (sock->uid_name) { struct passwd *pw; diff --git a/src/main/listen.c b/src/main/listen.c index 1c36953..2ff447c 100644 --- a/src/main/listen.c +++ b/src/main/listen.c @@ -1817,7 +1817,7 @@ static const rad_listen_master_t master_listen[RAD_LISTEN_MAX] = { #ifdef WITH_COMMAND_SOCKET /* TCP command socket */ - { command_socket_parse, NULL, + { command_socket_parse, command_socket_free, command_domain_accept, command_domain_send, command_socket_print, command_socket_encode, command_socket_decode }, #endif