diff options
author | Yaroslav Tykhiy <ytykhiy@gmail.com> | 2004-12-12 17:30:28 +0000 |
---|---|---|
committer | Yaroslav Tykhiy <ytykhiy@gmail.com> | 2004-12-12 17:30:28 +0000 |
commit | 6c98f401948b49d954ce9ca11c7a2cf00c3968af (patch) | |
tree | 27bf17cce16563d3aa6a7bdd9e30d1fbef61c398 /libexec | |
parent | e42ddbdf640c913eee2e249f483646e4d634e3fe (diff) | |
download | src-6c98f401948b49d954ce9ca11c7a2cf00c3968af.tar.gz src-6c98f401948b49d954ce9ca11c7a2cf00c3968af.zip |
Never emit a message to stderr: use syslog instead.
When in inetd mode, this prevents bogus messages from
appearing on the control channel. When running as a
daemon, we shouldn't write to the terminal we used to
have at all.
PR: bin/74823
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=138747
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/ftpd/ftpd.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 87aeb742f817..e686020f643c 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -273,6 +273,19 @@ main(int argc, char *argv[], char **envp) LastArgv = envp[-1] + strlen(envp[-1]); #endif /* OLD_SETPROCTITLE */ + /* + * Prevent diagnostic messages from appearing on stderr. + * We run as a daemon or from inetd; in both cases, there's + * more reason in logging to syslog. + */ + (void) freopen(_PATH_DEVNULL, "w", stderr); + opterr = 0; + + /* + * LOG_NDELAY sets up the logging connection immediately, + * necessary for anonymous ftp's that chroot and can't do it later. + */ + openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP); while ((ch = getopt(argc, argv, "46a:AdDEhlmMoOp:P:rRSt:T:u:UvW")) != -1) { @@ -367,7 +380,7 @@ main(int argc, char *argv[], char **envp) val = strtol(optarg, &optarg, 8); if (*optarg != '\0' || val < 0) - warnx("bad value for -u"); + syslog(LOG_WARNING, "bad value for -u"); else defumask = val; break; @@ -385,7 +398,7 @@ main(int argc, char *argv[], char **envp) break; default: - warnx("unknown flag -%c ignored", optopt); + syslog(LOG_WARNING, "unknown flag -%c ignored", optopt); break; } } @@ -393,13 +406,6 @@ main(int argc, char *argv[], char **envp) #ifdef VIRTUAL_HOSTING inithosts(); #endif - (void) freopen(_PATH_DEVNULL, "w", stderr); - - /* - * LOG_NDELAY sets up the logging connection immediately, - * necessary for anonymous ftp's that chroot and can't do it later. - */ - openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP); if (daemon_mode) { int *ctl_sock, fd, maxfd = -1, nfds, i; |