mirror of git://anongit.mindrot.org/openssh.git
upstream: allow log_stderr==2 to prefix log messages with argv[0]
use this to make scp's SFTP mode error messages more scp-like prompted by and ok deraadt@ OpenBSD-Commit-ID: 0e821dbde423fc2280e47414bdc22aaa5b4e0733
This commit is contained in:
parent
8a7a06ee50
commit
e694f8ac44
11
log.c
11
log.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: log.c,v 1.59 2021/05/07 04:11:51 djm Exp $ */
|
||||
/* $OpenBSD: log.c,v 1.60 2021/09/16 15:11:19 djm Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
|
@ -346,6 +346,7 @@ do_log(LogLevel level, int force, const char *suffix, const char *fmt,
|
|||
int pri = LOG_INFO;
|
||||
int saved_errno = errno;
|
||||
log_handler_fn *tmp_handler;
|
||||
const char *progname = argv0 != NULL ? argv0 : __progname;
|
||||
|
||||
if (!force && level > log_level)
|
||||
return;
|
||||
|
@ -403,16 +404,18 @@ do_log(LogLevel level, int force, const char *suffix, const char *fmt,
|
|||
tmp_handler(level, force, fmtbuf, log_handler_ctx);
|
||||
log_handler = tmp_handler;
|
||||
} else if (log_on_stderr) {
|
||||
snprintf(msgbuf, sizeof msgbuf, "%.*s\r\n",
|
||||
snprintf(msgbuf, sizeof msgbuf, "%s%s%.*s\r\n",
|
||||
(log_on_stderr > 1) ? progname : "",
|
||||
(log_on_stderr > 1) ? ": " : "",
|
||||
(int)sizeof msgbuf - 3, fmtbuf);
|
||||
(void)write(log_stderr_fd, msgbuf, strlen(msgbuf));
|
||||
} else {
|
||||
#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT)
|
||||
openlog_r(argv0 ? argv0 : __progname, LOG_PID, log_facility, &sdata);
|
||||
openlog_r(progname, LOG_PID, log_facility, &sdata);
|
||||
syslog_r(pri, &sdata, "%.500s", fmtbuf);
|
||||
closelog_r(&sdata);
|
||||
#else
|
||||
openlog(argv0 ? argv0 : __progname, LOG_PID, log_facility);
|
||||
openlog(progname, LOG_PID, log_facility);
|
||||
syslog(pri, "%.500s", fmtbuf);
|
||||
closelog();
|
||||
#endif
|
||||
|
|
12
scp.c
12
scp.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: scp.c,v 1.234 2021/09/11 00:40:24 djm Exp $ */
|
||||
/* $OpenBSD: scp.c,v 1.235 2021/09/16 15:11:19 djm Exp $ */
|
||||
/*
|
||||
* scp - secure remote copy. This is basically patched BSD rcp which
|
||||
* uses ssh to do the data transfer (instead of using rcmd).
|
||||
|
@ -467,7 +467,7 @@ main(int argc, char **argv)
|
|||
|
||||
__progname = ssh_get_progname(argv[0]);
|
||||
|
||||
log_init(argv0, log_level, SYSLOG_FACILITY_USER, 1);
|
||||
log_init(argv0, log_level, SYSLOG_FACILITY_USER, 2);
|
||||
|
||||
memset(&args, '\0', sizeof(args));
|
||||
memset(&remote_remote_args, '\0', sizeof(remote_remote_args));
|
||||
|
@ -588,7 +588,7 @@ main(int argc, char **argv)
|
|||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
log_init(argv0, log_level, SYSLOG_FACILITY_USER, 1);
|
||||
log_init(argv0, log_level, SYSLOG_FACILITY_USER, 2);
|
||||
|
||||
/* Do this last because we want the user to be able to override it */
|
||||
addargs(&args, "-oForwardAgent=no");
|
||||
|
@ -1540,11 +1540,9 @@ out:
|
|||
free(abs_src);
|
||||
free(tmp);
|
||||
globfree(&g);
|
||||
if (err == -1) {
|
||||
error("Failed to download '%s'", src);
|
||||
if (err == -1)
|
||||
errs = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define TYPE_OVERFLOW(type, val) \
|
||||
|
@ -1942,7 +1940,7 @@ out:
|
|||
free(tmp);
|
||||
globfree(&g);
|
||||
if (err == -1)
|
||||
fatal("Failed to download file '%s'", src);
|
||||
errs = 1;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in New Issue