diff options
Diffstat (limited to 'login')
-rw-r--r-- | login/getutid_r.c | 5 | ||||
-rw-r--r-- | login/getutmp.c | 12 | ||||
-rw-r--r-- | login/getutmpx.c | 13 | ||||
-rw-r--r-- | login/login.c | 4 | ||||
-rw-r--r-- | login/logout.c | 10 | ||||
-rw-r--r-- | login/logwtmp.c | 10 | ||||
-rw-r--r-- | login/programs/utmpdump.c | 46 | ||||
-rw-r--r-- | login/tst-utmp.c | 25 | ||||
-rw-r--r-- | login/utmp_file.c | 26 |
9 files changed, 10 insertions, 141 deletions
diff --git a/login/getutid_r.c b/login/getutid_r.c index 86ffc85..460d94b 100644 --- a/login/getutid_r.c +++ b/login/getutid_r.c @@ -32,7 +32,6 @@ __libc_lock_define (extern, __libc_utmp_lock attribute_hidden) int __getutid_r (const struct utmp *id, struct utmp *buffer, struct utmp **result) { -#if (_HAVE_UT_ID - 0) && (_HAVE_UT_TYPE - 0) int retval; /* Test whether ID has any of the legal types. */ @@ -54,10 +53,6 @@ __getutid_r (const struct utmp *id, struct utmp *buffer, struct utmp **result) __libc_lock_unlock (__libc_utmp_lock); return retval; -#else /* !_HAVE_UT_ID && !_HAVE_UT_TYPE */ - __set_errno (ENOSYS); - return -1; -#endif } libc_hidden_def (__getutid_r) weak_alias (__getutid_r, getutid_r) diff --git a/login/getutmp.c b/login/getutmp.c index 73bc15d..4e3be11 100644 --- a/login/getutmp.c +++ b/login/getutmp.c @@ -23,23 +23,11 @@ void getutmp (const struct utmpx *utmpx, struct utmp *utmp) { -#if _HAVE_UT_TYPE - 0 utmp->ut_type = utmpx->ut_type; -#endif -#if _HAVE_UT_PID - 0 utmp->ut_pid = utmpx->ut_pid; -#endif memcpy (utmp->ut_line, utmpx->ut_line, sizeof (utmp->ut_line)); memcpy (utmp->ut_user, utmpx->ut_user, sizeof (utmp->ut_user)); -#if _HAVE_UT_ID - 0 memcpy (utmp->ut_id, utmpx->ut_id, sizeof (utmp->ut_id)); -#endif -#if _HAVE_UT_HOST - 0 memcpy (utmp->ut_host, utmpx->ut_host, sizeof (utmp->ut_host)); -#endif -#if _HAVE_UT_TV - 0 utmp->ut_tv = utmpx->ut_tv; -#else - utmp->ut_time = utmpx->ut_time; -#endif } diff --git a/login/getutmpx.c b/login/getutmpx.c index b181d9b..da28d33 100644 --- a/login/getutmpx.c +++ b/login/getutmpx.c @@ -24,24 +24,11 @@ void getutmpx (const struct utmp *utmp, struct utmpx *utmpx) { memset (utmpx, 0, sizeof (struct utmpx)); - -#if _HAVE_UT_TYPE - 0 utmpx->ut_type = utmp->ut_type; -#endif -#if _HAVE_UT_PID - 0 utmpx->ut_pid = utmp->ut_pid; -#endif memcpy (utmpx->ut_line, utmp->ut_line, sizeof (utmp->ut_line)); memcpy (utmpx->ut_user, utmp->ut_user, sizeof (utmp->ut_user)); -#if _HAVE_UT_ID - 0 memcpy (utmpx->ut_id, utmp->ut_id, sizeof (utmp->ut_id)); -#endif -#if _HAVE_UT_HOST - 0 memcpy (utmpx->ut_host, utmp->ut_host, sizeof (utmp->ut_host)); -#endif -#if _HAVE_UT_TV - 0 utmpx->ut_tv = utmp->ut_tv; -#else - utmpx->ut_time = utmp->ut_time; -#endif } diff --git a/login/login.c b/login/login.c index 09ef3f7..b7d638c 100644 --- a/login/login.c +++ b/login/login.c @@ -91,12 +91,8 @@ login (const struct utmp *ut) struct utmp copy = *ut; /* Fill in those fields we supply. */ -#if _HAVE_UT_TYPE - 0 copy.ut_type = USER_PROCESS; -#endif -#if _HAVE_UT_PID - 0 copy.ut_pid = getpid (); -#endif /* Seek tty. */ found_tty = tty_name (STDIN_FILENO, &tty, sizeof (_tty)); diff --git a/login/logout.c b/login/logout.c index 85254d0..5015c1a 100644 --- a/login/logout.c +++ b/login/logout.c @@ -36,9 +36,7 @@ logout (const char *line) setutent (); /* Fill in search information. */ -#if _HAVE_UT_TYPE - 0 tmp.ut_type = USER_PROCESS; -#endif strncpy (tmp.ut_line, line, sizeof tmp.ut_line); /* Read the record. */ @@ -46,20 +44,12 @@ logout (const char *line) { /* Clear information about who & from where. */ memset (ut->ut_name, '\0', sizeof ut->ut_name); -#if _HAVE_UT_HOST - 0 memset (ut->ut_host, '\0', sizeof ut->ut_host); -#endif -#if _HAVE_UT_TV - 0 struct timeval tv; __gettimeofday (&tv, NULL); ut->ut_tv.tv_sec = tv.tv_sec; ut->ut_tv.tv_usec = tv.tv_usec; -#else - ut->ut_time = time (NULL); -#endif -#if _HAVE_UT_TYPE - 0 ut->ut_type = DEAD_PROCESS; -#endif if (pututline (ut) != NULL) result = 1; diff --git a/login/logwtmp.c b/login/logwtmp.c index f531871..50d1497 100644 --- a/login/logwtmp.c +++ b/login/logwtmp.c @@ -30,26 +30,16 @@ logwtmp (const char *line, const char *name, const char *host) /* Set information in new entry. */ memset (&ut, 0, sizeof (ut)); -#if _HAVE_UT_PID - 0 ut.ut_pid = getpid (); -#endif -#if _HAVE_UT_TYPE - 0 ut.ut_type = name[0] ? USER_PROCESS : DEAD_PROCESS; -#endif strncpy (ut.ut_line, line, sizeof ut.ut_line); strncpy (ut.ut_name, name, sizeof ut.ut_name); -#if _HAVE_UT_HOST - 0 strncpy (ut.ut_host, host, sizeof ut.ut_host); -#endif -#if _HAVE_UT_TV - 0 struct timeval tv; __gettimeofday (&tv, NULL); ut.ut_tv.tv_sec = tv.tv_sec; ut.ut_tv.tv_usec = tv.tv_usec; -#else - ut.ut_time = time (NULL); -#endif updwtmp (_PATH_WTMP, &ut); } diff --git a/login/programs/utmpdump.c b/login/programs/utmpdump.c index 4c312f0..85d8e31 100644 --- a/login/programs/utmpdump.c +++ b/login/programs/utmpdump.c @@ -37,47 +37,11 @@ print_entry (struct utmp *up) temp_tv.tv_sec = up->ut_tv.tv_sec; temp_tv.tv_usec = up->ut_tv.tv_usec; - (printf) ( - /* The format string. */ -#if _HAVE_UT_TYPE - "[%d] " -#endif -#if _HAVE_UT_PID - "[%05d] " -#endif -#if _HAVE_UT_ID - "[%-4.4s] " -#endif - "[%-8.8s] [%-12.12s]" -#if _HAVE_UT_HOST - " [%-16.16s]" -#endif - " [%-15.15s]" -#if _HAVE_UT_TV - " [%ld]" -#endif - "\n" - /* The arguments. */ -#if _HAVE_UT_TYPE - , up->ut_type -#endif -#if _HAVE_UT_PID - , up->ut_pid -#endif -#if _HAVE_UT_ID - , up->ut_id -#endif - , up->ut_user, up->ut_line -#if _HAVE_UT_HOST - , up->ut_host -#endif -#if _HAVE_UT_TV - , 4 + ctime (&temp_tv.tv_sec) - , (long int) temp_tv.tv_usec -#else - , 4 + ctime (&up->ut_time) -#endif - ); + printf ("[%d] [%05d] [%-4.4s] [%-8.8s] [%-12.12s] [%-16.16s] [%-15.15s]" + " [%ld]\n", + up->ut_type, up->ut_pid, up->ut_id, up->ut_user, up->ut_line, + up->ut_host, 4 + ctime (&temp_tv.tv_sec), + (long int) temp_tv.tv_usec); } int diff --git a/login/tst-utmp.c b/login/tst-utmp.c index ce48e83..02d0c1f 100644 --- a/login/tst-utmp.c +++ b/login/tst-utmp.c @@ -39,8 +39,6 @@ #endif -#if defined UTMPX || _HAVE_UT_TYPE - /* Prototype for our test function. */ static int do_test (int argc, char *argv[]); @@ -75,11 +73,7 @@ do_prepare (int argc, char *argv[]) struct utmp entry[] = { -#if defined UTMPX || _HAVE_UT_TV #define UT(a) .ut_tv = { .tv_sec = (a)} -#else -#define UT(a) .ut_time = (a) -#endif { .ut_type = BOOT_TIME, .ut_pid = 1, UT(1000) }, { .ut_type = RUN_LVL, .ut_pid = 1, UT(2000) }, @@ -167,11 +161,7 @@ simulate_login (const char *line, const char *user) entry[n].ut_pid = (entry_pid += 27); entry[n].ut_type = USER_PROCESS; strncpy (entry[n].ut_user, user, sizeof (entry[n].ut_user)); -#if defined UTMPX || _HAVE_UT_TV - 0 entry[n].ut_tv.tv_sec = (entry_time += 1000); -#else - entry[n].ut_time = (entry_time += 1000); -#endif setutent (); if (pututline (&entry[n]) == NULL) @@ -201,11 +191,7 @@ simulate_logout (const char *line) { entry[n].ut_type = DEAD_PROCESS; strncpy (entry[n].ut_user, "", sizeof (entry[n].ut_user)); -#if defined UTMPX || _HAVE_UT_TV - 0 entry[n].ut_tv.tv_sec = (entry_time += 1000); -#else - entry[n].ut_time = (entry_time += 1000); -#endif setutent (); if (pututline (&entry[n]) == NULL) @@ -390,14 +376,3 @@ do_test (int argc, char *argv[]) return result; } - -#else - -/* No field 'ut_type' in struct utmp. */ -int -main (void) -{ - return 0; -} - -#endif diff --git a/login/utmp_file.c b/login/utmp_file.c index cb8a028..9badf11 100644 --- a/login/utmp_file.c +++ b/login/utmp_file.c @@ -129,14 +129,7 @@ __libc_setutent (void) file_offset = 0; /* Make sure the entry won't match. */ -#if _HAVE_UT_TYPE - 0 last_entry.ut_type = -1; -#else - last_entry.ut_line[0] = '\177'; -# if _HAVE_UT_ID - 0 - last_entry.ut_id[0] = '\0'; -# endif -#endif return 1; } @@ -201,7 +194,6 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer, LOCKING_FAILED (); } -#if _HAVE_UT_TYPE - 0 if (id->ut_type == RUN_LVL || id->ut_type == BOOT_TIME || id->ut_type == OLD_TIME || id->ut_type == NEW_TIME) { @@ -225,7 +217,6 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer, } } else -#endif /* _HAVE_UT_TYPE */ { /* Search for the next entry with the specified ID and with type INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS, or DEAD_PROCESS. */ @@ -316,13 +307,10 @@ __libc_getutline_r (const struct utmp *line, struct utmp *buffer, file_offset += sizeof (struct utmp); /* Stop if we found a user or login entry. */ - if ( -#if _HAVE_UT_TYPE - 0 - (last_entry.ut_type == USER_PROCESS + if ((last_entry.ut_type == USER_PROCESS || last_entry.ut_type == LOGIN_PROCESS) - && -#endif - !strncmp (line->ut_line, last_entry.ut_line, sizeof line->ut_line)) + && (strncmp (line->ut_line, last_entry.ut_line, sizeof line->ut_line) + == 0)) break; } @@ -368,16 +356,12 @@ __libc_pututline (const struct utmp *data) /* Find the correct place to insert the data. */ if (file_offset > 0 - && ( -#if _HAVE_UT_TYPE - 0 - (last_entry.ut_type == data->ut_type + && ((last_entry.ut_type == data->ut_type && (last_entry.ut_type == RUN_LVL || last_entry.ut_type == BOOT_TIME || last_entry.ut_type == OLD_TIME || last_entry.ut_type == NEW_TIME)) - || -#endif - __utmp_equal (&last_entry, data))) + || __utmp_equal (&last_entry, data))) found = 1; else { |