~ubuntu-core-dev/apparmor/master

« back to all changes in this revision

Viewing changes to parser/network.c

  • Committer: Jamie Strandboge
  • Date: 2016-01-05 19:14:44 UTC
  • Revision ID: jamie@ubuntu.com-20160105191444-4cxbegq4ru62ri2n
Tags: 2.10-0ubuntu10
* debian/patches/lp1529074.patch: for systems using networkd, add read on
  /run/systemd/resolve/resolv.conf (LP: #1529074)
* No change rebuild for perl 5.22
* debian/patches/fix-abstraction-for-python3.5.patch: adjust python
  abstraction for python 3.5
* debian/apparmor.init,apparmor.upstart: clear only the system cache if
  apparmor version has changed on snappy flavors since snappy will handle
  the app's cache itself
* debian/lib/apparmor/functions:
  - compile /var/lib/snappy/apparmor/profiles policy
  - add compare_previous_version()
  - refactor clear_cache()
  - compare_and_save_debsums() checks if $PROFILES_VAR exists
* debian/libapparmor-dev.manpages: add 5 missing libapparmor manpages
  (LP: #1491147, LP: #1384431)
* Rebuild against python3.5.
* debian/patches/parser-fix-cache-file-mtime-regression.patch: Fix a bug
  that resulted in the mtime of generate policy cache files to be set
  incorrectly. The mtime of cache files should be the newest mtime detected
  on the profile and abstraction files used to generate the policy cache
  file. However, the bug caused the mtime of the policy cache file to either
  not be updated or to be updated to an incorrect time. (LP: #1484178)
* debian/patches/parser-verify-cache-file-mtime.patch: Add tests to verify
  that the policy cache file's mtime is being set correctly and that cache
  handling is correct when the profile or abstraction files are newer than
  the policy cache file.
* debian/patches/parser-run-caching-tests-without-apparmorfs.patch,
  debian/patches/parser-do-cleanup-when-test-was-skipped.patch: Enable the
  caching tests to run on the buildds even though apparmorfs isn't mounted.
* debian/patches/aa-status-dont_require_python3-apparmor.patch:
  make aa-status(8) work even when python3-apparmor is not installed,
  otherwise dh_apparmor postinst snippets can fail (LP: #1480492)
* debian/control: make apparmor-utils depend on the same package
  version of python3-apparmor
* Update to apparmor 2.10
  - libapparmor added functions to ease loading profile cache files to
    help support systemd on-demand load of policy (LP: #1385414)
  - apparmor parser: fixed policy generation to allow matching
    embedded NULs in abstract unix socket names (LP: #1413410)
  - aa-status: don't traceback when not permitted to read current
    set of apparmor policy (LP: #1466768)
  - aa-logprof: don't crash on policies that have an #include of a
    directory (LP: #1471425)
  - aa-logprof: fix crash when network rejections occur when file
    operations are performed on network sockets (LP: #1466812)
* dropped reproducible-pdf.patch, incorporated upstream
* debian/patches/tests-fix_sysctl_test.patch: fix sysctl test failure
  with 4.1 kernel and newer.
* debian/control: add alternate dependency on linux-initramfs-tool
  (LP: #1109029)
* debian/libapparmor1.symbols: update symbols file for added symbols
  in libapparmor
* No-change rebuild for python3.5 transition
* Update to apparmor 2.9.2
  - Fix minitools to work with multiple profiles at once (LP: #1378095)
  - Parse mounts that have non-ascii UTF-8 chars (LP: #1310598)
  - Update dovecot profiles (LP: #1296667)
  - Allow ubuntu-helpers to build texlive fonts (LP: #1010909)
* dropped patches incorporated upstream:
  add-mir-abstraction-lp1422521.patch, systemd-dev-log-lp1413232.patch
  parser-fix_modifier_compilation_+_tests.patch,
  tests-fix_systemd_breakage_in_pivot_root-lp1436109.patch,
  GDM_X_authority-lp1432126.patch, and
  debian/patches/easyprof-framework-policy.patch
* Partial merge with debian apparmor package:
  - debian/rules: enable the bindnow hardening flag during build.
  - debian/upstream/signing-key.asc: add new upstream public
    signing key
  - debian/watch: fix watch file, add gpg signature checking
  - install libapparmor.so dev symlink under /usr not /lib
  - debian/patches/reproducible-pdf.patch: make techdoc.pdf
    reproducible even in face of timezone variations.
  - debian/control: sync fields
  - debian/debhelper/postrm-apparmor: remove
    /etc/apparmor.d/{disable,} on package purge
  - debian/libapache2-mod-apparmor.postrm: on package purge, delete
    /etc/apparmor.d/{,disable} if empty
  - debian/libapparmor1.symbols: Use Build-Depends-Package in the
    symbols file.
  - debian/copyright: sync
* Make debian/lib/apparmor/profile-load executable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <sstream>
26
26
#include <map>
27
27
 
 
28
#include "lib.h"
28
29
#include "parser.h"
29
30
#include "profile.h"
30
31
#include "parser_yacc.h"
154
155
static size_t kernel_af_max(void) {
155
156
        char buffer[32];
156
157
        int major;
157
 
        int fd, res;
 
158
        autoclose int fd = -1;
 
159
        int res;
158
160
 
159
161
        if (!net_af_max_override) {
160
162
                return 0;
168
170
                /* fall back to default provided during build */
169
171
                return 0;
170
172
        res = read(fd, &buffer, sizeof(buffer) - 1);
171
 
        close(fd);
172
173
        if (res <= 0)
173
174
                return 0;
174
175
        buffer[res] = '\0';
321
322
 
322
323
#define ALL_TYPES 0x43e
323
324
 
324
 
/* another case of C++ not supporting non-trivial designated initializers */
325
 
#undef AA_GEN_NET_ENT
326
 
#define AA_GEN_NET_ENT(name, AF) name, /* [AF] = name, */
327
 
 
328
 
static const char *network_families[] = {
329
 
#include "af_names.h"
330
 
};
331
 
 
332
 
int net_find_af_val(const char *af)
333
 
{
334
 
        int i;
335
 
        for (i = 0; network_families[i]; i++) {
336
 
                if (strcmp(network_families[i], af) == 0)
337
 
                        return i;
338
 
        }
339
 
 
340
 
        return -1;
341
 
}
342
 
 
343
325
const char *net_find_af_name(unsigned int af)
344
326
{
 
327
        size_t i;
 
328
 
345
329
        if (af < 0 || af > get_af_max())
346
330
                return NULL;
347
331
 
348
 
        return network_families[af];
 
332
        for (i = 0; i < sizeof(network_mappings) / sizeof(*network_mappings); i++) {
 
333
                if (network_mappings[i].family == af)
 
334
                        return network_mappings[i].family_name;
 
335
        }
 
336
 
 
337
        return NULL;
349
338
}
350
339
 
351
340
void __debug_network(unsigned int *array, const char *name)
375
364
 
376
365
        for (i = 0; i < af_max; i++) {
377
366
                if (array[i]) {
378
 
                        const char *fam = network_families[i];
 
367
                        const char *fam = net_find_af_name(i);
379
368
                        if (fam)
380
369
                                printf("%s ", fam);
381
370
                        else