summaryrefslogtreecommitdiffstats
path: root/sys-utils/ctrlaltdel.c
blob: e5565d70486d2b677abe8d0918c910344a43ab68 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * 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/
 */

#include <stdio.h>
#include <unistd.h>
#include <string.h>

int reboot(int magic, int magictoo, int flag);

int
main(int argc, char *argv[]) {

	if(geteuid()) {
		fprintf(stderr, "You must be root to set the Ctrl-Alt-Del behaviour.\n");
		exit(1);
	}

	if(argc == 2 && !strcmp("hard", argv[1])) {
		if(reboot(0xfee1dead, 672274793, 0x89abcdef) < 0) {
			perror("ctrlaltdel: reboot");
			exit(1);
		}
	} else if(argc == 2 && !strcmp("soft", argv[1])) {
		if(reboot(0xfee1dead, 672274793, 0) < 0) {
			perror("ctrlaltdel: reboot");
			exit(1);
		}
	} else {
		fprintf(stderr, "Usage: ctrlaltdel hard|soft\n");
		exit(1);
	}
	exit(0);
}