aboutsummaryrefslogtreecommitdiff
path: root/src/rc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rc')
-rw-r--r--src/rc/checkpath.c22
-rw-r--r--src/rc/rc-misc.c22
-rw-r--r--src/rc/start-stop-daemon.c11
3 files changed, 32 insertions, 23 deletions
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;