The branch main has been updated by crees (doc, ports committer):

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3c6366067036d4573528309a0a4d3b52e2a76ae7

commit 3c6366067036d4573528309a0a4d3b52e2a76ae7
Author:     Chris Rees <cr...@freebsd.org>
AuthorDate: 2021-04-03 17:51:56 +0000
Commit:     Chris Rees <cr...@freebsd.org>
CommitDate: 2021-04-15 11:34:01 +0000

    lpd: Add -F flag to prevent daemonizing
    
    This is necessary for use with supervision, e.g. runit.
    
    I chose -F simply because that is what the folks at LPRng use.
    
    Approved by:            pfg, gad, ngie
    Differential Revision:  https://reviews.freebsd.org/D29566
---
 usr.sbin/lpr/lpd/lpd.8 | 11 +++++++++++
 usr.sbin/lpr/lpd/lpd.c | 22 +++++++++++++++-------
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/usr.sbin/lpr/lpd/lpd.8 b/usr.sbin/lpr/lpd/lpd.8
index 2554aba2f834..c9607265ee6f 100644
--- a/usr.sbin/lpr/lpd/lpd.8
+++ b/usr.sbin/lpr/lpd/lpd.8
@@ -108,6 +108,17 @@ This means that
 will not accept any connections from any remote
 hosts, although it will still accept print requests
 from all local users.
+.It Fl F
+By default,
+.Nm
+will daemonize into the background.
+The
+.Fl F
+flag causes
+.Nm
+to remain in the foreground.
+Logging is still performed with
+.Xr syslog 3 .
 .It Fl W
 By default, the
 .Nm
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
index f2f8994d1fee..56821d114268 100644
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -104,6 +104,7 @@ __FBSDID("$FreeBSD$");
 
 int    lflag;                          /* log requests flag */
 int    sflag;                          /* no incoming port flag */
+int    Fflag;                          /* run in foreground flag */
 int    from_remote;                    /* from remote socket */
 
 int             main(int argc, char **_argv);
@@ -152,7 +153,7 @@ main(int argc, char **argv)
                errx(EX_NOPERM,"must run as root");
 
        errs = 0;
-       while ((i = getopt(argc, argv, "cdlpswW46")) != -1)
+       while ((i = getopt(argc, argv, "cdlpswFW46")) != -1)
                switch (i) {
                case 'c':
                        /* log all kinds of connection-errors to syslog */
@@ -184,6 +185,9 @@ main(int argc, char **argv)
                        syslog(LOG_WARNING,
                            "NOTE: please change your lpd config to use -W");
                        /* FALLTHROUGH */
+               case 'F':
+                       Fflag++;
+                       break;
                case 'W':
                        /* allow connections coming from a non-reserved port */
                        /* (done by some lpr-implementations for MS-Windows) */ 
@@ -264,12 +268,16 @@ main(int argc, char **argv)
                             WEXITSTATUS(status));
        }
 
-#ifndef DEBUG
+#ifdef DEBUG
+       Fflag++;
+#endif
        /*
-        * Set up standard environment by detaching from the parent.
+        * Set up standard environment by detaching from the parent
+        * if -F not specified
         */
-       daemon(0, 0);
-#endif
+       if (Fflag == 0) {
+               daemon(0, 0);
+       }
 
        openlog("lpd", LOG_PID, LOG_LPR);
        syslog(LOG_INFO, "lpd startup: logging=%d%s%s", lflag,
@@ -932,9 +940,9 @@ static void
 usage(void)
 {
 #ifdef INET6
-       fprintf(stderr, "usage: lpd [-cdlsW46] [port#]\n");
+       fprintf(stderr, "usage: lpd [-cdlsFW46] [port#]\n");
 #else
-       fprintf(stderr, "usage: lpd [-cdlsW] [port#]\n");
+       fprintf(stderr, "usage: lpd [-cdlsFW] [port#]\n");
 #endif
        exit(EX_USAGE);
 }
_______________________________________________
dev-commits-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"

Reply via email to