]> git.pld-linux.org Git - packages/urxvt.git/blame - rxvt-utmp98.patch
- updated for 2.7.8.
[packages/urxvt.git] / rxvt-utmp98.patch
CommitLineData
dc69cbd5 1--- rxvt-2.7.8/src/logging.c.orig Wed May 15 08:29:09 2002
2+++ rxvt-2.7.8/src/logging.c Wed May 15 08:30:16 2002
3@@ -171,154 +171,9 @@
8f71c2d2 4 /* EXTPROTO */
5 void
6 rxvt_makeutent(rxvt_t *r, const char *pty, const char *hostname)
7-#ifndef USE_SYSV_UTMP
8-/* ------------------------------ BSD ------------------------------ */
9 {
10- FILE *fd0;
11- UTMP *ut = &(r->h->ut);
12- struct passwd *pwent = getpwuid(getuid());
13-#ifdef __QNX__
14- UTMP u2;
15- struct utsname un;
16-#endif
17- char buf[256], name[256];
18-
19-/* BSD naming is of the form /dev/tty?? or /dev/pty?? */
20- MEMSET(ut, 0, sizeof(UTMP));
21-
22- if (!STRNCMP(pty, "/dev/", 5))
23- pty += 5; /* skip /dev/ prefix */
24- if (STRNCMP(pty, "pty", 3) && STRNCMP(pty, "tty", 3)) {
25- rxvt_print_error("can't parse tty name \"%s\"", pty);
26- return;
27- }
28-#ifdef __QNX__
29- uname(&un);
30- STRNCPY(ut->id, un.nodename, sizeof(ut->ut_line));
31- ut->ut_pid = getpid();
32- ut->ut_type = USER_PROCESS;
33-#endif
34- STRNCPY(ut->ut_line, pty, sizeof(ut->ut_line));
35- STRNCPY(ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
36- sizeof(ut->ut_name));
37- STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host));
38- ut->ut_time = time(NULL);
39-
40- buf[sizeof(buf) - 1] = '\0';
41-#ifdef __QNX__
42- for (;;) {
dc69cbd5 43- r->h->utmp_pos = fseek(fd0, 0L, 1);
8f71c2d2 44- if (fread(&u2, sizeof(UTMP), 1, fd0) != 1)
45- break;
46- if ((u2.ut_type == LOGIN_PROCESS || u2.ut_type == USER_PROCESS)
47- && (STRNCMP(u2.ut_line, pty, sizeof(u2.ut_line)) == 0))
48- break;
49- }
50-#else
51- if ((fd0 = fopen(TTYTAB_FILENAME, "r")) != NULL) {
52- int i;
53-
54- for (i = 1; (fgets(buf, sizeof(buf) - 1, fd0) != NULL);) {
55- if (*buf == '#' || sscanf(buf, "%s", name) != 1)
56- continue;
57- if (!STRCMP(ut->ut_line, name)) {
58- r->h->utmp_pos = i;
59- fclose(fd0);
60- break;
61- }
62- i++;
63- }
64- fclose(fd0);
65- }
66-#endif
67- if (!rxvt_write_bsd_utmp(r->h->utmp_pos, ut))
68- r->h->utmp_pos = 0;
69-#ifdef WTMP_SUPPORT
70-# ifdef WTMP_ONLY_ON_LOGIN
71- if (r->Options & Opt_loginShell)
72-# endif
73- update_wtmp(RXVT_REAL_WTMP_FILE, ut);
74-#endif
75-#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
76- if (r->Options & Opt_loginShell)
77- rxvt_update_lastlog(RXVT_LASTLOG_FILE, pty, hostname);
78-#endif
79+ addToUtmp(pty, NULL, r->cmd_fd);
80 }
81-#else
82-/* ------------------------------ SYSV ------------------------------ */
83-{
84- int i;
85- char *colon;
86- UTMP *ut = &(r->h->ut);
87- struct passwd *pwent = getpwuid(getuid());
88-
89- MEMSET(ut, 0, sizeof(UTMP));
90-
91- if (!STRNCMP(pty, "/dev/", 5))
92- pty += 5; /* skip /dev/ prefix */
93- if (!STRNCMP(pty, "pty", 3) || !STRNCMP(pty, "tty", 3))
94- STRNCPY(ut->ut_id, (pty + 3), sizeof(ut->ut_id));
95- else if (sscanf(pty, "pts/%d", &i) == 1)
96- sprintf(ut->ut_id, "vt%02x", (i & 0xff)); /* sysv naming */
97- else {
98- rxvt_print_error("can't parse tty name \"%s\"", pty);
99- return;
100- }
101-
102-#if 0
103- /* XXX: most likely unnecessary. could be harmful */
104- utmpname(RXVT_REAL_UTMP_FILE);
105-#endif
106- STRNCPY(r->h->ut_id, ut->ut_id, sizeof(r->h->ut_id));
107-
108- setutent(); /* XXX: should be unnecessaray */
109-
110- ut->ut_type = DEAD_PROCESS;
111- getutid(ut); /* position to entry in utmp file */
112-
113-/* set up the new entry */
114- ut->ut_type = USER_PROCESS;
dc69cbd5 115-#if 0 /* #ifndef linux */
8f71c2d2 116- ut->ut_exit.e_exit = 2;
117-#endif
118- STRNCPY(ut->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
119- sizeof(ut->ut_user));
8f71c2d2 120- STRNCPY(ut->ut_id, r->h->ut_id, sizeof(ut->ut_id));
121- STRNCPY(ut->ut_line, pty, sizeof(ut->ut_line));
122-
123-#if (defined(HAVE_UTMP_HOST) && ! defined(RXVT_UTMP_AS_UTMPX)) || (defined(HAVE_UTMPX_HOST) && defined(RXVT_UTMP_AS_UTMPX))
124- STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host));
125-# ifndef linux
126- if ((colon = STRRCHR(ut->ut_host, ':')) != NULL)
127- *colon = '\0';
128-# endif
129-#endif
130-
131- ut->ut_pid = getpid();
132-
133-#ifdef RXVT_UTMP_AS_UTMPX
134- ut->ut_session = getsid(0);
135- ut->ut_tv.tv_sec = time(NULL);
136- ut->ut_tv.tv_usec = 0;
137-#else
138- ut->ut_time = time(NULL);
139-#endif /* HAVE_UTMPX_H */
140- pututline(ut);
141- r->h->utmp_pos = 1;
142-
143-#ifdef WTMP_SUPPORT
144-# ifdef WTMP_ONLY_ON_LOGIN
145- if (r->Options & Opt_loginShell)
146-# endif
147- update_wtmp(RXVT_REAL_WTMP_FILE, ut);
148-#endif
149-#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
150- if (r->Options & Opt_loginShell)
151- rxvt_update_lastlog(RXVT_LASTLOG_FILE, pty, hostname);
152-#endif
153- endutent(); /* close the file */
154-}
155-#endif /* !USE_SYSV_UTMP */
156
157 /* ------------------------------------------------------------------------- */
158 /*
dc69cbd5 159@@ -327,77 +182,9 @@
8f71c2d2 160 /* EXTPROTO */
161 void
162 rxvt_cleanutent(rxvt_t *r)
163-#ifndef USE_SYSV_UTMP
164-/* ------------------------------ BSD ------------------------------ */
165 {
166- UTMP *ut = &(r->h->ut);
167-#ifdef __QNX__
168- UTMP u2;
169-
170- MEMCPY(u2, ut, sizeof(UTMP));
171-#endif
172-#ifdef WTMP_SUPPORT
173-# ifdef WTMP_ONLY_ON_LOGIN
174- if (r->Options & Opt_loginShell)
175-# endif
176- {
177- MEMSET(ut->ut_name, 0, sizeof(ut->ut_name));
178- MEMSET(ut->ut_host, 0, sizeof(ut->ut_host));
179- ut->ut_time = time(NULL);
180- update_wtmp(RXVT_REAL_WTMP_FILE, ut);
181- }
182-#endif
183- if (!r->h->utmp_pos)
184- return;
185-#ifdef __QNX__
186- u2.ut_type = DEAD_PROCESS;
187- rxvt_write_bsd_utmp(r->h->utmp_pos, &u2);
188-#else
189- MEMSET(ut, 0, sizeof(UTMP));
190- rxvt_write_bsd_utmp(r->h->utmp_pos, ut);
191-#endif
192+ removeFromUtmp();
193 }
194-#else /* USE_SYSV_UTMP */
195-/* ------------------------------ SYSV ------------------------------ */
196-{
197- UTMP *putmp, *ut = &(r->h->ut);
198-
199- if (!r->h->utmp_pos)
200- return;
201
202-#if 0
203- /* XXX: most likely unnecessary. could be harmful */
204- utmpname(RXVT_REAL_UTMP_FILE);
205-#endif
206- MEMSET(ut, 0, sizeof(UTMP));
207- STRNCPY(ut->ut_id, r->h->ut_id, sizeof(ut->ut_id));
208- ut->ut_type = USER_PROCESS;
209
210- setutent(); /* XXX: should be unnecessaray */
211-
212- putmp = getutid(ut);
213- if (!putmp || putmp->ut_pid != getpid())
214- return;
215-
216- putmp->ut_type = DEAD_PROCESS;
217-
218-#ifdef RXVT_UTMP_AS_UTMPX
219- putmp->ut_session = getsid(0);
220- putmp->ut_tv.tv_sec = time(NULL);
221- putmp->ut_tv.tv_usec = 0;
222-#else /* HAVE_UTMPX_H */
223- putmp->ut_time = time(NULL);
224-#endif /* HAVE_UTMPX_H */
225- pututline(putmp);
226-
227-#ifdef WTMP_SUPPORT
228-# ifdef WTMP_ONLY_ON_LOGIN
229- if (r->Options & Opt_loginShell)
230-# endif
231- update_wtmp(RXVT_REAL_WTMP_FILE, putmp);
232-#endif
233-
234- endutent();
235-}
236-#endif /* !USE_SYSV_UTMP */
237 #endif /* UTMP_SUPPORT */
238--- rxvt-2.7.6/src/Makefile.in Mon Apr 2 16:33:43 2001
239+++ rxvt-2.7.6.modified/src/Makefile.in Thu May 10 16:58:32 2001
240@@ -82,7 +82,7 @@
241 all: allbin
242
243 rxvt: version.h rxvt.o librxvt.la
244- $(LIBTOOL) --mode=link $(LINK) rxvt.o librxvt.la $(LIBS) $(XLIB) $(DLIB) -o $@
245+ $(LIBTOOL) --mode=link $(LINK) rxvt.o librxvt.la $(LIBS) $(XLIB) -lutempter -lutil $(DLIB) -o $@
246
247 protos:
248 @for I in $(EXTPROS); do \
This page took 0.122781 seconds and 4 git commands to generate.