Add -f option to ftpd to stay in foreground with -D.

From nia in PR bin/53221.
This commit is contained in:
riastradh 2018-04-28 13:38:00 +00:00
parent 2489795f85
commit 7bc66ed4ff
2 changed files with 16 additions and 6 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ftpd.8,v 1.86 2017/07/03 21:35:48 wiz Exp $
.\" $NetBSD: ftpd.8,v 1.87 2018/04/28 13:38:00 riastradh Exp $
.\"
.\" Copyright (c) 1997-2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -65,7 +65,7 @@
Internet File Transfer Protocol server
.Sh SYNOPSIS
.Nm
.Op Fl 46DdHlnQqrsUuWwX
.Op Fl 46DdfHlnQqrsUuWwX
.Op Fl a Ar anondir
.Op Fl C Ar user Ns Op @ Ns Ar host
.Op Fl c Ar confdir
@ -154,6 +154,10 @@ for the
.Dq "\&%E"
escape sequence (see
.Sx Display file escape sequences )
.It Fl f
Stops the
.Fl D
flag from detaching from the tty and going into the background.
.It Fl H
Equivalent to
.Do

View File

@ -1,4 +1,4 @@
/* $NetBSD: ftpd.c,v 1.203 2016/07/19 21:25:38 shm Exp $ */
/* $NetBSD: ftpd.c,v 1.204 2018/04/28 13:38:00 riastradh Exp $ */
/*
* Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
@ -97,7 +97,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 1988, 1990, 1992, 1993, 1994\
#if 0
static char sccsid[] = "@(#)ftpd.c 8.5 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: ftpd.c,v 1.203 2016/07/19 21:25:38 shm Exp $");
__RCSID("$NetBSD: ftpd.c,v 1.204 2018/04/28 13:38:00 riastradh Exp $");
#endif
#endif /* not lint */
@ -177,6 +177,7 @@ static sig_atomic_t urgflag;
int data;
int Dflag;
int fflag;
int sflag;
int stru; /* avoid C keyword */
int mode;
@ -298,6 +299,7 @@ main(int argc, char *argv[])
logging = 0;
pdata = -1;
Dflag = 0;
fflag = 0;
sflag = 0;
dataport = 0;
dopidfile = 1; /* default: DO use a pid file to count users */
@ -323,7 +325,7 @@ main(int argc, char *argv[])
openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP);
while ((ch = getopt(argc, argv,
"46a:c:C:Dde:h:HlL:nP:qQrst:T:uUvV:wWX")) != -1) {
"46a:c:C:Dde:fh:HlL:nP:qQrst:T:uUvV:wWX")) != -1) {
switch (ch) {
case '4':
af = AF_INET;
@ -377,6 +379,10 @@ main(int argc, char *argv[])
emailaddr = optarg;
break;
case 'f':
fflag = 1;
break;
case 'h':
strlcpy(hostname, optarg, sizeof(hostname));
break;
@ -505,7 +511,7 @@ main(int argc, char *argv[])
struct pollfd *fds;
struct addrinfo hints, *res, *res0;
if (daemon(1, 0) == -1) {
if (!fflag && daemon(1, 0) == -1) {
syslog(LOG_ERR, "failed to daemonize: %m");
exit(1);
}