Avoid pulling in headers we don't need on Linux
For getutx?id(), call setutx?ent() first and always call endutx?ent().
This commit is contained in:
@@ -42,15 +42,15 @@
|
|||||||
#if TIME_WITH_SYS_TIME
|
#if TIME_WITH_SYS_TIME
|
||||||
# include <time.h>
|
# include <time.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_GETUTXID
|
#ifndef __linux__
|
||||||
# include <utmpx.h>
|
# if defined(HAVE_SYSCTL) && defined(KERN_BOOTTIME)
|
||||||
#endif
|
# include <sys/sysctl.h>
|
||||||
#ifdef HAVE_GETUTID
|
# elif defined(HAVE_GETUTXID)
|
||||||
# include <utmp.h>
|
# include <utmpx.h>
|
||||||
#endif
|
# elif defined(HAVE_GETUTID)
|
||||||
#ifdef HAVE_SYSCTL
|
# include <utmp.h>
|
||||||
# include <sys/sysctl.h>
|
# endif
|
||||||
#endif
|
#endif /* !__linux__ */
|
||||||
|
|
||||||
#include "missing.h"
|
#include "missing.h"
|
||||||
|
|
||||||
@@ -111,11 +111,12 @@ get_boottime(struct timeval *tv)
|
|||||||
|
|
||||||
memset(&key, 0, sizeof(key));
|
memset(&key, 0, sizeof(key));
|
||||||
key.ut_type = BOOT_TIME;
|
key.ut_type = BOOT_TIME;
|
||||||
|
setutxent();
|
||||||
if ((ut = getutxid(&key)) != NULL) {
|
if ((ut = getutxid(&key)) != NULL) {
|
||||||
tv->tv_sec = ut->ut_tv.tv_sec;
|
tv->tv_sec = ut->ut_tv.tv_sec;
|
||||||
tv->tv_usec = ut->ut_tv.tv_usec;
|
tv->tv_usec = ut->ut_tv.tv_usec;
|
||||||
endutxent();
|
|
||||||
}
|
}
|
||||||
|
endutxent();
|
||||||
return ut != NULL;
|
return ut != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,11 +129,12 @@ get_boottime(struct timeval *tv)
|
|||||||
|
|
||||||
memset(&key, 0, sizeof(key));
|
memset(&key, 0, sizeof(key));
|
||||||
key.ut_type = BOOT_TIME;
|
key.ut_type = BOOT_TIME;
|
||||||
|
setutent();
|
||||||
if ((ut = getutid(&key)) != NULL) {
|
if ((ut = getutid(&key)) != NULL) {
|
||||||
tv->tv_sec = ut->ut_time;
|
tv->tv_sec = ut->ut_time;
|
||||||
tv->tv_usec = 0;
|
tv->tv_usec = 0;
|
||||||
endutent();
|
|
||||||
}
|
}
|
||||||
|
endutent();
|
||||||
return ut != NULL;
|
return ut != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user