diff options
Diffstat (limited to 'servconf.c')
-rw-r--r-- | servconf.c | 87 |
1 files changed, 16 insertions, 71 deletions
diff --git a/servconf.c b/servconf.c index f6d063989..086bc0364 100644 --- a/servconf.c +++ b/servconf.c | |||
@@ -12,7 +12,7 @@ Created: Mon Aug 21 15:48:58 1995 ylo | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "includes.h" | 14 | #include "includes.h" |
15 | RCSID("$Id: servconf.c,v 1.4 1999/11/12 04:19:27 damien Exp $"); | 15 | RCSID("$Id: servconf.c,v 1.5 1999/11/21 02:23:53 damien Exp $"); |
16 | 16 | ||
17 | #include "ssh.h" | 17 | #include "ssh.h" |
18 | #include "servconf.h" | 18 | #include "servconf.h" |
@@ -214,41 +214,6 @@ static struct | |||
214 | { NULL, 0 } | 214 | { NULL, 0 } |
215 | }; | 215 | }; |
216 | 216 | ||
217 | static struct | ||
218 | { | ||
219 | const char *name; | ||
220 | SyslogFacility facility; | ||
221 | } log_facilities[] = | ||
222 | { | ||
223 | { "DAEMON", SYSLOG_FACILITY_DAEMON }, | ||
224 | { "USER", SYSLOG_FACILITY_USER }, | ||
225 | { "AUTH", SYSLOG_FACILITY_AUTH }, | ||
226 | { "LOCAL0", SYSLOG_FACILITY_LOCAL0 }, | ||
227 | { "LOCAL1", SYSLOG_FACILITY_LOCAL1 }, | ||
228 | { "LOCAL2", SYSLOG_FACILITY_LOCAL2 }, | ||
229 | { "LOCAL3", SYSLOG_FACILITY_LOCAL3 }, | ||
230 | { "LOCAL4", SYSLOG_FACILITY_LOCAL4 }, | ||
231 | { "LOCAL5", SYSLOG_FACILITY_LOCAL5 }, | ||
232 | { "LOCAL6", SYSLOG_FACILITY_LOCAL6 }, | ||
233 | { "LOCAL7", SYSLOG_FACILITY_LOCAL7 }, | ||
234 | { NULL, 0 } | ||
235 | }; | ||
236 | |||
237 | static struct | ||
238 | { | ||
239 | const char *name; | ||
240 | LogLevel level; | ||
241 | } log_levels[] = | ||
242 | { | ||
243 | { "QUIET", SYSLOG_LEVEL_QUIET }, | ||
244 | { "FATAL", SYSLOG_LEVEL_FATAL }, | ||
245 | { "ERROR", SYSLOG_LEVEL_ERROR }, | ||
246 | { "INFO", SYSLOG_LEVEL_INFO }, | ||
247 | { "CHAT", SYSLOG_LEVEL_CHAT }, | ||
248 | { "DEBUG", SYSLOG_LEVEL_DEBUG }, | ||
249 | { NULL, 0 } | ||
250 | }; | ||
251 | |||
252 | /* Returns the number of the token pointed to by cp of length len. | 217 | /* Returns the number of the token pointed to by cp of length len. |
253 | Never returns if the token is not known. */ | 218 | Never returns if the token is not known. */ |
254 | 219 | ||
@@ -273,7 +238,7 @@ void read_server_config(ServerOptions *options, const char *filename) | |||
273 | FILE *f; | 238 | FILE *f; |
274 | char line[1024]; | 239 | char line[1024]; |
275 | char *cp, **charptr; | 240 | char *cp, **charptr; |
276 | int linenum, *intptr, i, value; | 241 | int linenum, *intptr, value; |
277 | int bad_options = 0; | 242 | int bad_options = 0; |
278 | ServerOpCodes opcode; | 243 | ServerOpCodes opcode; |
279 | 244 | ||
@@ -495,45 +460,25 @@ void read_server_config(ServerOptions *options, const char *filename) | |||
495 | goto parse_flag; | 460 | goto parse_flag; |
496 | 461 | ||
497 | case sLogFacility: | 462 | case sLogFacility: |
463 | intptr = (int *)&options->log_facility; | ||
498 | cp = strtok(NULL, WHITESPACE); | 464 | cp = strtok(NULL, WHITESPACE); |
499 | if (!cp) | 465 | value = log_facility_number(cp); |
500 | { | 466 | if (value == (SyslogFacility)-1) |
501 | fprintf(stderr, "%s line %d: missing facility name.\n", | 467 | fatal("%.200s line %d: unsupported log facility '%s'\n", |
502 | filename, linenum); | 468 | filename, linenum, cp ? cp : "<NONE>"); |
503 | exit(1); | 469 | if (*intptr == -1) |
504 | } | 470 | *intptr = (SyslogFacility)value; |
505 | for (i = 0; log_facilities[i].name; i++) | ||
506 | if (strcasecmp(log_facilities[i].name, cp) == 0) | ||
507 | break; | ||
508 | if (!log_facilities[i].name) | ||
509 | { | ||
510 | fprintf(stderr, "%s line %d: unsupported log facility %s\n", | ||
511 | filename, linenum, cp); | ||
512 | exit(1); | ||
513 | } | ||
514 | if (options->log_facility == (SyslogFacility)(-1)) | ||
515 | options->log_facility = log_facilities[i].facility; | ||
516 | break; | 471 | break; |
517 | 472 | ||
518 | case sLogLevel: | 473 | case sLogLevel: |
474 | intptr = (int *)&options->log_level; | ||
519 | cp = strtok(NULL, WHITESPACE); | 475 | cp = strtok(NULL, WHITESPACE); |
520 | if (!cp) | 476 | value = log_level_number(cp); |
521 | { | 477 | if (value == (LogLevel)-1) |
522 | fprintf(stderr, "%s line %d: missing level name.\n", | 478 | fatal("%.200s line %d: unsupported log level '%s'\n", |
523 | filename, linenum); | 479 | filename, linenum, cp ? cp : "<NONE>"); |
524 | exit(1); | 480 | if (*intptr == -1) |
525 | } | 481 | *intptr = (LogLevel)value; |
526 | for (i = 0; log_levels[i].name; i++) | ||
527 | if (strcasecmp(log_levels[i].name, cp) == 0) | ||
528 | break; | ||
529 | if (!log_levels[i].name) | ||
530 | { | ||
531 | fprintf(stderr, "%s line %d: unsupported log level %s\n", | ||
532 | filename, linenum, cp); | ||
533 | exit(1); | ||
534 | } | ||
535 | if (options->log_level == (LogLevel)(-1)) | ||
536 | options->log_level = log_levels[i].level; | ||
537 | break; | 482 | break; |
538 | 483 | ||
539 | case sAllowUsers: | 484 | case sAllowUsers: |