From: Frank Lahm Date: Wed, 26 May 2010 08:20:35 +0000 (+0200) Subject: Fix for uninitialized AFP signature. From HAT X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f22b2f0df4776198f29eecafe6436d2e1e31f972;hp=68df0ba6ce53df85c33a9b1f559351cce8810eda;p=netatalk.git Fix for uninitialized AFP signature. From HAT --- diff --git a/NEWS b/NEWS index 5118b79d..e013d6ce 100644 --- 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. diff --git a/etc/afpd/afp_config.c b/etc/afpd/afp_config.c index 0a46ee2d..6381479d 100644 --- a/etc/afpd/afp_config.c +++ b/etc/afpd/afp_config.c @@ -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. */ diff --git a/etc/afpd/afp_options.c b/etc/afpd/afp_options.c index aa728512..ebc9a653 100644 --- a/etc/afpd/afp_options.c +++ b/etc/afpd/afp_options.c @@ -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; } diff --git a/etc/afpd/globals.h b/etc/afpd/globals.h index e096044a..40af2fe1 100644 --- a/etc/afpd/globals.h +++ b/etc/afpd/globals.h @@ -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; diff --git a/etc/afpd/status.c b/etc/afpd/status.c index ee9bd1fd..bcdca483 100644 --- a/etc/afpd/status.c +++ b/etc/afpd/status.c @@ -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); diff --git a/etc/afpd/status.h b/etc/afpd/status.h index c4a696bd..3a29a174 100644 --- a/etc/afpd/status.h +++ b/etc/afpd/status.h @@ -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);