mirror of
https://github.com/troglobit/finit.git
synced 2026-10-31 13:00:32 +00:00
Runtime detection of working UTMP/WTMP support in system
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
87f6769c51
commit
d9b705ab98
2 files changed
+12
No files matched your search
+11
@@ -30,6 +30,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <utmp.h>
|
||||||
#include <sys/sysinfo.h> /* sysinfo() */
|
#include <sys/sysinfo.h> /* sysinfo() */
|
||||||
#include <lite/lite.h> /* strlcat() */
|
#include <lite/lite.h> /* strlcat() */
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@@ -75,6 +76,16 @@ int echo(char *file, int append, char *fmt, ...)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* musl libc default to /dev/null/utmp and /dev/null/wtmp, respectively.
|
||||||
|
* See https://www.openwall.com/lists/musl/2012/03/04/4 for reasoning.
|
||||||
|
* Also, there's no __MUSL__, so we cannot make a libc-specific #ifdef
|
||||||
|
*/
|
||||||
|
int has_utmp(void)
|
||||||
|
{
|
||||||
|
return strncmp(_PATH_UTMP, "/dev/null", 9);
|
||||||
|
}
|
||||||
|
|
||||||
int strtobytes(char *arg)
|
int strtobytes(char *arg)
|
||||||
{
|
{
|
||||||
int mod = 0, bytes;
|
int mod = 0, bytes;
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ extern char *prognm;
|
|||||||
|
|
||||||
char *progname (char *arg0);
|
char *progname (char *arg0);
|
||||||
int echo (char *file, int append, char *fmt, ...);
|
int echo (char *file, int append, char *fmt, ...);
|
||||||
|
int has_utmp (void);
|
||||||
int strtobytes (char *arg);
|
int strtobytes (char *arg);
|
||||||
void do_sleep (unsigned int sec);
|
void do_sleep (unsigned int sec);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user