Rather than assuming that -1 is a valid value for a LogLevel or LogFacility,
explicitly declare SYSLOG_LEVEL_NOT_SET and SYSLOG_FACILITY_NOT_SET and use those instead. This is necessary for -fshort-enums platforms, and corresponds to the following OpenBSD revisions: log.c 1.21 log.h 1.5 readconf.c 1.95 servconf.c 1.53
This commit is contained in:
parent
bf06edf092
commit
4845a9458f
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: log.c,v 1.1.1.6 2001/09/27 02:00:44 itojun Exp $ */
|
||||
/* $NetBSD: log.c,v 1.2 2002/02/10 16:23:33 bjh21 Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
|
@ -66,7 +66,7 @@ static struct {
|
|||
{ "LOCAL5", SYSLOG_FACILITY_LOCAL5 },
|
||||
{ "LOCAL6", SYSLOG_FACILITY_LOCAL6 },
|
||||
{ "LOCAL7", SYSLOG_FACILITY_LOCAL7 },
|
||||
{ NULL, 0 }
|
||||
{ NULL, SYSLOG_FACILITY_NOT_SET }
|
||||
};
|
||||
|
||||
static struct {
|
||||
|
@ -83,7 +83,7 @@ static struct {
|
|||
{ "DEBUG1", SYSLOG_LEVEL_DEBUG1 },
|
||||
{ "DEBUG2", SYSLOG_LEVEL_DEBUG2 },
|
||||
{ "DEBUG3", SYSLOG_LEVEL_DEBUG3 },
|
||||
{ NULL, 0 }
|
||||
{ NULL, SYSLOG_LEVEL_NOT_SET }
|
||||
};
|
||||
|
||||
static void do_log(LogLevel level, const char *fmt, va_list args);
|
||||
|
@ -96,7 +96,7 @@ log_facility_number(char *name)
|
|||
for (i = 0; log_facilities[i].name; i++)
|
||||
if (strcasecmp(log_facilities[i].name, name) == 0)
|
||||
return log_facilities[i].val;
|
||||
return (SyslogFacility) - 1;
|
||||
return SYSLOG_FACILITY_NOT_SET;
|
||||
}
|
||||
|
||||
LogLevel
|
||||
|
@ -107,7 +107,7 @@ log_level_number(char *name)
|
|||
for (i = 0; log_levels[i].name; i++)
|
||||
if (strcasecmp(log_levels[i].name, name) == 0)
|
||||
return log_levels[i].val;
|
||||
return (LogLevel) - 1;
|
||||
return SYSLOG_LEVEL_NOT_SET;
|
||||
}
|
||||
/* Fatal messages. This function never returns. */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: log.h,v 1.3 2001/09/27 03:24:03 itojun Exp $ */
|
||||
/* $NetBSD: log.h,v 1.4 2002/02/10 16:23:34 bjh21 Exp $ */
|
||||
/* $OpenBSD: log.h,v 1.4 2001/06/26 17:27:24 markus Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -28,7 +28,8 @@ typedef enum {
|
|||
SYSLOG_FACILITY_LOCAL4,
|
||||
SYSLOG_FACILITY_LOCAL5,
|
||||
SYSLOG_FACILITY_LOCAL6,
|
||||
SYSLOG_FACILITY_LOCAL7
|
||||
SYSLOG_FACILITY_LOCAL7,
|
||||
SYSLOG_FACILITY_NOT_SET = -1,
|
||||
} SyslogFacility;
|
||||
|
||||
typedef enum {
|
||||
|
@ -39,7 +40,8 @@ typedef enum {
|
|||
SYSLOG_LEVEL_VERBOSE,
|
||||
SYSLOG_LEVEL_DEBUG1,
|
||||
SYSLOG_LEVEL_DEBUG2,
|
||||
SYSLOG_LEVEL_DEBUG3
|
||||
SYSLOG_LEVEL_DEBUG3,
|
||||
SYSLOG_LEVEL_NOT_SET = -1,
|
||||
} LogLevel;
|
||||
|
||||
void log_init(char *, LogLevel, SyslogFacility, int);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: readconf.c,v 1.13 2001/11/27 04:10:24 itojun Exp $ */
|
||||
/* $NetBSD: readconf.c,v 1.14 2002/02/10 16:23:34 bjh21 Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
|
@ -592,10 +592,10 @@ parse_int:
|
|||
intptr = (int *) &options->log_level;
|
||||
arg = strdelim(&s);
|
||||
value = log_level_number(arg);
|
||||
if (value == (LogLevel) - 1)
|
||||
if (value == SYSLOG_LEVEL_NOT_SET)
|
||||
fatal("%.200s line %d: unsupported log level '%s'",
|
||||
filename, linenum, arg ? arg : "<NONE>");
|
||||
if (*activep && (LogLevel) * intptr == -1)
|
||||
if (*activep && (LogLevel) *intptr == SYSLOG_LEVEL_NOT_SET)
|
||||
*intptr = (LogLevel) value;
|
||||
break;
|
||||
|
||||
|
@ -795,7 +795,7 @@ initialize_options(Options * options)
|
|||
options->num_local_forwards = 0;
|
||||
options->num_remote_forwards = 0;
|
||||
options->clear_forwardings = -1;
|
||||
options->log_level = (LogLevel) - 1;
|
||||
options->log_level = SYSLOG_LEVEL_NOT_SET;
|
||||
options->preferred_authentications = NULL;
|
||||
options->bind_address = NULL;
|
||||
options->smartcard_device = NULL;
|
||||
|
@ -914,7 +914,7 @@ fill_default_options(Options * options)
|
|||
options->system_hostfile2 = _PATH_SSH_SYSTEM_HOSTFILE2;
|
||||
if (options->user_hostfile2 == NULL)
|
||||
options->user_hostfile2 = _PATH_SSH_USER_HOSTFILE2;
|
||||
if (options->log_level == (LogLevel) - 1)
|
||||
if (options->log_level == SYSLOG_LEVEL_NOT_SET)
|
||||
options->log_level = SYSLOG_LEVEL_INFO;
|
||||
if (options->clear_forwardings == 1)
|
||||
clear_forwardings(options);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: servconf.c,v 1.14 2001/12/06 03:54:05 itojun Exp $ */
|
||||
/* $NetBSD: servconf.c,v 1.15 2002/02/10 16:23:34 bjh21 Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
* All rights reserved
|
||||
|
@ -63,8 +63,8 @@ initialize_server_options(ServerOptions *options)
|
|||
options->xauth_location = NULL;
|
||||
options->strict_modes = -1;
|
||||
options->keepalives = -1;
|
||||
options->log_facility = (SyslogFacility) - 1;
|
||||
options->log_level = (LogLevel) - 1;
|
||||
options->log_facility = SYSLOG_FACILITY_NOT_SET;
|
||||
options->log_level = SYSLOG_LEVEL_NOT_SET;
|
||||
options->rhosts_authentication = -1;
|
||||
options->rhosts_rsa_authentication = -1;
|
||||
options->hostbased_authentication = -1;
|
||||
|
@ -156,9 +156,9 @@ fill_default_server_options(ServerOptions *options)
|
|||
options->strict_modes = 1;
|
||||
if (options->keepalives == -1)
|
||||
options->keepalives = 1;
|
||||
if (options->log_facility == (SyslogFacility) (-1))
|
||||
if (options->log_facility == SYSLOG_FACILITY_NOT_SET)
|
||||
options->log_facility = SYSLOG_FACILITY_AUTH;
|
||||
if (options->log_level == (LogLevel) (-1))
|
||||
if (options->log_level == SYSLOG_LEVEL_NOT_SET)
|
||||
options->log_level = SYSLOG_LEVEL_INFO;
|
||||
if (options->rhosts_authentication == -1)
|
||||
options->rhosts_authentication = 0;
|
||||
|
@ -685,7 +685,7 @@ parse_flag:
|
|||
intptr = (int *) &options->log_facility;
|
||||
arg = strdelim(&cp);
|
||||
value = log_facility_number(arg);
|
||||
if (value == (SyslogFacility) - 1)
|
||||
if (value == SYSLOG_FACILITY_NOT_SET)
|
||||
fatal("%.200s line %d: unsupported log facility '%s'",
|
||||
filename, linenum, arg ? arg : "<NONE>");
|
||||
if (*intptr == -1)
|
||||
|
@ -696,7 +696,7 @@ parse_flag:
|
|||
intptr = (int *) &options->log_level;
|
||||
arg = strdelim(&cp);
|
||||
value = log_level_number(arg);
|
||||
if (value == (LogLevel) - 1)
|
||||
if (value == SYSLOG_LEVEL_NOT_SET)
|
||||
fatal("%.200s line %d: unsupported log level '%s'",
|
||||
filename, linenum, arg ? arg : "<NONE>");
|
||||
if (*intptr == -1)
|
||||
|
|
Loading…
Reference in New Issue