]> git.pld-linux.org Git - packages/urxvt.git/blob - rxvt-utmp98.patch
- patches from rawhide.
[packages/urxvt.git] / rxvt-utmp98.patch
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
3 @@ -170,157 +170,9 @@
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 (;;) {
43 -       utmp_pos = fseek(fd0, 0L, 1);
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;
115 -#ifndef linux
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));
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));
125 -
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));
128 -# ifndef linux
129 -    if ((colon = STRRCHR(ut->ut_host, ':')) != NULL)
130 -       *colon = '\0';
131 -# endif
132 -#endif
133 -
134 -    ut->ut_pid = getpid();
135 -
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;
140 -#else
141 -    ut->ut_time = time(NULL);
142 -#endif                         /* HAVE_UTMPX_H */
143 -    pututline(ut);
144 -    r->h->utmp_pos = 1;
145 -
146 -#ifdef WTMP_SUPPORT
147 -# ifdef WTMP_ONLY_ON_LOGIN
148 -    if (r->Options & Opt_loginShell)
149 -# endif
150 -       update_wtmp(RXVT_REAL_WTMP_FILE, ut);
151 -#endif
152 -#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
153 -    if (r->Options & Opt_loginShell)
154 -       rxvt_update_lastlog(RXVT_LASTLOG_FILE, pty, hostname);
155 -#endif
156 -    endutent();                        /* close the file */
157 -}
158 -#endif                         /* !USE_SYSV_UTMP */
159  
160  /* ------------------------------------------------------------------------- */
161  /*
162 @@ -329,77 +181,9 @@
163  /* EXTPROTO */
164  void
165  rxvt_cleanutent(rxvt_t *r)
166 -#ifndef USE_SYSV_UTMP
167 -/* ------------------------------ BSD ------------------------------  */
168  {
169 -    UTMP           *ut = &(r->h->ut);
170 -#ifdef __QNX__
171 -    UTMP            u2;
172 -
173 -    MEMCPY(u2, ut, sizeof(UTMP));
174 -#endif
175 -#ifdef WTMP_SUPPORT
176 -# ifdef WTMP_ONLY_ON_LOGIN
177 -    if (r->Options & Opt_loginShell)
178 -# endif
179 -    {
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);
184 -    }
185 -#endif
186 -    if (!r->h->utmp_pos)
187 -       return;
188 -#ifdef __QNX__
189 -    u2.ut_type = DEAD_PROCESS;
190 -    rxvt_write_bsd_utmp(r->h->utmp_pos, &u2);
191 -#else
192 -    MEMSET(ut, 0, sizeof(UTMP));
193 -    rxvt_write_bsd_utmp(r->h->utmp_pos, ut);
194 -#endif
195 +    removeFromUtmp();
196  }
197 -#else                          /* USE_SYSV_UTMP */
198 -/* ------------------------------ SYSV ------------------------------  */
199 -{
200 -    UTMP           *putmp, *ut = &(r->h->ut);
201 -
202 -    if (!r->h->utmp_pos)
203 -       return;
204  
205 -#if 0
206 -    /* XXX: most likely unnecessary.  could be harmful */
207 -    utmpname(RXVT_REAL_UTMP_FILE);
208 -#endif
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;
212  
213 -    setutent();                        /* XXX: should be unnecessaray */
214 -
215 -    putmp = getutid(ut);
216 -    if (!putmp || putmp->ut_pid != getpid())
217 -       return;
218 -
219 -    putmp->ut_type = DEAD_PROCESS;
220 -
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 */
228 -    pututline(putmp);
229 -
230 -#ifdef WTMP_SUPPORT
231 -# ifdef WTMP_ONLY_ON_LOGIN
232 -    if (r->Options & Opt_loginShell)
233 -# endif
234 -       update_wtmp(RXVT_REAL_WTMP_FILE, putmp);
235 -#endif
236 -
237 -    endutent();
238 -}
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
243 @@ -82,7 +82,7 @@
244  all: allbin
245  
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 $@
249  
250  protos:
251         @for I in $(EXTPROS); do \
This page took 0.143032 seconds and 4 git commands to generate.