*/
#include "includes.h"
-RCSID("$OpenBSD: servconf.c,v 1.53 2000/10/14 12:12:09 markus Exp $");
+RCSID("$OpenBSD: servconf.c,v 1.57 2001/01/08 22:29:05 markus Exp $");
#include "ssh.h"
#include "servconf.h"
options->num_ports = 0;
options->ports_from_cmdline = 0;
options->listen_addrs = NULL;
- options->host_key_file = NULL;
- options->host_dsa_key_file = NULL;
+ options->num_host_key_files = 0;
options->pid_file = NULL;
options->server_key_bits = -1;
options->login_grace_time = -1;
options->rhosts_authentication = -1;
options->rhosts_rsa_authentication = -1;
options->rsa_authentication = -1;
- options->dsa_authentication = -1;
+ options->pubkey_authentication = -1;
#ifdef KRB4
options->kerberos_authentication = -1;
options->kerberos_or_local_passwd = -1;
options->max_startups_begin = -1;
options->max_startups_rate = -1;
options->max_startups = -1;
+ options->banner = NULL;
}
void
fill_default_server_options(ServerOptions *options)
{
+ if (options->protocol == SSH_PROTO_UNKNOWN)
+ options->protocol = SSH_PROTO_1|SSH_PROTO_2;
+ if (options->num_host_key_files == 0) {
+ /* fill default hostkeys for protocols */
+ if (options->protocol & SSH_PROTO_1)
+ options->host_key_files[options->num_host_key_files++] = HOST_KEY_FILE;
+ if (options->protocol & SSH_PROTO_2)
+ options->host_key_files[options->num_host_key_files++] = HOST_DSA_KEY_FILE;
+ }
if (options->num_ports == 0)
options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
if (options->listen_addrs == NULL)
add_listen_addr(options, NULL);
- if (options->host_key_file == NULL)
- options->host_key_file = HOST_KEY_FILE;
- if (options->host_dsa_key_file == NULL)
- options->host_dsa_key_file = HOST_DSA_KEY_FILE;
if (options->pid_file == NULL)
options->pid_file = SSH_DAEMON_PID_FILE;
if (options->server_key_bits == -1)
if (options->log_facility == (SyslogFacility) (-1))
options->log_facility = SYSLOG_FACILITY_AUTH;
if (options->log_level == (LogLevel) (-1))
- options->log_level = SYSLOG_LEVEL_INFO;
+ options->log_level = SYSLOG_LEVEL_NOTICE;
if (options->rhosts_authentication == -1)
options->rhosts_authentication = 0;
if (options->rhosts_rsa_authentication == -1)
options->rhosts_rsa_authentication = 0;
if (options->rsa_authentication == -1)
options->rsa_authentication = 1;
- if (options->dsa_authentication == -1)
- options->dsa_authentication = 1;
+ if (options->pubkey_authentication == -1)
+ options->pubkey_authentication = 1;
#ifdef KRB4
if (options->kerberos_authentication == -1)
options->kerberos_authentication = (access(KEYFILE, R_OK) == 0);
options->use_login = 0;
if (options->allow_tcp_forwarding == -1)
options->allow_tcp_forwarding = 1;
- if (options->protocol == SSH_PROTO_UNKNOWN)
- options->protocol = SSH_PROTO_1|SSH_PROTO_2;
if (options->gateway_ports == -1)
options->gateway_ports = 0;
if (options->max_startups == -1)
sStrictModes, sEmptyPasswd, sRandomSeedFile, sKeepAlives, sCheckMail,
sUseLogin, sAllowTcpForwarding,
sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
- sIgnoreUserKnownHosts, sHostDSAKeyFile, sCiphers, sProtocol, sPidFile,
- sGatewayPorts, sDSAAuthentication, sXAuthLocation, sSubsystem, sMaxStartups
+ sIgnoreUserKnownHosts, sCiphers, sProtocol, sPidFile,
+ sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, sMaxStartups,
+ sBanner
} ServerOpCodes;
/* Textual representation of the tokens. */
} keywords[] = {
{ "port", sPort },
{ "hostkey", sHostKeyFile },
- { "hostdsakey", sHostDSAKeyFile },
+ { "hostdsakey", sHostKeyFile }, /* alias */
{ "pidfile", sPidFile },
{ "serverkeybits", sServerKeyBits },
{ "logingracetime", sLoginGraceTime },
{ "rhostsauthentication", sRhostsAuthentication },
{ "rhostsrsaauthentication", sRhostsRSAAuthentication },
{ "rsaauthentication", sRSAAuthentication },
- { "dsaauthentication", sDSAAuthentication },
+ { "pubkeyauthentication", sPubkeyAuthentication },
+ { "dsaauthentication", sPubkeyAuthentication }, /* alias */
#ifdef KRB4
{ "kerberosauthentication", sKerberosAuthentication },
{ "kerberosorlocalpasswd", sKerberosOrLocalPasswd },
{ "gatewayports", sGatewayPorts },
{ "subsystem", sSubsystem },
{ "maxstartups", sMaxStartups },
+ { "banner", sBanner },
{ NULL, 0 }
};
parse_token(const char *cp, const char *filename,
int linenum)
{
- unsigned int i;
+ u_int i;
for (i = 0; keywords[i].name; i++)
if (strcasecmp(cp, keywords[i].name) == 0)
arg = strdelim(&cp);
if (!*arg || *arg == '#')
continue;
+ intptr = NULL;
+ charptr = NULL;
opcode = parse_token(arg, filename, linenum);
switch (opcode) {
case sBadOption:
break;
case sHostKeyFile:
- case sHostDSAKeyFile:
- charptr = (opcode == sHostKeyFile ) ?
- &options->host_key_file : &options->host_dsa_key_file;
+ intptr = &options->num_host_key_files;
+ if (*intptr >= MAX_HOSTKEYS) {
+ fprintf(stderr, "%s line %d: to many host keys specified (max %d).\n",
+ filename, linenum, MAX_HOSTKEYS);
+ exit(1);
+ }
+ charptr = &options->host_key_files[*intptr];
parse_filename:
arg = strdelim(&cp);
if (!arg || *arg == '\0') {
filename, linenum);
exit(1);
}
- if (*charptr == NULL)
+ if (*charptr == NULL) {
*charptr = tilde_expand_filename(arg, getuid());
+ /* increase optional counter */
+ if (intptr != NULL)
+ *intptr = *intptr + 1;
+ }
break;
case sPidFile:
intptr = &options->rsa_authentication;
goto parse_flag;
- case sDSAAuthentication:
- intptr = &options->dsa_authentication;
+ case sPubkeyAuthentication:
+ intptr = &options->pubkey_authentication;
goto parse_flag;
#ifdef KRB4
intptr = &options->max_startups;
goto parse_int;
+ 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);