+ if ((c = getoption(buf, "-unsetuplog")))
+ unsetuplog(c);
+
+#ifdef ADMIN_GRP
+ if ((c = getoption(buf, "-admingroup"))) {
+ struct group *gr = getgrnam(c);
+ if (gr != NULL) {
+ options->admingid = gr->gr_gid;
+ }
+ }
+#endif /* ADMIN_GRP */
+
+ if ((c = getoption(buf, "-k5service")) && (opt = strdup(c)))
+ options->k5service = opt;
+ if ((c = getoption(buf, "-k5realm")) && (opt = strdup(c)))
+ options->k5realm = opt;
+ if ((c = getoption(buf, "-k5keytab"))) {
+ if ( NULL == (options->k5keytab = (char *) malloc(sizeof(char)*(strlen(c)+14)) )) {
+ LOG(log_error, logtype_afpd, "malloc failed");
+ exit(-1);
+ }
+ snprintf(options->k5keytab, strlen(c)+14, "KRB5_KTNAME=%s", c);
+ putenv(options->k5keytab);
+ /* setenv( "KRB5_KTNAME", c, 1 ); */
+ }
+ if ((c = getoption(buf, "-authprintdir")) && (opt = strdup(c)))
+ options->authprintdir = opt;
+ if ((c = getoption(buf, "-uampath")) && (opt = strdup(c)))
+ options->uampath = opt;
+ if ((c = getoption(buf, "-uamlist")) && (opt = strdup(c)))
+ options->uamlist = opt;
+
+ if ((c = getoption(buf, "-ipaddr"))) {
+ struct in_addr inaddr;
+ if (inet_aton(c, &inaddr) && (opt = strdup(c))) {
+ if (!gethostbyaddr((const char *) &inaddr, sizeof(inaddr), AF_INET))
+ LOG(log_info, logtype_afpd, "WARNING: can't find %s", opt);
+ options->ipaddr = opt;
+ }
+ else {
+ LOG(log_error, logtype_afpd, "Error parsing -ipaddr, is %s in numbers-and-dots notation?", c);
+ }
+ }
+
+ /* FIXME CNID Cnid_srv is a server attribute */
+ if ((c = getoption(buf, "-cnidserver"))) {
+ 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 = strdup(c);
+ if ((c = getoption(buf, "-ddpaddr")))
+ atalk_aton(c, &options->ddpaddr);
+ if ((c = getoption(buf, "-signature")) && (opt = strdup(c)))
+ options->signature = opt;
+
+ /* do a little checking for the domain name. */
+ if ((c = getoption(buf, "-fqdn"))) {
+ char *p = strchr(c, ':');
+ if (p)
+ *p = '\0';
+ if (gethostbyname(c)) {
+ if (p)
+ *p = ':';
+ if ((opt = strdup(c)))
+ options->fqdn = opt;
+ }
+ else {
+ LOG(log_error, logtype_afpd, "error parsing -fqdn, gethostbyname failed for: %s", c);
+ }
+ }
+
+ if ((c = getoption(buf, "-unixcodepage"))) {
+ if ((charset_t)-1 == ( options->unixcharset = add_charset(c)) ) {
+ options->unixcharset = CH_UNIX;
+ LOG(log_warning, logtype_afpd, "setting Unix codepage to '%s' failed", c);
+ }
+ else {
+ if ((opt = strdup(c)))
+ options->unixcodepage = opt;
+ }
+ }
+
+ if ((c = getoption(buf, "-maccodepage"))) {
+ if ((charset_t)-1 == ( options->maccharset = add_charset(c)) ) {
+ options->maccharset = CH_MAC;
+ LOG(log_warning, logtype_afpd, "setting Mac codepage to '%s' failed", c);
+ }
+ else {
+ if ((opt = strdup(c)))
+ options->maccodepage = opt;
+ }
+ }
+
+ if ((c = strstr(buf, "-closevol"))) {
+ options->closevol= 1;
+ }
+
+ if ((c = getoption(buf, "-ntdomain")) && (opt = strdup(c)))
+ options->ntdomain = opt;
+
+ if ((c = getoption(buf, "-ntseparator")) && (opt = strdup(c)))
+ options->ntseparator = opt;
+
+ return 1;
+}
+
+/*
+ * Show version information about afpd.
+ * Used by "afp -v".
+ */
+static void show_version( void )
+{
+ printf( "afpd %s - Apple Filing Protocol (AFP) daemon of Netatalk\n\n", VERSION );
+
+ puts( "This program is free software; you can redistribute it and/or modify it under" );
+ puts( "the terms of the GNU General Public License as published by the Free Software" );
+ puts( "Foundation; either version 2 of the License, or (at your option) any later" );
+ puts( "version. Please see the file COPYING for further information and details.\n" );
+
+ puts( "afpd has been compiled with support for these features:\n" );
+
+ printf( " AFP3.1 support:\t" );
+#ifdef AFP3x
+ puts( "Yes" );
+#else
+ puts( "No" );
+#endif
+
+ printf( " Transport layers:\t" );
+#ifdef NO_DDP
+ puts( "TCP/IP" );
+#else
+ puts( "TCP/IP DDP" );
+#endif
+
+ printf( " CNID backends:\t" );
+#ifdef CNID_BACKEND_CDB
+ printf( "cdb ");
+#endif
+#ifdef CNID_BACKEND_DB3
+ printf( "db3 " );
+#endif
+#ifdef CNID_BACKEND_DBD
+#ifdef CNID_BACKEND_DBD_TXN
+ printf( "dbd-txn " );
+#else
+ printf( "dbd " );
+#endif
+#endif
+#ifdef CNID_BACKEND_HASH
+ printf( "hash " );
+#endif
+#ifdef CNID_BACKEND_LAST
+ printf( "last " );
+#endif
+#ifdef CNID_BACKEND_MTAB
+ printf( "mtab " );
+#endif
+#ifdef CNID_BACKEND_TDB
+ printf( "tdb " );
+#endif
+ puts( "" );
+}
+
+/*
+ * Show extended version information about afpd and Netatalk.
+ * Used by "afp -V".
+ */
+static void show_version_extended(void )
+{
+ show_version( );
+
+ printf( " SLP support:\t" );
+#ifdef USE_SRVLOC
+ puts( "Yes" );
+#else
+ puts( "No" );
+#endif
+
+ printf( " TCP wrappers support:\t" );
+#ifdef TCPWRAP
+ puts( "Yes" );
+#else
+ puts( "No" );
+#endif
+
+ printf( " Quota support:\t" );
+#ifndef NO_QUOTA_SUPPORT
+ puts( "Yes" );
+#else
+ puts( "No" );
+#endif
+
+ printf( " Admin group support:\t" );
+#ifdef ADMIN_GRP
+ puts( "Yes" );
+#else
+ puts( "No" );
+#endif
+
+ printf( " Valid shell checks:\t" );
+#ifndef DISABLE_SHELLCHECK
+ puts( "Yes" );
+#else
+ puts( "No" );
+#endif
+
+ printf( " cracklib support:\t" );
+#ifdef USE_CRACKLIB
+ puts( "Yes" );
+#else
+ puts( "No" );
+#endif
+
+ printf( " Dropbox kludge:\t" );
+#ifdef DROPKLUDGE
+ puts( "Yes" );
+#else
+ puts( "No" );
+#endif
+
+ printf( " Force volume uid/gid:\t" );
+#ifdef FORCE_UIDGID
+ puts( "Yes" );
+#else
+ puts( "No" );
+#endif
+}
+
+/*
+ * Display compiled-in default paths
+ */
+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 );
+}
+
+/*
+ * Display usage information about adpd.
+ */
+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" );
+ fprintf( stderr, "\t [-s systemvolumes] [-S port] [-U uams]\n" );
+ fprintf( stderr, "\t%s -h|-v|-V\n", name );