*/
#include "includes.h"
-RCSID("$OpenBSD: servconf.c,v 1.64 2001/02/03 10:08:37 markus Exp $");
+RCSID("$OpenBSD: servconf.c,v 1.71 2001/03/05 15:44:51 stevesk Exp $");
#ifdef KRB4
#include <krb.h>
#include "tildexpand.h"
#include "misc.h"
#include "cipher.h"
+#include "kex.h"
+#include "mac.h"
/* add listen address */
void add_listen_addr(ServerOptions *options, char *addr);
options->server_key_bits = -1;
options->login_grace_time = -1;
options->key_regeneration_time = -1;
- options->permit_root_login = -1;
+ options->permit_root_login = PERMIT_NOT_SET;
options->ignore_rhosts = -1;
options->ignore_user_known_hosts = -1;
options->print_motd = -1;
options->num_allow_groups = 0;
options->num_deny_groups = 0;
options->ciphers = NULL;
+ options->macs = NULL;
options->protocol = SSH_PROTO_UNKNOWN;
options->gateway_ports = -1;
options->num_subsystems = 0;
options->login_grace_time = 600;
if (options->key_regeneration_time == -1)
options->key_regeneration_time = 3600;
- if (options->permit_root_login == -1)
- options->permit_root_login = 1; /* yes */
+ if (options->permit_root_login == PERMIT_NOT_SET)
+ options->permit_root_login = PERMIT_YES;
if (options->ignore_rhosts == -1)
options->ignore_rhosts = 1;
if (options->ignore_user_known_hosts == -1)
sChallengeResponseAuthentication,
sPasswordAuthentication, sKbdInteractiveAuthentication, sListenAddress,
sPrintMotd, sIgnoreRhosts, sX11Forwarding, sX11DisplayOffset,
- sStrictModes, sEmptyPasswd, sRandomSeedFile, sKeepAlives, sCheckMail,
+ sStrictModes, sEmptyPasswd, sKeepAlives, sCheckMail,
sUseLogin, sAllowTcpForwarding,
sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
- sIgnoreUserKnownHosts, sCiphers, sProtocol, sPidFile,
+ sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile,
sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, sMaxStartups,
sBanner, sReverseMappingCheck
} ServerOpCodes;
{ "port", sPort },
{ "hostkey", sHostKeyFile },
{ "hostdsakey", sHostKeyFile }, /* alias */
- { "pidfile", sPidFile },
+ { "pidfile", sPidFile },
{ "serverkeybits", sServerKeyBits },
{ "logingracetime", sLoginGraceTime },
{ "keyregenerationinterval", sKeyRegenerationTime },
{ "strictmodes", sStrictModes },
{ "permitemptypasswords", sEmptyPasswd },
{ "uselogin", sUseLogin },
- { "randomseed", sRandomSeedFile },
{ "keepalive", sKeepAlives },
{ "allowtcpforwarding", sAllowTcpForwarding },
{ "allowusers", sAllowUsers },
{ "allowgroups", sAllowGroups },
{ "denygroups", sDenyGroups },
{ "ciphers", sCiphers },
+ { "macs", sMacs },
{ "protocol", sProtocol },
{ "gatewayports", sGatewayPorts },
{ "subsystem", sSubsystem },
hints.ai_flags = (addr == NULL) ? AI_PASSIVE : 0;
snprintf(strport, sizeof strport, "%d", options->ports[i]);
if ((gaierr = getaddrinfo(addr, strport, &hints, &aitop)) != 0)
- fatal("bad addr or host: %s (%s)\n",
+ fatal("bad addr or host: %s (%s)",
addr ? addr : "<NULL>",
gai_strerror(gaierr));
for (ai = aitop; ai->ai_next; ai = ai->ai_next)
fatal("%s line %d: ports must be specified before "
"ListenAdress.\n", filename, linenum);
if (options->num_ports >= MAX_PORTS)
- fatal("%s line %d: too many ports.\n",
+ fatal("%s line %d: too many ports.",
filename, linenum);
arg = strdelim(&cp);
if (!arg || *arg == '\0')
- fatal("%s line %d: missing port number.\n",
+ fatal("%s line %d: missing port number.",
filename, linenum);
options->ports[options->num_ports++] = atoi(arg);
break;
case sListenAddress:
arg = strdelim(&cp);
if (!arg || *arg == '\0')
- fatal("%s line %d: missing inet addr.\n",
+ fatal("%s line %d: missing inet addr.",
filename, linenum);
add_listen_addr(options, arg);
break;
case sHostKeyFile:
intptr = &options->num_host_key_files;
if (*intptr >= MAX_HOSTKEYS) {
- fprintf(stderr, "%s line %d: to many host keys specified (max %d).\n",
+ fprintf(stderr,
+ "%s line %d: too many host keys specified (max %d).\n",
filename, linenum, MAX_HOSTKEYS);
exit(1);
}
charptr = &options->pid_file;
goto parse_filename;
- case sRandomSeedFile:
- fprintf(stderr, "%s line %d: \"randomseed\" option is obsolete.\n",
- filename, linenum);
- arg = strdelim(&cp);
- break;
-
case sPermitRootLogin:
intptr = &options->permit_root_login;
arg = strdelim(&cp);
if (!arg || *arg == '\0') {
- fprintf(stderr, "%s line %d: missing yes/without-password/no argument.\n",
- filename, linenum);
+ fprintf(stderr, "%s line %d: missing yes/"
+ "without-password/forced-commands-only/no "
+ "argument.\n", filename, linenum);
exit(1);
}
if (strcmp(arg, "without-password") == 0)
- value = 2;
+ value = PERMIT_NO_PASSWD;
+ else if (strcmp(arg, "forced-commands-only") == 0)
+ value = PERMIT_FORCED_ONLY;
else if (strcmp(arg, "yes") == 0)
- value = 1;
+ value = PERMIT_YES;
else if (strcmp(arg, "no") == 0)
- value = 0;
+ value = PERMIT_NO;
else {
- fprintf(stderr, "%s line %d: Bad yes/without-password/no argument: %s\n",
- filename, linenum, arg);
+ fprintf(stderr, "%s line %d: Bad yes/"
+ "without-password/forced-commands-only/no "
+ "argument: %s\n", filename, linenum, arg);
exit(1);
}
if (*intptr == -1)
case sXAuthLocation:
charptr = &options->xauth_location;
goto parse_filename;
-
+
case sStrictModes:
intptr = &options->strict_modes;
goto parse_flag;
arg = strdelim(&cp);
value = log_facility_number(arg);
if (value == (SyslogFacility) - 1)
- fatal("%.200s line %d: unsupported log facility '%s'\n",
+ fatal("%.200s line %d: unsupported log facility '%s'",
filename, linenum, arg ? arg : "<NONE>");
if (*intptr == -1)
*intptr = (SyslogFacility) value;
arg = strdelim(&cp);
value = log_level_number(arg);
if (value == (LogLevel) - 1)
- fatal("%.200s line %d: unsupported log level '%s'\n",
+ fatal("%.200s line %d: unsupported log level '%s'",
filename, linenum, arg ? arg : "<NONE>");
if (*intptr == -1)
*intptr = (LogLevel) value;
case sAllowUsers:
while ((arg = strdelim(&cp)) && *arg != '\0') {
if (options->num_allow_users >= MAX_ALLOW_USERS)
- fatal("%s line %d: too many allow users.\n",
+ fatal("%s line %d: too many allow users.",
filename, linenum);
options->allow_users[options->num_allow_users++] = xstrdup(arg);
}
case sDenyUsers:
while ((arg = strdelim(&cp)) && *arg != '\0') {
if (options->num_deny_users >= MAX_DENY_USERS)
- fatal( "%s line %d: too many deny users.\n",
+ fatal( "%s line %d: too many deny users.",
filename, linenum);
options->deny_users[options->num_deny_users++] = xstrdup(arg);
}
case sAllowGroups:
while ((arg = strdelim(&cp)) && *arg != '\0') {
if (options->num_allow_groups >= MAX_ALLOW_GROUPS)
- fatal("%s line %d: too many allow groups.\n",
+ fatal("%s line %d: too many allow groups.",
filename, linenum);
options->allow_groups[options->num_allow_groups++] = xstrdup(arg);
}
case sDenyGroups:
while ((arg = strdelim(&cp)) && *arg != '\0') {
if (options->num_deny_groups >= MAX_DENY_GROUPS)
- fatal("%s line %d: too many deny groups.\n",
+ fatal("%s line %d: too many deny groups.",
filename, linenum);
options->deny_groups[options->num_deny_groups++] = xstrdup(arg);
}
options->ciphers = xstrdup(arg);
break;
+ case sMacs:
+ arg = strdelim(&cp);
+ if (!arg || *arg == '\0')
+ fatal("%s line %d: Missing argument.", filename, linenum);
+ if (!mac_valid(arg))
+ fatal("%s line %d: Bad SSH2 mac spec '%s'.",
+ filename, linenum, arg ? arg : "<NONE>");
+ if (options->macs == NULL)
+ options->macs = xstrdup(arg);
+ break;
+
case sProtocol:
intptr = &options->protocol;
arg = strdelim(&cp);
case sBanner:
charptr = &options->banner;
goto parse_filename;
-
+
default:
fprintf(stderr, "%s line %d: Missing handler for opcode %s (%d)\n",
filename, linenum, arg, opcode);
exit(1);
}
if ((arg = strdelim(&cp)) != NULL && *arg != '\0') {
- fprintf(stderr,
+ fprintf(stderr,
"%s line %d: garbage at end of line; \"%.200s\".\n",
filename, linenum, arg);
exit(1);