diff options
| author | Yaroslav Tykhiy <ytykhiy@gmail.com> | 2004-12-21 12:44:00 +0000 |
|---|---|---|
| committer | Yaroslav Tykhiy <ytykhiy@gmail.com> | 2004-12-21 12:44:00 +0000 |
| commit | eddc372d73562fc0535ce038e535bb297f76d966 (patch) | |
| tree | 9eeae8cf4a2ab09c8161728ed4fa0a40fd2c9aca /libexec | |
| parent | 8864ed5be27918034bd17e7c4156d0ed173d3f81 (diff) | |
Notes
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 814c85657de47..a0ae0ba3e038c 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -272,6 +272,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) { @@ -366,7 +379,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; @@ -384,7 +397,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; } } @@ -392,13 +405,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; |
