ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/logging.C
(Generate patch)

Comparing rxvt-unicode/src/logging.C (file contents):
Revision 1.22 by root, Sun Jan 15 05:14:12 2006 UTC vs.
Revision 1.25 by root, Tue Jan 17 06:06:42 2006 UTC

28 * 28 *
29 * You should have received a copy of the GNU General Public License 29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software 30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 31 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 *----------------------------------------------------------------------*/ 32 *----------------------------------------------------------------------*/
33/*----------------------------------------------------------------------*
34 * Public:
35 * extern void cleanutent (void);
36 * extern void makeutent (const char * pty, const char * hostname);
37 *
38 * Private:
39 * rxvt_update_wtmp ();
40 *----------------------------------------------------------------------*/
41 33
42#include "../config.h" 34#include "../config.h"
43#include "rxvt.h" 35#include "rxvt.h"
44#include "logging.h" 36#include "logging.h"
45 37
63 55
64/* 56/*
65 * make and write utmp and wtmp entries 57 * make and write utmp and wtmp entries
66 */ 58 */
67void 59void
68rxvt_term::makeutent (const char *pty, const char *hostname) 60rxvt_session::login (const char *pty, int cmd_pid, bool login_shell, const char *hostname)
69{ 61{
62 this->cmd_pid = cmd_pid;
63 this->login_shell = login_shell;
64
70#ifdef HAVE_STRUCT_UTMP 65#ifdef HAVE_STRUCT_UTMP
71 struct utmp *ut = &this->ut; 66 struct utmp *ut = &this->ut;
72#endif 67#endif
73#ifdef HAVE_STRUCT_UTMPX 68#ifdef HAVE_STRUCT_UTMPX
74 struct utmpx *utx = &this->utx; 69 struct utmpx *utx = &this->utx;
194 i++; 189 i++;
195 } 190 }
196 fclose (fd0); 191 fclose (fd0);
197 } 192 }
198# endif 193# endif
199
200 } 194 }
201#endif 195#endif
202 196
203#ifdef WTMP_SUPPORT 197#ifdef WTMP_SUPPORT
204# ifdef WTMP_ONLY_ON_LOGIN 198# ifdef WTMP_ONLY_ON_LOGIN
205 if (OPTION (Opt_loginShell)) 199 if (login_shell)
206# endif 200# endif
207 { 201 {
208# ifdef HAVE_STRUCT_UTMP 202# ifdef HAVE_STRUCT_UTMP
209# ifdef HAVE_UPDWTMP 203# ifdef HAVE_UPDWTMP
210 updwtmp (RXVT_WTMP_FILE, ut); 204 updwtmp (RXVT_WTMP_FILE, ut);
211# else 205# else
212 rxvt_update_wtmp (RXVT_WTMP_FILE, ut); 206 rxvt_update_wtmp (RXVT_WTMP_FILE, ut);
213# endif 207# endif
214# endif 208# endif
215# ifdef HAVE_STRUCT_UTMPX 209# if defined(HAVE_STRUCT_UTMPX) && defined(HAVE_UPDWTMPX)
216# if HAVE_UPDWTMPX
217 updwtmpx (RXVT_WTMPX_FILE, utx); 210 updwtmpx (RXVT_WTMPX_FILE, utx);
218# else
219 pututxline (utx);
220# endif
221# endif 211# endif
222 } 212 }
223#endif 213#endif
224#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) 214#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
225 if (OPTION (Opt_loginShell)) 215 if (login_shell)
226 rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname); 216 rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname);
227#endif 217#endif
228} 218}
229 219
230/* ------------------------------------------------------------------------- */ 220/* ------------------------------------------------------------------------- */
231/* 221/*
232 * remove utmp and wtmp entries 222 * remove utmp and wtmp entries
233 */ 223 */
234void 224void
235rxvt_term::cleanutent () 225rxvt_session::logout ()
236{ 226{
237#ifdef HAVE_STRUCT_UTMP 227#ifdef HAVE_STRUCT_UTMP
238 struct utmp *ut = &this->ut; 228 struct utmp *ut = &this->ut;
239#endif 229#endif
240#ifdef HAVE_STRUCT_UTMPX 230#ifdef HAVE_STRUCT_UTMPX
246 memset (ut, 0, sizeof (struct utmp)); 236 memset (ut, 0, sizeof (struct utmp));
247 setutent (); 237 setutent ();
248 strncpy (ut->ut_id, this->ut_id, sizeof (ut->ut_id)); 238 strncpy (ut->ut_id, this->ut_id, sizeof (ut->ut_id));
249 ut->ut_type = USER_PROCESS; 239 ut->ut_type = USER_PROCESS;
250 { 240 {
251 struct utmp *tmput = getutid (ut); 241 struct utmp *tmput = getutid (ut);
252 242
253 if (tmput) /* position to entry in utmp file */ 243 if (tmput) /* position to entry in utmp file */
254 ut = tmput; 244 ut = tmput;
255 } 245 }
256 ut->ut_type = DEAD_PROCESS; 246 ut->ut_type = DEAD_PROCESS;
281 /* 271 /*
282 * Write ending wtmp entry 272 * Write ending wtmp entry
283 */ 273 */
284#ifdef WTMP_SUPPORT 274#ifdef WTMP_SUPPORT
285# ifdef WTMP_ONLY_ON_LOGIN 275# ifdef WTMP_ONLY_ON_LOGIN
286 if (OPTION (Opt_loginShell)) 276 if (login_shell)
287# endif 277# endif
288 { 278 {
289# ifdef HAVE_STRUCT_UTMP 279# ifdef HAVE_STRUCT_UTMP
290# ifdef HAVE_UPDWTMP 280# ifdef HAVE_UPDWTMP
291 updwtmp (RXVT_WTMP_FILE, ut); 281 updwtmp (RXVT_WTMP_FILE, ut);
292# else 282# else
293 rxvt_update_wtmp (RXVT_WTMP_FILE, ut); 283 rxvt_update_wtmp (RXVT_WTMP_FILE, ut);
294# endif 284# endif
295# endif 285# endif
296# ifdef HAVE_STRUCT_UTMPX 286# if defined(HAVE_STRUCT_UTMPX) && defined(HAVE_UPDWTMPX)
297# if HAVE_UPDWTMPX
298 updwtmpx (RXVT_WTMPX_FILE, utx); 287 updwtmpx (RXVT_WTMPX_FILE, utx);
299# else
300 pututxline (utx);
301# endif
302# endif 288# endif
303 } 289 }
304#endif 290#endif
305 291
306 /* 292 /*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines