util-linux/sys-utils/ctrlaltdel.c

49 lines
1009 B
C
Raw Normal View History

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>
* ftp://ftp.daimi.aau.dk/pub/linux/poe/
* 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>
#include <unistd.h>
#include <stdlib.h>
2006-12-06 17:25:32 -06:00
#include <string.h>
2006-12-06 17:25:37 -06:00
#include "linux_reboot.h"
2006-12-06 17:25:39 -06:00
#include "nls.h"
2006-12-06 17:25:32 -06: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
if(geteuid()) {
2006-12-06 17:25:37 -06:00
fprintf(stderr,
2006-12-06 17:25:39 -06:00
_("You must be root to set the Ctrl-Alt-Del behaviour.\n"));
2006-12-06 17:25:32 -06:00
exit(1);
}
if(argc == 2 && !strcmp("hard", argv[1])) {
2006-12-06 17:25:37 -06:00
if(my_reboot(LINUX_REBOOT_CMD_CAD_ON) < 0) {
2006-12-06 17:25:32 -06:00
perror("ctrlaltdel: reboot");
exit(1);
}
} else if(argc == 2 && !strcmp("soft", argv[1])) {
2006-12-06 17:25:37 -06:00
if(my_reboot(LINUX_REBOOT_CMD_CAD_OFF) < 0) {
2006-12-06 17:25:32 -06:00
perror("ctrlaltdel: reboot");
exit(1);
}
} else {
2006-12-06 17:25:39 -06:00
fprintf(stderr, _("Usage: ctrlaltdel hard|soft\n"));
2006-12-06 17:25:32 -06:00
exit(1);
}
exit(0);
}