]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afp_config.c
Merge remote branch 'origin/product-2-2' into develop
[netatalk.git] / etc / afpd / afp_config.c
index f859637942f5e7ce8ebee2c3afc1bcf3d51ee5fc..ed8067048da2e483bec545c8f61ba4580f5f9dd8 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
  *
  * Preserve object pointed to by "dsi".
- * "dsi" can be NULL in which case all DSI objects are freed
+ * "dsi" can be NULL in which case all DSI objects _and_ the options object are freed 
  */
 void configfree(AFPObj *obj, DSI *dsi)
 {
     DSI *p, *q;
 
-    afp_options_free(obj->options);
+    /* the master loaded the volumes for zeroconf, get rid of that */
+    unload_volumes(obj);
 
     for (p = obj->dsi; p; p = q) {
         q = p->next;
         if (p == dsi)
             continue;
         close(p->socket);
-        free(p->dsi);
         free(p);
     }
     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,23 +76,30 @@ int configinit(AFPObj *obj)
 {
     EC_INIT;
     DSI *dsi, **next = &obj->dsi;
-    char *p, *q = NULL;
+    char *p = NULL, *q = NULL, *savep;
+    const char *r;
+
+    auth_load(obj->options.uampath, obj->options.uamlist);
+    set_signature(&obj->options);
 
     LOG(log_debug, logtype_afpd, "DSIConfigInit: hostname: %s, listen: %s, port: %s",
-        obj->options->hostname,
-        obj->options->listen ? obj->options->listen : "(default: hostname)",
-        obj->options->port);
+        obj->options.hostname,
+        obj->options.listen ? obj->options.listen : "(default: hostname)",
+        obj->options.port);
 
     /* obj->options->listen is of the from "IP[:port][,IP:[PORT], ...]" */
     /* obj->options->port is the default port to listen (548) */
 
-    EC_NULL( q = p = strdup(obj->options->listen) );
-    EC_NULL( p = strtok(p, ',') );
+    if (obj->options.listen) {
+        EC_NULL( q = p = strdup(obj->options.listen) );
+        EC_NULL( p = strtok_r(p, ", ", &savep) );
+    }
 
-    while (p) {
-        if ((dsi = dsi_init(obj, obj->options->hostname, p, obj->options->port)) == NULL)
+    while (1) {
+        if ((dsi = dsi_init(obj, obj->options.hostname, p, obj->options.port)) == NULL)
             break;
 
+        status_init(obj, dsi);
         *next = dsi;
         next = &dsi->next;
 
@@ -97,26 +107,40 @@ int configinit(AFPObj *obj)
             getip_string((struct sockaddr *)&dsi->server),
             getip_port((struct sockaddr *)&dsi->server));
 
-        p = strtok(NULL, ',');
+        if (p)
+            /* p is NULL if ! obj->options.listen */
+            p = strtok_r(NULL, ", ", &savep);
+        if (!p)
+            break;
     }
 
     if (obj->dsi == NULL)
         EC_FAIL;
 
-    auth_load(obj->options->uampath, obj->options->uamlist);
-    status_init(obj);
-    set_signature(obj->options);
-
 #ifdef HAVE_LDAP
-    /* Parse afp_ldap.conf */
-    acl_ldap_readconfig(AFPObj->iniconfig);
+    /* Parse afp.conf */
+    acl_ldap_readconfig(obj->iniconfig);
 #endif /* HAVE_LDAP */
 
     /* Now register with zeroconf, we also need the volumes for that */
-    if (! (AFPObj->options.flags & OPTION_NOZEROCONF)) {
-        load_volumes(AFPObj);
-        zeroconf_register(AFPObj);
+    if (! (obj->options.flags & OPTION_NOZEROCONF)) {
+        load_volumes(obj, NULL);
+        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)