2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-05 08:45:22 +00:00

Compare commits

...

39 Commits

Author SHA1 Message Date
John Johansen
e0c253176a Bump release version to 2.9.4
Signed-off-by: John Johansen <john.johansen@canonical.com>
2017-01-08 17:09:32 -08:00
Christian Boltz
66280702af Handle ldd $? == 1 in get_reqs()
ldd exits with $? == 1 if a file is 'not a dynamic executable'.
This is correct behaviour of ldd, so we should handle it instead of
raising an exception ;-)

[not in 2.9 and 2.10] Also extend fake_ldd and add a test to test-aa.py to cover this.


Note that 2.10 and 2.9 don't have tests for get_reqs() nor fake_ldd,
so those branches will only get the aa.py changes.


Acked-by: John Johansen <john.johansen@canonical.com> for trunk, 2.10 and 2.9.
2016-12-31 00:51:10 +01:00
Christian Boltz
105dfb2a9d Update dovecot profiles
The dovecot/auth profile needs access to /run/dovecot/anvil-auth-penalty
and /var/spool/postfix/private/auth.

The dovecot/log profile needs the attach_disconnected flag.

Refences: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1652131


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.
2016-12-27 17:47:59 +01:00
Christian Boltz
ccb9f412b4 Update nmbd profile and abstractions/samba
nmbd needs some additional permissions:
- k for /var/cache/samba/lck/* (via abstractions/samba)
- rw for /var/cache/samba/msg/ (the log only mentioned r, but that
  directory needs to be created first)
- w for /var/cache/samba/msg/* (the log didn't indicate any read access)

Reported by FLD on IRC, audit log on https://paste.debian.net/902010/



Acked-by: Steve Beattie <steve@nxnw.org> for trunk, 2.10 and 2.9
2016-12-13 22:16:45 +01:00
Christian Boltz
e11226e9b2 Add change_onexec log example to test_multi
Found in https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1648143 comment 1



Acked-by: John Johansen <john.johansen@canonical.com> for 2.9, 2.10, head

Acked-by: Seth Arnold <seth.arnold@canonical.com>


Note: the 2.9 and 2.10 branches don't support test_multi/*.profile files,
therefore I don't add the *.profile file to them.
2016-12-12 22:23:50 +01:00
Christian Boltz
5531d0adf1 nscd profile: allow reading libvirt/dnsmasq/*.status
References: https://bugzilla.opensuse.org/show_bug.cgi?id=1014463


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9
2016-12-09 17:54:27 +01:00
Christian Boltz
524ff50160 abstractions/php: adjust PHP7 paths for openSUSE
openSUSE uses "php7" (not just "php") in several paths, so also allow that.


Acked-by: John Johansen <john.johansen@canonical.com> for trunk, 2.10 and 2.9.
2016-12-07 13:16:27 +01:00
John Johansen
0c687f1876 php abstraction update cherry-pick from 2.10
-r3370
  Update php abstraction

  Signed-off-by: kees cook <kees@outflux.net>
  Acked-by: John Johansen <john.johansen@canonical.com>
    
-r3371
  Add backwards compatibility php5 abstraction

  Signed-off-by: John Johansen <john.johansen@canonical.com>

Signed-off-by: John Johansen <john.johansne@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2016-12-07 02:42:09 -08:00
John Johansen
5b1135a833 Merge dev head -r3592 and -r3593
dev head -r3592
  aa-unconfined currently does not check/display ipv6 fix this
and -r3593
  In testing, I did notice one thing not getting turned up, from
  netstat -nlp46 output:

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2016-12-05 01:26:01 -08:00
Steve Beattie
019d2943d3 abstractions/X: yet another location for Xauthority
Merge from trunk commit 3591

Add access to /{,var/}run/user/*/X11/Xauthority.

Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=845250

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2016-12-01 16:11:12 -08:00
Christian Boltz
72637677cf dovecot profile: allow capability sys_resource
On servers with not too much memory ("only" 16 GB), dovecot logins fail:

Nov 25 21:35:15 server dovecot[28737]: master: Fatal: setrlimit(RLIMIT_DATA, 268435456): Permission denied
Nov 25 21:35:15 server dovecot[28731]: master: Error: service(auth): command startup failed, throttling for 2 secs
Nov 25 21:35:15 server dovecot[28737]: auth: Fatal: master: service(auth): child 25976 returned error 89 (Fatal failure)

audit.log messages are:
... apparmor="DENIED" operation="capable" profile="/usr/sbin/dovecot" pid=25000 comm="dovecot" capability=24  capname="sys_resource"
... apparmor="DENIED" operation="setrlimit" profile="/usr/sbin/dovecot" pid=25000 comm="dovecot" rlimit=data value=268435456

After allowing capability sys_resource, dovecot can increase the limit
and works again.


Acked-by: Steve Beattie <steve@nxnw.org> for trunk, 2.10 and 2.9
2016-11-29 21:57:54 +01:00
Christian Boltz
7ecd62fc18 Update abstractions/gnome with versioned gtk paths
References: https://bugs.debian.org/845005


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9
2016-11-22 00:35:03 +01:00
Christian Boltz
533fb92e24 Allow /var/lib/nscd in abstractions/nameservice and nscd profile
The latest glibc (including nscd) in openSUSE Tumbleweed comes with
    glibc-2.3.3-nscd-db-path.diff: Move persistent nscd databases to
    /var/lib/nscd

This needs updates (adding /var/lib/nscd/) to abstractions/nameservice
and the nscd profile.


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9
2016-11-18 20:19:33 +01:00
Christian Boltz
9f2ead4c97 Allow /var/cache/samba/lck/* in abstractions/samba
nmbd, winbindd (and most probably also smbd - but it has a more
permissive profile that already allows this) need rw access to
/var/cache/samba/lck/* on Debian 8.6.

Reported by FLD on IRC.


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9
2016-11-18 20:13:43 +01:00
Christian Boltz
3882b2fd4a Allow "network unspec dgram," in ntpd profile
A while ago, support for "network unspec" was added. However, nobody
updated the ntpd profile (at least not the profile in upstream bzr)
which was the main reason for adding "unspec".

References: https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/1546455
            (the original bugreport about "unspec")

References: https://bugzilla.opensuse.org/show_bug.cgi?id=1009964
            (about the ntpd profile)


Acked-by: Steve Beattie <steve@nxnw.org> for trunk, 2.10 and 2.9
2016-11-15 00:45:47 +01:00
Christian Boltz
43cba9723a Add m permissions to mlmmj profiles
Newer kernels need m permissions for the binary the profile covers,
so add it before someone hits this problem in the wild ;-)

Also add a note that the mlmmj-recieve profile is probably superfluous
because upstream renamed the misspelled binary.


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9
2016-11-09 19:45:40 +01:00
Christian Boltz
f6ad591a83 Update mlmmj profiles
This patch updates the mlmmj profiles in the extras directory to the
profiles that are used on lists.opensuse.org now. Besides adding lots
of trailing slashes for directories, several permissions were added.
Also, usr.bin.mlmmj-receive gets added - it seems upstream renamed
mlmmj-recieve to fix a typo.

These profiles were provided by Per Jessen.

References: https://bugzilla.opensuse.org/show_bug.cgi?id=1000201


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.
2016-11-08 21:37:02 +01:00
Christian Boltz
95b29546b4 fix typo in "reasonable" in apparmor_parser manpage
(merge request by intrigeri)


Acked-By: <Christian Boltz> for trunk, 2.10 and 2.9
2016-10-15 19:28:32 +02:00
Christian Boltz
23a489256c allow reading /tmp/.X11-unix/* in abstractions/X
This is needed when starting X with "-nolisten local".


References: https://bugs.launchpad.net/apparmor/+bug/1589823


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9
2016-10-14 20:36:38 +02:00
Christian Boltz
5ddf027996 syslog-ng profile: allow writing *.qf files
These files are needed for disk-based buffering (added in syslog-ng 3.8).
This was reported to me by Peter Czanik, one of the syslog-ng developers.

Note: I'm not sure about adding @{CHROOT_BASE} to this rule, so for now
I prefer not to do it - adding it later is easy, but finding out if it
could be removed is hard ;-)


Acked-by: John Johansen <john.johansen@canonical.com> for trunk, 2.10 and 2.9.
2016-10-13 20:30:55 +02:00
Christian Boltz
674b42702e Add missing permissions to dovecot profiles
- dovecot/auth: allow to read stats-user
- dovecot/config: allow to read /usr/share/dovecot/**
- dovecot/imap: allow to ix doveconf, read /etc/dovecot/ and
  /usr/share/dovecot/**

These things were reported by Félix Sipma in Debian Bug#835826
(with some help from sarnold on IRC)

References: https://bugs.debian.org/835826


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.



Also allow reading ~/.dovecot.svbin (that's the default filename in the
dovecot config) in dovecot/lmtp profile.
(*.svbin files can probably also appear inside @{DOVECOT_MAILSTORE}, but
that's already covered by the existing rules.)

References: https://bugs.debian.org/835826 (again)


Acked-by: John Johansen <john.johansen@canonical.com> for trunk, 2.10 and 2.9
2016-10-05 20:54:22 +02:00
Christian Boltz
096c9b5dbc Drop CMD_CONTINUE from ui.py (twice)
The latest version of pyflakes (1.3.0 / python 3.5) complains that
CMD_CONTINUE is defined twice in ui.py (with different texts).

Funnily CMD_CONTINUE isn't used anywhere, so we can just drop both.



Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9
2016-10-03 21:02:43 +02:00
Christian Boltz
28b8be7bcb [39/38] Ignore exec events for non-existing profiles
The switch to FileRule made some bugs visible that survived unnoticed
with hasher for years.

If aa-logprof sees an exec event for a non-existing profile _and_ a
profile file matching the expected profile filename exists in
/etc/apparmor.d/, it asks for the exec mode nevertheless (instead of
being silent). In the old code, this created a superfluous entry
somewhere in the aa hasher, and caused the existing profile to be
rewritten (without changes).

However, with FileRule it causes a crash saying

      File ".../utils/apparmor/aa.py", line 1335, in handle_children
        aa[profile][hat]['file'].add(FileRule(exec_target, file_perm, exec_mode, rule_to_name, owner=False, log_event=True))
    AttributeError: 'collections.defaultdict' object has no attribute 'add'

This patch makes sure exec events for unknown profiles get ignored.



Reproducer:

    python3 aa-logprof -f <(echo 'type=AVC msg=audit(1407865079.883:215): apparmor="ALLOWED" operation="exec" profile="/sbin/klogd" name="/does/not/exist" pid=11832 comm="foo" requested_mask="x" denied_mask="x" fsuid=1000 ouid=0 target="/sbin/klogd//null-1"')

This causes a crash without this patch because
/etc/apparmor.d/sbin.klogd exists, but has
    profile klogd /{usr/,}sbin/klogd {



References: https://bugs.launchpad.net/bugs/1379874



Acked-by: Steve Beattie <steve@nxnw.org> for trunk, 2.10 and 2.9
2016-10-01 20:26:25 +02:00
Christian Boltz
a15aee5490 Allow both paths in traceroute profile
In 2011 (r1803), the traceroute profile was changed to also match
/usr/bin/traceroute.db:
    /usr/{sbin/traceroute,bin/traceroute.db} {

However, permissions for /usr/bin/traceroute.db were never added.
This patch fixes this.


While on it, also change the /usr/sbin/traceroute permissions from
rmix to the less confusing mrix.


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.
2016-09-30 00:08:37 +02:00
Tyler Hicks
36ad13a9cd libapparmor: Force libtoolize to replace existing files
Fixes build error when attempting to build and test the 2.10.95 release
on Ubuntu 14.04:

 $ (cd libraries/libapparmor/ && ./autogen.sh && ./configure && \
   make && make check) > /dev/null
 ...
 libtool: Version mismatch error.  This is libtool 2.4.6 Debian-2.4.6-0.1, but the
 libtool: definition of this LT_INIT comes from libtool 2.4.2.
 libtool: You should recreate aclocal.m4 with macros from libtool 2.4.6 Debian-2.4.6-0.1
 libtool: and run autoconf again.
 make[2]: *** [grammar.lo] Error 63
 make[1]: *** [all] Error 2
 make: *** [all-recursive] Error 1

The --force option is needed to regenerate the libtool file in
libraries/libapparmor/.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2016-09-14 12:51:33 -05:00
Christian Boltz
cb9c8a41ea Fix aa-logprof "add hat" endless loop
This turned out to be a simple case of misinterpreting the promptUser()
result - it returns the answer and the selected option, and
"surprisingly" something like
    ('CMD_ADDHAT', 0)
never matched
    'CMD_ADDHAT'
;-)

I also noticed that the changed profile doesn't get marked as changed.
This is also fixed by this patch.


References: https://bugs.launchpad.net/apparmor/+bug/1538306


Note: the 2.10 and trunk version of this patch also initializes the
new hat as profile_storage(), but this function doesn't exist in 2.9
(and isn't needed because in 2.9 everything is a big, self-initializing
hasher)


Acked-by: Steve Beattie <steve@nxnw.org> for trunk, 2.10 and 2.9
2016-08-15 22:10:37 +02:00
Christian Boltz
bbcb2727a6 winbindd profile: allow dac_override
This is needed to delete kerberos ccache files, for details see
https://bugzilla.opensuse.org/show_bug.cgi?id=990006#c5


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.
Acked-by: Steve Beattie <steve@nxnw.org> for trunk, 2.10 and 2.9.
2016-08-03 21:53:42 +02:00
Christian Boltz
c1d5c659c4 logparser: store network-related params if an event looks like network
Network events can come with an operation= that looks like a file event.
Nevertheless, if the event has a typical network parameter (like
net_protocol) set, make sure to store the network-related flags in ev.

This fixes the test failure introduced in my last commit.


Acked-by: Kshitij Gupta <kgupta8592@gmail.com> for trunk, 2.10 and 2.9
2016-07-31 17:16:12 +02:00
Christian Boltz
eddd542b46 logparser.py: ignore network events with 'send receive'
We already ignore network events that look like file events (based on
the operation keyword) if they have a request_mask of 'send' or
'receive' to avoid aa-logprof crashes because of "unknown" permissions.
It turned out that both can happen at once, so we should also ignore
this case.

Also add the now-ignored log event as test_multi testcase.


References: https://bugs.launchpad.net/apparmor/+bug/1577051 #13


Acked-by: Tyler Hicks <tyhicks@canonical.com> for trunk, 2.10 and 2.9.
2016-07-30 00:46:09 +02:00
Christian Boltz
d173892c26 Allow mr for /usr/lib*/ldb/*.so in samba abstractions
This is needed for winbindd (since samba 4.4.x), but smbd could also need it.

References: https://bugzilla.opensuse.org/show_bug.cgi?id=990006


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.
2016-07-26 21:14:11 +02:00
Christian Boltz
414f5d6bce Add a note about still enforcing deny rules to aa-complain manpage
This behaviour makes sense (for example to force the confined program to
use a fallback path), but is probably surprising for users, so we should
document it.

References: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=826218#37


Acked-by: John Johansen <john.johansen@canonical.com> for trunk, 2.10 and 2.9
2016-06-05 23:44:25 +02:00
Christian Boltz
5f7014af8c honor 'chown' file events in logparser.py
Also add a testcase to libapparmor's log collection


Acked-by: Kshitij Gupta <kgupta8592@gmail.com> for trunk, 2.10 and 2.9
2016-06-05 20:08:08 +02:00
Christian Boltz
95aefde14c aa-genprof: ask about profiles in extra dir (again)
Thanks to reading the wrong directory in read_inactive_profiles()
(profile_dir instead of extra_profile_dir), aa-genprof never asked about
using a profile from the extra_profile_dir.

Sounds like an easy fix, right? ;-)

After fixing this (last chunk), several other errors popped up, one
after the other:
- get_profile() missed a required parameter in a serialize_profile() call
- when saving the profile, it was written to extra_profile_dir, not to
  profile_dir where it (as a now-active profile) should be. This is
  fixed by removing the filename from existing_profiles{} so that it can
  pick up the default name.
- CMD_FINISHED (when asking if the extra profile should be used or a new
  one) behaved exactly like CMD_CREATE_PROFILE, but this is surprising
  for the user. Remove it to avoid confusion.
- displaying the extra profile was only implemented in YaST mode
- get_pager() returned None, not an actual pager. Since we have 'less'
  hardcoded at several places, also return it in get_pager()

Finally, also remove CMD_FINISHED from the get_profile() test in
test-translations.py.


(test-translations.py is only in trunk, therefore this part of the patch
is obviously trunk-only.)




Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk
Acked-by: John Johansen <john.johansen@canonical.com> for trunk + a 50% ACK for 2.10 and 2.9
Acked-by: Kshitij Gupta <kgupta8592@gmail.com> for trunk, 2.10 and 2.9
2016-06-01 21:07:15 +02:00
Christian Boltz
a708c0dc57 Ignore file events with a request mask of 'send' or 'receive'
Those events are actually network events, so ideally we should map them
as such. Unfortunately this requires bigger changes, so here is a hotfix
that ignores those events and thus avoids crashing aa-logprof.

References: https://bugs.launchpad.net/apparmor/+bug/1577051
            https://bugs.launchpad.net/apparmor/+bug/1582374


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9
2016-05-23 23:32:56 +02:00
Christian Boltz
e5ca1ace1d Document empty quotes ("") as empty value of a variable
Acked-by: Seth Arnold <seth.arnold@canonical.com> for all branches where this makes sense :)
2016-05-22 14:52:25 +02:00
Christian Boltz
0dc638f5af allow inet6 in ping profile
The latest iputils merged ping and ping6 into a single binary that does
both IPv4 and IPv6 pings (by default, it really does both).
This means we need to allow network inet6 raw in the ping profile.

References: https://bugzilla.opensuse.org/show_bug.cgi?id=980596
            (contains more details and example output)


Acked-by: Steve Beattie <steve@nxnw.org> for trunk, 2.10 and 2.9
2016-05-18 21:19:06 +02:00
Seth Arnold
1e0014b4a9 dbus-session-strict: allow access to the user bus socket
From: Simon McVittie <simon.mcvittie@collabora.co.uk>
Date: Wed, 4 May 2016 13:48:36 +0100
Subject: dbus-session-strict: allow access to the user bus socket

If dbus is configured with --enable-user-bus (for example in the
dbus-user-session package in Debian and its derivatives), and the user
session is started with systemd, then the "dbus-daemon --session" will be
started by "systemd --user" and listen on $XDG_RUNTIME_DIR/bus. Similarly,
on systems where dbus-daemon has been replaced with kdbus, the
bridge/proxy used to provide compatibility with the traditional D-Bus
protocol listens on that same socket.

In practice, $XDG_RUNTIME_DIR is /run/user/$uid on all systemd systems,
where $uid represents the numeric uid. I have not used /{var/,}run here,
because systemd does not support configurations where /var/run and /run
are distinct; in practice, /var/run is a symbolic link.

Based on a patch by Sjoerd Simons, which originally used the historical
path /run/user/*/dbus/user_bus_socket. That path was popularized by the
user-session-units git repository, but has never been used in a released
version of dbus and should be considered unsupported.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-05-11 17:22:23 -07:00
Seth Arnold
24aa2fcd11 syscall_sysctl test: correctly skip if CONFIG_SYSCTL_SYSCALL=n
From: Simon McVittie <simon.mcvittie@collabora.co.uk>
Date: Wed, 11 May 2016 13:52:56 +0100
Subject: syscall_sysctl test: correctly skip if CONFIG_SYSCTL_SYSCALL=n

This test attempts to auto-skip the sysctl() part if that syscall
was not compiled into the current kernel, via
CONFIG_SYSCTL_SYSCALL=n. Unfortunately, this didn't actually work,
for two reasons:

* Because "${test} ro" wasn't in "&&", "||", a pipeline or an "if",
  and it had nonzero exit status, the trap on ERR was triggered,
  causing execution of the error_handler() shell function, which
  aborts the test with a failed status. The rules for ERR are the
  same as for "set -e", so we can circumvent it in the same ways.
* Because sysctl_syscall.c prints its diagnostic message to stderr,
  but the $() operator only captures stdout, it never matched
  in the string comparison. This is easily solved by redirecting
  its stderr to stdout.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-05-11 16:34:28 -07:00
Christian Boltz
561a0c0e3b accept hostname with dots
Some people have the full hostname in their syslog messages, so
libapparmor needs to accept hostnames that contain dots.


References: https://bugs.launchpad.net/apparmor/+bug/1453300 comments
            #1 and #2 (the log samples reported by scrx in #apparmor)



Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
for trunk, 2.10 and 2.9.
2016-05-05 12:04:28 +02:00
52 changed files with 327 additions and 101 deletions

View File

@@ -1 +1 @@
2.9.3
2.9.4

View File

@@ -38,6 +38,6 @@ aclocal
echo "Running autoconf"
autoconf --force
echo "Running libtoolize"
libtoolize --automake -c
libtoolize --automake -c --force
echo "Running automake"
automake -ac

View File

@@ -178,7 +178,7 @@ syslog_month Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(
hhmmss {digit}{2}{colon}{digit}{2}{colon}{digit}{2}
timezone ({plus}|{minus}){digit}{2}{colon}{digit}{2}
syslog_time {hhmmss}({period}{digits})?{timezone}?
syslog_hostname [[:alnum:]_-]+
syslog_hostname [[:alnum:]._-]+
dmesg_timestamp \[[[:digit:] ]{5,}\.[[:digit:]]{6,}\]
%x single_quoted_string

View File

@@ -0,0 +1 @@
[103975.623545] audit: type=1400 audit(1481284511.494:2807): apparmor="DENIED" operation="change_onexec" info="no new privs" error=-1 namespace="root//lxd-tor_<var-lib-lxd>" profile="unconfined" name="system_tor" pid=18593 comm="(tor)" target="system_tor"

View File

@@ -0,0 +1,15 @@
START
File: change_onexec_lp1648143.in
Event type: AA_RECORD_DENIED
Audit ID: 1481284511.494:2807
Operation: change_onexec
Profile: unconfined
Name: system_tor
Command: (tor)
Name2: system_tor
Namespace: root//lxd-tor_<var-lib-lxd>
Info: no new privs
ErrorCode: 1
PID: 18593
Epoch: 1481284511
Audit subid: 2807

View File

@@ -0,0 +1 @@
type=AVC msg=audit(1465133533.431:728): apparmor="DENIED" operation="chown" profile="/usr/sbin/cupsd" name="/run/cups/certs/" pid=8515 comm="cupsd" requested_mask="w" denied_mask="w" fsuid=0 ouid=4

View File

@@ -0,0 +1,15 @@
START
File: file_chown.in
Event type: AA_RECORD_DENIED
Audit ID: 1465133533.431:728
Operation: chown
Mask: w
Denied Mask: w
fsuid: 0
ouid: 4
Profile: /usr/sbin/cupsd
Name: /run/cups/certs/
Command: cupsd
PID: 8515
Epoch: 1465133533
Audit subid: 728

View File

@@ -0,0 +1 @@
Sep 14 18:49:13 mfa-mia-74-app-rabbitmq-1.mia.ix.int kernel: [964718.247816] type=1400 audit(1442256553.643:40143): apparmor="ALLOWED" operation="open" profile="/opt/evoke/venv/bin/gunicorn" name="/opt/evoke/venv/lib/python2.7/warnings.pyc" pid=28943 comm="gunicorn" requested_mask="r" denied_mask="r" fsuid=1000 ouid=110

View File

@@ -0,0 +1,15 @@
START
File: syslog_hostname_with_dot.in
Event type: AA_RECORD_ALLOWED
Audit ID: 1442256553.643:40143
Operation: open
Mask: r
Denied Mask: r
fsuid: 1000
ouid: 110
Profile: /opt/evoke/venv/bin/gunicorn
Name: /opt/evoke/venv/lib/python2.7/warnings.pyc
Command: gunicorn
PID: 28943
Epoch: 1442256553
Audit subid: 40143

View File

@@ -0,0 +1 @@
Jul 29 11:42:05 files kernel: [483212.877816] audit: type=1400 audit(1469785325.122:21021): apparmor="ALLOWED" operation="file_inherit" profile="/usr/bin/nginx-amplify-agent.py//null-/bin/dash" pid=18239 comm="sh" laddr=192.168.10.3 lport=50758 faddr=54.153.70.241 fport=443 family="inet" sock_type="stream" protocol=6 requested_mask="send receive" denied_mask="send receive"

View File

@@ -0,0 +1,19 @@
START
File: testcase_network_send_receive.in
Event type: AA_RECORD_ALLOWED
Audit ID: 1469785325.122:21021
Operation: file_inherit
Mask: send receive
Denied Mask: send receive
Profile: /usr/bin/nginx-amplify-agent.py//null-/bin/dash
Command: sh
PID: 18239
Network family: inet
Socket type: stream
Protocol: tcp
Local addr: 192.168.10.3
Foreign addr: 54.153.70.241
Local port: 50758
Foreign port: 443
Epoch: 1469785325
Audit subid: 21021

View File

@@ -966,7 +966,8 @@ must be made before the start of the profile.
The parser will automatically expand variables to include all values
that they have been assigned; it is an error to reference a variable
without setting at least one value.
without setting at least one value. You can use empty quotes ("") to
explicitly add an empty value.
At the time of this writing, the following variables are defined in the
provided AppArmor policy:

View File

@@ -282,7 +282,7 @@ it so that policy can't complete compilation due to size constraints
take days or longer to compile).
Note: The parser is set to use a balanced default set of flags, that
will result in resonable compression but not take excessive amounts
will result in reasonable compression but not take excessive amounts
of time to complete.
Use --help=optimize to see a full list of which optimization flags are

View File

@@ -21,9 +21,10 @@
owner /{,var/}run/lightdm/authority/[0-9]* r,
owner /{,var/}run/lightdm/*/xauthority r,
owner /{,var/}run/user/*/gdm/Xauthority r,
owner /{,var/}run/user/*/X11/Xauthority r,
# the unix socket to use to connect to the display
/tmp/.X11-unix/* w,
/tmp/.X11-unix/* rw,
unix (connect, receive, send)
type=stream
peer=(addr="@/tmp/.X11-unix/X[0-9]*"),

View File

@@ -17,6 +17,9 @@
type=stream
peer=(addr="@/tmp/dbus-*"),
# dbus with systemd and --enable-user-session
owner /run/user/[0-9]*/bus rw,
dbus send
bus=session
path=/org/freedesktop/DBus

View File

@@ -21,6 +21,8 @@
/etc/gtk/* r,
/usr/lib{,32,64}/gtk/** mr,
/usr/lib/@{multiarch}/gtk/** mr,
/usr/lib{,32,64}/gtk-[0-9]*/** mr,
/usr/lib/@{multiarch}/gtk-[0-9]*/** mr,
/usr/share/themes/ r,
/usr/share/themes/** r,

View File

@@ -50,7 +50,7 @@
# to vast speed increases when working with network-based lookups.
/{,var/}run/.nscd_socket rw,
/{,var/}run/nscd/socket rw,
/{var/db,var/cache,var/run,run}/nscd/{passwd,group,services,hosts} r,
/{var/db,var/cache,var/lib,var/run,run}/nscd/{passwd,group,services,hosts} r,
# nscd renames and unlinks files in it's operation that clients will
# have open
/{,var/}run/nscd/db* rmix,

View File

@@ -0,0 +1,36 @@
# vim:syntax=apparmor
# ------------------------------------------------------------------
#
# Copyright (C) 2002-2006 Novell/SUSE
# Copyright (C) 2009-2010 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# ------------------------------------------------------------------
# shared snippets for config files
/etc/php{,5,7}/**/ r,
/etc/php{,5,7}/**.ini r,
# Xlibs
/usr/X11R6/lib{,32,64}/lib*.so* mr,
# php extensions
/usr/lib{64,}/php{,5,7}/*/*.so mr,
# php session mmap socket
/var/lib/php{,5,7}/session_mm_* rwlk,
# file based session handler
/var/lib/php{,5,7}/sess_* rwlk,
/var/lib/php{,5,7}/sessions/* rwlk,
# php libraries
/usr/share/php{,5,7}/ r,
/usr/share/php{,5,7}/** mr,
# MySQL extension
/usr/share/mysql/** r,
# Zend opcache
/tmp/.ZendSem.* rwlk,

View File

@@ -1,35 +1,3 @@
# vim:syntax=apparmor
# ------------------------------------------------------------------
#
# Copyright (C) 2002-2006 Novell/SUSE
# Copyright (C) 2009-2010 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# ------------------------------------------------------------------
#backwards compatibility include, actual abstraction moved from php5 to php
# shared snippets for config files
/etc/php5/**/ r,
/etc/php5/**.ini r,
# Xlibs
/usr/X11R6/lib{,32,64}/lib*.so* mr,
# php extensions
/usr/lib{64,}/php5/*/*.so mr,
# php5 session mmap socket
/var/lib/php5/session_mm_* rwlk,
# file based session handler
/var/lib/php5/sess_* rwlk,
# php libraries
/usr/share/php{,5}/ r,
/usr/share/php{,5}/** mr,
# MySQL extension
/usr/share/mysql/** r,
# Zend opcache
/tmp/.ZendSem.* rwlk,
#include <abstractions/php>

View File

@@ -10,9 +10,11 @@
# ------------------------------------------------------------------
/etc/samba/* r,
/usr/lib*/ldb/*.so mr,
/usr/share/samba/*.dat r,
/usr/share/samba/codepages/{lowcase,upcase,valid}.dat r,
/var/cache/samba/ w,
/var/cache/samba/lck/* rwk,
/var/lib/samba/** rwk,
/var/log/samba/cores/ rw,
/var/log/samba/cores/** rw,

View File

@@ -5,7 +5,7 @@
#include <abstractions/apache2-common>
#include <abstractions/base>
#include <abstractions/nameservice>
#include <abstractions/php5>
#include <abstractions/php>
#include <abstractions/python>
/{,usr/}bin/dash ixr,

View File

@@ -18,6 +18,7 @@
capability net_raw,
capability setuid,
network inet raw,
network inet6 raw,
/{,usr/}bin/ping mixr,
/etc/modules.conf r,

View File

@@ -48,6 +48,7 @@
/sbin/syslog-ng mr,
/sys/devices/system/cpu/online r,
/usr/share/syslog-ng/** r,
/var/lib/syslog-ng/syslog-ng-?????.qf rw,
# chrooted applications
@{CHROOT_BASE}/var/lib/*/dev/log w,
@{CHROOT_BASE}/var/lib/syslog-ng/syslog-ng.persist* rw,

View File

@@ -38,7 +38,10 @@
/var/tmp/smtp_* rw,
/{var/,}run/dovecot/auth-token-secret.dat{,.tmp} rw,
/{var/,}run/dovecot/stats-user w,
/{var/,}run/dovecot/stats-user rw,
/{var/,}run/dovecot/anvil-auth-penalty rw,
/var/spool/postfix/private/auth w,
# Site-specific additions and overrides. See local/README for details.
#include <local/usr.lib.dovecot.auth>

View File

@@ -23,6 +23,7 @@
/usr/bin/doveconf rix,
/usr/lib/dovecot/config mr,
/usr/lib/dovecot/managesieve Px,
/usr/share/dovecot/** r,
# Site-specific additions and overrides. See local/README for details.
#include <local/usr.lib.dovecot.config>

View File

@@ -25,7 +25,14 @@
@{DOVECOT_MAILSTORE}/** rwkl,
@{HOME} r, # ???
/usr/lib/dovecot/imap mr,
/etc/dovecot/dovecot.conf r,
/etc/dovecot/conf.d/ r,
/etc/dovecot/conf.d/** r,
/usr/bin/doveconf rix,
/usr/lib/dovecot/imap mrix,
/usr/share/dovecot/** r,
/{,var/}run/dovecot/auth-master rw,
/{,var/}run/dovecot/mounts r,

View File

@@ -25,6 +25,8 @@
@{DOVECOT_MAILSTORE}/ rw,
@{DOVECOT_MAILSTORE}/** rwkl,
@{HOME}/.dovecot.svbin r,
/proc/*/mounts r,
/tmp/dovecot.lmtp.* rw,
/usr/lib/dovecot/lmtp mr,

View File

@@ -11,7 +11,7 @@
#include <tunables/global>
/usr/lib/dovecot/log {
/usr/lib/dovecot/log flags=(attach_disconnected) {
#include <abstractions/base>
#include <abstractions/dovecot-common>

View File

@@ -28,6 +28,7 @@
capability net_bind_service,
capability setuid,
capability sys_chroot,
capability sys_resource,
/etc/dovecot/** r,
/etc/mtab r,

View File

@@ -20,6 +20,8 @@
/var/{cache,lib}/samba/smb_tmp_krb5.* rw,
/var/{cache,lib}/samba/sync.* rw,
/var/{cache,lib}/samba/unexpected rw,
/var/cache/samba/msg/ rw,
/var/cache/samba/msg/* w,
/{,var/}run/samba/** rwk,

View File

@@ -28,8 +28,10 @@
/{,var/}run/nscd/ rw,
/{,var/}run/nscd/db* rwl,
/{,var/}run/nscd/socket wl,
/{var/cache,var/run,run}/nscd/{passwd,group,services,hosts,netgroup} rw,
/{var/cache,var/lib,var/run,run}/nscd/{passwd,group,services,hosts,netgroup} rw,
/{,var/}run/{nscd/,}nscd.pid rwl,
/var/lib/libvirt/dnsmasq/ r,
/var/lib/libvirt/dnsmasq/*.status r,
/var/log/nscd.log rw,
@{PROC}/@{pid}/cmdline r,
@{PROC}/@{pid}/fd/ r,

View File

@@ -27,6 +27,8 @@
capability sys_time,
capability sys_nice,
network unspec dgram,
/drift/ntp.drift rwl,
/drift/ntp.drift.TEMP rwl,
/etc/ntp.conf r,

View File

@@ -20,7 +20,8 @@
network inet raw,
network inet6 raw,
/usr/sbin/traceroute rmix,
/usr/sbin/traceroute mrix,
/usr/bin/traceroute.db mrix,
@{PROC}/net/route r,
# Site-specific additions and overrides. See local/README for details.

View File

@@ -7,6 +7,7 @@
deny capability block_suspend,
capability dac_override,
capability ipc_lock,
capability setuid,

View File

@@ -1,6 +1,7 @@
# ------------------------------------------------------------------
#
# Copyright (C) 2002-2005 Novell/SUSE
# Copyright (C) Per Jessen <per@computer.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
@@ -14,9 +15,26 @@
/usr/bin/mlmmj-bounce {
#include <abstractions/base>
/usr/bin/mlmmj-bounce r,
/usr/bin/mlmmj-bounce mr,
/usr/bin/mlmmj-send Px,
/usr/bin/mlmmj-maintd Px,
/var/spool/mlmmj/*/subscribers.d/ r,
/var/spool/mlmmj/*/subscribers.d/* r,
/var/spool/mlmmj/*/subconf rwl, #
/var/spool/mlmmj/*/subconf/* rwl,
/var/spool/mlmmj/*/queue rwl, #
/var/spool/mlmmj/*/queue/* rwl,
/var/spool/mlmmj/*/bounce/ rwl,
/var/spool/mlmmj/*/nomailsubs.d/ r,
/var/spool/mlmmj/*/nomailsubs.d/* r,
/var/spool/mlmmj/*/digesters.d/ r,
/var/spool/mlmmj/*/digesters.d/* r,
/var/spool/mlmmj/*/bounce/* rw,
/var/spool/mlmmj/*/unsubconf/* w,
/usr/share/mlmmj/text.skel/*/* r,
/var/spool/mlmmj/*/control/* r,
}

View File

@@ -1,6 +1,7 @@
# ------------------------------------------------------------------
#
# Copyright (C) 2002-2005 Novell/SUSE
# Copyright (C) Per Jessen <per@computer.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
@@ -16,21 +17,36 @@
capability setuid,
/usr/bin/mlmmj-maintd r,
/usr/bin/mlmmj-maintd mr,
/usr/bin/mlmmj-send Px,
/usr/bin/mlmmj-bounce Px,
/usr/bin/mlmmj-unsub Px,
/var/spool/mlmmj r,
/var/spool/mlmmj/*/bounce r,
/var/spool/mlmmj/ r,
/var/spool/mlmmj/* r, #
/var/spool/mlmmj/*/bounce/ r,
/var/spool/mlmmj/*/bounce/* rw,
/var/spool/mlmmj/*/index r,
/var/spool/mlmmj/*/lastdigest rw,
/var/spool/mlmmj/*/lastdigest rwk,
/var/spool/mlmmj/*/maintdlog-* lrw,
/var/spool/mlmmj/*/mlmmj-maintd.lastrun.log w,
/var/spool/mlmmj/*/moderation r,
/var/spool/mlmmj/*/moderation/ r,
/var/spool/mlmmj/*/moderation/* w,
/var/spool/mlmmj/*/archive/ r,
/var/spool/mlmmj/*/archive/* r,
/var/spool/mlmmj/*/control/ r,
/var/spool/mlmmj/*/control/* r,
/var/spool/mlmmj/*/queue r,
/var/spool/mlmmj/*/queue/* rwl,
/var/spool/mlmmj/*/requeue r,
/var/spool/mlmmj/*/subconf r,
/var/spool/mlmmj/*/unsubconf r,
/var/spool/mlmmj/*/queue/ r,
/var/spool/mlmmj/*/queue/** rwl,
/var/spool/mlmmj/*/requeue/ r,
/var/spool/mlmmj/*/requeue/* rw,
/var/spool/mlmmj/*/requeue/*/ rw,
/var/spool/mlmmj/*/subconf/ r,
/var/spool/mlmmj/*/subconf/* rw,
/var/spool/mlmmj/*/unsubconf/ r,
/var/spool/mlmmj/*/unsubconf/* rw,
/usr/share/mlmmj/text.skel/*/digest r,
/var/spool/mlmmj/*/mlmmj.operation.log rwk,
}

View File

@@ -1,6 +1,7 @@
# ------------------------------------------------------------------
#
# Copyright (C) 2002-2005 Novell/SUSE
# Copyright (C) Per Jessen <per@computer.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
@@ -14,16 +15,32 @@
/usr/bin/mlmmj-process {
#include <abstractions/base>
/usr/bin/mlmmj-process r,
/usr/bin/mlmmj-process mr,
/usr/bin/mlmmj-send Px,
/usr/bin/mlmmj-sub Px,
/usr/bin/mlmmj-unsub Px,
/usr/bin/mlmmj-bounce Px,
# skeleton data
/usr/share/mlmmj/text.skel/ r,
/usr/share/mlmmj/text.skel/*/* r,
/var/spool/mlmmj/*/control/* r,
/var/spool/mlmmj/*/text/* r,
/var/spool/mlmmj/*/incoming/* rwl,
/var/spool/mlmmj/*/queue/* rwl,
/var/spool/mlmmj/*/queue/** rwl,
/var/spool/mlmmj/*/subconf/* rwl,
/var/spool/mlmmj/*/unsubconf/* rwl,
/var/spool/mlmmj/*/mlmmj.operation.log rw,
/var/spool/mlmmj/*/mlmmj.operation.log rwk,
/var/spool/mlmmj/*/mlmmj.operation.log.rotated w,
/var/spool/mlmmj/*/nomailsubs.d/ r,
/var/spool/mlmmj/*/nomailsubs.d/* r,
/var/spool/mlmmj/*/subscribers.d/ r,
/var/spool/mlmmj/*/subscribers.d/* r,
/var/spool/mlmmj/*/digesters.d/ r,
/var/spool/mlmmj/*/digesters.d/* r,
/var/spool/mlmmj/*/moderation/* rw,
/etc/mlmmj/text/*/* r,
}

View File

@@ -0,0 +1,22 @@
# ------------------------------------------------------------------
#
# Copyright (C) 2002-2005 Novell/SUSE
# Copyright (C) Per Jessen <per@computer.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# ------------------------------------------------------------------
# vim:syntax=apparmor
#include <tunables/global>
/usr/bin/mlmmj-receive {
#include <abstractions/base>
/usr/bin/mlmmj-process Px,
/usr/bin/mlmmj-receive mr,
/var/spool/mlmmj/*/incoming/ rw,
/var/spool/mlmmj/*/incoming/* rw,
}

View File

@@ -9,12 +9,17 @@
# ------------------------------------------------------------------
# vim:syntax=apparmor
# mlmmj upstream renamed the (misspelled) mlmmj-recieve to mlmmj-receive,
# so this profile is probably superfluous
#include <tunables/global>
/usr/bin/mlmmj-recieve {
#include <abstractions/base>
/usr/bin/mlmmj-process Px,
/usr/bin/mlmmj-recieve r,
/usr/bin/mlmmj-recieve mr,
/var/spool/mlmmj/*/incoming/* w,
}

View File

@@ -1,6 +1,7 @@
# ------------------------------------------------------------------
#
# Copyright (C) 2002-2005 Novell/SUSE
# Copyright (C) Per Jessen <per@computer.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
@@ -15,11 +16,16 @@
#include <abstractions/base>
#include <abstractions/nameservice>
/usr/bin/mlmmj-send r,
/usr/bin/mlmmj-send mr,
/var/spool/mlmmj/*/archive/* w,
/var/spool/mlmmj/*/control/* r,
/var/spool/mlmmj/*/index rw,
/var/spool/mlmmj/*/queue/* lrw,
/var/spool/mlmmj/*/subscribers.d r,
/var/spool/mlmmj/*/index rwk,
/var/spool/mlmmj/*/queue/* klrw,
/var/spool/mlmmj/*/subscribers.d/ r,
/var/spool/mlmmj/*/subscribers.d/* r,
/var/spool/mlmmj/*/digesters.d/ r,
/var/spool/mlmmj/*/moderation/* rwk,
}

View File

@@ -1,6 +1,7 @@
# ------------------------------------------------------------------
#
# Copyright (C) 2002-2005 Novell/SUSE
# Copyright (C) Per Jessen <per@computer.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
@@ -17,12 +18,24 @@
capability setuid,
/usr/bin/mlmmj-send Px,
/usr/bin/mlmmj-sub r,
/usr/bin/mlmmj-sub mr,
/var/spool/mlmmj/*/control/ r,
/var/spool/mlmmj/*/control/* r,
/var/spool/mlmmj/*/queue/* w,
/var/spool/mlmmj/*/subconf/* w,
/var/spool/mlmmj/*/subscribers.d rw,
/var/spool/mlmmj/*/subscribers.d/* rw,
/var/spool/mlmmj/*/subscribers.d/.d.lock lw,
/var/spool/mlmmj/*/queue/ rw,
/var/spool/mlmmj/*/queue/* rw,
/var/spool/mlmmj/*/subconf/ rw,
/var/spool/mlmmj/*/subconf/* rw,
/var/spool/mlmmj/*/subscribers.d/ rw,
/var/spool/mlmmj/*/subscribers.d/* rwk,
/var/spool/mlmmj/*/text/ r, #
/var/spool/mlmmj/*/text/* r,
/usr/share/mlmmj/text.skel/*/* r,
/var/spool/mlmmj/*/nomailsubs.d/ rw,
/var/spool/mlmmj/*/nomailsubs.d/* rwk,
/var/spool/mlmmj/*/digesters.d/ rw,
/var/spool/mlmmj/*/digesters.d/* rwk,
}

View File

@@ -1,6 +1,7 @@
# ------------------------------------------------------------------
#
# Copyright (C) 2002-2005 Novell/SUSE
# Copyright (C) Per Jessen <per@computer.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
@@ -14,14 +15,27 @@
/usr/bin/mlmmj-unsub {
#include <abstractions/base>
/usr/bin/mlmmj-unsub r,
/usr/bin/mlmmj-unsub mr,
/usr/bin/mlmmj-send Px,
/var/spool/mlmmj/*/control/ r,
/var/spool/mlmmj/*/control/* r,
/var/spool/mlmmj/*/text/ r,
/var/spool/mlmmj/*/text/* r,
/var/spool/mlmmj/*/subscribers.d r,
/var/spool/mlmmj/*/subscribers.d/* r,
/var/spool/mlmmj/*/queue/ rwl,
/var/spool/mlmmj/*/queue/* rwl,
/var/spool/mlmmj/*/unsubconf/ rwl,
/var/spool/mlmmj/*/unsubconf/* rwl,
/var/spool/mlmmj/*/subscribers.d/* rwl,
/var/spool/mlmmj/*/subscribers.d/ rw,
/var/spool/mlmmj/*/subscribers.d/* rwk,
/var/spool/mlmmj/*/nomailsubs.d/ rw,
/var/spool/mlmmj/*/nomailsubs.d/* rwk,
/var/spool/mlmmj/*/digesters.d/ rw,
/var/spool/mlmmj/*/digesters.d/* rwk,
/usr/share/mlmmj/text.skel/*/* r,
/etc/mlmmj/text/*/finish r,
}

View File

@@ -149,8 +149,7 @@ test_sysctl_proc()
# generally we want to encourage kernels to disable it, but if it's
# enabled we want to test against it
settest syscall_sysctl
res=$(${test} ro)
if [ $? -ne 0 -a $res == "FAIL: sysctl read failed - Function not implemented" ] ; then
if ! res="$(${test} ro 2>&1)" && [ "$res" = "FAIL: sysctl read failed - Function not implemented" ] ; then
echo " WARNING: syscall sysctl not implemented, skipping tests ..."
else
test_syscall_sysctl

View File

@@ -41,6 +41,8 @@ B<aa-complain> is used to set the enforcement mode for one or more profiles to I
In this mode security policy is not enforced but rather access violations
are logged to the system log.
Note that 'deny' rules will be enforced even in complain mode.
=head1 BUGS
If you find any bugs, please report them at

View File

@@ -39,13 +39,13 @@ pids = []
if paranoid:
pids = list(filter(lambda x: re.search(r"^\d+$", x), aa.get_subdirectories("/proc")))
else:
regex_tcp_udp = re.compile(r"^(tcp|udp)\s+\d+\s+\d+\s+\S+\:(\d+)\s+\S+\:(\*|\d+)\s+(LISTEN|\s+)\s+(\d+)\/(\S+)")
regex_tcp_udp = re.compile(r"^(tcp|udp|raw)6?\s+\d+\s+\d+\s+\S+\:(\d+)\s+\S+\:(\*|\d+)\s+(LISTEN|\d+|\s+)\s+(\d+)\/(\S+)")
import subprocess
if sys.version_info < (3, 0):
output = subprocess.check_output("LANG=C netstat -nlp", shell=True).split("\n")
output = subprocess.check_output("LANG=C netstat -nlp46", shell=True).split("\n")
else:
#Python3 needs to translate a stream of bytes to string with specified encoding
output = str(subprocess.check_output("LANG=C netstat -nlp", shell=True), encoding='utf8').split("\n")
output = str(subprocess.check_output("LANG=C netstat -nlp46", shell=True), encoding='utf8').split("\n")
for line in output:
match = regex_tcp_udp.search(line)

View File

@@ -354,9 +354,9 @@ def get_reqs(file):
pattern2 = re.compile('^\s*(\/\S+)')
reqs = []
ret, ldd_out = get_output([ldd, file])
if ret == 0:
if ret == 0 or ret == 1:
for line in ldd_out:
if 'not a dynamic executable' in line:
if 'not a dynamic executable' in line: # comes with ret == 1
break
if 'cannot read header' in line:
break
@@ -484,8 +484,11 @@ def get_profile(prof_name):
inactive_profile[prof_name][prof_name].pop('filename')
profile_hash[uname]['username'] = uname
profile_hash[uname]['profile_type'] = 'INACTIVE_LOCAL'
profile_hash[uname]['profile'] = serialize_profile(inactive_profile[prof_name], prof_name)
profile_hash[uname]['profile'] = serialize_profile(inactive_profile[prof_name], prof_name, None)
profile_hash[uname]['profile_data'] = inactive_profile
existing_profiles.pop(prof_name) # remove profile filename from list to force storing in /etc/apparmor.d/ instead of extra_profile_dir
# If no profiles in repo and no inactive profiles
if not profile_hash.keys():
return None
@@ -506,18 +509,13 @@ def get_profile(prof_name):
q = aaui.PromptQuestion()
q.headers = ['Profile', prof_name]
q.functions = ['CMD_VIEW_PROFILE', 'CMD_USE_PROFILE', 'CMD_CREATE_PROFILE',
'CMD_ABORT', 'CMD_FINISHED']
q.functions = ['CMD_VIEW_PROFILE', 'CMD_USE_PROFILE', 'CMD_CREATE_PROFILE', 'CMD_ABORT']
q.default = "CMD_VIEW_PROFILE"
q.options = options
q.selected = 0
ans = ''
while 'CMD_USE_PROFILE' not in ans and 'CMD_CREATE_PROFILE' not in ans:
if ans == 'CMD_FINISHED':
save_profiles()
return
ans, arg = q.promptUser()
p = profile_hash[options[arg]]
q.selected = options.index(options[arg])
@@ -529,12 +527,13 @@ def get_profile(prof_name):
'profile_type': p['profile_type']
})
ypath, yarg = GetDataFromYast()
#else:
# pager = get_pager()
# proc = subprocess.Popen(pager, stdin=subprocess.PIPE)
else:
pager = get_pager()
proc = subprocess.Popen(pager, stdin=subprocess.PIPE)
# proc.communicate('Profile submitted by %s:\n\n%s\n\n' %
# (options[arg], p['profile']))
# proc.kill()
proc.communicate(p['profile'].encode())
proc.kill()
elif ans == 'CMD_USE_PROFILE':
if p['profile_type'] == 'INACTIVE_LOCAL':
profile_data = p['profile_data']
@@ -585,6 +584,7 @@ def autodep(bin_name, pname=''):
if not profile_data:
profile_data = create_new_profile(pname)
file = get_profile_filename(pname)
profile_data[pname][pname]['filename'] = None # will be stored in /etc/apparmor.d when saving, so it shouldn't carry the extra_profile_dir filename
attach_profile_data(aa, profile_data)
attach_profile_data(original_aa, profile_data)
if os.path.isfile(profile_dir + '/tunables/global'):
@@ -1022,7 +1022,7 @@ def handle_children(profile, hat, root):
seen_events += 1
ans = q.promptUser()
ans = q.promptUser()[0]
if ans == 'CMD_FINISHED':
save_profiles()
@@ -1033,6 +1033,7 @@ def handle_children(profile, hat, root):
if ans == 'CMD_ADDHAT':
hat = uhat
aa[profile][hat]['flags'] = aa[profile][profile]['flags']
changed[profile] = True
elif ans == 'CMD_USEDEFAULT':
hat = default_hat
elif ans == 'CMD_DENY':
@@ -1093,6 +1094,9 @@ def handle_children(profile, hat, root):
prelog[aamode][profile][hat]['path'][path] = mode
if do_execute:
if not aa[profile][hat]:
continue # ignore log entries for non-existing profiles
if profile_known_exec(aa[profile][hat], 'exec', exec_target):
continue
@@ -2378,7 +2382,7 @@ def save_profiles():
reload_base(profile_name)
def get_pager():
pass
return 'less'
def generate_diff(oldprofile, newprofile):
oldtemp = tempfile.NamedTemporaryFile('w')
@@ -2578,7 +2582,7 @@ def read_inactive_profiles():
except:
fatal_error(_("Can't read AppArmor profiles in %s") % extra_profile_dir)
for file in os.listdir(profile_dir):
for file in os.listdir(extra_profile_dir):
if os.path.isfile(extra_profile_dir + '/' + file):
if is_skippable_file(file):
continue

View File

@@ -133,7 +133,7 @@ class ReadLog:
ev['denied_mask'] = event.denied_mask
ev['request_mask'] = event.requested_mask
ev['magic_token'] = event.magic_token
if ev['operation'] and self.op_type(ev['operation']) == 'net':
if ev['operation'] and (self.op_type(ev['operation']) == 'net' or event.net_protocol):
ev['family'] = event.net_family
ev['protocol'] = event.net_protocol
ev['sock_type'] = event.net_sock_type
@@ -266,7 +266,7 @@ class ReadLog:
self.debug_logger.debug('add_event_to_tree: dropped exec event in %s' % e['profile'])
elif ( e['operation'].startswith('file_') or e['operation'].startswith('inode_') or
e['operation'] in ['open', 'truncate', 'mkdir', 'mknod', 'chmod', 'rename_src',
e['operation'] in ['open', 'truncate', 'mkdir', 'mknod', 'chmod', 'chown', 'rename_src',
'rename_dest', 'unlink', 'rmdir', 'symlink_create', 'link',
'sysctl', 'getattr', 'setattr', 'xattr'] ):
@@ -277,6 +277,13 @@ class ReadLog:
self.debug_logger.debug('UNHANDLED (missing request_mask): %s' % e)
return None
# sometimes network events come with an e['operation'] that matches the list of file operations
# see https://bugs.launchpad.net/apparmor/+bug/1577051 and https://bugs.launchpad.net/apparmor/+bug/1582374
# XXX these events are network events, so we should map them as such
if 'send' in e['request_mask'] or 'receive' in e['request_mask']:
self.debug_logger.debug('UNHANDLED (request_mask is send or receive): %s' % e)
return None
# Map c (create) and d (delete) to w (logging is more detailed than the profile language)
rmask = e['request_mask']
rmask = rmask.replace('c', 'w')

View File

@@ -249,7 +249,6 @@ CMDS = {'CMD_ALLOW': _('(A)llow'),
'CMD_EXEC_IX_ON': _('(X) ix On'),
'CMD_EXEC_IX_OFF': _('(X) ix Off'),
'CMD_SAVE': _('(S)ave Changes'),
'CMD_CONTINUE': _('(C)ontinue Profiling'),
'CMD_NEW': _('(N)ew'),
'CMD_GLOB': _('(G)lob'),
'CMD_GLOBEXT': _('Glob with (E)xtension'),
@@ -278,7 +277,6 @@ CMDS = {'CMD_ALLOW': _('(A)llow'),
'CMD_NET_FAMILY': _('Allow Network Fa(m)ily'),
'CMD_OVERWRITE': _('(O)verwrite Profile'),
'CMD_KEEP': _('(K)eep Profile'),
'CMD_CONTINUE': _('(C)ontinue'),
'CMD_IGNORE_ENTRY': _('(I)gnore')
}