upstream commit

Add SyslogFacility option to ssh(1) matching the
equivalent option in sshd(8).  bz#2705, patch from erahn at arista.com, ok
djm@

Upstream-ID: d5115c2c0193ceb056ed857813b2a7222abda9ed
This commit is contained in:
dtucker@openbsd.org 2017-04-28 03:20:27 +00:00 committed by Damien Miller
parent e13aad66e7
commit 68d3a2a059
4 changed files with 35 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: readconf.c,v 1.270 2017/03/10 04:27:32 djm Exp $ */ /* $OpenBSD: readconf.c,v 1.271 2017/04/28 03:20:27 dtucker Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -152,7 +152,7 @@ typedef enum {
oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts, oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts,
oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression, oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression,
oCompressionLevel, oTCPKeepAlive, oNumberOfPasswordPrompts, oCompressionLevel, oTCPKeepAlive, oNumberOfPasswordPrompts,
oUsePrivilegedPort, oLogLevel, oCiphers, oProtocol, oMacs, oUsePrivilegedPort, oLogFacility, oLogLevel, oCiphers, oProtocol, oMacs,
oPubkeyAuthentication, oPubkeyAuthentication,
oKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias, oKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias,
oDynamicForward, oPreferredAuthentications, oHostbasedAuthentication, oDynamicForward, oPreferredAuthentications, oHostbasedAuthentication,
@ -265,6 +265,7 @@ static struct {
{ "tcpkeepalive", oTCPKeepAlive }, { "tcpkeepalive", oTCPKeepAlive },
{ "keepalive", oTCPKeepAlive }, /* obsolete */ { "keepalive", oTCPKeepAlive }, /* obsolete */
{ "numberofpasswordprompts", oNumberOfPasswordPrompts }, { "numberofpasswordprompts", oNumberOfPasswordPrompts },
{ "syslogfacility", oLogFacility },
{ "loglevel", oLogLevel }, { "loglevel", oLogLevel },
{ "dynamicforward", oDynamicForward }, { "dynamicforward", oDynamicForward },
{ "preferredauthentications", oPreferredAuthentications }, { "preferredauthentications", oPreferredAuthentications },
@ -830,6 +831,7 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
u_int i, *uintptr, max_entries = 0; u_int i, *uintptr, max_entries = 0;
int r, oactive, negated, opcode, *intptr, value, value2, cmdline = 0; int r, oactive, negated, opcode, *intptr, value, value2, cmdline = 0;
LogLevel *log_level_ptr; LogLevel *log_level_ptr;
SyslogFacility *log_facility_ptr;
long long val64; long long val64;
size_t len; size_t len;
struct Forward fwd; struct Forward fwd;
@ -1264,6 +1266,17 @@ parse_keytypes:
*log_level_ptr = (LogLevel) value; *log_level_ptr = (LogLevel) value;
break; break;
case oLogFacility:
log_facility_ptr = &options->log_facility;
arg = strdelim(&s);
value = log_facility_number(arg);
if (value == SYSLOG_FACILITY_NOT_SET)
fatal("%.200s line %d: unsupported log facility '%s'",
filename, linenum, arg ? arg : "<NONE>");
if (*log_facility_ptr == -1)
*log_facility_ptr = (SyslogFacility) value;
break;
case oLocalForward: case oLocalForward:
case oRemoteForward: case oRemoteForward:
case oDynamicForward: case oDynamicForward:
@ -1838,6 +1851,7 @@ initialize_options(Options * options)
options->num_local_forwards = 0; options->num_local_forwards = 0;
options->remote_forwards = NULL; options->remote_forwards = NULL;
options->num_remote_forwards = 0; options->num_remote_forwards = 0;
options->log_facility = SYSLOG_FACILITY_NOT_SET;
options->log_level = SYSLOG_LEVEL_NOT_SET; options->log_level = SYSLOG_LEVEL_NOT_SET;
options->preferred_authentications = NULL; options->preferred_authentications = NULL;
options->bind_address = NULL; options->bind_address = NULL;
@ -2014,6 +2028,8 @@ fill_default_options(Options * options)
} }
if (options->log_level == SYSLOG_LEVEL_NOT_SET) if (options->log_level == SYSLOG_LEVEL_NOT_SET)
options->log_level = SYSLOG_LEVEL_INFO; options->log_level = SYSLOG_LEVEL_INFO;
if (options->log_facility == SYSLOG_FACILITY_NOT_SET)
options->log_facility = SYSLOG_FACILITY_USER;
if (options->no_host_authentication_for_localhost == - 1) if (options->no_host_authentication_for_localhost == - 1)
options->no_host_authentication_for_localhost = 0; options->no_host_authentication_for_localhost = 0;
if (options->identities_only == -1) if (options->identities_only == -1)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: readconf.h,v 1.117 2016/07/15 00:24:30 djm Exp $ */ /* $OpenBSD: readconf.h,v 1.118 2017/04/28 03:20:27 dtucker Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
@ -59,6 +59,7 @@ typedef struct {
int tcp_keep_alive; /* Set SO_KEEPALIVE. */ int tcp_keep_alive; /* Set SO_KEEPALIVE. */
int ip_qos_interactive; /* IP ToS/DSCP/class for interactive */ int ip_qos_interactive; /* IP ToS/DSCP/class for interactive */
int ip_qos_bulk; /* IP ToS/DSCP/class for bulk traffic */ int ip_qos_bulk; /* IP ToS/DSCP/class for bulk traffic */
SyslogFacility log_facility; /* Facility for system logging. */
LogLevel log_level; /* Level for logging. */ LogLevel log_level; /* Level for logging. */
int port; /* Port to connect. */ int port; /* Port to connect. */

11
ssh.c
View File

@ -1,4 +1,4 @@
/* $OpenBSD: ssh.c,v 1.451 2017/03/10 04:07:20 djm Exp $ */ /* $OpenBSD: ssh.c,v 1.452 2017/04/28 03:20:27 dtucker Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -1007,8 +1007,11 @@ main(int ac, char **av)
if (logfile != NULL) if (logfile != NULL)
log_redirect_stderr_to(logfile); log_redirect_stderr_to(logfile);
log_init(argv0, log_init(argv0,
options.log_level == -1 ? SYSLOG_LEVEL_INFO : options.log_level, options.log_level == SYSLOG_LEVEL_NOT_SET ?
SYSLOG_FACILITY_USER, !use_syslog); SYSLOG_LEVEL_INFO : options.log_level,
options.log_facility == SYSLOG_FACILITY_NOT_SET ?
SYSLOG_FACILITY_USER : options.log_facility,
!use_syslog);
if (debug_flag) if (debug_flag)
logit("%s, %s", SSH_RELEASE, logit("%s, %s", SSH_RELEASE,
@ -1150,7 +1153,7 @@ main(int ac, char **av)
#endif #endif
/* reinit */ /* reinit */
log_init(argv0, options.log_level, SYSLOG_FACILITY_USER, !use_syslog); log_init(argv0, options.log_level, options.log_facility, !use_syslog);
if (options.request_tty == REQUEST_TTY_YES || if (options.request_tty == REQUEST_TTY_YES ||
options.request_tty == REQUEST_TTY_FORCE) options.request_tty == REQUEST_TTY_FORCE)

View File

@ -33,8 +33,8 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: ssh_config.5,v 1.242 2017/02/27 14:30:33 jmc Exp $ .\" $OpenBSD: ssh_config.5,v 1.243 2017/04/28 03:20:27 dtucker Exp $
.Dd $Mdocdate: February 27 2017 $ .Dd $Mdocdate: April 28 2017 $
.Dt SSH_CONFIG 5 .Dt SSH_CONFIG 5
.Os .Os
.Sh NAME .Sh NAME
@ -1101,6 +1101,12 @@ indicates that the listening port be bound for local use only, while an
empty address or empty address or
.Sq * .Sq *
indicates that the port should be available from all interfaces. indicates that the port should be available from all interfaces.
.It Cm SyslogFacility
Gives the facility code that is used when logging messages from
.Xr ssh 1 .
The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2,
LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
The default is USER.
.It Cm LogLevel .It Cm LogLevel
Gives the verbosity level that is used when logging messages from Gives the verbosity level that is used when logging messages from
.Xr ssh 1 . .Xr ssh 1 .