~ubuntu-branches/ubuntu/oneiric/apparmor/oneiric-security

« back to all changes in this revision

Viewing changes to tests/regression/apparmor/syscall_query_module.c

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2011-04-27 10:38:07 UTC
  • mfrom: (5.1.118 natty)
  • Revision ID: james.westby@ubuntu.com-20110427103807-ym3rhwys6o84ith0
Tags: 2.6.1-2
debian/copyright: clarify for some full organization names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *      Copyright (C) 2002-2005 Novell/SUSE
 
3
 *
 
4
 *      This program is free software; you can redistribute it and/or
 
5
 *      modify it under the terms of the GNU General Public License as
 
6
 *      published by the Free Software Foundation, version 2 of the
 
7
 *      License.
 
8
 */
 
9
 
 
10
#include <stdio.h>
 
11
#include <unistd.h>
 
12
#include <errno.h>
 
13
#include <sys/types.h>
 
14
#include <linux/module.h>
 
15
 
 
16
#define BUFSIZE 4096
 
17
int main(int argc, char *argv[])
 
18
{
 
19
        char buffer[BUFSIZE];
 
20
        size_t ret = 0;
 
21
        struct module_info modinfo;
 
22
        
 
23
        if (argc > 2) {
 
24
                fprintf(stderr, "Usage: %s [module]\n",
 
25
                        argv[0]);
 
26
                return 1;
 
27
        } else if (argc == 1) {
 
28
                if (query_module(NULL, QM_MODULES, &buffer, BUFSIZE,
 
29
                                &ret) == -1) {
 
30
                        fprintf(stderr, "FAIL: query_module failed - %s\n",
 
31
                                strerror(errno));
 
32
                        return 1;
 
33
                }
 
34
                /* printf ("First module: %s\n", buffer); */
 
35
        } else {
 
36
                if (query_module(argv[1], QM_INFO, &modinfo, sizeof(modinfo),
 
37
                                &ret) == -1) {
 
38
                        fprintf(stderr, "FAIL: query_module failed - %s\n",
 
39
                                strerror(errno));
 
40
                        return 1;
 
41
                }
 
42
                /* printf ("module %s info: address 0x%8x size %u flags 0x%8x "
 
43
                                "usecount %d\n", 
 
44
                                argv[1],
 
45
                                modinfo.addr,
 
46
                                modinfo.size,
 
47
                                modinfo.flags,
 
48
                                modinfo.usecount); */
 
49
        }
 
50
 
 
51
        /* printf("Kernel release version is %s\n", release); */
 
52
        printf("PASS\n");
 
53
 
 
54
        return 0;
 
55
}