diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2004-09-10 08:30:51 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2004-09-10 08:30:51 +0000 |
commit | 4875a4b66eabdfee2d9186a694ea3599f19a51ed (patch) | |
tree | f68131ab196d3e317afa66c7dd0319a05eae1ad4 /winsup/cygwin/libc/bsdlib.cc | |
parent | 04d55823da83da01d25876c8f0e14cea948e2eeb (diff) | |
download | cygnal-4875a4b66eabdfee2d9186a694ea3599f19a51ed.tar.gz cygnal-4875a4b66eabdfee2d9186a694ea3599f19a51ed.tar.bz2 cygnal-4875a4b66eabdfee2d9186a694ea3599f19a51ed.zip |
* Makefile.in: Create libutil.a from bsdlib.o exports.
* bsdlib.cc (logwtmp): Move from syscalls.cc to here.
(login): Ditto.
(logout): Ditto.
* winsup.h (EXPORT_ALIAS): New macro.
* exec.cc: Define alias symbols using EXPORT_ALIAS macro.
* syscalls.cc: Ditto.
* times.cc: Ditto.
Diffstat (limited to 'winsup/cygwin/libc/bsdlib.cc')
-rw-r--r-- | winsup/cygwin/libc/bsdlib.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/winsup/cygwin/libc/bsdlib.cc b/winsup/cygwin/libc/bsdlib.cc index 71393fb87..c25163e2e 100644 --- a/winsup/cygwin/libc/bsdlib.cc +++ b/winsup/cygwin/libc/bsdlib.cc @@ -260,3 +260,52 @@ setprogname (const char *newprogname) __progname = (char *)newprogname; } } + +extern "C" void +logwtmp (const char *line, const char *user, const char *host) +{ + struct utmp ut; + memset (&ut, 0, sizeof ut); + ut.ut_type = USER_PROCESS; + ut.ut_pid = getpid (); + if (line) + strncpy (ut.ut_line, line, sizeof ut.ut_line); + time (&ut.ut_time); + if (user) + strncpy (ut.ut_user, user, sizeof ut.ut_user); + if (host) + strncpy (ut.ut_host, host, sizeof ut.ut_host); + updwtmp (_PATH_WTMP, &ut); +} + +extern "C" void +login (struct utmp *ut) +{ + pututline (ut); + endutent (); + updwtmp (_PATH_WTMP, ut); +} + +extern "C" int +logout (char *line) +{ + struct utmp ut_buf, *ut; + + memset (&ut_buf, 0, sizeof ut_buf); + strncpy (ut_buf.ut_line, line, sizeof ut_buf.ut_line); + setutent (); + ut = getutline (&ut_buf); + + if (ut) + { + ut->ut_type = DEAD_PROCESS; + memset (ut->ut_user, 0, sizeof ut->ut_user); + memset (ut->ut_host, 0, sizeof ut->ut_host); + time (&ut->ut_time); + debug_printf ("set logout time for %s", line); + pututline (ut); + endutent (); + return 1; + } + return 0; +} |