mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 14:39:24 -05:00
We shouldn't fork off a utmp helper subprocess when we aren't setuid,
because (a) under that circumstance we won't be writing to utmp anyway, and (b) if we aren't setuid, then we won't have created the pty at the point we fork, so even if our subprocess _could_ have written to utmp it wouldn't have done it right! Spotted by valgrind (triggering on the access beyond the end of the ttyname string in setup_utmp, clueing me in to it having been empty). [originally from svn r9309]
This commit is contained in:
parent
73444adc50
commit
f69591412c
@ -167,8 +167,8 @@ static tree234 *ptys_by_pid = NULL;
|
||||
static Pty single_pty = NULL;
|
||||
|
||||
#ifndef OMIT_UTMP
|
||||
static pid_t pty_utmp_helper_pid;
|
||||
static int pty_utmp_helper_pipe;
|
||||
static pid_t pty_utmp_helper_pid = -1;
|
||||
static int pty_utmp_helper_pipe = -1;
|
||||
static int pty_stamped_utmp;
|
||||
static struct utmpx utmp_entry;
|
||||
#endif
|
||||
@ -408,7 +408,6 @@ void pty_pre_init(void)
|
||||
|
||||
if (geteuid() != getuid() || getegid() != getgid()) {
|
||||
pty_open_master(pty);
|
||||
}
|
||||
|
||||
#ifndef OMIT_UTMP
|
||||
/*
|
||||
@ -508,6 +507,7 @@ void pty_pre_init(void)
|
||||
pty_utmp_helper_pipe = pipefd[1];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Drop privs. */
|
||||
{
|
||||
@ -735,7 +735,7 @@ static const char *pty_init(void *frontend, void **backend_handle, Conf *conf,
|
||||
if (!conf_get_int(conf, CONF_stamp_utmp)) {
|
||||
close(pty_utmp_helper_pipe); /* just let the child process die */
|
||||
pty_utmp_helper_pipe = -1;
|
||||
} else {
|
||||
} else if (pty_utmp_helper_pipe >= 0) {
|
||||
char *location = get_x_display(pty->frontend);
|
||||
int len = strlen(location)+1, pos = 0; /* +1 to include NUL */
|
||||
while (pos < len) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user