1 --- rxvt-2.7.6/src/logging.c Tue Apr 3 02:05:26 2001
2 +++ rxvt-2.7.6.modified/src/logging.c Thu May 10 17:14:43 2001
6 rxvt_makeutent(rxvt_t *r, const char *pty, const char *hostname)
8 -/* ------------------------------ BSD ------------------------------ */
11 - UTMP *ut = &(r->h->ut);
12 - struct passwd *pwent = getpwuid(getuid());
17 - char buf[256], name[256];
19 -/* BSD naming is of the form /dev/tty?? or /dev/pty?? */
20 - MEMSET(ut, 0, sizeof(UTMP));
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);
30 - STRNCPY(ut->id, un.nodename, sizeof(ut->ut_line));
31 - ut->ut_pid = getpid();
32 - ut->ut_type = USER_PROCESS;
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);
40 - buf[sizeof(buf) - 1] = '\0';
43 - utmp_pos = fseek(fd0, 0L, 1);
44 - if (fread(&u2, sizeof(UTMP), 1, fd0) != 1)
46 - if ((u2.ut_type == LOGIN_PROCESS || u2.ut_type == USER_PROCESS)
47 - && (STRNCMP(u2.ut_line, pty, sizeof(u2.ut_line)) == 0))
51 - if ((fd0 = fopen(TTYTAB_FILENAME, "r")) != NULL) {
54 - for (i = 1; (fgets(buf, sizeof(buf) - 1, fd0) != NULL);) {
55 - if (*buf == '#' || sscanf(buf, "%s", name) != 1)
57 - if (!STRCMP(ut->ut_line, name)) {
67 - if (!rxvt_write_bsd_utmp(r->h->utmp_pos, ut))
70 -# ifdef WTMP_ONLY_ON_LOGIN
71 - if (r->Options & Opt_loginShell)
73 - update_wtmp(RXVT_REAL_WTMP_FILE, ut);
75 -#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
76 - if (r->Options & Opt_loginShell)
77 - rxvt_update_lastlog(RXVT_LASTLOG_FILE, pty, hostname);
79 + addToUtmp(pty, NULL, r->cmd_fd);
82 -/* ------------------------------ SYSV ------------------------------ */
86 - UTMP *ut = &(r->h->ut);
87 - struct passwd *pwent = getpwuid(getuid());
89 - MEMSET(ut, 0, sizeof(UTMP));
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 */
98 - rxvt_print_error("can't parse tty name \"%s\"", pty);
103 - /* XXX: most likely unnecessary. could be harmful */
104 - utmpname(RXVT_REAL_UTMP_FILE);
106 - STRNCPY(r->h->ut_id, ut->ut_id, sizeof(r->h->ut_id));
108 - setutent(); /* XXX: should be unnecessaray */
110 - ut->ut_type = DEAD_PROCESS;
111 - getutid(ut); /* position to entry in utmp file */
113 -/* set up the new entry */
114 - ut->ut_type = USER_PROCESS;
116 - ut->ut_exit.e_exit = 2;
118 - STRNCPY(ut->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
119 - sizeof(ut->ut_user));
120 -/* ut_name is normally the same as ut_user, but .... */
121 - STRNCPY(ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
122 - sizeof(ut->ut_name));
123 - STRNCPY(ut->ut_id, r->h->ut_id, sizeof(ut->ut_id));
124 - STRNCPY(ut->ut_line, pty, sizeof(ut->ut_line));
126 -#if (defined(HAVE_UTMP_HOST) && ! defined(RXVT_UTMP_AS_UTMPX)) || (defined(HAVE_UTMPX_HOST) && defined(RXVT_UTMP_AS_UTMPX))
127 - STRNCPY(ut->ut_host, hostname, sizeof(ut->ut_host));
129 - if ((colon = STRRCHR(ut->ut_host, ':')) != NULL)
134 - ut->ut_pid = getpid();
136 -#ifdef RXVT_UTMP_AS_UTMPX
137 - ut->ut_session = getsid(0);
138 - ut->ut_tv.tv_sec = time(NULL);
139 - ut->ut_tv.tv_usec = 0;
141 - ut->ut_time = time(NULL);
142 -#endif /* HAVE_UTMPX_H */
144 - r->h->utmp_pos = 1;
147 -# ifdef WTMP_ONLY_ON_LOGIN
148 - if (r->Options & Opt_loginShell)
150 - update_wtmp(RXVT_REAL_WTMP_FILE, ut);
152 -#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
153 - if (r->Options & Opt_loginShell)
154 - rxvt_update_lastlog(RXVT_LASTLOG_FILE, pty, hostname);
156 - endutent(); /* close the file */
158 -#endif /* !USE_SYSV_UTMP */
160 /* ------------------------------------------------------------------------- */
165 rxvt_cleanutent(rxvt_t *r)
166 -#ifndef USE_SYSV_UTMP
167 -/* ------------------------------ BSD ------------------------------ */
169 - UTMP *ut = &(r->h->ut);
173 - MEMCPY(u2, ut, sizeof(UTMP));
176 -# ifdef WTMP_ONLY_ON_LOGIN
177 - if (r->Options & Opt_loginShell)
180 - MEMSET(ut->ut_name, 0, sizeof(ut->ut_name));
181 - MEMSET(ut->ut_host, 0, sizeof(ut->ut_host));
182 - ut->ut_time = time(NULL);
183 - update_wtmp(RXVT_REAL_WTMP_FILE, ut);
186 - if (!r->h->utmp_pos)
189 - u2.ut_type = DEAD_PROCESS;
190 - rxvt_write_bsd_utmp(r->h->utmp_pos, &u2);
192 - MEMSET(ut, 0, sizeof(UTMP));
193 - rxvt_write_bsd_utmp(r->h->utmp_pos, ut);
197 -#else /* USE_SYSV_UTMP */
198 -/* ------------------------------ SYSV ------------------------------ */
200 - UTMP *putmp, *ut = &(r->h->ut);
202 - if (!r->h->utmp_pos)
206 - /* XXX: most likely unnecessary. could be harmful */
207 - utmpname(RXVT_REAL_UTMP_FILE);
209 - MEMSET(ut, 0, sizeof(UTMP));
210 - STRNCPY(ut->ut_id, r->h->ut_id, sizeof(ut->ut_id));
211 - ut->ut_type = USER_PROCESS;
213 - setutent(); /* XXX: should be unnecessaray */
215 - putmp = getutid(ut);
216 - if (!putmp || putmp->ut_pid != getpid())
219 - putmp->ut_type = DEAD_PROCESS;
221 -#ifdef RXVT_UTMP_AS_UTMPX
222 - putmp->ut_session = getsid(0);
223 - putmp->ut_tv.tv_sec = time(NULL);
224 - putmp->ut_tv.tv_usec = 0;
225 -#else /* HAVE_UTMPX_H */
226 - putmp->ut_time = time(NULL);
227 -#endif /* HAVE_UTMPX_H */
231 -# ifdef WTMP_ONLY_ON_LOGIN
232 - if (r->Options & Opt_loginShell)
234 - update_wtmp(RXVT_REAL_WTMP_FILE, putmp);
239 -#endif /* !USE_SYSV_UTMP */
240 #endif /* UTMP_SUPPORT */
241 --- rxvt-2.7.6/src/Makefile.in Mon Apr 2 16:33:43 2001
242 +++ rxvt-2.7.6.modified/src/Makefile.in Thu May 10 16:58:32 2001
246 rxvt: version.h rxvt.o librxvt.la
247 - $(LIBTOOL) --mode=link $(LINK) rxvt.o librxvt.la $(LIBS) $(XLIB) $(DLIB) -o $@
248 + $(LIBTOOL) --mode=link $(LINK) rxvt.o librxvt.la $(LIBS) $(XLIB) -lutempter -lutil $(DLIB) -o $@
251 @for I in $(EXTPROS); do \