diff options
-rw-r--r-- | man/start-stop-daemon.8 | 4 | ||||
-rw-r--r-- | src/includes/rc-misc.h | 1 | ||||
-rw-r--r-- | src/rc/checkpath.c | 22 | ||||
-rw-r--r-- | src/rc/rc-misc.c | 22 | ||||
-rw-r--r-- | src/rc/start-stop-daemon.c | 11 |
5 files changed, 36 insertions, 24 deletions
diff --git a/man/start-stop-daemon.8 b/man/start-stop-daemon.8 index 33a9ceeb..a4df24f1 100644 --- a/man/start-stop-daemon.8 +++ b/man/start-stop-daemon.8 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd Jul 08, 2008 +.Dd August 20, 2008 .Dt START-STOP-DAEMON 8 SMM .Os OpenRC .Sh NAME @@ -127,6 +127,8 @@ as the path to the daemon, chdir and pidfile, should be relative to the chroot. Set the environment variable VAR to VALUE. .It Fl g , -group Ar group Start the daemon as in the group. +.It Fl k , -umask Ar mode +Set the umask of the daemon. .It Fl m , -make-pidfile Saves the pid of the daemon in the file specified by the .Fl p , -pidfile diff --git a/src/includes/rc-misc.h b/src/includes/rc-misc.h index 4bdeb01f..91e15895 100644 --- a/src/includes/rc-misc.h +++ b/src/includes/rc-misc.h @@ -157,4 +157,5 @@ _unused static const char *basename_c(const char *path) return (path); } +int parse_mode(mode_t *, char *); #endif diff --git a/src/rc/checkpath.c b/src/rc/checkpath.c index 8726dca8..7ea94f09 100644 --- a/src/rc/checkpath.c +++ b/src/rc/checkpath.c @@ -106,28 +106,6 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode, int file) return 0; } -/* Based on busybox */ -static int parse_mode (mode_t *mode, char *text) -{ - char *p; - unsigned long l; - - /* Check for a numeric mode */ - if ((*text - '0') < 8) { - l = strtoul(text, &p, 8); - if (*p || l > 07777U) { - errno = EINVAL; - return -1; - } - *mode = (mode_t) l; - return 0; - } - - /* We currently don't check g+w type stuff */ - errno = EINVAL; - return -1; -} - static int parse_owner(struct passwd **user, struct group **group, const char *owner) { diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c index 191fa3d4..22e2e309 100644 --- a/src/rc/rc-misc.c +++ b/src/rc/rc-misc.c @@ -374,3 +374,25 @@ pid_t exec_service(const char *service, const char *arg) return pid; } + +int +parse_mode(mode_t *mode, char *text) +{ + char *p; + unsigned long l; + + /* Check for a numeric mode */ + if ((*text - '0') < 8) { + l = strtoul(text, &p, 8); + if (*p || l > 07777U) { + errno = EINVAL; + return -1; + } + *mode = (mode_t) l; + return 0; + } + + /* We currently don't check g+w type stuff */ + errno = EINVAL; + return -1; +} diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index 76f2b028..dfecd609 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -499,7 +499,7 @@ static void handle_signal(int sig) #include "_usage.h" -#define getoptstring "KN:R:Sbc:d:e:g:mn:op:s:tu:r:x:1:2:" getoptstring_COMMON +#define getoptstring "KN:R:Sbc:d:e:g:k:mn:op:s:tu:r:x:1:2:" getoptstring_COMMON static const struct option longopts[] = { { "stop", 0, NULL, 'K'}, { "nicelevel", 1, NULL, 'N'}, @@ -510,6 +510,7 @@ static const struct option longopts[] = { { "chuid", 1, NULL, 'c'}, { "chdir", 1, NULL, 'd'}, { "env", 1, NULL, 'e'}, + { "umask", 1, NULL, 'k'}, { "group", 1, NULL, 'g'}, { "make-pidfile", 0, NULL, 'm'}, { "name", 1, NULL, 'n'}, @@ -534,6 +535,7 @@ static const char * const longopts_help[] = { "deprecated, use --user", "Change the PWD", "Set an environment string", + "Set the umask for the daemon", "Change the process group", "Create a pidfile", "Match process name", @@ -601,6 +603,7 @@ int start_stop_daemon(int argc, char **argv) char line[130]; FILE *fp; size_t len; + mode_t numask; TAILQ_INIT(&schedule); atexit(cleanup); @@ -696,6 +699,12 @@ int start_stop_daemon(int argc, char **argv) } break; + case 'k': + if (parse_mode(&numask, optarg)) + eerrorx("%s: invalid mode `%s'", + applet, optarg); + break; + case 'm': /* --make-pidfile */ makepidfile = true; break; |