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

« back to all changes in this revision

Viewing changes to .pc/0013-apparmor-lp800826.patch/libraries/libapparmor/src/aalogparse.h

  • 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
/*
 
2
 * Copyright (c) 1999-2008 NOVELL (All rights reserved)
 
3
 * Copyright 2009-2010 Canonical Ltd.
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of version 2.1 of the GNU Lesser General
 
7
 * Public License published by the Free Software Foundation.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public License
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 */
 
17
 
 
18
 
 
19
#ifndef __LIBAALOGPARSE_H_
 
20
#define __LIBAALOGPARSE_H_
 
21
 
 
22
#define AA_RECORD_EXEC_MMAP     1
 
23
#define AA_RECORD_READ          2
 
24
#define AA_RECORD_WRITE         4
 
25
#define AA_RECORD_EXEC          8
 
26
#define AA_RECORD_LINK          16
 
27
 
 
28
/**
 
29
 * This is just for convenience now that we have two 
 
30
 * wildly different grammars.
 
31
 */
 
32
 
 
33
typedef enum
 
34
{
 
35
        AA_RECORD_SYNTAX_V1,
 
36
        AA_RECORD_SYNTAX_V2,
 
37
        AA_RECORD_SYNTAX_UNKNOWN
 
38
} aa_record_syntax_version;
 
39
 
 
40
typedef enum
 
41
{
 
42
        AA_RECORD_INVALID,      /* Default event type */
 
43
        AA_RECORD_ERROR,        /* Internal AA error */
 
44
        AA_RECORD_AUDIT,        /* Audited event */
 
45
        AA_RECORD_ALLOWED,      /* Complain mode event */
 
46
        AA_RECORD_DENIED,       /* Denied access event */
 
47
        AA_RECORD_HINT,         /* Process tracking info */
 
48
        AA_RECORD_STATUS        /* Configuration change */
 
49
} aa_record_event_type;
 
50
 
 
51
/**
 
52
 * With the sole exception of active_hat, this is a 1:1
 
53
 * mapping from the keys that the new syntax uses.
 
54
 *
 
55
 * Some examples of the old syntax and how they're mapped with the aa_log_record struct:
 
56
 *
 
57
 * "PERMITTING r access to /path (program_name(12345) profile /profile active hat)"
 
58
 * - operation: access
 
59
 * - requested_mask: r
 
60
 * - pid: 12345
 
61
 * - profile: /profile
 
62
 * - name: /path
 
63
 * - info: program_name
 
64
 * - active_hat: hat
 
65
 *
 
66
 * "REJECTING mkdir on /path/to/something (bash(23415) profile /bin/freak-aa-out active /bin/freak-aa-out"
 
67
 * - operation: mkdir
 
68
 * - name: /path/to/something
 
69
 * - info: bash
 
70
 * - pid: 23415
 
71
 * - profile: /bin/freak-aa-out 
 
72
 * - active_hat: /bin/freak-aa-out 
 
73
 * 
 
74
 * "REJECTING xattr set on /path/to/something (bash(23415) profile /bin/freak-aa-out active /bin/freak-aa-out)"
 
75
 * - operation: xattr
 
76
 * - attribute: set
 
77
 * - name: /path/to/something
 
78
 * - info: bash
 
79
 * - pid: 23415
 
80
 * - profile: /bin/freak-aa-out
 
81
 * - active_hat: /bin/freak-aa-out
 
82
 *
 
83
 * "PERMITTING attribute (something) change to /else (bash(23415) profile /bin/freak-aa-out active /bin/freak-aa-out)"
 
84
 * - operation: setattr
 
85
 * - attribute: something
 
86
 * - name: /else
 
87
 * - info: bash
 
88
 * - pid: 23415
 
89
 * - profile: /bin/freak-aa-out
 
90
 * - active_hat: /bin/freak-aa-out
 
91
 * 
 
92
 * "PERMITTING access to capability 'cap' (bash(23415) profile /bin/freak-aa-out active /bin/freak-aa-out)"
 
93
 * - operation: capability
 
94
 * - name: cap
 
95
 * - info: bash
 
96
 * - pid: 23415
 
97
 * - profile: /bin/freak-aa-out
 
98
 * - active_hat: /bin/freak-aa-out
 
99
 * 
 
100
 * "LOGPROF-HINT unknown_hat TESTHAT pid=27764 profile=/change_hat_test/test_hat active=/change_hat_test/test_hat"
 
101
 * - operation: change_hat
 
102
 * - name: TESTHAT
 
103
 * - info: unknown_hat
 
104
 * - pid: 27764
 
105
 * - profile: /change_hat_test/test_hat
 
106
 * - active_hat: /change_hat_test/test_hat
 
107
 *
 
108
 * "LOGPROF-HINT fork pid=27764 child=38229"
 
109
 * - operation: clone
 
110
 * - task: 38229
 
111
 * - pid: 27764
 
112
 **/
 
113
 
 
114
typedef struct
 
115
{
 
116
        aa_record_syntax_version version;
 
117
        aa_record_event_type event;     /* Event type */
 
118
        unsigned long pid;              /* PID of the program logging the message */
 
119
        unsigned long task;
 
120
        unsigned long magic_token;
 
121
        long epoch;                     /* example: 12345679 */
 
122
        unsigned int audit_sub_id;      /* example: 12 */
 
123
 
 
124
        int bitmask;                    /* Bitmask containing "r" "w" "x" etc */
 
125
        char *audit_id;                 /* example: 12345679.1234:12 */
 
126
        char *operation;                /* "Exec" "Ptrace", etc. */
 
127
        char *denied_mask;              /* "r", "w", etc. */
 
128
        char *requested_mask;
 
129
        unsigned long fsuid;            /* fsuid of task - if logged */
 
130
        unsigned long ouid;             /* ouid of task - if logged */
 
131
        char *profile;                  /* The name of the profile */
 
132
        char *comm;                     /* Command that triggered msg */
 
133
        char *name;
 
134
        char *name2;
 
135
        char *namespace;
 
136
        char *attribute;
 
137
        unsigned long parent;   
 
138
        char *info;
 
139
        int error_code;                 /* error_code returned if logged */
 
140
        char *active_hat;
 
141
        char *net_family;
 
142
        char *net_protocol;
 
143
        char *net_sock_type;
 
144
} aa_log_record;
 
145
 
 
146
/**
 
147
 * Parses a single log record string and returns a pointer to the parsed
 
148
 * data.  It is the calling program's responsibility to free that struct
 
149
 * with free_record();
 
150
 * @param[in] Record to parse.
 
151
 * @return Parsed data.
 
152
 */
 
153
aa_log_record *
 
154
parse_record(char *str);
 
155
 
 
156
/**
 
157
 * Frees all struct data.
 
158
 * @param[in] Data to free.
 
159
 */
 
160
void
 
161
free_record(aa_log_record *record);
 
162
 
 
163
#endif
 
164