mirror of
https://github.com/sheumann/hush.git
synced 2024-12-22 14:30:31 +00:00
A patch from Andreas Neuhaus to be especially careful to not dup
any env variables when spawning child processes.
This commit is contained in:
parent
4aaefc2a50
commit
7f1978570f
27
init.c
27
init.c
@ -396,11 +396,11 @@ static void console_init()
|
|||||||
|
|
||||||
static pid_t run(char *command, char *terminal, int get_enter)
|
static pid_t run(char *command, char *terminal, int get_enter)
|
||||||
{
|
{
|
||||||
int i=0, j=0;
|
int i, j;
|
||||||
int fd;
|
int fd;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
char *tmpCmd;
|
char *tmpCmd, *s;
|
||||||
char *cmd[255], *cmdpath;
|
char *cmd[255], *cmdpath;
|
||||||
char buf[255];
|
char buf[255];
|
||||||
static const char press_enter[] =
|
static const char press_enter[] =
|
||||||
|
|
||||||
@ -410,18 +410,25 @@ static pid_t run(char *command, char *terminal, int get_enter)
|
|||||||
|
|
||||||
"\nPlease press Enter to activate this console. ";
|
"\nPlease press Enter to activate this console. ";
|
||||||
char *environment[MAXENV+1] = {
|
char *environment[MAXENV+1] = {
|
||||||
|
termType,
|
||||||
"HOME=/",
|
"HOME=/",
|
||||||
"PATH=/usr/bin:/bin:/usr/sbin:/sbin",
|
"PATH=/usr/bin:/bin:/usr/sbin:/sbin",
|
||||||
"SHELL=/bin/sh",
|
"SHELL=/bin/sh",
|
||||||
termType,
|
"USER=root",
|
||||||
"USER=root"
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
while (environment[i]) i++;
|
/* inherit environment to the child, merging our values -andy */
|
||||||
while ((environ[j]) && (i < MAXENV)) {
|
for (i=0; environ[i]; i++) {
|
||||||
if (strncmp(environ[j], "TERM=", 5))
|
for (j=0; environment[j]; j++) {
|
||||||
environment[i++] = environ[j];
|
s = strchr(environment[j], '=');
|
||||||
j++;
|
if (!strncmp(environ[i], environment[j], s - environment[j]))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!environment[j]) {
|
||||||
|
environment[j++] = environ[i];
|
||||||
|
environment[j] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pid = fork()) == 0) {
|
if ((pid = fork()) == 0) {
|
||||||
|
27
init/init.c
27
init/init.c
@ -396,11 +396,11 @@ static void console_init()
|
|||||||
|
|
||||||
static pid_t run(char *command, char *terminal, int get_enter)
|
static pid_t run(char *command, char *terminal, int get_enter)
|
||||||
{
|
{
|
||||||
int i=0, j=0;
|
int i, j;
|
||||||
int fd;
|
int fd;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
char *tmpCmd;
|
char *tmpCmd, *s;
|
||||||
char *cmd[255], *cmdpath;
|
char *cmd[255], *cmdpath;
|
||||||
char buf[255];
|
char buf[255];
|
||||||
static const char press_enter[] =
|
static const char press_enter[] =
|
||||||
|
|
||||||
@ -410,18 +410,25 @@ static pid_t run(char *command, char *terminal, int get_enter)
|
|||||||
|
|
||||||
"\nPlease press Enter to activate this console. ";
|
"\nPlease press Enter to activate this console. ";
|
||||||
char *environment[MAXENV+1] = {
|
char *environment[MAXENV+1] = {
|
||||||
|
termType,
|
||||||
"HOME=/",
|
"HOME=/",
|
||||||
"PATH=/usr/bin:/bin:/usr/sbin:/sbin",
|
"PATH=/usr/bin:/bin:/usr/sbin:/sbin",
|
||||||
"SHELL=/bin/sh",
|
"SHELL=/bin/sh",
|
||||||
termType,
|
"USER=root",
|
||||||
"USER=root"
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
while (environment[i]) i++;
|
/* inherit environment to the child, merging our values -andy */
|
||||||
while ((environ[j]) && (i < MAXENV)) {
|
for (i=0; environ[i]; i++) {
|
||||||
if (strncmp(environ[j], "TERM=", 5))
|
for (j=0; environment[j]; j++) {
|
||||||
environment[i++] = environ[j];
|
s = strchr(environment[j], '=');
|
||||||
j++;
|
if (!strncmp(environ[i], environment[j], s - environment[j]))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!environment[j]) {
|
||||||
|
environment[j++] = environ[i];
|
||||||
|
environment[j] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pid = fork()) == 0) {
|
if ((pid = fork()) == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user