]> arthur.barton.de Git - netatalk.git/commitdiff
Fix for uninitialized AFP signature. From HAT
authorFrank Lahm <franklahm@googlemail.com>
Wed, 26 May 2010 08:20:35 +0000 (10:20 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Wed, 26 May 2010 08:20:35 +0000 (10:20 +0200)
NEWS
etc/afpd/afp_config.c
etc/afpd/afp_options.c
etc/afpd/globals.h
etc/afpd/status.c
etc/afpd/status.h

diff --git a/NEWS b/NEWS
index 5118b79d7abd23ae028a36f8dbc80e88f715f771..e013d6ce566f0213e7840114014f70f1183ca35b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Changes in 2.1.1
        [Open]Solaris.
 * FIX: afpd: Check if options->server is set in set_signature, preventing
        SIGSEGV.
+* FIX: afpd: server signature wasn't initialized in some cases
 * FIX: DESTDIR support: DESTDIR was expanded twice
 * FIX: Fix for compilation error if header files of an older Netatalk
        version are installed.
index 0a46ee2d63acf117d495260f5b81d52a69840715..6381479d0ddc6a30b46ba069849d582be927f731 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: afp_config.c,v 1.32 2010-03-29 15:22:57 franklahm Exp $
- *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved.  See COPYRIGHT.
  */
@@ -497,6 +495,10 @@ static AFPConfig *AFPConfigInit(const struct afp_options *options,
         config->defoptions = defoptions;
 #endif /* NO_DDP */
 
+
+    /* set signature */
+    set_signature(options);
+
     /* handle dsi transports and dsi proxies. we only proxy
      * for DSI connections. */
 
index aa728512e0ba722be8133d4d5f23f1ea25b699fc..ebc9a653e79e1ee890de1d051fd2cec6d7be4d73 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: afp_options.c,v 1.54 2010-04-02 16:17:22 hat001 Exp $
- *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -137,8 +135,10 @@ void afp_options_free(struct afp_options *opt,
         free(opt->uamlist);
     if (opt->passwdfile && (opt->passwdfile != save->passwdfile))
         free(opt->passwdfile);
+    if (opt->signatureopt && (opt->signatureopt != save->signatureopt))
+       free(opt->signatureopt);
     if (opt->signature && (opt->signature != save->signature))
-       free(opt->signature);
+        free(opt->signature);
     if (opt->k5service && (opt->k5service != save->k5service))
        free(opt->k5service);
     if (opt->k5realm && (opt->k5realm != save->k5realm))
@@ -177,6 +177,7 @@ void afp_options_init(struct afp_options *options)
     options->sleep = 10* 120; /* 10 h in 30 seconds tick */
     options->server_notif = 1;
     options->authprintdir = NULL;
+    options->signatureopt = "auto";
     options->umask = 0;
 #ifdef ADMIN_GRP
     options->admingid = 0;
@@ -398,6 +399,8 @@ int afp_options_parseline(char *buf, struct afp_options *options)
         options->port = strdup(c);
     if ((c = getoption(buf, "-ddpaddr")))
         atalk_aton(c, &options->ddpaddr);
+    if ((c = getoption(buf, "-signature")) && (opt = strdup(c)))
+        options->signatureopt = opt;
 
     /* do a little checking for the domain name. */
     if ((c = getoption(buf, "-fqdn"))) {
@@ -446,13 +449,6 @@ int afp_options_parseline(char *buf, struct afp_options *options)
 
     if ((c = getoption(buf, "-ntseparator")) && (opt = strdup(c)))
        options->ntseparator = opt;
-     
-    if ((c = getoption(buf, "-signature")) && (opt = strdup(c))) {
-        set_signature(opt, options);
-    }
-    else {
-        set_signature("auto", options);
-    }
 
     return 1;
 }
index e096044a2603d63bfcce5860aafd19606b66e306..40af2fe1d756b9ea92bb620462ef8d80b4f679fb 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: globals.h,v 1.33 2010-03-29 15:22:57 franklahm Exp $
- *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
  */
@@ -70,6 +68,7 @@ struct afp_options {
     char *guest, *loginmesg, *keyfile, *passwdfile;
     char *uamlist;
     char *authprintdir;
+    char *signatureopt;
     unsigned char signature[16];
     char *k5service, *k5realm, *k5keytab;
     char *unixcodepage,*maccodepage;
index ee9bd1fddd0fb15b304a9515d999ec07a75d59e7..bcdca483f38c5d5e3b6ca54fe3e4a533d7c62907 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: status.c,v 1.31 2010-03-29 15:22:57 franklahm Exp $
- *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
  */
@@ -551,7 +549,7 @@ void status_init(AFPConfig *aspconfig, AFPConfig *dsiconfig,
 /* If cannot open conf file, use one-time signature.                  */
 /* If -signature user:xxxxx, use it.                                  */
 
-void set_signature(char *opt, struct afp_options *options) {
+void set_signature(struct afp_options *options) {
     char *usersign;
     int fd, i;
     struct stat tmpstat;
@@ -563,27 +561,27 @@ void set_signature(char *opt, struct afp_options *options) {
     char *server_tmp;
     
     server_tmp = (options->server ? options->server : options->hostname);
-    if (strcmp(opt, "auto") == 0) {
+    if (strcmp(options->signatureopt, "auto") == 0) {
         goto server_signature_auto;   /* default */
-    } else if (strcmp(opt, "host") == 0) {
-        LOG(log_warning, logtype_afpd, "WARNING: option \"-signature host\" is obsoleted. Switching back to auto.", opt);
+    } else if (strcmp(options->signatureopt, "host") == 0) {
+        LOG(log_warning, logtype_afpd, "WARNING: option \"-signature host\" is obsoleted. Switching back to auto.", options->signatureopt);
         goto server_signature_auto;   /* same as auto */
-    } else if (strncmp(opt, "user", 4) == 0) {
+    } else if (strncmp(options->signatureopt, "user", 4) == 0) {
         goto server_signature_user;   /*  user string */
     } else {
-        LOG(log_error, logtype_afpd, "ERROR: option \"-signature %s\" is not valid. Switching back to auto.", opt);
+        LOG(log_error, logtype_afpd, "ERROR: option \"-signature %s\" is not valid. Switching back to auto.", options->signatureopt);
         goto server_signature_auto;   /* switch back to auto*/
     }
     
 server_signature_user:
     
     /* Signature type is user string */
-    len = strlen(opt);
+    len = strlen(options->signatureopt);
     if (len <= 5) {
-        LOG(log_warning, logtype_afpd, "WARNING: option \"-signature %s\" is not valid. Switching back to auto.", opt);
+        LOG(log_warning, logtype_afpd, "WARNING: option \"-signature %s\" is not valid. Switching back to auto.", options->signatureopt);
         goto server_signature_auto;
     }
-    usersign = opt + 5;
+    usersign = options->signatureopt + 5;
     len = len - 5;
     if (len > 16) {
         LOG(log_warning, logtype_afpd, "WARNING: signature user string %s is very long !",  usersign);
index c4a696bd590b9698903711e6c6d700eabf9e0168..3a29a17418f092681bbf986e7de0a6b365158f91 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * $Id: status.h,v 1.11 2010-03-29 15:22:57 franklahm Exp $
- */
-
 #ifndef AFPD_STATUS_H
 #define AFPD_STATUS_H 1
 
@@ -43,7 +39,7 @@ extern void status_versions (char * /*status*/, const ASP, const DSI *);
 extern void status_uams (char * /*status*/, const char * /*authlist*/);
 extern void status_init (AFPConfig *, AFPConfig *,
                                  const struct afp_options *);
-extern void set_signature(char *, struct afp_options *);
+extern void set_signature(struct afp_options *);
 
 /* FP functions */
 int afp_getsrvrinfo (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,  size_t *rbuflen);