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 buffer[RC_LINEBUFFER];
char *token; char *token;
char *p; char *p;
ssize_t nr;
close (pfd[1]); close (pfd[1]);
memset (buffer, 0, sizeof (buffer)); memset (buffer, 0, sizeof (buffer));
/* Not the best implementation in the world. while ((nr = read (pfd[0], buffer, sizeof (buffer))) > 0) {
* 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) {
p = buffer; p = buffer;
while (*p && p - buffer < nr) {
token = strsep (&p, "="); token = strsep (&p, "=");
if (token) { if (token) {
unsetenv (token); unsetenv (token);
if (p) if (*p) {
setenv (token, p, 1); 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)); eerrorx ("%s: vfork: %s", applet, strerror (errno));
if (pid == 0) { if (pid == 0) {
#ifdef __linux__ #ifdef __linux__
execle ("/sbin/sulogin", "/sbin/sulogin", execle ("/sbin/sulogin", "/sbin/sulogin", (char *) NULL, newenv);
getenv ("CONSOLE"), (char *) NULL, newenv);
eerror ("%s: unable to exec `/sbin/sulogin': %s", applet, eerror ("%s: unable to exec `/sbin/sulogin': %s", applet,
strerror (errno)); strerror (errno));
#else #else
@ -412,8 +411,7 @@ static void sulogin (bool cont)
waitpid (pid, &status, 0); waitpid (pid, &status, 0);
} else { } else {
#ifdef __linux #ifdef __linux
execle ("/sbin/sulogin", "/sbin/sulogin", execle ("/sbin/sulogin", "/sbin/sulogin", (char *) NULL, newenv);
getenv ("CONSOLE"), (char *) NULL, newenv);
eerrorx ("%s: unable to exec `/sbin/sulogin': %s", applet, strerror (errno)); eerrorx ("%s: unable to exec `/sbin/sulogin': %s", applet, strerror (errno));
#else #else
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);