]> arthur.barton.de Git - netatalk.git/commitdiff
Fix build
authorFrank Lahm <franklahm@googlemail.com>
Tue, 14 Feb 2012 11:17:33 +0000 (12:17 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Tue, 14 Feb 2012 11:17:33 +0000 (12:17 +0100)
42 files changed:
bin/ad/ad.c
bin/misc/Makefile.am
bin/misc/logger_test.c
bin/misc/uuidtest.c
etc/afpd/Makefile.am
etc/afpd/afp_avahi.c
etc/afpd/afp_avahi.h
etc/afpd/afp_config.c
etc/afpd/afp_config.h
etc/afpd/afp_dsi.c
etc/afpd/afp_options.c
etc/afpd/afp_zeroconf.c
etc/afpd/afp_zeroconf.h
etc/afpd/auth.c
etc/afpd/desktop.c
etc/afpd/fce_util.c
etc/afpd/file.c
etc/afpd/fork.c
etc/afpd/main.c
etc/afpd/messages.c
etc/afpd/status.c
etc/afpd/status.h
etc/afpd/uam.c
etc/afpd/unix.c
etc/afpd/volume.c
etc/cnid_dbd/cmd_dbd.c
etc/cnid_dbd/cnid_metad.c
etc/cnid_dbd/main.c
include/atalk/dictionary.h
include/atalk/dsi.h
include/atalk/fce_api.h
include/atalk/globals.h
include/atalk/iniparser.h
include/atalk/uam.h
libatalk/acl/ldap_config.c
libatalk/dsi/Makefile.am
libatalk/dsi/dsi_init.c
libatalk/dsi/dsi_private.h [deleted file]
libatalk/dsi/dsi_tcp.c
libatalk/iniparser/dictionary.c
libatalk/iniparser/iniparser.c
libatalk/util/logger.c

index 38fd62bb3890099335d3780496af36a1eaaf8004..2287ee6aa53f8f6deb0145ce2fc0eb7402c3d340 100644 (file)
@@ -46,7 +46,7 @@ static void show_version(void)
 
 int main(int argc, char **argv)
 {
 
 int main(int argc, char **argv)
 {
-    setuplog("default log_note /dev/tty");
+    setuplog("default:note", "/dev/tty");
 
     if (argc < 2) {
         usage_main();
 
     if (argc < 2) {
         usage_main();
index 426dc3179f25ad99371bdff4e0e341e0a3cc6386..b8ec704016b62150c98b1a5708c622b48be4011e 100644 (file)
@@ -17,6 +17,6 @@ fce_CFLAGS = -I$(top_srcdir)/include
 
 bin_PROGRAMS += afpldaptest
 afpldaptest_SOURCES = uuidtest.c
 
 bin_PROGRAMS += afpldaptest
 afpldaptest_SOURCES = uuidtest.c
-afpldaptest_CFLAGS = -D_PATH_ACL_LDAPCONF=\"$(pkgconfdir)/afp_ldap.conf\"
+afpldaptest_CFLAGS = -D_PATH_CONFDIR=\"$(pkgconfdir)\"
 afpldaptest_LDADD =  $(top_builddir)/libatalk/libatalk.la
 
 afpldaptest_LDADD =  $(top_builddir)/libatalk/libatalk.la
 
index b3ab7b53be6f2d70947c57d2691f34852bb6ffdf..585c15839158a61534c96aafb62258908308d4ef 100644 (file)
@@ -25,11 +25,11 @@ int main(int argc, char *argv[])
 #endif
   /* filelog testing */
 
 #endif
   /* filelog testing */
 
-  setuplog("DSI log_maxdebug test.log");
+  setuplog("DSI:maxdebug", "test.log");
   LOG(log_info, logtype_dsi, "This should log.");
   LOG(log_error, logtype_default, "This should not log.");
 
   LOG(log_info, logtype_dsi, "This should log.");
   LOG(log_error, logtype_default, "This should not log.");
 
-  setuplog("Default log_debug test.log");
+  setuplog("Default:debug", "test.log");
   LOG(log_debug, logtype_default, "This should log.");
   LOG(log_maxdebug, logtype_default, "This should not log.");
 
   LOG(log_debug, logtype_default, "This should log.");
   LOG(log_maxdebug, logtype_default, "This should not log.");
 
index 0efc3318c6a45d0fe25c85b3cdf5016b9c548789..81d117361aa4105c576876d1f5dea587ce2b7504 100644 (file)
@@ -41,12 +41,14 @@ static void usage()
 static void parse_ldapconf()
 {
     static int inited = 0;
 static void parse_ldapconf()
 {
     static int inited = 0;
+    dictionary *iniconfig;
 
     if (! inited) {
 #ifdef HAVE_LDAP
         /* Parse afp_ldap.conf */
         printf("Start parsing afp_ldap.conf\n");
 
     if (! inited) {
 #ifdef HAVE_LDAP
         /* Parse afp_ldap.conf */
         printf("Start parsing afp_ldap.conf\n");
-        acl_ldap_readconfig(_PATH_ACL_LDAPCONF);
+        iniconfig = iniparser_load(_PATH_CONFDIR "afp.conf");
+        acl_ldap_readconfig(iniconfig);
         printf("Finished parsing afp_ldap.conf\n");
         if (ldap_config_valid) {
             if (ldap_auth_method == LDAP_AUTH_NONE)
         printf("Finished parsing afp_ldap.conf\n");
         if (ldap_config_valid) {
             if (ldap_auth_method == LDAP_AUTH_NONE)
@@ -83,14 +85,14 @@ int main( int argc, char **argv)
         case 'v':
             if (! verbose) {
                 verbose = 1;
         case 'v':
             if (! verbose) {
                 verbose = 1;
-                setuplog("default log_maxdebug /dev/tty");
+                setuplog("default:maxdebug", "/dev/tty");
                 logsetup = 1;
             }
             break;
 
         case 'u':
             if (! logsetup)
                 logsetup = 1;
             }
             break;
 
         case 'u':
             if (! logsetup)
-                setuplog("default log_info /dev/tty");
+                setuplog("default:info", "/dev/tty");
             parse_ldapconf();
             printf("Searching user: %s\n", optarg);
             ret = getuuidfromname( optarg, UUID_USER, uuid);
             parse_ldapconf();
             printf("Searching user: %s\n", optarg);
             ret = getuuidfromname( optarg, UUID_USER, uuid);
@@ -103,7 +105,7 @@ int main( int argc, char **argv)
 
         case 'g':
             if (! logsetup)
 
         case 'g':
             if (! logsetup)
-                setuplog("default log_info /dev/tty");
+                setuplog("default:info", "/dev/tty");
             parse_ldapconf();
             printf("Searching group: %s\n", optarg);
             ret = getuuidfromname( optarg, UUID_GROUP, uuid);
             parse_ldapconf();
             printf("Searching group: %s\n", optarg);
             ret = getuuidfromname( optarg, UUID_GROUP, uuid);
@@ -116,7 +118,7 @@ int main( int argc, char **argv)
 
         case 'i':
             if (! logsetup)
 
         case 'i':
             if (! logsetup)
-                setuplog("default log_info /dev/tty");
+                setuplog("default:info", "/dev/tty");
             parse_ldapconf();
             printf("Searching uuid: %s\n", optarg);
             uuid_string2bin(optarg, uuid);
             parse_ldapconf();
             printf("Searching uuid: %s\n", optarg);
             uuid_string2bin(optarg, uuid);
index 544c5843af52bc44af886e8601e8e87bf712eee2..747d84f590e7c050a504b0b7a8c8893c9e158e65 100644 (file)
@@ -45,14 +45,14 @@ afpd_SOURCES = \
 afpd_LDADD =  \
        $(top_builddir)/libatalk/cnid/libcnid.la \
        $(top_builddir)/libatalk/libatalk.la \
 afpd_LDADD =  \
        $(top_builddir)/libatalk/cnid/libcnid.la \
        $(top_builddir)/libatalk/libatalk.la \
-       @LIBGCRYPT_LIBS@ @QUOTA_LIBS@ @SLP_LIBS@ @WRAP_LIBS@ @LIBADD_DL@ @ACL_LIBS@ @ZEROCONF_LIBS@ @PTHREAD_LIBS@
+       @LIBGCRYPT_LIBS@ @QUOTA_LIBS@ @WRAP_LIBS@ @LIBADD_DL@ @ACL_LIBS@ @ZEROCONF_LIBS@ @PTHREAD_LIBS@
 
 afpd_LDFLAGS = -export-dynamic
 
 afpd_CFLAGS = \
        -I$(top_srcdir)/include \
        -I$(top_srcdir)/sys \
 
 afpd_LDFLAGS = -export-dynamic
 
 afpd_CFLAGS = \
        -I$(top_srcdir)/include \
        -I$(top_srcdir)/sys \
-       @SLP_CFLAGS@ @ZEROCONF_CFLAGS@ \
+       @ZEROCONF_CFLAGS@ \
        -DAPPLCNAME \
        -DSERVERTEXT=\"$(SERVERTEXT)/\" \
        -D_PATH_AFPDPWFILE=\"$(pkgconfdir)/afppasswd\" \
        -DAPPLCNAME \
        -DSERVERTEXT=\"$(SERVERTEXT)/\" \
        -D_PATH_AFPDPWFILE=\"$(pkgconfdir)/afppasswd\" \
index 89ff95fdca66bf01ee8bc2dfa360bd9fb643623c..ef7d529336b7dab60cbaa237b283f1a32ef99f2e 100644 (file)
@@ -44,7 +44,7 @@ static void publish_reply(AvahiEntryGroup *g,
  */
 static void register_stuff(void) {
     uint port;
  */
 static void register_stuff(void) {
     uint port;
-    const AFPConfig *config;
+    const AFPObj *obj;
     const struct vol *volume;
     DSI *dsi;
     char name[MAXINSTANCENAMELEN+1];
     const struct vol *volume;
     DSI *dsi;
     char name[MAXINSTANCENAMELEN+1];
@@ -92,16 +92,12 @@ static void register_stuff(void) {
         }
 
         /* AFP server */
         }
 
         /* AFP server */
-        for (config = ctx->configs; config; config = config->next) {
-
-            dsi = (DSI *)config->obj.dsi;
+        for (dsi = obj->dsi; dsi; dsi = dsi->next) {
             port = getip_port((struct sockaddr *)&dsi->server);
 
             port = getip_port((struct sockaddr *)&dsi->server);
 
-            if (convert_string(config->obj.options.unixcharset,
+            if (convert_string(obj->options.unixcharset,
                                CH_UTF8,
                                CH_UTF8,
-                               config->obj.options.server ?
-                               config->obj.options.server :
-                               config->obj.options.hostname,
+                               obj->options.hostname,
                                -1,
                                name,
                                MAXINSTANCENAMELEN) <= 0) {
                                -1,
                                name,
                                MAXINSTANCENAMELEN) <= 0) {
@@ -146,8 +142,8 @@ static void register_stuff(void) {
                 goto fail;
             }  /* if */
 
                 goto fail;
             }  /* if */
 
-            if (config->obj.options.mimicmodel) {
-                strlist2 = avahi_string_list_add_printf(strlist2, "model=%s", config->obj.options.mimicmodel);
+            if (obj->options.mimicmodel) {
+                strlist2 = avahi_string_list_add_printf(strlist2, "model=%s", obj->options.mimicmodel);
                 if (avahi_entry_group_add_service_strlst(ctx->group,
                                                          AVAHI_IF_UNSPEC,
                                                          AVAHI_PROTO_UNSPEC,
                 if (avahi_entry_group_add_service_strlst(ctx->group,
                                                          AVAHI_IF_UNSPEC,
                                                          AVAHI_PROTO_UNSPEC,
@@ -278,7 +274,7 @@ static void client_callback(AvahiClient *client,
  * Tries to setup the Zeroconf thread and any
  * neccessary config setting.
  */
  * Tries to setup the Zeroconf thread and any
  * neccessary config setting.
  */
-void av_zeroconf_register(const AFPConfig *configs) {
+void av_zeroconf_register(const AFPObj *obj) {
     int error;
 
     /* initialize the struct that holds our config settings. */
     int error;
 
     /* initialize the struct that holds our config settings. */
@@ -287,7 +283,7 @@ void av_zeroconf_register(const AFPConfig *configs) {
         avahi_entry_group_reset(ctx->group);
     } else {
         ctx = calloc(1, sizeof(struct context));
         avahi_entry_group_reset(ctx->group);
     } else {
         ctx = calloc(1, sizeof(struct context));
-        ctx->configs = configs;
+        ctx->obj = obj;
         assert(ctx);
     }
 
         assert(ctx);
     }
 
index e516408c6a79e17cc27ad95e7230e3e70e1830bd..f7d0473d0c65be91d483c172b7dda19662df01c2 100644 (file)
@@ -37,11 +37,11 @@ struct context {
   AvahiClient       *client;
   AvahiEntryGroup   *group;
        /* Netatalk stuff */
   AvahiClient       *client;
   AvahiEntryGroup   *group;
        /* Netatalk stuff */
-       const AFPConfig   *configs;
+       const AFPObj      *obj;
 };
 
 /* prototype definitions */
 };
 
 /* prototype definitions */
-void av_zeroconf_register(const AFPConfig *configs);
+void av_zeroconf_register(const AFPObj *obj);
 int av_zeroconf_unregister(void);
 
 #endif   /* AFPD_AVAHI_H */
 int av_zeroconf_unregister(void);
 
 #endif   /* AFPD_AVAHI_H */
index f859637942f5e7ce8ebee2c3afc1bcf3d51ee5fc..1fafee03a04641623c898de1a6af916260911ac7 100644 (file)
@@ -48,14 +48,13 @@ void configfree(AFPObj *obj, DSI *dsi)
 {
     DSI *p, *q;
 
 {
     DSI *p, *q;
 
-    afp_options_free(obj->options);
+    afp_options_free(&obj->options);
 
     for (p = obj->dsi; p; p = q) {
         q = p->next;
         if (p == dsi)
             continue;
         close(p->socket);
 
     for (p = obj->dsi; p; p = q) {
         q = p->next;
         if (p == dsi)
             continue;
         close(p->socket);
-        free(p->dsi);
         free(p);
     }
     if (dsi) {
         free(p);
     }
     if (dsi) {
@@ -76,20 +75,21 @@ int configinit(AFPObj *obj)
     char *p, *q = NULL;
 
     LOG(log_debug, logtype_afpd, "DSIConfigInit: hostname: %s, listen: %s, port: %s",
     char *p, *q = NULL;
 
     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) */
 
 
     /* 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, ',') );
+    EC_NULL( q = p = strdup(obj->options.listen) );
+    EC_NULL( p = strtok(p, ",") );
 
     while (p) {
 
     while (p) {
-        if ((dsi = dsi_init(obj, obj->options->hostname, p, obj->options->port)) == NULL)
+        if ((dsi = dsi_init(obj, obj->options.hostname, p, obj->options.port)) == NULL)
             break;
 
             break;
 
+        status_init(obj, dsi);
         *next = dsi;
         next = &dsi->next;
 
         *next = dsi;
         next = &dsi->next;
 
@@ -97,25 +97,24 @@ int configinit(AFPObj *obj)
             getip_string((struct sockaddr *)&dsi->server),
             getip_port((struct sockaddr *)&dsi->server));
 
             getip_string((struct sockaddr *)&dsi->server),
             getip_port((struct sockaddr *)&dsi->server));
 
-        p = strtok(NULL, ',');
+        p = strtok(NULL, ",");
     }
 
     if (obj->dsi == NULL)
         EC_FAIL;
 
     }
 
     if (obj->dsi == NULL)
         EC_FAIL;
 
-    auth_load(obj->options->uampath, obj->options->uamlist);
-    status_init(obj);
-    set_signature(obj->options);
+    auth_load(obj->options.uampath, obj->options.uamlist);
+    set_signature(&obj->options);
 
 #ifdef HAVE_LDAP
     /* Parse afp_ldap.conf */
 
 #ifdef HAVE_LDAP
     /* Parse afp_ldap.conf */
-    acl_ldap_readconfig(AFPObj->iniconfig);
+    acl_ldap_readconfig(obj->iniconfig);
 #endif /* HAVE_LDAP */
 
     /* Now register with zeroconf, we also need the volumes for that */
 #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);
+        zeroconf_register(obj);
     }
 
 EC_CLEANUP:
     }
 
 EC_CLEANUP:
index 09cad9bb92e35ae243ca17357fd9d352cef95192..bfa93c73d4a6dba22c23a3e95efb21597231daf8 100644 (file)
@@ -3,8 +3,9 @@
 
 #include <atalk/server_child.h>
 #include <atalk/globals.h>
 
 #include <atalk/server_child.h>
 #include <atalk/globals.h>
+#include <atalk/dsi.h>
 
 
-extern AFPConfig *configinit (struct afp_options *);
-extern void configfree (AFPConfig *, const AFPConfig *);
+extern int configinit (AFPObj *);
+extern void configfree (AFPObj *, DSI *);
 
 #endif
 
 #endif
index 47dd4e46ce9610017ebe83f3440b043e140a684c..2869722e6fbca2e6fb3857fa4042073076d3c2d1 100644 (file)
@@ -541,15 +541,15 @@ void afp_over_dsi(AFPObj *obj)
 
             if (debugging) {
                 if (obj->options.logconfig)
 
             if (debugging) {
                 if (obj->options.logconfig)
-                    setuplog(obj->options.logconfig);
+                    setuplog(obj->options.logconfig, obj->options.logfile);
                 else
                 else
-                    setuplog("default log_note");
+                    setuplog("default:note", NULL);
                 debugging = 0;
             } else {
                 char logstr[50];
                 debugging = 1;
                 debugging = 0;
             } else {
                 char logstr[50];
                 debugging = 1;
-                sprintf(logstr, "default log_maxdebug /tmp/afpd.%u.XXXXXX", getpid());
-                setuplog(logstr);
+                sprintf(logstr, "/tmp/afpd.%u.XXXXXX", getpid());
+                setuplog("default:maxdebug", logstr);
             }
         }
 
             }
         }
 
index e39bf3f7217985cd8babe174e8379a6d370666c7..b4e2306d21497af063ed486649bec3c4bbd5cc57 100644 (file)
@@ -36,6 +36,7 @@
 #include <atalk/compat.h>
 #include <atalk/globals.h>
 #include <atalk/fce_api.h>
 #include <atalk/compat.h>
 #include <atalk/globals.h>
 #include <atalk/fce_api.h>
+#include <atalk/errchk.h>
 
 #include "status.h"
 #include "auth.h"
 
 #include "status.h"
 #include "auth.h"
@@ -54,8 +55,8 @@ void afp_options_free(struct afp_options *opt)
         free(opt->fqdn);
     if (opt->guest)
         free(opt->guest);
         free(opt->fqdn);
     if (opt->guest)
         free(opt->guest);
-    if (opt->ipaddr)
-        free(opt->ipaddr);
+    if (opt->listen)
+        free(opt->listen);
     if (opt->k5realm)
         free(opt->k5realm);
     if (opt->k5keytab)
     if (opt->k5realm)
         free(opt->k5realm);
     if (opt->k5keytab)
@@ -64,6 +65,8 @@ void afp_options_free(struct afp_options *opt)
         free(opt->k5service);
     if (opt->logconfig)
         free(opt->logconfig);
         free(opt->k5service);
     if (opt->logconfig)
         free(opt->logconfig);
+    if (opt->logfile)
+        free(opt->logfile);
     if (opt->loginmesg)
         free(opt->loginmesg);
     if (opt->maccodepage)
     if (opt->loginmesg)
         free(opt->loginmesg);
     if (opt->maccodepage)
@@ -78,8 +81,6 @@ void afp_options_free(struct afp_options *opt)
         free(opt->passwdfile);
     if (opt->port)
         free(opt->port);
         free(opt->passwdfile);
     if (opt->port)
         free(opt->port);
-    if (opt->server)
-        free(opt->server);
     if (opt->signatureopt)
         free(opt->signatureopt);
     if (opt->uamlist)
     if (opt->signatureopt)
         free(opt->signatureopt);
     if (opt->uamlist)
@@ -93,10 +94,12 @@ void afp_options_free(struct afp_options *opt)
 #define MAXVAL 1024
 int afp_config_parse(AFPObj *AFPObj)
 {
 #define MAXVAL 1024
 int afp_config_parse(AFPObj *AFPObj)
 {
+    EC_INIT;
     dictionary *config;
     struct afp_options *options = &AFPObj->options;
     dictionary *config;
     struct afp_options *options = &AFPObj->options;
-    int i;
+    int i, c;
     const char *p, *tmp;
     const char *p, *tmp;
+    char *q, *r;
     char val[MAXVAL];
 
     memset(options, 0, sizeof(struct afp_options));
     char val[MAXVAL];
 
     memset(options, 0, sizeof(struct afp_options));
@@ -104,9 +107,16 @@ int afp_config_parse(AFPObj *AFPObj)
     options->sigconffile = strdup(_PATH_CONFDIR "afp_signature.conf");
     options->uuidconf    = strdup(_PATH_CONFDIR "afp_voluuid.conf");
     options->flags |= OPTION_ACL2MACCESS | OPTION_UUID | OPTION_SERVERNOTIF;
     options->sigconffile = strdup(_PATH_CONFDIR "afp_signature.conf");
     options->uuidconf    = strdup(_PATH_CONFDIR "afp_voluuid.conf");
     options->flags |= OPTION_ACL2MACCESS | OPTION_UUID | OPTION_SERVERNOTIF;
+    if (gethostname(val, sizeof(val)) < 0 ) {
+        perror( "gethostname" );
+        return 0;
+    }
+    if (NULL != (q = strchr(val, '.')))
+        *q = '\0';
+    options->hostname = strdup(val);
 
 
-    while (EOF != (p = getopt(AFPObj->argc, AFPObj->argv, "dF:"))) {
-        switch (p) {
+    while ((c = getopt(AFPObj->argc, AFPObj->argv, "dF:")) != -1) {
+        switch (c) {
         case 'd':
             options->flags |= OPTION_DEBUG;
             break;
         case 'd':
             options->flags |= OPTION_DEBUG;
             break;
@@ -125,10 +135,10 @@ int afp_config_parse(AFPObj *AFPObj)
     AFPObj->iniconfig = config;
 
     /* [Global] */
     AFPObj->iniconfig = config;
 
     /* [Global] */
-    options->logconfig = iniparser_getstring(config, INISEC_GLOBAL, "loglevel", "default:note");
-    options->logfile   = iniparser_getstring(config, INISEC_GLOBAL, "logfile",  NULL);
+    options->logconfig = iniparser_getstrdup(config, INISEC_GLOBAL, "loglevel", "default:note");
+    options->logfile   = iniparser_getstrdup(config, INISEC_GLOBAL, "logfile",  NULL);
     set_processname("afpd");
     set_processname("afpd");
-    setuplog(logconfig, logfile);
+    setuplog(options->logconfig, options->logfile);
 
     /* [AFP] "options" options wo values */
     p = iniparser_getstring(config, INISEC_AFP, "options", "");
 
     /* [AFP] "options" options wo values */
     p = iniparser_getstring(config, INISEC_AFP, "options", "");
@@ -190,7 +200,7 @@ int afp_config_parse(AFPObj *AFPObj)
     options->tcp_rcvbuf     = iniparser_getint   (config, INISEC_AFP, "tcprcvbuf",      0);
     options->fce_fmodwait   = iniparser_getint   (config, INISEC_AFP, "fceholdfmod",    60);
     options->sleep          = iniparser_getint   (config, INISEC_AFP, "sleep",          10) * 60 * 2;
     options->tcp_rcvbuf     = iniparser_getint   (config, INISEC_AFP, "tcprcvbuf",      0);
     options->fce_fmodwait   = iniparser_getint   (config, INISEC_AFP, "fceholdfmod",    60);
     options->sleep          = iniparser_getint   (config, INISEC_AFP, "sleep",          10) * 60 * 2;
-    options->disconnect     = iniparser_getint   (config, INISEC_AFP, "disconnect"      24) * 60 * 2;
+    options->disconnected   = iniparser_getint   (config, INISEC_AFP, "disconnect",     24) * 60 * 2;
 
 
     if ((p = iniparser_getstring(config, INISEC_AFP, "k5keytab", NULL))) {
 
 
     if ((p = iniparser_getstring(config, INISEC_AFP, "k5keytab", NULL))) {
@@ -207,29 +217,30 @@ int afp_config_parse(AFPObj *AFPObj)
     }
 #endif /* ADMIN_GRP */
 
     }
 #endif /* ADMIN_GRP */
 
-    p = iniparser_getstring(config, INISEC_AFP, "cnidserver", "localhost:4700");
-    tmp = strrchr(p, ':');
-    if (tmp)
-        *t = 0;
-    options->Cnid_srv = strdup(p);
-    if (tmp)
-        options->Cnid_port = strdup(tmp + 1);
+    q = iniparser_getstrdup(config, INISEC_AFP, "cnidserver", "localhost:4700");
+    r = strrchr(q, ':');
+    if (r)
+        *r = 0;
+    options->Cnid_srv = strdup(q);
+    if (r)
+        options->Cnid_port = strdup(r + 1);
     LOG(log_debug, logtype_afpd, "CNID Server: %s:%s", options->Cnid_srv, options->Cnid_port);
     LOG(log_debug, logtype_afpd, "CNID Server: %s:%s", options->Cnid_srv, options->Cnid_port);
+    if (q)
+        free(q);
 
 
-
-    if ((p = iniparser_getstring(config, INISEC_AFP, "fqdn", NULL))) {
+    if ((q = iniparser_getstrdup(config, INISEC_AFP, "fqdn", NULL))) {
         /* do a little checking for the domain name. */
         /* do a little checking for the domain name. */
-        tmp = strchr(c, ':');
-        if (tmp)
-            *tmp = '\0';
-        if (gethostbyname(p)) {
-            if (tmp)
-                *tmp = ':';
-            if ((opt = strdup(p)))
-                options->fqdn = opt;
+        r = strchr(q, ':');
+        if (r)
+            *r = '\0';
+        if (gethostbyname(q)) {
+            if (r)
+                *r = ':';
+            EC_NULL_LOG( options->fqdn = strdup(q) );
         } else {
             LOG(log_error, logtype_afpd, "error parsing -fqdn, gethostbyname failed for: %s", c);
         }
         } else {
             LOG(log_error, logtype_afpd, "error parsing -fqdn, gethostbyname failed for: %s", c);
         }
+        free(q);
     }
 
     p = iniparser_getstring(config, INISEC_AFP, "unixcodepage", "LOCALE");
     }
 
     p = iniparser_getstring(config, INISEC_AFP, "unixcodepage", "LOCALE");
@@ -245,7 +256,7 @@ int afp_config_parse(AFPObj *AFPObj)
         options->maccharset = CH_MAC;
         LOG(log_warning, logtype_afpd, "Setting Unix codepage to '%s' failed", p);
     } else {
         options->maccharset = CH_MAC;
         LOG(log_warning, logtype_afpd, "Setting Unix codepage to '%s' failed", p);
     } else {
-        options->maccharset = strdup(p);
+        options->maccodepage = strdup(p);
     }
 
     if ((p = iniparser_getstring(config, INISEC_AFP, "fcelistener", NULL))) {
     }
 
     if ((p = iniparser_getstring(config, INISEC_AFP, "fcelistener", NULL))) {
@@ -275,7 +286,8 @@ int afp_config_parse(AFPObj *AFPObj)
     if (options->volnamelen > 255)
            options->volnamelen = 255; /* AFP3 spec */
 
     if (options->volnamelen > 255)
            options->volnamelen = 255; /* AFP3 spec */
 
-    return 0;
+EC_CLEANUP:
+    EC_EXIT;
 }
 
 /*
 }
 
 /*
@@ -404,16 +416,9 @@ static void show_version_extended(void )
  */
 static void show_paths( void )
 {
  */
 static void show_paths( void )
 {
-       printf( "             afpd.conf:\t%s\n", _PATH_AFPDCONF );
-       printf( "   AppleVolumes.system:\t%s\n", _PATH_AFPDSYSVOL );
-       printf( "  AppleVolumes.default:\t%s\n", _PATH_AFPDDEFVOL );
-       printf( "    afp_signature.conf:\t%s\n", _PATH_AFPDSIGCONF );
-       printf( "      afp_voluuid.conf:\t%s\n", _PATH_AFPDUUIDCONF );
-#ifdef HAVE_LDAP
-       printf( "         afp_ldap.conf:\t%s\n", _PATH_ACL_LDAPCONF );
-#else
-       printf( "         afp_ldap.conf:\tnot supported\n");
-#endif
+       printf( "              afp.conf:\t%s\n", _PATH_CONFDIR "afp.conf");
+       printf( "    afp_signature.conf:\t%s\n", _PATH_CONFDIR "afp_signature.conf");
+       printf( "      afp_voluuid.conf:\t%s\n", _PATH_CONFDIR "afp_voluuid.conf");
        printf( "       UAM search path:\t%s\n", _PATH_AFPDUAMPATH );
        printf( "  Server messages path:\t%s\n", SERVERTEXT);
        printf( "              lockfile:\t%s\n", _PATH_AFPDLOCK);
        printf( "       UAM search path:\t%s\n", _PATH_AFPDUAMPATH );
        printf( "  Server messages path:\t%s\n", SERVERTEXT);
        printf( "              lockfile:\t%s\n", _PATH_AFPDLOCK);
@@ -430,20 +435,11 @@ static void show_usage( char *name )
        fprintf( stderr, "\t%s -h|-v|-V\n", name );
 }
 
        fprintf( stderr, "\t%s -h|-v|-V\n", name );
 }
 
-int afp_options_parse_cmdline(int ac, char **av)
+void afp_options_parse_cmdline(int ac, char **av)
 {
     char *p;
     char *tmp; /* Used for error checking the result of strtol */
     int c, err = 0;
 {
     char *p;
     char *tmp; /* Used for error checking the result of strtol */
     int c, err = 0;
-    char buf[1024];
-
-    if (gethostname(buf, sizeof(buf)) < 0 ) {
-        perror( "gethostname" );
-        return 0;
-    }
-    if (NULL != (p = strchr(buf, '.')))
-        *p = '\0';
-    options->hostname = strdup(buf);
 
     while (EOF != ( c = getopt( ac, av, "vVh" )) ) {
         switch ( c ) {
 
     while (EOF != ( c = getopt( ac, av, "vVh" )) ) {
         switch ( c ) {
@@ -470,5 +466,5 @@ int afp_options_parse_cmdline(int ac, char **av)
         exit( 2 );
     }
 
         exit( 2 );
     }
 
-    return 1;
+    return;
 }
 }
index d6fa657728b568ee1fe5b9a547ab02fc3b10990b..64347be3f330d18d7c458096f4b3b97adf321ddf 100644 (file)
@@ -22,7 +22,7 @@
 /*
  * Functions (actually they are just facades)
  */
 /*
  * Functions (actually they are just facades)
  */
-void zeroconf_register(const AFPConfig *configs)
+void zeroconf_register(const AFPObj *configs)
 {
 #if defined (HAVE_AVAHI)
   LOG(log_debug, logtype_afpd, "Attempting to register with mDNS using Avahi");
 {
 #if defined (HAVE_AVAHI)
   LOG(log_debug, logtype_afpd, "Attempting to register with mDNS using Avahi");
index e2711afb3a4a680d7c1f8ad063a2922b616f409e..5058cc60d3f987bce36cf601305fd90a4ece0ba1 100644 (file)
@@ -19,7 +19,7 @@
 /*
  * registers service with a particular Zerconf implemenation.
  */
 /*
  * registers service with a particular Zerconf implemenation.
  */
-void zeroconf_register(const AFPConfig *configs);
+void zeroconf_register(const AFPObj *obj);
 
 /*
  * de-registers the ntpd service with a particular Zerconf implemenation.
 
 /*
  * de-registers the ntpd service with a particular Zerconf implemenation.
index d6382c84118bda9b89f4b801af9b520805494840..aff77956e69b55bb6cfd2fe63b92d41cf11d31ea 100644 (file)
@@ -655,9 +655,6 @@ static int get_version(AFPObj *obj, char *ibuf, size_t ibuflen, size_t len)
     if ( i == num )                 /* An inappropo version */
         return AFPERR_BADVERS ;
 
     if ( i == num )                 /* An inappropo version */
         return AFPERR_BADVERS ;
 
-    if (afp_version >= 30 && obj->proto != AFPPROTO_DSI)
-        return AFPERR_BADVERS ;
-
     /* FIXME Hack */
     if (afp_version >= 30 && sizeof(off_t) != 8) {
         LOG(log_error, logtype_afpd, "get_version: no LARGE_FILE support recompile!" );
     /* FIXME Hack */
     if (afp_version >= 30 && sizeof(off_t) != 8) {
         LOG(log_error, logtype_afpd, "get_version: no LARGE_FILE support recompile!" );
index c03f07691d689119001d603adbf40dcf78ab0f1d..258f3e5fc04735307a24dd30a33b40a08d1280fc 100644 (file)
@@ -204,42 +204,34 @@ int afp_addicon(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t
      */
 addicon_err:
     if ( cc < 0 ) {
      */
 addicon_err:
     if ( cc < 0 ) {
-        if (obj->proto == AFPPROTO_DSI) {
-            dsi_writeinit(obj->dsi, rbuf, buflen);
-            dsi_writeflush(obj->dsi);
-        }
+        dsi_writeinit(obj->dsi, rbuf, buflen);
+        dsi_writeflush(obj->dsi);
         return cc;
     }
 
         return cc;
     }
 
-    switch (obj->proto) {
-    case AFPPROTO_DSI:
-        {
-            DSI *dsi = obj->dsi;
+    DSI *dsi = obj->dsi;
 
 
-            iovcnt = dsi_writeinit(dsi, rbuf, buflen);
+    iovcnt = dsi_writeinit(dsi, rbuf, buflen);
 
 
-            /* add headers at end of file */
-            if ((cc == 0) && (write(si.sdt_fd, imh, sizeof(imh)) < 0)) {
-                LOG(log_error, logtype_afpd, "afp_addicon(%s): write: %s", icon_dtfile(vol, fcreator), strerror(errno));
-                dsi_writeflush(dsi);
-                return AFPERR_PARAM;
-            }
+    /* add headers at end of file */
+    if ((cc == 0) && (write(si.sdt_fd, imh, sizeof(imh)) < 0)) {
+        LOG(log_error, logtype_afpd, "afp_addicon(%s): write: %s", icon_dtfile(vol, fcreator), strerror(errno));
+        dsi_writeflush(dsi);
+        return AFPERR_PARAM;
+    }
 
 
-            if ((cc = write(si.sdt_fd, rbuf, iovcnt)) < 0) {
-                LOG(log_error, logtype_afpd, "afp_addicon(%s): write: %s", icon_dtfile(vol, fcreator), strerror(errno));
-                dsi_writeflush(dsi);
-                return AFPERR_PARAM;
-            }
+    if ((cc = write(si.sdt_fd, rbuf, iovcnt)) < 0) {
+        LOG(log_error, logtype_afpd, "afp_addicon(%s): write: %s", icon_dtfile(vol, fcreator), strerror(errno));
+        dsi_writeflush(dsi);
+        return AFPERR_PARAM;
+    }
 
 
-            while ((iovcnt = dsi_write(dsi, rbuf, buflen))) {
-                if ((cc = write(si.sdt_fd, rbuf, iovcnt)) < 0) {
-                    LOG(log_error, logtype_afpd, "afp_addicon(%s): write: %s", icon_dtfile(vol, fcreator), strerror(errno));
-                    dsi_writeflush(dsi);
-                    return AFPERR_PARAM;
-                }
-            }
+    while ((iovcnt = dsi_write(dsi, rbuf, buflen))) {
+        if ((cc = write(si.sdt_fd, rbuf, iovcnt)) < 0) {
+            LOG(log_error, logtype_afpd, "afp_addicon(%s): write: %s", icon_dtfile(vol, fcreator), strerror(errno));
+            dsi_writeflush(dsi);
+            return AFPERR_PARAM;
         }
         }
-        break;
     }
 
     close( si.sdt_fd );
     }
 
     close( si.sdt_fd );
@@ -441,7 +433,7 @@ int afp_geticon(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t
 #define min(a,b)       ((a)<(b)?(a):(b))
     rc = min( bsize, rsize );
 
 #define min(a,b)       ((a)<(b)?(a):(b))
     rc = min( bsize, rsize );
 
-    if ((obj->proto == AFPPROTO_DSI) && (buflen < rc)) {
+    if (buflen < rc) {
         DSI *dsi = obj->dsi;
         struct stat st;
         off_t size;
         DSI *dsi = obj->dsi;
         struct stat st;
         off_t size;
index 672adac82d9be151e8ba5d552ad2877cb7fd338a..75bc3f4ba2292f8048c8a607dd8b731ce746d700 100644 (file)
@@ -172,7 +172,7 @@ bool fce_handle_coalescation( char *path, int is_dir, int mode )
  * all|delete|create
  */
 
  * all|delete|create
  */
 
-int fce_set_coalesce(char *opt)
+int fce_set_coalesce(const char *opt)
 {
     char *e;
     char *p;
 {
     char *e;
     char *p;
index 06ba8c19d5b99e17961dbdd856c1db5efe2018ba..c8101048e038ecbc52c1acd6db978047435c2234 100644 (file)
@@ -76,22 +76,16 @@ static int default_type(void *finder)
 /* FIXME path : unix or mac name ? (for now it's unix name ) */
 void *get_finderinfo(const struct vol *vol, const char *upath, struct adouble *adp, void *data, int islink)
 {
 /* FIXME path : unix or mac name ? (for now it's unix name ) */
 void *get_finderinfo(const struct vol *vol, const char *upath, struct adouble *adp, void *data, int islink)
 {
-    struct extmap      *em;
     void                *ad_finder = NULL;
     int                 chk_ext = 0;
     void                *ad_finder = NULL;
     int                 chk_ext = 0;
-    
-    if (adp)
+
         ad_finder = ad_entry(adp, ADEID_FINDERI);
 
     if (ad_finder) {
         memcpy(data, ad_finder, ADEDLEN_FINDERI);
         ad_finder = ad_entry(adp, ADEID_FINDERI);
 
     if (ad_finder) {
         memcpy(data, ad_finder, ADEDLEN_FINDERI);
-        /* default type ? */
-        if (default_type(ad_finder)) 
-            chk_ext = 1;
     }
     else {
         memcpy(data, ufinderi, ADEDLEN_FINDERI);
     }
     else {
         memcpy(data, ufinderi, ADEDLEN_FINDERI);
-        chk_ext = 1;
         if (vol_inv_dots(vol) && *upath == '.') { /* make it invisible */
             uint16_t ashort;
             
         if (vol_inv_dots(vol) && *upath == '.') { /* make it invisible */
             uint16_t ashort;
             
@@ -107,14 +101,8 @@ void *get_finderinfo(const struct vol *vol, const char *upath, struct adouble *a
         memcpy((char *)data + FINDERINFO_FRFLAGOFF, &linkflag, 2);
         memcpy((char *)data + FINDERINFO_FRTYPEOFF,"slnk",4); 
         memcpy((char *)data + FINDERINFO_FRCREATOFF,"rhap",4); 
         memcpy((char *)data + FINDERINFO_FRFLAGOFF, &linkflag, 2);
         memcpy((char *)data + FINDERINFO_FRTYPEOFF,"slnk",4); 
         memcpy((char *)data + FINDERINFO_FRCREATOFF,"rhap",4); 
-        chk_ext = 0;
     }
 
     }
 
-    /** Only enter if no appledouble information and no finder information found. */
-    if (chk_ext && (em = getextmap( upath ))) {
-        memcpy(data, em->em_type, sizeof( em->em_type ));
-        memcpy((char *)data + 4, em->em_creator, sizeof(em->em_creator));
-    }
     return data;
 }
 
     return data;
 }
 
@@ -1004,17 +992,6 @@ int setfilparams(struct vol *vol,
             ad_setdate(adp, AD_DATE_BACKUP, bdate);
             break;
         case FILPBIT_FINFO :
             ad_setdate(adp, AD_DATE_BACKUP, bdate);
             break;
         case FILPBIT_FINFO :
-            if (default_type( ad_entry( adp, ADEID_FINDERI ))
-                    && ( 
-                     ((em = getextmap( path->m_name )) &&
-                      !memcmp(finder_buf, em->em_type, sizeof( em->em_type )) &&
-                      !memcmp(finder_buf + 4, em->em_creator,sizeof( em->em_creator)))
-                     || ((em = getdefextmap()) &&
-                      !memcmp(finder_buf, em->em_type, sizeof( em->em_type )) &&
-                      !memcmp(finder_buf + 4, em->em_creator,sizeof( em->em_creator)))
-            )) {
-                memcpy(finder_buf, ufinderi, 8 );
-            }
             memcpy(ad_entry( adp, ADEID_FINDERI ), finder_buf, 32 );
             break;
         case FILPBIT_UNIXPR :
             memcpy(ad_entry( adp, ADEID_FINDERI ), finder_buf, 32 );
             break;
         case FILPBIT_UNIXPR :
index 8e0ba7325bfd450c3b7f9003198c013494fec151..89f15e18ac23e9a60fae0333354d20b0bc8d7620 100644 (file)
@@ -851,7 +851,7 @@ static int read_fork(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, si
 
     /* dsi can stream requests. we can only do this if we're not checking
      * for an end-of-line character. oh well. */
 
     /* dsi can stream requests. we can only do this if we're not checking
      * for an end-of-line character. oh well. */
-    if ((obj->proto == AFPPROTO_DSI) && (*rbuflen < reqcount) && !nlmask) {
+    if ((*rbuflen < reqcount) && !nlmask) {
         DSI    *dsi = obj->dsi;
         off_t  size;
 
         DSI    *dsi = obj->dsi;
         off_t  size;
 
@@ -1191,63 +1191,56 @@ static int write_fork(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, s
         goto afp_write_err;
     }
 
         goto afp_write_err;
     }
 
-    /* this is yucky, but dsi can stream i/o and asp can't */
-    switch (obj->proto) {
-    case AFPPROTO_DSI:
-    {
-        DSI *dsi = obj->dsi;
-        /* find out what we have already and write it out. */
-        cc = dsi_writeinit(dsi, rbuf, *rbuflen);
+    DSI *dsi = obj->dsi;
+    /* find out what we have already and write it out. */
+    cc = dsi_writeinit(dsi, rbuf, *rbuflen);
 
 
-        if (!cc || (cc = write_file(ofork, eid, offset, rbuf, cc)) < 0) {
+    if (!cc || (cc = write_file(ofork, eid, offset, rbuf, cc)) < 0) {
+        dsi_writeflush(dsi);
+        *rbuflen = 0;
+        ad_tmplock(ofork->of_ad, eid, ADLOCK_CLR, saveoff, reqcount, ofork->of_refnum);
+        return cc;
+    }
+
+    offset += cc;
+
+#if 0 /*def HAVE_SENDFILE_WRITE*/
+    if (!(obj->options.flags & OPTION_DEBUG)) {
+        if ((cc = ad_writefile(ofork->of_ad, eid, dsi->socket,
+                               offset, dsi->datasize)) < 0) {
+            switch (errno) {
+            case EDQUOT :
+            case EFBIG :
+            case ENOSPC :
+                cc = AFPERR_DFULL;
+                break;
+            default :
+                LOG(log_error, logtype_afpd, "afp_write: ad_writefile: %s", strerror(errno) );
+                goto afp_write_loop;
+            }
             dsi_writeflush(dsi);
             *rbuflen = 0;
             dsi_writeflush(dsi);
             *rbuflen = 0;
-            ad_tmplock(ofork->of_ad, eid, ADLOCK_CLR, saveoff, reqcount, ofork->of_refnum);
+            ad_tmplock(ofork->of_ad, eid, ADLOCK_CLR, saveoff,
+                       reqcount,  ofork->of_refnum);
             return cc;
         }
 
         offset += cc;
             return cc;
         }
 
         offset += cc;
-
-#if 0 /*def HAVE_SENDFILE_WRITE*/
-        if (!(obj->options.flags & OPTION_DEBUG)) {
-            if ((cc = ad_writefile(ofork->of_ad, eid, dsi->socket,
-                                   offset, dsi->datasize)) < 0) {
-                switch (errno) {
-                case EDQUOT :
-                case EFBIG :
-                case ENOSPC :
-                    cc = AFPERR_DFULL;
-                    break;
-                default :
-                    LOG(log_error, logtype_afpd, "afp_write: ad_writefile: %s", strerror(errno) );
-                    goto afp_write_loop;
-                }
-                dsi_writeflush(dsi);
-                *rbuflen = 0;
-                ad_tmplock(ofork->of_ad, eid, ADLOCK_CLR, saveoff,
-                           reqcount,  ofork->of_refnum);
-                return cc;
-            }
-
-            offset += cc;
-            goto afp_write_done;
-        }
+        goto afp_write_done;
+    }
 #endif /* 0, was HAVE_SENDFILE_WRITE */
 
 #endif /* 0, was HAVE_SENDFILE_WRITE */
 
-        /* loop until everything gets written. currently
-         * dsi_write handles the end case by itself. */
-        while ((cc = dsi_write(dsi, rbuf, *rbuflen))) {
-            if ((cc = write_file(ofork, eid, offset, rbuf, cc)) < 0) {
-                dsi_writeflush(dsi);
-                *rbuflen = 0;
-                ad_tmplock(ofork->of_ad, eid, ADLOCK_CLR, saveoff,
-                           reqcount,  ofork->of_refnum);
-                return cc;
-            }
-            offset += cc;
+    /* loop until everything gets written. currently
+     * dsi_write handles the end case by itself. */
+    while ((cc = dsi_write(dsi, rbuf, *rbuflen))) {
+        if ((cc = write_file(ofork, eid, offset, rbuf, cc)) < 0) {
+            dsi_writeflush(dsi);
+            *rbuflen = 0;
+            ad_tmplock(ofork->of_ad, eid, ADLOCK_CLR, saveoff,
+                       reqcount,  ofork->of_refnum);
+            return cc;
         }
         }
-    }
-    break;
+        offset += cc;
     }
 
     ad_tmplock(ofork->of_ad, eid, ADLOCK_CLR, saveoff, reqcount,  ofork->of_refnum);
     }
 
     ad_tmplock(ofork->of_ad, eid, ADLOCK_CLR, saveoff, reqcount,  ofork->of_refnum);
@@ -1264,10 +1257,9 @@ static int write_fork(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, s
     return( AFP_OK );
 
 afp_write_err:
     return( AFP_OK );
 
 afp_write_err:
-    if (obj->proto == AFPPROTO_DSI) {
-        dsi_writeinit(obj->dsi, rbuf, *rbuflen);
-        dsi_writeflush(obj->dsi);
-    }
+    dsi_writeinit(obj->dsi, rbuf, *rbuflen);
+    dsi_writeflush(obj->dsi);
+
     if (err != AFP_OK) {
         *rbuflen = 0;
     }
     if (err != AFP_OK) {
         *rbuflen = 0;
     }
index d96d52dbd79022f6e965431316d5fa184ae54e94..8729fc12466134ab0875576df3dd4bf42b3c191a 100644 (file)
@@ -43,7 +43,7 @@
 
 unsigned char nologin = 0;
 
 
 unsigned char nologin = 0;
 
-static AFPObj AFPObj;
+static AFPObj obj;
 static server_child *server_children;
 static sig_atomic_t reloadconfig = 0;
 static sig_atomic_t gotsigchld = 0;
 static server_child *server_children;
 static sig_atomic_t reloadconfig = 0;
 static sig_atomic_t gotsigchld = 0;
@@ -62,7 +62,7 @@ static void afp_exit(void)
 {
     if (parent_or_child == 0)
         /* Only do this in the parent */
 {
     if (parent_or_child == 0)
         /* Only do this in the parent */
-        server_unlock(default_options.pidfile);
+        server_unlock(_PATH_AFPDLOCK);
 }
 
 
 }
 
 
@@ -71,7 +71,7 @@ static void afp_exit(void)
 */
 static void fd_set_listening_sockets(const AFPObj *config)
 {
 */
 static void fd_set_listening_sockets(const AFPObj *config)
 {
-    const DSI *dsi;
+    DSI *dsi;
 
     for (dsi = config->dsi; dsi; dsi = dsi->next) {
         fdset_add_fd(config->options.connections + AFP_LISTENERS + FDSET_SAFETY,
 
     for (dsi = config->dsi; dsi; dsi = dsi->next) {
         fdset_add_fd(config->options.connections + AFP_LISTENERS + FDSET_SAFETY,
@@ -119,7 +119,7 @@ static void afp_goaway(int sig)
             LOG(log_note, logtype_afpd, "AFP Server shutting down on SIGTERM");
             break;
         case SIGQUIT:
             LOG(log_note, logtype_afpd, "AFP Server shutting down on SIGTERM");
             break;
         case SIGQUIT:
-            if (default_options.flags & OPTION_KEEPSESSIONS) {
+            if (obj.options.flags & OPTION_KEEPSESSIONS) {
                 LOG(log_note, logtype_afpd, "AFP Server shutting down on SIGQUIT, NOT disconnecting clients");
             } else {
                 LOG(log_note, logtype_afpd, "AFP Server shutting down on SIGQUIT");
                 LOG(log_note, logtype_afpd, "AFP Server shutting down on SIGQUIT, NOT disconnecting clients");
             } else {
                 LOG(log_note, logtype_afpd, "AFP Server shutting down on SIGQUIT");
@@ -130,8 +130,8 @@ static void afp_goaway(int sig)
         if (server_children)
             server_child_kill(server_children, CHILD_DSIFORK, sig);
 
         if (server_children)
             server_child_kill(server_children, CHILD_DSIFORK, sig);
 
-        server_unlock(AFPObj->options.pidfile);
-        exit(0);
+        server_unlock(_PATH_AFPDLOCK);
+        _exit(0);
         break;
 
     case SIGUSR1 :
         break;
 
     case SIGUSR1 :
@@ -220,15 +220,16 @@ int main(int ac, char **av)
     int                 ret;
 
     /* Parse argv args and initialize default options */
     int                 ret;
 
     /* Parse argv args and initialize default options */
-    AFPObj.argc = ac;
-    AFPObj.argv = av;
-    if (afp_config_parse(&AFPObj) != 0)
+    afp_options_parse_cmdline(ac, av);
+    obj.argc = ac;
+    obj.argv = av;
+    if (afp_config_parse(&obj) != 0)
         exit(EXITERR_CONF);
 
     if (check_lockfile("afpd", _PATH_AFPDLOCK) != 0)
         exit(EXITERR_SYS);
 
         exit(EXITERR_CONF);
 
     if (check_lockfile("afpd", _PATH_AFPDLOCK) != 0)
         exit(EXITERR_SYS);
 
-    if (!(AFPObj.options.flags & OPTION_DEBUG) && (daemonize(0, 0) != 0))
+    if (!(obj.options.flags & OPTION_DEBUG) && (daemonize(0, 0) != 0))
         exit(EXITERR_SYS);
 
     if (create_lockfile("afpd", _PATH_AFPDLOCK) != 0)
         exit(EXITERR_SYS);
 
     if (create_lockfile("afpd", _PATH_AFPDLOCK) != 0)
@@ -239,13 +240,12 @@ int main(int ac, char **av)
     atexit(afp_exit);
 
     /* Save the user's current umask */
     atexit(afp_exit);
 
     /* Save the user's current umask */
-    AFPObj.options.save_mask = umask(AFPObj.options.umask);
+    obj.options.save_mask = umask(obj.options.umask);
 
     /* install child handler for asp and dsi. we do this before afp_goaway
      * as afp_goaway references stuff from here. 
      * XXX: this should really be setup after the initial connections. */
 
     /* install child handler for asp and dsi. we do this before afp_goaway
      * as afp_goaway references stuff from here. 
      * XXX: this should really be setup after the initial connections. */
-    if (!(server_children = server_child_alloc(AFPObj.options.connections,
-                                               CHILD_NFORKS))) {
+    if (!(server_children = server_child_alloc(obj.options.connections, CHILD_NFORKS))) {
         LOG(log_error, logtype_afpd, "main: server_child alloc: %s", strerror(errno) );
         exit(EXITERR_SYS);
     }
         LOG(log_error, logtype_afpd, "main: server_child alloc: %s", strerror(errno) );
         exit(EXITERR_SYS);
     }
@@ -343,7 +343,7 @@ int main(int ac, char **av)
     sigaddset(&sigs, SIGCHLD);
 
     pthread_sigmask(SIG_BLOCK, &sigs, NULL);
     sigaddset(&sigs, SIGCHLD);
 
     pthread_sigmask(SIG_BLOCK, &sigs, NULL);
-    if (configinit(&AFPObj) != 0) {
+    if (configinit(&obj) != 0) {
         LOG(log_error, logtype_afpd, "main: no servers configured");
         exit(EXITERR_CONF);
     }
         LOG(log_error, logtype_afpd, "main: no servers configured");
         exit(EXITERR_CONF);
     }
@@ -354,12 +354,12 @@ int main(int ac, char **av)
     
     /* watch atp, dsi sockets and ipc parent/child file descriptor. */
 
     
     /* watch atp, dsi sockets and ipc parent/child file descriptor. */
 
-    if (AFPObj.options.flags & OPTION_KEEPSESSIONS) {
+    if (obj.options.flags & OPTION_KEEPSESSIONS) {
         LOG(log_note, logtype_afpd, "Activating continous service");
         disasociated_ipc_fd = ipc_server_uds(_PATH_AFP_IPC);
     }
 
         LOG(log_note, logtype_afpd, "Activating continous service");
         disasociated_ipc_fd = ipc_server_uds(_PATH_AFP_IPC);
     }
 
-    fd_set_listening_sockets(&AFPObj);
+    fd_set_listening_sockets(&obj);
 
     /* set limits */
     (void)setlimits();
 
     /* set limits */
     (void)setlimits();
@@ -391,17 +391,17 @@ int main(int ac, char **av)
         if (reloadconfig) {
             nologin++;
             auth_unload();
         if (reloadconfig) {
             nologin++;
             auth_unload();
-            fd_reset_listening_sockets(&AFPObj);
+            fd_reset_listening_sockets(&obj);
 
             LOG(log_info, logtype_afpd, "re-reading configuration file");
 
 
             LOG(log_info, logtype_afpd, "re-reading configuration file");
 
-            configfree(&AFPObj, NULL);
-            if (configinit(&AFPObj) != 0) {
+            configfree(&obj, NULL);
+            if (configinit(&obj) != 0) {
                 LOG(log_error, logtype_afpd, "config re-read: no servers configured");
                 exit(EXITERR_CONF);
             }
 
                 LOG(log_error, logtype_afpd, "config re-read: no servers configured");
                 exit(EXITERR_CONF);
             }
 
-            fd_set_listening_sockets(&AFPObj);
+            fd_set_listening_sockets(&obj);
 
             nologin = 0;
             reloadconfig = 0;
 
             nologin = 0;
             reloadconfig = 0;
@@ -424,9 +424,9 @@ int main(int ac, char **av)
                 switch (polldata[i].fdtype) {
 
                 case LISTEN_FD:
                 switch (polldata[i].fdtype) {
 
                 case LISTEN_FD:
-                    if (child = dsi_start(AFPObj, (DSI *)polldata[i].data, server_children)) {
+                    if (child = dsi_start(&obj, (DSI *)polldata[i].data, server_children)) {
                         /* Add IPC fd to select fd set */
                         /* Add IPC fd to select fd set */
-                        fdset_add_fd(AFPObj.options.connections + AFP_LISTENERS + FDSET_SAFETY,
+                        fdset_add_fd(obj.options.connections + AFP_LISTENERS + FDSET_SAFETY,
                                      &fdset,
                                      &polldata,
                                      &fdset_used,
                                      &fdset,
                                      &polldata,
                                      &fdset_used,
@@ -445,7 +445,7 @@ int main(int ac, char **av)
                         fdset_del_fd(&fdset, &polldata, &fdset_used, &fdset_size, child->ipc_fds[0]);
                         close(child->ipc_fds[0]);
                         child->ipc_fds[0] = -1;
                         fdset_del_fd(&fdset, &polldata, &fdset_used, &fdset_size, child->ipc_fds[0]);
                         close(child->ipc_fds[0]);
                         child->ipc_fds[0] = -1;
-                        if ((AFPObj.options.flags & OPTION_KEEPSESSIONS) && child->disasociated) {
+                        if ((obj.options.flags & OPTION_KEEPSESSIONS) && child->disasociated) {
                             LOG(log_note, logtype_afpd, "main: removing reattached child[%u]", child->pid);
                             server_child_remove(server_children, CHILD_DSIFORK, child->pid);
                         }
                             LOG(log_note, logtype_afpd, "main: removing reattached child[%u]", child->pid);
                             server_child_remove(server_children, CHILD_DSIFORK, child->pid);
                         }
@@ -470,7 +470,7 @@ int main(int ac, char **av)
                         break;
                     }
                     child->disasociated = 1;
                         break;
                     }
                     child->disasociated = 1;
-                    fdset_add_fd(AFPObj.options.connections + AFP_LISTENERS + FDSET_SAFETY,
+                    fdset_add_fd(obj.options.connections + AFP_LISTENERS + FDSET_SAFETY,
                                  &fdset,
                                  &polldata,
                                  &fdset_used,
                                  &fdset,
                                  &polldata,
                                  &fdset_used,
index cd3f32f78545ab79d39764a0ccd60d92ae94f7ae..e2dd1535c443a60a13a35d353603721a30b77e55 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "misc.h"
 
 
 #include "misc.h"
 
-
 #define MAXMESGSIZE 199
 
 /* this is only used by afpd children, so it's okay. */
 #define MAXMESGSIZE 199
 
 /* this is only used by afpd children, so it's okay. */
@@ -44,7 +43,7 @@ void readmessage(AFPObj *obj)
     uid_t euid;
     uint32_t maxmsgsize;
 
     uid_t euid;
     uint32_t maxmsgsize;
 
-    maxmsgsize = (obj->proto == AFPPROTO_DSI)?MIN(MAX(((DSI*)obj->dsi)->attn_quantum, MAXMESGSIZE),MAXPATHLEN):MAXMESGSIZE;
+    maxmsgsize = MIN(MAX(obj->dsi->attn_quantum, MAXMESGSIZE), MAXPATHLEN);
 
     i=0;
     /* Construct file name SERVERTEXT/message.[pid] */
 
     i=0;
     /* Construct file name SERVERTEXT/message.[pid] */
@@ -121,7 +120,7 @@ int afp_getsrvrmesg(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, siz
 
     *rbuflen = 0;
 
 
     *rbuflen = 0;
 
-    msgsize = (obj->proto == AFPPROTO_DSI)?MAX(((DSI*)obj->dsi)->attn_quantum, MAXMESGSIZE):MAXMESGSIZE;
+    msgsize = MAX(obj->dsi->attn_quantum, MAXMESGSIZE);
 
     memcpy(&type, ibuf + 2, sizeof(type));
     memcpy(&bitmap, ibuf + 4, sizeof(bitmap));
 
     memcpy(&type, ibuf + 2, sizeof(type));
     memcpy(&bitmap, ibuf + 4, sizeof(bitmap));
index 4aa134e9f78c15c55cb87a68f1a346bb5f18ef62..0f45ce4571ab7cf1cdc0c1cbb1af4582b1419313 100644 (file)
@@ -364,7 +364,7 @@ static size_t status_utf8servername(char *data, int *nameoffset,
      */
 
     /* extract the obj part of the server */
      */
 
     /* extract the obj part of the server */
-    Obj = (char *) (options->server ? options->server : options->hostname);
+    Obj = options->hostname;
     if ((size_t) -1 == (len = convert_string (
                             options->unixcharset, CH_UTF8_MAC, 
                             Obj, -1, data+sizeof(namelen), maxstatuslen-offset )) ) {
     if ((size_t) -1 == (len = convert_string (
                             options->unixcharset, CH_UTF8_MAC, 
                             Obj, -1, data+sizeof(namelen), maxstatuslen-offset )) ) {
@@ -413,36 +413,27 @@ static void status_icon(char *data, const unsigned char *icondata,
 
 /* ---------------------
  */
 
 /* ---------------------
  */
-void status_init(AFPConfig *dsiconfig,
-                 const struct afp_options *options)
+void status_init(AFPObj *obj, DSI *dsi)
 {
 {
-    DSI *dsi;
-    char *status = NULL;
+    char *status = dsi->status;
     size_t statuslen;
     size_t statuslen;
-    int c, sigoff, ipok;
-
-    if (!dsiconfig || !options)
-        return;
-       
-    ipok = 0;
-    if (dsiconfig) {
-        status = dsiconfig->status;
-        maxstatuslen=sizeof(dsiconfig->status);
-        dsi = dsiconfig->obj.dsi;
-        if (dsi->server.ss_family == AF_INET) { /* IPv4 */
-            const struct sockaddr_in *sa4 = (struct sockaddr_in *)&dsi->server;
-            ipok = sa4->sin_addr.s_addr ? 1 : 0;
-        } else { /* IPv6 */
-            const struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&dsi->server;
-            for (int i=0; i<16; i++) {
-                if (sa6->sin6_addr.s6_addr[i]) {
-                    ipok = 1;
-                    break;
-                }
+    int c, sigoff, ipok = 0;
+    const struct afp_options *options = &obj->options;
+
+    maxstatuslen = sizeof(dsi->status);
+
+    if (dsi->server.ss_family == AF_INET) { /* IPv4 */
+        const struct sockaddr_in *sa4 = (struct sockaddr_in *)&dsi->server;
+        ipok = sa4->sin_addr.s_addr ? 1 : 0;
+    } else { /* IPv6 */
+        const struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&dsi->server;
+        for (int i=0; i<16; i++) {
+            if (sa6->sin6_addr.s6_addr[i]) {
+                ipok = 1;
+                break;
             }
         }
             }
         }
-    } else
-        dsi = NULL;
+    }
 
     /*
      * These routines must be called in order -- earlier calls
 
     /*
      * These routines must be called in order -- earlier calls
@@ -465,14 +456,13 @@ void status_init(AFPConfig *dsiconfig,
      */
 
     status_flags(status,
      */
 
     status_flags(status,
-                 options->server_notif,
+                 options->flags & OPTION_SERVERNOTIF,
                  (options->fqdn || ipok),
                  options->passwdbits, 
                  (options->k5service && options->k5realm && options->fqdn),
                  options->flags);
     /* returns offset to signature offset */
                  (options->fqdn || ipok),
                  options->passwdbits, 
                  (options->k5service && options->k5realm && options->fqdn),
                  options->flags);
     /* returns offset to signature offset */
-    c = status_server(status, options->server ? options->server :
-                      options->hostname, options);
+    c = status_server(status, options->hostname, options);
     status_machine(status);
     status_versions(status, dsi);
     status_uams(status, options->uamlist);
     status_machine(status);
     status_versions(status, dsi);
     status_uams(status, options->uamlist);
@@ -493,14 +483,12 @@ void status_init(AFPConfig *dsiconfig,
     if ( statuslen < maxstatuslen) 
         statuslen = status_utf8servername(status, &c, dsi, options);
 
     if ( statuslen < maxstatuslen) 
         statuslen = status_utf8servername(status, &c, dsi, options);
 
-    if (dsiconfig) {
-        if ((options->flags & OPTION_CUSTOMICON) == 0) {
-            status_icon(status, apple_tcp_icon, sizeof(apple_tcp_icon), 0);
-        }
-        dsi_setstatus(dsi, status, statuslen);
-        dsiconfig->signature = status + sigoff;
-        dsiconfig->statuslen = statuslen;
+    if ((options->flags & OPTION_CUSTOMICON) == 0) {
+        status_icon(status, apple_tcp_icon, sizeof(apple_tcp_icon), 0);
     }
     }
+
+    dsi->signature = status + sigoff;
+    dsi->statuslen = statuslen;
 }
 
 /* set_signature()                                                    */
 }
 
 /* set_signature()                                                    */
@@ -522,7 +510,7 @@ void set_signature(struct afp_options *options) {
     size_t len;
     char *server_tmp;
     
     size_t len;
     char *server_tmp;
     
-    server_tmp = (options->server ? options->server : options->hostname);
+    server_tmp = options->hostname;
     if (strcmp(options->signatureopt, "auto") == 0) {
         goto server_signature_auto;   /* default */
     } else if (strcmp(options->signatureopt, "host") == 0) {
     if (strcmp(options->signatureopt, "auto") == 0) {
         goto server_signature_auto;   /* default */
     } else if (strcmp(options->signatureopt, "host") == 0) {
@@ -682,9 +670,8 @@ server_signature_done:
 /* this is the same as asp/dsi_getstatus */
 int afp_getsrvrinfo(AFPObj *obj, char *ibuf _U_, size_t ibuflen _U_, char *rbuf, size_t *rbuflen)
 {
 /* this is the same as asp/dsi_getstatus */
 int afp_getsrvrinfo(AFPObj *obj, char *ibuf _U_, size_t ibuflen _U_, char *rbuf, size_t *rbuflen)
 {
-    AFPConfig *config = obj->config;
+    memcpy(rbuf, obj->dsi->status, obj->dsi->statuslen);
+    *rbuflen = obj->dsi->statuslen;
 
 
-    memcpy(rbuf, config->status, config->statuslen);
-    *rbuflen = config->statuslen;
     return AFP_OK;
 }
     return AFP_OK;
 }
index 1a1365e3dc678e8b493e8a9896baca7babc794ea..3057b7594a14b821aad093bc4ac1e830417e64ee 100644 (file)
@@ -41,7 +41,7 @@
 
 extern void status_versions (char * /*status*/, const DSI *);
 extern void status_uams (char * /*status*/, const char * /*authlist*/);
 
 extern void status_versions (char * /*status*/, const DSI *);
 extern void status_uams (char * /*status*/, const char * /*authlist*/);
-extern void status_init (AFPConfig *, const struct afp_options *);
+extern void status_init (AFPObj *, DSI *dsi);
 extern void set_signature(struct afp_options *);
 
 /* FP functions */
 extern void set_signature(struct afp_options *);
 
 /* FP functions */
index 8adfb3bbd9539a9e3daa1b9b9e6f4a871862a269..0d7b6b2b704115033e64092b84144394481c7a14 100644 (file)
@@ -372,7 +372,7 @@ int uam_afpserver_option(void *private, const int what, void *option,
         break;
 
     case UAM_OPTION_SIGNATURE:
         break;
 
     case UAM_OPTION_SIGNATURE:
-        *buf = (void *) (((AFPConfig *)obj->config)->signature);
+        *buf = (void *)obj->dsi->signature;
         if (len)
             *len = 16;
         break;
         if (len)
             *len = 16;
         break;
@@ -390,10 +390,6 @@ int uam_afpserver_option(void *private, const int what, void *option,
             *len = strlen(obj->options.hostname);
         break;
 
             *len = strlen(obj->options.hostname);
         break;
 
-    case UAM_OPTION_PROTOCOL:
-        *((int *) option) = obj->proto;
-        break;
-        
     case UAM_OPTION_CLIENTNAME:
     {
         struct DSI *dsi = obj->dsi;
     case UAM_OPTION_CLIENTNAME:
     {
         struct DSI *dsi = obj->dsi;
index 1688c9abbf06854f8b6954b30c7586c6c27211b1..21602ab13b1d8f079ddec03cddb5b8a10e185724 100644 (file)
@@ -266,17 +266,17 @@ int setdeskmode(const mode_t mode)
             }
 
             if (S_ISDIR(st.st_mode)) {
             }
 
             if (S_ISDIR(st.st_mode)) {
-                if ( chmod_acl( modbuf,  (DIRBITS | mode) & ~default_options.umask ) < 0 && errno != EPERM ) {
+                if ( chmod_acl( modbuf,  (DIRBITS | mode)) < 0 && errno != EPERM ) {
                      LOG(log_error, logtype_afpd, "setdeskmode: chmod %s: %s",fullpathname(modbuf), strerror(errno) );
                 }
                      LOG(log_error, logtype_afpd, "setdeskmode: chmod %s: %s",fullpathname(modbuf), strerror(errno) );
                 }
-            } else if ( chmod_acl( modbuf,  mode & ~(default_options.umask | EXEC_MODE) ) < 0 && errno != EPERM ) {
+            } else if ( chmod_acl( modbuf,  mode & ~EXEC_MODE ) < 0 && errno != EPERM ) {
                 LOG(log_error, logtype_afpd, "setdeskmode: chmod %s: %s",fullpathname(modbuf), strerror(errno) );
             }
 
         }
         closedir( sub );
         /* XXX: need to preserve special modes */
                 LOG(log_error, logtype_afpd, "setdeskmode: chmod %s: %s",fullpathname(modbuf), strerror(errno) );
             }
 
         }
         closedir( sub );
         /* XXX: need to preserve special modes */
-        if ( chmod_acl( deskp->d_name,  (DIRBITS | mode) & ~default_options.umask ) < 0 && errno != EPERM ) {
+        if ( chmod_acl( deskp->d_name,  (DIRBITS | mode)) < 0 && errno != EPERM ) {
             LOG(log_error, logtype_afpd, "setdeskmode: chmod %s: %s",fullpathname(deskp->d_name), strerror(errno) );
         }
     }
             LOG(log_error, logtype_afpd, "setdeskmode: chmod %s: %s",fullpathname(deskp->d_name), strerror(errno) );
         }
     }
@@ -286,7 +286,7 @@ int setdeskmode(const mode_t mode)
         return -1;
     }
     /* XXX: need to preserve special modes */
         return -1;
     }
     /* XXX: need to preserve special modes */
-    if ( chmod_acl( ".AppleDesktop",  (DIRBITS | mode) & ~default_options.umask ) < 0 && errno != EPERM ) {
+    if ( chmod_acl( ".AppleDesktop",  (DIRBITS | mode)) < 0 && errno != EPERM ) {
         LOG(log_error, logtype_afpd, "setdeskmode: chmod %s: %s", fullpathname(".AppleDesktop"),strerror(errno) );
     }
     return( 0 );
         LOG(log_error, logtype_afpd, "setdeskmode: chmod %s: %s", fullpathname(".AppleDesktop"),strerror(errno) );
     }
     return( 0 );
index f09381b3559a2542524d9d091b9897fe6669c085..73904fc4c3b083891f6c9d82607e0387e542bee4 100644 (file)
@@ -152,7 +152,6 @@ static void volfree(struct vol_option *options, const struct vol_option *save)
  * $s   -> server name (hostname if it doesn't exist)
  * $u   -> username (guest is usually nobody)
  * $v   -> volume name or basename if null
  * $s   -> server name (hostname if it doesn't exist)
  * $u   -> username (guest is usually nobody)
  * $v   -> volume name or basename if null
- * $z   -> zone (may not exist)
  * $$   -> $
  *
  * This get's called from readvolfile with
  * $$   -> $
  *
  * This get's called from readvolfile with
@@ -253,12 +252,7 @@ static char *volxlate(AFPObj *obj,
             DSI *dsi = obj->dsi;
             q = getip_string((struct sockaddr *)&dsi->client);
         } else if (is_var(p, "$s")) {
             DSI *dsi = obj->dsi;
             q = getip_string((struct sockaddr *)&dsi->client);
         } else if (is_var(p, "$s")) {
-            if (obj->Obj)
-                q = obj->Obj;
-            else if (obj->options.server) {
-                q = obj->options.server;
-            } else
-                q = obj->options.hostname;
+            q = obj->options.hostname;
         } else if (obj->username && is_var(p, "$u")) {
             if (afpmaster && xlatevolname)
                 return NULL;
         } else if (obj->username && is_var(p, "$u")) {
             if (afpmaster && xlatevolname)
                 return NULL;
@@ -279,8 +273,6 @@ static char *volxlate(AFPObj *obj,
                 else if (*(q + 1) != '\0')
                     q++;
             }
                 else if (*(q + 1) != '\0')
                     q++;
             }
-        } else if (is_var(p, "$z")) {
-            q = obj->Zone;
         } else if (is_var(p, "$$")) {
             q = "$";
         } else
         } else if (is_var(p, "$$")) {
             q = "$";
         } else
@@ -309,7 +301,7 @@ static char *volxlate(AFPObj *obj,
 }
 
 /* -------------------- */
 }
 
 /* -------------------- */
-static void setoption(struct vol_option *options, struct vol_option *save, int opt, const char *val)
+static void setoption(struct vol_option *options, const struct vol_option *save, int opt, const char *val)
 {
     if (options[opt].c_value && (!save || options[opt].c_value != save[opt].c_value))
         free(options[opt].c_value);
 {
     if (options[opt].c_value && (!save || options[opt].c_value != save[opt].c_value))
         free(options[opt].c_value);
@@ -320,72 +312,72 @@ static void setoption(struct vol_option *options, struct vol_option *save, int o
 static void volset(const dictionary *conf, const char *vol, struct vol_option *options, const struct vol_option *save)
 {
     const char *val;
 static void volset(const dictionary *conf, const char *vol, struct vol_option *options, const struct vol_option *save)
 {
     const char *val;
-    const char *p;
+    char *p, *q;
 
 
-    if (val = iniparser_getstring(conf, vol, "allow"))
+    if (val = iniparser_getstring(conf, vol, "allow", NULL))
         setoption(options, save, VOLOPT_ALLOW, val);
 
         setoption(options, save, VOLOPT_ALLOW, val);
 
-    if (val = iniparser_getstring(conf, vol, "deny"))
+    if (val = iniparser_getstring(conf, vol, "deny", NULL))
         setoption(options, save, VOLOPT_DENY, val);
 
         setoption(options, save, VOLOPT_DENY, val);
 
-    if (val = iniparser_getstring(conf, vol, "rwlist"))
+    if (val = iniparser_getstring(conf, vol, "rwlist", NULL))
         setoption(options, save, VOLOPT_RWLIST, val);
 
         setoption(options, save, VOLOPT_RWLIST, val);
 
-    if (val = iniparser_getstring(conf, vol, "rolist"))
+    if (val = iniparser_getstring(conf, vol, "rolist", NULL))
         setoption(options, save, VOLOPT_ROLIST, val);
 
         setoption(options, save, VOLOPT_ROLIST, val);
 
-    if (val = iniparser_getstring(conf, vol, "volcharset"))
+    if (val = iniparser_getstring(conf, vol, "volcharset", NULL))
         setoption(options, save, VOLOPT_ENCODING, val);
 
         setoption(options, save, VOLOPT_ENCODING, val);
 
-    if (val = iniparser_getstring(conf, vol, "maccharset"))
+    if (val = iniparser_getstring(conf, vol, "maccharset", NULL))
         setoption(options, save, VOLOPT_MACCHARSET, val);
 
         setoption(options, save, VOLOPT_MACCHARSET, val);
 
-    if (val = iniparser_getstring(conf, vol, "veto"))
+    if (val = iniparser_getstring(conf, vol, "veto", NULL))
         setoption(options, save, VOLOPT_VETO, val);
 
         setoption(options, save, VOLOPT_VETO, val);
 
-    if (val = iniparser_getstring(conf, vol, "cnidscheme"))
+    if (val = iniparser_getstring(conf, vol, "cnidscheme", NULL))
         setoption(options, save, VOLOPT_CNIDSCHEME, val);
 
         setoption(options, save, VOLOPT_CNIDSCHEME, val);
 
-    if (val = iniparser_getstring(conf, vol, "dbpath"))
+    if (val = iniparser_getstring(conf, vol, "dbpath", NULL))
         setoption(options, save, VOLOPT_DBPATH, val);
 
         setoption(options, save, VOLOPT_DBPATH, val);
 
-    if (val = iniparser_getstring(conf, vol, "password"))
+    if (val = iniparser_getstring(conf, vol, "password", NULL))
         setoption(options, save, VOLOPT_PASSWORD, val);
 
         setoption(options, save, VOLOPT_PASSWORD, val);
 
-    if (val = iniparser_getstring(conf, vol, "root_preexec"))
+    if (val = iniparser_getstring(conf, vol, "root_preexec", NULL))
         setoption(options, save, VOLOPT_ROOTPREEXEC, val);
 
         setoption(options, save, VOLOPT_ROOTPREEXEC, val);
 
-    if (val = iniparser_getstring(conf, vol, "preexec"))
+    if (val = iniparser_getstring(conf, vol, "preexec", NULL))
         setoption(options, save, VOLOPT_PREEXEC, val);
 
         setoption(options, save, VOLOPT_PREEXEC, val);
 
-    if (val = iniparser_getstring(conf, vol, "root_postexec"))
+    if (val = iniparser_getstring(conf, vol, "root_postexec", NULL))
         setoption(options, save, VOLOPT_ROOTPOSTEXEC, val);
 
         setoption(options, save, VOLOPT_ROOTPOSTEXEC, val);
 
-    if (val = iniparser_getstring(conf, vol, "postexec"))
+    if (val = iniparser_getstring(conf, vol, "postexec", NULL))
         setoption(options, save, VOLOPT_POSTEXEC, val);
 
         setoption(options, save, VOLOPT_POSTEXEC, val);
 
-    if (val = iniparser_getstring(conf, vol, "allowed_hosts"))
+    if (val = iniparser_getstring(conf, vol, "allowed_hosts", NULL))
         setoption(options, save, VOLOPT_ALLOWED_HOSTS, val);
 
         setoption(options, save, VOLOPT_ALLOWED_HOSTS, val);
 
-    if (val = iniparser_getstring(conf, vol, "denied_hosts"))
+    if (val = iniparser_getstring(conf, vol, "denied_hosts", NULL))
         setoption(options, save, VOLOPT_DENIED_HOSTS, val);
 
         setoption(options, save, VOLOPT_DENIED_HOSTS, val);
 
-    if (val = iniparser_getstring(conf, vol, "umask"))
+    if (val = iniparser_getstring(conf, vol, "umask", NULL))
         options[VOLOPT_UMASK].i_value = (int)strtol(val, NULL, 8);
 
         options[VOLOPT_UMASK].i_value = (int)strtol(val, NULL, 8);
 
-    if (val = iniparser_getstring(conf, vol, "dperm"))
+    if (val = iniparser_getstring(conf, vol, "dperm", NULL))
         options[VOLOPT_DPERM].i_value = (int)strtol(val, NULL, 8);
 
         options[VOLOPT_DPERM].i_value = (int)strtol(val, NULL, 8);
 
-    if (val = iniparser_getstring(conf, vol, "fperm"))
+    if (val = iniparser_getstring(conf, vol, "fperm", NULL))
         options[VOLOPT_FPERM].i_value = (int)strtol(val, NULL, 8);
 
         options[VOLOPT_FPERM].i_value = (int)strtol(val, NULL, 8);
 
-    if (val = iniparser_getstring(conf, vol, "perm"))
+    if (val = iniparser_getstring(conf, vol, "perm", NULL))
         options[VOLOPT_DFLTPERM].i_value = (int)strtol(val, NULL, 8);
 
         options[VOLOPT_DFLTPERM].i_value = (int)strtol(val, NULL, 8);
 
-    if (val = iniparser_getstring(conf, vol, "volsizelimit"))
+    if (val = iniparser_getstring(conf, vol, "volsizelimit", NULL))
         options[VOLOPT_LIMITSIZE].i_value = (uint32_t)strtoul(val, NULL, 10);
 
         options[VOLOPT_LIMITSIZE].i_value = (uint32_t)strtoul(val, NULL, 10);
 
-    if (val = iniparser_getstring(conf, vol, "casefold")) {
+    if (val = iniparser_getstring(conf, vol, "casefold", NULL)) {
         if (strcasecmp(val, "tolower") == 0)
             options[VOLOPT_CASEFOLD].i_value = AFPVOL_UMLOWER;
         else if (strcasecmp(val, "toupper") == 0)
         if (strcasecmp(val, "tolower") == 0)
             options[VOLOPT_CASEFOLD].i_value = AFPVOL_UMLOWER;
         else if (strcasecmp(val, "toupper") == 0)
@@ -396,14 +388,14 @@ static void volset(const dictionary *conf, const char *vol, struct vol_option *o
             options[VOLOPT_CASEFOLD].i_value = AFPVOL_ULOWERMUPPER;
     }
 
             options[VOLOPT_CASEFOLD].i_value = AFPVOL_ULOWERMUPPER;
     }
 
-    if (val = iniparser_getstring(conf, vol, "adouble")) {
+    if (val = iniparser_getstring(conf, vol, "adouble", NULL)) {
         if (strcasecmp(val, "v2") == 0)
             options[VOLOPT_ADOUBLE].i_value = AD_VERSION2;
         else if (strcasecmp(val, "ea") == 0)
             options[VOLOPT_ADOUBLE].i_value = AD_VERSION_EA;
     }
 
         if (strcasecmp(val, "v2") == 0)
             options[VOLOPT_ADOUBLE].i_value = AD_VERSION2;
         else if (strcasecmp(val, "ea") == 0)
             options[VOLOPT_ADOUBLE].i_value = AD_VERSION_EA;
     }
 
-    if (val = iniparser_getstring(conf, vol, "ea")) {
+    if (val = iniparser_getstring(conf, vol, "ea", NULL)) {
         if (strcasecmp(val, "ad") == 0)
             options[VOLOPT_EA_VFS].i_value = AFPVOL_EA_AD;
         else if (strcasecmp(val, "sys") == 0)
         if (strcasecmp(val, "ad") == 0)
             options[VOLOPT_EA_VFS].i_value = AFPVOL_EA_AD;
         else if (strcasecmp(val, "sys") == 0)
@@ -412,19 +404,19 @@ static void volset(const dictionary *conf, const char *vol, struct vol_option *o
             options[VOLOPT_EA_VFS].i_value = AFPVOL_EA_NONE;
     }
 
             options[VOLOPT_EA_VFS].i_value = AFPVOL_EA_NONE;
     }
 
-    if (val = iniparser_getstrdup(conf, vol, "cnidserver")) {
-        if (p = strrchr(val, ':')) {
-            *p = 0;
-            setoption(options, save, VOLOPT_CNIDPORT, p + 1);
+    if (p = iniparser_getstrdup(conf, vol, "cnidserver", NULL)) {
+        if (q = strrchr(val, ':')) {
+            *q = 0;
+            setoption(options, save, VOLOPT_CNIDPORT, q + 1);
         }
         }
-        setoption(options, save, VOLOPT_CNIDSERVER, val);
+        setoption(options, save, VOLOPT_CNIDSERVER, p);
         LOG(log_debug, logtype_afpd, "CNID Server for volume '%s': %s:%s",
         LOG(log_debug, logtype_afpd, "CNID Server for volume '%s': %s:%s",
-            volname, val, p ? p + 1 : Cnid_port);
-        free(val);
+            vol, p, q ? q + 1 : "4700");
+        free(p);
     }
 
     }
 
-    if (val = iniparser_getstrdup(conf, vol, "options")) {
-        if (p = strtok(val, ",")) {
+    if (q = iniparser_getstrdup(conf, vol, "options", NULL)) {
+        if (p = strtok(q, ",")) {
             while (p) {
                 if (strcasecmp(p, "ro") == 0)
                     options[VOLOPT_FLAGS].i_value |= AFPVOL_RO;
             while (p) {
                 if (strcasecmp(p, "ro") == 0)
                     options[VOLOPT_FLAGS].i_value |= AFPVOL_RO;
@@ -461,7 +453,7 @@ static void volset(const dictionary *conf, const char *vol, struct vol_option *o
                 p = strtok(NULL, ",");
             }
         }
                 p = strtok(NULL, ",");
             }
         }
-        free(val);
+        free(q);
     }
 }
 
     }
 }
 
@@ -850,9 +842,6 @@ static int hostaccessvol(int type, const char *volname, const char *args, const
     if ((p = strtok_r(buf, ",", &b)) == NULL) /* nothing, return okay */
         return -1;
 
     if ((p = strtok_r(buf, ",", &b)) == NULL) /* nothing, return okay */
         return -1;
 
-    if (obj->proto != AFPPROTO_DSI)
-        return -1;
-
     while (p) {
         int ret;
         char *ipaddr, *mask_char;
     while (p) {
         int ret;
         char *ipaddr, *mask_char;
@@ -906,18 +895,12 @@ static int hostaccessvol(int type, const char *volname, const char *args, const
 
 /* ----------------------
  */
 
 /* ----------------------
  */
-static int volfile_changed(struct afp_volume_name *p)
+static int volfile_changed(struct afp_options *p)
 {
     struct stat      st;
 {
     struct stat      st;
-    char *name;
 
 
-    if (p->full_name)
-        name = p->full_name;
-    else
-        name = p->name;
-
-    if (!stat( name, &st) && st.st_mtime > p->mtime) {
-        p->mtime = st.st_mtime;
+    if (!stat(p->configfile, &st) && st.st_mtime > p->volfile.mtime) {
+        p->volfile.mtime = st.st_mtime;
         return 1;
     }
     return 0;
         return 1;
     }
     return 0;
@@ -944,7 +927,8 @@ static int readvolfile(AFPObj *obj, struct afp_volume_name *p1, struct passwd *p
     char        path[MAXPATHLEN + 1];
     char        volname[AFPVOL_U8MNAMELEN + 1];
     char        tmp[MAXPATHLEN + 1];
     char        path[MAXPATHLEN + 1];
     char        volname[AFPVOL_U8MNAMELEN + 1];
     char        tmp[MAXPATHLEN + 1];
-    char        *u, *p;
+    char        *u;
+    const char  *p;
     int         fd;
     int         i;
     struct passwd     *pw;
     int         fd;
     int         i;
     struct passwd     *pw;
@@ -952,10 +936,8 @@ static int readvolfile(AFPObj *obj, struct afp_volume_name *p1, struct passwd *p
     struct vol_option default_options[VOLOPT_NUM];
     struct vol_option options[VOLOPT_NUM];
 
     struct vol_option default_options[VOLOPT_NUM];
     struct vol_option options[VOLOPT_NUM];
 
-    LOG(log_debug, logtype_afpd, "readvolfile(\"%s\"): BEGIN", p1->name);
+    LOG(log_debug, logtype_afpd, "readvolfile: BEGIN");
 
 
-    if (!p1->name)
-        return -1;
     p1->mtime = 0;
 
     memset(default_options, 0, sizeof(default_options));
     p1->mtime = 0;
 
     memset(default_options, 0, sizeof(default_options));
@@ -974,7 +956,7 @@ static int readvolfile(AFPObj *obj, struct afp_volume_name *p1, struct passwd *p
     for (i = 0; i < secnum; secname = iniparser_getsecname(obj->iniconfig, i), i++) { 
         if (!vol_section(secname))
             continue;
     for (i = 0; i < secnum; secname = iniparser_getsecname(obj->iniconfig, i), i++) { 
         if (!vol_section(secname))
             continue;
-        if ((p = iniparser_getstring(obj->iniconfig, secname, "path")) == NULL)
+        if ((p = iniparser_getstrdup(obj->iniconfig, secname, "path", NULL)) == NULL)
             continue;
         strlcpy(path, p, MAXPATHLEN);
         strcpy(tmp, path);
             continue;
         strlcpy(path, p, MAXPATHLEN);
         strcpy(tmp, path);
@@ -1012,7 +994,7 @@ static int readvolfile(AFPObj *obj, struct afp_volume_name *p1, struct passwd *p
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_RO;
 
             /* do variable substitution for volname */
                 options[VOLOPT_FLAGS].i_value |= AFPVOL_RO;
 
             /* do variable substitution for volname */
-            if (volxlate(obj, tmp, sizeof(tmp) - 1, secname, pwent, path, NULL) == NULL) {
+            if (volxlate(obj, tmp, sizeof(tmp) - 1, volname, pwent, path, NULL) == NULL) {
                 volfree(options, default_options);
                 continue;
             }
                 volfree(options, default_options);
                 continue;
             }
@@ -1583,6 +1565,7 @@ void load_volumes(AFPObj *obj)
     int fd = -1;
     struct passwd   *pwent;
     struct stat         st;
     int fd = -1;
     struct passwd   *pwent;
     struct stat         st;
+    int retries = 0;
 
     if (parent_or_child == 0) {
         LOG(log_debug, logtype_afpd, "load_volumes: AFP MASTER");
 
     if (parent_or_child == 0) {
         LOG(log_debug, logtype_afpd, "load_volumes: AFP MASTER");
@@ -1590,19 +1573,22 @@ void load_volumes(AFPObj *obj)
         LOG(log_debug, logtype_afpd, "load_volumes: user: %s", obj->username);
     }
 
         LOG(log_debug, logtype_afpd, "load_volumes: user: %s", obj->username);
     }
 
-    if (Volumes && volfile_changed(&obj->options.volfile))
+    if (Volumes) {
+        if (!volfile_changed(&obj->options))
+            return;
         free_volumes();
         free_volumes();
+    }
 
     /* try putting a read lock on the volume file twice, sleep 1 second if first attempt fails */
 
     /* try putting a read lock on the volume file twice, sleep 1 second if first attempt fails */
-    int retries = 2;
-    fd = open(p1->name, O_RDWR);
-    if (fd != -1 && fstat(fd, &st) == 0)
-        p1->mtime = st.st_mtime; 
-    while (1) {
+
+    fd = open(obj->options.configfile, O_RDWR);
+
+    while (retries < 2) {
         if ((read_lock(fd, 0, SEEK_SET, 0)) != 0) {
         if ((read_lock(fd, 0, SEEK_SET, 0)) != 0) {
-            retries--;
+            retries++;
             if (!retries) {
             if (!retries) {
-                LOG(log_error, logtype_afpd, "readvolfile: can't lock volume file \"%s\"", path);
+                LOG(log_error, logtype_afpd, "readvolfile: can't lock configfile \"%s\"",
+                    obj->options.configfile);
                 EC_FAIL;
             }
             sleep(1);
                 EC_FAIL;
             }
             sleep(1);
@@ -1612,7 +1598,7 @@ void load_volumes(AFPObj *obj)
     }
 
     iniparser_freedict(obj->iniconfig);
     }
 
     iniparser_freedict(obj->iniconfig);
-    obj->iniconfig = iniparser_load(obj->configfile);
+    obj->iniconfig = iniparser_load(obj->options.configfile);
 
     if (obj->username)
         pwent = getpwnam(obj->username);
 
     if (obj->username)
         pwent = getpwnam(obj->username);
@@ -1635,7 +1621,7 @@ void load_volumes(AFPObj *obj)
 EC_CLEANUP:
     if (fd != -1)
         (void)close(fd);
 EC_CLEANUP:
     if (fd != -1)
         (void)close(fd);
-    EC_EXIT;
+    return;
 }
 
 /* ------------------------------- */
 }
 
 /* ------------------------------- */
@@ -1742,7 +1728,7 @@ static int volume_codepage(AFPObj *obj, struct vol *volume)
 }
 
 /* ------------------------- */
 }
 
 /* ------------------------- */
-static int volume_openDB(struct vol *volume)
+static int volume_openDB(const AFPObj *obj, struct vol *volume)
 {
     int flags = 0;
 
 {
     int flags = 0;
 
@@ -1757,37 +1743,15 @@ static int volume_openDB(struct vol *volume)
     }
 
     LOG(log_info, logtype_afpd, "CNID server: %s:%s",
     }
 
     LOG(log_info, logtype_afpd, "CNID server: %s:%s",
-        volume->v_cnidserver ? volume->v_cnidserver : Cnid_srv,
-        volume->v_cnidport ? volume->v_cnidport : Cnid_port);
-
-#if 0
-/* Found this in branch dir-rewrite, maybe we want to use it sometimes */
-
-    /* Legacy pre 2.1 way of sharing eg CD-ROM */
-    if (strcmp(volume->v_cnidscheme, "last") == 0) {
-        /* "last" is gone. We support it by switching to in-memory "tdb" */
-        volume->v_cnidscheme = strdup("tdb");
-        flags |= CNID_FLAG_MEMORY;
-    }
-
-    /* New way of sharing CD-ROM */
-    if (volume->v_flags & AFPVOL_CDROM) {
-        flags |= CNID_FLAG_MEMORY;
-        if (strcmp(volume->v_cnidscheme, "tdb") != 0) {
-            free(volume->v_cnidscheme);
-            volume->v_cnidscheme = strdup("tdb");
-            LOG(log_info, logtype_afpd, "Volume %s is ejectable, switching to scheme %s.",
-                volume->v_path, volume->v_cnidscheme);
-        }
-    }
-#endif
+        volume->v_cnidserver ? volume->v_cnidserver : obj->options.Cnid_srv,
+        volume->v_cnidport ? volume->v_cnidport : obj->options.Cnid_port);
 
     volume->v_cdb = cnid_open(volume->v_path,
                               volume->v_umask,
                               volume->v_cnidscheme,
                               flags,
 
     volume->v_cdb = cnid_open(volume->v_path,
                               volume->v_umask,
                               volume->v_cnidscheme,
                               flags,
-                              volume->v_cnidserver ? volume->v_cnidserver : Cnid_srv,
-                              volume->v_cnidport ? volume->v_cnidport : Cnid_port);
+                              volume->v_cnidserver ? volume->v_cnidserver : obj->options.Cnid_srv,
+                              volume->v_cnidport ? volume->v_cnidport : obj->options.Cnid_port);
 
     if ( ! volume->v_cdb && ! (flags & CNID_FLAG_MEMORY)) {
         /* The first attempt failed and it wasn't yet an attempt to open in-memory */
 
     if ( ! volume->v_cdb && ! (flags & CNID_FLAG_MEMORY)) {
         /* The first attempt failed and it wasn't yet an attempt to open in-memory */
@@ -2028,7 +1992,7 @@ int afp_openvol(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t
     volume->v_root = dir;
     curdir = dir;
 
     volume->v_root = dir;
     curdir = dir;
 
-    if (volume_openDB(volume) < 0) {
+    if (volume_openDB(obj, volume) < 0) {
         LOG(log_error, logtype_afpd, "Fatal error: cannot open CNID or invalid CNID backend for %s: %s",
             volume->v_path, volume->v_cnidscheme);
         ret = AFPERR_MISC;
         LOG(log_error, logtype_afpd, "Fatal error: cannot open CNID or invalid CNID backend for %s: %s",
             volume->v_path, volume->v_cnidscheme);
         ret = AFPERR_MISC;
@@ -2040,8 +2004,8 @@ int afp_openvol(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t
     if (ret == AFP_OK) {
         handle_special_folders(volume);
         savevolinfo(volume,
     if (ret == AFP_OK) {
         handle_special_folders(volume);
         savevolinfo(volume,
-                    volume->v_cnidserver ? volume->v_cnidserver : Cnid_srv,
-                    volume->v_cnidport   ? volume->v_cnidport   : Cnid_port);
+                    volume->v_cnidserver ? volume->v_cnidserver : obj->options.Cnid_srv,
+                    volume->v_cnidport   ? volume->v_cnidport   : obj->options.Cnid_port);
 
 
         /*
 
 
         /*
@@ -2184,39 +2148,6 @@ struct vol *getvolbyvid(const uint16_t vid )
     return( vol );
 }
 
     return( vol );
 }
 
-/* ------------------------ */
-static int ext_cmp_key(const void *key, const void *obj)
-{
-    const char          *p = key;
-    const struct extmap *em = obj;
-    return strdiacasecmp(p, em->em_ext);
-}
-struct extmap *getextmap(const char *path)
-{
-    char      *p;
-    struct extmap *em;
-
-    if (!Extmap_cnt || NULL == ( p = strrchr( path, '.' )) ) {
-        return( Defextmap );
-    }
-    p++;
-    if (!*p) {
-        return( Defextmap );
-    }
-    em = bsearch(p, Extmap, Extmap_cnt, sizeof(struct extmap), ext_cmp_key);
-    if (em) {
-        return( em );
-    } else {
-        return( Defextmap );
-    }
-}
-
-/* ------------------------- */
-struct extmap *getdefextmap(void)
-{
-    return( Defextmap );
-}
-
 /* --------------------------
    poll if a volume is changed by other processes.
    return
 /* --------------------------
    poll if a volume is changed by other processes.
    return
@@ -2236,7 +2167,7 @@ int  pollvoltime(AFPObj *obj)
     struct timeval   tv;
     struct stat      st;
 
     struct timeval   tv;
     struct stat      st;
 
-    if (!(afp_version > 21 && obj->options.server_notif))
+    if (!(afp_version > 21 && obj->options.flags & OPTION_SERVERNOTIF))
         return 0;
 
     if ( gettimeofday( &tv, NULL ) < 0 )
         return 0;
 
     if ( gettimeofday( &tv, NULL ) < 0 )
@@ -2276,7 +2207,7 @@ void setvoltime(AFPObj *obj, struct vol *vol)
         /* or finder doesn't update free space
          * AFP 3.2 and above clients seem to be ok without so many notification
          */
         /* or finder doesn't update free space
          * AFP 3.2 and above clients seem to be ok without so many notification
          */
-        if (afp_version < 32 && obj->options.server_notif) {
+        if (afp_version < 32 && obj->options.flags & OPTION_SERVERNOTIF) {
             obj->attention(obj->dsi, AFPATTN_NOTIFY | AFPATTN_VOLCHANGED);
         }
     }
             obj->attention(obj->dsi, AFPATTN_NOTIFY | AFPATTN_VOLCHANGED);
         }
     }
index a9993d4cba197857b9d0ced8c3e4659874fcc48c..ad0e22b4189acba3c2343baef0e8b11a8cc1ad8f 100644 (file)
@@ -262,9 +262,9 @@ int main(int argc, char **argv)
 
     /* Setup logging. Should be portable among *NIXes */
     if (!verbose)
 
     /* Setup logging. Should be portable among *NIXes */
     if (!verbose)
-        setuplog("default log_info /dev/tty");
+        setuplog("default:info", "/dev/tty");
     else
     else
-        setuplog("default log_debug /dev/tty");
+        setuplog("default:debug", "/dev/tty");
 
     /* Load .volinfo file */
     if (loadvolinfo(volpath, &volinfo) == -1) {
 
     /* Load .volinfo file */
     if (loadvolinfo(volpath, &volinfo) == -1) {
index 2a3bc6b9f32ce83e4ad0930dab5ab80bd8021e91..580c36cd3339c9fdc363a25087d8e8b58699e80d 100644 (file)
@@ -444,8 +444,6 @@ int main(int argc, char *argv[])
     int    err = 0;
     int    debug = 0;
     int    ret;
     int    err = 0;
     int    debug = 0;
     int    ret;
-    char   *loglevel = NULL;
-    char   *logfile  = NULL;
     sigset_t set;
     struct volinfo *volinfo;
 
     sigset_t set;
     struct volinfo *volinfo;
 
@@ -483,12 +481,6 @@ int main(int argc, char *argv[])
         case 's':
             dbdpn = strdup(optarg);
             break;
         case 's':
             dbdpn = strdup(optarg);
             break;
-        case 'l':
-            loglevel = strdup(optarg);
-            break;
-        case 'f':
-            logfile = strdup(optarg);
-            break;
         default:
             err++;
             break;
         default:
             err++;
             break;
@@ -506,16 +498,7 @@ int main(int argc, char *argv[])
     if (create_lockfile("cnid_metad", _PATH_CNID_METAD_LOCK))
         return -1;
 
     if (create_lockfile("cnid_metad", _PATH_CNID_METAD_LOCK))
         return -1;
 
-    if (loglevel) {
-        strlcpy(logconfig + 8, loglevel, 13);
-        free(loglevel);
-        strcat(logconfig, " ");
-    }
-    if (logfile) {
-        strlcat(logconfig, logfile, MAXPATHLEN);
-        free(logfile);
-    }
-    setuplog(logconfig);
+    setuplog("default:note", NULL);
 
     if (err) {
         LOG(log_error, logtype_cnid, "main: bad arguments");
 
     if (err) {
         LOG(log_error, logtype_cnid, "main: bad arguments");
index 55bbcddbb100c3b34fb34f5355d965c00bc6b3f0..000abbf0aa06079b7b6267773ed5fce7c284139e 100644 (file)
@@ -313,8 +313,8 @@ int main(int argc, char *argv[])
 
     ctrlfd = atoi(argv[optind + 1]);
     clntfd = atoi(argv[optind + 2]);
 
     ctrlfd = atoi(argv[optind + 1]);
     clntfd = atoi(argv[optind + 2]);
-    logconfig = strdup(argv[optind + 3]);
-    setuplog(logconfig);
+
+    setuplog("default:note", NULL);
 
     if (vol_load_charsets(&volinfo) == -1) {
         LOG(log_error, logtype_cnid, "Error loading charsets!");
 
     if (vol_load_charsets(&volinfo) == -1) {
         LOG(log_error, logtype_cnid, "Error loading charsets!");
index 0d6eb677261157e1f4b3a05dd9e3ca554a066e30..7a910524699446d41745e4b5b6fb52aa0503e723 100644 (file)
@@ -50,8 +50,8 @@
 typedef struct _dictionary_ {
        int                             n ;             /** Number of entries in dictionary */
        int                             size ;  /** Storage size */
 typedef struct _dictionary_ {
        int                             n ;             /** Number of entries in dictionary */
        int                             size ;  /** Storage size */
-       char            **      val ;   /** List of string values */
-       char            **  key ;       /** List of string keys */
+       char        **  val ;   /** List of string values */
+       char        **  key ;   /** List of string keys */
        unsigned         *      hash ;  /** List of hash values for keys */
 } dictionary ;
 
        unsigned         *      hash ;  /** List of hash values for keys */
 } dictionary ;
 
@@ -63,7 +63,7 @@ typedef struct _dictionary_ {
 unsigned   dictionary_hash  (char * key);
 dictionary *dictionary_new  (int size);
 void       dictionary_del   (dictionary * vd);
 unsigned   dictionary_hash  (char * key);
 dictionary *dictionary_new  (int size);
 void       dictionary_del   (dictionary * vd);
-char       *dictionary_get  (dictionary * d, char *section, char * key, char * def);
+const char *dictionary_get  (const dictionary * d, const char *section, const char * key, const char * def);
 int        dictionary_set   (dictionary * vd, char *section, char * key, char * val);
 void       dictionary_unset (dictionary * d, char *section, char * key);
 void       dictionary_dump  (dictionary * d, FILE * out);
 int        dictionary_set   (dictionary * vd, char *section, char * key, char * val);
 void       dictionary_unset (dictionary * d, char *section, char * key);
 void       dictionary_dump  (dictionary * d, FILE * out);
index f520c209b400effd11975f8ee0be723c3a9799af..5af4cac570457f5228ff36bf1729781e98e81df3 100644 (file)
@@ -56,8 +56,11 @@ struct dsi_block {
 /* child and parent processes might interpret a couple of these
  * differently. */
 typedef struct DSI {
 /* child and parent processes might interpret a couple of these
  * differently. */
 typedef struct DSI {
-    DSI      *next;             /* multiple listening addresses */
+    struct DSI *next;             /* multiple listening addresses */
     AFPObj   *AFPobj;
     AFPObj   *AFPobj;
+    int      statuslen;
+    char     status[1400];
+    char     *signature;
     struct dsi_block        header;
     struct sockaddr_storage server, client;
     struct itimerval        timer;
     struct dsi_block        header;
     struct sockaddr_storage server, client;
     struct itimerval        timer;
@@ -69,9 +72,7 @@ typedef struct DSI {
 
     uint32_t attn_quantum, datasize, server_quantum;
     uint16_t serverID, clientID;
 
     uint32_t attn_quantum, datasize, server_quantum;
     uint16_t serverID, clientID;
-    char     *status;
     uint8_t  commands[DSI_CMDSIZ], data[DSI_DATASIZ];
     uint8_t  commands[DSI_CMDSIZ], data[DSI_DATASIZ];
-    size_t   statuslen;
     size_t   datalen, cmdlen;
     off_t    read_count, write_count;
     uint32_t flags;             /* DSI flags like DSI_SLEEPING, DSI_DISCONNECTED */
     size_t   datalen, cmdlen;
     off_t    read_count, write_count;
     uint32_t flags;             /* DSI flags like DSI_SLEEPING, DSI_DISCONNECTED */
@@ -155,12 +156,9 @@ typedef struct DSI {
 #endif
 
 /* basic initialization: dsi_init.c */
 #endif
 
 /* basic initialization: dsi_init.c */
-extern DSI *dsi_init (const dsi_proto /*protocol*/,
-                      const char * /*program*/,
-                      const char * /*host*/, const char * /*address*/,
-                      const char * /*port*/, const int /*proxy*/,
-                      const uint32_t /* server quantum */);
+extern DSI *dsi_init(AFPObj *obj, const char *hostname, const char *address, const char *port);
 extern void dsi_setstatus (DSI *, char *, const size_t);
 extern void dsi_setstatus (DSI *, char *, const size_t);
+extern int dsi_tcp_init(DSI *dsi, const char *hostname, const char *address, const char *port);
 
 /* in dsi_getsess.c */
 extern afp_child_t *dsi_getsession (DSI *, server_child *, const int);
 
 /* in dsi_getsess.c */
 extern afp_child_t *dsi_getsession (DSI *, server_child *, const int);
index 9175afe90be69dffbc8bffd14e721762c45031a0..aebb56adffcdafdb9463b712afa9fe91685186e0 100755 (executable)
@@ -54,7 +54,7 @@ int fce_register_file_modification( struct ofork *ofork );
 int fce_register_tm_size(const char *vol, size_t used);
 
 int fce_add_udp_socket(const char *target );  // IP or IP:Port
 int fce_register_tm_size(const char *vol, size_t used);
 
 int fce_add_udp_socket(const char *target );  // IP or IP:Port
-int fce_set_coalesce( char *coalesce_opt ); // all|delete|create
+int fce_set_coalesce(const char *coalesce_opt ); // all|delete|create
 int fce_set_events(const char *events);     /* fmod,fdel,ddel,fcre,dcre,tmsz (default is all except tmsz) */
 
 #define FCE_DEFAULT_PORT 12250
 int fce_set_events(const char *events);     /* fmod,fdel,ddel,fcre,dcre,tmsz (default is all except tmsz) */
 
 #define FCE_DEFAULT_PORT 12250
index 83fd3a1eeb0894e3795a001c9103c77ff35129ec..f8c353cac0a2e8356ccfc27348d200a9c93146d9 100644 (file)
 struct DSI;
 #define AFPOBJ_TMPSIZ (MAXPATHLEN)
 
 struct DSI;
 #define AFPOBJ_TMPSIZ (MAXPATHLEN)
 
-/* a couple of these options could get stuck in unions to save
- * space. */
 struct afp_volume_name {
     time_t     mtime;
 struct afp_volume_name {
     time_t     mtime;
-    char       *name;
-    char       *full_name;
     int        loaded;
 };
 
     int        loaded;
 };
 
@@ -108,12 +104,10 @@ struct afp_options {
 typedef struct AFPObj {
     int argc;
     char **argv;
 typedef struct AFPObj {
     int argc;
     char **argv;
-    int statuslen;
-    char status[1400];
     const void *signature;
     struct DSI *dsi;
     struct afp_options options;
     const void *signature;
     struct DSI *dsi;
     struct afp_options options;
-    const dictionary *iniconfig;
+    dictionary *iniconfig;
     char username[MAXUSERLEN];
     /* to prevent confusion, only use these in afp_* calls */
     char oldtmp[AFPOBJ_TMPSIZ + 1], newtmp[AFPOBJ_TMPSIZ + 1];
     char username[MAXUSERLEN];
     /* to prevent confusion, only use these in afp_* calls */
     char oldtmp[AFPOBJ_TMPSIZ + 1], newtmp[AFPOBJ_TMPSIZ + 1];
@@ -144,7 +138,7 @@ extern const char         *Cnid_port;
 
 extern int  get_afp_errno   (const int param);
 extern void afp_options_init (struct afp_options *);
 
 extern int  get_afp_errno   (const int param);
 extern void afp_options_init (struct afp_options *);
-extern int  afp_options_parse_cmdline (int ac, char **av);
+extern void afp_options_parse_cmdline(int ac, char **av);
 extern int  afp_config_parse(AFPObj *AFPObj);
 extern void afp_options_free(struct afp_options *);
 extern void setmessage (const char *);
 extern int  afp_config_parse(AFPObj *AFPObj);
 extern void afp_options_free(struct afp_options *);
 extern void setmessage (const char *);
index 6466358c8192265beb13013cac0ec9a867cc1c66..0eefa4cb3aa64c8603d985d60741d7ff09ffe0a4 100644 (file)
 
 #include "dictionary.h"
 
 
 #include "dictionary.h"
 
-int        iniparser_getnsec(dictionary * d);
-char       *iniparser_getsecname(dictionary * d, int n);
-void       iniparser_dump_ini(dictionary * d, FILE * f);
-void       iniparser_dump(dictionary * d, FILE * f);
-char       *iniparser_getstring(dictionary * d, char *section, char * key, char * def);
-char       *iniparser_getstrdup(dictionary * d, char *section, char * key, char * def);
-int        iniparser_getint(dictionary * d, char *section, char * key, int notfound);
-double     iniparser_getdouble(dictionary * d, char *section, char * key, double notfound);
-int        iniparser_getboolean(dictionary * d, char *section, char * key, int notfound);
+int        iniparser_getnsec(const dictionary * d);
+const char *iniparser_getsecname(const dictionary * d, int n);
+void       iniparser_dump_ini(const dictionary * d, FILE * f);
+void       iniparser_dump(const dictionary * d, FILE * f);
+const char *iniparser_getstring(const dictionary * d, const char *section, const char * key, const char * def);
+char       *iniparser_getstrdup(const dictionary * d, const char *section, const char * key, const char * def);
+int        iniparser_getint(const dictionary * d, const char *section, const char * key, int notfound);
+double     iniparser_getdouble(const dictionary * d, const char *section, const char * key, double notfound);
+int        iniparser_getboolean(const dictionary * d, const char *section, const char * key, int notfound);
 int        iniparser_set(dictionary * ini, char *section, char * key, char * val);
 void       iniparser_unset(dictionary * ini, char *section, char * key);
 int        iniparser_set(dictionary * ini, char *section, char * key, char * val);
 void       iniparser_unset(dictionary * ini, char *section, char * key);
-int        iniparser_find_entry(dictionary * ini, char * entry) ;
-dictionary *iniparser_load(char * ininame);
+int        iniparser_find_entry(const dictionary * ini, const char * entry) ;
+dictionary *iniparser_load(const char * ininame);
 void       iniparser_freedict(dictionary * d);
 
 #endif
 void       iniparser_freedict(dictionary * d);
 
 #endif
index 72207f1fcdb1d0aa28dc7ce6ea7958525d1cfe2d..dcb32e99d2e726b7feaaf67c0799e9454f35de59 100644 (file)
@@ -39,7 +39,6 @@
 #define UAM_OPTION_RANDNUM      (1 << 4) /* request a random number */
 #define UAM_OPTION_HOSTNAME     (1 << 5) /* get host name */
 #define UAM_OPTION_COOKIE       (1 << 6) /* cookie handle */
 #define UAM_OPTION_RANDNUM      (1 << 4) /* request a random number */
 #define UAM_OPTION_HOSTNAME     (1 << 5) /* get host name */
 #define UAM_OPTION_COOKIE       (1 << 6) /* cookie handle */
-#define UAM_OPTION_PROTOCOL    (1 << 7) /* DSI or ASP */
 #define UAM_OPTION_CLIENTNAME   (1 << 8) /* get client IP address */
 #define UAM_OPTION_KRB5SERVICE  (1 << 9) /* service name for krb5 principal */
 #define UAM_OPTION_MACCHARSET   (1 << 10) /* mac charset handle */
 #define UAM_OPTION_CLIENTNAME   (1 << 8) /* get client IP address */
 #define UAM_OPTION_KRB5SERVICE  (1 << 9) /* service name for krb5 principal */
 #define UAM_OPTION_MACCHARSET   (1 << 10) /* mac charset handle */
index d719cafdfc4a2c66ea32a4297c195fddc93e949b..bbba8b66c2fae1e8cce37b7d7781cd07bfcc40fc 100644 (file)
@@ -25,6 +25,7 @@
 #include <ctype.h>
 #include <ldap.h>
 
 #include <ctype.h>
 #include <ldap.h>
 
+#include <atalk/globals.h>
 #include <atalk/ldapconfig.h>
 #include <atalk/logger.h>
 #include <atalk/iniparser.h>
 #include <atalk/ldapconfig.h>
 #include <atalk/logger.h>
 #include <atalk/iniparser.h>
@@ -37,9 +38,7 @@ int acl_ldap_readconfig(dictionary *iniconfig)
     i = 0;
     /* now see if its a correct pref */
     for (i = 0; ldap_prefs[i].name != NULL; i++) {
     i = 0;
     /* now see if its a correct pref */
     for (i = 0; ldap_prefs[i].name != NULL; i++) {
-        if ((val = iniparser_getstring(ldap_prefs[i].name)) != NULL) {
-            /* ok, found a valid pref */
-
+        if ((val = iniparser_getstring(iniconfig, INISEC_AFP, ldap_prefs[i].name, NULL))) {
             /* check if we have pre-defined values */
             if (ldap_prefs[i].intfromarray == 0) {
                 /* no, its just a string */
             /* check if we have pre-defined values */
             if (ldap_prefs[i].intfromarray == 0) {
                 /* no, its just a string */
@@ -89,7 +88,6 @@ int acl_ldap_readconfig(dictionary *iniconfig)
         }
     } else
         LOG(log_info, logtype_afpd,"afp_ldap.conf: not used");
         }
     } else
         LOG(log_info, logtype_afpd,"afp_ldap.conf: not used");
-    fclose(f);
     return 0;
 }
 #endif /* HAVE_LDAP */
     return 0;
 }
 #endif /* HAVE_LDAP */
index d64cbed69f8babe20481577e9e13905219195877..34fa76e544e2bd7e462dfeb72ca579fe419db37c 100644 (file)
@@ -7,5 +7,3 @@ LIBS = @LIBS@
 noinst_LTLIBRARIES = libdsi.la
 
 libdsi_la_SOURCES = dsi_attn.c dsi_close.c dsi_cmdreply.c dsi_getsess.c dsi_getstat.c dsi_init.c dsi_opensess.c dsi_read.c dsi_tcp.c dsi_tickle.c dsi_write.c dsi_stream.c
 noinst_LTLIBRARIES = libdsi.la
 
 libdsi_la_SOURCES = dsi_attn.c dsi_close.c dsi_cmdreply.c dsi_getsess.c dsi_getstat.c dsi_init.c dsi_opensess.c dsi_read.c dsi_tcp.c dsi_tickle.c dsi_write.c dsi_stream.c
-
-noinst_HEADERS = dsi_private.h
index 568f9ffdfd9f6565547f453f45a0f1ea49ed409e..824d31f36d255d407192bd6a9eaec98be63fda80 100644 (file)
@@ -1,7 +1,5 @@
 /*
 /*
- * $Id: dsi_init.c,v 1.10 2009-11-05 14:38:08 franklahm Exp $
- *
- * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
+ * Copyright (c) 2012, Frank Lahm <franklahm@googlemail.com>
  * All rights reserved. See COPYRIGHT.
  */
 
  * All rights reserved. See COPYRIGHT.
  */
 
@@ -13,7 +11,6 @@
 #include <stdlib.h>
 #include <signal.h>
 #include <atalk/dsi.h>
 #include <stdlib.h>
 #include <signal.h>
 #include <atalk/dsi.h>
-#include "dsi_private.h"
 
 DSI *dsi_init(AFPObj *obj, const char *hostname, const char *address, const char *port)
 {
 
 DSI *dsi_init(AFPObj *obj, const char *hostname, const char *address, const char *port)
 {
@@ -24,7 +21,7 @@ DSI *dsi_init(AFPObj *obj, const char *hostname, const char *address, const char
 
     dsi->attn_quantum = DSI_DEFQUANT;
     dsi->server_quantum = obj->options.server_quantum;
 
     dsi->attn_quantum = DSI_DEFQUANT;
     dsi->server_quantum = obj->options.server_quantum;
-    dsi->dsireadbuf = obj->options->dsireadbuf;
+    dsi->dsireadbuf = obj->options.dsireadbuf;
 
     /* currently the only transport protocol that exists for dsi */
     if (dsi_tcp_init(dsi, hostname, address, port) != 0) {
 
     /* currently the only transport protocol that exists for dsi */
     if (dsi_tcp_init(dsi, hostname, address, port) != 0) {
@@ -34,9 +31,3 @@ DSI *dsi_init(AFPObj *obj, const char *hostname, const char *address, const char
 
     return dsi;
 }
 
     return dsi;
 }
-
-void dsi_setstatus(DSI *dsi, char *status, const size_t slen)
-{
-    dsi->status = status;
-    dsi->statuslen = slen;
-}
diff --git a/libatalk/dsi/dsi_private.h b/libatalk/dsi/dsi_private.h
deleted file mode 100644 (file)
index c953afd..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
- * All rights reserved. See COPYRIGHT.
- */
-
-#ifndef _DSI_PRIVATE_H
-#define _DSI_PRIVATE_H 1
-
-/* this header handles interactions between protocol-specific code and
- * dsi initialization. only dsi_init.c and dsi_<proto>.c should
- * include it.
- */
-
-#include <sys/types.h>
-#include <arpa/inet.h>
-
-extern int dsi_tcp_init (DSI *, const char * /*host*/, 
-                            const char * /*address*/,
-                            const char * /*port*/,
-                            const int /*proxy*/);
-
-#endif /* _DSI_PRIVATE_H */
index f11eca51f59d2f93aaab5b60bef6d292b34b5b31..01aca6f7f39826a8a1c81e2dfbd96c1418ac5300 100644 (file)
@@ -53,8 +53,6 @@ int deny_severity = log_warning;
 #include <atalk/util.h>
 #include <atalk/errchk.h>
 
 #include <atalk/util.h>
 #include <atalk/errchk.h>
 
-#include "dsi_private.h"
-
 #define min(a,b)  ((a) < (b) ? (a) : (b))
 
 #ifndef DSI_TCPMAXPEND
 #define min(a,b)  ((a) < (b) ? (a) : (b))
 
 #ifndef DSI_TCPMAXPEND
@@ -273,17 +271,19 @@ int dsi_tcp_init(DSI *dsi, const char *hostname, const char *inaddress, const ch
 {
     EC_INIT;
     int                flag;
 {
     EC_INIT;
     int                flag;
-    char               *p, *address = NULL;
+    char               *a = NULL, *b;
+    const char         *address;
+    const char         *port;
     struct addrinfo    hints, *servinfo, *p;
 
     /* Check whether address is of the from IP:PORT and split */
     address = inaddress;
     port = inport;
     if (address && strchr(address, ':')) {
     struct addrinfo    hints, *servinfo, *p;
 
     /* Check whether address is of the from IP:PORT and split */
     address = inaddress;
     port = inport;
     if (address && strchr(address, ':')) {
-        EC_NULL_LOG( address = strdup(inaddress) );
-        p = strchr(address, ':');
-        *p = 0;
-        port = p + 1;
+        EC_NULL_LOG( address = a = strdup(address) );
+        b = strchr(a, ':');
+        *b = 0;
+        port = b + 1;
     }
 
     /* Prepare hint for getaddrinfo */
     }
 
     /* Prepare hint for getaddrinfo */
@@ -310,64 +310,59 @@ int dsi_tcp_init(DSI *dsi, const char *hostname, const char *inaddress, const ch
         EC_FAIL;
     }
 
         EC_FAIL;
     }
 
-    /* create a socket */
-    if (proxy)
-        dsi->serversock = -1;
-    else {
-        /* loop through all the results and bind to the first we can */
-        for (p = servinfo; p != NULL; p = p->ai_next) {
-            if ((dsi->serversock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
-                LOG(log_info, logtype_dsi, "dsi_tcp_init: socket: %s", strerror(errno));
-                continue;
-            }
+    /* loop through all the results and bind to the first we can */
+    for (p = servinfo; p != NULL; p = p->ai_next) {
+        if ((dsi->serversock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
+            LOG(log_info, logtype_dsi, "dsi_tcp_init: socket: %s", strerror(errno));
+            continue;
+        }
 
 
-            /*
-             * Set some socket options:
-             * SO_REUSEADDR deals w/ quick close/opens
-             * TCP_NODELAY diables Nagle
-             */
+        /*
+         * Set some socket options:
+         * SO_REUSEADDR deals w/ quick close/opens
+         * TCP_NODELAY diables Nagle
+         */
 #ifdef SO_REUSEADDR
 #ifdef SO_REUSEADDR
-            flag = 1;
-            setsockopt(dsi->serversock, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
+        flag = 1;
+        setsockopt(dsi->serversock, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
 #endif
 #if defined(FREEBSD) && defined(IPV6_BINDV6ONLY)
 #endif
 #if defined(FREEBSD) && defined(IPV6_BINDV6ONLY)
-            int on = 0;
-            setsockopt(dsi->serversock, IPPROTO_IPV6, IPV6_BINDV6ONLY, (char *)&on, sizeof (on));
+        int on = 0;
+        setsockopt(dsi->serversock, IPPROTO_IPV6, IPV6_BINDV6ONLY, (char *)&on, sizeof (on));
 #endif
 
 #ifdef USE_TCP_NODELAY
 #ifndef SOL_TCP
 #define SOL_TCP IPPROTO_TCP
 #endif
 #endif
 
 #ifdef USE_TCP_NODELAY
 #ifndef SOL_TCP
 #define SOL_TCP IPPROTO_TCP
 #endif
-            flag = 1;
-            setsockopt(dsi->serversock, SOL_TCP, TCP_NODELAY, &flag, sizeof(flag));
+        flag = 1;
+        setsockopt(dsi->serversock, SOL_TCP, TCP_NODELAY, &flag, sizeof(flag));
 #endif /* USE_TCP_NODELAY */
             
 #endif /* USE_TCP_NODELAY */
             
-            if (bind(dsi->serversock, p->ai_addr, p->ai_addrlen) == -1) {
-                close(dsi->serversock);
-                LOG(log_info, logtype_dsi, "dsi_tcp_init: bind: %s\n", strerror(errno));
-                continue;
-            }
-
-            if (listen(dsi->serversock, DSI_TCPMAXPEND) < 0) {
-                close(dsi->serversock);
-                LOG(log_info, logtype_dsi, "dsi_tcp_init: listen: %s\n", strerror(errno));
-                continue;
-            }
-            
-            break;
+        if (bind(dsi->serversock, p->ai_addr, p->ai_addrlen) == -1) {
+            close(dsi->serversock);
+            LOG(log_info, logtype_dsi, "dsi_tcp_init: bind: %s\n", strerror(errno));
+            continue;
         }
 
         }
 
-        if (p == NULL)  {
-            LOG(log_error, logtype_dsi, "dsi_tcp_init: no suitable network config for TCP socket");
-            freeaddrinfo(servinfo);
-            EC_FAIL;
+        if (listen(dsi->serversock, DSI_TCPMAXPEND) < 0) {
+            close(dsi->serversock);
+            LOG(log_info, logtype_dsi, "dsi_tcp_init: listen: %s\n", strerror(errno));
+            continue;
         }
         }
+            
+        break;
+    }
 
 
-        /* Copy struct sockaddr to struct sockaddr_storage */
-        memcpy(&dsi->server, p->ai_addr, p->ai_addrlen);
+    if (p == NULL)  {
+        LOG(log_error, logtype_dsi, "dsi_tcp_init: no suitable network config for TCP socket");
         freeaddrinfo(servinfo);
         freeaddrinfo(servinfo);
-    } /* if (proxy) */
+        EC_FAIL;
+    }
+
+    /* Copy struct sockaddr to struct sockaddr_storage */
+    memcpy(&dsi->server, p->ai_addr, p->ai_addrlen);
+    freeaddrinfo(servinfo);
 
     /* Point protocol specific functions to tcp versions */
     dsi->proto_open = dsi_tcp_open;
 
     /* Point protocol specific functions to tcp versions */
     dsi->proto_open = dsi_tcp_open;
@@ -416,8 +411,8 @@ interfaces:
     guess_interface(dsi, hostname, port ? port : "548");
 
 EC_CLEANUP:
     guess_interface(dsi, hostname, port ? port : "548");
 
 EC_CLEANUP:
-    if (address)
-        free(address);
+    if (a)
+        free(a);
     EC_EXIT;
 }
 
     EC_EXIT;
 }
 
index 6ba083583de8d3b6b7daf9c3ed1f71d3be0e5c92..1848b45db15c036ada509e72ccbb1af74dd7875c 100644 (file)
@@ -193,7 +193,7 @@ void dictionary_del(dictionary * d)
   dictionary object, you should not try to free it or modify it.
  */
 /*--------------------------------------------------------------------------*/
   dictionary object, you should not try to free it or modify it.
  */
 /*--------------------------------------------------------------------------*/
-char * dictionary_get(dictionary * d, char *section, char * key, char * def)
+const char * dictionary_get(const dictionary * d, const char *section, const char * key, const char * def)
 {
        unsigned        hash ;
        int                     i ;
 {
        unsigned        hash ;
        int                     i ;
index 0308ed2c8a2a2d015c84aa0a410d381b5c443b02..761b9303fc947e0e16ae8c9f321aa8ad445dbc4d 100644 (file)
@@ -88,7 +88,7 @@ static char * strstrip(char * s)
   This function returns -1 in case of error.
  */
 /*--------------------------------------------------------------------------*/
   This function returns -1 in case of error.
  */
 /*--------------------------------------------------------------------------*/
-int iniparser_getnsec(dictionary * d)
+int iniparser_getnsec(const dictionary * d)
 {
     int i ;
     int nsec ;
 {
     int i ;
     int nsec ;
@@ -119,7 +119,7 @@ int iniparser_getnsec(dictionary * d)
   This function returns NULL in case of error.
  */
 /*--------------------------------------------------------------------------*/
   This function returns NULL in case of error.
  */
 /*--------------------------------------------------------------------------*/
-char * iniparser_getsecname(dictionary * d, int n)
+const char * iniparser_getsecname(const dictionary * d, int n)
 {
     int i ;
     int foundsec ;
 {
     int i ;
     int foundsec ;
@@ -154,7 +154,7 @@ char * iniparser_getsecname(dictionary * d, int n)
   purposes mostly.
  */
 /*--------------------------------------------------------------------------*/
   purposes mostly.
  */
 /*--------------------------------------------------------------------------*/
-void iniparser_dump(dictionary * d, FILE * f)
+void iniparser_dump(const dictionary * d, FILE * f)
 {
     int     i ;
 
 {
     int     i ;
 
@@ -182,12 +182,12 @@ void iniparser_dump(dictionary * d, FILE * f)
   It is Ok to specify @c stderr or @c stdout as output files.
  */
 /*--------------------------------------------------------------------------*/
   It is Ok to specify @c stderr or @c stdout as output files.
  */
 /*--------------------------------------------------------------------------*/
-void iniparser_dump_ini(dictionary * d, FILE * f)
+void iniparser_dump_ini(const dictionary * d, FILE * f)
 {
     int     i, j ;
     char    keym[ASCIILINESZ+1];
     int     nsec ;
 {
     int     i, j ;
     char    keym[ASCIILINESZ+1];
     int     nsec ;
-    char *  secname ;
+    const char *  secname ;
     int     seclen ;
 
     if (d==NULL || f==NULL) return ;
     int     seclen ;
 
     if (d==NULL || f==NULL) return ;
@@ -238,9 +238,9 @@ void iniparser_dump_ini(dictionary * d, FILE * f)
   the dictionary, do not free or modify it.
  */
 /*--------------------------------------------------------------------------*/
   the dictionary, do not free or modify it.
  */
 /*--------------------------------------------------------------------------*/
-char * iniparser_getstring(dictionary * d, char *section, char * key, char * def)
+const char * iniparser_getstring(const dictionary * d, const char *section, const char * key, const char * def)
 {
 {
-    char * sval ;
+    const char * sval ;
 
     if (d==NULL || key==NULL)
         return def ;
 
     if (d==NULL || key==NULL)
         return def ;
@@ -264,12 +264,12 @@ char * iniparser_getstring(dictionary * d, char *section, char * key, char * def
   The returned char pointer a strdup'ed allocated string, so the caller must free it.
  */
 /*--------------------------------------------------------------------------*/
   The returned char pointer a strdup'ed allocated string, so the caller must free it.
  */
 /*--------------------------------------------------------------------------*/
-char * iniparser_getstrdup(dictionary * d, char *section, char * key, char * def)
+char * iniparser_getstrdup(const dictionary * d, const char *section, const char * key, const char * def)
 {
 {
-    char * sval ;
+    const char * sval ;
 
     if (d==NULL || key==NULL)
 
     if (d==NULL || key==NULL)
-        return def ;
+        return NULL;
 
     if ((sval = dictionary_get(d, section, key, def)))
         return strdup(sval);
 
     if ((sval = dictionary_get(d, section, key, def)))
         return strdup(sval);
@@ -304,9 +304,9 @@ char * iniparser_getstrdup(dictionary * d, char *section, char * key, char * def
   Credits: Thanks to A. Becker for suggesting strtol()
  */
 /*--------------------------------------------------------------------------*/
   Credits: Thanks to A. Becker for suggesting strtol()
  */
 /*--------------------------------------------------------------------------*/
-int iniparser_getint(dictionary * d, char *section, char * key, int notfound)
+int iniparser_getint(const dictionary * d, const char *section, const char * key, int notfound)
 {
 {
-    char    *   str ;
+    const char    *   str ;
 
     str = iniparser_getstring(d, section, key, INI_INVALID_KEY);
     if (str==INI_INVALID_KEY) return notfound ;
 
     str = iniparser_getstring(d, section, key, INI_INVALID_KEY);
     if (str==INI_INVALID_KEY) return notfound ;
@@ -327,9 +327,9 @@ int iniparser_getint(dictionary * d, char *section, char * key, int notfound)
   the notfound value is returned.
  */
 /*--------------------------------------------------------------------------*/
   the notfound value is returned.
  */
 /*--------------------------------------------------------------------------*/
-double iniparser_getdouble(dictionary * d, char *section, char * key, double notfound)
+double iniparser_getdouble(const dictionary * d, const char *section, const char * key, double notfound)
 {
 {
-    char    *   str ;
+    const char    *   str ;
 
     str = iniparser_getstring(d, section, key, INI_INVALID_KEY);
     if (str==INI_INVALID_KEY) return notfound ;
 
     str = iniparser_getstring(d, section, key, INI_INVALID_KEY);
     if (str==INI_INVALID_KEY) return notfound ;
@@ -369,9 +369,9 @@ double iniparser_getdouble(dictionary * d, char *section, char * key, double not
   necessarily have to be 0 or 1.
  */
 /*--------------------------------------------------------------------------*/
   necessarily have to be 0 or 1.
  */
 /*--------------------------------------------------------------------------*/
-int iniparser_getboolean(dictionary * d, char *section, char * key, int notfound)
+int iniparser_getboolean(const dictionary * d, const char *section, const char * key, int notfound)
 {
 {
-    char    *   c ;
+    const char    *   c ;
     int         ret ;
 
     c = iniparser_getstring(d, section, key, INI_INVALID_KEY);
     int         ret ;
 
     c = iniparser_getstring(d, section, key, INI_INVALID_KEY);
@@ -398,7 +398,7 @@ int iniparser_getboolean(dictionary * d, char *section, char * key, int notfound
   of querying for the presence of sections in a dictionary.
  */
 /*--------------------------------------------------------------------------*/
   of querying for the presence of sections in a dictionary.
  */
 /*--------------------------------------------------------------------------*/
-int iniparser_find_entry(dictionary *ini, char *entry)
+int iniparser_find_entry(const dictionary *ini, const char *entry)
 {
     int found=0 ;
     if (iniparser_getstring(ini, entry, NULL, INI_INVALID_KEY)!=INI_INVALID_KEY) {
 {
     int found=0 ;
     if (iniparser_getstring(ini, entry, NULL, INI_INVALID_KEY)!=INI_INVALID_KEY) {
@@ -526,7 +526,7 @@ static line_status iniparser_line(
   The returned dictionary must be freed using iniparser_freedict().
  */
 /*--------------------------------------------------------------------------*/
   The returned dictionary must be freed using iniparser_freedict().
  */
 /*--------------------------------------------------------------------------*/
-dictionary * iniparser_load(char * ininame)
+dictionary * iniparser_load(const char * ininame)
 {
     FILE * in ;
 
 {
     FILE * in ;
 
index c1e981dd417d5bf8473a1764ad2cef98c1802291..b96b2181c506e5f7314010155e0df54e486e0218 100644 (file)
@@ -90,16 +90,20 @@ UAM_MODULE_EXPORT logtype_conf_t type_configs[logtype_end_of_list_marker] = {
     DEFAULT_LOG_CONFIG /* logtype_uams */
 };
 
     DEFAULT_LOG_CONFIG /* logtype_uams */
 };
 
+static void syslog_setup(int loglevel, enum logtypes logtype, int display_options, int facility);
+
 /* We use this in order to track the last n log messages in order to prevent flooding */
 #define LOG_FLOODING_MINCOUNT 5 /* this controls after how many consecutive messages must be detected
                                    before we start to hide them */
 #define LOG_FLOODING_MAXCOUNT 1000 /* this controls after how many consecutive messages we force a 
                                       "repeated x times" message */
 #define LOG_FLOODING_ARRAY_SIZE 3 /* this contols how many messages in flow we track */
 /* We use this in order to track the last n log messages in order to prevent flooding */
 #define LOG_FLOODING_MINCOUNT 5 /* this controls after how many consecutive messages must be detected
                                    before we start to hide them */
 #define LOG_FLOODING_MAXCOUNT 1000 /* this controls after how many consecutive messages we force a 
                                       "repeated x times" message */
 #define LOG_FLOODING_ARRAY_SIZE 3 /* this contols how many messages in flow we track */
+
 struct log_flood_entry {
     int count;
     unsigned int hash;
 };
 struct log_flood_entry {
     int count;
     unsigned int hash;
 };
+
 static struct log_flood_entry log_flood_array[LOG_FLOODING_ARRAY_SIZE];
 static int log_flood_entries;
 
 static struct log_flood_entry log_flood_array[LOG_FLOODING_ARRAY_SIZE];
 static int log_flood_entries;
 
@@ -639,7 +643,7 @@ void setuplog(const char *logstr, const char *logfile)
             ptr++;
         c = *ptr;
         *ptr = 0;
             ptr++;
         c = *ptr;
         *ptr = 0;
-        setuplog_internal(loglevel, logtype, filename);
+        setuplog_internal(loglevel, logtype, logfile);
         *ptr = c;
     }
 
         *ptr = c;
     }