~ubuntu-branches/ubuntu/raring/apparmor/raring

« back to all changes in this revision

Viewing changes to tests/regression/subdomain/syscall_reboot.c

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-03-23 16:42:01 UTC
  • Revision ID: james.westby@ubuntu.com-20070323164201-jkax6f0oku087b7l
Tags: upstream-2.0.1+510.dfsg
ImportĀ upstreamĀ versionĀ 2.0.1+510.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: syscall_reboot.c 61 2006-05-19 18:32:14Z steve-beattie $ */
 
2
 
 
3
/*
 
4
 *      Copyright (C) 2002-2005 Novell/SUSE
 
5
 *
 
6
 *      This program is free software; you can redistribute it and/or
 
7
 *      modify it under the terms of the GNU General Public License as
 
8
 *      published by the Free Software Foundation, version 2 of the
 
9
 *      License.
 
10
 */
 
11
 
 
12
#include <stdio.h>
 
13
#include <unistd.h>
 
14
#include <errno.h>
 
15
#include <sys/types.h>
 
16
#include <sys/reboot.h>
 
17
#include <string.h>
 
18
 
 
19
int main(int argc, char *argv[])
 
20
{
 
21
        int cmd = RB_ENABLE_CAD;
 
22
        
 
23
        if (argc != 2) {
 
24
                fprintf(stderr, "Usage %s [on|off|reboot]\n", argv[0]);
 
25
                return 1;
 
26
        }
 
27
 
 
28
        if (strcmp(argv[1], "off") == 0) 
 
29
                cmd = RB_DISABLE_CAD;
 
30
        else if (strcmp(argv[1], "on") == 0) 
 
31
                /* dangerous, a CAD will do a forced reboot (no shutdown) */
 
32
                cmd = RB_ENABLE_CAD;
 
33
        else if (strcmp(argv[1], "reboot") == 0) 
 
34
                /* Aiieee, you could lose data if you do this */
 
35
                cmd = RB_AUTOBOOT;
 
36
        else {
 
37
                fprintf(stderr, "Usage %s [on|off|reboot]\n", argv[0]);
 
38
                return 1;
 
39
        }
 
40
                
 
41
        if (reboot(cmd) == -1){
 
42
                fprintf(stderr, "FAIL: reboot failed - %s\n",
 
43
                        strerror(errno));
 
44
                return 1;
 
45
        }
 
46
 
 
47
        printf("PASS\n");
 
48
 
 
49
        return 0;
 
50
}