mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-18 19:48:05 -05:00
Finish up utmp processing: add the -ut- command-line option to
suppress stamping it at all. (I suppose this ought to be part of the cfg structure really.) [originally from svn r2059]
This commit is contained in:
parent
6118021749
commit
0813c25bf6
@ -1283,6 +1283,7 @@ char *get_x_display(void)
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
extern int pty_master_fd; /* declared in pty.c */
|
extern int pty_master_fd; /* declared in pty.c */
|
||||||
|
extern int pty_stamp_utmp; /* declared in pty.c */
|
||||||
extern char **pty_argv; /* declared in pty.c */
|
extern char **pty_argv; /* declared in pty.c */
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
@ -1329,6 +1330,9 @@ int main(int argc, char **argv)
|
|||||||
if (!strcmp(p, "-hide")) {
|
if (!strcmp(p, "-hide")) {
|
||||||
cfg.hide_mouseptr = 1;
|
cfg.hide_mouseptr = 1;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(p, "-ut-")) {
|
||||||
|
pty_stamp_utmp = 0;
|
||||||
|
}
|
||||||
if (!strcmp(p, "-nethack")) {
|
if (!strcmp(p, "-nethack")) {
|
||||||
cfg.nethack_keypad = 1;
|
cfg.nethack_keypad = 1;
|
||||||
}
|
}
|
||||||
|
28
unix/pty.c
28
unix/pty.c
@ -40,7 +40,23 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up a default for vaguely sane systems. The idea is that if
|
||||||
|
* OMIT_UTMP is not defined, then at least one of the symbols which
|
||||||
|
* enable particular forms of utmp processing should be, if only so
|
||||||
|
* that a link error can warn you that you should have defined
|
||||||
|
* OMIT_UTMP if you didn't want any. Currently HAVE_PUTUTLINE is
|
||||||
|
* the only such symbol.
|
||||||
|
*/
|
||||||
|
#ifndef OMIT_UTMP
|
||||||
|
#if !defined HAVE_PUTUTLINE
|
||||||
|
#define HAVE_PUTUTLINE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
int pty_master_fd;
|
int pty_master_fd;
|
||||||
|
int pty_stamp_utmp = 1;
|
||||||
|
static int pty_stamped_utmp = 0;
|
||||||
static int pty_child_pid;
|
static int pty_child_pid;
|
||||||
static sig_atomic_t pty_child_dead;
|
static sig_atomic_t pty_child_dead;
|
||||||
#ifndef OMIT_UTMP
|
#ifndef OMIT_UTMP
|
||||||
@ -63,10 +79,14 @@ static void setup_utmp(char *ttyname)
|
|||||||
FILE *lastlog;
|
FILE *lastlog;
|
||||||
#endif
|
#endif
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
char *location = get_x_display();
|
char *location;
|
||||||
FILE *wtmp;
|
FILE *wtmp;
|
||||||
|
|
||||||
|
if (!pty_stamp_utmp)
|
||||||
|
return;
|
||||||
|
|
||||||
pw = getpwuid(getuid());
|
pw = getpwuid(getuid());
|
||||||
|
location = get_x_display();
|
||||||
memset(&utmp_entry, 0, sizeof(utmp_entry));
|
memset(&utmp_entry, 0, sizeof(utmp_entry));
|
||||||
utmp_entry.ut_type = USER_PROCESS;
|
utmp_entry.ut_type = USER_PROCESS;
|
||||||
utmp_entry.ut_pid = getpid();
|
utmp_entry.ut_pid = getpid();
|
||||||
@ -100,6 +120,8 @@ static void setup_utmp(char *ttyname)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
pty_stamped_utmp = 1;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +130,9 @@ static void cleanup_utmp(void)
|
|||||||
#ifndef OMIT_UTMP
|
#ifndef OMIT_UTMP
|
||||||
FILE *wtmp;
|
FILE *wtmp;
|
||||||
|
|
||||||
|
if (!pty_stamp_utmp || !pty_stamped_utmp)
|
||||||
|
return;
|
||||||
|
|
||||||
utmp_entry.ut_type = DEAD_PROCESS;
|
utmp_entry.ut_type = DEAD_PROCESS;
|
||||||
memset(utmp_entry.ut_user, 0, lenof(utmp_entry.ut_user));
|
memset(utmp_entry.ut_user, 0, lenof(utmp_entry.ut_user));
|
||||||
time(&utmp_entry.ut_time);
|
time(&utmp_entry.ut_time);
|
||||||
@ -127,6 +152,7 @@ static void cleanup_utmp(void)
|
|||||||
endutent();
|
endutent();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
pty_stamped_utmp = 0; /* ensure we never double-cleanup */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user