… | |
… | |
58 | */ |
58 | */ |
59 | void |
59 | void |
60 | rxvt_term::makeutent (const char *pty, const char *hostname) |
60 | rxvt_term::makeutent (const char *pty, const char *hostname) |
61 | { |
61 | { |
62 | #ifdef HAVE_STRUCT_UTMP |
62 | #ifdef HAVE_STRUCT_UTMP |
63 | struct utmp *ut = & (this->ut); |
63 | struct utmp *ut = &this->ut; |
64 | #endif |
64 | #endif |
65 | #ifdef HAVE_STRUCT_UTMPX |
65 | #ifdef HAVE_STRUCT_UTMPX |
66 | struct utmpx *utx = & (this->utx); |
66 | struct utmpx *utx = &this->utx; |
67 | #endif |
67 | #endif |
68 | #ifdef HAVE_UTMP_PID |
68 | #ifdef HAVE_UTMP_PID |
69 | int i; |
69 | int i; |
70 | #endif |
70 | #endif |
71 | char ut_id[5]; |
|
|
72 | struct passwd *pwent = getpwuid (getuid ()); |
71 | struct passwd *pwent = getpwuid (getuid ()); |
73 | |
72 | |
74 | if (!strncmp (pty, "/dev/", 5)) |
73 | if (!strncmp (pty, "/dev/", 5)) |
75 | pty += 5; /* skip /dev/ prefix */ |
74 | pty += 5; /* skip /dev/ prefix */ |
76 | |
75 | |
77 | if (!strncmp (pty, "pty", 3) || !strncmp (pty, "tty", 3)) |
76 | if (!strncmp (pty, "pty", 3) || !strncmp (pty, "tty", 3)) |
78 | { |
|
|
79 | strncpy (ut_id, (pty + 3), sizeof (ut_id)); |
77 | strncpy (ut_id, (pty + 3), sizeof (ut_id)); |
80 | } |
|
|
81 | #ifdef HAVE_UTMP_PID |
78 | #ifdef HAVE_UTMP_PID |
82 | else if (sscanf (pty, "pts/%d", &i) == 1) |
79 | else if (sscanf (pty, "pts/%d", &i) == 1) |
83 | sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ |
80 | sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ |
84 | #endif |
81 | #endif |
85 | else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3)) |
82 | else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3)) |
… | |
… | |
225 | */ |
222 | */ |
226 | void |
223 | void |
227 | rxvt_term::cleanutent () |
224 | rxvt_term::cleanutent () |
228 | { |
225 | { |
229 | #ifdef HAVE_STRUCT_UTMP |
226 | #ifdef HAVE_STRUCT_UTMP |
230 | struct utmp *ut = & (this->ut); |
227 | struct utmp *ut = &this->ut; |
231 | #endif |
228 | #endif |
232 | #ifdef HAVE_STRUCT_UTMPX |
229 | #ifdef HAVE_STRUCT_UTMPX |
233 | struct utmpx *tmputx, *utx = & (this->utx); |
230 | struct utmpx *tmputx, *utx = &this->utx; |
234 | #endif |
231 | #endif |
235 | |
232 | |
236 | #ifdef HAVE_STRUCT_UTMP |
233 | #ifdef HAVE_STRUCT_UTMP |
237 | # ifdef HAVE_UTMP_PID |
234 | # ifdef HAVE_UTMP_PID |
238 | memset (ut, 0, sizeof (struct utmp)); |
235 | memset (ut, 0, sizeof (struct utmp)); |