summaryrefslogtreecommitdiff
path: root/src/utmps/logwtmp.c
blob: 7294a7d4193c07f366172e4c4cc10cf8e0fcdbd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* ISC license. */

#include <unistd.h>
#include <string.h>
#include <skalibs/tai.h>
#include <utmps/utmpx.h>

void logwtmp (char const *line, char const *name, char const *host)
{
  struct utmpx b ;
  memset(&b, 0, sizeof(struct utmpx)) ;
  strncpy(b.ut_line, line, UTMPS_UT_LINESIZE - 1) ;
  strncpy(b.ut_user, name, UTMPS_UT_NAMESIZE - 1) ;
  strncpy(b.ut_host, host, UTMPS_UT_HOSTSIZE - 1) ;
  b.ut_pid = getpid() ;
  {
    tain now ;
    tain_wallclock_read(&now) ;
    timeval_from_tain(&b.ut_tv, &now) ;
  }
  updwtmpx("", &b) ;
}