mirror of
https://github.com/troglobit/finit.git
synced 2026-11-19 19:40:50 +00:00
initctl: refactor has_utmp() capability check to use new cmd conds
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
5d08353284
commit
6a893f50ae
1 file changed
+8
-19
+8
-19
@@ -64,6 +64,7 @@ int plain = 0;
|
|||||||
int quiet = 0;
|
int quiet = 0;
|
||||||
int runlevel = 0;
|
int runlevel = 0;
|
||||||
int cgrp = 0;
|
int cgrp = 0;
|
||||||
|
int utmp = 0;
|
||||||
|
|
||||||
int iw, pw;
|
int iw, pw;
|
||||||
|
|
||||||
@@ -516,7 +517,7 @@ int utmp_show(char *file)
|
|||||||
|
|
||||||
static int do_utmp(char *file)
|
static int do_utmp(char *file)
|
||||||
{
|
{
|
||||||
if (!has_utmp())
|
if (!utmp)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (fexist(file))
|
if (fexist(file))
|
||||||
@@ -944,13 +945,11 @@ static int usage(int rc)
|
|||||||
" poweroff Halt and power off system\n"
|
" poweroff Halt and power off system\n"
|
||||||
" suspend Suspend system\n");
|
" suspend Suspend system\n");
|
||||||
|
|
||||||
if (has_utmp())
|
if (utmp)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"\n"
|
"\n"
|
||||||
" utmp show Raw dump of UTMP/WTMP db\n"
|
" utmp show Raw dump of UTMP/WTMP db\n");
|
||||||
"\n");
|
fprintf(stderr, "\n");
|
||||||
else
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -1069,7 +1068,7 @@ int main(int argc, char *argv[])
|
|||||||
{ "poweroff", NULL, do_poweroff, NULL },
|
{ "poweroff", NULL, do_poweroff, NULL },
|
||||||
{ "suspend", NULL, do_suspend, NULL },
|
{ "suspend", NULL, do_suspend, NULL },
|
||||||
|
|
||||||
{ "utmp", NULL, do_utmp, NULL },
|
{ "utmp", NULL, do_utmp, &utmp },
|
||||||
{ NULL, NULL, NULL, NULL }
|
{ NULL, NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
int interactive = 1, c;
|
int interactive = 1, c;
|
||||||
@@ -1077,8 +1076,9 @@ int main(int argc, char *argv[])
|
|||||||
if (transform(progname(argv[0])))
|
if (transform(progname(argv[0])))
|
||||||
return reboot_main(argc, argv);
|
return reboot_main(argc, argv);
|
||||||
|
|
||||||
/* Enable some functionality if kernel supports cgroups v2 */
|
/* Enable functionality depending on system capabilities */
|
||||||
cgrp = cgroup_avail();
|
cgrp = cgroup_avail();
|
||||||
|
utmp = has_utmp();
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "1bcdfh?pqtv", long_options, NULL)) != EOF) {
|
while ((c = getopt_long(argc, argv, "1bcdfh?pqtv", long_options, NULL)) != EOF) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
@@ -1127,17 +1127,6 @@ int main(int argc, char *argv[])
|
|||||||
if (interactive)
|
if (interactive)
|
||||||
ttinit();
|
ttinit();
|
||||||
|
|
||||||
if (!has_utmp()) {
|
|
||||||
/* system w/o utmp support, disable 'utmp' command */
|
|
||||||
for (c = 0; command[c].cmd; c++) {
|
|
||||||
if (!string_compare(command[c].cmd, "utmp"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
command[c].cb = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmd_parse(argc - optind, &argv[optind], command);
|
return cmd_parse(argc - optind, &argv[optind], command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user