summaryrefslogtreecommitdiff
path: root/servconf.c
diff options
context:
space:
mode:
Diffstat (limited to 'servconf.c')
-rw-r--r--servconf.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/servconf.c b/servconf.c
index abc3c72fb..6eb368661 100644
--- a/servconf.c
+++ b/servconf.c
@@ -1,5 +1,5 @@
1 1
2/* $OpenBSD: servconf.c,v 1.256 2014/12/21 22:27:56 djm Exp $ */ 2/* $OpenBSD: servconf.c,v 1.257 2014/12/22 07:55:51 djm Exp $ */
3/* 3/*
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * All rights reserved 5 * All rights reserved
@@ -162,9 +162,18 @@ initialize_server_options(ServerOptions *options)
162 options->fingerprint_hash = -1; 162 options->fingerprint_hash = -1;
163} 163}
164 164
165/* Returns 1 if a string option is unset or set to "none" or 0 otherwise. */
166static int
167option_clear_or_none(const char *o)
168{
169 return o == NULL || strcasecmp(o, "none") == 0;
170}
171
165void 172void
166fill_default_server_options(ServerOptions *options) 173fill_default_server_options(ServerOptions *options)
167{ 174{
175 int i;
176
168 /* Portable-specific options */ 177 /* Portable-specific options */
169 if (options->use_pam == -1) 178 if (options->use_pam == -1)
170 options->use_pam = 0; 179 options->use_pam = 0;
@@ -196,7 +205,7 @@ fill_default_server_options(ServerOptions *options)
196 if (options->listen_addrs == NULL) 205 if (options->listen_addrs == NULL)
197 add_listen_addr(options, NULL, 0); 206 add_listen_addr(options, NULL, 0);
198 if (options->pid_file == NULL) 207 if (options->pid_file == NULL)
199 options->pid_file = _PATH_SSH_DAEMON_PID_FILE; 208 options->pid_file = xstrdup(_PATH_SSH_DAEMON_PID_FILE);
200 if (options->server_key_bits == -1) 209 if (options->server_key_bits == -1)
201 options->server_key_bits = 1024; 210 options->server_key_bits = 1024;
202 if (options->login_grace_time == -1) 211 if (options->login_grace_time == -1)
@@ -220,7 +229,7 @@ fill_default_server_options(ServerOptions *options)
220 if (options->x11_use_localhost == -1) 229 if (options->x11_use_localhost == -1)
221 options->x11_use_localhost = 1; 230 options->x11_use_localhost = 1;
222 if (options->xauth_location == NULL) 231 if (options->xauth_location == NULL)
223 options->xauth_location = _PATH_XAUTH; 232 options->xauth_location = xstrdup(_PATH_XAUTH);
224 if (options->permit_tty == -1) 233 if (options->permit_tty == -1)
225 options->permit_tty = 1; 234 options->permit_tty = 1;
226 if (options->permit_user_rc == -1) 235 if (options->permit_user_rc == -1)
@@ -321,6 +330,24 @@ fill_default_server_options(ServerOptions *options)
321 if (use_privsep == -1) 330 if (use_privsep == -1)
322 use_privsep = PRIVSEP_NOSANDBOX; 331 use_privsep = PRIVSEP_NOSANDBOX;
323 332
333#define CLEAR_ON_NONE(v) \
334 do { \
335 if (option_clear_or_none(v)) { \
336 free(v); \
337 v = NULL; \
338 } \
339 } while(0)
340 CLEAR_ON_NONE(options->pid_file);
341 CLEAR_ON_NONE(options->xauth_location);
342 CLEAR_ON_NONE(options->banner);
343 CLEAR_ON_NONE(options->trusted_user_ca_keys);
344 CLEAR_ON_NONE(options->revoked_keys_file);
345 for (i = 0; i < options->num_host_key_files; i++)
346 CLEAR_ON_NONE(options->host_key_files[i]);
347 for (i = 0; i < options->num_host_cert_files; i++)
348 CLEAR_ON_NONE(options->host_cert_files[i]);
349#undef CLEAR_ON_NONE
350
324#ifndef HAVE_MMAP 351#ifndef HAVE_MMAP
325 if (use_privsep && options->compression == 1) { 352 if (use_privsep && options->compression == 1) {
326 error("This platform does not support both privilege " 353 error("This platform does not support both privilege "
@@ -538,6 +565,8 @@ derelativise_path(const char *path)
538{ 565{
539 char *expanded, *ret, cwd[MAXPATHLEN]; 566 char *expanded, *ret, cwd[MAXPATHLEN];
540 567
568 if (strcasecmp(path, "none") == 0)
569 return xstrdup("none");
541 expanded = tilde_expand_filename(path, getuid()); 570 expanded = tilde_expand_filename(path, getuid());
542 if (*expanded == '/') 571 if (*expanded == '/')
543 return expanded; 572 return expanded;
@@ -1982,7 +2011,8 @@ dump_cfg_string(ServerOpCodes code, const char *val)
1982{ 2011{
1983 if (val == NULL) 2012 if (val == NULL)
1984 return; 2013 return;
1985 printf("%s %s\n", lookup_opcode_name(code), val); 2014 printf("%s %s\n", lookup_opcode_name(code),
2015 val == NULL ? "none" : val);
1986} 2016}
1987 2017
1988static void 2018static void