home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / slackwar / a / util / util-lin.2 / util-lin / util-linux-2.2 / sys-utils / ctrlaltdel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-22  |  807 b   |  39 lines

  1. /*
  2.  * ctrlaltdel.c - Set the function of the Ctrl-Alt-Del combination
  3.  * Created 4-Jul-92 by Peter Orbaek <poe@daimi.aau.dk>
  4.  * ftp://ftp.daimi.aau.dk/pub/linux/poe/
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <unistd.h>
  9. #include <string.h>
  10.  
  11. int reboot(int magic, int magictoo, int flag);
  12.  
  13. int
  14. main(int argc, char *argv[]) {
  15.  
  16.     if(geteuid()) {
  17.         fprintf(stderr, "You must be root to set the Ctrl-Alt-Del behaviour.\n");
  18.         exit(1);
  19.     }
  20.  
  21.     if(argc == 2 && !strcmp("hard", argv[1])) {
  22.         if(reboot(0xfee1dead, 672274793, 0x89abcdef) < 0) {
  23.             perror("ctrlaltdel: reboot");
  24.             exit(1);
  25.         }
  26.     } else if(argc == 2 && !strcmp("soft", argv[1])) {
  27.         if(reboot(0xfee1dead, 672274793, 0) < 0) {
  28.             perror("ctrlaltdel: reboot");
  29.             exit(1);
  30.         }
  31.     } else {
  32.         fprintf(stderr, "Usage: ctrlaltdel hard|soft\n");
  33.         exit(1);
  34.     }
  35.     exit(0);
  36. }
  37.  
  38.  
  39.