]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afp_config.c
IPv6 support for afpd and cnid_metad
[netatalk.git] / etc / afpd / afp_config.c
index 7949cb3c4f9b6b417376a71fb35601d87efad66d..8c8ac012ad964c79e441d9463869bc4fe096203f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_config.c,v 1.24 2009-01-16 18:45:26 morgana Exp $
+ * $Id: afp_config.c,v 1.29 2009-11-05 14:38:07 franklahm Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved.  See COPYRIGHT.
@@ -50,6 +50,9 @@ char *strchr (), *strrchr ();
 #ifdef USE_SRVLOC
 #include <slp.h>
 #endif /* USE_SRVLOC */
+#ifdef HAVE_NFSv4_ACLS
+#include <atalk/ldapconfig.h>
+#endif
 
 #include "globals.h"
 #include "afp_config.h"
@@ -114,7 +117,7 @@ static char * srvloc_encode(const struct afp_options *options, const char *name)
 
        /* Convert name to maccharset */
         if ((size_t)-1 ==(convert_string_allocate( options->unixcharset, options->maccharset,
-                        name, strlen(name), &conv_name)) )
+                        name, -1, &conv_name)) )
                return (char*)name;
 
        /* Escape characters */
@@ -362,6 +365,11 @@ static AFPConfig *DSIConfigInit(const struct afp_options *options,
         return NULL;
     }
 
+    LOG(log_debug, logtype_afpd, "DSIConfigInit: hostname: %s, ip/port: %s/%s, ",
+        options->hostname,
+        options->ipaddr ? options->ipaddr : "default",
+        options->port ? options->port : "548");
+
     if ((dsi = dsi_init(protocol, "afpd", options->hostname,
                         options->ipaddr, options->port,
                         options->flags & OPTION_PROXY,
@@ -372,13 +380,11 @@ static AFPConfig *DSIConfigInit(const struct afp_options *options,
     }
 
     if (options->flags & OPTION_PROXY) {
-        LOG(log_info, logtype_afpd, "ASIP proxy initialized for %s:%d (%s)",
-            inet_ntoa(dsi->server.sin_addr), ntohs(dsi->server.sin_port),
-            VERSION);
+        LOG(log_info, logtype_afpd, "AFP/TCP proxy initialized for %s:%d (%s)",
+            getip_string((struct sockaddr *)&dsi->server), getip_port((struct sockaddr *)&dsi->server), VERSION);
     } else {
-        LOG(log_info, logtype_afpd, "ASIP started on %s:%d(%d) (%s)",
-            inet_ntoa(dsi->server.sin_addr), ntohs(dsi->server.sin_port),
-            dsi->serversock, VERSION);
+        LOG(log_info, logtype_afpd, "AFP/TCP started, advertising %s:%d (%s)",
+            getip_string((struct sockaddr *)&dsi->server), getip_port((struct sockaddr *)&dsi->server), VERSION);
     }
 
 #ifdef USE_SRVLOC
@@ -538,6 +544,13 @@ AFPConfig *configinit(struct afp_options *cmdline)
     struct afp_options options;
     AFPConfig *config=NULL, *first = NULL; 
 
+#ifdef HAVE_NFSv4_ACLS
+    /* Parse ldap.conf first so we can set the uuid option */
+    LOG(log_debug, logtype_afpd, "Start parsing ldap.conf");
+    acl_ldap_readconfig(_PATH_ACL_LDAPCONF);
+    LOG(log_debug, logtype_afpd, "Finished parsing ldap.conf");
+#endif
+
     status_reset();
     /* if config file doesn't exist, load defaults */
     if ((fp = fopen(cmdline->configfile, "r")) == NULL)
@@ -555,7 +568,7 @@ AFPConfig *configinit(struct afp_options *cmdline)
        if (!fgets(&buf[len], LINESIZE - len, fp) || buf[len] == '#')
             continue;
        len = strlen(buf);
-       if ( buf[len-2] == '\\' ) {
+       if ( len >= 2 && buf[len-2] == '\\' ) {
            len -= 2;
            continue;
        } else
@@ -574,6 +587,12 @@ AFPConfig *configinit(struct afp_options *cmdline)
         if (!afp_options_parseline(p, &options))
             continue;
 
+#ifdef HAVE_NFSv4_ACLS
+       /* Enable UUID support if LDAP config is complete */
+       if (ldap_config_valid)
+           options.flags |= OPTION_UUID;
+#endif
+
         /* this should really get a head and a tail to simplify things. */
         if (!first) {
             if ((first = AFPConfigInit(&options, cmdline)))
@@ -587,7 +606,7 @@ AFPConfig *configinit(struct afp_options *cmdline)
     fclose(fp);
 
     if (!have_option)
-        return AFPConfigInit(cmdline, cmdline);
+        first = AFPConfigInit(cmdline, cmdline);
 
     return first;
 }