1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
--- ./src/logging.c.orig 2002-12-15 16:33:04.000000000 -0800
+++ ./src/logging.c 2003-06-07 21:08:52.000000000 -0700
@@ -60,157 +60,7 @@
void
rxvt_makeutent(rxvt_t *r, const char *pty, const char *hostname)
{
-#ifdef HAVE_STRUCT_UTMP
- struct utmp *ut = &(r->h->ut);
-#endif
-#ifdef HAVE_STRUCT_UTMPX
- struct utmpx *utx = &(r->h->utx);
-#endif
-#ifdef HAVE_UTMP_PID
- int i;
-#endif
- char ut_id[5];
- struct passwd *pwent = getpwuid(getuid());
-
- if (!STRNCMP(pty, "/dev/", 5))
- pty += 5; /* skip /dev/ prefix */
-
- if (!STRNCMP(pty, "pty", 3) || !STRNCMP(pty, "tty", 3)) {
- STRNCPY(ut_id, (pty + 3), sizeof(ut_id));
- }
-#ifdef HAVE_UTMP_PID
- else if (sscanf(pty, "pts/%d", &i) == 1)
- sprintf(ut_id, "vt%02x", (i & 0xff)); /* sysv naming */
-#endif
- else if (STRNCMP(pty, "pty", 3) && STRNCMP(pty, "tty", 3)) {
- rxvt_print_error("can't parse tty name \"%s\"", pty);
- return;
- }
-
-#ifdef HAVE_STRUCT_UTMP
- MEMSET(ut, 0, sizeof(struct utmp));
-# ifdef HAVE_UTMP_PID
- setutent();
- STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id));
- ut->ut_type = DEAD_PROCESS;
- getutid(ut); /* position to entry in utmp file */
- STRNCPY(r->h->ut_id, ut_id, sizeof(r->h->ut_id));
-# endif
-#endif
-
-#ifdef HAVE_STRUCT_UTMPX
- MEMSET(utx, 0, sizeof(struct utmpx));
- setutxent();
- STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id));
- utx->ut_type = DEAD_PROCESS;
- getutxid(utx); /* position to entry in utmp file */
- STRNCPY(r->h->ut_id, ut_id, sizeof(r->h->ut_id));
-#endif
-
-#ifdef HAVE_STRUCT_UTMP
- STRNCPY(ut->ut_line, pty, sizeof(ut->ut_line));
- ut->ut_time = time(NULL);
-# ifdef HAVE_UTMP_PID
- STRNCPY(ut->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
- sizeof(ut->ut_user));
- STRNCPY(ut->ut_id, ut_id, sizeof(ut->ut_id));
- ut->ut_time = time(NULL);
- ut->ut_pid = r->h->cmd_pid;
-# ifdef HAVE_UTMP_HOST
- STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host));
-# endif
- ut->ut_type = USER_PROCESS;
- pututline(ut);
- endutent(); /* close the file */
- r->h->utmp_pos = -1;
-# else
- STRNCPY(ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
- sizeof(ut->ut_name));
-# ifdef HAVE_UTMP_HOST
- STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host));
-# endif
-# endif
-#endif
-
-#ifdef HAVE_STRUCT_UTMPX
- STRNCPY(utx->ut_line, pty, sizeof(utx->ut_line));
- STRNCPY(utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
- sizeof(utx->ut_user));
- STRNCPY(utx->ut_id, ut_id, sizeof(utx->ut_id));
- utx->ut_session = getsid(0);
- utx->ut_tv.tv_sec = time(NULL);
- utx->ut_tv.tv_usec = 0;
- utx->ut_pid = r->h->cmd_pid;
-# ifdef HAVE_UTMPX_HOST
- STRNCPY(utx->ut_host, hostname, sizeof(utx->ut_host));
-# if 0
- {
- char *colon;
-
- if ((colon = STRRCHR(ut->ut_host, ':')) != NULL)
- *colon = '\0';
- }
-# endif
-# endif
- utx->ut_type = USER_PROCESS;
- pututxline(utx);
- endutxent(); /* close the file */
- r->h->utmp_pos = -1;
-#endif
-
-#if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID)
- {
- int i;
-# ifdef HAVE_TTYSLOT
- i = ttyslot();
- if (rxvt_write_bsd_utmp(i, ut))
- r->h->utmp_pos = i;
-# else
- FILE *fd0;
-
- if ((fd0 = fopen(TTYTAB_FILENAME, "r")) != NULL) {
- char buf[256], name[256];
-
- buf[sizeof(buf) - 1] = '\0';
- for (i = 1; (fgets(buf, sizeof(buf) - 1, fd0) != NULL);) {
- if (*buf == '#' || sscanf(buf, "%s", name) != 1)
- continue;
- if (!STRCMP(ut->ut_line, name)) {
- if (!rxvt_write_bsd_utmp(i, ut))
- i = 0;
- r->h->utmp_pos = i;
- fclose(fd0);
- break;
- }
- i++;
- }
- fclose(fd0);
- }
-# endif
- }
-#endif
-
-#ifdef WTMP_SUPPORT
-# ifdef WTMP_ONLY_ON_LOGIN
- if (r->Options & Opt_loginShell)
-# endif
- {
-# ifdef HAVE_STRUCT_UTMP
-# ifdef HAVE_UPDWTMP
- updwtmp(RXVT_WTMP_FILE, ut);
-# else
- rxvt_update_wtmp(RXVT_WTMP_FILE, ut);
-# endif
-# endif
-# ifdef HAVE_STRUCT_UTMPX
- updwtmpx(RXVT_WTMPX_FILE, utx);
-# endif
- }
-#endif
-#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
- if (r->Options & Opt_loginShell)
- rxvt_update_lastlog(RXVT_LASTLOG_FILE, pty, hostname);
-#endif
+ addToUtmp(pty, NULL, r->cmd_fd);
}
/* ------------------------------------------------------------------------- */
@@ -221,85 +71,7 @@
void
rxvt_cleanutent(rxvt_t *r)
{
-#ifdef HAVE_STRUCT_UTMP
- struct utmp *tmput, *ut = &(r->h->ut);
-#endif
-#ifdef HAVE_STRUCT_UTMPX
- struct utmpx *tmputx, *utx = &(r->h->utx);
-#endif
-
-#ifdef HAVE_STRUCT_UTMP
-# ifdef HAVE_UTMP_PID
- MEMSET(ut, 0, sizeof(struct utmp));
- setutent();
- STRNCPY(ut->ut_id, r->h->ut_id, sizeof(ut->ut_id));
- ut->ut_type = USER_PROCESS;
- if ((tmput = getutid(ut))) /* position to entry in utmp file */
- ut = tmput;
- ut->ut_type = DEAD_PROCESS;
-# else
- MEMSET(ut->ut_name, 0, sizeof(ut->ut_name));
-# ifdef HAVE_UTMP_HOST
- MEMSET(ut->ut_host, 0, sizeof(ut->ut_host));
-# endif
-# endif
- ut->ut_time = time(NULL);
-#endif
-
-#ifdef HAVE_STRUCT_UTMPX
- MEMSET(utx, 0, sizeof(struct utmpx));
- setutxent();
- STRNCPY(utx->ut_id, r->h->ut_id, sizeof(utx->ut_id));
- utx->ut_type = USER_PROCESS;
- if ((tmputx = getutxid(utx))) /* position to entry in utmp file */
- utx = tmputx;
- utx->ut_type = DEAD_PROCESS;
- utx->ut_session = getsid(0);
- utx->ut_tv.tv_sec = time(NULL);
- utx->ut_tv.tv_usec = 0;
-#endif
-
- /*
- * Write ending wtmp entry
- */
-#ifdef WTMP_SUPPORT
-# ifdef WTMP_ONLY_ON_LOGIN
- if (r->Options & Opt_loginShell)
-# endif
- {
-# ifdef HAVE_STRUCT_UTMP
-# ifdef HAVE_UPDWTMP
- updwtmp(RXVT_WTMP_FILE, ut);
-# else
- rxvt_update_wtmp(RXVT_WTMP_FILE, ut);
-# endif
-# endif
-# ifdef HAVE_STRUCT_UTMPX
- updwtmpx(RXVT_WTMPX_FILE, utx);
-# endif
- }
-#endif
-
- /*
- * Write utmp entry
- */
-#ifdef HAVE_STRUCT_UTMP
-# ifdef HAVE_UTMP_PID
- if (ut->ut_pid == r->h->cmd_pid)
- pututline(ut);
- endutent();
-# else
- if (r->h->utmp_pos > 0) {
- MEMSET(ut, 0, sizeof(struct utmp));
- rxvt_write_bsd_utmp(r->h->utmp_pos, ut);
- }
-# endif
-#endif
-#ifdef HAVE_STRUCT_UTMPX
- if (utx->ut_pid == r->h->cmd_pid)
- pututxline(utx);
- endutxent();
-#endif
+ removeFromUtmp();
}
/* ------------------------------------------------------------------------- */
--- ./src/init.c.orig 2002-12-03 21:21:39.000000000 -0800
+++ ./src/init.c 2003-06-07 21:09:26.000000000 -0700
@@ -858,6 +858,7 @@
rxvt_print_error("aborting");
exit(EXIT_FAILURE);
}
+ rxvt_privileged_utmp(r, SAVE);
}
/*----------------------------------------------------------------------*/
@@ -1364,7 +1365,6 @@
#endif
r->num_fds++; /* counts from 0 */
- rxvt_privileged_utmp(r, SAVE);
return cfd;
}
--- ./autoconf/Make.common.in.orig 2001-11-29 19:22:56.000000000 -0800
+++ ./autoconf/Make.common.in 2003-06-07 21:08:52.000000000 -0700
@@ -68,7 +68,7 @@
LIBTOOL = @LIBTOOL@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(DEBUG) $(DINCLUDE) $(XINC) -I$(basedir) -I$(srcdir) -I.
-LINK = $(CC) $(CFLAGS) $(LDFLAGS)
+LINK = $(CC) $(CFLAGS) $(LDFLAGS) -lutempter -lutil
# End of common section of the Makefile
#-------------------------------------------------------------------------
|