]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afp_options.c
Consistently set default UAMs to DHX,DHX2. From HAT.
[netatalk.git] / etc / afpd / afp_options.c
index e95cf9087c373750674150d9268d73a3fcf3ff78..59d0066f879f9335afb25e0328748039e0e4c863 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_options.c,v 1.30.2.2.2.1 2003-09-09 16:42:19 didg Exp $
+ * $Id: afp_options.c,v 1.30.2.2.2.11.2.2 2009-04-30 09:35:06 franklahm Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -62,10 +62,10 @@ char *strchr (), *strrchr ();
 #endif /* MIN */
 
 /* FIXME CNID */
-char             *Cnid_srv;
-int              Cnid_port;
+char             Cnid_srv[MAXHOSTNAMELEN + 1] = "localhost";
+int              Cnid_port = 4700;
 
-#define OPTIONS "dn:f:s:uc:g:P:ptDS:TL:F:U:Ivm:"
+#define OPTIONS "dn:f:s:uc:g:P:ptDS:TL:F:U:hIvVm:"
 #define LENGTH 512
 
 /* return an option. this uses an internal array, so it's necessary
@@ -133,8 +133,6 @@ void afp_options_free(struct afp_options *opt,
         free(opt->uampath);
     if (opt->uamlist && (opt->uamlist != save->uamlist))
         free(opt->uamlist);
-    if (opt->nlspath && (opt->nlspath != save->nlspath))
-        free(opt->nlspath);
     if (opt->passwdfile && (opt->passwdfile != save->passwdfile))
         free(opt->passwdfile);
     if (opt->signature && (opt->signature != save->signature))
@@ -160,9 +158,8 @@ void afp_options_init(struct afp_options *options)
     options->defaultvol.name = _PATH_AFPDDEFVOL;
     options->systemvol.name = _PATH_AFPDSYSVOL;
     options->configfile = _PATH_AFPDCONF;
-    options->nlspath = _PATH_AFPDNLSPATH;
     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;
@@ -224,6 +221,8 @@ int afp_options_parseline(char *buf, struct afp_options *options)
         options->flags &= ~OPTION_CUSTOMICON;
     if (strstr(buf, " -icon"))
         options->flags |= OPTION_CUSTOMICON;
+    if (strstr(buf, " -advertise_ssh"))
+        options->flags |= OPTION_ANNOUNCESSH;
 
     /* passwd bits */
     if (strstr(buf, " -nosavepassword"))
@@ -433,26 +432,29 @@ int afp_options_parseline(char *buf, struct afp_options *options)
         options->uampath = opt;
     if ((c = getoption(buf, "-uamlist")) && (opt = strdup(c)))
         options->uamlist = opt;
-    if ((c = getoption(buf, "-nlspath")) && (opt = strdup(c)))
-        options->nlspath = 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\n", opt);
+                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 */
+    /* FIXME CNID Cnid_srv is a server attribute */
     if ((c = getoption(buf, "-cnidserver"))) {
         char *p;
-        
-        Cnid_srv = strdup(c);
-        p = strchr(Cnid_srv, ':');
-        *p = 0;
-        Cnid_port = atoi(p +1);
+       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);
+       }
     }
 
     if ((c = getoption(buf, "-port")))
@@ -473,28 +475,181 @@ int afp_options_parseline(char *buf, struct afp_options *options)
             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"))) {
-       options->unixcodepage = c;
-       if ( 0 == ( options->unixcharset = add_charset(options->unixcodepage)) ) {
-               options->unixcodepage= "LOCALE";
-               options->unixcharset = CH_UNIX;
+       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"))) {
-       options->maccodepage = c;
-       if ( 0 == ( options->maccharset = add_charset(options->maccodepage)) ) {
-               options->maccodepage= "Mac_Roman";
-               options->maccharset = CH_MAC;
+       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);
        }
-       LOG(log_debug, logtype_afpd, "Setting Mac Codepage to '%s'", options->maccodepage);
+       else {
+            if ((opt = strdup(c)))
+                options->maccodepage = opt;
+       }
     }
 
     return 1;
 }
 
+/*
+ * Show version information about afpd.
+ * Used by "afp -v".
+ */
+void show_version( )
+{
+       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".
+ */
+void show_version_extended( )
+{
+       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
+ */
+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.
+ */
+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 );
+}
+
 int afp_options_parse(int ac, char **av, struct afp_options *options)
 {
     extern char *optarg;
@@ -572,8 +727,18 @@ int afp_options_parse(int ac, char **av, struct afp_options *options)
             options->uamlist = optarg;
             break;
         case 'v':      /* version */
-            printf( "afpd (version %s)\n", VERSION );
-            exit ( 1 );
+            show_version( ); puts( "" );
+           show_paths( ); puts( "" );
+            exit( 0 );
+            break;
+        case 'V':      /* extended version */
+            show_version_extended( ); puts( "" );
+           show_paths( ); puts( "" );
+            exit( 0 );
+            break;
+        case 'h':      /* usage */
+            show_usage( p );
+            exit( 0 );
             break;
         case 'I':
             options->flags |= OPTION_CUSTOMICON;
@@ -594,13 +759,8 @@ int afp_options_parse(int ac, char **av, struct afp_options *options)
         }
     }
     if ( err || optind != ac ) {
-        fprintf( stderr,
-                 "Usage:\t%s [ -dpDTIt ] [ -n nbpname ] [ -f defvols ] \
-                 [ -P pidfile ] [ -s sysvols ] \n", p );
-        fprintf( stderr,
-                 "\t[ -u ] [ -c maxconn ] [ -g guest ] \
-                 [ -S port ] [ -L loginmesg ] [ -F configfile ] [ -U uamlist ]\n" );
-        return 0;
+        show_usage( p );
+        exit( 2 );
     }
 
 #ifdef ultrix