Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/ftpd Add -f option to ftpd to stay in f...



details:   https://anonhg.NetBSD.org/src/rev/5fcf2c028ac2
branches:  trunk
changeset: 318531:5fcf2c028ac2
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Apr 28 13:38:00 2018 +0000
description:
Add -f option to ftpd to stay in foreground with -D.

>From nia in PR bin/53221.

diffstat:

 libexec/ftpd/ftpd.8 |   8 ++++++--
 libexec/ftpd/ftpd.c |  14 ++++++++++----
 2 files changed, 16 insertions(+), 6 deletions(-)

diffs (92 lines):

diff -r a997fa7835f7 -r 5fcf2c028ac2 libexec/ftpd/ftpd.8
--- a/libexec/ftpd/ftpd.8       Sat Apr 28 13:26:57 2018 +0000
+++ b/libexec/ftpd/ftpd.8       Sat Apr 28 13:38:00 2018 +0000
@@ -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 @@
 .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
diff -r a997fa7835f7 -r 5fcf2c028ac2 libexec/ftpd/ftpd.c
--- a/libexec/ftpd/ftpd.c       Sat Apr 28 13:26:57 2018 +0000
+++ b/libexec/ftpd/ftpd.c       Sat Apr 28 13:38:00 2018 +0000
@@ -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 @@
 #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 @@
 
 int    data;
 int    Dflag;
+int    fflag;
 int    sflag;
 int    stru;                   /* avoid C keyword */
 int    mode;
@@ -298,6 +299,7 @@
        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 @@
        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 @@
                        emailaddr = optarg;
                        break;
 
+               case 'f':
+                       fflag = 1;
+                       break;
+
                case 'h':
                        strlcpy(hostname, optarg, sizeof(hostname));
                        break;
@@ -505,7 +511,7 @@
                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);
                }



Home | Main Index | Thread Index | Old Index