|
Lines 22-33
RCSID("$OpenBSD: servconf.c,v 1.146 2005
Link Here
|
| 22 |
#include "cipher.h" |
22 |
#include "cipher.h" |
| 23 |
#include "kex.h" |
23 |
#include "kex.h" |
| 24 |
#include "mac.h" |
24 |
#include "mac.h" |
|
|
25 |
#include "match.h" |
| 25 |
|
26 |
|
| 26 |
static void add_listen_addr(ServerOptions *, char *, u_short); |
27 |
static void add_listen_addr(ServerOptions *, char *, u_short); |
| 27 |
static void add_one_listen_addr(ServerOptions *, char *, u_short); |
28 |
static void add_one_listen_addr(ServerOptions *, char *, u_short); |
| 28 |
|
29 |
|
| 29 |
/* Use of privilege separation or not */ |
30 |
/* Use of privilege separation or not */ |
| 30 |
extern int use_privsep; |
31 |
extern int use_privsep; |
|
|
32 |
extern Buffer cfg; |
| 31 |
|
33 |
|
| 32 |
/* Initializes the server options to their default values. */ |
34 |
/* Initializes the server options to their default values. */ |
| 33 |
|
35 |
|
|
Lines 102-110
initialize_server_options(ServerOptions
Link Here
|
| 102 |
options->authorized_keys_file2 = NULL; |
104 |
options->authorized_keys_file2 = NULL; |
| 103 |
options->num_accept_env = 0; |
105 |
options->num_accept_env = 0; |
| 104 |
options->permit_tun = -1; |
106 |
options->permit_tun = -1; |
| 105 |
|
|
|
| 106 |
/* Needs to be accessable in many places */ |
| 107 |
use_privsep = -1; |
| 108 |
} |
107 |
} |
| 109 |
|
108 |
|
| 110 |
void |
109 |
void |
|
Lines 274-383
typedef enum {
Link Here
|
| 274 |
sHostbasedUsesNameFromPacketOnly, sClientAliveInterval, |
273 |
sHostbasedUsesNameFromPacketOnly, sClientAliveInterval, |
| 275 |
sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2, |
274 |
sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2, |
| 276 |
sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel, |
275 |
sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel, |
|
|
276 |
sMatch, |
| 277 |
sUsePrivilegeSeparation, |
277 |
sUsePrivilegeSeparation, |
| 278 |
sDeprecated, sUnsupported |
278 |
sDeprecated, sUnsupported |
| 279 |
} ServerOpCodes; |
279 |
} ServerOpCodes; |
| 280 |
|
280 |
|
|
|
281 |
#define SSHCFG_GLOBAL 0x01 |
| 282 |
#define SSHCFG_MATCH 0x02 |
| 283 |
#define SSHCFG_ALL (SSHCFG_GLOBAL|SSHCFG_MATCH) |
| 284 |
|
| 281 |
/* Textual representation of the tokens. */ |
285 |
/* Textual representation of the tokens. */ |
| 282 |
static struct { |
286 |
static struct { |
| 283 |
const char *name; |
287 |
const char *name; |
| 284 |
ServerOpCodes opcode; |
288 |
ServerOpCodes opcode; |
|
|
289 |
u_int flags; |
| 285 |
} keywords[] = { |
290 |
} keywords[] = { |
| 286 |
/* Portable-specific options */ |
291 |
/* Portable-specific options */ |
| 287 |
#ifdef USE_PAM |
292 |
#ifdef USE_PAM |
| 288 |
{ "usepam", sUsePAM }, |
293 |
{ "usepam", sUsePAM, SSHCFG_ALL }, |
| 289 |
#else |
294 |
#else |
| 290 |
{ "usepam", sUnsupported }, |
295 |
{ "usepam", sUnsupported, SSHCFG_ALL }, |
| 291 |
#endif |
296 |
#endif |
| 292 |
{ "pamauthenticationviakbdint", sDeprecated }, |
297 |
{ "pamauthenticationviakbdint", sDeprecated, SSHCFG_GLOBAL }, |
| 293 |
/* Standard Options */ |
298 |
/* Standard Options */ |
| 294 |
{ "port", sPort }, |
299 |
{ "port", sPort, SSHCFG_GLOBAL }, |
| 295 |
{ "hostkey", sHostKeyFile }, |
300 |
{ "hostkey", sHostKeyFile, SSHCFG_GLOBAL }, |
| 296 |
{ "hostdsakey", sHostKeyFile }, /* alias */ |
301 |
{ "hostdsakey", sHostKeyFile, SSHCFG_GLOBAL }, /* alias */ |
| 297 |
{ "pidfile", sPidFile }, |
302 |
{ "pidfile", sPidFile, SSHCFG_GLOBAL }, |
| 298 |
{ "serverkeybits", sServerKeyBits }, |
303 |
{ "serverkeybits", sServerKeyBits, SSHCFG_GLOBAL }, |
| 299 |
{ "logingracetime", sLoginGraceTime }, |
304 |
{ "logingracetime", sLoginGraceTime, SSHCFG_ALL }, |
| 300 |
{ "keyregenerationinterval", sKeyRegenerationTime }, |
305 |
{ "keyregenerationinterval", sKeyRegenerationTime, SSHCFG_GLOBAL }, |
| 301 |
{ "permitrootlogin", sPermitRootLogin }, |
306 |
{ "permitrootlogin", sPermitRootLogin, SSHCFG_ALL }, |
| 302 |
{ "syslogfacility", sLogFacility }, |
307 |
{ "syslogfacility", sLogFacility, SSHCFG_ALL }, |
| 303 |
{ "loglevel", sLogLevel }, |
308 |
{ "loglevel", sLogLevel, SSHCFG_ALL }, |
| 304 |
{ "rhostsauthentication", sDeprecated }, |
309 |
{ "rhostsauthentication", sDeprecated, SSHCFG_GLOBAL }, |
| 305 |
{ "rhostsrsaauthentication", sRhostsRSAAuthentication }, |
310 |
{ "rhostsrsaauthentication", sRhostsRSAAuthentication, SSHCFG_ALL }, |
| 306 |
{ "hostbasedauthentication", sHostbasedAuthentication }, |
311 |
{ "hostbasedauthentication", sHostbasedAuthentication, SSHCFG_ALL }, |
| 307 |
{ "hostbasedusesnamefrompacketonly", sHostbasedUsesNameFromPacketOnly }, |
312 |
{ "hostbasedusesnamefrompacketonly", sHostbasedUsesNameFromPacketOnly, SSHCFG_ALL }, |
| 308 |
{ "rsaauthentication", sRSAAuthentication }, |
313 |
{ "rsaauthentication", sRSAAuthentication, SSHCFG_ALL }, |
| 309 |
{ "pubkeyauthentication", sPubkeyAuthentication }, |
314 |
{ "pubkeyauthentication", sPubkeyAuthentication, SSHCFG_ALL }, |
| 310 |
{ "dsaauthentication", sPubkeyAuthentication }, /* alias */ |
315 |
{ "dsaauthentication", sPubkeyAuthentication, SSHCFG_ALL }, /* alias */ |
| 311 |
#ifdef KRB5 |
316 |
#ifdef KRB5 |
| 312 |
{ "kerberosauthentication", sKerberosAuthentication }, |
317 |
{ "kerberosauthentication", sKerberosAuthentication, SSHCFG_ALL }, |
| 313 |
{ "kerberosorlocalpasswd", sKerberosOrLocalPasswd }, |
318 |
{ "kerberosorlocalpasswd", sKerberosOrLocalPasswd, SSHCFG_ALL }, |
| 314 |
{ "kerberosticketcleanup", sKerberosTicketCleanup }, |
319 |
{ "kerberosticketcleanup", sKerberosTicketCleanup, SSHCFG_ALL }, |
| 315 |
#ifdef USE_AFS |
320 |
#ifdef USE_AFS |
| 316 |
{ "kerberosgetafstoken", sKerberosGetAFSToken }, |
321 |
{ "kerberosgetafstoken", sKerberosGetAFSToken, SSHCFG_ALL }, |
| 317 |
#else |
322 |
#else |
| 318 |
{ "kerberosgetafstoken", sUnsupported }, |
323 |
{ "kerberosgetafstoken", sUnsupported, SSHCFG_ALL }, |
| 319 |
#endif |
324 |
#endif |
| 320 |
#else |
325 |
#else |
| 321 |
{ "kerberosauthentication", sUnsupported }, |
326 |
{ "kerberosauthentication", sUnsupported, SSHCFG_ALL }, |
| 322 |
{ "kerberosorlocalpasswd", sUnsupported }, |
327 |
{ "kerberosorlocalpasswd", sUnsupported, SSHCFG_ALL }, |
| 323 |
{ "kerberosticketcleanup", sUnsupported }, |
328 |
{ "kerberosticketcleanup", sUnsupported, SSHCFG_ALL }, |
| 324 |
{ "kerberosgetafstoken", sUnsupported }, |
329 |
{ "kerberosgetafstoken", sUnsupported, SSHCFG_ALL }, |
| 325 |
#endif |
330 |
#endif |
| 326 |
{ "kerberostgtpassing", sUnsupported }, |
331 |
{ "kerberostgtpassing", sUnsupported, SSHCFG_ALL }, |
| 327 |
{ "afstokenpassing", sUnsupported }, |
332 |
{ "afstokenpassing", sUnsupported, SSHCFG_ALL }, |
| 328 |
#ifdef GSSAPI |
333 |
#ifdef GSSAPI |
| 329 |
{ "gssapiauthentication", sGssAuthentication }, |
334 |
{ "gssapiauthentication", sGssAuthentication, SSHCFG_ALL }, |
| 330 |
{ "gssapicleanupcredentials", sGssCleanupCreds }, |
335 |
{ "gssapicleanupcredentials", sGssCleanupCreds, SSHCFG_ALL }, |
| 331 |
#else |
336 |
#else |
| 332 |
{ "gssapiauthentication", sUnsupported }, |
337 |
{ "gssapiauthentication", sUnsupported, SSHCFG_ALL }, |
| 333 |
{ "gssapicleanupcredentials", sUnsupported }, |
338 |
{ "gssapicleanupcredentials", sUnsupported, SSHCFG_ALL }, |
| 334 |
#endif |
339 |
#endif |
| 335 |
{ "passwordauthentication", sPasswordAuthentication }, |
340 |
{ "passwordauthentication", sPasswordAuthentication, SSHCFG_ALL }, |
| 336 |
{ "kbdinteractiveauthentication", sKbdInteractiveAuthentication }, |
341 |
{ "kbdinteractiveauthentication", sKbdInteractiveAuthentication, SSHCFG_ALL }, |
| 337 |
{ "challengeresponseauthentication", sChallengeResponseAuthentication }, |
342 |
{ "challengeresponseauthentication", sChallengeResponseAuthentication, SSHCFG_ALL }, |
| 338 |
{ "skeyauthentication", sChallengeResponseAuthentication }, /* alias */ |
343 |
{ "skeyauthentication", sChallengeResponseAuthentication, SSHCFG_ALL }, /* alias */ |
| 339 |
{ "checkmail", sDeprecated }, |
344 |
{ "checkmail", sDeprecated, SSHCFG_GLOBAL }, |
| 340 |
{ "listenaddress", sListenAddress }, |
345 |
{ "listenaddress", sListenAddress, SSHCFG_GLOBAL }, |
| 341 |
{ "addressfamily", sAddressFamily }, |
346 |
{ "addressfamily", sAddressFamily, SSHCFG_GLOBAL }, |
| 342 |
{ "printmotd", sPrintMotd }, |
347 |
{ "printmotd", sPrintMotd, SSHCFG_ALL }, |
| 343 |
{ "printlastlog", sPrintLastLog }, |
348 |
{ "printlastlog", sPrintLastLog, SSHCFG_ALL }, |
| 344 |
{ "ignorerhosts", sIgnoreRhosts }, |
349 |
{ "ignorerhosts", sIgnoreRhosts, SSHCFG_ALL }, |
| 345 |
{ "ignoreuserknownhosts", sIgnoreUserKnownHosts }, |
350 |
{ "ignoreuserknownhosts", sIgnoreUserKnownHosts, SSHCFG_ALL }, |
| 346 |
{ "x11forwarding", sX11Forwarding }, |
351 |
{ "x11forwarding", sX11Forwarding, SSHCFG_ALL }, |
| 347 |
{ "x11displayoffset", sX11DisplayOffset }, |
352 |
{ "x11displayoffset", sX11DisplayOffset, SSHCFG_ALL }, |
| 348 |
{ "x11uselocalhost", sX11UseLocalhost }, |
353 |
{ "x11uselocalhost", sX11UseLocalhost, SSHCFG_ALL }, |
| 349 |
{ "xauthlocation", sXAuthLocation }, |
354 |
{ "xauthlocation", sXAuthLocation, SSHCFG_ALL }, |
| 350 |
{ "strictmodes", sStrictModes }, |
355 |
{ "strictmodes", sStrictModes, SSHCFG_ALL }, |
| 351 |
{ "permitemptypasswords", sEmptyPasswd }, |
356 |
{ "permitemptypasswords", sEmptyPasswd, SSHCFG_ALL }, |
| 352 |
{ "permituserenvironment", sPermitUserEnvironment }, |
357 |
{ "permituserenvironment", sPermitUserEnvironment, SSHCFG_ALL }, |
| 353 |
{ "uselogin", sUseLogin }, |
358 |
{ "uselogin", sUseLogin, SSHCFG_ALL }, |
| 354 |
{ "compression", sCompression }, |
359 |
{ "compression", sCompression, SSHCFG_GLOBAL }, |
| 355 |
{ "tcpkeepalive", sTCPKeepAlive }, |
360 |
{ "tcpkeepalive", sTCPKeepAlive, SSHCFG_GLOBAL }, |
| 356 |
{ "keepalive", sTCPKeepAlive }, /* obsolete alias */ |
361 |
{ "keepalive", sTCPKeepAlive, SSHCFG_GLOBAL }, /* obsolete alias */ |
| 357 |
{ "allowtcpforwarding", sAllowTcpForwarding }, |
362 |
{ "allowtcpforwarding", sAllowTcpForwarding, SSHCFG_ALL }, |
| 358 |
{ "allowusers", sAllowUsers }, |
363 |
{ "allowusers", sAllowUsers, SSHCFG_GLOBAL }, |
| 359 |
{ "denyusers", sDenyUsers }, |
364 |
{ "denyusers", sDenyUsers, SSHCFG_GLOBAL }, |
| 360 |
{ "allowgroups", sAllowGroups }, |
365 |
{ "allowgroups", sAllowGroups, SSHCFG_GLOBAL }, |
| 361 |
{ "denygroups", sDenyGroups }, |
366 |
{ "denygroups", sDenyGroups, SSHCFG_GLOBAL }, |
| 362 |
{ "ciphers", sCiphers }, |
367 |
{ "ciphers", sCiphers, SSHCFG_GLOBAL }, |
| 363 |
{ "macs", sMacs }, |
368 |
{ "macs", sMacs, SSHCFG_GLOBAL }, |
| 364 |
{ "protocol", sProtocol }, |
369 |
{ "protocol", sProtocol, SSHCFG_GLOBAL }, |
| 365 |
{ "gatewayports", sGatewayPorts }, |
370 |
{ "gatewayports", sGatewayPorts, SSHCFG_ALL }, |
| 366 |
{ "subsystem", sSubsystem }, |
371 |
{ "subsystem", sSubsystem, SSHCFG_ALL }, |
| 367 |
{ "maxstartups", sMaxStartups }, |
372 |
{ "maxstartups", sMaxStartups, SSHCFG_GLOBAL }, |
| 368 |
{ "maxauthtries", sMaxAuthTries }, |
373 |
{ "maxauthtries", sMaxAuthTries, SSHCFG_ALL }, |
| 369 |
{ "banner", sBanner }, |
374 |
{ "banner", sBanner, SSHCFG_ALL }, |
| 370 |
{ "usedns", sUseDNS }, |
375 |
{ "usedns", sUseDNS, SSHCFG_GLOBAL }, |
| 371 |
{ "verifyreversemapping", sDeprecated }, |
376 |
{ "verifyreversemapping", sDeprecated, SSHCFG_GLOBAL }, |
| 372 |
{ "reversemappingcheck", sDeprecated }, |
377 |
{ "reversemappingcheck", sDeprecated, SSHCFG_GLOBAL }, |
| 373 |
{ "clientaliveinterval", sClientAliveInterval }, |
378 |
{ "clientaliveinterval", sClientAliveInterval, SSHCFG_ALL }, |
| 374 |
{ "clientalivecountmax", sClientAliveCountMax }, |
379 |
{ "clientalivecountmax", sClientAliveCountMax, SSHCFG_ALL }, |
| 375 |
{ "authorizedkeysfile", sAuthorizedKeysFile }, |
380 |
{ "authorizedkeysfile", sAuthorizedKeysFile, SSHCFG_ALL }, |
| 376 |
{ "authorizedkeysfile2", sAuthorizedKeysFile2 }, |
381 |
{ "authorizedkeysfile2", sAuthorizedKeysFile2, SSHCFG_ALL }, |
| 377 |
{ "useprivilegeseparation", sUsePrivilegeSeparation}, |
382 |
{ "useprivilegeseparation", sUsePrivilegeSeparation, SSHCFG_GLOBAL}, |
| 378 |
{ "acceptenv", sAcceptEnv }, |
383 |
{ "acceptenv", sAcceptEnv, SSHCFG_ALL }, |
| 379 |
{ "permittunnel", sPermitTunnel }, |
384 |
{ "permittunnel", sPermitTunnel, SSHCFG_ALL }, |
| 380 |
{ NULL, sBadOption } |
385 |
{ "match", sMatch, SSHCFG_ALL }, |
|
|
386 |
{ NULL, sBadOption, 0 } |
| 381 |
}; |
387 |
}; |
| 382 |
|
388 |
|
| 383 |
/* |
389 |
/* |
|
Lines 386-398
static struct {
Link Here
|
| 386 |
|
392 |
|
| 387 |
static ServerOpCodes |
393 |
static ServerOpCodes |
| 388 |
parse_token(const char *cp, const char *filename, |
394 |
parse_token(const char *cp, const char *filename, |
| 389 |
int linenum) |
395 |
int linenum, u_int *flags) |
| 390 |
{ |
396 |
{ |
| 391 |
u_int i; |
397 |
u_int i; |
| 392 |
|
398 |
|
| 393 |
for (i = 0; keywords[i].name; i++) |
399 |
for (i = 0; keywords[i].name; i++) |
| 394 |
if (strcasecmp(cp, keywords[i].name) == 0) |
400 |
if (strcasecmp(cp, keywords[i].name) == 0) { |
|
|
401 |
*flags = keywords[i].flags; |
| 395 |
return keywords[i].opcode; |
402 |
return keywords[i].opcode; |
|
|
403 |
} |
| 396 |
|
404 |
|
| 397 |
error("%s: line %d: Bad configuration option: %s", |
405 |
error("%s: line %d: Bad configuration option: %s", |
| 398 |
filename, linenum, cp); |
406 |
filename, linenum, cp); |
|
Lines 437-451
add_one_listen_addr(ServerOptions *optio
Link Here
|
| 437 |
options->listen_addrs = aitop; |
445 |
options->listen_addrs = aitop; |
| 438 |
} |
446 |
} |
| 439 |
|
447 |
|
|
|
448 |
/* |
| 449 |
* The strategy for the Match blocks is that the config file is parsed twice. |
| 450 |
* |
| 451 |
* The first time is at startup. activep is initialized to 1 and the |
| 452 |
* directives in the global context are processed and acted on. Hitting a |
| 453 |
* Match directive unsets activep and the directives inside the block are |
| 454 |
* checked for syntax only. |
| 455 |
* |
| 456 |
* The second time is after a connection has been established but before |
| 457 |
* authentication. activep is initialized to 2 and global config directives |
| 458 |
* are ignored since they have already been processed. If the criteria in a |
| 459 |
* Match block is met, activep is set and the subsequent directives |
| 460 |
* processed and actioned until EOF or another Match block unsets it. Any |
| 461 |
* options set are copied into the main server config. |
| 462 |
* |
| 463 |
* Potential additions/improvements: |
| 464 |
* - Add Match support for pre-kex directives, eg Protocol, Ciphers. |
| 465 |
* |
| 466 |
* - Add a Tag directive (idea from David Leonard) ala pf, eg: |
| 467 |
* Match Address 192.168.0.* |
| 468 |
* Tag trusted |
| 469 |
* Match Group wheel |
| 470 |
* Tag trusted |
| 471 |
* Match Tag trusted |
| 472 |
* AllowTcpForwarding yes |
| 473 |
* GatewayPorts clientspecified |
| 474 |
* [...] |
| 475 |
* |
| 476 |
* - Add a PermittedChannelRequests directive |
| 477 |
* Match Group shell |
| 478 |
* PermittedChannelRequests session,forwarded-tcpip |
| 479 |
*/ |
| 480 |
|
| 440 |
int |
481 |
int |
| 441 |
process_server_config_line(ServerOptions *options, char *line, |
482 |
process_server_config_line(ServerOptions *options, char *line, |
| 442 |
const char *filename, int linenum) |
483 |
const char *filename, int linenum, int *activep, const char *user, |
|
|
484 |
const char *host, const char *address) |
| 443 |
{ |
485 |
{ |
| 444 |
char *cp, **charptr, *arg, *p; |
486 |
char *cp, **charptr, *arg, *p; |
| 445 |
int *intptr, value, n; |
487 |
int cmdline = 0, *intptr, value, n; |
| 446 |
ServerOpCodes opcode; |
488 |
ServerOpCodes opcode; |
| 447 |
u_short port; |
489 |
u_short port; |
| 448 |
u_int i; |
490 |
u_int i, flags = 0; |
| 449 |
|
491 |
|
| 450 |
cp = line; |
492 |
cp = line; |
| 451 |
arg = strdelim(&cp); |
493 |
arg = strdelim(&cp); |
|
Lines 456-462
process_server_config_line(ServerOptions
Link Here
|
| 456 |
return 0; |
498 |
return 0; |
| 457 |
intptr = NULL; |
499 |
intptr = NULL; |
| 458 |
charptr = NULL; |
500 |
charptr = NULL; |
| 459 |
opcode = parse_token(arg, filename, linenum); |
501 |
opcode = parse_token(arg, filename, linenum, &flags); |
|
|
502 |
|
| 503 |
if (activep == NULL) { /* We are processing a command line directive */ |
| 504 |
cmdline = 1; |
| 505 |
activep = &cmdline; |
| 506 |
} |
| 507 |
debug3("match: line %s active %d flags %d", line, *activep, flags); |
| 508 |
if (*activep == 0 && !(flags & SSHCFG_MATCH)) { |
| 509 |
if (user == NULL) { |
| 510 |
fatal("%s line %d: Directive '%s' is not allowed " |
| 511 |
"within a Match block", filename, linenum, arg); |
| 512 |
} else { /* this is a directive we have already processed */ |
| 513 |
while (arg) |
| 514 |
arg = strdelim(&cp); |
| 515 |
return 0; |
| 516 |
} |
| 517 |
} |
| 518 |
|
| 460 |
switch (opcode) { |
519 |
switch (opcode) { |
| 461 |
/* Portable-specific options */ |
520 |
/* Portable-specific options */ |
| 462 |
case sUsePAM: |
521 |
case sUsePAM: |
|
Lines 494-500
parse_int:
Link Here
|
| 494 |
fatal("%s line %d: missing integer value.", |
553 |
fatal("%s line %d: missing integer value.", |
| 495 |
filename, linenum); |
554 |
filename, linenum); |
| 496 |
value = atoi(arg); |
555 |
value = atoi(arg); |
| 497 |
if (*intptr == -1) |
556 |
if (*activep && *intptr == -1) |
| 498 |
*intptr = value; |
557 |
*intptr = value; |
| 499 |
break; |
558 |
break; |
| 500 |
|
559 |
|
|
Lines 574-580
parse_filename:
Link Here
|
| 574 |
if (!arg || *arg == '\0') |
633 |
if (!arg || *arg == '\0') |
| 575 |
fatal("%s line %d: missing file name.", |
634 |
fatal("%s line %d: missing file name.", |
| 576 |
filename, linenum); |
635 |
filename, linenum); |
| 577 |
if (*charptr == NULL) { |
636 |
if (*activep && *charptr == NULL) { |
| 578 |
*charptr = tilde_expand_filename(arg, getuid()); |
637 |
*charptr = tilde_expand_filename(arg, getuid()); |
| 579 |
/* increase optional counter */ |
638 |
/* increase optional counter */ |
| 580 |
if (intptr != NULL) |
639 |
if (intptr != NULL) |
|
Lines 625-631
parse_flag:
Link Here
|
| 625 |
else |
684 |
else |
| 626 |
fatal("%s line %d: Bad yes/no argument: %s", |
685 |
fatal("%s line %d: Bad yes/no argument: %s", |
| 627 |
filename, linenum, arg); |
686 |
filename, linenum, arg); |
| 628 |
if (*intptr == -1) |
687 |
if (*activep && *intptr == -1) |
| 629 |
*intptr = value; |
688 |
*intptr = value; |
| 630 |
break; |
689 |
break; |
| 631 |
|
690 |
|
|
Lines 890-895
parse_flag:
Link Here
|
| 890 |
if (!arg || *arg == '\0') |
949 |
if (!arg || *arg == '\0') |
| 891 |
fatal("%s line %d: Missing subsystem name.", |
950 |
fatal("%s line %d: Missing subsystem name.", |
| 892 |
filename, linenum); |
951 |
filename, linenum); |
|
|
952 |
if (!*activep) { |
| 953 |
arg = strdelim(&cp); |
| 954 |
break; |
| 955 |
} |
| 893 |
for (i = 0; i < options->num_subsystems; i++) |
956 |
for (i = 0; i < options->num_subsystems; i++) |
| 894 |
if (strcmp(arg, options->subsystem_name[i]) == 0) |
957 |
if (strcmp(arg, options->subsystem_name[i]) == 0) |
| 895 |
fatal("%s line %d: Subsystem '%s' already defined.", |
958 |
fatal("%s line %d: Subsystem '%s' already defined.", |
|
Lines 961-966
parse_flag:
Link Here
|
| 961 |
if (options->num_accept_env >= MAX_ACCEPT_ENV) |
1024 |
if (options->num_accept_env >= MAX_ACCEPT_ENV) |
| 962 |
fatal("%s line %d: too many allow env.", |
1025 |
fatal("%s line %d: too many allow env.", |
| 963 |
filename, linenum); |
1026 |
filename, linenum); |
|
|
1027 |
if (!*activep) |
| 1028 |
break; |
| 964 |
options->accept_env[options->num_accept_env++] = |
1029 |
options->accept_env[options->num_accept_env++] = |
| 965 |
xstrdup(arg); |
1030 |
xstrdup(arg); |
| 966 |
} |
1031 |
} |
|
Lines 988-993
parse_flag:
Link Here
|
| 988 |
*intptr = value; |
1053 |
*intptr = value; |
| 989 |
break; |
1054 |
break; |
| 990 |
|
1055 |
|
|
|
1056 |
case sMatch: |
| 1057 |
if (cmdline) |
| 1058 |
fatal("Match directive not supported as a command-line " |
| 1059 |
"option"); |
| 1060 |
value = match_cfg_line(&cp, linenum, user, host, address); |
| 1061 |
if (value < 0) |
| 1062 |
fatal("%s line %d: Bad Match condition", filename, |
| 1063 |
linenum); |
| 1064 |
*activep = value; |
| 1065 |
break; |
| 1066 |
|
| 991 |
case sDeprecated: |
1067 |
case sDeprecated: |
| 992 |
logit("%s line %d: Deprecated option %s", |
1068 |
logit("%s line %d: Deprecated option %s", |
| 993 |
filename, linenum, arg); |
1069 |
filename, linenum, arg); |
|
Lines 1044-1061
load_server_config(const char *filename,
Link Here
|
| 1044 |
} |
1120 |
} |
| 1045 |
|
1121 |
|
| 1046 |
void |
1122 |
void |
| 1047 |
parse_server_config(ServerOptions *options, const char *filename, Buffer *conf) |
1123 |
parse_server_match_config(ServerOptions *options, const char *user, |
|
|
1124 |
const char *host, const char *address) |
| 1125 |
{ |
| 1126 |
u_int i; |
| 1127 |
ServerOptions mo; |
| 1128 |
|
| 1129 |
initialize_server_options(&mo); |
| 1130 |
parse_server_config(&mo, "reprocess config", &cfg, user, host, address); |
| 1131 |
|
| 1132 |
/* now copy any (supported) values set */ |
| 1133 |
if (mo.use_pam != -1) |
| 1134 |
options->use_pam = mo.use_pam; |
| 1135 |
if (mo.num_accept_env > 0) { |
| 1136 |
for (i = 0; i < options->num_accept_env; i++) |
| 1137 |
xfree(options->accept_env[i]); |
| 1138 |
options->num_accept_env = 0; |
| 1139 |
for (i = 0; i < mo.num_accept_env; i++) { |
| 1140 |
if (options->num_accept_env >= MAX_ACCEPT_ENV) |
| 1141 |
fatal("Too many allow env in Match block."); |
| 1142 |
options->accept_env[options->num_accept_env++] = |
| 1143 |
mo.accept_env[i]; |
| 1144 |
} |
| 1145 |
} |
| 1146 |
if (mo.allow_tcp_forwarding != -1) |
| 1147 |
options->allow_tcp_forwarding = mo.allow_tcp_forwarding; |
| 1148 |
if (mo.authorized_keys_file != NULL) { |
| 1149 |
if (options->authorized_keys_file != NULL) |
| 1150 |
xfree(options->authorized_keys_file); |
| 1151 |
options->authorized_keys_file = mo.authorized_keys_file; |
| 1152 |
} |
| 1153 |
if (mo.authorized_keys_file2 != NULL) { |
| 1154 |
if (options->authorized_keys_file2 != NULL) |
| 1155 |
xfree(options->authorized_keys_file2); |
| 1156 |
options->authorized_keys_file2 = mo.authorized_keys_file2; |
| 1157 |
} |
| 1158 |
if (mo.banner != NULL) { |
| 1159 |
if (options->banner != NULL) |
| 1160 |
xfree(options->banner); |
| 1161 |
options->banner = mo.banner; |
| 1162 |
} |
| 1163 |
if (mo.password_authentication != -1) |
| 1164 |
options->password_authentication = mo.password_authentication; |
| 1165 |
if (mo.challenge_response_authentication != -1) |
| 1166 |
options->challenge_response_authentication = |
| 1167 |
mo.challenge_response_authentication; |
| 1168 |
if (mo.client_alive_count_max != -1) |
| 1169 |
options->client_alive_count_max = mo.client_alive_count_max; |
| 1170 |
if (mo.client_alive_interval != -1) |
| 1171 |
options->client_alive_interval = mo.client_alive_interval; |
| 1172 |
if (mo.gateway_ports != -1) |
| 1173 |
options->gateway_ports = mo.gateway_ports; |
| 1174 |
if (mo.gss_authentication != -1) |
| 1175 |
options->gss_authentication = mo.gss_authentication; |
| 1176 |
if (mo.hostbased_authentication != -1) |
| 1177 |
options->hostbased_authentication = mo.hostbased_authentication; |
| 1178 |
if (mo.hostbased_uses_name_from_packet_only != -1) |
| 1179 |
options->hostbased_uses_name_from_packet_only = |
| 1180 |
mo.hostbased_uses_name_from_packet_only; |
| 1181 |
if (mo.kerberos_authentication != -1) |
| 1182 |
options->kerberos_authentication = mo.kerberos_authentication; |
| 1183 |
if (mo.kerberos_or_local_passwd != -1) |
| 1184 |
options->kerberos_or_local_passwd = mo.kerberos_or_local_passwd; |
| 1185 |
if (mo.kerberos_ticket_cleanup != -1) |
| 1186 |
options->kerberos_ticket_cleanup = mo.kerberos_ticket_cleanup; |
| 1187 |
if (mo.kerberos_get_afs_token != -1) |
| 1188 |
options->kerberos_get_afs_token = mo.kerberos_get_afs_token; |
| 1189 |
if (mo.login_grace_time != -1) |
| 1190 |
options->login_grace_time = mo.login_grace_time; |
| 1191 |
if (mo.log_facility != -1) |
| 1192 |
options->log_facility = mo.log_facility; |
| 1193 |
if (mo.log_level != -1) |
| 1194 |
options->log_level = mo.log_level; |
| 1195 |
if (mo.permit_root_login != -1) |
| 1196 |
options->permit_root_login = mo.permit_root_login; |
| 1197 |
if (mo.max_authtries != -1) |
| 1198 |
options->max_authtries = mo.max_authtries; |
| 1199 |
if (mo.permit_empty_passwd != -1) |
| 1200 |
options->permit_empty_passwd = mo.permit_empty_passwd; |
| 1201 |
if (mo.permit_tun != -1) |
| 1202 |
options->permit_tun = mo.permit_tun; |
| 1203 |
if (mo.permit_user_env != -1) |
| 1204 |
options->permit_user_env = mo.permit_user_env; |
| 1205 |
if (mo.print_motd != -1) |
| 1206 |
options->print_motd = mo.print_motd; |
| 1207 |
if (mo.pubkey_authentication != -1) |
| 1208 |
options->pubkey_authentication = mo.pubkey_authentication; |
| 1209 |
if (mo.rsa_authentication != -1) |
| 1210 |
options->rsa_authentication = mo.rsa_authentication; |
| 1211 |
if (mo.strict_modes != -1) |
| 1212 |
options->strict_modes = mo.strict_modes; |
| 1213 |
if (mo.num_subsystems != 0) { /* Not currently used */ |
| 1214 |
for (i = 0; i < options->num_subsystems; i++) { |
| 1215 |
xfree(options->subsystem_name[i]); |
| 1216 |
xfree(options->subsystem_command[i]); |
| 1217 |
} |
| 1218 |
options->num_subsystems = 0; |
| 1219 |
for (i = 0; i < mo.num_subsystems; i++) { |
| 1220 |
options->subsystem_name[options->num_subsystems] = |
| 1221 |
mo.subsystem_name[i]; |
| 1222 |
options->subsystem_command[options->num_subsystems] = |
| 1223 |
mo.subsystem_command[i]; |
| 1224 |
options->num_subsystems++; |
| 1225 |
} |
| 1226 |
} |
| 1227 |
if (mo.use_login != -1) |
| 1228 |
options->use_login = mo.use_login; |
| 1229 |
if (mo.xauth_location != NULL) { |
| 1230 |
if (options->xauth_location != NULL) |
| 1231 |
xfree(options->xauth_location); |
| 1232 |
options->xauth_location = mo.xauth_location; |
| 1233 |
} |
| 1234 |
if (mo.x11_display_offset != -1) |
| 1235 |
options->x11_display_offset = mo.x11_display_offset; |
| 1236 |
if (mo.x11_forwarding != -1) |
| 1237 |
options->x11_forwarding = mo.x11_forwarding; |
| 1238 |
if (mo.x11_use_localhost != -1) |
| 1239 |
options->x11_use_localhost = mo.x11_use_localhost; |
| 1240 |
} |
| 1241 |
|
| 1242 |
void |
| 1243 |
parse_server_config(ServerOptions *options, const char *filename, Buffer *conf, |
| 1244 |
const char *user, const char *host, const char *address) |
| 1048 |
{ |
1245 |
{ |
| 1049 |
int linenum, bad_options = 0; |
1246 |
int active, linenum, bad_options = 0; |
| 1050 |
char *cp, *obuf, *cbuf; |
1247 |
char *cp, *obuf, *cbuf; |
| 1051 |
|
1248 |
|
| 1052 |
debug2("%s: config %s len %d", __func__, filename, buffer_len(conf)); |
1249 |
debug2("%s: config %s len %d", __func__, filename, buffer_len(conf)); |
| 1053 |
|
1250 |
|
| 1054 |
obuf = cbuf = xstrdup(buffer_ptr(conf)); |
1251 |
obuf = cbuf = xstrdup(buffer_ptr(conf)); |
|
|
1252 |
active = user ? 0 : 1; |
| 1055 |
linenum = 1; |
1253 |
linenum = 1; |
| 1056 |
while ((cp = strsep(&cbuf, "\n")) != NULL) { |
1254 |
while ((cp = strsep(&cbuf, "\n")) != NULL) { |
| 1057 |
if (process_server_config_line(options, cp, filename, |
1255 |
if (process_server_config_line(options, cp, filename, |
| 1058 |
linenum++) != 0) |
1256 |
linenum++, &active, user, host, address) != 0) |
| 1059 |
bad_options++; |
1257 |
bad_options++; |
| 1060 |
} |
1258 |
} |
| 1061 |
xfree(obuf); |
1259 |
xfree(obuf); |