X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=sys-utils%2Fctrlaltdel.c;h=1601154f858f7f3a5c3f67d1d4fe5f526c03789b;hb=HEAD;hp=6b3f38f561bf75912777d3b357d01ea047f6e756;hpb=d0983208a8e08b0286251f6aa762285e23fcdbc0;p=thirdparty%2Futil-linux.git diff --git a/sys-utils/ctrlaltdel.c b/sys-utils/ctrlaltdel.c index 6b3f38f561..1601154f85 100644 --- a/sys-utils/ctrlaltdel.c +++ b/sys-utils/ctrlaltdel.c @@ -1,10 +1,16 @@ /* - * ctrlaltdel.c - Set the function of the Ctrl-Alt-Del combination - * Created 4-Jul-92 by Peter Orbaek - * 1999-02-22 Arkadiusz Miśkiewicz - * - added Native Language Support + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Copyright (C) 1992 Peter Orbaek + * Copyright (C) 1992-1993 Rickard E. Faith + * + * Set the function of the Ctrl-Alt-Del combination */ - #include #include #include @@ -31,14 +37,17 @@ static void __attribute__((__noreturn__)) usage(void) fprintf(out, _("Set the function of the Ctrl-Alt-Del combination.\n")); fputs(USAGE_OPTIONS, out); - print_usage_help_options(16); + fprintf(out, USAGE_HELP_OPTIONS(16)); fprintf(out, USAGE_MAN_TAIL("ctrlaltdel(8)")); exit(EXIT_SUCCESS); } static int get_cad(void) { - uint64_t val = path_read_u64(_PATH_PROC_CTRL_ALT_DEL); + uint64_t val; + + if (ul_path_read_u64(NULL, &val, _PATH_PROC_CTRL_ALT_DEL) != 0) + err(EXIT_FAILURE, _("cannot read %s"), _PATH_PROC_CTRL_ALT_DEL); switch (val) { case 0: @@ -59,10 +68,6 @@ static int set_cad(const char *arg) { unsigned int cmd; - if (geteuid()) { - warnx(_("You must be root to set the Ctrl-Alt-Del behavior")); - return EXIT_FAILURE; - } if (!strcmp("hard", arg)) cmd = LINUX_REBOOT_CMD_CAD_ON; else if (!strcmp("soft", arg)) @@ -72,7 +77,7 @@ static int set_cad(const char *arg) return EXIT_FAILURE; } if (reboot(cmd) < 0) { - warnx("reboot"); + warn("reboot"); return EXIT_FAILURE; } return EXIT_SUCCESS; @@ -90,13 +95,12 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((ch = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1) switch (ch) { case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'h': usage(); default: