Don't allow disconnect of admin network.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 23 Nov 2007 16:51:49 +0000 (17:51 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 23 Nov 2007 16:51:49 +0000 (17:51 +0100)
NEWS
lib/network.c
lib/network.h
src/admin.c

diff --git a/NEWS b/NEWS
index e10e384..1960bd8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,8 @@ Ctrlproxy 3.0.4 UNRELEASED
     * Add "default-network" setting.
 
   BUG FIXES
+    
+    * Don't allow disconnect of admin network. (#164)
 
     * Clearer error messages during disconnect.
 
index 2e259c4..d964862 100644 (file)
@@ -1295,6 +1295,7 @@ gboolean disconnect_network(struct network *s)
        if (s->connection.state == NETWORK_CONNECTION_STATE_NOT_CONNECTED) {
                return FALSE;
        }
+
        log_network(LOG_INFO, s, "Disconnecting");
        return close_server(s);
 }
index 8fc1351..a4f2bb9 100644 (file)
@@ -80,9 +80,10 @@ struct network_connection {
                        void *private_data;
                        struct virtual_network_ops {
                                char *name;
+                               gboolean not_disconnectable;
                                gboolean (*init) (struct network *);
                                gboolean (*to_server) (struct network *, struct client *c, const struct line *);
-                               gboolean (*fini) (struct network *);
+                               void (*fini) (struct network *);
                        } *ops;
                } virtual;
        } data;
index 393ef59..3a5b895 100644 (file)
@@ -281,6 +281,10 @@ static void cmd_disconnect_network (admin_handle h, char **args, void *userdata)
 
        if (n->connection.state == NETWORK_CONNECTION_STATE_NOT_CONNECTED) {
                admin_out(h, "Already disconnected from `%s'", n->info.name);
+       } else if (n->config->type == NETWORK_VIRTUAL && 
+               n->connection.data.virtual.ops->not_disconnectable) {
+               admin_out(h, "Built-in network `%s' can't be disconnected", 
+                                 n->info.name);
        } else {
                admin_out(h, "Disconnecting from `%s'", n->info.name);
                disconnect_network(n);
@@ -794,7 +798,10 @@ static gboolean admin_to_server (struct network *n, struct client *c, const stru
 }
 
 struct virtual_network_ops admin_network = {
-       "admin", admin_net_init, admin_to_server, NULL
+       .name = "admin", 
+       .init = admin_net_init, 
+       .to_server = admin_to_server, 
+       .not_disconnectable = TRUE,
 };