2006-12-06 17:25:32 -06:00
|
|
|
|
/*
|
|
|
|
|
* ctrlaltdel.c - Set the function of the Ctrl-Alt-Del combination
|
|
|
|
|
* Created 4-Jul-92 by Peter Orbaek <poe@daimi.aau.dk>
|
2006-12-06 17:25:46 -06:00
|
|
|
|
* 1999-02-22 Arkadiusz Mi<EFBFBD>kiewicz <misiek@pld.ORG.PL>
|
2006-12-06 17:25:39 -06:00
|
|
|
|
* - added Native Language Support
|
2006-12-06 17:25:32 -06:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2006-12-06 17:25:44 -06:00
|
|
|
|
#include <stdlib.h>
|
2006-12-06 17:25:32 -06:00
|
|
|
|
#include <string.h>
|
2010-10-17 04:01:22 -05:00
|
|
|
|
#include <errno.h>
|
2006-12-06 17:25:37 -06:00
|
|
|
|
#include "linux_reboot.h"
|
2006-12-06 17:25:39 -06:00
|
|
|
|
#include "nls.h"
|
2011-01-25 15:44:52 -06:00
|
|
|
|
#include "c.h"
|
2006-12-06 17:25:32 -06:00
|
|
|
|
|
2010-10-17 04:01:22 -05:00
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
2006-12-06 17:25:39 -06:00
|
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
|
|
|
textdomain(PACKAGE);
|
2006-12-06 17:25:32 -06:00
|
|
|
|
|
2010-10-17 04:01:22 -05:00
|
|
|
|
if (geteuid())
|
|
|
|
|
errx(EXIT_FAILURE,
|
|
|
|
|
_("You must be root to set the Ctrl-Alt-Del behaviour"));
|
2006-12-06 17:25:32 -06:00
|
|
|
|
|
2010-10-17 04:01:22 -05:00
|
|
|
|
if (argc == 2 && !strcmp("hard", argv[1])) {
|
|
|
|
|
if (my_reboot(LINUX_REBOOT_CMD_CAD_ON) < 0)
|
|
|
|
|
err(EXIT_FAILURE, "reboot");
|
|
|
|
|
} else if (argc == 2 && !strcmp("soft", argv[1])) {
|
|
|
|
|
if (my_reboot(LINUX_REBOOT_CMD_CAD_OFF) < 0)
|
|
|
|
|
err(EXIT_FAILURE, "reboot");
|
|
|
|
|
} else
|
|
|
|
|
errx(EXIT_FAILURE, _("Usage: %s hard|soft"),
|
|
|
|
|
program_invocation_short_name);
|
2006-12-06 17:25:32 -06:00
|
|
|
|
|
2010-10-17 04:01:22 -05:00
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
}
|