aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaatu <[email protected]>2016-05-02 16:02:00 +1200
committerKlaatu <[email protected]>2016-05-02 16:02:00 +1200
commit614c5f64e01c6f820319e951177549f61b82d62b (patch)
tree77b9e08eca04563c6d543c0f6f5d8309dcc2bcd2
parent86f0721bd904d8163c5f8f2472b78169146cc67d (diff)
some improvements kindly made available from gitlab.com/ShadowKyogre/ninitHEADmaster
-rw-r--r--man/nsvc.87
-rw-r--r--nsvc.c10
-rw-r--r--shutdown.c5
3 files changed, 15 insertions, 7 deletions
diff --git a/man/nsvc.8 b/man/nsvc.8
index 3ac0900..f9385d9 100644
--- a/man/nsvc.8
+++ b/man/nsvc.8
@@ -230,9 +230,12 @@ if it is down or 3 if it is finished.
.SH "ENVIRON"
.B nsvc
uses the variables
-.B NINIT_MEMORY
+.B NINIT_MEMORY
+,
+.B NINIT_HOME
+,
and
-.B NINIT_HOME.
+.B NINIT_SYSDIR
.SH "SEE ALSO"
ninit(8), ninit-scan(8)
diff --git a/nsvc.c b/nsvc.c
index 7a89255..c187978 100644
--- a/nsvc.c
+++ b/nsvc.c
@@ -12,7 +12,7 @@
extern int ioctl();
-static char **Names_skip, **NamesX, *buf, *initroot, *nsvc_other, respmode;
+static char **Names_skip, **NamesX, *buf, *initroot, *initsysdir, *nsvc_other, respmode;
static int NamesI, do_update, tty = -111;
static void e(int n) { buffer_flush(buffer_1); _exit(n); }
@@ -247,6 +247,7 @@ int main(int argc,char *argv[]) {
errmsg_iam("nsvc");
infd = -1; outfd = -1;
INIT_ENV_GET_HOME(initroot,"NINIT_HOME","INIT_HOME");
+ INIT_ENV_GET_HOME(initsysdir,"NINIT_SYSDIR","INIT_SYSDIR");
Names_skip = alloca(argc * sizeof(char *));
for (skp=Names_skip; (x=argv[1]); argv++) {
@@ -259,6 +260,7 @@ int main(int argc,char *argv[]) {
int uid=getuid(), euid=geteuid();
if (initroot && (uid != euid)) { ops: die_xx("\ago away!"); }
if (initroot==0) initroot=INITROOT;
+ if (initsysdir==0) initsysdir=INITSYSDIR;
if (argv[1] == 0) { setuid(uid); goto REMOVE; }
open_inout(initroot);
@@ -300,7 +302,7 @@ int main(int argc,char *argv[]) {
ret=fmt_service(i,0);
if (i >= 0 && tty && root[i].pid > 1) {
- INIT_ARGS2(argv, "./sys/procfs", fu(root[i].pid));
+ INIT_ARGS2(argv, "./procfs", fu(root[i].pid));
goto PROCFS;
}
} else {
@@ -323,11 +325,11 @@ int main(int argc,char *argv[]) {
case 'E':
case 'Z':
REMOVE:
- argv[0] = "./sys/remove"; /* XXX: make sys as environ! */
+ argv[0] = "./remove"; /* ~~XXX: make sys as environ!~~ */
PROCFS:
close_inout();
buffer_flush(buffer_1);
- ret = chdir(initroot);
+ ret = chdir(initsysdir);
if (!ret) ret=execve(argv[0], argv, environ);
break;
default:
diff --git a/shutdown.c b/shutdown.c
index 520acdb..513e4e9 100644
--- a/shutdown.c
+++ b/shutdown.c
@@ -40,13 +40,16 @@ static void exec_cmd(char *cmd, ...) {
const char *s;
va_list a;
pid_t pid;
+ int count_args = 0;
*arg++ = cmd;
+ count_args++;
va_start(a,cmd);
do {
s=va_arg(a,const char*);
*arg++ = (char *)s;
- } while (s);
+ count_args++;
+ } while (s && count_args < 25);
while ((pid = fork()) < 0) nano_sleep(0,500000000);
if (pid == 0) {