2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 06:16:03 +00:00

Compare commits

...

137 Commits

Author SHA1 Message Date
John Johansen
3004390a6c Bump version to 2.10.3
Signed-off-by: John Johansen <john.johansen@canonical.com>
2017-10-19 00:44:42 -07:00
John Johansen
95d2b6ed3d parser: Allow AF_UNSPEC family in network rules
https://launchpad.net/bugs/1546455

Don't filter out AF_UNSPEC from the list of valid protocol families so
that the parser will accept rules such as 'network unspec,'.

There are certain syscalls, such as socket(2), where the LSM hooks are
called before the protocol family is validated. In these cases, AppArmor
was emitting denials even though socket(2) will eventually fail. There
may be cases where AF_UNSPEC sockets are accepted and we need to make
sure that we're mediating those appropriately.

cherry-pick: r3376
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Suggested-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>
[cboltz: Add 'unspec' to the network domain keywords of the utils]
2017-10-18 23:35:11 -07:00
Steve Beattie
2e1d4f5b67 libapparmor: fix swig test_apparmor.py for zero length ptrace records
Merge from trunk revision 3715

The added testcase for a ptrace target with an empty string
(ptrace_garbage_lp1689667_1.in) was causing the swig python test script
to fail. The generated python swig record for libapparmor ends up
setting a number of fields to None or other values that indicate the
value is unset, and the test script was checking if the value in the
field didn't evaluate to False in a python 'if' test.

Unfortunately, python evaluates the empty string '' as False in 'if'
tests, resulting in the specific field that contained the empty string
to be dropped from the returned record. This commit fixes that by
special case checking for the empty string.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>
2017-10-18 17:09:42 -07:00
John Johansen
24c136f069 Fix af_unix downgrade of network rules
with unix rules we output a downgraded rule compatible with network rules
so that policy will work on kernels that support network socket controls
but not the extended af_unix rules

however this is currently broken if the socket type is left unspecified
(initialized to -1), resulting in denials for kernels that don't support
the extended af_unix rules.

cherry-pick: lp:apparmor r3700
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: timeout
2017-10-18 14:46:51 -07:00
Christian Boltz
f9df4da913 Allow /var/run/dovecot/login-master-notify* in dovecot imap-login profiles
Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.11, 2.10 and 2.9.
2017-09-28 17:48:42 +02:00
Christian Boltz
4dff14d0b2 Merge updated traceroute profile into 2.10 and 2.9 branch
References: https://bugzilla.opensuse.org/show_bug.cgi?id=1057900


------------------------------------------------------------
revno: 3690 [merge]
committer: Steve Beattie <sbeattie@ubuntu.com>
branch nick: apparmor
timestamp: Wed 2017-08-09 08:57:36 -0700
message:
  traceroute profile: support TCP SYN for probes, quite net_admin request
  
  Merge from Vincas Dargis, approved by intrigeri.
  fix traceroute denies in tcp mode
  
  Acked-by: Steve Beattie <steve@nxnw.org>
------------------------------------------------------------


Backport to 2.10 and 2.9 branch

Acked-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2017-09-12 23:25:06 +02:00
Christian Boltz
000cbb1f8a abstractions/freedesktop.org: support /usr/local/applications; support subdirs of applications folder
Merge request by Cameron Norman 2015-06-07
https://code.launchpad.net/~cameronnemo/apparmor/abstraction-fdo-applications-fixups/+merge/261336

Acked-by: Christian Boltz <apparmor@cboltz.de> for trunk, 2.11, 2.10 and 2.9
2017-09-10 12:28:46 +02:00
Christian Boltz
667b38528a Add network 'smc' keyword in NetworkRule and apparmor.d manpage
'smc' seems to be new in kernel 4.12.


Note that the 2.10 apparmor.d manpage also misses the 'kcm' keyword, so
the patch also adds it there.


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.11 and 2.10.
2017-08-30 11:07:28 +02:00
Christian Boltz
d32501b204 Samba profile updates for ActiveDirectory / Kerberos
The Samba package used by the INVIS server (based on openSUSE) needs
some additional Samba permissions for the added ActiveDirectory /
Kerberos support.

As discussed with Seth, add /var/lib/sss/mc/initgroups read permissions
to abstractions/nameservice instead of only to the smbd profile because
it's probably needed by more than just Samba if someone uses sss.


Acked-by: Seth Arnold <seth.arnold@canonical.com> for 2.9, 2.10, 2.11 and trunk.
2017-08-29 13:32:30 +02:00
Christian Boltz
9c33ba4359 update some Postfix profiles
- change abstractions/postfix-common to allow /etc/postfix/*.db k
- add several permissions to postfix/error, postfix/lmtp and postfix/pipe
- remove superfluous abstractions/kerberosclient from all postfix
  profiles - it's included via abstractions/nameservice


Acked-by: Seth Arnold <seth.arnold@canonical.com> for 2.9, 2.10, 2.11 and trunk
2017-08-22 12:44:34 +02:00
Christian Boltz
205f19704a remove test_multi unconfined-change_hat.profile from 2.10 and 2.9 branch
2.10 branch r3387 and 2.9 branch r3052 (Ignore change_hat events
with error=-1 and "unconfined can not change_hat") accidently added
unconfined-change_hat.profile to the test_multi directory.

2.9 and 2.10 don't support the test_multi *.profile files and error out
in the tests saying "Found unknown file unconfined-change_hat.profile",
therefore delete this file.


Acked-by: Seth Arnold <seth.arnold@canonical.com>
2017-07-31 21:38:02 +02:00
Jamie Strandboge
fdbe6e9f7f update aa-status.pod for updated podchecker
Bug-Ubuntu: https://launchpad.net/bugs/1707614

Signed-Off-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2017-07-31 10:23:19 -05:00
Jamie Strandboge
e409e5b66d Adjust python abstraction for python3.6
Signed-Off-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2017-07-26 15:12:03 -05:00
Christian Boltz
ed37e5edc2 Add --no-reload to various utils manpages
This option exists in several aa-* tools since 2.9, but isn't mentioned
in the manpage.

Also drop some trailing whitespace in the manpages.


Acked-by: John Johansen <john.johansen@canonical.com>
for 2.9, 2.10, 2.11 and trunk.
2017-07-23 21:31:49 +02:00
Christian Boltz
98d0f323a4 dovecot profile: add the attach_disconnected flag
Reported by pfak on IRC

[...] apparmor="DENIED" operation="sendmsg" info="Failed name lookup - disconnected path" error=-13 profile="/usr/sbin/dovecot" name="run/systemd/journal/dev-log" pid=20313 comm="dovecot" requested_mask="w" denied_mask="w" fsuid=0 ouid=0


Acked-by <timeout> for 2.9, 2.10, 2.11 and trunk.
2017-06-29 22:54:44 +02:00
Jamie Strandboge
f052a62e4a Origin: r3669 from trunk
Description: adjust the multiarch alternation rule in the perl abstraction for
 modern Debian and Ubuntu systems which store some modules under the
 architecture-specific perl-base directory instead of perl or perl5.

Signed-Off-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2017-06-26 14:45:28 -05:00
Christian Boltz
01824ded0b update dovecot-lda profile
dovecot-lda needs
- the attach_disconnected flags
- read access to /usr/share/dovecot/protocols.d/
- rw for /run/dovecot/auth-userdb

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


Acked-by: Steve Beattie <steve@nxnw.org> for 2.9, 2.10 and trunk.
2017-04-07 00:14:35 +02:00
Tyler Hicks
68af901615 utils: Add aa-remove-unknown utility to unload unknown profiles
https://launchpad.net/bugs/1668892

This patch creates a new utility, with the code previously used in the
init script 'restart' action, that removes unknown profiles which are
not found in /etc/apparmor.d/. The functionality was removed from the
common init script code in the fix for CVE-2017-6507.

The new utility prints a message containing the name of each unknown
profile before the profiles are removed. It also supports a dry run mode
so that an administrator can check which profiles will be removed before
unloading any unknown profiles.

If you backport this utility with the fix for CVE-2017-6507 to an
apparmor 2.10 release and your backported aa-remove-unknown utility is
sourcing the upstream rc.apparmor.functions file, you'll want to include
the following bug fix to prevent the aa-remove-unknown utility from
removing child profiles that it shouldn't remove:

  r3440 - Fix: parser: incorrect output of child profile names

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2017-03-24 17:39:49 +00:00
Tyler Hicks
9dd1cbec0a parser: Preserve unknown profiles when restarting apparmor init/job/unit
CVE-2017-6507

https://launchpad.net/bugs/1668892

The common AppArmor 'restart' code used by some init scripts, upstart
jobs, and/or systemd units contained functionality that is no longer
appropriate to retain. Any profiles not found /etc/apparmor.d/ were
assumed to be obsolete and were unloaded. That behavior became
problematic now that there's a growing number of projects that maintain
their own internal set of AppArmor profiles outside of /etc/apparmor.d/.
It resulted in the AppArmor 'restart' code leaving some important
processes running unconfined. A couple examples are profiles managed by
LXD and Docker.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2017-03-24 17:36:51 +00:00
Seth Arnold
d0ef880bbe parser: Fix delete after new[] -- patch from Oleg Strikov <oleg.strikov@gmail.com> 2017-03-21 21:44:57 -07:00
Christian Boltz
d9be57a140 Ignore change_hat events with error=-1 and "unconfined can not change_hat"
That's much better than crashing aa-logprof ;-)  (use the log line in
the added testcase if you want to see the crash)

Reported by pfak on IRC.


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.
2017-02-23 01:01:51 +01:00
Christian Boltz
5094333f2c Remove re.LOCALE flag
Starting with python 3.6, the re.LOCALE flag can only be used with byte
patterns, and errors out if used with str. This patch removes the flag
in get_translated_hotkey().


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


Acked-by: Steve Beattie <steve@nxnw.org> for trunk, 2.10 and 2.9
2017-02-21 18:47:43 +01:00
Steve Beattie
d47fdc7b42 regression tests: fix environ fail case
merge from trunk commit revision 3630

In the environ regression test, when the exec() of the child process
fails, we don't report FAIL to stdout, so the regression tests consider
it an error rather than a failure and abort, short-circuiting the
test script.

This commit fixes this by emitting the FAIL message when the result
from the wait() syscall indicates the child process did not succeed.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2017-02-01 21:44:40 -08:00
Christian Boltz
860ccb3b13 Dovecot profile: change Px to mrPx for /usr/lib/dovecot/*
Some of the /usr/lib/dovecot/* rules already have mrPx permissions,
while others don't.

With a more recent kernel, I noticed that at least auth, config, dict,
lmtp, pop3 and ssl-params need mrPx instead of just Px (confirmed by the
audit.log and actual breakage caused by the missing mr permissions).

The mr additions for anvil, log and managesieve are just a wild guess,
but I would be very surprised if they don't need mr.


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.
2017-01-30 20:44:40 +01:00
Christian Boltz
1395a86f84 Dovecot profile update
Add several permissions to the dovecot profiles that are needed on ubuntu
(surprisingly not on openSUSE, maybe it depends on the dovecot config?)

As discussed some weeks ago, the added permissions use only /run/
instead of /{var/,}run/ (which is hopefully superfluous nowadays).


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


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.
2017-01-26 21:42:52 +01:00
Kees Cook
6bcb0928d2 glibc uses /proc/*/auxv and /proc/*/status files, too
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2017-01-20 17:22:10 -08:00
Kees Cook
f73180c395 Apache2 profile updates for proper signal handling, optional saslauth,
and OCSP stapling

Acked-by: Seth Arnold <seth.arnold@canonical.com>
2017-01-20 17:19:56 -08:00
Steve Beattie
43495f0033 Subject: utils/aa-unconfined: fix netstat invocation regression
It was reported that converting the netstat command to examine
processes bound to ipv6 addresses broke on OpenSUSE due to the version
of nettools not supporting the short -4 -6 arguments.

This patch fixes the invocation of netstat to use the "--protocol
inet,inet6" arguments instead, which should return the same results
as the short options.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2017-01-09 09:22:58 -08:00
John Johansen
99cb8cc7f1 update version 2.10.2 2017-01-08 20:19:13 -08:00
Christian Boltz
7b47dee81e Backport abstractions/wayland changes from trunk r3590
Acked-by: Steve Beattie <steve@nxnw.org>

------------------------------------------------------------
revno: 3590
fixes bug: https://launchpad.net/bugs/1507469
committer: Seth Arnold <seth.arnold@canonical.com>
branch nick: apparmor
timestamp: Wed 2016-11-30 15:16:32 -0800
message:
  Add more wayland paths, suggested by Simon McVittie in
  https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1507469
2017-01-08 17:10:09 +01:00
Christian Boltz
789309f419 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:49:47 +01:00
Christian Boltz
e7488ebff1 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:24 +01:00
Christian Boltz
498853ca6e 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:25 +01:00
Christian Boltz
e262991d18 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:22:06 +01:00
Christian Boltz
90b8189547 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:53:39 +01:00
Christian Boltz
34d1b5ddce 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:15:23 +01:00
John Johansen
9d09389290 Add backwards compatibility php5 abstraction
Signed-off-by: John Johansen <john.johansen@canonical.com>
2016-12-07 00:29:41 -08:00
John Johansen
b292de2ca0 Update php abstraction
Signed-off-by: kees cook <kees@outflux.net>
Acked-by: John Johansen <john.johansen@canonical.com>
2016-12-07 00:26:57 -08:00
Christian Boltz
e5daa5fa39 logparser.py: improve file vs. network event recognition
Sometimes network events come with an operation keyword looking like
file_perm which makes them look like file events. Instead of ignoring
these events (which was a hotfix to avoid crashes), improve the type
detection.

In detail, this means:
- replace OPERATION_TYPES (which was basically a list of network event
  keywords) with OP_TYPE_FILE_OR_NET (which is a list of keywords for
  file and network events)
- change op_type() parameters to expect the whole event, not only the
  operation keyword, and rebuild the type detection based on the event
  details
- as a side effect, this simplifies the detection for file event
  operations in parse_event_for_tree()
- remove workaround code from parse_event_for_tree()

Also add 4 new testcases with log messages that were ignored before.

References:

a) various bugreports about crashes caused by unexpected operation keywords:
   https://bugs.launchpad.net/apparmor/+bug/1466812
   https://bugs.launchpad.net/apparmor/+bug/1509030
   https://bugs.launchpad.net/apparmor/+bug/1540562
   https://bugs.launchpad.net/apparmor/+bug/1577051
   https://bugs.launchpad.net/apparmor/+bug/1582374

b) the summary bug for this patch
   https://bugs.launchpad.net/apparmor/+bug/1613061



Acked-by: Steve Beattie <steve@nxnw.org> for trunk and 2.10.


Note: in 2.10, the test_multi/*.profile files are unexpected and not
checked because this part of the tests is trunk-only, therefore I don't
include them.
2016-12-06 22:29:39 +01:00
John Johansen
383bbd68d6 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:21:27 -08:00
Steve Beattie
845507b8a1 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:06:55 -08:00
Christian Boltz
6b2a8191a6 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:36:19 +01:00
Christian Boltz
681fef917b 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:33:46 +01:00
Christian Boltz
b15f758490 logparser.py parse_event(): always store family, protocol and sock_type
Storing these event details depending on the operation type only makes
things more difficult because it's hard to differenciate between file
and network events.

Note that this happens at the first log parsing stage (libapparmor log
event -> temporary python array) and therefore doesn't add a serious
memory footprint. The event tree will still only contain the elements
relevant for the actual event type.

This change means that lots of testcases now get 3 more fields (all
None) when testing parse_event(), so update all affected testcases.
(test-network doesn't need a change for probably obvious reasons.)

Also rename a misnamed test in test-change_profile.


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


Note: 2.10 has fewer rule classes, therefore less test-*.py files need
to be changed. Also, I had to slightly adjust the logparser.py patch
because 2.10 doesn't have support for signal events.
2016-11-19 11:00:01 +01:00
Christian Boltz
c9e3e6e85a 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:01 +01:00
Christian Boltz
6920e3d717 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:15 +01:00
Christian Boltz
ae595aea03 Fix 'alias' rule description in apparmor.d manpage
The apparmor.d description about alias rules was broken in multiple
ways. The manpage
- didn't include the   alias   keyword
- listed alias rules in the "COMMA RULES" section - while that's correct
  for the comma requirement, it's also wrong because COMMA RULES is
  meant to be inside a profile
- didn't list alias rules in the PREAMBLE section

This patch fixes this.

It also moves the definition of VARIABLE, VARIABLE ASSIGNMENT (both
unchanged) and ALIAS RULE next to PREAMBLE.


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk and 2.10
2016-11-16 20:42:08 +01:00
Christian Boltz
1251e0c143 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:44:53 +01:00
Steve Beattie
b56fdec804 libapparmor python bindings: use __init__.py to import from LibAppArmor.py
Merge from trunk revision 3582.

Fix import errors with swig > 3.0.8 with the libapparmor python
bindings. Do this by removing the code to rename the generated
LibAppArmor.py, and instead use a stub __init__.py that automatically
imports everything from LibAppArmor.py. Also adjust bzrignore to
compensate for the autogenerated file name changing.

Bug: https://bugzilla.opensuse.org/show_bug.cgi?id=987607

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2016-11-14 14:10:35 -08:00
Christian Boltz
eacb977ebd 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:12 +01:00
Christian Boltz
29d287f94e 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:35:20 +01:00
Christian Boltz
9fd54008c4 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:17 +02:00
Christian Boltz
0ffc0941a8 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:03 +02:00
intrigeri
ed68e397aa Profile abstractions: add wayland/weston abstraction
Merged from trunk commit 3566.

Add a basic wayland abstraction.
Include the wayland abstraction from the gnome one.

This is the least invasive solution to the problem I'm trying to
solve right now (Evince not starting in GNOME on Wayland, and probably
similar issues for other GNOME applications I suppose).

Bug: https://bugs.debian.org/827335
Bug: https://bugs.debian.org/807880
2016-10-14 10:01:50 -07:00
Christian Boltz
c79607927d 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:29:59 +02:00
Christian Boltz
353ef34ca0 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:53:37 +02:00
Christian Boltz
80a17a6106 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:15 +02:00
Christian Boltz
44f2c6d2bc [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


*** *** ***   backport
*** *** ***   --fixes lp:1379874
2016-10-01 20:25:51 +02:00
Christian Boltz
a7898cfe5b 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:08 +02:00
Tyler Hicks
91b9b44f53 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:50:43 -05:00
Christian Boltz
8fcfc27d56 Allow 'kcm' in network rules
This is probably
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/Documentation/networking/kcm.txt


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk and 2.10.
2016-09-12 23:35:00 +02:00
Christian Boltz
791d40aa9d 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 new hat doesn't get initialized as
profile_storage(), and 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


Acked-by: Steve Beattie <steve@nxnw.org> for trunk, 2.10 and 2.9
2016-08-15 22:06:47 +02:00
Christian Boltz
4ad98a8302 type_is_str(): make pyflakes3 happy
pyflakes3 doesn't check sys.version and therefore complains about
'unicode' being undefined.

This patch defines unicode as alias of str to make pyflakes3 happy, and
as a side effect, simplifies type_is_str().


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk and 2.10.
2016-08-12 12:02:43 +02:00
Christian Boltz
064541cb53 delete_duplicates(): don't modify self.rules while looping over it
By calling self.delete() inside the delete_duplicates() loop, the
self.rules list was modified. This resulted in some rules not being
checked and therefore (some, not all) superfluous rules not being
removed.

This patch switches to a temporary variable to loop over, and rebuilds
self.rules with the rules that are not superfluous.

This also fixes some strange issues already marked with a "Huh?" comment
in the tests.


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

Note that in 2.10 cleanprof_test.* doesn't contain a ptrace rule,
therefore the cleanprof_test.out change doesn't make sense for 2.10.
2016-08-08 23:16:12 +02:00
Christian Boltz
9618cc9a62 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:06 +02:00
Christian Boltz
119522307f 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:15:42 +02:00
Christian Boltz
2a929f3f1c 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:44:18 +02:00
Seth Arnold
ec4de6e081 add ld.so.preload to <abstractions/base>, thanks to Uzair Shamim 2016-07-29 11:46:16 -07:00
Christian Boltz
fde4f8a522 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:13:49 +02:00
Seth Arnold
cad5d461ca intrigeri@boum.org 2016-06-24 mod_apparmor manpage: fix "documenation" typo. 2016-06-24 10:36:42 -07:00
Seth Arnold
922096a8be From: Simon McVittie <simon.mcvittie@collabora.co.uk>
Date: Tue, 21 Jun 2016 18:18:45 +0100
Subject: abstractions/nameservice: also support ConnMan-managed resolv.conf

Follow the same logic we already did for NetworkManager,
resolvconf and systemd-resolved. The wonderful thing about
standards is that there are so many to choose from.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>

[modified by sarnold to fit the surroundings]
2016-06-22 15:15:42 -07:00
Christian Boltz
9d8340a8b3 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:43:55 +02:00
Christian Boltz
1d8e388c93 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:07:33 +02:00
Christian Boltz
28d5c335af 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:06:25 +02:00
Christian Boltz
8ea1054f50 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:23 +02:00
Christian Boltz
36b699bcf6 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:51:55 +02:00
Christian Boltz
0125d04924 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:18:34 +02:00
Seth Arnold
ad169656bf 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:23:22 -07:00
Seth Arnold
0f7ccc49bb 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:30:29 -07:00
Christian Boltz
90e5294578 load variables in ask_the_questions()
Variables can be used in several rule types (from the existing *Rule
classes: change_profile, dbus, ptrace, signal). It seems nobody uses
variables with those rules, otherwise we'd have received a bugreport ;-)

I noticed this while working on FileRule, where usage of variables is
more common. The file code in bzr (not using a *Rule class) already
loads the variables, so old versions don't need changes for file rule
handling.

However, 2.10 already has ChangeProfileRule and therefore also needs
this fix.


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk and 2.10.
2016-05-10 14:34:40 +02:00
Christian Boltz
6d19a507ae 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:02:11 +02:00
John Johansen
fff8d65985 common/Version: prepare for 2.10.1 release 2016-04-20 02:07:34 -07:00
John Johansen
8e2595c634 Fix: parser: incorrect output of child profile names
BugLink: http://bugs.launchpad.net/bugs/1551950

The apparmor_parser is incorrectly outputting the names of child profiles
and hats, by adding a : between the parent and the child profile name

  Eg.
    /usr/sbin/httpd{,2}-prefork
    /usr/sbin/httpd{,2}-prefork://DEFAULT_URI
    /usr/sbin/httpd{,2}-prefork://HANDLING_UNTRUSTED_INPUT

  instead of what it should be
    /usr/sbin/httpd{,2}-prefork
    /usr/sbin/httpd{,2}-prefork//DEFAULT_URI
    /usr/sbin/httpd{,2}-prefork//HANDLING_UNTRUSTED_INPUT

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2016-04-18 13:09:51 -07:00
Christian Boltz
711ca72c6b smbd profile needs capability sys_admin
smbd stores ACLS in the security.NTACL namespace, which means it needs
capability sys_admin.

References: https://bugzilla.opensuse.org/show_bug.cgi?id=964971
            http://samba-technical.samba.narkive.com/eHtOW8DE/nt-acls-using-the-security-namespace-for-ntacl-considered-improper



Acked-by: Steve Beattie <steve@nxnw.org> for 2.10 and 2.9
(trunk got this and other changes via a merge request from Simon already)
2016-04-13 23:21:31 +02:00
Tyler Hicks
af8ccba6d2 profiles: Add attach_disconnected flag to dnsmasq profile
https://launchpad.net/bugs/1569316

When Ubuntu made the jump from network-manager 1.0.4 to 1.1.93, the
dnsmasq process spawned from network-manager started hitting a
disconnected path denial:

  audit: type=1400 audit(1460463960.943:31702): apparmor="ALLOWED"
    operation="connect" info="Failed name lookup - disconnected path"
    error=-13 profile="/usr/sbin/dnsmasq"
    name="run/dbus/system_bus_socket" pid=3448 comm="dnsmasq"
    requested_mask="wr" denied_mask="wr" fsuid=65534 ouid=0

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2016-04-12 16:37:26 -05:00
Christian Boltz
fa5d235f28 dovecot/auth: allow access to /var/run/dovecot/stats-user
Since the latest openSUSE Tumbleweed update (dovecot 2.2.21 -> 2.2.22),
dovecot/auth writes to /var/run/dovecot/stats-user.


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.
2016-04-07 00:53:30 +02:00
Christian Boltz
bdb18c5ccf Update abstractions/ssl_* for acmetool-generated certificates
acmetool is an alternative client for Let's Encrypt.
(https://github.com/hlandau/acme/)

It stores the certificates etc. in the following directory layout:

    /var/lib/acme/live/<domain> -> ../certs/<hash>
    /var/lib/acme/certs/<hash>/cert
    /var/lib/acme/certs/<hash>/chain
    /var/lib/acme/certs/<hash>/privkey -> ../../keys/<hash>/privkey
    /var/lib/acme/certs/<hash>/url
    /var/lib/acme/certs/<hash>/fullchain
    /var/lib/acme/keys/<hash>/privkey

This patch adds the needed permissions to the ssl_certs and ssl_keys
abstractions so that the certificates can be used.


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.
2016-03-28 21:43:23 +02:00
Christian Boltz
0cd0743b47 nscd profile: allow paranoia mode
In /etc/nscd.conf there is an option allowing to restart nscd after a
certain time. However, this requires reading /proc/self/cmdline -
otherwise nscd will disable paranoia mode.


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


Acked-By: Jamie Strandboge <jamie@canonical.com> for trunk, 2.10 and 2.9
2016-03-21 21:31:06 +01:00
Steve Beattie
6e1e27a931 utils: make aa-status(8) work without python3-apparmor
Merge from trunk commit 3391

Bug: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1480492

If python3-apparmor is not installed, aa-status aborts due to the
ded
import to handle fancier exception handling failing. This patch makes
aa-status(8) work even in that case, falling back to normal python
exceptions, to keep its required dependencies as small as possible.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2016-03-18 13:32:45 -07:00
Christian Boltz
150350c42c Fix wrong usage of write_prof_data in serialize_profile_from_old_profile()
write_prof_data[hat] is correct (it only contains one profile, see bug 1528139),
write_prof_data[profile][hat] is not and returns an empty (sub)hasher.

This affects RE_PROFILE_START and RE_PROFILE_BARE_FILE_ENTRY.


Acked-by: Kshitij Gupta <kgupta8592@gmail.com> for trunk, 2.9 and 2.10
2016-03-01 21:25:29 +01:00
Christian Boltz
61ee9623c5 Prevent crash caused by serialize_profile_from_old_profile()
If a profile file contains multiple profiles and one of those profiles
contains a rule managed by a *Ruleset class,
serialize_profile_from_old_profile() crashes with an AttributeError.

This happens because profile_data / write_prof_data contain only one
profile with its hats, which explodes if a file contains multiple
profiles, as reported in lp#1528139

Fixing this would need lots of
    write_prof_data[hat] -> write_prof_data[profile][hat]
changes (and of course also a change in the calling code) or, better
option, a full rewrite of serialize_profile_from_old_profile().

Unfortunately I don't have the time to do the rewrite at the moment (I
have other things on my TODO list), and changing write_prof_data[hat] ->
write_prof_data[profile][hat] is something that might introduce more
breakage, so I'm not too keen to do that.

Therefore this patch wraps the serialize_profile_from_old_profile() call
in try/except. If it fails, the diff will include an error message and
recommend to use 'View Changes b/w (C)lean profiles' instead, which is
known to work.

Note: I know using an error message as 'newprofile' isn't an usual way
to display an error message, but I found it more intuitive than
displaying it as a warning (without $PAGER).


References: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1528139



Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk and 2.10
2016-02-20 13:33:17 +01:00
Christian Boltz
458f696f8e dovecot-lda profile: allow tempfiles and executing sendmail
dovecot-lda needs to read and write /tmp/dovecot.lda.*.

It also needs to be able to execute sendmail to send sieve vacation
mails.

For now, I'm using a child profile for sendmail to avoid introducing a
new profile with possible regressions. This child profile is based on
the usr.sbin.sendmail profile in extras and should cover both postfix'
and sendmail's sendmail.
I also mixed in some bits that were needed for (postfix) sendmail on my
servers, and dropped some rules that were obsolete (directory rules not
ending with a /) or covered by an abstraction.

In the future, we might want to provide a stand-alone profile for
sendmail (based on this child profile) and change the rule in the
dovecot-lda profile to Px.


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



Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.
2016-02-20 01:16:49 +01:00
Christian Boltz
331e54b36e Add simple_tests/profile/profile_ns_bad8.sd to utils test exception list
parser/tst/simple_tests/profile/profile_ns_bad8.sd was added in r3376
(trunk) / r3312 (2.10 branch) and contains the profile name ':ns/t'
which misses the terminating ':' for the namespace.

Unfortunately the tools don't understand namespaces yet and just use the
full profile name. This also means this test doesn't fail as expected
when tested against the utils code.

This patch adds profile_ns_bad8.sd to the exception list of
test-parser-simple-tests.py.


Acked-by: Steve Beattie <steve@nxnw.org> for trunk and 2.10.
2016-02-19 00:25:20 +01:00
Tyler Hicks
85be9528ec parser: Allow AF_UNSPEC family in network rules
https://launchpad.net/bugs/1546455

Don't filter out AF_UNSPEC from the list of valid protocol families so
that the parser will accept rules such as 'network unspec,'.

There are certain syscalls, such as socket(2), where the LSM hooks are
called before the protocol family is validated. In these cases, AppArmor
was emitting denials even though socket(2) will eventually fail. There
may be cases where AF_UNSPEC sockets are accepted and we need to make
sure that we're mediating those appropriately.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Suggested-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>
[cboltz: Add 'unspec' to the network domain keywords of the utils]
2016-02-18 16:31:56 -06:00
Tyler Hicks
5493e01408 parser: Properly parse named transition targets
https://launchpad.net/bugs/1540666

Reuse the new parse_label() function to initialize named_transition
structs so that transition targets, when used with change_profile, are
properly seperated into a profile namespace and profile name.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2016-02-18 16:00:05 -06:00
Tyler Hicks
da0daadf40 parser: Allow the profile keyword to be used with namespaces
https://launchpad.net/bugs/1544387

Don't split namespaces from profile names using YACC grammar. Instead,
treat the entire string as a label in the grammer. The label can then be
split into a namespace and a profile name using the new parse_label()
function.

This fixes a bug that caused the profile keyword to not be used with a
label containing a namespace in the profile declaration.

Fixing this bug uncovered a bad parser test case at
simple_tests/profile/profile_ns_ok1.sd. The test case mistakenly
included two definitions of the :foo:unattached profile despite being
marked as expected to pass. I've adjusted the name of one of the
profiles to :foo:unattached2.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2016-02-18 16:00:04 -06:00
Christian Boltz
6d05fa4a6e Fix aa-mergeprof crash with files containing multiple profiles
If a profile file contains multiple profiles, aa-mergeprof crashes on
saving in write_profile() because the second profile in the file is not
listed in 'changed'. (This happens only if the second profile didn't
change.)

This patch first checks if 'changed' contains the profile before
pop()ing it.

Reproducer: copy utils/test/cleanprof_test.in to your profile directory
and run   aa-mergeprof utils/test/cleanprof_test.out. Then just press
's' to save the profile.


Acked-by: Kshitij Gupta <kgupta8592@gmail.com> for trunk, 2.10 and 2.9
2016-02-12 22:09:36 +01:00
Christian Boltz
f5df1bf45e Remove pname to bin_name mapping in autodep()
If autodep() is called with a pname starting with / (which can happen
for (N)amed exec depending on the user input), this pname is mapped to
bin_name.

This might look like a good idea, however if the given pname doesn't
exist as file on-disk, autodep() returns None instead of a (mostly
empty) profile. (Reproducer: choose (N)amed, enter "/foo/bar")

Further down the road, this results in two things:
a) the None result gets written as empty profile file (with only a "Last
   modified" line)
b) a crash if someone chooses to add an abstraction to the None, because
   None doesn't support the delete_duplicates() method for obvious
   reasons ;-)


Unfortunately this patch also introduces a regression - aa-logprof now
fails to follow the exec and doesn't ask about the log events for the
exec target anymore. However this doesn't really matter because of a) -
asking and saving to /dev/null vs. not asking isn't a real difference
;-)


Actually the patch slightly improves things - it creates a profile for
the exec target, but only with the depmod() defaults (abstractions/base)
and always in complain mode.

I'd prefer a patch that also creates a complete profile for the exec
target, but that isn't as easy as fixing the issues mentioned above and
therefore is something for a future fix. To avoid we forget it, I opened
https://bugs.launchpad.net/apparmor/+bug/1545155


Note: 2.9 "only" writes an empty file and doesn't crash - but writing
an empty profile is still an improvement.


Acked-by: Kshitij Gupta <kgupta8592@gmail.com> for trunk, 2.10 and 2.9
2016-02-12 21:57:25 +01:00
Christian Boltz
a80c75e308 apparmor.d.pod: document 'deny x'
deny rules don't allow ix, Px, Ux etc. - only 'deny /foo x,' is allowed.


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


Note: Seth mentioned in the mail that he doesn't like the 'deny x'
section too much, but we didn't find a better solution when discussing
it on IRC. Therefore I keep the patch unchanged, but will happily
review a follow-up patch if someone sends one ;-)
2016-02-12 21:43:42 +01:00
Christian Boltz
f5462aa931 logparser.py: do sanity check for all file events
Most probably-file log events can also be network events. Therefore
check for request_mask in all events, not only file_perm, file_inherit
and (from the latest bugreport) file_receive.

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


Acked-by: Kshitij Gupta <kgupta8592@gmail.com> for trunk, 2.10 and 2.9.
2016-02-10 19:09:57 +01:00
Tyler Hicks
91e73d54fe pam_apparmor: Don't leak /dev/urandom fd
If reading /dev/urandom failed, the corresponding file descriptor was
leaked through the error path.

Coverity CID #56012

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2016-02-01 10:35:57 -06:00
Tyler Hicks
57cdc4257d libapparmor: Correct meaning of EPERM in aa_change_profile man page
I suspect that the incorrect description of EPERM was copied from
the aa_change_hat man page, where it is possible to see EPERM if the
application is not confined by AppArmor.

This patch corrects the description by documenting that the only
possible way to see EPERM is if a confined application has the
no_new_privs bit set.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Reported-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2016-01-27 13:38:39 -06:00
Tyler Hicks
4c04a05996 libapparmor: Open fds may be revalidated after aa_change_profile()
It is possible that file descriptors will be revalidated after an
aa_change_profile() but there is a lot of complexity involved that
doesn't need to be spelled out in the man page. Instead, mention that
revalidation is possible but the only way to ensure that file
descriptors are not passed on is to close them.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Reported-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2016-01-27 13:38:39 -06:00
Tyler Hicks
a492bcfc80 libapparmor: Remove incorrect statement in aa_change_profile man page
The statement was meant to convey the difference between aa_change_hat()
and aa_change_profile(). Unfortunately, it read as if there was
something preventing a program from using aa_change_profile() twice to
move from profile A to profile B and back to profile A, even if profiles
A and B contained the necessary rules.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Reported-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2016-01-27 13:38:39 -06:00
Steve Beattie
ec9292bd5e utils: handle versioned ruby interpreters
Merge from trunk revision 3353

On Debian and Ubuntu it's possible to have multiple ruby interpreters
installed, and the default to use is handled by the ruby-defaults
package, which includes a symlink from /usr/bin/ruby to the versioned
ruby interpreter.

This patch makes aa.py:get_interpreter_and_abstraction() take that into
account by using a regex to match possible versions of ruby. Testcases
are included. (I noticed this lack of support because on Ubuntu the
ruby test was failing because get_interpreter_and_abstraction()
would get the complete path, which on my 16.04 laptop would get
/usr/bin/ruby2.2.)

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2016-01-25 23:05:47 -08:00
Christian Boltz
703cc22b52 utils/test/Makefile: print test filenames in 'make check' and 'make coverage'
This makes it easier to find the file that contains a failing test.



Acked-by: Steve Beattie <steve@nxnw.org> for trunk and 2.10.

Bug: https://launchpad.net/bugs/1526085
2016-01-25 23:49:54 +01:00
Christian Boltz
4fd66468d8 Better error message on unknown profile lines
When hitting an unknown line while parsing a profile, it's a good idea
to include that line in the error message ;-)


Note: 2.9 would print a literal \n because it doesn't have apparmor.fail,
so it will get a slightly different patch with spaces instead of \n.


Acked-by: Steve Beattie <steve@nxnw.org> for trunk, 2.10 and 2.9.

Bug: https://launchpad.net/bugs/1525119
2016-01-25 23:45:52 +01:00
Christian Boltz
b80aadd624 Improve __repr__() for *Ruleset
If a *Ruleset is empty, let __repr__() print/return

    <FooRuleset (empty) />

instead of

    <FooRuleset>
</FooRuleset>



Acked-by: Steve Beattie <steve@nxnw.org> for trunk and 2.10.

Bug: https://launchpad.net/bugs/1523297
2016-01-25 23:42:45 +01:00
Steve Beattie
0dde5efc62 regression tests: define arch specific bits for s390x
Merge from trunk revision 3342

bug: https://bugs.launchpad.net/bugs/1531325

This patch defines the arch specific registers struct for s390 for the
ptrace regression test.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>
2016-01-21 13:23:23 -08:00
Christian Boltz
99b59f7169 AARE: escape exclamation mark
'!' is a reserved symbol and needs to be escaped in AARE.

Note: aare.py only exists in trunk, therefore this part is trunk-only.



Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9 as needed.
2016-01-20 21:51:52 +01:00
Christian Boltz
061c76c5b1 Fix a missing comma in parser_misc.c capnames
The capnames list missed a comma, which lead to the funny
"mac_overridesyslog" capability name.

__debug_capabilities() seems to be the only user of capnames, which
might explain why this bug wasn't noticed earlier.


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.
2016-01-16 11:27:26 +01:00
John Johansen
dab2636a27 Fix: segfault when processing directories
BugLink: http://bugs.launchpad.net/bugs/1534405

Patch -r 2952 switched over to using the library kernel interface, and
added a kernel_interface parameter to the dir_cb struct, that is used
to process directories.

Unfortunately kernel_interface parameter of the dir_cb struct is not being
properly initialized resulting in odd failures and sefaults when the parser
is processing directories.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2016-01-14 17:30:33 -08:00
Christian Boltz
a41bff515f More useful logparser failure reports
If parse_event_for_tree() raises an AppArmorException (for example
because of an invalid/unknown request_mask), catch it in read_log() and
re-raise it together with the log line causing the Exception.



Acked-by: Steve Beattie <steve@nxnw.org> for trunk, 2.10 and 2.9.
2016-01-12 19:49:52 +01:00
Christian Boltz
483f11d06c Fix handling of link events in aa-logprof
handle_children() has some special code for handling link events with
denied_mask = 'l'. Unfortunately this special code depends on a regex
that matches the old, obsolete log format - in a not really parsed
format ("^from .* to .*$").

The result was that aa-logprof did not ask about events containing 'l'
in denied_mask.

Fortunately the fix is easy - delete the code with the special handling
for 'l' events, and the remaining code that handles other file
permissions will handle it :-)


References: Bugreport by pfak on IRC


Testcase (with hand-tuned log event):

    aa-logprof -f <( echo 'Jan  7 03:11:24 mail kernel: [191223.562261] type=1400 audit(1452136284.727:344): apparmor="ALLOWED" operation="link" profile="/usr/sbin/smbd" name="/foo" pid=10262 comm=616D617669736420286368362D3130 requested_mask="l" denied_mask="l" fsuid=110 ouid=110 target="/bar"')

should ask to add '/foo l,' to the profile.



Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.
2016-01-07 21:26:46 +01:00
Jamie Strandboge
1140e54442 Merge from trunk
allow read on /run/systemd/resolve/resolv.conf for systems using networkd
(LP: #1529074)

Signed-Off-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2016-01-05 17:04:34 -06:00
Christian Boltz
b54d1f2049 Write unix rules when saving a profile
r2637 added support for parsing unix rules, but forgot to add write
support. The result was that a profile lost its unix rules when it was
saved.

This patch adds the write_unix_rules() and write_unix() functions (based
on the write_pivot_root() and write_pivot_root_rules() functions) and
makes sure they get called at the right place.

The cleanprof testcase gets an unix rule added to ensure it's not
deleted when writing the profile. (Note that minitools_test.py is not
part of the default "make check", however I always run it.)


References: https://bugs.launchpad.net/apparmor/+bug/1522938
            https://bugzilla.opensuse.org/show_bug.cgi?id=954104



Acked-by: Tyler Hicks <tyhicks@canonical.com> for trunk, 2.10 and 2.9.
2015-12-17 23:48:43 +01:00
Christian Boltz
6e846245ab Adjust test-aa.py for python2
This means:
- expect unicode (instead of str) when reading from a file in py2
- convert keys() result to a set to avoid test failures because of
  dict_keys type

After this change, all tests work for both py2 and py3.


Acked-by: Tyler Hicks <tyhicks@canonical.com> for trunk and 2.10.
2015-12-17 23:45:33 +01:00
Christian Boltz
218cb42fbe Adjust type(x) == str checks in the rule classes for py2
python 3 uses only the 'str' type, while python 2 also uses 'unicode'.
This patch adds a type_is_str() function to common.py - depending on the
python version, it checks for both. This helper function is used to keep
the complexity outside of the rule classes.

The rule classes get adjusted to use type_is_str() instead of checking
for type(x) == str, which means they support both python versions.

Finally, add test-common.py with some tests for type_is_str().


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


Acked-by: Tyler Hicks <tyhicks@canonical.com> for trunk and 2.10

Note: 2.10 doesn't contain SignalRule and aare.py, and rule/__init__.py
doesn't have check_and_split_list(), therefore it doesn't get those
parts of the patch.
2015-12-17 23:38:02 +01:00
Tyler Hicks
df12e87fb5 utils: Use apparmor.fail for AppArmorException handling in aa-easyprof
Don't catch AppArmorExceptions in aa-easyprof any longer and rely on
apparmor.fail to print the exception to stderr.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2015-12-16 16:12:59 -06:00
Christian Boltz
5a2da347d4 Let the apparmor.fail error handler print to stderr
The patch also switches to using error() instead of a plain print() for
AppArmorException, which means prefixing the error message with 'ERROR: '



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


Acked-by: Tyler Hicks <tyhicks@canonical.com> for trunk and 2.10.
2015-12-16 12:00:00 +01:00
Tyler Hicks
cfbc1a2a79 parser: Honor the --namespace-string commandline option
https://launchpad.net/bugs/1526085

Revno 2934 'Add fns to handle profile removal to the kernel interface'
introduced a regression in the parser's namespace support by causing the
--namespace-string option to be ignored. This resulted in the profile(s)
being loaded into the global namespace rather than the namespace
specified on the command line.

This patch fixes the bug by setting the Profile object's ns member, if
the --namespace-string option was specified, immediately after the
Profile object is allocated.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2015-12-15 16:41:35 -06:00
Christian Boltz
51a0d5d863 ignore log event if request_mask == ''
We already check for None, but '' != None ;-)


References: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1525119


Acked-by: John Johansen <john.johansen@canonical.com> for 2.9, 2.10 and trunk.
2015-12-12 13:31:20 +01:00
Christian Boltz
3ab596ed83 Fix logparser.py crash on change_hat events
'change_hat' events have the target profile in 'name2', not in 'name'
(which is None and therefore causes a crash when checking if it contains
'//')

Also add the log event causing this crash to the libapparmor testsuite.

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


Acked-by: John Johansen <john.johansen@canonical.com> for trunk, 2.10 and 2.9.
2015-12-12 13:06:57 +01:00
Christian Boltz
d5824674d1 Several fixes for variable handling
Parsing variables was broken in several ways:
- empty quotes (representing an intentionally empty value) were lost,
  causing parser failures
- items consisting of only one letter were lost due to a bug in RE_VARS
- RE_VARS didn't start with ^, which means leading garbage (= syntax
  errors) was ignored
- trailing garbage was also ignored

This patch fixes those issues in separate_vars() and changes
var_transform() to write out empty quotes (instead of nothing) for empty
values.

Also add some tests for separate_vars() with empty quotes and adjust
several tests with invalid syntax to expect an AppArmorException.

var_transform() gets some tests added.

Finally, remove 3 testcases from the "fails to raise an exception" list
in test-parser-simple-tests.py.



Acked-by: John Johansen <john.johansen@canonical.com> for trunk and 2.9
(which also implies 2.10)


Note: 2.9 doesn't have test-parser-simple-tests.py, therefore it won't
get that part of the patch.
2015-12-12 13:01:19 +01:00
Christian Boltz
3ef80d788a Add realtime signals to SIGNALS list in apparmor.d
Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.10 and 2.9.
2015-12-02 22:06:07 +01:00
Christian Boltz
d579fc51d4 Add realtime signal example to the apparmor.d manpage
Acked-by: Steve Beattie <steve@nxnw.org> for trunk, 2.10 and 2.9.
2015-12-02 20:10:24 +01:00
Christian Boltz
8d68618f0b Add missing variables to the apparmor.d manpage
@{pids} and @{apparmorfs} was not mentioned in the apparmor.d manpage.


Acked-by: John Johansen <john.johansen@canonical.com> for trunk, 2.10 and 2.9
2015-11-28 21:45:20 +01:00
Christian Boltz
f6dcade84f Change abstract methods in BaseRule to use NotImplementedError
As Kshitij mentioned, abstract methods should use NotImplementedError
instead of AppArmorBug.

While changing this, I noticed that __repr__() needs to be robust against
NotImplementedError because get_raw() is not available in BaseRule.
Therefore the patch changes __repr__() to catch NotImplementedError.

Of course the change to NotImplementedError also needs several
adjustments in the tests.


Acked-by: Kshitij Gupta <kgupta8592@gmail.com>
(long before branching off 2.10, therefore I also commit to 2.10)


Note: 2.10 doesn't have test-signal.py, which means it can't be patched ;-)
2015-11-24 00:22:37 +01:00
Christian Boltz
0f4310d301 Map c (create) log events to w instead of a
Creating a file is in theory covered by the 'a' permission, however
discussion on IRC brought up that depending on the open flags it might
not be enough (real-world example: creating the apache pid file).

Therefore change the mapping to 'w' permissions. That might allow more
than needed in some cases, but makes sure the profile always works.


Acked-by: Kshitij Gupta <kgupta8592@gmail.com> for 2.9, 2.10 and trunk
2015-11-19 21:23:31 +01:00
Christian Boltz
84ab95d263 Also add python 3.5 to logprof.conf
Acked-by: Kshitij Gupta <kgupta8592@gmail.com> for 2.9, 2.10 and trunk
2015-11-19 20:23:26 +01:00
Jamie Strandboge
eb2adf119b Description: update python abstraction for python 3.
Signed-off-by: Jamie Strandboge <jamie@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2015-11-19 08:52:39 -06:00
Christian Boltz
68041e0d2e Add debug info to profile_storage()
For debugging, it's helpful to know which part of the code initialized a
profile_storage and for which profile and hat this was done.

This patch adds an 'info' array with that information, adds the
corresponding parameters to profile_storage() and changes the callers to
deliver some useful content.


Acked-by: John Johansen <john.johansen@canonical.com> for trunk and 2.10
2015-11-18 22:02:53 +01:00
Christian Boltz
4c0e6334b5 Fix parsing/storing bare file rules
We replaced parse_audit_allow() with parse_modifiers() in r2833, but
overlooked that parse_modifiers() returns allow/deny as boolean. This
resulted in storing bare file rules in aa[profile][hat]['path'][False]
instead of aa[profile][hat]['path']['allow'] (or True instead of 'deny'
for 'deny file,' rules), with the user-visible result of loosing bare
file rules when saving the profile.

This patch converts the boolean value from parse_modifiers back to a
string.

Note: 2.9 is not affected because the old parse_audit_allow() returns
'allow' or 'deny' as string, not as boolean.


Acked-by: Kshitij Gupta <kgupta8592@gmail.com> for trunk and 2.10
2015-11-18 21:31:45 +01:00
Christian Boltz
73cdd97596 update PYMODULES in tools/Makefile
PYMODULES is used for generating *.pod, so it should include rule/*.PYMODULES


Acked-by: Kshitij Gupta <kgupta8592@gmail.com> for trunk and 2.10
2015-11-18 21:29:25 +01:00
Christian Boltz
dfe58983bb utils/test/Makefile: add libapparmor to PYTHONPATH
The last utils/test/Makefile change switched to using the in-tree
libapparmor by default (unless USE_SYSTEM=1 is given). However, I missed
to add the swig/python parts of libapparmor to PYTHONPATH, so the
system-wide LibAppArmor/__init__.py was always used.

This patch adds the in-tree libapparmor python module to PYTHONPATH.

I'm sorry for the interesting[tm] way to find out that path, but
a) I don't know a better / less ugly way and
b) a similar monster already works in libapparmor/swig/python/test/ ;-)


Acked-by: John Johansen <john.johansen@canonical.com> for 2.9 and trunk
(that also implies 2.10 ;-)
2015-11-18 13:45:47 +01:00
Christian Boltz
07b6148fd1 Add python to the "no Px rule" list in logprof.conf
To make things more interesting, /usr/bin/python and /usr/bin/python[23]
are symlinks to /usr/bin/python[23].[0-9], so we have to explicitely
list several versions.


Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com> for 2.9, 2.10 and trunk
2015-11-18 13:39:33 +01:00
Steve Beattie
d04a03359c Update REPO_URL to point to the apparmor 2.10 branch 2015-11-18 01:32:49 -08:00
168 changed files with 1447 additions and 475 deletions

View File

@@ -88,7 +88,7 @@ libraries/libapparmor/swig/perl/MYMETA.yml
libraries/libapparmor/swig/perl/blib
libraries/libapparmor/swig/perl/libapparmor_wrap.c
libraries/libapparmor/swig/perl/pm_to_blib
libraries/libapparmor/swig/python/__init__.py
libraries/libapparmor/swig/python/LibAppArmor.py
libraries/libapparmor/swig/python/build/
libraries/libapparmor/swig/python/libapparmor_wrap.c
libraries/libapparmor/swig/python/Makefile

View File

@@ -18,7 +18,7 @@ DIRS=parser \
#REPO_URL?=lp:apparmor
# --per-file-timestamps is failing over SSH, https://bugs.launchpad.net/bzr/+bug/1257078
REPO_URL?=https://code.launchpad.net/~apparmor-dev/apparmor/master
REPO_URL?=https://code.launchpad.net/~apparmor-dev/apparmor/2.10
# alternate possibilities to export from
#REPO_URL=.
#REPO_URL="bzr+ssh://bazaar.launchpad.net/~sbeattie/+junk/apparmor-dev/"

View File

@@ -65,7 +65,7 @@ provides the AAHatName and AADefaultHatName Apache configuration options.
AAHatName allows you to specify a hat to be used for a given Apache
E<lt>DirectoryE<gt>, E<lt>DirectoryMatchE<gt>, E<lt>LocationE<gt> or
E<lt>LocationMatchE<gt> directive (see the Apache documenation for more
E<lt>LocationMatchE<gt> directive (see the Apache documentation for more
details). Note that mod_apparmor behavior can become confused if
E<lt>Directory*E<gt> and E<lt>Location*E<gt> directives are intermingled
and it is recommended to use one type of directive. If the hat specified by

View File

@@ -111,6 +111,7 @@ int pam_sm_open_session(pam_handle_t *pamh, int flags,
sizeof(magic_token));
if (retval < 0) {
pam_syslog(pamh, LOG_ERR, "Can't read from /dev/urandom\n");
close(fd);
return PAM_PERM_DENIED;
}
} while ((magic_token == 0) || (retval != sizeof(magic_token)));

View File

@@ -98,7 +98,7 @@ list_capabilities: /usr/include/linux/capability.h
# to mediate. We use PF_ here since that is what is required in
# bits/socket.h, but we will rewrite these as AF_.
FILTER_FAMILIES=PF_UNSPEC PF_UNIX
FILTER_FAMILIES=PF_UNIX
__FILTER=$(shell echo $(strip $(FILTER_FAMILIES)) | sed -e 's/ /\\\|/g')

View File

@@ -1 +1 @@
2.10
2.10.3

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

@@ -40,16 +40,15 @@ An AppArmor profile applies to an executable program; if a portion of
the program needs different access permissions than other portions,
the program can "change profile" to a different profile. To change into a
new profile, it can use the aa_change_profile() function to do so. It passes
in a pointer to the I<profile> to transition to. Transitioning to another
profile via aa_change_profile() is permanent and the process is not
permitted to transition back to the original profile. Confined programs
wanting to use aa_change_profile() need to have rules permitting changing
to the named profile. See apparmor.d(8) for details.
in a pointer to the I<profile> to transition to. Confined programs wanting to
use aa_change_profile() need to have rules permitting changing to the named
profile. See apparmor.d(8) for details.
If a program wants to return out of the current profile to the
original profile, it should use aa_change_hat(2) instead.
original profile, it may use aa_change_hat(2). Otherwise, the two profiles must
have rules permitting changing between the two profiles.
Open file descriptors are not remediated after a call to aa_change_profile()
Open file descriptors may not be remediated after a call to aa_change_profile()
so the calling program must close(2) open file descriptors to ensure they
are not available after calling aa_change_profile(). As aa_change_profile()
is typically used just before execve(2), you may want to use open(2) or
@@ -84,8 +83,8 @@ Insufficient kernel memory was available.
=item B<EPERM>
The calling application is not confined by apparmor, or the no_new_privs
bit is set.
The calling application is confined by apparmor and the no_new_privs bit is
set.
=item B<EACCES>

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

@@ -6,9 +6,8 @@ SUBDIRS = test
libapparmor_wrap.c: $(srcdir)/../SWIG/libapparmor.i
$(SWIG) -python -I$(srcdir)/../../include -module LibAppArmor -o $@ $(srcdir)/../SWIG/libapparmor.i
mv LibAppArmor.py __init__.py
MOSTLYCLEANFILES=libapparmor_wrap.c __init__.py
MOSTLYCLEANFILES=libapparmor_wrap.c LibAppArmor.py
all-local: libapparmor_wrap.c setup.py
if test ! -f libapparmor_wrap.c; then cp $(srcdir)/libapparmor_wrap.c . ; fi

View File

@@ -0,0 +1,6 @@
import sys
if sys.version_info[0] >= 3:
from LibAppArmor.LibAppArmor import *
else:
from .LibAppArmor import *

View File

@@ -121,7 +121,7 @@ class AAPythonBindingsTests(unittest.TestCase):
continue
else:
new_record[key] = str(value)
elif record.__getattr__(key):
elif value or value == '':
new_record[key] = str(value)
return new_record

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 @@
Oct 22 15:57:38 NR021AA kernel: [ 69.827705] audit: type=1400 audit(1445522258.769:1054): apparmor="DENIED" operation="file_inherit" profile="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=2407 comm="nm-dhcp-client." lport=10580 family="inet6" sock_type="dgram" protocol=17

View File

@@ -0,0 +1,14 @@
START
File: file_inherit_network_lp1509030.in
Event type: AA_RECORD_DENIED
Audit ID: 1445522258.769:1054
Operation: file_inherit
Profile: /usr/lib/NetworkManager/nm-dhcp-client.action
Command: nm-dhcp-client.
PID: 2407
Network family: inet6
Socket type: dgram
Protocol: udp
Local port: 10580
Epoch: 1445522258
Audit subid: 1054

View File

@@ -0,0 +1 @@
Jun 19 12:00:55 piorun kernel: [4475115.459952] audit: type=1400 audit(1434708055.676:19629): apparmor="ALLOWED" operation="file_perm" profile="/usr/sbin/apache2" pid=3512 comm="apache2" laddr=::ffff:192.168.236.159 lport=80 faddr=::ffff:192.168.103.80 fport=61985 family="inet6" sock_type="stream" protocol=6

View File

@@ -0,0 +1,17 @@
START
File: file_perm_network_lp1466812.in
Event type: AA_RECORD_ALLOWED
Audit ID: 1434708055.676:19629
Operation: file_perm
Profile: /usr/sbin/apache2
Command: apache2
PID: 3512
Network family: inet6
Socket type: stream
Protocol: tcp
Local addr: ::ffff:192.168.236.159
Foreign addr: ::ffff:192.168.103.80
Local port: 80
Foreign port: 61985
Epoch: 1434708055
Audit subid: 19629

View File

@@ -0,0 +1 @@
type=AVC msg=audit(1463403689.381:267599): apparmor="ALLOWED" operation="file_perm" profile="/usr/sbin/apache2//www.xxxxxxxxxx.co.uk" pid=13215 comm="apache2" laddr=::ffff:192.168.1.100 lport=80 faddr=::ffff:192.168.1.100 fport=45658 family="inet6" sock_type="stream" protocol=6 requested_mask="send" denied_mask="send"

View File

@@ -0,0 +1,19 @@
START
File: file_perm_network_receive_lp1577051.in
Event type: AA_RECORD_ALLOWED
Audit ID: 1463403689.381:267599
Operation: file_perm
Mask: send
Denied Mask: send
Profile: /usr/sbin/apache2//www.xxxxxxxxxx.co.uk
Command: apache2
PID: 13215
Network family: inet6
Socket type: stream
Protocol: tcp
Local addr: ::ffff:192.168.1.100
Foreign addr: ::ffff:192.168.1.100
Local port: 80
Foreign port: 45658
Epoch: 1463403689
Audit subid: 267599

View File

@@ -0,0 +1 @@
Apr 30 21:53:05 nova kernel: [24668.960760] audit: type=1400 audit(1462045985.636:2154): apparmor="ALLOWED" operation="file_perm" profile="/usr/local/apache-tomcat-8.0.33/bin/catalina.sh///usr/local/jdk1.8.0_92/bin/java" pid=12529 comm="java" laddr=::ffff:127.0.0.1 lport=8080 faddr=::ffff:127.0.0.1 fport=52308 family="inet6" sock_type="stream" protocol=6 requested_mask="receive" denied_mask="receive"

View File

@@ -0,0 +1,19 @@
START
File: file_perm_network_receive_lp1582374.in
Event type: AA_RECORD_ALLOWED
Audit ID: 1462045985.636:2154
Operation: file_perm
Mask: receive
Denied Mask: receive
Profile: /usr/local/apache-tomcat-8.0.33/bin/catalina.sh///usr/local/jdk1.8.0_92/bin/java
Command: java
PID: 12529
Network family: inet6
Socket type: stream
Protocol: tcp
Local addr: ::ffff:127.0.0.1
Foreign addr: ::ffff:127.0.0.1
Local port: 8080
Foreign port: 52308
Epoch: 1462045985
Audit subid: 2154

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 @@
type=AVC msg=audit(1449442292.901:961): apparmor="ALLOWED" operation="change_hat" profile="/usr/sbin/httpd{,2}-prefork" pid=8527 comm="httpd-prefork" target="/usr/sbin/httpd{,2}-prefork//HANDLING_UNTRUSTED_INPUT"

View File

@@ -0,0 +1,11 @@
START
File: testcase_changehat_01.in
Event type: AA_RECORD_ALLOWED
Audit ID: 1449442292.901:961
Operation: change_hat
Profile: /usr/sbin/httpd{,2}-prefork
Command: httpd-prefork
Name2: /usr/sbin/httpd{,2}-prefork//HANDLING_UNTRUSTED_INPUT
PID: 8527
Epoch: 1449442292
Audit subid: 961

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

@@ -0,0 +1 @@
Feb 21 23:22:01 mail-20170118 kernel: [1222198.459750] audit: type=1400 audit(1487719321.954:218): apparmor="ALLOWED" operation="change_hat" info="unconfined can not change_hat" error=-1 profile="unconfined" pid=19941 comm="apache2"

View File

@@ -0,0 +1,12 @@
START
File: unconfined-change_hat.in
Event type: AA_RECORD_ALLOWED
Audit ID: 1487719321.954:218
Operation: change_hat
Profile: unconfined
Command: apache2
Info: unconfined can not change_hat
ErrorCode: 1
PID: 19941
Epoch: 1487719321
Audit subid: 218

View File

@@ -196,16 +196,20 @@ static void writeu16(std::ostringstream &o, int v)
#define CMD_OPT 4
void unix_rule::downgrade_rule(Profile &prof) {
unsigned int mask = (unsigned int) -1;
if (!prof.net.allow && !prof.alloc_net_table())
yyerror(_("Memory allocation error."));
if (sock_type_n != -1)
mask = 1 << sock_type_n;
if (deny) {
prof.net.deny[AF_UNIX] |= 1 << sock_type_n;
prof.net.deny[AF_UNIX] |= mask;
if (!audit)
prof.net.quiet[AF_UNIX] |= 1 << sock_type_n;
prof.net.quiet[AF_UNIX] |= mask;
} else {
prof.net.allow[AF_UNIX] |= 1 << sock_type_n;
prof.net.allow[AF_UNIX] |= mask;
if (audit)
prof.net.audit[AF_UNIX] |= 1 << sock_type_n;
prof.net.audit[AF_UNIX] |= mask;
}
}

View File

@@ -46,7 +46,13 @@ to the policy; this behaviour is modelled after cpp(1).
B<PROFILE FILE> = ( [ I<PREAMBLE> ] [ I<PROFILE> ] )*
B<PREAMBLE> = ( I<COMMENT> | I<VARIABLE ASSIGNMENT> | I<INCLUDE> )* (variable assignment must come before the profile)
B<PREAMBLE> = ( I<COMMENT> | I<VARIABLE ASSIGNMENT> | I<ALIAS RULE> | I<INCLUDE> )* (variable assignment and alias rules must come before the profile)
B<VARIABLE ASSIGNMENT> = I<VARIABLE> ('=' | '+=') (space separated values)
B<VARIABLE> = '@{' I<ALPHA> [ ( I<ALPHANUMERIC> | '_' ) ... ] '}'
B<ALIAS RULE> = 'alias' I<ABS PATH> '-E<gt>' I<REWRITTEN ABS PATH> ','
B<INCLUDE> = '#include' ( I<ABS PATH> | I<MAGIC PATH> )
@@ -78,7 +84,7 @@ B<RULES> = [ ( I<LINE RULES> | I<COMMA RULES> ',' | I<BLOCK RULES> )
B<LINE RULES> = ( I<COMMENT> | I<INCLUDE> ) [ '\r' ] '\n'
B<COMMA RULES> = ( I<CAPABILITY RULE> | I<NETWORK RULE> | I<MOUNT RULE> | I<PIVOT ROOT RULE> | I<UNIX RULE> | I<FILE RULE> | I<LINK RULE> | I<CHANGE_PROFILE RULE> | I<RLIMIT RULE> | I<ALIAS RULE> | I<DBUS RULE> )
B<COMMA RULES> = ( I<CAPABILITY RULE> | I<NETWORK RULE> | I<MOUNT RULE> | I<PIVOT ROOT RULE> | I<UNIX RULE> | I<FILE RULE> | I<LINK RULE> | I<CHANGE_PROFILE RULE> | I<RLIMIT RULE> | I<DBUS RULE> )
B<BLOCK RULES> = ( I<SUBPROFILE> | I<HAT> | I<QUALIFIER BLOCK> )
@@ -103,7 +109,7 @@ capabilities(7))
B<NETWORK RULE> = [ I<QUALIFIERS> ] 'network' [ I<DOMAIN> ] [ I<TYPE> | I<PROTOCOL> ]
B<DOMAIN> = ( 'inet' | 'ax25' | 'ipx' | 'appletalk' | 'netrom' | 'bridge' | 'atmpvc' | 'x25' | 'inet6' | 'rose' | 'netbeui' | 'security' | 'key' | 'packet' | 'ash' | 'econet' | 'atmsvc' | 'sna' | 'irda' | 'pppox' | 'wanpipe' | 'bluetooth' | 'netlink' | 'unix' | 'rds' | 'llc' | 'can' | 'tipc' | 'iucv' | 'rxrpc' | 'isdn' | 'phonet' | 'ieee802154' | 'caif' | 'alg' | 'nfc' | 'vsock' | 'mpls' | 'ib' ) ','
B<DOMAIN> = ( 'inet' | 'ax25' | 'ipx' | 'appletalk' | 'netrom' | 'bridge' | 'atmpvc' | 'x25' | 'inet6' | 'rose' | 'netbeui' | 'security' | 'key' | 'packet' | 'ash' | 'econet' | 'atmsvc' | 'sna' | 'irda' | 'pppox' | 'wanpipe' | 'bluetooth' | 'netlink' | 'unix' | 'rds' | 'llc' | 'can' | 'tipc' | 'iucv' | 'rxrpc' | 'isdn' | 'phonet' | 'ieee802154' | 'caif' | 'alg' | 'nfc' | 'vsock' | 'mpls' | 'ib' | 'kcm' | 'smc' ) ','
B<TYPE> = ( 'stream' | 'dgram' | 'seqpacket' | 'rdm' | 'raw' | 'packet' )
@@ -161,7 +167,7 @@ B<SIGNAL SET> = 'set' '=' '(' I<SIGNAL LIST> ')'
B<SIGNAL LIST> = Comma or space separated list of I<SIGNALS>
B<SIGNALS> = ( 'hup' | 'int' | 'quit' | 'ill' | 'trap' | 'abrt' | 'bus' | 'fpe' | 'kill' | 'usr1' | 'segv' | 'usr2' | 'pipe' | 'alrm' | 'term' | 'stkflt' | 'chld' | 'cont' | 'stop' | 'stp' | 'ttin' | 'ttou' | 'urg' | 'xcpu' | 'xfsz' | 'vtalrm' | 'prof' | 'winch' | 'io' | 'pwr' | 'sys' | 'emt' | 'exists' )
B<SIGNALS> = ( 'hup' | 'int' | 'quit' | 'ill' | 'trap' | 'abrt' | 'bus' | 'fpe' | 'kill' | 'usr1' | 'segv' | 'usr2' | 'pipe' | 'alrm' | 'term' | 'stkflt' | 'chld' | 'cont' | 'stop' | 'stp' | 'ttin' | 'ttou' | 'urg' | 'xcpu' | 'xfsz' | 'vtalrm' | 'prof' | 'winch' | 'io' | 'pwr' | 'sys' | 'emt' | 'exists' | 'rtmin+0' ... 'rtmin+32' )
B<SIGNAL PEER> = 'peer' '=' I<AARE>
@@ -251,18 +257,12 @@ B<UNQUOTED FILEGLOB> = (must start with '/' (after variable expansion), B<AARE>
B<ACCESS> = ( 'r' | 'w' | 'a' | 'l' | 'k' | 'm' | I<EXEC TRANSITION> )+ (not all combinations are allowed; see below.)
B<EXEC TRANSITION> = ( 'ix' | 'ux' | 'Ux' | 'px' | 'Px' | 'cx' | 'Cx' | 'pix' | 'Pix' | 'cix' | 'Cix' | 'pux' | 'PUx' | 'cux' | 'CUx' )
B<EXEC TRANSITION> = ( 'ix' | 'ux' | 'Ux' | 'px' | 'Px' | 'cx' | 'Cx' | 'pix' | 'Pix' | 'cix' | 'Cix' | 'pux' | 'PUx' | 'cux' | 'CUx' | 'x' ) ('x' is only allowed in rules with the deny qualifier, everything else only without the deny qualifier)
B<EXEC TARGET> = name (requires I<EXEC TRANSITION> specified)
B<LINK RULE> = I<QUALIFIERS> [ 'owner' ] 'link' [ 'subset' ] I<FILEGLOB> ( 'to' | '-E<gt>' ) I<FILEGLOB>
B<VARIABLE> = '@{' I<ALPHA> [ ( I<ALPHANUMERIC> | '_' ) ... ] '}'
B<VARIABLE ASSIGNMENT> = I<VARIABLE> ('=' | '+=') (space separated values)
B<ALIAS RULE> = I<ABS PATH> '-E<gt>' I<REWRITTEN ABS PATH>
B<ALPHA> = ('a', 'b', 'c', ... 'z', 'A', 'B', ... 'Z')
B<ALPHANUMERIC> = ('0', '1', '2', ... '9', 'a', 'b', 'c', ... 'z', 'A', 'B', ... 'Z')
@@ -366,6 +366,10 @@ modes:
- transition to subprofile on execute with fallback to unconfined -- scrub the environment
=item B<deny x>
- disallow execute (in rules with the deny qualifier)
=item B<m>
- allow PROT_EXEC with mmap(2) calls
@@ -425,7 +429,7 @@ over the callee. Use this mode only if the child absolutely must be
run unconfined and LD_PRELOAD must be used. Any profile using this mode
provides negligible security. Use at your own risk.
Incompatible with other exec transition modes.
Incompatible with other exec transition modes and the deny qualifier.
=item B<Ux - unconfined execute -- scrub the environment>
@@ -439,7 +443,7 @@ designated child processes to be run without any AppArmor protection.
Use this mode only if the child absolutely must be run unconfined. Use
at your own risk.
Incompatible with other exec transition modes.
Incompatible with other exec transition modes and the deny qualifier.
=item B<px - Discrete Profile execute mode>
@@ -451,7 +455,7 @@ B<WARNING> 'px' does not scrub the environment of variables such as
LD_PRELOAD; as a result, the calling domain may have an undue amount of
influence over the callee.
Incompatible with other exec transition modes.
Incompatible with other exec transition modes and the deny qualifier.
=item B<Px - Discrete Profile execute mode -- scrub the environment>
@@ -460,7 +464,7 @@ will invoke the Linux Kernel's B<unsafe_exec> routines to scrub
the environment, similar to setuid programs. (See ld.so(8) for some
information on setuid/setgid environment scrubbing.)
Incompatible with other exec transition modes.
Incompatible with other exec transition modes and the deny qualifier.
=item B<cx - Transition to Subprofile execute mode>
@@ -472,7 +476,7 @@ B<WARNING> 'cx' does not scrub the environment of variables such as
LD_PRELOAD; as a result, the calling domain may have an undue amount of
influence over the callee.
Incompatible with other exec transition modes.
Incompatible with other exec transition modes and the deny qualifier.
=item B<Cx - Transition to Subprofile execute mode -- scrub the environment>
@@ -481,7 +485,7 @@ will invoke the Linux Kernel's B<unsafe_exec> routines to scrub
the environment, similar to setuid programs. (See ld.so(8) for some
information on setuid/setgid environment scrubbing.)
Incompatible with other exec transition modes.
Incompatible with other exec transition modes and the deny qualifier.
=item B<ix - Inherit execute mode>
@@ -495,7 +499,7 @@ profile, or losing the permissions of the current profile. There is no
version to scrub the environment because 'ix' executions don't change
privileges.
Incompatible with other exec transition modes.
Incompatible with other exec transition modes and the deny qualifier.
=item B<Profile transition with inheritance fallback execute mode>
@@ -509,7 +513,7 @@ the 'ix' transition mode.
'Cix' == 'Cx' with fallback to 'ix'
'cix' == 'cx' with fallback to 'ix'
Incompatible with other exec transition modes.
Incompatible with other exec transition modes and the deny qualifier.
=item B<Profile transition with unconfined fallback execute mode>
@@ -524,7 +528,14 @@ if 'PUx', 'CUx' is used.
'CUx' == 'Cx' with fallback to 'Ux'
'cux' == 'cx' with fallback to 'ux'
Incompatible with other exec transition modes.
Incompatible with other exec transition modes and the deny qualifier.
=item B<deny x - Deny execute>
For rules including the deny modifier, only 'x' is allowed to deny execute.
The 'ix', 'Px', 'px', 'Cx', 'cx' and the fallback modes conflict with the deny
modifier.
=item B<Directed profile transitions>
@@ -964,6 +975,9 @@ Example AppArmor signal rules:
# Allow us to signal ourselves using the built-in @{profile_name} variable
signal peer=@{profile_name},
# Allow two real-time signals
signal set=(rtmin+0 rtmin+32),
=head2 DBus rules
AppArmor supports DBus mediation. The mediation is performed in conjunction
@@ -1220,7 +1234,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:
@@ -1229,8 +1244,10 @@ provided AppArmor policy:
@{HOMEDIRS}
@{multiarch}
@{pid}
@{pids}
@{PROC}
@{securityfs}
@{apparmorfs}
@{sys}
@{tid}
@{XDG_DESKTOP_DIR}

View File

@@ -288,7 +288,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

@@ -672,7 +672,7 @@ public:
~hashedNodeVec()
{
delete nodes;
delete [] nodes;
}
unsigned long size()const { return len; }

View File

@@ -393,6 +393,9 @@ extern int get_rlimit(const char *name);
extern char *process_var(const char *var);
extern int parse_mode(const char *mode);
extern int parse_X_mode(const char *X, int valid, const char *str_mode, int *mode, int fail);
void parse_label(char **ns, char **name, const char *label);
void parse_named_transition_target(struct named_transition *nt,
const char *target);
extern struct cod_entry *new_entry(char *ns, char *id, int mode, char *link_id);
/* returns -1 if value != true or false, otherwise 0 == false, 1 == true */

View File

@@ -225,8 +225,8 @@ SET_VAR_PREFIX @
SET_VARIABLE {SET_VAR_PREFIX}(\{{VARIABLE_NAME}\}|{VARIABLE_NAME})
BOOL_VARIABLE $(\{{VARIABLE_NAME}\}|{VARIABLE_NAME})
PATHNAME (\/|{SET_VARIABLE}{POST_VAR_ID}){ID}*
QPATHNAME \"(\/|{SET_VAR_PREFIX})([^\0"]|\\\")*\"
LABEL (\/|{SET_VARIABLE}{POST_VAR_ID}|{COLON}){ID}*
QUOTED_LABEL \"(\/|{SET_VAR_PREFIX}|{COLON})([^\0"]|\\\")*\"
OPEN_PAREN \(
CLOSE_PAREN \)
@@ -510,7 +510,7 @@ LT_EQUAL <=
}
<MOUNT_MODE,DBUS_MODE,SIGNAL_MODE,PTRACE_MODE,UNIX_MODE>{
({IDS_NOEQ}|{PATHNAME}|{QUOTED_ID}) {
({IDS_NOEQ}|{LABEL}|{QUOTED_ID}) {
yylval.id = processid(yytext, yyleng);
RETURN_TOKEN(TOK_ID);
}
@@ -557,7 +557,7 @@ include/{WS} {
{CLOSE_BRACE} { RETURN_TOKEN(TOK_CLOSE); }
({PATHNAME}|{QPATHNAME}) {
({LABEL}|{QUOTED_LABEL}) {
yylval.id = processid(yytext, yyleng);
RETURN_TOKEN(TOK_ID);
}

View File

@@ -964,8 +964,10 @@ int main(int argc, char *argv[])
void *data);
struct dir_cb_data cb_data;
memset(&cb_data, 0, sizeof(struct dir_cb_data));
cb_data.dirname = profilename;
cb_data.cachedir = cacheloc;
cb_data.kernel_interface = kernel_interface;
cb = binary_input ? binary_dir_cb : profile_dir_cb;
if ((retval = dirat_for_each(AT_FDCWD, profilename,
&cb_data, cb))) {

View File

@@ -569,6 +569,65 @@ int parse_X_mode(const char *X, int valid, const char *str_mode, int *mode, int
return 1;
}
void parse_label(char **ns, char **name, const char *label)
{
const char *name_start = NULL;
char *_ns = NULL;
char *_name = NULL;
if (label[0] != ':') {
/* There is no namespace specified in the label */
name_start = label;
} else {
/* A leading ':' indicates that a namespace is specified */
const char *ns_start = label + 1;
const char *ns_end = strstr(ns_start, ":");
if (!ns_end)
yyerror(_("Namespace not terminated: %s\n"), label);
else if (ns_end - ns_start == 0)
yyerror(_("Empty namespace: %s\n"), label);
/**
* Handle either of the two namespace formats:
* 1) :ns:name
* 2) :ns://name
*/
name_start = ns_end + 1;
if (!strncmp(name_start, "//", 2))
name_start += 2;
_ns = strndup(ns_start, ns_end - ns_start);
if (!_ns)
yyerror(_("Memory allocation error."));
}
if (!strlen(name_start))
yyerror(_("Empty named transition profile name: %s\n"), label);
_name = strdup(name_start);
if (!_name) {
free(_ns);
yyerror(_("Memory allocation error."));
}
*ns = _ns;
*name = _name;
}
void parse_named_transition_target(struct named_transition *nt,
const char *target)
{
memset(nt, 0, sizeof(*nt));
if (!target) {
/* Return with nt->present set to 0 (thanks to the memset) */
return;
}
parse_label(&nt->ns, &nt->name, target);
nt->present = 1;
}
struct cod_entry *new_entry(char *ns, char *id, int mode, char *link_id)
{
struct cod_entry *entry = NULL;
@@ -724,7 +783,7 @@ static const char *capnames[] = {
"audit_write",
"audit_control",
"setfcap",
"mac_override"
"mac_override",
"syslog",
};

View File

@@ -258,8 +258,6 @@ void add_local_entry(Profile *prof);
%type <boolean> opt_profile_flag
%type <boolean> opt_flags
%type <boolean> opt_perm_mode
%type <id> opt_ns
%type <id> ns_id
%type <id> opt_id
%type <prefix> opt_prefix
%type <fmode> dbus_perm
@@ -299,11 +297,6 @@ opt_profile_flag: { /* nothing */ $$ = 0; }
| TOK_PROFILE { $$ = 1; }
| hat_start { $$ = 2; }
ns_id: TOK_COLON id_or_var TOK_COLON { $$ = $2; }
opt_ns: { /* nothing */ $$ = NULL; }
| ns_id { $$ = $1; }
opt_id: { /* nothing */ $$ = NULL; }
| TOK_ID { $$ = $1; }
@@ -318,7 +311,26 @@ profile_base: TOK_ID opt_id_or_var flags TOK_OPEN rules TOK_CLOSE
yyerror(_("Memory allocation error."));
}
prof->name = $1;
parse_label(&prof->ns, &prof->name, $1);
free($1);
/* Honor the --namespace-string command line option */
if (profile_ns) {
/**
* Print warning if the profile specified a namespace
* different than the one specified with the
* --namespace-string command line option
*/
if (prof->ns && strcmp(prof->ns, profile_ns))
pwarn("%s: -n %s overriding policy specified namespace :%s:\n",
progname, profile_ns, prof->ns);
free(prof->ns);
prof->ns = strdup(profile_ns);
if (!prof->ns)
yyerror(_("Memory allocation error."));
}
prof->attachment = $2;
if ($2 && !($2[0] == '/' || strncmp($2, "@{", 2) == 0))
yyerror(_("Profile attachment must begin with a '/' or variable."));
@@ -340,25 +352,18 @@ profile_base: TOK_ID opt_id_or_var flags TOK_OPEN rules TOK_CLOSE
};
profile: opt_profile_flag opt_ns profile_base
profile: opt_profile_flag profile_base
{
Profile *prof = $3;
if ($2)
PDEBUG("Matched: %s://%s { ... }\n", $2, $3->name);
else
PDEBUG("Matched: %s { ... }\n", $3->name);
Profile *prof = $2;
if ($3->name[0] != '/' && !($1 || $2))
if ($2->ns)
PDEBUG("Matched: :%s://%s { ... }\n", $2->ns, $2->name);
else
PDEBUG("Matched: %s { ... }\n", $2->name);
if ($2->name[0] != '/' && !($1 || $2->ns))
yyerror(_("Profile names must begin with a '/', namespace or keyword 'profile' or 'hat'."));
if ($2 && profile_ns) {
pwarn("%s: -n %s overriding policy specified namespace :%s:\n", progname, profile_ns, $2);
free($2);
prof->ns = strdup(profile_ns);
if (!prof->ns)
yyerror(_("Memory allocation error."));
} else
prof->ns = $2;
if ($1 == 2)
prof->flags.hat = 1;
$$ = prof;
@@ -1035,21 +1040,12 @@ id_or_var: TOK_SET_VAR { $$ = $1; };
opt_named_transition:
{ /* nothing */
$$.present = 0;
$$.ns = NULL;
$$.name = NULL;
parse_named_transition_target(&$$, NULL);
}
| TOK_ARROW id_or_var
{
$$.present = 1;
$$.ns = NULL;
$$.name = $2;
}
| TOK_ARROW ns_id id_or_var
{
$$.present = 1;
$$.ns = $2;
$$.name = $3;
parse_named_transition_target(&$$, $2);
free($2);
};
rule: file_rule { $$ = $1; }
@@ -1490,27 +1486,25 @@ change_profile_head: TOK_CHANGE_PROFILE opt_id
$$ = $2;
}
change_profile: change_profile_head TOK_END_OF_RULE
change_profile: change_profile_head opt_named_transition TOK_END_OF_RULE
{
struct cod_entry *entry;
char *rule = strdup("**");
if (!rule)
yyerror(_("Memory allocation error."));
PDEBUG("Matched change_profile,\n");
entry = new_entry(NULL, rule, AA_CHANGE_PROFILE, $1);
if (!entry)
yyerror(_("Memory allocation error."));
PDEBUG("change_profile,\n");
$$ = entry;
};
change_profile: change_profile_head TOK_ARROW opt_ns TOK_ID TOK_END_OF_RULE
{
struct cod_entry *entry;
PDEBUG("Matched change_profile: tok_id (:%s://%s)\n", $3 ? $3 : "", $4);
entry = new_entry($3, $4, AA_CHANGE_PROFILE, $1);
if ($2.present) {
PDEBUG("Matched change_profile: tok_id (:%s://%s)\n",
$2.ns ? $2.ns : "", $2.name);
entry = new_entry($2.ns, $2.name, AA_CHANGE_PROFILE, $1);
} else {
char *rule = strdup("**");
if (!rule)
yyerror(_("Memory allocation error."));
PDEBUG("Matched change_profile,\n");
entry = new_entry(NULL, rule, AA_CHANGE_PROFILE, $1);
}
if (!entry)
yyerror(_("Memory allocation error."));
PDEBUG("change_profile.entry: (%s)\n", entry->name);
$$ = entry;
};

View File

@@ -225,7 +225,7 @@ public:
std::string fqname(void)
{
if (parent)
return parent->fqname() + "://" + name;
return parent->fqname() + "//" + name;
else if (!ns)
return hname();
return ":" + std::string(ns) + "://" + hname();

View File

@@ -451,34 +451,7 @@ __apparmor_restart() {
configure_owlsm
parse_profiles reload
# Clean out running profiles not associated with the current profile
# set, excluding the libvirt dynamically generated profiles.
# Note that we reverse sort the list of profiles to remove to
# ensure that child profiles (e.g. hats) are removed before the
# parent. We *do* need to remove the child profile and not rely
# on removing the parent profile when the profile has had its
# child profile names changed.
profiles_names_list | awk '
BEGIN {
while (getline < "'${SFS_MOUNTPOINT}'/profiles" ) {
str = sub(/ \((enforce|complain)\)$/, "", $0);
if (match($0, /^libvirt-[0-9a-f\-]+$/) == 0)
arr[$str] = $str
}
}
{ if (length(arr[$0]) > 0) { delete arr[$0] } }
END {
for (key in arr)
if (length(arr[key]) > 0) {
printf("%s\n", arr[key])
}
}
' | LC_COLLATE=C sort -r | while IFS= read profile ; do
echo -n "$profile" > "$SFS_MOUNTPOINT/.remove"
done
# will not catch all errors, but still better than nothing
rc=$?
aa_log_end_msg $rc
return $rc

View File

@@ -3,6 +3,7 @@
#=EXRESULT PASS
#
/usr/bin/foo {
network unspec,
network inet,
network ax25,
network ipx,

View File

@@ -0,0 +1,9 @@
#
#=DESCRIPTION basic unspec network tests
#=EXRESULT PASS
#
/usr/bin/foo {
network unspec stream,
network unspec dgram,
network unspec raw,
}

View File

@@ -0,0 +1,9 @@
#
#=DESCRIPTION namespace with no profile name
#=EXRESULT FAIL
# vim:syntax=apparmor
# Last Modified: Thu Feb 11 00:14:20 2016
#
:namespace: {
/does/not/exist r,
}

View File

@@ -0,0 +1,13 @@
#
#=DESCRIPTION collision same profile, same namespace with profile keyword
#=EXRESULT FAIL
# vim:syntax=apparmor
# Last Modified: Thu Feb 11 00:14:20 2016
#
profile :ns:/t {
/does/not/exist r,
}
profile :ns:/t {
/does/not/exist r,
}

View File

@@ -0,0 +1,13 @@
#
#=DESCRIPTION collision same profile, same namespace w/ and w/o profile keyword
#=EXRESULT FAIL
# vim:syntax=apparmor
# Last Modified: Thu Feb 11 00:14:20 2016
#
:ns:/t {
/does/not/exist r,
}
profile :ns:/t {
/does/not/exist r,
}

View File

@@ -0,0 +1,9 @@
#
#=DESCRIPTION no terminating ':' for ns namespace (w/ profile keyword)
#=EXRESULT FAIL
# vim:syntax=apparmor
# Last Modified: Thu Feb 11 00:14:20 2016
#
profile :ns/t {
/does/not/exist r,
}

View File

@@ -40,7 +40,7 @@ profile :foo:/does/not/exist2 {
/bin/echo uxuxuxuxux,
}
profile :foo:unattached {
profile :foo:unattached2 {
#include <includes/base>
/usr/X11R6/lib/lib*so* rrr,

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

@@ -8,6 +8,8 @@
signal (receive) peer=unconfined,
# Allow apache to send us signals by default
signal (receive) peer=/usr/sbin/apache2,
# Allow other hats to signal by default
signal peer=/usr/sbin/apache2//*,
# Allow us to signal ourselves
signal peer=@{profile_name},
@@ -25,3 +27,8 @@
/dev/urandom r,
# sasl-auth
/run/saslauthd/mux rw,
# OCSP stapling
/var/log/apache2/stapling-cache rw,

View File

@@ -47,6 +47,7 @@
# ld.so.cache and ld are used to load shared libraries; they are best
# available everywhere
/etc/ld.so.cache mr,
/etc/ld.so.preload r,
/lib{,32,64}/ld{,32,64}-*.so mrix,
/lib{,32,64}/**/ld{,32,64}-*.so mrix,
/lib/@{multiarch}/ld{,32,64}-*.so mrix,
@@ -91,7 +92,7 @@
/sys/devices/system/cpu/online r,
# glibc's *printf protections read the maps file
@{PROC}/@{pid}/maps r,
@{PROC}/@{pid}/{maps,auxv,status} r,
# libgcrypt reads some flags from /proc
@{PROC}/sys/crypto/* r,

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

@@ -10,10 +10,10 @@
# ------------------------------------------------------------------
# system configuration
/usr/share/applications/ r,
/usr/share/applications/defaults.list r,
/usr/share/applications/mimeinfo.cache r,
/usr/share/applications/*.desktop r,
/usr/{,local/}share/applications/{*/,} r,
/usr/{,local/}share/applications/{*/,}defaults.list r,
/usr/{,local/}share/applications/{*/,}mimeinfo.cache r,
/usr/{,local/}share/applications/{*/,}*.desktop r,
/usr/share/icons/ r,
/usr/share/icons/** r,
/usr/share/pixmaps/ r,

View File

@@ -15,12 +15,15 @@
#include <abstractions/freedesktop.org>
#include <abstractions/xdg-desktop>
#include <abstractions/user-tmp>
#include <abstractions/wayland>
# systemwide gtk defaults
/etc/gnome/gtkrc* r,
/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

@@ -29,14 +29,14 @@
# When using sssd, the passwd and group files are stored in an alternate path
# and the nss plugin also needs to talk to a pipe
/var/lib/sss/mc/group r,
/var/lib/sss/mc/initgroups r,
/var/lib/sss/mc/passwd r,
/var/lib/sss/pipes/nss rw,
/etc/resolv.conf r,
# on systems using resolvconf, /etc/resolv.conf is a symlink to
# /{,var/}run/resolvconf/resolv.conf and a file sometimes referenced in
# /etc/resolvconf/run/resolv.conf
/{,var/}run/resolvconf/resolv.conf r,
# On systems where /etc/resolv.conf is managed programmatically, it is
# a symlink to /{,var/}run/(whatever program is managing it)/resolv.conf.
/{,var/}run/{resolvconf,NetworkManager,systemd/resolve,connman}/resolv.conf r,
/etc/resolvconf/run/resolv.conf r,
/etc/samba/lmhosts r,
@@ -47,7 +47,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

@@ -15,8 +15,8 @@
/usr/lib{,32,64}/perl5/** r,
/usr/lib{,32,64}/perl{,5}/**.so* mr,
/usr/lib/@{multiarch}/perl{,5}/** r,
/usr/lib/@{multiarch}/perl{,5}/[0-9]*/**.so* mr,
/usr/lib/@{multiarch}/perl{,5,-base}/** r,
/usr/lib/@{multiarch}/perl{,5,-base}/[0-9]*/**.so* mr,
/usr/share/perl/** r,
/usr/share/perl5/** r,

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

@@ -22,7 +22,7 @@
/etc/mailname r,
/etc/postfix/*.cf r,
/etc/postfix/*.db r,
/etc/postfix/*.db rk,
@{PROC}/net/if_inet6 r,
/usr/lib/postfix/*.so mr,
/usr/lib{,32,64}/sasl2/* mr,

View File

@@ -10,18 +10,18 @@
#
# ------------------------------------------------------------------
/usr/lib{,32,64}/python{2.[4-7],3.[0-4]}/**.{pyc,so} mr,
/usr/lib{,32,64}/python{2.[4-7],3.[0-4]}/**.{egg,py,pth} r,
/usr/lib{,32,64}/python{2.[4-7],3.[0-4]}/{site,dist}-packages/ r,
/usr/lib{,32,64}/python3.[0-4]/lib-dynload/*.so mr,
/usr/lib{,32,64}/python{2.[4-7],3.[0-6]}/**.{pyc,so} mr,
/usr/lib{,32,64}/python{2.[4-7],3.[0-6]}/**.{egg,py,pth} r,
/usr/lib{,32,64}/python{2.[4-7],3.[0-6]}/{site,dist}-packages/ r,
/usr/lib{,32,64}/python3.[0-6]/lib-dynload/*.so mr,
/usr/local/lib{,32,64}/python{2.[4-7],3.[0-4]}/**.{pyc,so} mr,
/usr/local/lib{,32,64}/python{2.[4-7],3.[0-4]}/**.{egg,py,pth} r,
/usr/local/lib{,32,64}/python{2.[4-7],3.[0-4]}/{site,dist}-packages/ r,
/usr/local/lib{,32,64}/python3.[0-4]/lib-dynload/*.so mr,
/usr/local/lib{,32,64}/python{2.[4-7],3.[0-6]}/**.{pyc,so} mr,
/usr/local/lib{,32,64}/python{2.[4-7],3.[0-6]}/**.{egg,py,pth} r,
/usr/local/lib{,32,64}/python{2.[4-7],3.[0-6]}/{site,dist}-packages/ r,
/usr/local/lib{,32,64}/python3.[0-6]/lib-dynload/*.so mr,
# Site-wide configuration
/etc/python{2.[4-7],3.[0-4]}/** r,
/etc/python{2.[4-7],3.[0-6]}/** r,
# shared python paths
/usr/share/{pyshared,pycentral,python-support}/** r,
@@ -34,4 +34,4 @@
/usr/lib/wx/python/*.pth r,
# python build configuration and headers
/usr/include/python{2.[4-7],3.[0-4]}*/pyconfig.h r,
/usr/include/python{2.[4-7],3.[0-6]}*/pyconfig.h r,

View File

@@ -10,9 +10,12 @@
# ------------------------------------------------------------------
/etc/samba/* r,
/usr/lib*/ldb/*.so mr,
/usr/lib*/samba/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

@@ -23,3 +23,7 @@
/usr/local/share/ca-certificates/** r,
/var/lib/ca-certificates/ r,
/var/lib/ca-certificates/** r,
# acmetool
/var/lib/acme/certs/*/chain r,
/var/lib/acme/certs/*/cert r,

View File

@@ -16,3 +16,7 @@
/etc/ssl/ r,
/etc/ssl/** r,
# acmetool
/var/lib/acme/live/* r,
/var/lib/acme/certs/** r,
/var/lib/acme/keys/** r,

View File

@@ -0,0 +1,14 @@
# vim:syntax=apparmor
# ------------------------------------------------------------------
#
# Copyright (C) 2016 intrigeri <intrigeri@boum.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.
#
# ------------------------------------------------------------------
owner /var/run/user/*/weston-shared-* rw,
owner /run/user/*/wayland-[0-9]* rw,
owner /run/user/*/{mesa,mutter,sdl,weston,xwayland}-shared-* 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 @@ profile syslog-ng /{usr/,}sbin/syslog-ng {
/{usr/,}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

@@ -18,6 +18,7 @@
capability setuid,
capability sys_chroot,
/run/dovecot/anvil rw,
/usr/lib/dovecot/anvil mr,
# Site-specific additions and overrides. See local/README for details.

View File

@@ -37,7 +37,14 @@
/var/tmp/sieve_* rw,
/var/tmp/smtp_* rw,
/run/dovecot/auth-master rw,
/run/dovecot/auth-worker rw,
/run/dovecot/login/login rw,
/{var/,}run/dovecot/auth-token-secret.dat{,.tmp} rw,
/{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

@@ -1,6 +1,6 @@
# ------------------------------------------------------------------
#
# Copyright (C) 2013 Christian Boltz
# Copyright (C) 2013-2016 Christian Boltz
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
@@ -12,7 +12,7 @@
#include <tunables/global>
#include <tunables/dovecot>
/usr/lib/dovecot/dovecot-lda {
/usr/lib/dovecot/dovecot-lda flags=(attach_disconnected) {
#include <abstractions/base>
#include <abstractions/nameservice>
#include <abstractions/dovecot-common>
@@ -24,10 +24,67 @@
/etc/dovecot/** r,
/proc/*/mounts r,
owner /tmp/dovecot.lda.* rw,
/{var/,}run/dovecot/mounts r,
/run/dovecot/auth-userdb rw,
/usr/bin/doveconf mrix,
/usr/lib/dovecot/dovecot-lda mrix,
/usr/sbin/sendmail Cx,
/usr/share/dovecot/protocols.d/ r,
# Site-specific additions and overrides. See local/README for details.
#include <local/usr.lib.dovecot.dovecot-lda>
profile /usr/sbin/sendmail flags=(attach_disconnected) {
# this profile is based on the usr.sbin.sendmail profile in extras
# and should support both postfix' and sendmail's sendmail binary
#include <abstractions/base>
#include <abstractions/consoles>
#include <abstractions/nameservice>
#include <abstractions/user-tmp>
#include <abstractions/postfix-common>
capability sys_ptrace,
/etc/aliases rw, # newaliases is a symlink to sendmail, so it's
/etc/aliases.db rw, # actually the same binary
/etc/fstab r,
/etc/hosts.allow r,
/etc/hosts.deny r,
/etc/mail/* r,
/etc/mail/statistics rw,
/etc/mtab r,
/etc/postfix/aliases r,
/etc/postfix/aliases.db rw, # newaliases again
/etc/sendmail.cf r,
/etc/sendmail.cw r,
/etc/shells r,
/proc/loadavg r,
/proc/net/if_inet6 r,
/root/.forward r,
/root/dead.letter w,
/usr/bin/procmail Px,
/usr/lib/postfix/master Px,
/usr/lib/postfix/showq Px,
/usr/lib/postfix/smtpd Px,
/usr/sbin/postalias Px,
/usr/sbin/postdrop Px,
/usr/sbin/postfix Px,
/usr/sbin/postqueue Px,
/usr/sbin/sendmail mrix,
/usr/sbin/sendmail.postfix mrix,
/usr/sbin/sendmail.sendmail mrix,
/{var/,}run/sendmail.pid rwl,
/{var/,}run/sm-client.pid rwl,
/{var/,}run/utmp rw,
/var/spool/clientmqueue/* rwl,
/var/spool/mail/* rwl,
/var/spool/mqueue/* rwl,
/var/spool/postfix/maildrop/* rwl,
/var/spool/postfix/public/pickup w,
/var/spool/postfix/public/qmgr w,
/var/spool/postfix/public/showq w,
}
}

View File

@@ -21,11 +21,21 @@
capability setuid,
deny capability block_suspend,
network unix stream,
@{DOVECOT_MAILSTORE}/ rw,
@{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,
/run/dovecot/login/imap rw,
/{,var/}run/dovecot/auth-master rw,
/{,var/}run/dovecot/mounts r,

View File

@@ -22,9 +22,11 @@
network inet stream,
network inet6 stream,
network unix stream,
/usr/lib/dovecot/imap-login mr,
/{,var/}run/dovecot/anvil rw,
/{,var/}run/dovecot/login-master-notify* rw,
/{,var/}run/dovecot/login/ r,
/{,var/}run/dovecot/login/* rw,

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

@@ -15,6 +15,7 @@
#include <abstractions/base>
#include <abstractions/dovecot-common>
/run/dovecot/login/ssl-params rw,
/usr/lib/dovecot/ssl-params mr,
/var/lib/dovecot/ssl-parameters.dat rw,
/var/lib/dovecot/ssl-parameters.dat.tmp rwk,

View File

@@ -12,7 +12,7 @@
@{TFTP_DIR}=/var/tftp /srv/tftpboot
#include <tunables/global>
/usr/sbin/dnsmasq {
/usr/sbin/dnsmasq flags=(attach_disconnected) {
#include <abstractions/base>
#include <abstractions/dbus>
#include <abstractions/nameservice>

View File

@@ -12,7 +12,7 @@
#include <tunables/global>
/usr/sbin/dovecot {
/usr/sbin/dovecot flags=(attach_disconnected) {
#include <abstractions/authentication>
#include <abstractions/base>
#include <abstractions/dovecot-common>
@@ -28,6 +28,7 @@
capability net_bind_service,
capability setuid,
capability sys_chroot,
capability sys_resource,
/etc/dovecot/** r,
/etc/mtab r,
@@ -35,21 +36,21 @@
/etc/SuSE-release r,
@{PROC}/@{pid}/mounts r,
/usr/bin/doveconf rix,
/usr/lib/dovecot/anvil Px,
/usr/lib/dovecot/auth Px,
/usr/lib/dovecot/config Px,
/usr/lib/dovecot/dict Px,
/usr/lib/dovecot/anvil mrPx,
/usr/lib/dovecot/auth mrPx,
/usr/lib/dovecot/config mrPx,
/usr/lib/dovecot/dict mrPx,
/usr/lib/dovecot/dovecot-auth Pxmr,
/usr/lib/dovecot/imap Pxmr,
/usr/lib/dovecot/imap-login Pxmr,
/usr/lib/dovecot/lmtp Px,
/usr/lib/dovecot/log Px,
/usr/lib/dovecot/managesieve Px,
/usr/lib/dovecot/lmtp mrPx,
/usr/lib/dovecot/log mrPx,
/usr/lib/dovecot/managesieve mrPx,
/usr/lib/dovecot/managesieve-login Pxmr,
/usr/lib/dovecot/pop3 Px,
/usr/lib/dovecot/pop3 mrPx,
/usr/lib/dovecot/pop3-login Pxmr,
/usr/lib/dovecot/ssl-build-param rix,
/usr/lib/dovecot/ssl-params Px,
/usr/lib/dovecot/ssl-params mrPx,
/usr/sbin/dovecot mrix,
/usr/share/dovecot/protocols.d/ r,
/usr/share/dovecot/protocols.d/** 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,9 +28,12 @@
/{,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,
@{PROC}/@{pid}/fd/* r,
@{PROC}/@{pid}/mounts 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

@@ -17,6 +17,7 @@
capability net_bind_service,
capability setgid,
capability setuid,
capability sys_admin, # needed to store ACLS in the security.NTACL namespace
capability sys_resource,
capability sys_tty_config,

View File

@@ -15,13 +15,16 @@
#include <abstractions/consoles>
#include <abstractions/nameservice>
deny capability net_admin, # noisy setsockopt() calls
capability net_raw,
network inet raw,
network inet6 raw,
/usr/sbin/traceroute rmix,
/usr/sbin/traceroute mrix,
/usr/bin/traceroute.db mrix,
@{PROC}/net/route r,
@{PROC}/sys/net/ipv4/{tcp_ecn,tcp_sack,tcp_timestamps,tcp_window_scaling} r,
# Site-specific additions and overrides. See local/README for details.
#include <local/usr.sbin.traceroute>

View File

@@ -7,6 +7,7 @@
deny capability block_suspend,
capability dac_override,
capability ipc_lock,
capability setuid,
@@ -19,6 +20,7 @@
@{PROC}/sys/kernel/core_pattern r,
/tmp/.winbindd/ w,
/tmp/krb5cc_* rwk,
/usr/lib*/samba/gensec/krb*.so mr,
/usr/lib*/samba/idmap/*.so mr,
/usr/lib*/samba/nss_info/*.so mr,
/usr/lib*/samba/pdb/*.so mr,

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,
}

Some files were not shown because too many files have changed in this diff Show More