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.26 by ayin, Tue Jan 17 09:31:24 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;
199 } 194 }
200#endif 195#endif
201 196
202#ifdef WTMP_SUPPORT 197#ifdef WTMP_SUPPORT
203# ifdef WTMP_ONLY_ON_LOGIN 198# ifdef WTMP_ONLY_ON_LOGIN
204 if (OPTION (Opt_loginShell)) 199 if (login_shell)
205# endif 200# endif
206 { 201 {
207# ifdef HAVE_STRUCT_UTMP 202# ifdef HAVE_STRUCT_UTMP
208# ifdef HAVE_UPDWTMP 203# ifdef HAVE_UPDWTMP
209 updwtmp (RXVT_WTMP_FILE, ut); 204 updwtmp (RXVT_WTMP_FILE, ut);
215 updwtmpx (RXVT_WTMPX_FILE, utx); 210 updwtmpx (RXVT_WTMPX_FILE, utx);
216# endif 211# endif
217 } 212 }
218#endif 213#endif
219#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) 214#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
220 if (OPTION (Opt_loginShell)) 215 if (login_shell)
221 rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname); 216 rxvt_update_lastlog (RXVT_LASTLOG_FILE, pty, hostname);
222#endif 217#endif
223} 218}
224 219
225/* ------------------------------------------------------------------------- */ 220/* ------------------------------------------------------------------------- */
226/* 221/*
227 * remove utmp and wtmp entries 222 * remove utmp and wtmp entries
228 */ 223 */
229void 224void
230rxvt_term::cleanutent () 225rxvt_session::logout ()
231{ 226{
232#ifdef HAVE_STRUCT_UTMP 227#ifdef HAVE_STRUCT_UTMP
233 struct utmp *ut = &this->ut; 228 struct utmp *tmput, *ut = &this->ut;
234#endif 229#endif
235#ifdef HAVE_STRUCT_UTMPX 230#ifdef HAVE_STRUCT_UTMPX
236 struct utmpx *tmputx, *utx = &this->utx; 231 struct utmpx *tmputx, *utx = &this->utx;
237#endif 232#endif
238 233
240# ifdef HAVE_UTMP_PID 235# ifdef HAVE_UTMP_PID
241 memset (ut, 0, sizeof (struct utmp)); 236 memset (ut, 0, sizeof (struct utmp));
242 setutent (); 237 setutent ();
243 strncpy (ut->ut_id, this->ut_id, sizeof (ut->ut_id)); 238 strncpy (ut->ut_id, this->ut_id, sizeof (ut->ut_id));
244 ut->ut_type = USER_PROCESS; 239 ut->ut_type = USER_PROCESS;
245 {
246 struct utmp *tmput = getutid (ut);
247
248 if (tmput) /* position to entry in utmp file */ 240 if ((tmput = getutid (ut))) /* position to entry in utmp file */
249 ut = tmput; 241 ut = tmput;
250 }
251 ut->ut_type = DEAD_PROCESS; 242 ut->ut_type = DEAD_PROCESS;
252# else 243# else
253 memset (ut->ut_name, 0, sizeof (ut->ut_name)); 244 memset (ut->ut_name, 0, sizeof (ut->ut_name));
254# ifdef HAVE_UTMP_HOST 245# ifdef HAVE_UTMP_HOST
255 memset (ut->ut_host, 0, sizeof (ut->ut_host)); 246 memset (ut->ut_host, 0, sizeof (ut->ut_host));
276 /* 267 /*
277 * Write ending wtmp entry 268 * Write ending wtmp entry
278 */ 269 */
279#ifdef WTMP_SUPPORT 270#ifdef WTMP_SUPPORT
280# ifdef WTMP_ONLY_ON_LOGIN 271# ifdef WTMP_ONLY_ON_LOGIN
281 if (OPTION (Opt_loginShell)) 272 if (login_shell)
282# endif 273# endif
283 { 274 {
284# ifdef HAVE_STRUCT_UTMP 275# ifdef HAVE_STRUCT_UTMP
285# ifdef HAVE_UPDWTMP 276# ifdef HAVE_UPDWTMP
286 updwtmp (RXVT_WTMP_FILE, ut); 277 updwtmp (RXVT_WTMP_FILE, ut);
287# else 278# else
288 rxvt_update_wtmp (RXVT_WTMP_FILE, ut); 279 rxvt_update_wtmp (RXVT_WTMP_FILE, ut);
289# endif 280# endif
290# endif 281# endif
291# ifdef HAVE_STRUCT_UTMPX 282# if defined(HAVE_STRUCT_UTMPX) && defined(HAVE_UPDWTMPX)
292# if HAVE_UPDWTMPX
293 updwtmpx (RXVT_WTMPX_FILE, utx); 283 updwtmpx (RXVT_WTMPX_FILE, utx);
294# else
295 pututxline (utx);
296# endif
297# endif 284# endif
298 } 285 }
299#endif 286#endif
300 287
301 /* 288 /*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines