- char *c, *opt;
-
- /* handle server */
- if (*buf != '-' && (c = getoption(buf, NULL)) && (opt = strdup(c)))
- options->server = opt;
-
- /* parse toggles */
- if (strstr(buf, " -nodebug"))
- options->flags &= ~OPTION_DEBUG;
-
- if (strstr(buf, " -nouservolfirst"))
- options->flags &= ~OPTION_USERVOLFIRST;
- if (strstr(buf, " -uservolfirst"))
- options->flags |= OPTION_USERVOLFIRST;
- if (strstr(buf, " -nouservol"))
- options->flags |= OPTION_NOUSERVOL;
- if (strstr(buf, " -uservol"))
- options->flags &= ~OPTION_NOUSERVOL;
- if (strstr(buf, " -proxy"))
- options->flags |= OPTION_PROXY;
- if (strstr(buf, " -noicon"))
- options->flags &= ~OPTION_CUSTOMICON;
- if (strstr(buf, " -icon"))
- options->flags |= OPTION_CUSTOMICON;
-
- /* passwd bits */
- if (strstr(buf, " -nosavepassword"))
- options->passwdbits |= PASSWD_NOSAVE;
- if (strstr(buf, " -savepassword"))
- options->passwdbits &= ~PASSWD_NOSAVE;
- if (strstr(buf, " -nosetpassword"))
- options->passwdbits &= ~PASSWD_SET;
- if (strstr(buf, " -setpassword"))
- options->passwdbits |= PASSWD_SET;
-
- /* transports */
- if (strstr(buf, " -transall"))
- options->transports = AFPTRANS_ALL;
- if (strstr(buf, " -notransall"))
- options->transports = AFPTRANS_NONE;
- if (strstr(buf, " -tcp"))
- options->transports |= AFPTRANS_TCP;
- if (strstr(buf, " -notcp"))
- options->transports &= ~AFPTRANS_TCP;
- if (strstr(buf, " -ddp"))
- options->transports |= AFPTRANS_DDP;
- if (strstr(buf, " -noddp"))
- options->transports &= ~AFPTRANS_DDP;
-
- /* figure out options w/ values. currently, this will ignore the setting
- * if memory is lacking. */
- if ((c = getoption(buf, "-defaultvol")) && (opt = strdup(c)))
- options->defaultvol = opt;
- if ((c = getoption(buf, "-systemvol")) && (opt = strdup(c)))
- options->systemvol = opt;
- if ((c = getoption(buf, "-loginmesg")) && (opt = strdup(c)))
- options->loginmesg = opt;
- if ((c = getoption(buf, "-guestname")) && (opt = strdup(c)))
- options->guest = opt;
- if ((c = getoption(buf, "-passwdfile")) && (opt = strdup(c)))
- options->passwdfile = opt;
- if ((c = getoption(buf, "-passwdminlen")))
- options->passwdminlen = MIN(1, atoi(c));
- if ((c = getoption(buf, "-loginmaxfail")))
- options->loginmaxfail = atoi(c);
- if ((c = getoption(buf, "-tickleval")))
- options->tickleval = atoi(c);
-
- if ((c = getoption(buf, "-server_quantum")))
- options->server_quantum = strtoul(c, NULL, 0);
+ char *c, *opt;
+
+ /* handle server */
+ if (*buf != '-' && (c = getoption(buf, NULL)) && (opt = strdup(c)))
+ options->server = opt;
+
+ /* parse toggles */
+ if (strstr(buf, " -nodebug"))
+ options->flags &= ~OPTION_DEBUG;
+#ifdef USE_SRVLOC
+ if (strstr(buf, " -slp"))
+ options->flags &= ~OPTION_NOSLP;
+#endif
+
+ if (strstr(buf, " -nouservolfirst"))
+ options->flags &= ~OPTION_USERVOLFIRST;
+ if (strstr(buf, " -uservolfirst"))
+ options->flags |= OPTION_USERVOLFIRST;
+ if (strstr(buf, " -nouservol"))
+ options->flags |= OPTION_NOUSERVOL;
+ if (strstr(buf, " -uservol"))
+ options->flags &= ~OPTION_NOUSERVOL;
+ if (strstr(buf, " -proxy"))
+ options->flags |= OPTION_PROXY;
+ if (strstr(buf, " -noicon"))
+ 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"))
+ options->passwdbits |= PASSWD_NOSAVE;
+ if (strstr(buf, " -savepassword"))
+ options->passwdbits &= ~PASSWD_NOSAVE;
+ if (strstr(buf, " -nosetpassword"))
+ options->passwdbits &= ~PASSWD_SET;
+ if (strstr(buf, " -setpassword"))
+ options->passwdbits |= PASSWD_SET;
+
+ /* transports */
+ if (strstr(buf, " -transall"))
+ options->transports = AFPTRANS_ALL;
+ if (strstr(buf, " -notransall"))
+ options->transports = AFPTRANS_NONE;
+ if (strstr(buf, " -tcp"))
+ options->transports |= AFPTRANS_TCP;
+ if (strstr(buf, " -notcp"))
+ options->transports &= ~AFPTRANS_TCP;
+ if (strstr(buf, " -ddp"))
+ options->transports |= AFPTRANS_DDP;
+ if (strstr(buf, " -noddp"))
+ options->transports &= ~AFPTRANS_DDP;
+ if (strstr(buf, "-client_polling"))
+ options->server_notif = 0;
+
+ /* figure out options w/ values. currently, this will ignore the setting
+ * if memory is lacking. */
+
+ if ((c = getoption(buf, "-hostname"))) {
+ int len = strlen (c);
+ if (len <= MAXHOSTNAMELEN) {
+ memcpy(options->hostname, c, len);
+ options->hostname[len] = 0;
+ }
+ else
+ LOG(log_info, logtype_afpd, "WARNING: hostname %s is too long (%d)",c,len);
+ }
+
+ if ((c = getoption(buf, "-defaultvol")) && (opt = strdup(c)))
+ options->defaultvol.name = opt;
+ if ((c = getoption(buf, "-systemvol")) && (opt = strdup(c)))
+ options->systemvol.name = opt;
+ if ((c = getoption(buf, "-loginmesg")) && (opt = strdup(c)))
+ options->loginmesg = opt;
+ if ((c = getoption(buf, "-guestname")) && (opt = strdup(c)))
+ options->guest = opt;
+ if ((c = getoption(buf, "-passwdfile")) && (opt = strdup(c)))
+ options->passwdfile = opt;
+ if ((c = getoption(buf, "-passwdminlen")))
+ options->passwdminlen = MIN(1, atoi(c));
+ if ((c = getoption(buf, "-loginmaxfail")))
+ options->loginmaxfail = atoi(c);
+ if ((c = getoption(buf, "-tickleval"))) {
+ options->tickleval = atoi(c);
+ if (options->tickleval <= 0) {
+ options->tickleval = 30;
+ }
+ }
+ if ((c = getoption(buf, "-timeout"))) {
+ options->timeout = atoi(c);
+ if (options->timeout <= 0) {
+ options->timeout = 4;
+ }
+ }
+
+ if ((c = getoption(buf, "-sleep"))) {
+ options->sleep = atoi(c) *120;
+ if (options->sleep <= 4) {
+ options->sleep = 4;
+ }
+ }
+
+ if ((c = getoption(buf, "-server_quantum")))
+ options->server_quantum = strtoul(c, NULL, 0);
+
+ if ((c = getoption(buf, "-volnamelen"))) {
+ options->volnamelen = atoi(c);
+ if (options->volnamelen < 8) {
+ options->volnamelen = 8; /* max mangled volname "???#FFFF" */
+ }
+ if (options->volnamelen > 255) {
+ options->volnamelen = 255; /* AFP3 spec */
+ }
+ }