*/
#include "includes.h"
-RCSID("$OpenBSD: servconf.c,v 1.47 2000/07/10 16:30:25 ho Exp $");
+RCSID("$OpenBSD: servconf.c,v 1.49 2000/07/14 22:59:46 markus Exp $");
#include "ssh.h"
#include "servconf.h"
options->max_startups = 10;
}
-#define WHITESPACE " \t\r\n="
-
/* Keyword tokens. */
typedef enum {
sBadOption, /* == unknown option */
linenum = 0;
while (fgets(line, sizeof(line), f)) {
linenum++;
- cp = line + strspn(line, WHITESPACE);
- if (!*cp || *cp == '#')
+ cp = line;
+ arg = strdelim(&cp);
+ /* Ignore leading whitespace */
+ if (*arg == '\0')
+ arg = strdelim(&cp);
+ if (!*arg || *arg == '#')
continue;
- arg = strsep(&cp, WHITESPACE);
opcode = parse_token(arg, filename, linenum);
switch (opcode) {
case sBadOption:
if (options->num_ports >= MAX_PORTS)
fatal("%s line %d: too many ports.\n",
filename, linenum);
- arg = strsep(&cp, WHITESPACE);
+ arg = strdelim(&cp);
if (!arg || *arg == '\0')
fatal("%s line %d: missing port number.\n",
filename, linenum);
case sServerKeyBits:
intptr = &options->server_key_bits;
parse_int:
- arg = strsep(&cp, WHITESPACE);
+ arg = strdelim(&cp);
if (!arg || *arg == '\0') {
fprintf(stderr, "%s line %d: missing integer value.\n",
filename, linenum);
goto parse_int;
case sListenAddress:
- arg = strsep(&cp, WHITESPACE);
+ arg = strdelim(&cp);
if (!arg || *arg == '\0')
fatal("%s line %d: missing inet addr.\n",
filename, linenum);
charptr = (opcode == sHostKeyFile ) ?
&options->host_key_file : &options->host_dsa_key_file;
parse_filename:
- arg = strsep(&cp, WHITESPACE);
+ arg = strdelim(&cp);
if (!arg || *arg == '\0') {
fprintf(stderr, "%s line %d: missing file name.\n",
filename, linenum);
case sRandomSeedFile:
fprintf(stderr, "%s line %d: \"randomseed\" option is obsolete.\n",
filename, linenum);
- arg = strsep(&cp, WHITESPACE);
+ arg = strdelim(&cp);
break;
case sPermitRootLogin:
intptr = &options->permit_root_login;
- arg = strsep(&cp, WHITESPACE);
+ arg = strdelim(&cp);
if (!arg || *arg == '\0') {
fprintf(stderr, "%s line %d: missing yes/without-password/no argument.\n",
filename, linenum);
case sIgnoreRhosts:
intptr = &options->ignore_rhosts;
parse_flag:
- arg = strsep(&cp, WHITESPACE);
+ arg = strdelim(&cp);
if (!arg || *arg == '\0') {
fprintf(stderr, "%s line %d: missing yes/no argument.\n",
filename, linenum);
case sLogFacility:
intptr = (int *) &options->log_facility;
- arg = strsep(&cp, WHITESPACE);
+ arg = strdelim(&cp);
value = log_facility_number(arg);
if (value == (SyslogFacility) - 1)
fatal("%.200s line %d: unsupported log facility '%s'\n",
case sLogLevel:
intptr = (int *) &options->log_level;
- arg = strsep(&cp, WHITESPACE);
+ arg = strdelim(&cp);
value = log_level_number(arg);
if (value == (LogLevel) - 1)
fatal("%.200s line %d: unsupported log level '%s'\n",
break;
case sAllowUsers:
- while ((arg = strsep(&cp, WHITESPACE)) && *arg != '\0') {
+ while ((arg = strdelim(&cp)) && *arg != '\0') {
if (options->num_allow_users >= MAX_ALLOW_USERS)
fatal("%s line %d: too many allow users.\n",
filename, linenum);
break;
case sDenyUsers:
- while ((arg = strsep(&cp, WHITESPACE)) && *arg != '\0') {
+ while ((arg = strdelim(&cp)) && *arg != '\0') {
if (options->num_deny_users >= MAX_DENY_USERS)
fatal( "%s line %d: too many deny users.\n",
filename, linenum);
break;
case sAllowGroups:
- while ((arg = strsep(&cp, WHITESPACE)) && *arg != '\0') {
+ while ((arg = strdelim(&cp)) && *arg != '\0') {
if (options->num_allow_groups >= MAX_ALLOW_GROUPS)
fatal("%s line %d: too many allow groups.\n",
filename, linenum);
break;
case sDenyGroups:
- while ((arg = strsep(&cp, WHITESPACE)) && *arg != '\0') {
+ while ((arg = strdelim(&cp)) && *arg != '\0') {
if (options->num_deny_groups >= MAX_DENY_GROUPS)
fatal("%s line %d: too many deny groups.\n",
filename, linenum);
break;
case sCiphers:
- arg = strsep(&cp, WHITESPACE);
+ arg = strdelim(&cp);
if (!arg || *arg == '\0')
fatal("%s line %d: Missing argument.", filename, linenum);
if (!ciphers_valid(arg))
case sProtocol:
intptr = &options->protocol;
- arg = strsep(&cp, WHITESPACE);
+ arg = strdelim(&cp);
if (!arg || *arg == '\0')
fatal("%s line %d: Missing argument.", filename, linenum);
value = proto_spec(arg);
fatal("%s line %d: too many subsystems defined.",
filename, linenum);
}
- arg = strsep(&cp, WHITESPACE);
+ arg = strdelim(&cp);
if (!arg || *arg == '\0')
fatal("%s line %d: Missing subsystem name.",
filename, linenum);
fatal("%s line %d: Subsystem '%s' already defined.",
filename, linenum, arg);
options->subsystem_name[options->num_subsystems] = xstrdup(arg);
- arg = strsep(&cp, WHITESPACE);
+ arg = strdelim(&cp);
if (!arg || *arg == '\0')
fatal("%s line %d: Missing subsystem command.",
filename, linenum);
filename, linenum, arg, opcode);
exit(1);
}
- if ((arg = strsep(&cp, WHITESPACE)) != NULL && *arg != '\0') {
+ if ((arg = strdelim(&cp)) != NULL && *arg != '\0') {
fprintf(stderr,
"%s line %d: garbage at end of line; \"%.200s\".\n",
filename, linenum, arg);