1 /* wtmp support rubbish (i.e. complete crap)
3 Written by Erik Andersen <andersee@debian.org>
5 The GNU C Library is free software
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
30 void logwtmp (const char *line, const char *name, const char *host)
33 memset (&(lutmp), 0, sizeof (struct utmp));
35 lutmp.ut_type = (name && *name)? USER_PROCESS : DEAD_PROCESS;
36 lutmp.ut_pid = getpid();
37 strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1);
38 strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1);
39 strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1);
40 #if __WORDSIZE_COMPAT32 == 0
41 gettimeofday(&(lutmp.ut_tv), NULL);
45 gettimeofday (&tv, NULL);
46 lutmp.ut_tv.tv_sec = tv.tv_sec;
47 lutmp.ut_tv.tv_usec = tv.tv_usec;
51 updwtmp(_PATH_WTMP, &(lutmp));
55 /* This is enabled in uClibc/libc/misc/utmp/wtent.c */
56 extern void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
60 fd = open(wtmp_file, O_APPEND | O_WRONLY, 0);
62 if (lockf(fd, F_LOCK, 0)==0) {
63 write(fd, (const char *) lutmp, sizeof(struct utmp));
64 lockf(fd, F_ULOCK, 0);