mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-10-12 01:26:48 +08:00
Write wtmp file if possible.
This commit is contained in:
+12
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user