From b2f0faf04264c13d7877646330da7f5954380342 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 5 Apr 2010 19:27:41 +0200 Subject: libutil/login: was totally broken. fixed Also made login() and logout() usable with utmpname(non_std_utmp_file) text data bss dec hex filename 111 0 0 111 6f libutil/login.o 217 0 0 217 d9 libutil/login.o text data bss dec hex filename 164 0 0 164 a4 libutil/logout.o 134 0 0 134 86 libutil/logout.o Signed-off-by: Denys Vlasenko --- libutil/logout.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'libutil/logout.c') diff --git a/libutil/logout.c b/libutil/logout.c index e6d9565ab..5f58b8f42 100644 --- a/libutil/logout.c +++ b/libutil/logout.c @@ -29,9 +29,9 @@ logout (const char *line) struct utmp *ut; int result = 0; - /* Tell that we want to use the UTMP file. */ - if (utmpname (_PATH_UTMP) == -1) - return 0; + /* if (utmpname (_PATH_UTMP) == -1) return 0; - why? + * this makes it impossible for caller to use other file! + * Does any standard or historical precedent says this must be done? */ /* Open UTMP file. */ setutent (); @@ -43,7 +43,7 @@ logout (const char *line) strncpy (tmp.ut_line, line, sizeof tmp.ut_line); /* Read the record. */ - if( (ut = getutline(&tmp)) ) + if ((ut = getutline(&tmp)) != NULL) { /* Clear information about who & from where. */ memset (ut->ut_name, 0, sizeof ut->ut_name); @@ -54,12 +54,12 @@ logout (const char *line) # if !defined __WORDSIZE_COMPAT32 || __WORDSIZE_COMPAT32 == 0 gettimeofday (&ut->ut_tv, NULL); # else - { - struct timeval tv; - gettimeofday (&tv, NULL); - ut->ut_tv.tv_sec = tv.tv_sec; - ut->ut_tv.tv_usec = tv.tv_usec; - } + { + struct timeval tv; + gettimeofday (&tv, NULL); + ut->ut_tv.tv_sec = tv.tv_sec; + ut->ut_tv.tv_usec = tv.tv_usec; + } # endif #else time (&ut->ut_time); -- cgit v1.2.3