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.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;
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 *tmput, *ut = &this->ut;
239#endif 229#endif
240#ifdef HAVE_STRUCT_UTMPX 230#ifdef HAVE_STRUCT_UTMPX
241 struct utmpx *tmputx, *utx = &this->utx; 231 struct utmpx *tmputx, *utx = &this->utx;
242#endif 232#endif
243 233
245# ifdef HAVE_UTMP_PID 235# ifdef HAVE_UTMP_PID
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 {
251 struct utmp *tmput = getutid (ut);
252
253 if (tmput) /* position to entry in utmp file */ 240 if ((tmput = getutid (ut))) /* position to entry in utmp file */
254 ut = tmput; 241 ut = tmput;
255 }
256 ut->ut_type = DEAD_PROCESS; 242 ut->ut_type = DEAD_PROCESS;
257# else 243# else
258 memset (ut->ut_name, 0, sizeof (ut->ut_name)); 244 memset (ut->ut_name, 0, sizeof (ut->ut_name));
259# ifdef HAVE_UTMP_HOST 245# ifdef HAVE_UTMP_HOST
260 memset (ut->ut_host, 0, sizeof (ut->ut_host)); 246 memset (ut->ut_host, 0, sizeof (ut->ut_host));
281 /* 267 /*
282 * Write ending wtmp entry 268 * Write ending wtmp entry
283 */ 269 */
284#ifdef WTMP_SUPPORT 270#ifdef WTMP_SUPPORT
285# ifdef WTMP_ONLY_ON_LOGIN 271# ifdef WTMP_ONLY_ON_LOGIN
286 if (OPTION (Opt_loginShell)) 272 if (login_shell)
287# endif 273# endif
288 { 274 {
289# ifdef HAVE_STRUCT_UTMP 275# ifdef HAVE_STRUCT_UTMP
290# ifdef HAVE_UPDWTMP 276# ifdef HAVE_UPDWTMP
291 updwtmp (RXVT_WTMP_FILE, ut); 277 updwtmp (RXVT_WTMP_FILE, ut);
292# else 278# else
293 rxvt_update_wtmp (RXVT_WTMP_FILE, ut); 279 rxvt_update_wtmp (RXVT_WTMP_FILE, ut);
294# endif 280# endif
295# endif 281# endif
296# ifdef HAVE_STRUCT_UTMPX 282# if defined(HAVE_STRUCT_UTMPX) && defined(HAVE_UPDWTMPX)
297# if HAVE_UPDWTMPX
298 updwtmpx (RXVT_WTMPX_FILE, utx); 283 updwtmpx (RXVT_WTMPX_FILE, utx);
299# else
300 pututxline (utx);
301# endif
302# endif 284# endif
303 } 285 }
304#endif 286#endif
305 287
306 /* 288 /*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines