Skip to content
Snippets Groups Projects
Commit 685b582e authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

remove foreground option

parent 68b7b47f
No related branches found
No related tags found
No related merge requests found
......@@ -264,7 +264,7 @@ extern char const *help_halt ;
#define OPTS_SCANDIR_WRAPPER "ho:"
#define OPTS_SCANCTL_WRAPPER_LEN (sizeof OPTS_SCANDIR_WRAPPER - 1)
#define OPTS_SCANDIR_SIGNAL "d:s:e:bBf"
#define OPTS_SCANDIR_SIGNAL "d:s:e:bB"
#define OPTS_SCANDIR_SIGNAL_LEN (sizeof OPTS_SCANDIR_SIGNAL - 1)
#define OPTS_SCANDIR_CREATE "bBs:cL:"
#define OPTS_SCANDIR_CREATE_LEN (sizeof OPTS_SCANDIR_CREATE - 1)
......
......@@ -512,7 +512,7 @@ char const *help_scandir_remove =
" -h: print this help\n"
;
char const *usage_scandir_start = "66 scandir start [ -h ] [ -d notif ] [ -s rescan ] [ -e environment ] [ -b|B ] [ -f ]" ;
char const *usage_scandir_start = "66 scandir start [ -h ] [ -d notif ] [ -s rescan ] [ -e environment ] [ -b|B ]" ;
char const *help_scandir_start =
"\nstart a scandir\n"
......@@ -524,7 +524,6 @@ char const *help_scandir_start =
" -e: use environment as environment directory\n"
" -b: create scandir (if it not exist yet) for a boot process\n"
" -B: create scandir (if it not exist yet) for a boot process inside a container\n"
" -f: fork and become a daemon"
;
char const *usage_scandir_stop = "66 scandir stop [ -h ]" ;
......
......@@ -168,7 +168,7 @@ static int send_signal(char const *scandir, char const *signal)
return svc_scandir_send(scandir,csig) ;
}
static void scandir_up(char const *scandir, unsigned int timeout, unsigned int notif, unsigned int foreground, char const *const *envp, ssexec_t *info)
static void scandir_up(char const *scandir, unsigned int timeout, unsigned int notif, char const *const *envp, ssexec_t *info)
{
uid_t uid = getuid() ;
gid_t gid = getgid() ;
......@@ -191,88 +191,6 @@ static void scandir_up(char const *scandir, unsigned int timeout, unsigned int n
newup[m++] = scandir ;
newup[m++] = 0 ;
if (!foreground && info->owner) {
int fd ;
char *target = "/dev/null" ;
char home[SS_MAX_PATH_LEN + 1] ;
gid_t gid = -1 ;
if (!yourgid(&gid, info->owner))
log_dieusys(LOG_EXIT_SYS, "get gid") ;
if (!set_ownerhome_stack_byuid(home, info->owner))
log_dieusys(LOG_EXIT_SYS,"set home directory") ;
size_t homelen = strlen(home), loglen = strlen(SS_LOGGER_USERDIR) ;
char file[homelen + loglen + 1 + SS_SCANDIR_LEN + 1 + SS_TREE_CURRENT_LEN + 1] ;
auto_strings(file, home, SS_LOGGER_USERDIR, "/", SS_SCANDIR) ;
if (!dir_create_parent(file, 755))
log_dieusys(LOG_EXIT_SYS, "create directory: ", file) ;
file[homelen + loglen + 1] = 0 ;
if (chown(file, info->owner, gid) < 0)
log_dieusys(LOG_EXIT_SYS, "chown: ", file) ;
if (chmod(file, 0755) < 0)
log_dieusys(LOG_EXIT_SYS,"chmod: ", file) ;
auto_strings(file + homelen + loglen + 1, SS_SCANDIR) ;
if (chown(file, info->owner, gid) < 0)
log_dieusys(LOG_EXIT_SYS, "chown: ", file) ;
if (chmod(file, 0755) < 0)
log_dieusys(LOG_EXIT_SYS,"chmod: ", file) ;
auto_strings(file + homelen + loglen + 1 + SS_SCANDIR_LEN, "/", SS_TREE_CURRENT) ;
pid_t pid = fork() ;
if (pid < 0)
log_dieusys(LOG_EXIT_SYS, "fork") ;
else if (pid)
_exit(0) ;
if (setsid() < 0)
log_dieusys(LOG_EXIT_SYS, "setsid") ;
pid = fork() ;
if (pid < 0)
log_dieusys(LOG_EXIT_SYS, "fork") ;
else if (pid)
_exit(0) ;
if ((chdir("/")) < 0)
log_dieusys(LOG_EXIT_SYS,"chdir") ;
fd = open(target,O_RDONLY) ;
if (fd < 0)
log_dieusys(LOG_EXIT_SYS, "open ",target) ;
if (dup2(fd, 0) < 0)
log_dieusys(LOG_EXIT_SYS, "copy stdin to ", target) ;
close(fd) ;
fd = open(file, O_WRONLY|O_NONBLOCK|O_CREAT|O_APPEND, 0700) ;
if (fd < 0)
log_dieusys(LOG_EXIT_SYS, "open file: ", file) ;
if (dup2(fd, 1) < 0)
log_dieusys(LOG_EXIT_SYS, "copy stdout to: ", file) ;
close(fd) ;
if (dup2(1, 2) < 0)
log_dieusys(LOG_EXIT_SYS, "copy stderr to stdout") ;
if (chown(file, info->owner, gid) < 0)
log_dieusys(LOG_EXIT_SYS, "chown: ", file) ;
}
if (!uid && uid != info->owner) {
/** -o <owner> was asked. Respect it
* a start the s6-svscan process with the
......@@ -297,7 +215,7 @@ int ssexec_scandir_signal(int argc, char const *const *argv, ssexec_t *info)
int r ;
unsigned int timeout = 0, notif = 0, sig = 0, container = 0, boot = 0, foreground = 0 ;
unsigned int timeout = 0, notif = 0, sig = 0, container = 0, boot = 0 ;
char const *newenv[MAXENV+1] ;
char const *const *genv = 0 ;
......@@ -355,12 +273,6 @@ int ssexec_scandir_signal(int argc, char const *const *argv, ssexec_t *info)
break ;
case 'f' :
foreground = 1 ;
break ;
default :
log_usage(info->usage, "\n", info->help) ;
......@@ -439,7 +351,7 @@ int ssexec_scandir_signal(int argc, char const *const *argv, ssexec_t *info)
return 0 ;
}
scandir_up(scandir, timeout, notif, foreground, genv, info) ;
scandir_up(scandir, timeout, notif, genv, info) ;
}
r = svc_scandir_ok(info->scandir.s) ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment