typedef struct fr_command_socket_t {
char *path;
+ char *copy; /* <sigh> */
uid_t uid;
gid_t gid;
int mode;
return sockfd;
}
+
static void command_close_socket(rad_listen_t *this)
{
this->status = RAD_LISTEN_STATUS_CLOSED;
return 1;
}
-extern void revive_home_server(void *ctx);
-extern void mark_home_server_dead(home_server *home, struct timeval *when);
-
static int command_set_home_server_state(rad_listen_t *listener, int argc, char *argv[])
{
int last;
return 1; /* success */
}
+#ifdef WITH_STATS
static int command_print_stats(rad_listen_t *listener, fr_stats_t *stats,
int auth)
{
return 1;
}
-
#ifdef WITH_DETAIL
static FR_NAME_NUMBER state_names[] = {
{ "unopened", STATE_UNOPENED },
return command_print_stats(listener, client->auth, auth);
}
+#endif /* WITH_STATS */
static int command_add_client_file(rad_listen_t *listener, int argc, char *argv[])
}
+static int command_del_client(rad_listen_t *listener, int argc, char *argv[])
+{
+#ifdef WITH_DYNAMIC_CLIENTS
+ RADCLIENT *client;
+
+ client = get_client(listener, argc - 1, argv + 1);
+ if (!client) return 0;
+
+ if (!client->dynamic) {
+ cprintf(listener, "ERROR: Client %s was not dynamically defined.\n", argv[1]);
+ return 0;
+ }
+
+ /*
+ * DON'T delete it. Instead, mark it as "dead now". The
+ * next time we receive a packet for the client, it will
+ * be deleted.
+ *
+ * If we don't receive a packet from it, the client
+ * structure will stick around for a while. Oh well...
+ */
+ client->lifetime = 1;
+#else
+ cprintf(listener, "ERROR: Dynamic clients are not supported.\n");
+#endif
+
+ return 1;
+}
+
+
+static fr_command_table_t command_table_del_client[] = {
+ { "ipaddr", FR_WRITE,
+ "del client ipaddr <ipaddr> - Delete a dynamically created client",
+ command_del_client, NULL },
+
+ { NULL, 0, NULL, NULL, NULL }
+};
+
+
+static fr_command_table_t command_table_del[] = {
+ { "client", FR_WRITE,
+ "del client <command> - Delete client configuration commands",
+ NULL, command_table_del_client },
+
+ { NULL, 0, NULL, NULL, NULL }
+};
+
+
static fr_command_table_t command_table_add_client[] = {
{ "file", FR_WRITE,
"add client file <filename> - Add new client definition from <filename>",
};
+#ifdef WITH_STATS
static fr_command_table_t command_table_stats[] = {
{ "client", FR_READ,
"stats client [auth/acct] <ipaddr> "
{ NULL, 0, NULL, NULL, NULL }
};
+#endif
static fr_command_table_t command_table[] = {
{ "add", FR_WRITE, NULL, NULL, command_table_add },
{ "debug", FR_WRITE,
"debug <command> - debugging commands",
NULL, command_table_debug },
+ { "del", FR_WRITE, NULL, NULL, command_table_del },
{ "hup", FR_WRITE,
"hup [module] - sends a HUP signal to the server, or optionally to one module",
command_hup, NULL },
command_terminate, NULL },
{ "set", FR_WRITE, NULL, NULL, command_table_set },
{ "show", FR_READ, NULL, NULL, command_table_show },
+#ifdef WITH_STATS
{ "stats", FR_READ, NULL, NULL, command_table_stats },
+#endif
{ NULL, 0, NULL, NULL, NULL }
};
+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.
*
{
fr_command_socket_t *sock;
+ if (check_config) return 0;
+
sock = this->data;
if (cf_section_parse(cs, sock, command_config) < 0) {
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;
return 0;
}
-static int command_socket_print(rad_listen_t *this, char *buffer, size_t bufsize)
+static int command_socket_print(const rad_listen_t *this, char *buffer, size_t bufsize)
{
fr_command_socket_t *sock = this->data;
*/
if (((co->mode & FR_WRITE) == 0) &&
((table[i].mode & FR_WRITE) != 0)) {
- cprintf(listener, "ERROR: You do not have write permission. See \"mode = rw\" in %s\n", co->path);
+ cprintf(listener, "ERROR: You do not have write permission. See \"mode = rw\" in the \"listen\" section for this socket.\n");
goto do_next;
}