Don't pass $CONSOLE to sulogin and split rc_environ_fd on NULLs

This commit is contained in:
Roy Marples 2007-04-25 15:48:54 +00:00
parent 6ba6f0403f
commit 8e7868d80f
2 changed files with 14 additions and 13 deletions

View File

@ -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++;
}
}
}

View File

@ -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);