mirror of
https://github.com/troglobit/finit.git
synced 2026-12-04 21:58:19 +00:00
initctl: drop utmp/wtmp functionality on systems w/o it (musl)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
c1e4c24136
commit
89a57054f5
1 file changed
+22
-6
+22
-6
@@ -133,9 +133,6 @@ static int do_log(char *svc)
|
|||||||
return system(cmd);
|
return system(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX: Convert to read UTMP instead, like runlevel(8) does
|
|
||||||
*/
|
|
||||||
static int do_runlevel(char *arg)
|
static int do_runlevel(char *arg)
|
||||||
{
|
{
|
||||||
struct init_request rq = {
|
struct init_request rq = {
|
||||||
@@ -407,6 +404,9 @@ int utmp_show(char *file)
|
|||||||
|
|
||||||
static int do_utmp(char *file)
|
static int do_utmp(char *file)
|
||||||
{
|
{
|
||||||
|
if (!has_utmp())
|
||||||
|
return 1;
|
||||||
|
|
||||||
if (fexist(file))
|
if (fexist(file))
|
||||||
return utmp_show(file);
|
return utmp_show(file);
|
||||||
|
|
||||||
@@ -464,7 +464,6 @@ static int show_status(char *arg)
|
|||||||
char ident[MAX_IDENT_LEN];
|
char ident[MAX_IDENT_LEN];
|
||||||
svc_t *svc;
|
svc_t *svc;
|
||||||
|
|
||||||
/* Fetch UTMP runlevel, needed for svc_status() call below */
|
|
||||||
runlevel = runlevel_get(NULL);
|
runlevel = runlevel_get(NULL);
|
||||||
|
|
||||||
if (arg && arg[0]) {
|
if (arg && arg[0]) {
|
||||||
@@ -642,10 +641,15 @@ static int usage(int rc)
|
|||||||
" runlevel [0-9] Show or set runlevel: 0 halt, 6 reboot\n"
|
" runlevel [0-9] Show or set runlevel: 0 halt, 6 reboot\n"
|
||||||
" reboot Reboot system\n"
|
" reboot Reboot system\n"
|
||||||
" halt Halt system\n"
|
" halt Halt system\n"
|
||||||
" poweroff Halt and power off system\n"
|
" poweroff Halt and power off system\n", prognm);
|
||||||
|
|
||||||
|
if (has_utmp())
|
||||||
|
fprintf(stderr,
|
||||||
"\n"
|
"\n"
|
||||||
" utmp show Raw dump of UTMP/WTMP db\n"
|
" utmp show Raw dump of UTMP/WTMP db\n"
|
||||||
"\n", prognm);
|
"\n");
|
||||||
|
else
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -730,6 +734,16 @@ int main(int argc, char *argv[])
|
|||||||
if (optind >= argc)
|
if (optind >= argc)
|
||||||
return show_status(NULL);
|
return show_status(NULL);
|
||||||
|
|
||||||
|
if (!has_utmp()) {
|
||||||
|
for (c = 0; command[c].cmd; c++) {
|
||||||
|
if (!string_compare(command[c].cmd, "utmp"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
command[c].cb = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
memset(arg, 0, sizeof(arg));
|
memset(arg, 0, sizeof(arg));
|
||||||
cmd = argv[optind++];
|
cmd = argv[optind++];
|
||||||
while (optind < argc) {
|
while (optind < argc) {
|
||||||
@@ -741,6 +755,8 @@ int main(int argc, char *argv[])
|
|||||||
for (c = 0; command[c].cmd; c++) {
|
for (c = 0; command[c].cmd; c++) {
|
||||||
if (!string_match(command[c].cmd, cmd))
|
if (!string_match(command[c].cmd, cmd))
|
||||||
continue;
|
continue;
|
||||||
|
if (!command[c].cb)
|
||||||
|
continue;
|
||||||
|
|
||||||
return command[c].cb(arg);
|
return command[c].cb(arg);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user