Write wtmp file if possible.

This commit is contained in:
Nikos Mavrogiannopoulos
2013-02-10 13:35:50 +01:00
parent 3784aa6ddc
commit db9f441e6e
+12 -1
View File
@@ -175,6 +175,10 @@ add_utmp_entry(main_server_st *s, struct proc_st* proc, struct lease_st* lease)
setutxent();
pututxline(&entry);
endutxent();
#if defined(WTMPX_FILE)
updwtmpx(WTMPX_FILE, &entry);
#endif
return;
#endif
@@ -184,6 +188,7 @@ static void remove_utmp_entry(main_server_st *s, struct proc_st* proc)
{
#ifdef HAVE_LIBUTIL
struct utmpx entry;
struct timespec tv;
if (s->config->use_utmp == 0)
return;
@@ -193,11 +198,17 @@ static void remove_utmp_entry(main_server_st *s, struct proc_st* proc)
if (proc->lease && proc->lease->name)
snprintf(entry.ut_line, sizeof(entry.ut_line), "%s", proc->lease->name);
entry.ut_pid = proc->pid;
gettime(&tv);
entry.ut_tv.tv_sec = tv.tv_sec;
entry.ut_tv.tv_usec = tv.tv_nsec / 1000;
setutxent();
pututxline(&entry);
endutxent();
#if defined(WTMPX_FILE)
updwtmpx(WTMPX_FILE, &entry);
#endif
return;
#endif
}