X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fafpd%2Fafp_options.c;h=3c57fd22fbbcc05ea3a7be1016717eaba0f72f73;hb=2bf71d3ccf20c072bc67a9d075b6ac8b0798021e;hp=c275544a816d3bfba0de3591128ba75b4341dbf0;hpb=f46e5ef2816b2b330e9a8808e585f015c87d02b0;p=netatalk.git diff --git a/etc/afpd/afp_options.c b/etc/afpd/afp_options.c index c275544a..3c57fd22 100644 --- a/etc/afpd/afp_options.c +++ b/etc/afpd/afp_options.c @@ -1,5 +1,5 @@ /* - * $Id: afp_options.c,v 1.36 2007-12-03 14:50:38 didg Exp $ + * $Id: afp_options.c,v 1.52 2010-02-03 11:35:58 franklahm Exp $ * * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu) * Copyright (c) 1990,1993 Regents of The University of Michigan. @@ -62,8 +62,8 @@ char *strchr (), *strrchr (); #endif /* MIN */ /* FIXME CNID */ -char Cnid_srv[MAXHOSTNAMELEN + 1] = "localhost"; -int Cnid_port = 4700; +const char *Cnid_srv = "localhost"; +const char *Cnid_port = "4700"; #define OPTIONS "dn:f:s:uc:g:P:ptDS:TL:F:U:hIvVm:" #define LENGTH 512 @@ -127,6 +127,8 @@ void afp_options_free(struct afp_options *opt, free(opt->server); if (opt->ipaddr && (opt->ipaddr != save->ipaddr)) free(opt->ipaddr); + if (opt->port && (opt->port != save->port)) + free(opt->port); if (opt->fqdn && (opt->fqdn != save->fqdn)) free(opt->fqdn); if (opt->uampath && (opt->uampath != save->uampath)) @@ -164,10 +166,10 @@ void afp_options_init(struct afp_options *options) options->systemvol.name = _PATH_AFPDSYSVOL; options->configfile = _PATH_AFPDCONF; options->uampath = _PATH_AFPDUAMPATH; - options->uamlist = "uams_clrtxt.so,uams_dhx.so"; + options->uamlist = "uams_dhx.so,uams_dhx2.so"; options->guest = "nobody"; options->loginmesg = ""; - options->transports = AFPTRANS_ALL; + options->transports = AFPTRANS_TCP; /* TCP only */ options->passwdfile = _PATH_AFPDPWFILE; options->tickleval = 30; options->timeout = 4; @@ -186,9 +188,13 @@ void afp_options_init(struct afp_options *options) options->unixcodepage = "LOCALE"; options->maccharset = CH_MAC; options->maccodepage = "MAC_ROMAN"; - + options->volnamelen = 80; /* spec: 255, 10.1: 73, 10.4/10.5: 80 */ options->ntdomain = NULL; options->ntseparator = NULL; +#ifdef USE_SRVLOC + /* don't advertize slp by default */ + options->flags |= OPTION_NOSLP; +#endif } /* parse an afpd.conf line. i'm doing it this way because it's @@ -211,9 +217,9 @@ int afp_options_parseline(char *buf, struct afp_options *options) if (strstr(buf, " -nodebug")) options->flags &= ~OPTION_DEBUG; #ifdef USE_SRVLOC - if (strstr(buf, " -noslp")) - options->flags |= OPTION_NOSLP; -#endif /* USE_SRVLOC */ + if (strstr(buf, " -slp")) + options->flags &= ~OPTION_NOSLP; +#endif if (strstr(buf, " -nouservolfirst")) options->flags &= ~OPTION_USERVOLFIRST; @@ -308,121 +314,31 @@ int afp_options_parseline(char *buf, struct afp_options *options) if ((c = getoption(buf, "-server_quantum"))) options->server_quantum = strtoul(c, NULL, 0); -#ifndef DISABLE_LOGGER - /* -setuplogtype */ - /* -[no]setuplog []*/ - if ((c = getoption(buf, "-setuplog"))) - { - char *ptr, *logsource, *logtype, *loglevel, *filename; - - LOG(log_debug6, logtype_afpd, "setting up logtype, c is %s", c); - ptr = c; - - /* - logsource = ptr = c; - if (ptr) - { - ptr = strpbrk(ptr, " \t"); - if (ptr) - { - *ptr++ = 0; - while (*ptr && isspace(*ptr)) - ptr++; + if ((c = getoption(buf, "-volnamelen"))) { + options->volnamelen = atoi(c); + if (options->volnamelen < 8) { + options->volnamelen = 8; /* max mangled volname "???#FFFF" */ } - } - */ - - logtype = ptr; - if (ptr) - { - ptr = strpbrk(ptr, " \t"); - if (ptr) - { - *ptr++ = 0; - while (*ptr && isspace(*ptr)) - ptr++; + if (options->volnamelen > 255) { + options->volnamelen = 255; /* AFP3 spec */ } - } - - loglevel = ptr; - if (ptr) - { - ptr = strpbrk(ptr, " \t"); - if (ptr) - { - *ptr++ = 0; - while (*ptr && isspace(*ptr)) - ptr++; - } - } - - filename = ptr; - if (ptr) - { - ptr = strpbrk(ptr, " \t"); - if (ptr) - { - *ptr++ = 0; - while (*ptr && isspace(*ptr)) - ptr++; - } - } - - LOG(log_debug7, logtype_afpd, "calling setuplog %s %s %s", - logtype, loglevel, filename); + } - setuplog(logtype, loglevel, filename); + /* -[no]setuplog []*/ + c = buf; + /* Now THIS is hokey! Multiple occurrences are not supported by our current code, */ + /* so I have to loop myself. */ + while (NULL != (c = strstr(c, "-setuplog"))) { + char *optstr; + if ((optstr = getoption(c, "-setuplog"))) { + setuplog(optstr); + c += sizeof("-setuplog"); + } } if ((c = getoption(buf, "-unsetuplog"))) - { - char *ptr, *logtype, *loglevel, *filename; - - LOG(log_debug6, logtype_afpd, "unsetting up logtype, c is %s", c); - - ptr = c; - logtype = ptr; - if (ptr) - { - ptr = strpbrk(ptr, " \t"); - if (ptr) - { - *ptr++ = 0; - while (*ptr && isspace(*ptr)) - ptr++; - } - } - - loglevel = ptr; - if (ptr) - { - ptr = strpbrk(ptr, " \t"); - if (ptr) - { - *ptr++ = 0; - while (*ptr && isspace(*ptr)) - ptr++; - } - } - - filename = ptr; - if (ptr) - { - ptr = strpbrk(ptr, " \t"); - if (ptr) - { - *ptr++ = 0; - while (*ptr && isspace(*ptr)) - ptr++; - } - } - - LOG(log_debug7, logtype_afpd, "calling setuplog %s %s %s", - logtype, NULL, filename); + unsetuplog(c); - setuplog(logtype, NULL, filename); - } -#endif /* DISABLE_LOGGER */ #ifdef ADMIN_GRP if ((c = getoption(buf, "-admingroup"))) { struct group *gr = getgrnam(c); @@ -453,6 +369,7 @@ int afp_options_parseline(char *buf, struct afp_options *options) options->uamlist = opt; if ((c = getoption(buf, "-ipaddr"))) { +#if 0 struct in_addr inaddr; if (inet_aton(c, &inaddr) && (opt = strdup(c))) { if (!gethostbyaddr((const char *) &inaddr, sizeof(inaddr), AF_INET)) @@ -462,22 +379,23 @@ int afp_options_parseline(char *buf, struct afp_options *options) else { LOG(log_error, logtype_afpd, "Error parsing -ipaddr, is %s in numbers-and-dots notation?", c); } +#endif + options->ipaddr = strdup(c); } /* FIXME CNID Cnid_srv is a server attribute */ if ((c = getoption(buf, "-cnidserver"))) { - char *p; - int len; - p = strchr(c, ':'); - if (p != NULL && (len = p - c) <= MAXHOSTNAMELEN) { - memcpy(Cnid_srv, c, len); - Cnid_srv[len] = 0; - Cnid_port = atoi(p +1); - } + char *p = strrchr(c, ':'); + if (p) + *p = 0; + Cnid_srv = strdup(c); + if (p) + Cnid_port = strdup(p + 1); + LOG(log_debug, logtype_afpd, "CNID Server: %s:%s", Cnid_srv, Cnid_port); } if ((c = getoption(buf, "-port"))) - options->port = atoi(c); + options->port = strdup(c); if ((c = getoption(buf, "-ddpaddr"))) atalk_aton(c, &options->ddpaddr); if ((c = getoption(buf, "-signature")) && (opt = strdup(c))) @@ -538,7 +456,7 @@ int afp_options_parseline(char *buf, struct afp_options *options) * Show version information about afpd. * Used by "afp -v". */ -void show_version( ) +static void show_version( void ) { printf( "afpd %s - Apple Filing Protocol (AFP) daemon of Netatalk\n\n", VERSION ); @@ -549,7 +467,7 @@ void show_version( ) puts( "afpd has been compiled with support for these features:\n" ); - printf( " AFP3.1 support:\t" ); + printf( " AFP3.x support:\t" ); #ifdef AFP3x puts( "Yes" ); #else @@ -596,7 +514,7 @@ void show_version( ) * Show extended version information about afpd and Netatalk. * Used by "afp -V". */ -void show_version_extended( ) +static void show_version_extended(void ) { show_version( ); @@ -660,18 +578,19 @@ void show_version_extended( ) /* * Display compiled-in default paths */ -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( " UAM search path:\t%s\n", _PATH_AFPDUAMPATH ); + printf( " Server messages path:\t%s\n", SERVERTEXT); } /* * Display usage information about adpd. */ -void show_usage( char *name ) +static void show_usage( char *name ) { fprintf( stderr, "Usage:\t%s [-dDIptTu] [-c maxconnections] [-f defaultvolumes] [-F config]\n", name ); fprintf( stderr, "\t [-g guest] [-L message] [-m umask][-n nbpname] [-P pidfile]\n" ); @@ -741,7 +660,7 @@ int afp_options_parse(int ac, char **av, struct afp_options *options) options->transports &= ~AFPTRANS_DDP; break; case 'S': - options->port = atoi(optarg); + options->port = optarg; break; case 'T': options->transports &= ~AFPTRANS_TCP; @@ -794,9 +713,8 @@ int afp_options_parse(int ac, char **av, struct afp_options *options) #ifdef ultrix openlog( p, LOG_PID ); /* ultrix only */ -#else /* ultrix */ +#else set_processname(p); - syslog_setup(log_debug, logtype_default, logoption_ndelay|logoption_pid, logfacility_daemon); #endif /* ultrix */ return 1;