]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afp_config.c
Fix volume loading in afpd session
[netatalk.git] / etc / afpd / afp_config.c
index d853e0b4ac2eb3893bca7c577e020b9d3a7120b2..61bbf6844d1cffce461bc9d8e60fbc4029687d21 100644 (file)
@@ -26,6 +26,8 @@
 #include <atalk/server_child.h>
 #include <atalk/globals.h>
 #include <atalk/errchk.h>
+#include <atalk/netatalk_conf.h>
+#include <atalk/fce_api.h>
 
 #ifdef HAVE_LDAP
 #include <atalk/ldapconfig.h>
 
 
 /*!
- * Free and cleanup all linked DSI objects from config
+ * Free and cleanup config and DSI
  *
- * Preserve object pointed to by "dsi".
- * "dsi" can be NULL in which case all DSI objects _and_ the options object are freed 
+ * "dsi" can be NULL in which case all DSI objects and the config object is freed,
+ * otherwise its an afpd session child and only any unneeded DSI objects are freed
  */
 void configfree(AFPObj *obj, DSI *dsi)
 {
     DSI *p, *q;
 
+    if (!dsi) {
+        /* Master afpd reloading config */
+        auth_unload();
+        if (! (obj->options.flags & OPTION_NOZEROCONF)) {
+            zeroconf_deregister();
+        }
+    }
+
+    unload_volumes(obj);
+
+    /* Master and child releasing unneeded DSI handles */
     for (p = obj->dsi; p; p = q) {
         q = p->next;
         if (p == dsi)
             continue;
-        close(p->socket);
+        dsi_free(p);
         free(p);
     }
+    obj->dsi = NULL;
+
+    /* afpd session child passes dsi handle to obj handle */
     if (dsi) {
         dsi->next = NULL;
         obj->dsi = dsi;
-    } else {
-        afp_options_free(&obj->options);
     }
-
-    /* the master loaded the volumes for zeroconf, get rid of that */
-    unload_volumes();
 }
 
 /*!
@@ -73,10 +84,14 @@ int configinit(AFPObj *obj)
 {
     EC_INIT;
     DSI *dsi, **next = &obj->dsi;
-    char *p = NULL, *q = NULL;
+    char *p = NULL, *q = NULL, *savep;
+    const char *r;
 
     auth_load(obj->options.uampath, obj->options.uamlist);
     set_signature(&obj->options);
+#ifdef HAVE_LDAP
+    acl_ldap_freeconfig();
+#endif /* HAVE_LDAP */
 
     LOG(log_debug, logtype_afpd, "DSIConfigInit: hostname: %s, listen: %s, port: %s",
         obj->options.hostname,
@@ -88,7 +103,7 @@ int configinit(AFPObj *obj)
 
     if (obj->options.listen) {
         EC_NULL( q = p = strdup(obj->options.listen) );
-        EC_NULL( p = strtok(p, ",") );
+        EC_NULL( p = strtok_r(p, ", ", &savep) );
     }
 
     while (1) {
@@ -98,6 +113,7 @@ int configinit(AFPObj *obj)
         status_init(obj, dsi);
         *next = dsi;
         next = &dsi->next;
+        dsi->AFPobj = obj;
 
         LOG(log_note, logtype_afpd, "Netatalk AFP/TCP listening on %s:%d",
             getip_string((struct sockaddr *)&dsi->server),
@@ -105,16 +121,13 @@ int configinit(AFPObj *obj)
 
         if (p)
             /* p is NULL if ! obj->options.listen */
-            p = strtok(NULL, ",");
+            p = strtok_r(NULL, ", ", &savep);
         if (!p)
             break;
     }
 
-    if (obj->dsi == NULL)
-        EC_FAIL;
-
 #ifdef HAVE_LDAP
-    /* Parse afp_ldap.conf */
+    /* Parse afp.conf */
     acl_ldap_readconfig(obj->iniconfig);
 #endif /* HAVE_LDAP */
 
@@ -124,6 +137,19 @@ int configinit(AFPObj *obj)
         zeroconf_register(obj);
     }
 
+    if ((r = iniparser_getstring(obj->iniconfig, INISEC_GLOBAL, "fce listener", NULL))) {
+               LOG(log_note, logtype_afpd, "Adding FCE listener: %s", r);
+               fce_add_udp_socket(r);
+    }
+    if ((r = iniparser_getstring(obj->iniconfig, INISEC_GLOBAL, "fce coalesce", NULL))) {
+               LOG(log_note, logtype_afpd, "Fce coalesce: %s", r);
+               fce_set_coalesce(r);
+    }
+    if ((r = iniparser_getstring(obj->iniconfig, INISEC_GLOBAL, "fce events", NULL))) {
+               LOG(log_note, logtype_afpd, "Fce events: %s", r);
+               fce_set_events(r);
+    }
+
 EC_CLEANUP:
     if (q)
         free(q);