Add -k,--umask option, Gentoo #232455.
This commit is contained in:
parent
a9f7d2d5e5
commit
1ab1e9328a
@ -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
|
||||
|
@ -157,4 +157,5 @@ _unused static const char *basename_c(const char *path)
|
||||
return (path);
|
||||
}
|
||||
|
||||
int parse_mode(mode_t *, char *);
|
||||
#endif
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user