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.23 by root, Mon Jan 16 09:10:16 2006 UTC vs.
Revision 1.27 by root, Tue Jan 17 10:14:26 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 "ptytty.h"
45 37
46#ifdef UTMP_SUPPORT 38#if UTMP_SUPPORT
47 39
48#if HAVE_STRUCT_UTMP 40#if HAVE_STRUCT_UTMP
49static int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu); 41static int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu);
50static void rxvt_update_wtmp (const char *fname, const struct utmp *putmp); 42static void rxvt_update_wtmp (const char *fname, const struct utmp *putmp);
51#endif 43#endif
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_ptytty::login (int cmd_pid, bool login_shell, const char *hostname)
69{ 61{
62 this->cmd_pid = cmd_pid;
63 this->login_shell = login_shell;
64
65 const char *pty = name;
66
70#ifdef HAVE_STRUCT_UTMP 67#ifdef HAVE_STRUCT_UTMP
71 struct utmp *ut = &this->ut; 68 struct utmp *ut = &this->ut;
72#endif 69#endif
73#ifdef HAVE_STRUCT_UTMPX 70#ifdef HAVE_STRUCT_UTMPX
74 struct utmpx *utx = &this->utx; 71 struct utmpx *utx = &this->utx;
199 } 196 }
200#endif 197#endif
201 198
202#ifdef WTMP_SUPPORT 199#ifdef WTMP_SUPPORT
203# ifdef WTMP_ONLY_ON_LOGIN 200# ifdef WTMP_ONLY_ON_LOGIN
204 if (OPTION (Opt_loginShell)) 201 if (login_shell)
205# endif 202# endif
206 { 203 {
207# ifdef HAVE_STRUCT_UTMP 204# ifdef HAVE_STRUCT_UTMP
208# ifdef HAVE_UPDWTMP 205# ifdef HAVE_UPDWTMP
209 updwtmp (RXVT_WTMP_FILE, ut); 206 updwtmp (RXVT_WTMP_FILE, ut);
215 updwtmpx (RXVT_WTMPX_FILE, utx); 212 updwtmpx (RXVT_WTMPX_FILE, utx);
216# endif 213# endif
217 } 214 }
218#endif 215#endif
219#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) 216#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
220 if (OPTION (Opt_loginShell)) 217 if (login_shell)
221 rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname); 218 rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname);
222#endif 219#endif
223} 220}
224 221
225/* ------------------------------------------------------------------------- */ 222/* ------------------------------------------------------------------------- */
226/* 223/*
227 * remove utmp and wtmp entries 224 * remove utmp and wtmp entries
228 */ 225 */
229void 226void
230rxvt_term::cleanutent () 227rxvt_ptytty::logout ()
231{ 228{
232#ifdef HAVE_STRUCT_UTMP 229#ifdef HAVE_STRUCT_UTMP
233 struct utmp *ut = &this->ut; 230 struct utmp *tmput, *ut = &this->ut;
234#endif 231#endif
235#ifdef HAVE_STRUCT_UTMPX 232#ifdef HAVE_STRUCT_UTMPX
236 struct utmpx *tmputx, *utx = &this->utx; 233 struct utmpx *tmputx, *utx = &this->utx;
237#endif 234#endif
238 235
240# ifdef HAVE_UTMP_PID 237# ifdef HAVE_UTMP_PID
241 memset (ut, 0, sizeof (struct utmp)); 238 memset (ut, 0, sizeof (struct utmp));
242 setutent (); 239 setutent ();
243 strncpy (ut->ut_id, this->ut_id, sizeof (ut->ut_id)); 240 strncpy (ut->ut_id, this->ut_id, sizeof (ut->ut_id));
244 ut->ut_type = USER_PROCESS; 241 ut->ut_type = USER_PROCESS;
245 {
246 struct utmp *tmput = getutid (ut);
247
248 if (tmput) /* position to entry in utmp file */ 242 if ((tmput = getutid (ut))) /* position to entry in utmp file */
249 ut = tmput; 243 ut = tmput;
250 }
251 ut->ut_type = DEAD_PROCESS; 244 ut->ut_type = DEAD_PROCESS;
252# else 245# else
253 memset (ut->ut_name, 0, sizeof (ut->ut_name)); 246 memset (ut->ut_name, 0, sizeof (ut->ut_name));
254# ifdef HAVE_UTMP_HOST 247# ifdef HAVE_UTMP_HOST
255 memset (ut->ut_host, 0, sizeof (ut->ut_host)); 248 memset (ut->ut_host, 0, sizeof (ut->ut_host));
276 /* 269 /*
277 * Write ending wtmp entry 270 * Write ending wtmp entry
278 */ 271 */
279#ifdef WTMP_SUPPORT 272#ifdef WTMP_SUPPORT
280# ifdef WTMP_ONLY_ON_LOGIN 273# ifdef WTMP_ONLY_ON_LOGIN
281 if (OPTION (Opt_loginShell)) 274 if (login_shell)
282# endif 275# endif
283 { 276 {
284# ifdef HAVE_STRUCT_UTMP 277# ifdef HAVE_STRUCT_UTMP
285# ifdef HAVE_UPDWTMP 278# ifdef HAVE_UPDWTMP
286 updwtmp (RXVT_WTMP_FILE, ut); 279 updwtmp (RXVT_WTMP_FILE, ut);
287# else 280# else
288 rxvt_update_wtmp (RXVT_WTMP_FILE, ut); 281 rxvt_update_wtmp (RXVT_WTMP_FILE, ut);
289# endif 282# endif
290# endif 283# endif
291# ifdef HAVE_STRUCT_UTMPX 284# if defined(HAVE_STRUCT_UTMPX) && defined(HAVE_UPDWTMPX)
292# if HAVE_UPDWTMPX
293 updwtmpx (RXVT_WTMPX_FILE, utx); 285 updwtmpx (RXVT_WTMPX_FILE, utx);
294# else
295 pututxline (utx);
296# endif
297# endif 286# endif
298 } 287 }
299#endif 288#endif
300 289
301 /* 290 /*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines