Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153498767
D20983.id59869.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D20983.id59869.diff
View Options
Index: usr.sbin/daemon/daemon.8
===================================================================
--- usr.sbin/daemon/daemon.8
+++ usr.sbin/daemon/daemon.8
@@ -44,6 +44,7 @@
.Op Fl s Ar syslog_priority
.Op Fl T Ar syslog_tag
.Op Fl l Ar syslog_facility
+.Op Fl M Ar umask
.Op Fl R Ar restart_delay_seconds
.Ar command arguments ...
.Sh DESCRIPTION
@@ -117,6 +118,8 @@
.It Fl r
Supervise and restart the program after a one-second delay if it has
been terminated.
+.It Fl M Ar umask
+Set umask before starting child process.
.It Fl R Ar restart_delay_seconds
Supervise and restart the program after the specified delay
if it has been terminated.
Index: usr.sbin/daemon/daemon.c
===================================================================
--- usr.sbin/daemon/daemon.c
+++ usr.sbin/daemon/daemon.c
@@ -35,6 +35,7 @@
#include <sys/param.h>
#include <sys/mman.h>
+#include <sys/stat.h>
#include <sys/wait.h>
#include <fcntl.h>
@@ -84,7 +85,7 @@
sigset_t mask_susp, mask_orig, mask_read, mask_term;
struct log_params logpar;
int pfd[2] = { -1, -1 }, outfd = -1;
- int stdmask, logpri, logfac;
+ int stdmask, logpri, logfac, mask;
struct pidfh *ppfh, *pfh;
char *p;
@@ -99,8 +100,29 @@
dosyslog = 0;
outfn = NULL;
title = NULL;
- while ((ch = getopt(argc, argv, "cfSp:P:ru:o:s:l:t:l:m:R:T:")) != -1) {
+ mask = -1;
+ while ((ch = getopt(argc, argv, "M:P:R:ST:cfl:m:o:p:rs:t:u:")) != -1) {
switch (ch) {
+ case 'M':
+ mask = strtol(optarg, &p, 0);
+ if (p == optarg || mask < 0 || mask > 0777)
+ errx(6, "unrecognized umask");
+ break;
+ case 'P':
+ ppidfile = optarg;
+ break;
+ case 'R':
+ restart = strtol(optarg, &p, 0);
+ if (p == optarg || restart < 1)
+ errx(6, "invalid restart delay");
+ break;
+ case 'S':
+ dosyslog = 1;
+ break;
+ case 'T':
+ logtag = optarg;
+ dosyslog = 1;
+ break;
case 'c':
nochdir = 0;
break;
@@ -124,33 +146,18 @@
case 'p':
pidfile = optarg;
break;
- case 'P':
- ppidfile = optarg;
- break;
case 'r':
restart = 1;
break;
- case 'R':
- restart = strtol(optarg, &p, 0);
- if (p == optarg || restart < 1)
- errx(6, "invalid restart delay");
- break;
case 's':
logpri = get_log_mapping(optarg, prioritynames);
if (logpri == -1)
errx(4, "unrecognized syslog priority");
dosyslog = 1;
break;
- case 'S':
- dosyslog = 1;
- break;
case 't':
title = optarg;
break;
- case 'T':
- logtag = optarg;
- dosyslog = 1;
- break;
case 'u':
user = optarg;
break;
@@ -301,6 +308,9 @@
pfd[1] != STDOUT_FILENO)
close(pfd[1]);
}
+ /* Set umask if requested */
+ if (mask > 0)
+ umask(mask);
execvp(argv[0], argv);
/*
* execvp() failed -- report the error. The child is
@@ -566,6 +576,7 @@
" [-u user] [-o output_file] [-t title]\n"
" [-l syslog_facility] [-s syslog_priority]\n"
" [-T syslog_tag] [-m output_mask] [-R restart_delay_secs]\n"
+ " [-M umask]\n"
"command arguments ...\n");
exit(1);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 22, 11:44 AM (10 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31976267
Default Alt Text
D20983.id59869.diff (3 KB)
Attached To
Mode
D20983: Sort & dedupe getopt flags for daemon
Attached
Detach File
Event Timeline
Log In to Comment