Page MenuHomeFreeBSD

D20969.id59803.diff
No OneTemporary

D20969.id59803.diff

Index: src/usr.sbin/daemon/daemon.8
===================================================================
--- src/usr.sbin/daemon/daemon.8
+++ src/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: src/usr.sbin/daemon/daemon.c
===================================================================
--- src/usr.sbin/daemon/daemon.c
+++ src/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,7 +100,8 @@
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, "cfSp:P:ru:o:s:l:t:l:m:M:R:T:")) != -1) {
switch (ch) {
case 'c':
nochdir = 0;
@@ -135,6 +137,11 @@
if (p == optarg || restart < 1)
errx(6, "invalid restart delay");
break;
+ case 'M':
+ mask = strtol(optarg, &p, 0);
+ if (p == optarg || mask < 0 || mask > 0777)
+ errx(6, "unrecognized umask");
+ break;
case 's':
logpri = get_log_mapping(optarg, prioritynames);
if (logpri == -1)
@@ -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
@@ -564,6 +574,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

Mime Type
text/plain
Expires
Tue, Apr 21, 7:33 PM (8 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31929358
Default Alt Text
D20969.id59803.diff (2 KB)

Event Timeline