diff options
| author | Roy Marples <roy@marples.name> | 2007-04-25 15:48:54 +0000 | 
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2007-04-25 15:48:54 +0000 | 
| commit | 8e7868d80f4f45bd360765fc32780293231db831 (patch) | |
| tree | f06dbd78bc32b7919a6d2a513d2ec7423050a9b6 | |
| parent | 6ba6f0403f953d14653e69b5528b2ffe68e2c30e (diff) | |
| download | openrc-8e7868d80f4f45bd360765fc32780293231db831.tar.xz | |
Don't pass $CONSOLE to sulogin and split rc_environ_fd on NULLs
| -rw-r--r-- | src/rc-plugin.c | 21 | ||||
| -rw-r--r-- | src/rc.c | 6 | 
2 files changed, 14 insertions, 13 deletions
| diff --git a/src/rc-plugin.c b/src/rc-plugin.c index aca20239..2d3d7072 100644 --- a/src/rc-plugin.c +++ b/src/rc-plugin.c @@ -132,20 +132,23 @@ void rc_plugin_run (rc_hook_t hook, const char *value)  				char buffer[RC_LINEBUFFER];  				char *token;  				char *p; +				ssize_t nr;  				close (pfd[1]);  				memset (buffer, 0, sizeof (buffer)); -				/* Not the best implementation in the world. -				 * We should be able to handle >1 env var. -				 * Maybe split the strings with a NULL character? */ -				while (read (pfd[0], buffer, sizeof (buffer)) > 0) { +				while ((nr = read (pfd[0], buffer, sizeof (buffer))) > 0) {  					p = buffer; -					token = strsep (&p, "="); -					if (token) { -						unsetenv (token); -						if (p) -							setenv (token, p, 1); +					while (*p && p - buffer < nr) { +						token = strsep (&p, "="); +						if (token) { +							unsetenv (token); +							if (*p) { +								setenv (token, p, 1); +								p += strlen (p) + 1; +							} else +								p++; +						}  					}  				} @@ -398,8 +398,7 @@ static void sulogin (bool cont)  			eerrorx ("%s: vfork: %s", applet, strerror (errno));  		if (pid == 0) {  #ifdef __linux__ -			execle ("/sbin/sulogin", "/sbin/sulogin", -					getenv ("CONSOLE"), (char *) NULL, newenv); +			execle ("/sbin/sulogin", "/sbin/sulogin", (char *) NULL, newenv);  			eerror ("%s: unable to exec `/sbin/sulogin': %s", applet,  					strerror (errno));  #else @@ -412,8 +411,7 @@ static void sulogin (bool cont)  		waitpid (pid, &status, 0);  	} else {  #ifdef __linux -		execle ("/sbin/sulogin", "/sbin/sulogin", -				getenv ("CONSOLE"), (char *) NULL, newenv); +		execle ("/sbin/sulogin", "/sbin/sulogin", (char *) NULL, newenv);  		eerrorx ("%s: unable to exec `/sbin/sulogin': %s", applet, strerror (errno));  #else  		exit (EXIT_SUCCESS); | 
