]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afp_config.c
Fix SIGHUP config reloading
[netatalk.git] / etc / afpd / afp_config.c
index ed8067048da2e483bec545c8f61ba4580f5f9dd8..3d9aff81e32b35c762655829cb391271af81c672 100644 (file)
 
 
 /*!
- * 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;
 
-    /* the master loaded the volumes for zeroconf, get rid of that */
-    unload_volumes(obj);
+    if (!dsi) {
+        /* Master afpd reloading config */
+        auth_unload();
+        if (! (obj->options.flags & OPTION_NOZEROCONF)) {
+            unload_volumes(obj);
+            zeroconf_deregister();
+        }
+    }
 
+    /* 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);
     }
-
 }
 
 /*!
@@ -81,6 +88,9 @@ int configinit(AFPObj *obj)
 
     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,
@@ -102,6 +112,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),
@@ -114,9 +125,6 @@ int configinit(AFPObj *obj)
             break;
     }
 
-    if (obj->dsi == NULL)
-        EC_FAIL;
-
 #ifdef HAVE_LDAP
     /* Parse afp.conf */
     acl_ldap_readconfig(obj->iniconfig);
@@ -124,7 +132,7 @@ int configinit(AFPObj *obj)
 
     /* Now register with zeroconf, we also need the volumes for that */
     if (! (obj->options.flags & OPTION_NOZEROCONF)) {
-        load_volumes(obj, NULL);
+        load_volumes(obj);
         zeroconf_register(obj);
     }
 
@@ -141,7 +149,6 @@ int configinit(AFPObj *obj)
                fce_set_events(r);
     }
 
-
 EC_CLEANUP:
     if (q)
         free(q);