~saviq/ubuntu/trusty/apparmor/libapparmor-multiarch-same

« back to all changes in this revision

Viewing changes to .pc/0054-libaalogparse-Parse-dbus-daemon-audit-messages.patch/libraries/libapparmor/src/libaalogparse.c

  • Committer: Package Import Robot
  • Author(s): Tyler Hicks, Tyler Hicks, Jamie Strandboge
  • Date: 2013-08-26 15:32:12 UTC
  • Revision ID: package-import@ubuntu.com-20130826153212-va8c7fugv96f6sml
Tags: 2.8.0-0ubuntu25
[ Tyler Hicks ]
* Add support for mediation of D-Bus messages and services. AppArmor D-Bus
  rules are described in the apparmor.d(5) man page. dbus-daemon will use
  libapparmor to perform queries against the AppArmor policies to determine
  if a connection should be able to send messages to another connection, if
  a connection should be able to receive messages from another connection,
  and if a connection should be able to bind to a well-known name.
  - 0042-Fix-mount-rule-preprocessor-output.patch,
    0043-libapparmor-Safeguard-aa_getpeercon-buffer-reallocat.patch,
    0044-libapparmor-fix-return-value-of-aa_getpeercon_raw.patch,
    0045-libapparmor-Move-mode-parsing-into-separate-function.patch,
    0046-libapparmor-Parse-mode-from-confinement-string-in-ge.patch,
    0047-libapparmor-Make-aa_getpeercon_raw-similar-to-aa_get.patch,
    0048-libapparmor-Update-aa_getcon-man-page-to-reflect-get.patch:
    Backport parser and libapparmor pre-requisites for D-Bus mediation
  - 0049-parser-Update-man-page-for-DBus-rules.patch: Update apparmor.d man
    page
  - 0050-parser-Add-support-for-DBus-rules.patch,
    0051-parser-Regression-tests-for-DBus-rules.patch,
    0052-parser-Binary-profile-equality-tests-for-DBus-rules.patch: Add
    apparmor_parser support for D-Bus mediation rules
  - 0053-libapparmor-Export-a-label-based-query-interface.patch,
    debian/libapparmor1.symbols: Provide the libapparmor interface necessary
    for trusted helpers to make security decisions based upon AppArmor
    policy
  - 0054-libaalogparse-Parse-dbus-daemon-audit-messages.patch,
    0055-libaalogparse-Regression-tests-for-dbus-daemon-audit.patch: Allow
    applications to parse denials, generated by dbus-daemon, using
    libaalogparse and add a set of regression tests
  - 0056-tests-Add-an-optional-final-check-to-checktestfg.patch,
    0057-tests-Add-required-features-check.patch,
    0058-tests-Add-regression-tests-for-dbus.patch: Add regression tests
    which start their own dbus-daemon, load profiles containing D-Bus rules,
    and confine simple D-Bus service and client applications
  - 0059-dbus-rules-for-dbus-abstractions.patch: Add bus-specific, but
    otherwise permissive, D-Bus rules to the dbus and dbus-session
    abstractions. Confined applications that use D-Bus should already be
    including these abstractions in their profiles so this should be a
    seamless transition for those profiles.
* 0060-utils-make_clean_fixup.patch: Clean up the Python cache in the
  AppArmor tests directory
* 0061-profiles-dnsmasq-needs-dbus-abstraction.patch: Dnsmasq uses the
  system D-Bus when it is started with --enable-dbus, so its AppArmor
  profile needs to include the system bus abstraction
* 0062-fix-clone-test-on-arm.patch: Fix compiler error when building
  regression tests on ARM
* 0063-utils-ignore-unsupported-rules.patch: Utilities that use the
  Immunix::AppArmor perl module, such as aa-logprof and aa-genprof, error
  out when they encounter rules unsupported by the perl module. This patch
  ignores unsupported rules.

[ Jamie Strandboge ]
* debian/control: don't have easyprof Depends on apparmor-easyprof-ubuntu

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
 * @author Matt Barringer <mbarringer@suse.de>
 
20
 */
 
21
 
 
22
/*
 
23
 * TODO:
 
24
 *
 
25
 * - Convert the text permission mask into a bitmask
 
26
 * - Clean up parser grammar
 
27
 */
 
28
 
 
29
 
 
30
#include <stdlib.h>
 
31
#include <string.h>
 
32
#include <stdio.h>
 
33
#include <netinet/in.h>
 
34
#include "aalogparse.h"
 
35
#include "parser.h"
 
36
 
 
37
/* This is mostly just a wrapper around the code in grammar.y */
 
38
aa_log_record *parse_record(char *str)
 
39
{
 
40
        if (str == NULL)
 
41
                return NULL;
 
42
 
 
43
        return _parse_yacc(str);
 
44
}
 
45
 
 
46
void free_record(aa_log_record *record)
 
47
{
 
48
        if (record != NULL)
 
49
        {
 
50
                if (record->operation != NULL)
 
51
                        free(record->operation);
 
52
                if (record->requested_mask != NULL)
 
53
                        free(record->requested_mask);
 
54
                if (record->denied_mask != NULL)
 
55
                        free(record->denied_mask);
 
56
                if (record->profile != NULL)
 
57
                        free(record->profile);
 
58
                if (record->comm != NULL)
 
59
                        free(record->comm);
 
60
                if (record->name != NULL)
 
61
                        free(record->name);
 
62
                if (record->name2 != NULL)
 
63
                        free(record->name2);
 
64
                if (record->namespace != NULL)
 
65
                        free(record->namespace);
 
66
                if (record->attribute != NULL)
 
67
                        free(record->attribute);
 
68
                if (record->info != NULL)
 
69
                        free(record->info);
 
70
                if (record->active_hat != NULL)
 
71
                        free(record->active_hat);
 
72
                if (record->audit_id != NULL)
 
73
                        free(record->audit_id);
 
74
                if (record->net_family != NULL)
 
75
                        free(record->net_family);
 
76
                if (record->net_protocol != NULL)
 
77
                        free(record->net_protocol);
 
78
                if (record->net_sock_type != NULL)
 
79
                        free(record->net_sock_type);
 
80
 
 
81
                free(record);
 
82
        }
 
83
        return;
 
84
}
 
85
 
 
86
/* Set all of the fields to appropriate values */
 
87
void _init_log_record(aa_log_record *record)
 
88
{
 
89
        if (record == NULL)
 
90
                return;
 
91
 
 
92
        memset(record, 0, sizeof(aa_log_record));
 
93
 
 
94
        record->version = AA_RECORD_SYNTAX_UNKNOWN;
 
95
        record->event = AA_RECORD_INVALID;
 
96
        record->fsuid = (unsigned long) -1;
 
97
        record->ouid = (unsigned long) -1;
 
98
 
 
99
        return;
 
100
}
 
101
 
 
102
/* convert a hex-encoded string to its char* version */
 
103
char *hex_to_string(char *hexstring)
 
104
{
 
105
        char *ret = NULL;
 
106
        char buf[3], *endptr;
 
107
        size_t len;
 
108
        int i;
 
109
 
 
110
        if (!hexstring)
 
111
                goto out;
 
112
 
 
113
        len = strlen(hexstring) / 2;
 
114
        ret = malloc(len + 1);
 
115
        if (!ret)
 
116
                goto out;
 
117
 
 
118
        for (i = 0; i < len; i++) {
 
119
                sprintf(buf, "%.2s", hexstring);
 
120
                hexstring += 2;
 
121
                ret[i] = (unsigned char) strtoul(buf, &endptr, 16);
 
122
        }
 
123
        ret[len] = '\0';
 
124
 
 
125
out:
 
126
        return ret;
 
127
}
 
128
 
 
129
struct ipproto_pairs {
 
130
        unsigned int protocol;
 
131
        char *protocol_name;
 
132
};
 
133
 
 
134
#define AA_GEN_PROTO_ENT(name, IP) {name, IP},
 
135
 
 
136
static struct ipproto_pairs ipproto_mappings[] = {
 
137
#include "af_protos.h"
 
138
        /* terminate */
 
139
        {0, NULL}
 
140
};
 
141
 
 
142
/* convert an ip protocol number to a string */
 
143
char *ipproto_to_string(unsigned int proto)
 
144
{
 
145
        char *ret = NULL;
 
146
        struct ipproto_pairs *current = ipproto_mappings;
 
147
 
 
148
        while (current->protocol != proto && current->protocol_name != NULL) {
 
149
                current++;
 
150
        }
 
151
 
 
152
        if (current->protocol_name) {
 
153
                ret = strdup(current->protocol_name);
 
154
        } else {
 
155
                if (!asprintf(&ret, "unknown(%u)", proto))
 
156
                        ret = NULL;
 
157
        }
 
158
 
 
159
        return ret;
 
160
}
 
161