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