~ubuntu-branches/ubuntu/precise/apparmor/precise-security

« back to all changes in this revision

Viewing changes to .pc/0013-apparmor-lp800826.patch/libraries/libapparmor/testsuite/test_multi.c

  • Committer: Package Import Robot
  • Author(s): Steve Beattie, Jamie Strandboge, Serge Hallyn, Steve Beattie
  • Date: 2012-04-12 06:17:42 UTC
  • Revision ID: package-import@ubuntu.com-20120412061742-9v75hjko2mjtbewv
Tags: 2.7.102-0ubuntu3
[ Jamie Strandboge ]
* debian/patches/0007-ubuntu-manpage-updates.patch: update apparmor(5)
  to describe Ubuntu's two-stage policy load and how to add utilize it
  when developing policy (LP: #974089)

[ Serge Hallyn ]
* debian/apparmor.init: do nothing in a container.  This can be
  removed once stacked profiles are supported and used by lxc.
  (LP: #978297)

[ Steve Beattie ]
* debian/patches/0008-apparmor-lp963756.patch: Fix permission mapping
  for change_profile onexec (LP: #963756)
* debian/patches/0009-apparmor-lp959560-part1.patch,
  debian/patches/0010-apparmor-lp959560-part2.patch: Update the parser
  to support the 'in' keyword for value lists, and make mount
  operations aware of 'in' keyword so they can affect the flags build
  list (LP: #959560)
* debian/patches/0011-apparmor-lp872446.patch: fix logprof missing
  exec events in complain mode (LP: #872446)
* debian/patches/0012-apparmor-lp978584.patch: allow inet6 access in
  dovecot imap-login profile (LP: #978584)
* debian/patches/0013-apparmor-lp800826.patch: fix libapparmor
  log parsing library from dropping apparmor network events that
  contain ip addresses or ports in them (LP: #800826)
* debian/patches/0014-apparmor-lp979095.patch: document new mount rule
  syntax and usage in apparmor.d(5) manpage (LP: #979095)
* debian/patches/0015-apparmor-lp963756.patch: Fix change_onexec
  for profiles without attachment specification (LP: #963756,
  LP: #978038)
* debian/patches/0016-apparmor-lp968956.patch: Fix protocol error when
  loading policy to kernels without compat patches (LP: #968956)
* debian/patches/0017-apparmor-lp979135.patch: Fix change_profile to
  grant access to /proc/attr api (LP: #979135)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include <string.h>
 
4
#include <errno.h>
 
5
 
 
6
#include "aalogparse.h"
 
7
 
 
8
int print_results(aa_log_record *record);
 
9
 
 
10
int main(int argc, char **argv)
 
11
{
 
12
        FILE *testcase;
 
13
        char log_line[1024];
 
14
        aa_log_record *test = NULL;
 
15
        int ret = -1;
 
16
 
 
17
        if (argc != 2)
 
18
        {
 
19
                fprintf(stderr, "Usage: test_multi.multi <filename>\n");
 
20
                return(1);
 
21
        }
 
22
 
 
23
        printf("START\n");
 
24
        printf("File: %s\n", argv[1]);
 
25
 
 
26
        testcase = fopen(argv[1], "r");
 
27
        if (testcase == NULL)
 
28
        {
 
29
                perror("Could not open testcase: ");
 
30
                return(1);
 
31
        }
 
32
 
 
33
        if (fgets(log_line, 1023, testcase) == NULL)
 
34
        {
 
35
                fprintf(stderr, "Could not read testcase.\n");
 
36
                fclose(testcase);
 
37
                return(1);
 
38
        }
 
39
 
 
40
        fclose(testcase);
 
41
 
 
42
        test = parse_record(log_line);
 
43
 
 
44
        if (test == NULL)
 
45
        {
 
46
                fprintf(stderr,"Parsing failed.\n");
 
47
                return(1);
 
48
        }
 
49
        ret = print_results(test);
 
50
        free_record(test);
 
51
        return ret;
 
52
}
 
53
 
 
54
int print_results(aa_log_record *record)
 
55
{
 
56
                printf("Event type: ");
 
57
                switch(record->event)
 
58
                {
 
59
                        case AA_RECORD_ERROR:
 
60
                        {
 
61
                                printf("AA_RECORD_ERROR\n");
 
62
                                break;
 
63
                        }
 
64
                        case AA_RECORD_INVALID:
 
65
                        {
 
66
                                printf("AA_RECORD_INVALID\n");
 
67
                                break;
 
68
                        }
 
69
                        case AA_RECORD_AUDIT:
 
70
                        {
 
71
                                printf("AA_RECORD_AUDIT\n");
 
72
                                break;
 
73
                        }
 
74
                        case AA_RECORD_ALLOWED:
 
75
                        {
 
76
                                printf("AA_RECORD_ALLOWED\n");
 
77
                                break;
 
78
                        }
 
79
                        case AA_RECORD_DENIED:
 
80
                        {
 
81
                                printf("AA_RECORD_DENIED\n");
 
82
                                break;
 
83
                        }
 
84
                        case AA_RECORD_HINT:
 
85
                        {
 
86
                                printf("AA_RECORD_HINT\n");
 
87
                                break;
 
88
                        }
 
89
                        case AA_RECORD_STATUS:
 
90
                        {
 
91
                                printf("AA_RECORD_STATUS\n");
 
92
                                break;
 
93
                        }
 
94
                        default:
 
95
                        {
 
96
                                printf("UNKNOWN EVENT TYPE\n");
 
97
                                break;
 
98
                        }
 
99
                }
 
100
                if (record->audit_id != NULL)
 
101
                {
 
102
                        printf("Audit ID: %s\n", record->audit_id);
 
103
                }
 
104
                if (record->operation != NULL)
 
105
                {
 
106
                        printf("Operation: %s\n", record->operation);
 
107
                }
 
108
                if (record->requested_mask != NULL)
 
109
                {
 
110
                        printf("Mask: %s\n", record->requested_mask);
 
111
                }
 
112
                if (record->denied_mask != NULL)
 
113
                {
 
114
                        printf("Denied Mask: %s\n", record->denied_mask);
 
115
                }
 
116
                if (record->fsuid != (unsigned long) -1)
 
117
                {
 
118
                        printf("fsuid: %ld\n", record->fsuid);
 
119
                }
 
120
                if (record->ouid != (unsigned long) -1)
 
121
                {
 
122
                        printf("ouid: %ld\n", record->ouid);
 
123
                }
 
124
                if (record->profile != NULL)
 
125
                {
 
126
                        printf("Profile: %s\n", record->profile);
 
127
                }
 
128
                if (record->name != NULL)
 
129
                {
 
130
                        printf("Name: %s\n", record->name);
 
131
                }
 
132
                if (record->comm != NULL)
 
133
                {
 
134
                        printf("Command: %s\n", record->comm);
 
135
                }
 
136
                if (record->name2 != NULL)
 
137
                {
 
138
                        printf("Name2: %s\n", record->name2);
 
139
                }
 
140
                if (record->namespace != NULL)
 
141
                {
 
142
                        printf("Namespace: %s\n", record->namespace);
 
143
                }
 
144
                if (record->attribute != NULL)
 
145
                {
 
146
                        printf("Attribute: %s\n", record->attribute);
 
147
                }
 
148
                if (record->task != 0)
 
149
                {
 
150
                        printf("Task: %ld\n", record->task);
 
151
                }
 
152
                if (record->parent != 0)
 
153
                {
 
154
                        printf("Parent: %ld\n", record->parent);
 
155
                }
 
156
                if (record->magic_token != 0)
 
157
                {
 
158
                        printf("Token: %lu\n", record->magic_token);
 
159
                }
 
160
                if (record->info != NULL)
 
161
                {
 
162
                        printf("Info: %s\n", record->info);
 
163
                }
 
164
                if (record->error_code)
 
165
                {
 
166
                        printf("ErrorCode: %d\n", record->error_code);
 
167
                }
 
168
                if (record->pid != 0)
 
169
                {
 
170
                        printf("PID: %ld\n", record->pid);
 
171
                }
 
172
                if (record->active_hat != NULL)
 
173
                {
 
174
                        printf("Active hat: %s\n", record->active_hat);
 
175
                }
 
176
                if (record->net_family != NULL)
 
177
                {
 
178
                        printf("Network family: %s\n", record->net_family);
 
179
                }
 
180
                if (record->net_sock_type != NULL)
 
181
                {
 
182
                        printf("Socket type: %s\n", record->net_sock_type);
 
183
                }
 
184
                if (record->net_protocol != NULL)
 
185
                {
 
186
                        printf("Protocol: %s\n", record->net_protocol);
 
187
                }
 
188
                printf("Epoch: %lu\n", record->epoch);
 
189
                printf("Audit subid: %u\n", record->audit_sub_id);
 
190
        return(0);
 
191
}