diff options
| author | Roy Marples <roy@marples.name> | 2008-09-22 12:14:47 +0000 | 
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2008-09-22 12:14:47 +0000 | 
| commit | 53693367dfb533cc515ea9751899c3612febc30d (patch) | |
| tree | 87caecddea41129dea9e81f267fc761bc7483516 /src/rc | |
| parent | 554d2fea19274c2c4c7483b2b93d78b6ae9cbde9 (diff) | |
| download | openrc-53693367dfb533cc515ea9751899c3612febc30d.tar.xz | |
Our match arguments could be different from the exec arguments, as only the kernel should set script arguments.
Diffstat (limited to 'src/rc')
| -rw-r--r-- | src/rc/start-stop-daemon.c | 25 | 
1 files changed, 13 insertions, 12 deletions
| diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c index 7e850abe..23ba2275 100644 --- a/src/rc/start-stop-daemon.c +++ b/src/rc/start-stop-daemon.c @@ -606,6 +606,7 @@ int start_stop_daemon(int argc, char **argv)  	size_t len;  	bool setumask = false;  	mode_t numask; +	char **margv;  	TAILQ_INIT(&schedule);  	atexit(cleanup); @@ -868,7 +869,7 @@ int start_stop_daemon(int argc, char **argv)  			if (line[0] == '#' && line[1] == '!') {  				p = line + 2;  				/* Strip leading spaces */ -				while (*p == ' ') +				while (*p == ' ' || *p == '\t')  					p++;  				/* Remove the trailing newline */  				len = strlen(p) - 1; @@ -876,29 +877,29 @@ int start_stop_daemon(int argc, char **argv)  					p[len] = '\0';  				token = strsep(&p, " ");  				strncpy(exec_file, token, sizeof(exec_file)); -				token = strsep(&p, " ");  				opt = 0;  				for (nav = argv; *nav; nav++)  					opt++; -				nav = xmalloc(sizeof(char *) * (opt + token ? 3 : 2)); +				nav = xmalloc(sizeof(char *) * (opt + 3));  				nav[0] = exec_file; -				if (token) -					nav[1] = token; +				len = 1; +				if (p) +					nav[len++] = p;  				for (i = 0; i < opt; i++) -					nav[i + token ? 2 : 1] = argv[i]; -				nav[i + token ? 2 : 1] = '\0'; -				argv = nav; -				exec = exec_file; +					nav[i + len] = argv[i]; +				nav[i + len] = '\0';  			}  		}  	} +	margv = nav ? nav : argv; +  	if (pidfile)  		pid = get_pid(pidfile, true);  	else  		pid = 0; -	if (do_stop(exec, (const char * const *)argv, pid, uid, +	if (do_stop(exec, (const char * const *)margv, pid, uid,  		    0, true, false, true) > 0)  		eerrorx("%s: %s is already running", applet, exec); @@ -1165,7 +1166,7 @@ int start_stop_daemon(int argc, char **argv)  						nloopsp = 0;  				} else  					pid = 0; -				if (do_stop(exec, (const char *const *)argv, +				if (do_stop(exec, (const char *const *)margv,  					    pid, uid, 0, true, false, true) > 0)  					alive = true;  			} @@ -1176,7 +1177,7 @@ int start_stop_daemon(int argc, char **argv)  	}  	if (svcname) -		rc_service_daemon_set(svcname, exec, (const char *const *)argv, +		rc_service_daemon_set(svcname, exec, (const char *const *)margv,  				      pidfile, true);  	exit(EXIT_SUCCESS); | 
