2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-01 06:45:38 +00:00

Compare commits

..

178 Commits

Author SHA1 Message Date
John Johansen
702c282325 Prepare for AppArmor 3.0.6 release
- update version file

Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-08-01 01:22:42 -07:00
John Johansen
822db765c6 Merge abstraction/exo-open: Remove dbus deny rule
Abstractions should not generally include deny rules as this can unduly
constrain profiles which include them due to the precedent matching rules
between deny vs allow rules. Also as per the comment, this is not required
for exo-open to work, so simply omit it from the abstraction for
now. Finally, in Ubuntu, the evince profile includes the exo-open
abstraction and this deny rule causes evince to fail to initialise
correctly as it then assumes it cannot use gvfs.

Signed-off-by: Alex Murray <alex.murray@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/884
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit d7e3f33aa8)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-07-26 23:23:49 -07:00
Georgia Garcia
e34149546d parser: fix LTO build
The previous fix for LTO builds in b6d3daa7 did not take into
consideration that LTO support could be added through CFLAGS,in which
case the fix would not be applied.

This patch applied the fix -flto-partition=none even if CFLAGS is
already defined.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
Closes #214
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/901
Acked-by: John Johansen <john@jjmx.net>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
(cherry picked from commit 0afc2cbb84)
2022-07-25 17:36:05 -03:00
Christian Boltz
8668d4a456 Merge dirtest.sh: don't rely on apparmor_parser -N's output sort order to be deterministic
I've seen this test fail because "apparmor_parser -N" returned the expected
lines, but in a different order than what's expected (dirtest.out).

To fix this, sort both the expected and actual output.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/900
Approved-by: Jon Tourville <jon.tourville@canonical.com>
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 1f3a817c11)

c0815d0e dirtest.sh: don't rely on apparmor_parser -N's output sort order to be deterministic
2022-07-25 20:09:30 +00:00
John Johansen
704c82c574 Prepare for AppArmor 3.0.5 release
- update version file
  - bump library version

Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-07-25 00:22:07 -07:00
Christian Boltz
bcda237953 Merge [3.0] Support setuptools >= 61.2 in Python tests
Fix for #253, by mirroring the change from 1c23f5e1e4

This is the 3.0 version of https://gitlab.com/apparmor/apparmor/-/merge_requests/897, with the difference that the 3.0 branch already has `python3-setuptools` in `.gitlab-ci.yml` and therefore doesn't need the commit that updates `.gitlab-ci.yml`.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/899
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2022-07-20 16:52:24 +00:00
Ben Greiner
8485770cdf reviewed edits
(cherry picked from commit d442584a0a)
2022-07-19 22:33:52 +02:00
Ben Greiner
cc7f549665 use new build_platlib path with setuptools >= 61.2
(cherry picked from commit 47d68dac0f)
2022-07-19 22:32:32 +02:00
Guillem Jover
d6441c9da8 profiles: merge Update syslogd for inetutils-syslogd
The inetutils syslogd implementation integrates the kmsg support in the
main server, it has support for syslog.d configuration fragment files.
and it uses a slightly different pid filename.

Signed-off-by: Guillem Jover <guillem@hadrons.org>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/888
Approved-by: Steve Beattie <gitlab@nxnw.org>
Merged-by: Steve Beattie <gitlab@nxnw.org>
(cherry picked from commit 0859b42ba2)
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2022-07-07 22:29:57 -07:00
Christian Boltz
18813234b9 Merge [3.0] Fix inconsistent return length in _run_tests()
This is a manual backport of
728dbde5e4 / https://gitlab.com/apparmor/apparmor/-/merge_requests/890 by Mark Grassi

For the records: the inconsistent return length was introduced when
splitting run_tests() into two functions in
500cbf89a7

2.13 and older don't have the split run_tests() and therefore don't need this patch.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/891
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2022-06-29 13:27:10 +00:00
Christian Boltz
b9aaa632fb Fix inconsistent return length in _run_tests()
This is a manual backport of
728dbde5e4 by Mark Grassi

For the records: the inconsistent return length was introduced when
splitting run_tests() into two functions in
500cbf89a7
2022-06-28 21:06:12 +02:00
Christian Boltz
8cf3ec75fc Merge samba profiles: support paths used by Arch Linux
On Arch Linux `rpcd_classic`, `rpcd_epmapper`, `rpcd_fsrvp`, `rpcd_lsad`, `rpcd_mdssvc`, `rpcd_rpcecho`, `rpcd_spoolss`, `rpcd_winreg`, `samba-bgqd`, `samba-dcerpcd` and `smbspool_krb5_wrapper` are in `/usr/lib/samba/samba/`.

See https://archlinux.org/packages/extra/x86_64/samba/files/ and https://bugs.archlinux.org/task/74614.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/883
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 48fc233d05)

deadcc0d samba profiles: support paths used by Arch Linux
2022-06-06 10:54:08 +00:00
John Johansen
d4e465a0bb parser: fix min length calculation for inverse character sets
The inverse character set lists the characters it doesn't match. If
the inverse character set contains an oob then that is NOT considered
a match. So length should be one.

However because of oobs are handle not containing an oob doesn't mean
there is a match either. Currently the only way to match an oob is
via a positive express (no inverse matches are possible).

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/872
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-05-23 15:43:30 -07:00
John Johansen
8890dbcedc Merge Update for the mesa abstraction
I noticed that some apps return the following errors when launched:

```
  kernel: audit: type=1400 audit(1651244478.255:5501): apparmor="DENIED" operation="open" profile="some_app" name="/sys/devices/pci0000:00/0000:00:02.0/revision" pid=1877976 comm="some_app" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
  kernel: audit: type=1400 audit(1651244478.255:5502): apparmor="DENIED" operation="open" profile="some_app" name="/sys/devices/pci0000:00/0000:00:02.0/config" pid=1877976 comm="some_app" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
```

Blocking the files results in the following errors when the app is executed in a terminal:

```
  MESA: error: Failed to query drm device.
  libGL error: failed to create dri screen
  libGL error: failed to load driver: crocus
  MESA: error: Failed to query drm device.
  libGL error: failed to create dri screen
  libGL error: failed to load driver: crocus
```

Since they have something to do with MESA, I think the mesa abstraction should
be updated to fix the issue.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/879
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-05-23 15:36:49 -07:00
John Johansen
0e7d009164 Merge Add missing permissions for dovecot-{imap,lmtp,pop3}
References: https://bugzilla.opensuse.org/show_bug.cgi?id=1199535

I propose this patch for 3.0 and master. (2.13 and older have more different dovecot profiles which might make backporting a bit harder.)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/881
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-05-23 15:34:23 -07:00
John Johansen
215b5de131 Merge parser/capability.h: add missing <cstdint> include
Without the change apparmor build fails on this week's gcc-13 snapshot as:

    capability.h:66:6: error: variable or field '__debug_capabilities' declared void
       66 | void __debug_capabilities(uint64_t capset, const char *name);
          |      ^~~~~~~~~~~~~~~~~~~~
    capability.h:66:27: error: 'uint64_t' was not declared in this scope
       66 | void __debug_capabilities(uint64_t capset, const char *name);
          |                           ^~~~~~~~
    capability.h:23:1: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
       22 | #include <linux/capability.h>
      +++ |+#include <cstdint>
       23 |

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/882
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-05-23 15:30:04 -07:00
John Johansen
59c8d43cec parser: move ifdefs for capabilities to single common file
Unfortunately the parser was doing ifdef checks for capabilities
in two places. Move all the capability ifdefs into capability.h

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/768
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Georgia Garcia  <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-05-23 15:29:51 -07:00
Christian Boltz
ec19c34795 Merge profiles/apparmor.d: update samba-dceprpc & samba-rpcd-* profiles
aarch64 needs some additional rules on tumbleweed to handle for
example

apparmor="DENIED" operation="file_mmap" profile="samba-dcerpcd" name="/usr/lib64/samba/samba-dcerpcd" pid=897 comm="samba-dcerpcd" requested_mask="m" denied_mask="m" fsuid=0 ouid=0

The other new rpcd_* services exhibit similar errors

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1198309

Signed-off-by: Noel Power <noel.power@suse.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/880
Approved-by: Christian Boltz <apparmor@cboltz.de> for 3.0 and master
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit ab19f5599d)

6a621616 profiles/apparmor.d: update samba-dceprpc & samba-rpcd-* profiles
2022-05-11 19:44:56 +00:00
John Johansen
df1bbdbb20 Merge Allow reading all of /etc/php[578]/** in abstractions/php
... and with that, make a rule in the php-fpm profile (which missed
php8) superfluous.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/229
Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1186267#c11
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/876
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 3083ce7a39)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-04-19 11:44:16 -07:00
John Johansen
a5586f45fb Merge profiles: update snap_browsers permissions
The snap_browsers abstraction requires more permissions
due to updates on snaps.

Some of the permissions are not required in older versions of
Ubuntu that use 2.12 and 2.13, but are introduced for unification
and ease of maintenance purposes. These include:
```
    all dbus permissions,
    @{PROC}/sys/kernel/random/uuid r,
    owner @{PROC}/@{pid}/cgroup r,
    /var/lib/snapd/sequence/{chromium,firefox,opera}.json r,
```

I also propose a cherry-pick of this commit to 2.12, 2.13 and 3.0

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/877
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit bfa67b369d)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-04-19 11:37:36 -07:00
Christian Boltz
9099b7ed41 Merge profiles/apparmor.d: Add new profiles needed for samba-4.16
samba-4.16 has a completely new dcerpc subsystem, services that
used to be built into the smbd daemon itself (and deployed in forked
instances) are now hosted in standalone binaries. The following new
binaries now need new profiles

  rpcd_classic
  rpcd_epmapper
  rpcd_fsrvp
  rpcd_lsad
  rpcd_mdssvc
  rpcd_rpcecho
  rpcd_spoolss
  rpcd_winreg
  samba-dcerpcd

Additionally smbd & winbindd need new entries because the exec
samba-dcerpcd

Signed-off-by: Noel Power <noel.power@suse.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/871
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 3d27977b1c)

c785bcbe profiles/apparmor.d: Add new profiles needed for samba-4.16
2022-04-15 12:52:39 +00:00
John Johansen
6bb342380c Merge profiles/apparmor.d/abstraction: Squash noisey setsockopt calls.
systemd will attempt to force socket buffer size using setsockopt
and param SO_SNDBUFFORCE (which require net_admin cap) if it's previous
attempt to set size was clipped by kernel limit.

- Silence 'type=AVC msg=audit(1648725005.727:201): apparmor="DENIED" operation="capable" profile="smbd" pid=3054 comm="smbd" capability=12  capname="net_admin"'

type entries.

Signed-off-by: Noel Power <noel.power@suse.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/867
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 4537a5014b)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-04-12 11:14:43 -07:00
John Johansen
0e26be21df Merge sbin.rpc.statd: add hosts_access abstraction, /etc/nfs.conf{,.d/}
Observed these denials on an Ubuntu jammy system, when a user with an NFS homedir logs in:
```
Mar 29 06:57:14 darkstar kernel: [ 5988.206958] audit: type=1400 audit(1648551434.502:72): apparmor="DENIED" operation="open" profile="rpc.statd" name="/etc/nfs.conf" pid=3195 comm="rpc.statd" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Mar 29 06:57:14 darkstar kernel: [ 5988.207023] audit: type=1400 audit(1648551434.502:73): apparmor="DENIED" operation="open" profile="rpc.statd" name="/etc/nfs.conf.d/" pid=3195 comm="rpc.statd" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Mar 29 10:48:49 darkstar kernel: [19883.319957] audit: type=1400 audit(1648565329.710:74): apparmor="DENIED" operation="open" profile="rpc.statd" name="/etc/hosts.allow" pid=3196 comm="rpc.statd" requested_mask="r" denied_mask="r" fsuid=111 ouid=0
Mar 29 10:48:49 darkstar kernel: [19883.320016] audit: type=1400 audit(1648565329.710:75): apparmor="DENIED" operation="open" profile="rpc.statd" name="/etc/hosts.deny" pid=3196 comm="rpc.statd" requested_mask="r" denied_mask="r" fsuid=111 ouid=0
Mar 29 17:07:33 darkstar kernel: [  162.642366] audit: type=1400 audit(1648588053.026:72): apparmor="DENIED" operation="file_lock" profile="rpc.statd" name="/etc/nfs.conf" pid=1697 comm="rpc.statd" requested_mask="k" denied_mask="k" fsuid=0 ouid=0
```

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/866
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 103603277a)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-04-12 11:14:22 -07:00
Christian Boltz
36886b9c45 Merge dirtest.sh: error out on unexpected success
... if a test is expected to fail, but succeeds.

Also fix the copyright year - the test was created in 2022, not in 2013.

This fixes my comments on
bd78b6b292

The original MR !850 was merged into 3.0 and master, therefore I also propose this patch for 3.0 and master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/868
Approved-by: Jon Tourville <jon.tourville@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 52b6b97c98)

2036f6fa dirtest.sh: error out on unexpected success
2022-04-04 11:14:27 +00:00
Christian Boltz
b0af2c2217 Merge Allow dovecot to use all signals
similar to commit 2f9d172c64
we discovered that there was a service outage
when dovecot tried to send a usr1 signal

type=AVC msg=audit(1648024138.249:184964): apparmor="DENIED" operation="signal" profile="dovecot" pid=1690 comm="dovecot" requested_mask="send" denied_mask="send" signal=usr1 peer="dovecot-imap-login"

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/865
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 83685ba703)

f0919f83 Allow dovecot to use all signals
2022-03-25 20:53:05 +00:00
Christian Boltz
32c87d09c5 Merge abstractions/ssh_certs: extend pki/trust directories
- add pki/blacklist and pki/blocklist
- add /usr/share/pki/ in adddition to /etc/pki/

pki/blocklist was suggested by @darix, the other changes are things I noticed while adding it.

I propose this patch for 3.0 and master. (`abstractions/ssl_certs` on 2.x branches is quite different and needs a manual backport (or more cherry-picks) if you want to backport this MR.)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/864
Approved-by: Jon Tourville <jon.tourville@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit ff9e457189)

32cd90eb abstractions/ssh_certs: extend pki/trust directories
2022-03-23 20:35:39 +00:00
Georgia Garcia
dceba9763a add snap-browsers profile
Whenever the evince deb package tries to open a snap browser which was
selected as the default, we get the following denial:

audit[2110]: AVC apparmor="DENIED" operation="exec" profile="/usr/bin/evince" name="/usr/bin/snap" pid=2110 comm="env" requested_mask="x" denied_mask="x" fsuid=1000 ouid=0

As a short-term solution, we are adding a snap-browsers profile
which restricts what snaps opened by evince can do.
The long-term solution is currently not available, but could be
accomplished by using enhanced environment variable filtering/mediation
and delegation of open fds.

Bug: https://launchpad.net/bugs/1794064

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
(cherry picked from commit fb3283f37e)
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/863
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2022-03-17 09:43:01 -03:00
Christian Boltz
f1c6defb4a Merge profiles/apparmor.d: Fix read access denied on /proc/*/fd bsc#1196850
- Fix "type=AVC msg=audit(1646702374.347:182): apparmor="DENIED"
       operation="open" profile="samba-bgqd" name="/proc/1933/fd/"
       pid=1933 comm="samba-bgqd" requested_mask="r" denied_mask="r"
       fsuid=0 ouid=0"

entries appearing in SLE15-SP4

Signed-off-by: Noel Power <noel.power@suse.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/860
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit e2319167d0)

6b83ba91 profiles/apparmor.d: Fix read access denied on /proc/*/fd bsc#1196850
2022-03-14 12:16:38 +00:00
John Johansen
ecf8abab98 Merge smbd, samba-bgqd: allow reading openssl.cnf
References: https://bugzilla.opensuse.org/show_bug.cgi?id=1195463#c10

I propose this patch for 3.0 and master. (<= 2.13 don't have the samba-bgpd profile - if we want to backport to 2.x, we'll have to pick only the smbd part.)

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1195463#c10
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/862
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit c3f64513f2)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-03-13 08:07:20 -07:00
John Johansen
9b72afe9c3 Merge abstractions/nss-systemd: Allow access for systemd-machined names
See downstream bug at
https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1964325

Signed-off-by: Alex Murray <alex.murray@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/861
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 8f7768cd02)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-03-09 20:09:03 -08:00
John Johansen
c6324c2a3e Merge [2.x..3.0] aa-remove-unknown: abort on parser failure
If apparmor_parser -N (in profiles_names_list()) fails,
aa-remove-unknown possibly gets an incomplete list of profiles in
/etc/apparmor.d/ and therefore might remove more profiles than it
should.

Replace the profiles_names_list() call with a direct apparmor_parser
call, and abort aa-remove-unknown if it exits with $? != 0

Before:
```
aa-remove-unknown -n
AppArmor parser error for /etc/apparmor.d/broken in profile /etc/apparmor.d/broken at line 1: syntax error, unexpected TOK_ID, expecting TOK_OPEN
Would remove 'delete_me'
```

After:
```
./aa-remove-unknown -n
AppArmor parser error for /etc/apparmor.d in profile /etc/apparmor.d/zbroken at line 1: syntax error, unexpected TOK_ID, expecting TOK_OPEN
apparmor_parser exited with failure, aborting.
```

And of course, after fixing the broken profile:
```
./aa-remove-unknown -n
Would remove 'delete_me'
```

(cherry picked from commit 5053a01d84)

This backports the fix in `aa-remove-unknown` from !836, but doesn't backport the cleanup in `rc.apparmor.functions`.

I propose this patch for 3.0 and all 2.x branches.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/859
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
2022-03-10 00:54:57 +00:00
Christian Boltz
cecb8e2855 aa-remove-unknown: abort on parser failure
If apparmor_parser -N (in profiles_names_list()) fails,
aa-remove-unknown possibly gets an incomplete list of profiles in
/etc/apparmor.d/ and therefore might remove more profiles than it
should.

Replace the profiles_names_list() call with a direct apparmor_parser
call, and abort aa-remove-unknown if it exits with $? != 0

Before:
```
aa-remove-unknown -n
AppArmor parser error for /etc/apparmor.d/broken in profile /etc/apparmor.d/broken at line 1: syntax error, unexpected TOK_ID, expecting TOK_OPEN
Would remove 'delete_me'
```

After:
```
./aa-remove-unknown -n
AppArmor parser error for /etc/apparmor.d in profile /etc/apparmor.d/zbroken at line 1: syntax error, unexpected TOK_ID, expecting TOK_OPEN
apparmor_parser exited with failure, aborting.
```

And of course, after fixing the broken profile:
```
./aa-remove-unknown -n
Would remove 'delete_me'
```

(cherry picked from commit 5053a01d84)
2022-03-05 22:48:34 +01:00
John Johansen
4f2f7c60a6 parser: dirtest that was supposed to be part of the previous commit
libapparmor: fix handling of failed symlink traversal, fixed a couple
of directory walk issues that could cause failures. The test included
in this commit was supposed to be included in the previous commit,
but was accidentally dropped. Even worse the make file changes did
make it causing the previous commit to break the CI.

Fixes: MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/85
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit bd78b6b292)
2022-02-27 01:32:50 -08:00
John Johansen
da879c0704 libapparmor: fix handling of failed symlink traversal
Ideally we would have a flag or something so the caller could choose
to handle symlinks, or traverse them. But since all callers currently
don't handle symlinks just handle them in the iterator.

Beyond fixing the early termination due to a failed symlink this also
fixes another case of failure in one job cause dir based loads to
terminate early. Which can result in partial loads.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/215
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/850
Signed-off-by: John Johansen <john.johansen@canonical.com>
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
(cherry picked from commit acc6ba1cb7)
2022-02-27 01:32:38 -08:00
John Johansen
9799fbde99 Merge GTK abstraction: add support for gtk4.
The recently added gtk abstraction (!825) lack the support for the new gtk4.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/857
Approved-by: Jon Tourville <jon.tourville@canonical.com>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit 6f18326232)

8074ff4f GTK abstraction: add support for gtk4.
2022-02-22 22:02:20 +00:00
John Johansen
2b6eada019 Merge smbd: allow reading under /usr/share/samba
Today, a normal user connected and did something (dunno what) that caused smbd to try to `/usr/share/samba/mdssvc/elasticsearch_mappings.json`:

Samba logs:

```
root@smb:~# journalctl -b0 -u smbd
-- Logs begin at Fri 2022-01-21 14:17:01 UTC, end at Thu 2022-02-17 23:56:02 UTC. --
Feb 17 14:01:20 smb systemd[1]: Starting Samba SMB Daemon...
Feb 17 14:01:26 smb smbd[113]: [2022/02/17 14:01:26.904865,  0] ../../lib/util/become_daemon.c:135(daemon_ready)
Feb 17 14:01:26 smb systemd[1]: Started Samba SMB Daemon.
Feb 17 14:01:26 smb smbd[113]:   daemon_ready: daemon 'smbd' finished starting up and ready to serve connections
Feb 17 21:05:35 smb smbd[3084]: pam_unix(samba:session): session opened for user jdoe by (uid=0)
Feb 17 21:05:37 smb smbd[3084]: [2022/02/17 21:05:37.735182,  0] ../../source3/rpc_server/mdssvc/mdssvc_es.c:92(mdssvc_es_init)
Feb 17 21:05:37 smb smbd[3084]:   mdssvc_es_init: Opening mapping file [/usr/share/samba/mdssvc/elasticsearch_mappings.json] failed: unable to open /usr/share/samba/mdssvc/elasticsearch_mappings.json: Permission denied
Feb 17 21:05:37 smb smbd[3084]: [2022/02/17 21:05:37.735436,  0] ../../source3/rpc_server/mdssvc/mdssvc.c:1490(mdssvc_init)
Feb 17 21:05:37 smb smbd[3084]:   mdssvc_init: backend init failed
Feb 17 21:05:37 smb smbd[3084]: [2022/02/17 21:05:37.735562,  0] ../../source3/rpc_server/mdssvc/srv_mdssvc_nt.c:152(_mdssvc_open)
Feb 17 21:05:37 smb smbd[3084]:   _mdssvc_open: Couldn't create policy handle for partage
Feb 17 23:56:02 smb smbd[3084]: pam_unix(samba:session): session closed for user jdoe
```

Since the 'smb' machine is a container, the Apparmor denial ended up in the host's log:

```
$ journalctl -o cat --grep samba -k --since today | cat
audit: type=1400 audit(1645131937.730:98): apparmor="DENIED" operation="open" namespace="root//lxd-smb_<var-snap-lxd-common-lxd>" profile="smbd" name="/usr/share/samba/mdssvc/elasticsearch_mappings.json" pid=35359 comm="smbd" requested_mask="r" denied_mask="r" fsuid=166549 ouid=165536

```

It is the first time it occurs in years of use but it seems legitimate as:

1) this file is installed by the package
2) `git grep -F elasticsearch_mappings` in Debian samba's source shows many hits:
```
$ git grep -F elasticsearch_mappings
debian/samba.install:usr/share/samba/mdssvc/elasticsearch_mappings.json
docs-xml/manpages/mdsearch.1.xml:         <filename>/usr/share/samba/mdssvc/elasticsearch_mappings.json</filename>
docs-xml/smbdotconf/misc/elasticsearchmappings.xml:  <value type="default">&pathconfig.SAMBA_DATADIR;/elasticsearch_mappings.json</value>
docs/manpages/mdfind.1:/usr/share/samba/mdssvc/elasticsearch_mappings\&.json
docs/manpages/smb.conf.5:\fI\fIelasticsearch:mappings\fR\fR\fI = \fR\fI${prefix}/var/samba/elasticsearch_mappings\&.json\fR\fI \fR
selftest/selftest.pl:   elasticsearch:mappings = $srcdir_abs/source3/rpc_server/mdssvc/elasticsearch_mappings.json
selftest/target/Samba3.pm:      elasticsearch:mappings = $srcdir_abs/source3/rpc_server/mdssvc/elasticsearch_mappings.json
source3/rpc_server/mdssvc/es_parser_test.c:             "%s/mdssvc/elasticsearch_mappings.json",
source3/rpc_server/mdssvc/mdssvc_es.c:          "%s/mdssvc/elasticsearch_mappings.json",
source3/rpc_server/wscript_build:                          'mdssvc/elasticsearch_mappings.json')
```

While only the `mdssvc` sub-dir could be authorized, the whole dir content seemed OK for read access anyway:

```
root@smb:~# ll /usr/share/samba/
total 53
drwxr-xr-x  5 root root   10 Feb  1 14:08 ./
drwxr-xr-x 67 root root   67 Jun 22  2021 ../
-rwxr-xr-x  1 root root 1163 Jan 31 13:11 addshare.py*
drwxr-xr-x  3 root root    4 Feb  1 14:08 admx/
drwxr-xr-x  2 root root    3 Feb  1 14:08 mdssvc/
-rwxr-xr-x  1 root root 2059 Jan 31 13:11 panic-action*
-rwxr-xr-x  1 root root 1333 Jan 31 13:11 setoption.py*
drwxr-xr-x  5 root root   57 Feb  1 14:08 setup/
-rw-r--r--  1 root root 8942 Jan 31 13:11 smb.conf
-rwxr-xr-x  1 root root 2682 Jan 31 13:11 update-apparmor-samba-profile*
```

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/853
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 6e5fdb5c05)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-02-21 12:05:54 -08:00
Georgia Garcia
bc952a5c85 Merge parser: fix building with link time optimization (lto)
Libapparmor was fixed for lto builds on commit 7cde91f5 but
the parser was also failing due to the same reasons when lto
was enabled.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/214
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>

Closes #214
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/851
Acked-by: Approved-by: John Johansen <john@jjmx.net>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>

(cherry picked from commit 5001431cdf)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-02-17 15:33:13 -08:00
John Johansen
b27a5b0cab Merge Update apache2-common so that other processes can trace the hats that include...
Update apache2-common so that other processes can trace the hats that include this file. The main `usr.sbin.apache2` profile includes `abstractions/base` which has these lines in it, which is why `ss -tnlp` sometimes fails and sometimes works.

See also: [Debian Bug #1003153](https://bugs.debian.org/1003153) for more details about how this occurs.

Fixes: https://bugs.debian.org/1003153
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/852
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit 6fa2d528e9)

071935b9 Update apache2-common so that other processes can trace the hats that include...
2022-02-17 12:44:38 +00:00
John Johansen
74e074a213 Merge smbd: include snippet generated at runtime on Debian and openSUSE
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/838
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit e71e27c574)

9af832f4 smbd: include snippet generated at runtime on Debian
19abc664 smbd: include snippet generated at runtime on openSUSE
2022-02-16 12:40:52 +00:00
John Johansen
8a21472175 Merge make test-aa-notify test_help_contents () less strict
Python 3.10 generates a slightly different --help output.

Fixes https://gitlab.com/apparmor/apparmor/-/issues/220

Closes #220
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/848
Acked-by: Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>

(cherry picked from commit ba14227bb5)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-02-15 11:19:29 -08:00
John Johansen
1d3193b55c Merge Make the systemd unit a no-op in containers with no internal policy
In 73e124d4fb I've upstreamed the `is_container_with_internal_policy()` function, but so far it was not used anywhere upstream. This is the missing bit.

I could trace the history of that patch back to 2012 (2.7.102-0ubuntu3):

    * debian/apparmor.init: do nothing in a container.  This can be
      removed once stacked profiles are supported and used by lxc.
      (LP: #978297)

Context: I lack both knowledge and motivation to keep maintaining this as part of the Debian delta. I'd rather see upstream, and in particular folks more knowledgeable than me about LXC/LXD, or with external motivation factors to work on this part of the stack, take care of it.

Note: Debian has similar code in its [sysvinit script](https://salsa.debian.org/apparmor-team/apparmor/-/blob/debian/master/debian/apparmor.init). I'm not touching that one.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/840
Acked-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 5a41024bbe)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-02-14 23:30:50 -08:00
John Johansen
d0a131b70e Merge Allow access to socket directory used by recent ibus-daemon
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/837
Acked-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 26b7ddee36)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-02-14 14:08:39 -08:00
John Johansen
78baf655b2 Merge Import profile-load script from Debian
This script is used at least by LXC upstream and MySQL in Debian:
https://codesearch.debian.net/search?q=%2Flib%2Fapparmor%2Fprofile-load

Presumably it could be useful elsewhere if it was more readily available.

Similarly to !840, this is another user of the `is_container_with_internal_policy()` function. I'd like all the callers of this function to live in harmony under the same roof, upstream.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/841
Acked-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 6a54d59172)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-02-14 00:33:01 -08:00
John Johansen
5141132c48 Merge Add .desktop file for aa-notify
This allows distributions to start aa-notify automatically, should they wish so, by installing that file in a suitable location, such as `/etc/xdg/autostart`.

This file was introduced in Ubuntu 2.8.95~2430-0ubuntu3 package in 2014, replacing the `/etc/X11/Xsession.d` snippet that Ubuntu had added in 2010.

I'd like to stop having to care about this file as part of the Debian delta and to enable greater collaboration.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/839
Acked-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 046442741f)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-02-14 00:31:53 -08:00
Christian Boltz
de9d56c29e Merge Drop superfluous shebang from python module
Found by rpmlint.

I propose this fix for 3.0 and master to keep the file in sync.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/846
Acked-by: Approved-by: intrigeri <intrigeri@boum.org> for 3.0 and master
Merged-by: Christian Boltz <gitlab2@cboltz.de>

(cherry picked from commit a744564fa4)

749234f5 Drop superfluous shebang from python module
2022-02-13 18:35:09 +00:00
John Johansen
939530b2b8 Prepare for AppArmor 3.0.4 release
- update version file
- bump library version

Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-02-09 16:45:25 -08:00
John Johansen
b4fc4c3c14 Merge Add 'mctp' network domain keyword
Reported as comment on https://build.opensuse.org/request/show/951354
(update to glibc 2.35)

I propose this patch for at least 3.0 and master. Backporting it to older releases can't hurt, even if seeing a new-enough glibc or kernel with them is less likely.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/832
Acked-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 5041a6235a)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-02-08 10:51:01 -08:00
John Johansen
59a22c5786 libapparmor: fix building with link time optimization (lto)
Currently libapparmor fails to build when lto is used because it uses
the asm directive to provide different version of some symbols.
Unfortunately gcc does not recognize this and the symbols defined by
asm are lost and optimized out by lto and then the link fails.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/214
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/831
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 7cde91f57f)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-02-04 15:50:06 -08:00
John Johansen
f3ee5a1849 Merge Fix: Opening links with Chrome
Permission denied when Evince tries to use Chrome to open link.

In config is missing the bin: `/opt/google/chrome/crashpad_handler`.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/830
Acked-by: John Johansen <john@jjmx.net>
(cherry picked from commit 08f32ac703)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-02-04 02:17:38 -08:00
John Johansen
2c25ed160e Merge Add the GTK abstraction
GTK/QT apps need to read some config files in order to properly render their windows in a graphical session. There are some `qt5` abstractions already, but it looks like the `gtk` abstraction is missing.

The `*gtk*` rules are basically the location of the GTK config files I found on the internet when I was trying to compose this abstraction. Some of the paths are missing in Debian, but different distros can use (or were using) them. Since GTK apps use themes, the abstraction also include the whole `/usr/share/themes/` , `@{HOME}/.themes/` and `@{HOME}/.local/share/themes/` dirs. I'm not sure whether this should be tightened. The `.Xauthority` file is generally needed when you deal with GUI apps under Xserver. Also since all GUI apps redirect output/error to the `~/.xsession-errors` file, this file also was included here.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/65
Fixes: https://gitlab.com/apparmor/apparmor/-/issues/168
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/825
Acked-by: John Johansen <john.johansen@canonical.com>


(cherry picked from commit c67681a5a9)

93d49a39 add the GTK abstraction
2022-01-28 19:45:30 +00:00
John Johansen
edf59286e5 libapparmor: Fix ruby 3.1 build for libapparmor
The Hack used to build the libapparmor swig interface for ruby fails
with ruby 3.1.  Instead of trying to do black magic in ruby to rename
the generated Makefile to Makefile.new, just save off the Makefile
and restore after ruby's setup has been called.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/206
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 1ca30e35b0)
2022-01-27 12:25:29 +00:00
John Johansen
1e9e0e40a9 Merge init: make xargs invocation busybox-compatible
busybox xargs does not have -d nor long --max-procs options, instead use -0 (and separate arguments with printf "%s\\0") and -P which are more portable. While we are here, also add -r (--no-run-if-empty, which also has no long equivalent for busybox) as we likely don't want to run anything if no profile were found

This is useful for alpine systems where findutils is not installed by default, but busybox xargs is available.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/828
Acked-by: John Johansen <john.johansen@canoical.com>
(cherry picked from commit 0e52b555ae)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-01-26 19:25:13 -08:00
John Johansen
5049cdb45f aa-status: fix crash due to \n in profile name
This fixes a crash when a profile name contains a \n character which
breaks profile name parsing. The fix is minimal in that it ignores
the bad profile name and continues processing.

Ideally this name would not exist and is indicative of a bug in the kernel.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/211
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/824
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
(cherry picked from commit 457ab38b93)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-01-20 13:41:54 -08:00
Christian Boltz
aa82f874e2 Merge branch 'cboltz-samba-lmb2' into 'master'
abstractions/samba: allow ldb2 paths

See merge request apparmor/apparmor!821

Note: https://bugzilla.opensuse.org/show_bug.cgi?id=1192684 was made public in the meantime.

Acked-by: Jon Tourville <jon.tourville@canonical.com>

(cherry picked from commit 90b312c55a)

901f2ea9 abstractions/samba: allow ldb2 paths
2022-01-18 12:54:07 +00:00
John Johansen
fa98c9aafa Merge abstractions/openssl: allow /etc/ssl/{engdef,engines}.d/
These directories were introduced in openssl in https://patchwork.ozlabs.org/project/openwrt/patch/20210429153530.10020-2-cotequeiroz@gmail.com/

I propose this patch for 3.0 and master. Optionally also for older branches, even if it's unlikely that systems using 2.13.x or older get a new-enough openssl to need this ;-)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/818
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 2b270216aa)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-01-17 12:09:39 -08:00
Christian Boltz
033ed7837c Merge branch 'bsc1192336' into 'master'
profiles/apparmor.d: Fix file_mmap violation for bsc#1192336.

See merge request apparmor/apparmor!819

Acked-by: Christian Boltz <apparmor@cboltz.de> for 3.0 and master

(cherry picked from commit fc4d1f76fa)

e19abd3b profiles/apparmor.d: Fix file_mmap violation for bsc#1192336.
2021-12-20 18:07:00 +00:00
Christian Boltz
5ca5b3879f Merge branch 'cboltz-abstractions-python' into 'master'
abstractions/python: merge /usr/ and /usr/local/ rules, and add some new rules

See merge request apparmor/apparmor!814

Acked-by: Georgia Garcia <georgia.garcia@canonical.com>

(cherry picked from commit 529c408d9e)

5491b758 abstractions/python: merge /usr/ and /usr/local/ rules
cac848e2 abstractions/python: add several permissions
2021-12-13 17:03:05 +00:00
Georgia Garcia
ab4cfb5e84 replace deprecated distutils with setuptools
Adds python3 setuptools as a build dependency for libapparmor

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/202
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/813
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
(cherry picked from commit 21e5a721ab)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-11-11 21:30:41 -08:00
John Johansen
d1e2ab6a77 Merge Add support for reading s390x and aarch64 wtmp file
Both aarch64 and s390x have a bigger wtmp record size (16 bytes more
than x86_64, 400 bytes total).

The byte position of the timestamp is also different on each
architecture. To make things even more interesting, s390x is big
endian.

Note that this MR includes more things, like
  * moving `get_last_login_timestamp()` to the new `apparmor/notify.py` file
  * add unit tests for it
  * add wtmp example files from various architectures, including a
    hand-edited one claiming to be from 1999
  * fixing a bug in `get_last_login_timestamp()` that unpacked `type` from
    too many bytes - which accidently worked on x86_64
  * detecting from which architecture the wtmp file comes (luckily the
    timestamps are located at different locations)

    See the individual commits for details.

 Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1181155
 MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/809
(cherry picked from commit ca276d2bfd)
Acked-by: John Johansen <john.johansen@canonical.com>
2021-11-08 12:56:09 -08:00
Christian Boltz
b4cc405b80 Add tests for sane_timestamp
Ensure that pre-2000 and post-2050 dates get rejected, and something in
between gets accepted.

This also extends coverage to 100% - before, the post-2050 branch was
not covered.
2021-11-08 12:54:19 -08:00
Christian Boltz
c2c2cf005c Add truncated and ancient wtmp example to tests
A too-small file can't contain something useful.

Also, a wtmp file with a timestamp from pre-2000 is beyond what you'd
expect on a 2021 system.
2021-11-08 12:54:19 -08:00
Christian Boltz
0e4d3e6b30 Add support for reading s390x and aarch64 wtmp file
Both aarch64 and s390x have a bigger wtmp record size (16 bytes more
than x86_64, 400 bytes total).

The byte position of the timestamp is also different on each
architecture. To make things even more interesting, s390x is big endian.

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1181155
2021-11-08 12:54:19 -08:00
Christian Boltz
af8d5021a5 fix reading 'type' from wtmp
'type' is a short (see "ut_type" in wtmp(5)), therefore only read two
bytes and unpack them as short. Afterwards read two padding bytes to
/dev/null.

This accidently worked on x86_64 because it's little endian, but will
fail on big endian architectures.
2021-11-08 12:54:19 -08:00
Christian Boltz
8c63d75a20 Add unittest for get_last_login_timestamp
... starting with a x86_64 wtmp example file
2021-11-08 12:54:19 -08:00
Christian Boltz
7371119f28 Move get_last_login_timestamp() into apparmor.notify
This is a preparation to make adding tests easier.
2021-11-08 12:54:19 -08:00
John Johansen
e8041a7f48 Merge Add missing /proc permissions to avahi-daemon profile
Fixes: https://gitlab.com/apparmor/apparmor/-/issues/203

MR:https://gitlab.com/apparmor/apparmor/-/merge_requests/811
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit ee9e61aad2)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-10-30 02:17:58 -07:00
Jon Tourville
b23de50180 Merge Generate af_names.h similar to cap_names.h
This adds a base_af_names.h file similar to base_cap_names.h to support newer address families in policy when built against older headers.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/195
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/808
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit b6551618d8)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-10-22 13:33:46 -07:00
John Johansen
9aac5e09d7 Merge abstractions/samba: allow use of /run/lock/samba
Some distros use /run/lock/samba as the Samba lock directory, so allow
that in the samba abstraction in addition to /run/samba.

MR: https://gitlab.com/apparmor/apparmor!805
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 9d14d6ebfb)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-10-16 00:11:12 -07:00
John Johansen
cb285b0cdd Merge Add profile for samba-bgqd
... and some rules in the smbd profile to execute it and send it a term
signal.

samba-bgqd is (quoting its manpage) "an internal helper program
performing asynchronous printing-related jobs."

samba-bgqd was added in Samba 4.15.

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1191532
MR: https://gitlab.com/apparmor!807
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 8db7e70395)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-10-16 00:07:38 -07:00
Steve Beattie
609a262447 binutils/aa-features-abi: fix a couple of minor issues
A small patch set to fix two issues with binutils/aa-features-abi:

1. The `aa-features-abi -f` short argument was not added to the
   `getopt_long()` set of short arguments, resulting in the command
   incorrectly failing when passed -f

2. Due to variable shadowing the file descriptor for the `--file`
   argument was not being autoclosed.

- binutils/aa-features-abi: make -f short arg actually be accepted
- binutils/aa-features-abi: fix failure to close fd due to shadowed
  var decl

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/804


(cherry picked from commit a24cda5ae1)

8137beb2 binutils/aa-features-abi: make -f short arg actually be accepted
ffc6529b binutils/aa-features-abi: fix failure to close fd due to shadowed var decl
2021-09-27 21:38:08 +00:00
Christian Boltz
e186512671 Merge branch 'fix-lexer' into 'master'
parser: Fix unknown state condition RLIMIT_MODEINCLDE

See merge request apparmor/apparmor!803

Acked-by: Christian Boltz for all branches

(cherry picked from commit b0bc0d5323)

dc7755e5 parser: Fix unknown state condition RLIMIT_MODEINCLDE
2021-09-24 11:26:41 +00:00
John Johansen
ca6f239790 Merge aa-unconfined: Improve fallback handling to attr/current
If /proc/*/attr/apparmor/current exists, only read that - instead of
falling back to /proc/*/attr/current if a process is for example
unconfined so that read_proc_current returns None.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/199
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/801
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 0700b47df8)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-09-18 13:49:26 -07:00
John Johansen
c903b36d05 Merge dnsmasq: allow paths for podman dnsname plugin
The dnsname plugin in podman needs access to some files in
/run/containers/cni/dnsname/*/

This is also documented upstream:
https://github.com/containers/dnsname/blob/main/README_PODMAN.md
but nobody thought about telling us to just update the profile :-/

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1190271
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/800
Acked-by: John Johansen <john.johansen@canonical.com>


(cherry picked from commit 3b6257edea)

254ebacb dnsmasq: allow paths for podman dnsname plugin
2021-09-17 12:21:11 +00:00
John Johansen
66ede4ae7a libapparmor: fix log parsing for socklogd
The default log format for void linux is not handled by current log
parsing. The following example message results in an invalid record
error.

2021-09-11T20:57:41.91645 kern.notice: [  469.180605] audit: type=1400 audit(1631392703.952:3): apparmor="ALLOWED" operation="mkdir" profile="/usr/bin/kak" name="/run/user/1000/kakoune/" pid=2545 comm="kak" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000

This log message fails on parsing

  kern.notice:

which differs from the expect syslog format of
  host_name kernel:

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/196
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/799
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit b32b898a9a)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-09-13 16:12:01 -07:00
John Johansen
663b9636ed libapparmor: fix memory leaks in logparsing
bison reports the follow warnings on the parser

/home/jj/apparmor/apparmor-jjohansen.git/libraries/libapparmor/src/grammar.y:245.48-62: warning: unused value: $4 [-Wother]
 	| syslog_date TOK_ID TOK_SYSLOG_KERNEL TOK_DMESG_STAMP TOK_AUDIT TOK_COLON key_type audit_id audit_user_msg_partial_tail
                                                ^^^^^^^^^^^^^^^
/home/jj/apparmor/apparmor-jjohansen.git/libraries/libapparmor/src/grammar.y:247.48-62: warning: unused value: $4 [-Wother]
 	| syslog_date TOK_ID TOK_SYSLOG_KERNEL TOK_DMESG_STAMP TOK_AUDIT TOK_COLON key_type audit_id audit_user_msg_tail
                                                ^^^^^^^^^^^^^^^
which it turns out are memory leaks.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/799
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 1192dae561)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-09-13 16:11:39 -07:00
John Johansen
73e2f0cd8c libapparmor: fix debug build of log parsing
When building with YYDEBUG=1 the following failure occurs

grammar.y:49:46: error: unknown type name ‘no_debug_unused_’; did you mean ‘debug_unused_’?
 void aalogparse_error(unused_ void *scanner, no_debug_unused_ char const *s)
                                              ^~~~~~~~~~~~~~~~
                                              debug_unused_
g

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/799
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 4fe5387b69)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-09-13 16:11:26 -07:00
John Johansen
37f5326d0e Merge Avoid aa-notify crash on log events without operation=
Some STATUS log events trigger a crash in aa-notify because the log
line doesn't have operation=. Examples are:

    type=AVC msg=audit(1630913351.586:4): apparmor="STATUS" info="AppArmor Filesystem Enabled" pid=1 comm="swapper/0"

    type=AVC msg=audit(1630913352.610:6): apparmor="STATUS" info="AppArmor sha1 policy hashing enabled" pid=1 comm="swapper/0"

Fix this by not looking at log events without operation=

Also add one of the example events as libapparmor testcase.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/194
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/797
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit c37586cd11)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-09-13 16:09:00 -07:00
Steve Beattie
06dc32a9f3 utils: Add new python versions to logprof.conf
Adding everything up to 3.19 should make the file future-proof for a
while ;-)

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/193
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/795
Acked-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 4559a2997c)
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2021-08-26 10:53:09 -07:00
Christian Boltz
b1a6f9c86e Merge branch 'fix-video-abstraction' into 'master'
add a missing slash at the end of the sys rule

See merge request apparmor/apparmor!791

Acked-by: Christian Boltz <apparmor@cboltz.de> for 2.12..master

(cherry picked from commit 4fd7bcc289)

b3dcd02d add a missing slash at the end of the sys rule
2021-08-20 18:16:20 +00:00
Christian Boltz
dc00e28558 Merge branch 'cboltz-typo' into 'master'
Fix typo in manpage

Closes #192

See merge request apparmor/apparmor!789

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

(cherry picked from commit 131ae8425b)

1459f49b Fix typo in manpage
2021-08-17 18:26:12 +00:00
John Johansen
6cfc6eeec2 Merge Update abstractions/python and profiles for python 3.10
Add support for python 3.10 in abstractions and profiles.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/187
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/783
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 31fda3eee7)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-08-13 13:15:12 -07:00
Steve Beattie
4fbd6468ac Revert "regression tests: fix aa_policy_cache when using system parser"
This reverts commit e9e9340eff.

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2021-08-12 00:03:06 -07:00
Steve Beattie
e9e9340eff regression tests: fix aa_policy_cache when using system parser
Merge branch 'fix-policy-cache-regression-tests' into 'master'

When using the system parser ${parser_config} will be empty and so if this
is unconditionally passed as an argument to the parser then this gets in
interpreted as the name of a file to be compiled and hence the parser just
prints:

File  not found, skipping...
File  not found, skipping...
File  not found, skipping...
...

for all the aa_policy_cache tests - instead fix this to pass a single args
argument to the parser which will only include parser_config if it is not
empty.

This fixes the regression tests to run to completion without error when
USE_SYSTEM=1 is set.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/782
Signed-off-by: Alex Murray <alex.murray@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
(cherry picked from commit 8d0b48df12)
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2021-08-11 22:33:55 -07:00
John Johansen
1a6c042ac6 Prepare for AppArmor 3.0.3 release
- update version file

Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-08-07 01:40:00 -07:00
Jon Tourville
5a5f969a5e parser: sort feature directory entries in to match libapparmor's directory traversal
(cherry picked from commit e82a23dfe4)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-08-07 00:22:46 -07:00
John Johansen
59ec31bcb3 Prepare for AppArmor 3.0.2 release
- update version file
  - bump library version

Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-08-05 22:24:22 -07:00
John Johansen
b1b046f4b6 libapparmor: fix comments about kernel exporte interfaces
Some basic fixes to comments, that were found after !713 was merged.

Fixes: https://gitlab.com/apparmor/apparmor/-/merge_requests/713
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/777
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit 3f46d96aca)
2021-07-22 22:11:23 +00:00
John Johansen
53e34f9d53 Merge libapparmor: Adjust stacking interface check
libapparmor performs a test for the new stacking interface, however
how it does this test is problematic as it requires all confined
tasks to be given read access to the task introspection interface.
This results in tasks needing to be given read access to the interface
even if they don't need it. Making it possible for tasks to discover
their confinement even if they are not supposed to be able to.
Instead change the check to using state on the parent directory.
This will generate a getattr request instead of read and make it
on the directory instead of on any interface file that could be
used to obtain information.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/713
Signed-off-by: John Johansen john.johansen@canonical.com
Acked-by: Timeout
(cherry-picked from commit  29215b4784)
Signed-off-by: John Johansen john.johansen@canonical.com
2021-07-21 15:51:54 -07:00
John Johansen
93f080fe8e [7/7] abstractions: Make "available" readable as part of the enabled api
Understacking AppArmor if it is not the major LSM may set the enabled
field to false, to keep userspace from hitting the old shared proc
interfaces. The parameter "available" is added to indicate apparmor
is available but not present on the older interfaces.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/150
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/713
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit a98469eb09)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-07-21 15:50:55 -07:00
John Johansen
79d03f4279 [6/7] parser: update the parser to add interface rules for change_X
For change_hat and change_profile instead of a single interface
rule we need to add some readonly interfaces for discovery and
the new and old proc interface for writing.

Consolidate into a single shared routine.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/150
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/713
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit c60fc809a9)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-07-21 15:50:45 -07:00
John Johansen
d01bfaefc7 [5/7] libapparmor: rework trying original interface if new interface fails
Adjust the interface check and fallback. Unfortunately there is no
solution that will fix all failure cases. Instead try to minimize
the failure cases and bias towards failures that don't cause a
regression under an old parser/policy.

Note: In cases where we absolutely know the interface should not
      be accessed fail those accesses imediately instead of relying
      on what ever LSM active to handle it.

While we are at it document the interfaces and failure cases.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/150
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/713
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 35e58273e6)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-07-21 15:50:36 -07:00
John Johansen
4d8bbf97fc [4/7] libapparmor: fix available and enabled checks
Make it easier to separate errors from an actual answer, and ensure
we do a fallback check if there was an error.

Also fix the error code returned from aa_is_enabled() which got
broken by the addition of the private_enabled() check.

Finally make sure the private enabled error code is documented.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/150
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/713
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit d0c4fc7d68)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-07-21 15:50:25 -07:00
John Johansen
5d030f7765 [3/7] libapparmor: Fix AppArmor private interface availability check
The parameter that is landing upstream in "available" not
"private_enabled".

Also set the correct variable, as previously we were not.

Note: that skipping checking available for the private apparmor
proc interfaces is okay, as the dedicated apparmor interfaces will
fail correctly if available is False.

This just gives a clear way for userspace to query this info without
having to resort to error codes that access to the private interfaces
would return.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/150
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/713
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 3fb4c4b876)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-07-21 15:50:14 -07:00
John Johansen
bcef865116 [2/7] libapparmor: Adjust stacking interface check
libapparmor performs a test for the new stacking interface, however
how it does this test is problematic as it requires all confined
tasks to be given read access to the task introspection interface.

This results in tasks needing to be given read access to the interface
even if they don't need it. Making it possible for tasks to discover
their confinement even if they are not supposed to be able to.

Instead change the check to using stat on the parent directory.
This will generate a getattr request instead of read and make it
on the directory instead of on any interface file that could be
used to obtain information.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/150
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/713
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 6c4ed2af8d)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-07-21 15:49:57 -07:00
John Johansen
b86bb506ef [1/7] libapparmor: fix check for asprintf failure in proc init fn()
The fn() handling proc base address init is not checking for asprintf
failure. Fix it.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/150
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/713
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 0be67ec840)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-07-21 15:49:44 -07:00
John Johansen
64fbb1e25b Merge allow Prometheus metrics end-point in dovecot/stats
Patch by Michael Ströder <michael@stroeder.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/776
Acked-by: John Johansen <john@jjmx.net>
(cherry picked from commit d8ec3dafb7)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-07-21 12:29:47 -07:00
John Johansen
2cedb8794c Merge Allow reading /etc/login.defs.d/ in abstraction/authentication
This directory can include login.defs config sniplets in openSUSE
Tumbleweed.

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

See also
https://en.opensuse.org/openSUSE:Packaging_UsrEtc#pam.2Fpam-config

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/774
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 710bf66e51)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-07-16 15:09:44 -07:00
John Johansen
37e691bd8a parser: fix cache time stamp check to include dir time stamps
Currently for directory includes the directory timestamp is ignored.
This is wrong as operations like removing a file from the dir won't
be considered in the timestamp check.

Fix this by updating the timestamp check to include the included
directories timestamp.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/760
Signed-off-by: John Johansen <john@jjmx.net>
Acked-by: Georgia Garcia  <georgia.garcia@canonical.com>
(cherry picked from commit 3d1232e640)
2021-07-13 18:11:17 -07:00
John Johansen
5af298855f Merge Add crypto abstraction to 3.0 Branch
... and include it in abstractions/base.

This is a backport of
https://gitlab.com/apparmor/apparmor/-/merge_requests/772 which only
adds the crypto abstraction, but doesn't clean up the rules moved from
other abstractions into crypto.

Details:
* @{etc_ro}/gcrypt/random.conf r, (new rule) is possibly needed for all
  programs that use libgcrypt.
* @{PROC}/sys/crypto/* r, (from base)
* crypto-policies (from ssl_certs)
* @{PROC}/sys/crypto/fips_enabled (from openssl)

MR 722 contains individual commits with more details.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/773
Acked-by: John Johansen <john.johansen@canonical.com>
2021-07-13 22:27:14 +00:00
Christian Boltz
071eb797ef Add crypto abstraction to 3.0 Branch
... and include it in abstractions/base.

This is a backport of
https://gitlab.com/apparmor/apparmor/-/merge_requests/772 which only
adds the crypto abstraction, but doesn't clean up the rules moved from
other abstractions into crypto.

Details:
* @{etc_ro}/gcrypt/random.conf r, (new rule) is possibly needed for all
  programs that use libgcrypt.
* @{PROC}/sys/crypto/* r, (from base)
* crypto-policies (from ssl_certs)
* @{PROC}/sys/crypto/fips_enabled (from openssl)

MR 722 contains individual commits with more details.
2021-07-13 23:42:35 +02:00
Christian Boltz
c7d426255b Merge branch 'cboltz-crypto-policies' into 'master'
abstractions/ssl_certs: allow reading crypto policies

See merge request apparmor/apparmor!720

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

(cherry picked from commit 93bd9a1d5b)

13a82216 abstractions/ssl_certs: allow reading crypto policies
2021-06-29 12:42:08 +00:00
Georgia Garcia
0729b13293 tests: fix i18n.sh regression test on arm64
The following errors are happening on the regression tests
of i18n.sh on arm64 hirsute/impish:

Error: open failed. Test 'i18n (194) OPEN (octal) "/tmp/sdtest.3654-6536-J2ZwFM/file__post" RW' was expected to 'pass'. Reason for failure 'FAIL: open /tmp/sdtest.3654-6536-J2ZwFM/file__post failed - Permission denied'
...

The cause is a bash bug handling UTF-8 on subshells.

Fixes: https://bugs.launchpad.net/apparmor/+bug/1932331
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/765

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 458a981b62)
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2021-06-28 15:49:07 -03:00
Christian Boltz
3396bf8d77 abstractions/php: support PHP 8
Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1186267
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/755
(cherry picked from commit 5853f52233)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-05-24 03:10:27 -07:00
John Johansen
debe35adf5 Merge Update postfix profiles
... with paths and needed permissions seen on latest Tumbleweed

I propose these additions for 3.0 and master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/753
Acked-by: John Johansen <john@jjmx.net>
(cherry picked from commit 52de1a226f)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-05-17 16:59:03 -07:00
John Johansen
ec44a2c46b Merge Fix comment wording in file_cache.h
Fixes: https://gitlab.com/apparmor/apparmor/-/merge_requests/743
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/752
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 33a53c2664)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-05-02 02:43:15 -07:00
Steve Beattie
4ba0e3897a tests: add basic recursive include tests
With simple recursion loop detection landing in both the parser and the
utils, cherry-pick the added test cases to ensure we don't break things
in future backports to the 3.0 branch.

Cherry-picked:
  5dc9b4ce - parser: add a simple one-level recursive include test
  f0221f4b - Add a test with recursive include in preamble

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/743
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/750
2021-04-28 07:46:10 -07:00
Christian Boltz
4a9d52c7e6 tests: Add a test with recursive include in preamble
(cherry picked from commit f0221f4bca)
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/750
2021-04-28 07:33:25 -07:00
Steve Beattie
27c931f089 parser: add a simple one-level recursive include test
This adds a recursive include that otherwise parses correctly, to check
that the parser handles one-level recursion loop acceptably. When the
utils can support it, we should have tests that exercise deeper levels
of looping, e.g. include a -> include b -> include c -> include a or
deeper.

Without the fix in
https://gitlab.com/apparmor/apparmor/-/merge_requests/743, the parser
does fail due to hitting its file descriptor limit.

(The test at

  https://gitlab.com/apparmor/apparmor/-/blob/master/parser/tst/simple_tests/include_tests/recursive.sd

includes itself, which will result in a recursive profile definition
which isn't accepted by the parser.)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/743
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit c00b0d325b)
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2021-04-28 07:32:28 -07:00
John Johansen
9e22a6e1e3 parser: Fix invalid reference to name in attachment warning
The name var is being improperly used in a warning. Not only is
it being used after it is freed, it also never had the correct value
as the "name" variable contained the value being used as the base
attachment.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/727
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: time out
(cherry picked from commit 74bc4275a5)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-04-27 21:56:07 -07:00
John Johansen
fe64edc828 parser: fix filter slashes for profile attachments
The parser is failing to properly filter the slashes in the profile
attachment after variable expansion. Causing matche failures when
multiple slashes occur.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/154
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/727
Reported-by: Mikhail Morfikov <mmorfikov@gmail.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: time out
(cherry picked from commit be0d2fa947)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-04-27 21:55:45 -07:00
John Johansen
7ab110df19 parser: add include dedup cache to handle include loops
Profile includes can be setup to loop and expand in a pathalogical
manner that causes build failures. Fix this by caching which includes
have already been seen in a given profile context.

In addition this can speed up some profile compiles, that end up
re-including common abstractions. By not only deduping the files
being included but skipping the need to reprocess and dedup the
rules within the include.

Fixes: https://bugzilla.suse.com/show_bug.cgi?id=1184779
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/743
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 7dcf013bca)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-04-27 21:02:58 -07:00
Christian Boltz
244334eab3 .gitignore: Add aa-features-abi and utils coverage files
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/748
(cherry picked from commit 5c0609453c)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-04-26 17:35:07 -07:00
Steve Beattie
4831e933f0 [3.0] Detect endless #include loop when parsing profiles
Merge branch 'cboltz-3.0-detect-self-include' into 'apparmor-3.0'

If an include file includes itsself (for example if local/foo has
'#include <local/foo>'), print a warning instead of calling
load_include() again and again.

This fixes a crash when hitting such a case:
    RecursionError: maximum recursion depth exceeded while calling a Python object

Fixes: https://bugzilla.suse.com/show_bug.cgi?id=1184779 for the tools.
The parser will also need a fix.

This is the 3.0 version of 30323a2ded /
https://gitlab.com/apparmor/apparmor/-/merge_requests/742

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/746
Acked-By: Steve Beattie <steve@nxnw.org>
2021-04-22 19:49:00 +00:00
Christian Boltz
b5a2a1ec13 Detect endless #include loop when parsing profiles
If an include file includes itsself (for example if local/foo has
'#include <local/foo>'), print a warning instead of calling
load_include() again and again.

This fixes a crash when hitting such a case:
    RecursionError: maximum recursion depth exceeded while calling a Python object

Fixes: https://bugzilla.suse.com/show_bug.cgi?id=1184779 for the tools.
The parser will also need a fix.

This is the 3.0 version of 30323a2ded /
https://gitlab.com/apparmor/apparmor/-/merge_requests/742
2021-04-22 19:38:56 +02:00
John Johansen
4ee00aa076 profiles: dhclient: allow setting task comm name
dhclient wants to set its thread names to functional names for
introspection purposes. Eg.

$ pstree -at 3395
dhclient ens3
  ├─{isc-socket}
  ├─{isc-timer}
  └─{isc-worker0000}

When denied this can result in dhclient breaking and failing to obtain
IPv4 addresses.

Fixes: https://bugs.launchpad.net/ubuntu/+source/isc-dhcp/+bug/1918410
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
(cherry picked from commit c734839551)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-03-31 03:01:49 -07:00
John Johansen
55da3a19c2 Merge look up python-config using AC_PATH_TOOL
Doing so adds the $ac_tool_prefix during cross compilation and will end up using the correct, architecture-dependent python-config.

This is the second and last upstreamable change from https://bugs.debian.org/984582. It looks a little simpler here, because apparmor evolved upstream compared to the Debian version. Fortunately, it got a lot simpler in the process.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/729
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit c32c970d00)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-03-20 03:12:54 -07:00
John Johansen
e58742c028 Merge Do not abuse AC_CHECK_FILE
AC_CHECK_FILE is meant to check for host files and therefore fails hard during cross compilation unless one supplies a cached check result. Here we want to know about the presence of a build system file though, so AC_CHECK_FILE is the wrong tool.

This is part of https://bugs.debian.org/984582.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/728
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit f17143b5c3)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-03-20 03:12:24 -07:00
John Johansen
7f84e8bc4e profiles: dhcpd: add rule for port_range
The following AppArmor denial errors are shown on startup:

Oct 25 00:52:00 xxx kernel: [  556.231990] audit: type=1400 audit(1603601520.710:32): apparmor="DENIED" operation="open" profile="/usr/sbin/dhcpd" name="/proc/sys/net/ipv4/ip_local_port_range" pid=1982 comm="dhcpd" requested_mask="r" denied_mask="r" fsuid=0 ouid=0

Oct 25 00:52:00 xxx kernel: [  556.232257] audit: type=1400 audit(1603601520.710:33): apparmor="DENIED" operation="open" profile="/usr/sbin/dhcpd" name="/proc/sys/net/ipv4/ip_local_port_range" pid=1982 comm="dhcpd" requested_mask="r" denied_mask="r" fsuid=0 ouid=0

Fixes: https://bugs.launchpad.net/bugs/1901373
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/726
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 277677daf3)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-03-15 23:58:27 -07:00
John Johansen
8b939b8dd4 parser: fix filter slashes for link targets
The parser is failing to properly filter the slashes in the link name
after variable expansion. Causing match failures when multiple slashes
occur.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/153
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/723
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 2852e1ecdf)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-03-15 00:48:07 -07:00
Mikhail Morfikov
4c6f8352b1 abstractions: Add missing rule in wutmp abstraction
Currently the wutmp abstraction has the following rules:
  /var/log/lastlog  rwk,
  /var/log/wtmp     wk,
  @{run}/utmp       rwk,

According to what I see in my apparmor profiles, just a few apps want
to interact with the files listed above, especially with the
/var/log/wtmp . But when the apps do this, they sometimes want the
read access to this file. An example could be the last command. Is
there any reason for not having the r in the rule?  The second thing
is the file /var/log/btmp (which isn't included in the
abstracion). Whenever I see an app, which wants to access the
/var/log/wtmp file, it also tries to interact with the /var/log/btmp
file, for instance lightdm/sddm or su . Most of the time they need
just wk permissions, but sometimes apps need also r on this file, an
example could be the lastb command, which is just a link to last.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/152
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/724
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit d4e0a94511)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-03-14 11:53:21 -07:00
John Johansen
f79ea041a4 libapparmor: alphasort directory traversals
Directory traversal does not have a guaranteed walk order which can
cause ordering problems on profile loads when explicit dependencies
are missing.

Combined with MR:703 this provides a userspace work around for issue
147.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/147
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/706
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit fe477af62a)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-03-14 07:27:13 -07:00
John Johansen
4983fda88b parser: fix rule downgrade for unix rules
Rule downgrades are used to provide some confinement when a feature
is only partially supported by the kernel.

  Eg. On a kernel that doesn't support fine grained af_unix mediation
      but does support network mediation.

        unix (connect, receive, send)
              type=stream
              peer=(addr="@/tmp/.ICE-unix/[0-9]*"),

      will be downgraded to

        network unix type=stream,

Which while more permissive still provides some mediation while
allowing the appication to still function. However making the rule
a deny rule result in tightening the profile.

  Eg.
        deny unix (connect, receive, send)
              type=stream
              peer=(addr="@/tmp/.ICE-unix/[0-9]*"),

      will be downgraded to

        deny network unix type=stream,

and that deny rule will take priority over any allow rule. Which means
that if the profile also had unix allow rules they will get blocked by
the downgraded deny rule, because deny rules have a higher priority,
and the application will break. Even worse there is no way to add the
functionality back to the profile without deleting the offending deny
rule.

To fix this we drop deny rules that can't be downgraded in a way that
won't break the application.

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1180766
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/700
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 855dbd4ac8)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-03-14 07:18:49 -07:00
Christian Boltz
3db5d76282 postfix-flush and -showq: add permissions needed with latest postfix
... as seen on openSUSE Tumbleweed

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/717
(cherry picked from commit 08719eebc1)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-03-14 06:34:00 -07:00
Christian Boltz
1cd34e5ce6 postfix: allow access to *.lmdb files
... in addition to *.db files.

openSUSE Tumbleweed now uses the lmdb format by default.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/717
(cherry picked from commit a07f30e25d)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-03-14 06:33:18 -07:00
Christian Boltz
06b56e2511 cleanup postfix profiles
/etc/postfix/*.db is covered by abstractions/postfix-common

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/717
(cherry picked from commit 32bd2bcec3)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-03-14 06:30:30 -07:00
John Johansen
377613433f parser: fix build issue with REALLOCARRAY check
On some systems the build of the parser is spitting out

cc: fatal error: no input files
compilation terminated.

This is being caused by the REALLOCARRAY checkfailing due to cpp trying
to check for both input and output files and not correctly falling
back to stdin/stdout if infile and outfile aren't specified.

Fix this by being explicit that infile and outfile are supposed to
use stdin and stdout.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/712
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
(cherry picked from commit b6fbe10d11)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-02-16 05:18:02 -08:00
Rose Kunkel
6e8df906bf Fix nscd conflict with systemd-homed
My main user account is managed by systemd-homed. When I enable
AppArmor and have nscd running, I get inconsistent behavior with my
user account - sometimes I can't log in, sometimes I can log in but
not use sudo, etc.

This is the output of getent passwd:
  $ getent passwd
  root0:0::/root:/usr/bin/zsh
  bin1:1::/:/sbin/nologin
  daemon2:2::/:/sbin/nologin
  mail8:12::/var/spool/mail:/sbin/nologin
  ftp14:11::/srv/ftp:/sbin/nologin
  http33:33::/srv/http:/sbin/nologin
  nobody65534:65534:Nobody:/:/sbin/nologin
  dbus81:81:System Message Bus:/:/sbin/nologin
  [...]
  rose1000:1000:Rose Kunkel:/home/rose:/usr/bin/zsh

But getent passwd rose and getent passwd 1000 both return no output.
Stopping nscd.service fixes these problems. Checking the apparmor
logs, I noticed that nscd was denied access to
/etc/machine-id. Allowing access to that file seems to have fixed the
issue.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/707
Fixes: https://gitlab.com/apparmor/apparmor/-/issues/145
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit ee5303c8a0)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-02-11 22:55:47 -08:00
Seth Arnold
f65572d847 profiles: firefox Add support for widevine DRM
Ubuntu 18.04, Firefox 60.0.1+build2-0ubuntu0.18.04.1

Running firefix, then going to netflix.com and attempting to play a
movie. The widevinecdm plugin crashes, the following is found in
syslog:

Jun 15 19:13:22 xplt kernel: [301351.553043] audit: type=1400 audit(1529046802.585:246): apparmor="DENIED" operation="file_mmap" profile="/usr/lib/firefox/firefox{,*[^s][^h]}" name="/home/xav/.mozilla/firefox/wiavokxk.default-1510977878171/gmp-widevinecdm/1.4.8.1008/libwidevinecdm.so" pid=16118 comm="plugin-containe" requested_mask="m" denied_mask="m" fsuid=1000 ouid=1000
Jun 15 19:13:22 xplt kernel: [301351.553236] audit: type=1400 audit(1529046802.585:247): apparmor="DENIED" operation="ptrace" profile="/usr/lib/firefox/firefox{,*[^s][^h]}" pid=24714 comm="firefox" requested_mask="trace" denied_mask="trace" peer="/usr/lib/firefox/firefox{,*[^s][^h]}"
Jun 15 19:13:22 xplt kernel: [301351.553259] plugin-containe[16118]: segfault at 0 ip 00007fcdfdaa76af sp 00007ffc1ff03e28 error 6 in libxul.so[7fcdfb77a000+6111000]
Jun 15 19:13:22 xplt snmpd[2334]: error on subcontainer 'ia_addr' insert
...

Fixes: https://bugs.launchpad.net/ubuntu/+source/firefox/+bug/1777070
Reported-by: Xav Paice <xav.paice@canonical.com>
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/684
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 656f2103ed)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-02-11 19:40:16 -08:00
nl6720
b35b15ae70 usr.sbin.ntpd: add abstractions/ssl_certs
openntpd requires access to CA certificates when using the HTTPS constraint feature.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/698
(cherry picked from commit c5ef2d2f9e)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-02-11 04:32:01 -08:00
nl6720
acf97383ae abstractions/ssl_certs: add /etc/ca-certificates/ and /etc/libressl/
- On Arch Linux certificates are extracted to /etc/ca-certificates/ by the update-ca-trust script.
- /etc/libressl/ is used by Arch Linux's libressl package.
- Combine rules to reduce number of lines.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/698
(cherry picked from commit 63bcad086f)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-02-11 04:31:24 -08:00
John Johansen
88acc4006d parser: fix --jobs so job scaling is applied correctly
job scaling allows the parser to resample the number of cpus available
and increase the number of jobs that can be launched if cpu available
increases.

Unfortunately job scaling was being applied even when a fixed number
of jobs was specified. So
  --jobs=2

doesn't actually clamp the compile at 2 jobs.

Instead job scaling should only be applied when --jobs=auto or when
jobs are set to a multiple of the cpus.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/703
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 65ba20b955)
2021-02-10 19:16:37 -08:00
Steve Beattie
42c12930a3 profiles: add new deny path for kwallet (used in KDE 5)
Reported on IRC by finalspacevoid

Acked-by: Steve Beattie <steve@nxnw.org>
Merge branch 'cboltz-kwallet-path' into 'master'
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/704

(cherry picked from commit 15e897cad0)
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2021-02-07 21:58:42 -08:00
Aaron U'Ren
9d24cef8d5 fix setting proc_attr_base
There is currently a case in which proc_attr_base won't get set when
asprintf is able to generate the path, but the file doesn't exist, it
will exit proc_attr_base_init_once() without proc_attr_base having been
set as the fall-through if/else logic will get bypassed when asprintf is
successful.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/701
(cherry picked from commit cc113f4820)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-01-22 12:47:39 -08:00
Christian Boltz
e35e838034 add re_match_include_parse() test with invalid rule name
... to increase test coverity of regex.py to 100%.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/695
(cherry picked from commit c3d3203a60)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-01-10 14:45:27 -08:00
Christian Boltz
c848e8e270 Add missing test for ProfileList add_alias()
... to ensure that it errors out if a wrong parameter type is given.

This also increases the test coverage of ProfileList to 100%.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/694
(cherry picked from commit 32b11c0375)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-01-10 03:36:48 -08:00
Christian Boltz
f5c0fe6dce Fix comment in split_name() tests
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/692
(cherry picked from commit 2cbd0d94be)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2021-01-10 03:36:20 -08:00
Christian Boltz
49f3b6649b apparmor.vim: add support for abi rules
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/690
(cherry picked from commit c421fcd38a)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-12-11 14:54:57 -08:00
zt1024
543da0cee9 parser: don't abort profile compile if the kernel is missing caps/mask
3.0 added the ability to extract and use the kernels cap mask
to augment its internal capability list as a stop gap measure to
support new capabilities.

Unfortunately not all kernel export the cap/mask and this is causing
the policy compile to fail. If the kernel doesn't export a cp/mask
just use the internal list.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/140
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/691
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit c43bdf2e8b)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-12-11 12:45:19 -08:00
David Runge
c4a2f5d9b1 Honor global LDFLAGS when building python library
libraries/libapparmor/swig/python/Makefile.am:
Add global LDFLAGS when building the python library.
When only applying the custom PYTHON_LDFLAGS (which are in fact
`python-config --ldflags`) distributions are unable to build the library
with e.g. full RELRO.

Fixes #129
Related to #138

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/689
(cherry picked from commit b646bbf21b)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-12-11 03:06:20 -08:00
John Johansen
b0f08aa9d6 Prepare for AppArmor 3.0.1 release
- update version file

Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-12-02 03:01:37 -08:00
John Johansen
f8cdac9017 Bump library version in preperation for release
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-12-02 02:57:56 -08:00
John Johansen
4c7042c1fc libapparmor: fix failure in procattr accesses due to domain change
libapparmor on startup does detection of whether the new stacking
proc interfaces are available and then store a var for which interface
should be used. This avoids libapparmor needing to detect which interface
to use on each proc based api call.

Unfortunately if the domain is changed on the task via change_hat or
change_profile and the proc interface is used after the domain change
it is possible that access to the interface will be denied by policy.
This is not a problem in and of it self except policy may have been
created assuming the old interface.

Fix this by adding a fallback that tries the old interface if we
are using the new interface by default and the failure was due to
an EACCES denial (policy based).

Also refactor the code a bit so this retry is isolated to one function
instead of adding it in two places.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/131
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/681
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit d26da6c42f)
2020-12-01 20:36:03 -08:00
John Johansen
900b595cab aa-notify: don't crash if the logfile is not present due to rotation
If aa-notify races file rotation it may crash with a trace back to
the log file being removed before the new one is moved into place.

    Traceback (most recent call last):
       File "/usr/sbin/aa-notify", line 570, in <module>
         main()
       File "/usr/sbin/aa-notify", line 533, in main
          for message in notify_about_new_entries(logfile, args.wait):
       File "/usr/sbin/aa-notify", line 145, in notify_about_new_entries
         for event in follow_apparmor_events(logfile, wait):
       File "/usr/sbin/aa-notify", line 236, in follow_apparmor_events
         if os.stat(logfile).st_ino != log_inode:
    FileNotFoundError: [Errno 2] No such file or directory: '/var/log/audit/audit.log'

If we hit this situation sleep and then retry opening the logfile.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/130
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/688
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
(cherry picked from commit 7c88f02d6a)
2020-11-30 05:22:12 -08:00
Christian Boltz
4992a6ab86 create_new_profile(): check if abstractions exist
... instead of blindly adding them to the profile, and later crash
(and/or cause parser errors) because they don't exist.

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1178527
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/683
(cherry picked from commit dfd7c245cd)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-11-28 05:20:31 -08:00
Christian Boltz
dd7f1817b4 aa-autodep: load abstractions on start
So far, aa-autodep "accidently" loaded the abstractions when parsing the
existing profiles. Obviously, this only worked if there is at least one
profile in the active or extra profile directory.

Without any existing profiles, aa-autodep crashed with
KeyError: '/tmp/apparmor.d/abstractions/base'

Prevent this crash by explicitely loading the abstractions on start.

Fixes: https://bugzilla.opensuse.org/show_bug.cgi?id=1178527#c1 [1]
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/682
(cherry picked from commit f6b3de7116)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-11-28 05:12:33 -08:00
Christian Boltz
ec93821b54 abstractions/X: Allow (only) reading X compose cache
... (/var/cache/libx11/compose/*), and deny any write attempts

Reported by darix,
https://git.nordisch.org/darix/apparmor-profiles-nordisch/-/blob/master/apparmor.d/teams

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/685
(cherry picked from commit 78bd811e2a)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-11-17 02:11:32 -08:00
John Johansen
7497ff4353 Merge Fix invalid Pux (should be PUx) permissions in dhclient-script
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/676
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit c29357a294)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-11-01 01:44:55 -08:00
John Johansen
c4150a1659 Merge Fix hotkey conflict in utils de.po and id.po
This is needed to catch conflicts between uppercase and lowercase hotkeys of the same letter, as seen with `(B)enannt` and `A(b)lehnen` in the german utils translations.

Also fix conflicting hotkeys in utils de.po, id.po and sv.po.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/675
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit e57174589c)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-11-01 01:29:57 -08:00
Vincas Dargis
cd464446b6 dovecot: allow reading dh.pem
Dovecot is hit with this denial on Debian 10 (buster):
```
type=AVC msg=audit(1603647096.369:24514): apparmor="DENIED"
operation="open" profile="dovecot" name="/usr/share/dovecot/dh.pem"
pid=28774 comm="doveconf" requested_mask="r" denied_mask="r" fsuid=0
ouid=0
```

This results in fatal error:

```
Oct 25 19:31:36 dovecot[28774]: doveconf: Fatal: Error in configuration
file /etc/dovecot/conf.d/10-ssl.conf line 50: ssl_dh: Can't open file
/usr/share/dovecot/dh.pem: Permission denied
```

Add rule to allow reading dh.pem.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/671
(cherry picked from commit 9d8e111abe)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-26 15:16:45 -07:00
Vincas Dargis
ba23532a59 dovecot: allow kill signal
Dovecot might try to kill related processes:

```
type=AVC msg=audit(1601314853.031:9327): apparmor="DENIED"
operation="signal" profile="dovecot" pid=21223 comm="dovecot"
requested_mask="send" denied_mask="send" signal=kill
peer="/usr/lib/dovecot/auth"

type=AVC msg=audit(1601315453.655:9369): apparmor="DENIED"
operation="signal" profile="dovecot" pid=21223 comm="dovecot"
requested_mask="send" denied_mask="send" signal=kill
peer="/usr/lib/dovecot/pop3"

type=AVC msg=audit(1602939754.145:101362): apparmor="DENIED"
operation="signal" profile="dovecot" pid=31632 comm="dovecot"
requested_mask="send" denied_mask="send" signal=kill
peer="/usr/lib/dovecot/pop3-login"
```
This discovered on low-power high-load machine (last resort timeout
handling?).

Update signal rule to allow SIGKILL.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/671
(cherry picked from commit 2f9d172c64)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-26 15:16:04 -07:00
intrigeri
11d1f3812f Fix typos
Spotted by Lintian.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/669
(cherry picked from commit d6e18b0db8)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-25 05:09:38 -07:00
intrigeri
51144b5cbb apparmor_xattrs.7: fix whatis entry
Spotted by Lintian (bad-whatis-entry).

(cherry picked from commit 0da70b173c)
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/669
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-25 05:09:03 -07:00
John Johansen
3e18c0785a Merge profiles/apparmor.d/abstractions/X: make x11 socket writable again
Unfortunately in apparmor sockets need `rw` access. Currently x11 can only work if abstract socket is available and used instead so those restrictions won't trigger.

partially reverts c7b8368216

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/664
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 0cb35fda84)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-25 04:33:45 -07:00
John Johansen
15595eb51d Merge Add Fontmatrix to abstractions/fonts
[Fontmatrix](https://github.com/fontmatrix/fontmatrix) [adds \~/.Fontmatrix/Activated to fonts.conf](https://github.com/fontmatrix/fontmatrix/blob/75552e2/src/typotek.cpp#L1081-L1088). This causes programs which use [Fontconfig](https://gitlab.freedesktop.org/fontconfig/fontconfig) (directly or indirectly through libraries such as [Pango](https://pango.gnome.org/)) to include that directory in their font search path, which causes errors such as:

```
audit: type=1400 audit(1602678958.525:53): apparmor="DENIED" operation="open" profile="fr.emersion.Mako" name="/home/username/.Fontmatrix/Activated/.uuid" pid=48553 comm="mako" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
audit: type=1400 audit(1602678958.525:54): apparmor="DENIED" operation="open" profile="fr.emersion.Mako" name="/home/username/.Fontmatrix/Activated/" pid=48553 comm="mako" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
```

if the program does not explicitly include this directory in its AppArmor profile. As with other common font locations, add `~/.Fontmatrix/Activated` to the fonts abstraction for read-only access.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/657
Acked-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 24855edd11)
2020-10-25 04:26:38 -07:00
Francois Marier
ad30555a96 Adjust to support brave in ubuntu abstractions
Bug-Ubuntu: https://launchpad.net/bugs/1889699
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/667
(cherry picked from commit 9b30f9306d)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-25 04:16:55 -07:00
Jamie Strandboge
b0e12a5788 Adjust ubuntu-integration to use abstractions/exo-open
Bug-Ubuntu: https://launchpad.net/bugs/1891338
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/666
(cherry picked from commit 9ff0bbb69e)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-25 04:15:46 -07:00
Christian Boltz
1ba978b65c Merge branch 'adjust-for-new-ICEauthority-path-in-run' into 'master'
Adjust for new ICEauthority path in /run

Bug-Ubuntu: https://launchpad.net/bugs/1881357

See merge request apparmor/apparmor!668


Acked-by: Christian Boltz <apparmor@cboltz.de> for 3.0 and master

(cherry picked from commit dbb1b900b8)

1abe1017 Adjust for new ICEauthority path in /run
2020-10-25 10:16:40 +00:00
Mikhail Morfikov
3c2ddc2ede abstractions: mesa - tightens cache location and add fallback
This tightens the cache location in @{HOME}/.cache and also adds
the tmp fallback location.

Currently there are the following entries in the mesa abstraction:

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/91
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 5aa6db68e0)
2020-10-25 02:17:37 -07:00
glitsj16
805cb2c796 profiles: nscd: service fails with apparmor 3.0.0-2 on Arch Linux
After a recent upgrade of apparmor on Arch Linux the nscd systemd service fails to start. Arch Linux has /var/db/nscd and that path is missing from the profile AFAICT.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/651
Fixes: https://gitlab.com/apparmor/apparmor/-/issues/124
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 821f9fe42d)
2020-10-25 02:09:54 -07:00
John Johansen
8cb1f8f4f6 utils: fix make -C profiles check-logprof fails
On arch
  make -C profiles check-logprof

fails with
  *** Checking profiles from ./apparmor.d against logprof

  ERROR: Can't find AppArmor profiles in /etc/apparmor.d
  make: *** [Makefile:113: check-logprof] Error 1
  make: Leaving directory '/build/apparmor/src/apparmor-2.13.3/profiles'

because /etc/apparmor.d/ is not available in the build environment
and aa-logprofs --dir argument, is not being passed to init_aa()
but used to update profiles_dir after the fact.

Fix this by passing profiledir as an argument to init_aa()

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/36
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/663
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
(cherry picked from commit 15dc06248c)
2020-10-22 14:58:37 -07:00
John Johansen
ff72ea9a56 aa-notify: Stop aa-notify from exit after 100s of polling
When run with the -p flag, aa-notify works fine for 100 seconds and then it exits.
I suspect that the issue arises from the following check on line 259 in utils/aa-notify
if debug_logger.debug_level <= 10 and int(time.time()) - start_time > 100:
    debug_logger.debug('Debug mode detected: aborting notification emitter after 100 seconds.')
    sys.exit(0)
together with line 301 in utils/apparmor/common.py which initializes debug_logger.debug_level to logging.DEBUG which has the numerical value 10.
A simple solution might be to just remove the check as I'm not quit sure why one would want aa-notify to exit when run in debug mode in the first place.
Alternatively, one could check against debug_logger.debugging (initialized to False) or change the initialization of debug_logger.debug_level to something else, but I don't know how that would affect other consumers of utils/apparmor/common.py.

For now just add dbugger_logger.debugging as an additional check as the
reason for timing out after 100s during debugging are unclear.

Suggested-by: vicvbcun
Fixes: https://gitlab.com/apparmor/apparmor/-/issues/126
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/660
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Otto Kekäläinen <otto@kekalainen.net>
(cherry picked from commit 8ea7630b6d)
2020-10-21 17:04:24 -07:00
John Johansen
eab43b5358 utils: split linting with PYFLAKES into a separate target.
This a step towards addressing the linting of the utils causing
problems in a build vs dev environment. See
  https://gitlab.com/apparmor/apparmor/-/issues/121

Split off linting with PYFLAKES into its own target as a step towards
making the running of the lint checks as a configuration option.

https://gitlab.com/apparmor/apparmor/-/merge_requests/662
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
(cherry picked from commit 43eb54d13c)
2020-10-21 17:04:07 -07:00
John Johansen
bf75381287 Merge Revert "Merge dnsmasq: Permit access to /proc/self/fd/"
This reverts merge request !628. My reason for this proposal is that commit 88c142c6 already provided this change, something I must have missed when I opened the initial merge request. This resulted in duplicate entries in the profile, something that is also potentially confusing to users or other contributors.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/659
Acked-by: John Johansen <john.johansen@canonical.com>


(cherry picked from commit 38c611ed31)

e0b20a4d Revert "Merge dnsmasq: Permit access to /proc/self/fd/"
2020-10-20 20:00:57 +00:00
Christian Boltz
80efc15e18 Add CAP_CHECKPOINT_RESTORE to severity.db
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/656
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 2c2dbdc3a3)
2020-10-15 03:02:02 -07:00
John Johansen
49db93a79d translations: update generated pot files
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-14 04:08:04 -07:00
John Johansen
935003883e parser: Add support for CAP_CHECKPOINT_RESTORE
Linux 5.9 added CAP_CHECKPOINT_RESTORE add it to the set of supported
capabilities.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/654
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
(cherry picked from commit 644a473971)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-13 21:33:06 -07:00
John Johansen
5ee729331a regression tests: fix aa_policy_cache to use correct config file
The aa_policy_cache test is using the system parser.conf file even
when the tests are set to use source. This can lead to failures
if the system parser.conf contain options not understood by
the source parser.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/653
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 1033e19171)
2020-10-13 05:06:55 -07:00
John Johansen
d89478794e regression test: Fix regression tests when using in tree parser
When using the in tree parser we should not be using the system
parser.conf file, as if the system apparmor is newer than the
tree being tested the parser.conf file could contain options not
understood by the in tree apparmor_parser.

Use --config-file to specify the default in tree parser.conf

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/653
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 5ac368bce7)
2020-10-13 05:06:45 -07:00
John Johansen
738c7c60ba parser: Fix warning message when complain mode is forced
when a profile is being forced to complain a variation of the
following message is displayed

  Warning from /etc/apparmor.d/usr.sbin.sssd (/etc/apparmor.d/usr.sbin.sssd line 54): Warning failed to create cache: usr.sbin.sssd

This is incorrect in that the parser doesn't even try to create the
cache, it just can't cache force complain profiles.

Output a warning message for this case that is correct.

Fixes: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1899218
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/649
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
(cherry picked from commit 21060e802a)
2020-10-11 03:57:18 -07:00
John Johansen
e142376368 parser: fix parser.conf commenting on pinning an abi
The comments describing the example rules to pin the abi are wrong.
The comments of the two example rules are swapped resulting in confusion.

While we are at it. Add a reference to the wiki doc on abi, and
how to disable abi warnings without pinning.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/648
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
(cherry picked from commit ec19ff9f72)
2020-10-11 03:56:35 -07:00
Armin Kuster
8f39da5501 parser/Makefile: dont force host cpp to detect reallocarray
In cross build environments, using the hosts cpp gives incorrect
detection of reallocarray. Change cpp to a variable.

fixes:
parser_misc.c: In function 'int capable_add_cap(const char*, int, unsigned int, capability_flags)':
| parser_misc.c:297:37: error: 'reallocarray' was not declared in this scope
|   297 |   tmp = (struct capability_table *) reallocarray(cap_table, sizeof(struct capability_table), cap_table_size+1);

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/647
Signed-off-by: Armin Kuster <akuster808@gmail.com>
(cherry picked from commit 0dbcbee700)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-11 03:53:58 -07:00
Armin Kuster
2f774431cb aa_status: Fix build issue with musl
add limits.h

aa_status.c:269:22: error: 'PATH_MAX' undeclared (first use in this function); did you mean 'AF_MAX'?
|   269 |    real_exe = calloc(PATH_MAX + 1, sizeof(char));

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/647
Signed-off-by: Armin Kuster <akuster808@gmail.com>
(cherry picked from commit a2a0d14b9c)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-11 03:53:15 -07:00
Armin Kuster
b64bf7771a apparmor: fix manpage order
It trys to create a symlink before the man pages are installed.

 ln -sf aa-status.8 /(path}/apparmor/3.0-r0/image/usr/share/man/man8/apparmor_status.8
 | ln: failed to create symbolic link '{path}/apparmor/3.0-r0/image/usr/share/man/man8/apparmor_status.8': No such file or directory

...

install -d /{path}/apparmor/3.0-r0/image/usr/share/man/man8 ; install -m 644 aa-status.8 /{path}/apparmor/3.0-r0/image/usr/share/man/man8;

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/646
Signed-off-by: Armin Kuster <akuster808@gmail.com>
(cherry picked from commit 37b9028499)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-11 03:50:23 -07:00
Anton Nesterov
848664b47b Fix dhclient and dhclient-script profiles to work on debian buster
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/645
(cherry picked from commit 9b70ef4fb7)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-11 03:48:59 -07:00
David Runge
526c902ba2 Skip test if it can not access /var/log/wtmp
utils/test/test-aa-notify.py:
Change `AANotifyTest.test_entries_since_login()` to be decorated by a
`skipUnless()` checking for existence of **/var/log/wtmp** (similar to
`AANotifyTest.test_entries_since_login_verbose()`).
The test otherwise fails trying to access /var/log/wtmp in environments
where the file is not available.

Fixes https://gitlab.com/apparmor/apparmor/-/issues/120
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/641
(cherry picked from commit e0200b1b16)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-11 03:46:22 -07:00
Patrick Steinhardt
b73b8ed432 libapparmor: add missing include for socklen_t
While `include/sys/apparmor.h` makes use of `socklen_t`, it doesn't
include the `<sys/socket.h>` header to make its declaration available.
While this works on systems using glibc via transitive includes, it
breaks compilation on musl libc.

Fix the issue by including the header.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/642
Signed-off-by: Patrick Steinhardt <ps@pks.im>
(cherry picked from commit 47263a3a74)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-11 03:44:55 -07:00
Patrick Steinhardt
59589308eb libapparmor: add _aa_asprintf to private symbols
While `_aa_asprintf` is supposed to be of private visibility, it's used
by apparmor_parser and thus required to be visible when linking. This
commit thus adds it to the list of private symbols to make it available
for linking in apparmor_parser.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/643
Signed-off-by: Patrick Steinhardt <ps@pks.im>
(cherry picked from commit 9a8fee6bf1)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-11 03:43:28 -07:00
Patrick Steinhardt
2ef17fa972 libapparmor: add aa_features_new_from_file to public symbols
With AppArmor release 3.0, a new function `aa_features_new_from_file`
was added, but not added to the list of public symbols. As a result,
it's not possible to make use of this function when linking against
libapparmor.so.

Fix the issue by adding it to the symbol map.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/643
Signed-off-by: Patrick Steinhardt <ps@pks.im>
(cherry picked from commit c9255a0343)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-11 03:42:40 -07:00
237 changed files with 4382 additions and 5554 deletions

21
.gitignore vendored
View File

@@ -216,11 +216,7 @@ utils/vim/apparmor.vim
utils/vim/apparmor.vim.5
utils/vim/apparmor.vim.5.html
utils/vim/pod2htmd.tmp
tests/regression/apparmor/*.o
tests/regression/apparmor/aa_policy_cache
tests/regression/apparmor/access
tests/regression/apparmor/at_secure
tests/regression/apparmor/attach_disconnected
tests/regression/apparmor/changehat
tests/regression/apparmor/changehat_fail
tests/regression/apparmor/changehat_fork
@@ -235,10 +231,6 @@ tests/regression/apparmor/chgrp
tests/regression/apparmor/chmod
tests/regression/apparmor/chown
tests/regression/apparmor/clone
tests/regression/apparmor/dbus_eavesdrop
tests/regression/apparmor/dbus_message
tests/regression/apparmor/dbus_service
tests/regression/apparmor/dbus_unrequested_reply
tests/regression/apparmor/deleted
tests/regression/apparmor/env_check
tests/regression/apparmor/environ
@@ -249,10 +241,7 @@ tests/regression/apparmor/fchdir
tests/regression/apparmor/fchgrp
tests/regression/apparmor/fchmod
tests/regression/apparmor/fchown
tests/regression/apparmor/fd_inheritance
tests/regression/apparmor/fd_inheritor
tests/regression/apparmor/fork
tests/regression/apparmor/introspect
tests/regression/apparmor/link
tests/regression/apparmor/link_subset
tests/regression/apparmor/mkdir
@@ -263,20 +252,15 @@ tests/regression/apparmor/net_raw
tests/regression/apparmor/open
tests/regression/apparmor/openat
tests/regression/apparmor/pipe
tests/regression/apparmor/pivot_root
tests/regression/apparmor/ptrace
tests/regression/apparmor/ptrace_helper
tests/regression/apparmor/pwrite
tests/regression/apparmor/query_label
tests/regression/apparmor/readdir
tests/regression/apparmor/rename
tests/regression/apparmor/rw
tests/regression/apparmor/socketpair
tests/regression/apparmor/swap
tests/regression/apparmor/symlink
tests/regression/apparmor/syscall_chroot
tests/regression/apparmor/syscall_ioperm
tests/regression/apparmor/syscall_iopl
tests/regression/apparmor/syscall_mknod
tests/regression/apparmor/syscall_mlockall
tests/regression/apparmor/syscall_ptrace
@@ -288,15 +272,10 @@ tests/regression/apparmor/syscall_setscheduler
tests/regression/apparmor/syscall_sysctl
tests/regression/apparmor/sysctl_proc
tests/regression/apparmor/tcp
tests/regression/apparmor/transition
tests/regression/apparmor/unix_fd_client
tests/regression/apparmor/unix_fd_server
tests/regression/apparmor/unix_socket
tests/regression/apparmor/unix_socket_client
tests/regression/apparmor/unlink
tests/regression/apparmor/uservars.inc
tests/regression/apparmor/xattrs
tests/regression/apparmor/xattrs_profile
tests/regression/apparmor/coredump
**/__pycache__/
*.orig

View File

@@ -1,5 +1,9 @@
---
image: ubuntu:latest
before_script:
- export DEBIAN_FRONTEND=noninteractive && apt-get update -qq && apt-get install --no-install-recommends -y build-essential apache2-dev autoconf automake bison dejagnu flex libpam-dev libtool perl liblocale-gettext-perl pkg-config python-all-dev python3-all-dev pyflakes3 ruby-dev swig lsb-release python3-notify2 python3-psutil python3-setuptools zlib1g-dev
- lsb_release -a
- uname -a
# XXX - add a deploy stage to publish man pages, docs, and coverage
# reports
@@ -8,131 +12,44 @@ stages:
- build
- test
.ubuntu-before_script:
before_script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get update -qq
- apt-get install --no-install-recommends -y gcc perl liblocale-gettext-perl linux-libc-dev lsb-release make
- lsb_release -a
- uname -a
.install-c-build-deps: &install-c-build-deps
- apt-get install --no-install-recommends -y build-essential apache2-dev autoconf automake bison dejagnu flex libpam-dev libtool pkg-config python3-all-dev python3-setuptools ruby-dev swig zlib1g-dev
build-all:
stage: build
extends:
- .ubuntu-before_script
artifacts:
name: ${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
expire_in: 30 days
untracked: true
paths:
- libraries/libapparmor/
- parser/
- binutils/
- utils/
- changehat/mod_apparmor/
- changehat/pam_apparmor/
- profiles/
- libraries/libapparmor/
- parser/
- binutils/
- utils/
- changehat/mod_apparmor/
- changehat/pam_apparmor/
- profiles/
script:
- *install-c-build-deps
- cd libraries/libapparmor && ./autogen.sh && ./configure --with-perl --with-python --prefix=/usr && make && cd ../.. || { cat config.log ; exit 1 ; }
- make -C parser
- make -C binutils
- make -C utils
- make -C changehat/mod_apparmor
- make -C changehat/pam_apparmor
- make -C profiles
- cd libraries/libapparmor && ./autogen.sh && ./configure --with-perl --with-python --prefix=/usr && make && cd ../.. || { cat config.log ; exit 1 ; }
- make -C parser
- make -C binutils
- make -C utils
- make -C changehat/mod_apparmor
- make -C changehat/pam_apparmor
- make -C profiles
test-libapparmor:
test-all:
stage: test
needs: ["build-all"]
extends:
- .ubuntu-before_script
script:
- *install-c-build-deps
- make -C libraries/libapparmor check
test-parser:
stage: test
needs: ["build-all"]
extends:
- .ubuntu-before_script
script:
- *install-c-build-deps
- make -C parser check
test-binutils:
stage: test
needs: ["build-all"]
extends:
- .ubuntu-before_script
script:
- make -C binutils check
test-utils:
stage: test
needs: ["build-all"]
extends:
- .ubuntu-before_script
script:
- apt-get install --no-install-recommends -y libc6-dev libjs-jquery libjs-jquery-throttle-debounce libjs-jquery-isonscreen libjs-jquery-tablesorter pyflakes3 python3-coverage python3-notify2 python3-psutil
# See apparmor/apparmor#221
- make -C parser/tst gen_dbus
- make -C parser/tst gen_xtrans
- make -C utils check
- make -C utils/test coverage-regression
artifacts:
paths:
- utils/test/htmlcov/
when: always
test-mod-apparmor:
stage: test
needs: ["build-all"]
extends:
- .ubuntu-before_script
script:
- make -C changehat/mod_apparmor check
test-profiles:
stage: test
needs: ["build-all"]
extends:
- .ubuntu-before_script
script:
- make -C profiles check-parser
- make -C profiles check-abstractions.d
shellcheck:
stage: test
needs: []
extends:
- .ubuntu-before_script
script:
- apt-get install --no-install-recommends -y file shellcheck xmlstarlet
- shellcheck --version
- './tests/bin/shellcheck-tree --format=checkstyle
| xmlstarlet tr tests/checkstyle2junit.xslt
> shellcheck.xml'
artifacts:
when: always
reports:
junit: shellcheck.xml
- make -C libraries/libapparmor check
- make -C parser check
- make -C binutils check
- make -C utils check
- make -C changehat/mod_apparmor check
- make -C profiles check-parser
- make -C profiles check-abstractions.d
# Disabled due to aa-logprof dependency on /sbin/apparmor_parser existing
# - make -C profiles check-profiles
# - make -C profiles check-profiles
# test-pam_apparmor:
# - stage: test
# - script:
# - cd changehat/pam_apparmor && make check
include:
- template: SAST.gitlab-ci.yml
- template: Secret-Detection.gitlab-ci.yml
variables:
SAST_EXCLUDED_ANALYZERS: "eslint,flawfinder,semgrep,spotbugs"
SAST_BANDIT_EXCLUDED_PATHS: "*/tst/*, */test/*"

View File

@@ -1,10 +0,0 @@
# Don't follow source'd scripts
disable=SC1090
disable=SC1091
# dash supports 'local'
disable=SC2039
disable=SC3043
# dash supports 'echo -n'
disable=SC3037

View File

@@ -1,66 +0,0 @@
# Copyright (C) 2015 Canonical Ltd
# This file is distributed under the same license as the AppArmor package.
# John Johansen <john.johansen@canonical.com>, 2015.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: apparmor@lists.ubuntu.com\n"
"POT-Creation-Date: 2015-11-28 10:23-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../aa_enabled.c:26
#, c-format
msgid ""
"%s: [options]\n"
" options:\n"
" -q | --quiet Don't print out any messages\n"
" -h | --help Print help\n"
msgstr ""
#: ../aa_enabled.c:45
#, c-format
msgid "unknown or incompatible options\n"
msgstr ""
#: ../aa_enabled.c:55
#, c-format
msgid "unknown option '%s'\n"
msgstr ""
#: ../aa_enabled.c:64
#, c-format
msgid "Yes\n"
msgstr ""
#: ../aa_enabled.c:71
#, c-format
msgid "No - not available on this system.\n"
msgstr ""
#: ../aa_enabled.c:74
#, c-format
msgid "No - disabled at boot.\n"
msgstr ""
#: ../aa_enabled.c:77
#, c-format
msgid "Maybe - policy interface not available.\n"
msgstr ""
#: ../aa_enabled.c:81
#, c-format
msgid "Maybe - insufficient permissions to determine availability.\n"
msgstr ""
#: ../aa_enabled.c:84
#, c-format
msgid "Error - '%s'\n"
msgstr ""

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: apparmor@lists.ubuntu.com\n"
"POT-Creation-Date: 2020-10-14 03:52-0700\n"
"POT-Creation-Date: 2020-10-14 03:58-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -22,7 +22,7 @@ msgstr ""
msgid ""
"%s: [options]\n"
" options:\n"
" -x | --exclusive Shared interfaces must be available\n"
" -x | --exclusive Shared interfaces must be availabe\n"
" -q | --quiet Don't print out any messages\n"
" -h | --help Print help\n"
msgstr ""

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: apparmor@lists.ubuntu.com\n"
"POT-Creation-Date: 2020-10-14 03:52-0700\n"
"POT-Creation-Date: 2020-10-14 03:58-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: apparmor@lists.ubuntu.com\n"
"POT-Creation-Date: 2020-10-14 03:52-0700\n"
"POT-Creation-Date: 2020-10-14 03:58-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@@ -412,7 +412,7 @@ register_hooks(unused_ apr_pool_t *p)
module AP_MODULE_DECLARE_DATA apparmor_module = {
STANDARD20_MODULE_STUFF,
aa_create_dir_config, /* dir config creator */
aa_create_dir_config, /* dir config creater */
NULL, /* dir merger --- default is to override */
/* immunix_merge_dir_config, */ /* dir merger --- default is to override */
aa_create_srv_config, /* server config */

View File

@@ -66,8 +66,8 @@ under src/jni_src.
cp dist/libJNIChangeHat.so /usr/lib
[Note: you must ensure that the target directory is passed to tomcat via the
java.library.path property. This can be accomplished by setting the JAVA_OPTS
environment variable, export JAVA_OPTS=-Djava.library.path, or set via the
java.library.path propert. This can be accomplished by setting the JAVA_OPTS
enviroment variable, export JAVA_OPTS=-Djava.library.path, or set via the
env variable LD_LIBRARY_PATH to include this directory so that tomcat can
find this library at startup]
@@ -108,13 +108,13 @@ under src/jni_src.
Once the installation steps above have been started you are ready to begin
creating a profile for your application. The profile creation tool genprof will
guide you through generating a profile and its support for change_hat will
prompt you create discrete hats as requested by the changeHatValve during
prompt you create discrete hats as requested byt the changeHatValve during
tomcat execution.
1. Create a basic profile for the tomcat server.
- Run the command "genprof PATH_TO_CATALINA.SH"
- In a separate window start tomcat and then stop tomcat
- In a seperate window start tomcat and then stop tomcat
- In the genprof window press "S" to scan for events
- Answer the questions about the initial profile for tomcat
@@ -124,7 +124,7 @@ tomcat execution.
- Stop the tomcat server
- Deploy your WAR file or equivalent files under the container.
- execute "genprof PATH_TO_CATALINA.SH"
- In a separate window start tomcat and then exercise your web application
- In a seperate window start tomcat and then exercise your web application
- In the genprof window press "S" to scan for events
During the prompting you will be asked questions similar to:
@@ -180,7 +180,7 @@ all subsequent resource requests will be mediated in this hew hat (or security
context).
If you choose to use the default hat: genprof will mediate all resource
requests in the default hat for the duration of processing this request.
When the request processing is complete the valve will change_hat back to the
When the request processng is complete the valve will change_hat back to the
parent context.

View File

@@ -66,8 +66,8 @@ under src/jni_src.
cp dist/libJNIChangeHat.so /usr/lib
[Note: you must ensure that the target directory is passed to tomcat via the
java.library.path property. This can be accomplished by setting the JAVA_OPTS
environment variable, export JAVA_OPTS=-Djava.library.path, or set via the
java.library.path propert. This can be accomplished by setting the JAVA_OPTS
enviroment variable, export JAVA_OPTS=-Djava.library.path, or set via the
env variable LD_LIBRARY_PATH to include this directory so that tomcat can
find this library at startup]
@@ -108,13 +108,13 @@ under src/jni_src.
Once the installation steps above have been started you are ready to begin
creating a profile for your application. The profile creation tool genprof will
guide you through generating a profile and its support for change_hat will
prompt you create discrete hats as requested by the changeHatValve during
prompt you create discrete hats as requested byt the changeHatValve during
tomcat execution.
1. Create a basic profile for the tomcat server.
- Run the command "genprof PATH_TO_CATALINA.SH"
- In a separate window start tomcat and then stop tomcat
- In a seperate window start tomcat and then stop tomcat
- In the genprof window press "S" to scan for events
- Answer the questions about the initial profile for tomcat
@@ -124,7 +124,7 @@ tomcat execution.
- Stop the tomcat server
- Deploy your WAR file or equivalent files under the container.
- execute "genprof PATH_TO_CATALINA.SH"
- In a separate window start tomcat and then exercise your web application
- In a seperate window start tomcat and then exercise your web application
- In the genprof window press "S" to scan for events
During the prompting you will be asked questions similar to:
@@ -180,7 +180,7 @@ all subsequent resource requests will be mediated in this hew hat (or security
context).
If you choose to use the default hat: genprof will mediate all resource
requests in the default hat for the duration of processing this request.
When the request processing is complete the valve will change_hat back to the
When the request processng is complete the valve will change_hat back to the
parent context.

View File

@@ -1 +1 @@
3.0.98
3.0.6

View File

@@ -6,7 +6,7 @@
# the source tree
# =====================
# It doesn't make sense for AppArmor to mediate PF_UNIX, filter it out. Search
# It doesn't make sence for AppArmor to mediate PF_UNIX, filter it out. Search
# for "PF_" constants since that is what is required in bits/socket.h, but
# rewrite as "AF_".

View File

@@ -125,7 +125,7 @@ layer. Binary policy cache files will be located in the directory
returned by this function.
The aa_policy_cache_dir_levels() function provides access to the number
of directories that are being overlaid to create the policy cache.
of directories that are being overlayed to create the policy cache.
=head1 RETURN VALUE

View File

@@ -27,7 +27,7 @@ INCLUDES = $(all_includes)
# http://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html
#
AA_LIB_CURRENT = 9
AA_LIB_REVISION = 2
AA_LIB_REVISION = 3
AA_LIB_AGE = 8
SUFFIXES = .pc.in .pc

View File

@@ -666,7 +666,7 @@ static const char *features_lookup(aa_features *features, const char *str)
/* Empty strings are not accepted. Neither are leading '/' chars. */
if (!str || str[0] == '/')
return NULL;
return false;
/**
* Break @str into an array of components. For example,
@@ -679,7 +679,7 @@ static const char *features_lookup(aa_features *features, const char *str)
/* At least one valid token is required */
if (!num_components)
return NULL;
return false;
/* Ensure that all components are valid and found */
for (i = 0; i < num_components; i++) {

View File

@@ -378,7 +378,7 @@ key: TOK_KEY_OPERATION TOK_EQUALS TOK_QUOTED_STRING
| TOK_KEY_CAPABILITY TOK_EQUALS TOK_DIGITS
{ /* need to reverse map number to string, need to figure out
* how to get auto generation of reverse mapping table into
* autotools Makefile. For now just drop assuming capname is
* autotools Makefile. For now just drop assumming capname is
* present which it should be with current kernels */
}
| TOK_KEY_CAPNAME TOK_EQUALS TOK_QUOTED_STRING
@@ -386,7 +386,7 @@ key: TOK_KEY_OPERATION TOK_EQUALS TOK_QUOTED_STRING
ret_record->name = $3;
}
| TOK_KEY_OFFSET TOK_EQUALS TOK_DIGITS
{ /* offset is used for reporting where an error occurred unpacking
{ /* offset is used for reporting where an error occured unpacking
* loaded policy. We can just drop this currently
*/
}

View File

@@ -1319,9 +1319,9 @@ int aa_query_link_path_len(const char *label, size_t label_len,
query[pos] = 0;
query[++pos] = AA_CLASS_FILE;
memcpy(query + pos + 1, link, link_len);
/* The kernel does the query in two parts; we could simulate this
/* The kernel does the query in two parts we could similate this
* doing the following, however as long as policy is compiled
* correctly this isn't required, and it requires an extra round
* correctly this isn't requied, and it requires and extra round
* trip to the kernel and adds a race on policy replacement between
* the two queries.
*

View File

@@ -90,7 +90,7 @@ static int write_buffer(int fd, const char *buffer, int size)
/**
* write_policy_buffer - load compiled policy into the kernel
* @fd: kernel interface to write to
* @fd: kernel iterface to write to
* @atomic: whether to load all policy in buffer atomically (true)
* @buffer: buffer of policy to load
* @size: the size of the data in the buffer
@@ -205,7 +205,7 @@ static int write_policy_file_to_iface(aa_kernel_interface *kernel_interface,
* @apparmorfs: path to the apparmor directory of the mounted securityfs (can
* be NULL and the path will be auto discovered)
*
* Returns: 0 on success, -1 on error with errno set and *@kernel_interface
* Returns: 0 on success, -1 on error with errnot set and *@kernel_interface
* pointing to NULL
*/
int aa_kernel_interface_new(aa_kernel_interface **kernel_interface,

View File

@@ -63,7 +63,7 @@ struct ignored_suffix_t {
};
static struct ignored_suffix_t ignored_suffixes[] = {
/* Debian packaging files, which are in flux during install
/* Debian packging files, which are in flux during install
should be silently ignored. */
{ ".dpkg-new", 9, 1 },
{ ".dpkg-old", 9, 1 },
@@ -147,7 +147,7 @@ int _aa_is_blacklisted(const char *name)
return 0;
}
/* automatically free allocated variables tagged with autofree on fn exit */
/* automaticly free allocated variables tagged with autofree on fn exit */
void _aa_autofree(void *p)
{
void **_p = (void**)p;

View File

@@ -10,8 +10,7 @@ test_python.py: test_python.py.in $(top_builddir)/config.status
CLEANFILES = test_python.py
# bah, how brittle is this?
PYTHON_DIST_BUILD_PATH = '$(builddir)/../build/$$($(PYTHON) -c "import sysconfig; print(\"lib.%s-%s\" %(sysconfig.get_platform(), sysconfig.get_python_version()))")'
PYTHON_DIST_BUILD_PATH = '$(builddir)/../build/$$($(PYTHON) buildpath.py)'
TESTS = test_python.py
TESTS_ENVIRONMENT = \

View File

@@ -0,0 +1,10 @@
#!/usr/bin/python3
# the build path has changed in setuptools 61.2
import sys
import sysconfig
import setuptools
if tuple(map(int,setuptools.__version__.split("."))) >= (61, 2):
identifier = sys.implementation.cache_tag
else:
identifier = "%d.%d" % sys.version_info[:2]
print("lib.%s-%s" % (sysconfig.get_platform(), identifier))

View File

@@ -1,5 +1,5 @@
# Runs all tests with the extension "multi" for several times.
# Each test program <programname>.multi has its own subdirectory
# Runs all tests with the extention "multi" for several times.
# Each testprogram <programname>.multi has an own subdirectory
# <programmname> in which several testcases are defined for this program
# Each testcase has 3 files:
#

View File

@@ -60,7 +60,7 @@ WARNINGS = -Wall
CXX_WARNINGS = ${WARNINGS} ${EXTRA_WARNINGS}
CPP_WARNINGS =
ifndef CFLAGS
CFLAGS = -g -O2 -pipe -flto-partition=none
CFLAGS = -g -O2 -pipe
ifdef DEBUG
CFLAGS += -pg -D DEBUG
@@ -70,6 +70,8 @@ CFLAGS = -g -pg -fprofile-arcs -ftest-coverage
endif
endif #CFLAGS
CFLAGS += -flto-partition=none
EXTRA_CXXFLAGS = ${CFLAGS} ${CPPFLAGS} ${CXX_WARNINGS} -std=gnu++0x
EXTRA_CFLAGS = ${EXTRA_CXXFLAGS} ${CPP_WARNINGS}

View File

@@ -37,7 +37,7 @@ static struct supported_cond supported_conds[] = {
{ "type", true, false, false, local_cond },
{ "protocol", false, false, false, local_cond },
{ "label", true, false, false, peer_cond },
{ NULL, false, false, false, local_cond }, /* eol sentinel */
{ NULL, false, false, false, local_cond }, /* eol sentinal */
};
bool af_rule::cond_check(struct supported_cond *conds, struct cond_entry *ent,

View File

@@ -29,7 +29,7 @@
#include "profile.h"
#include "af_unix.h"
/* See unix(7) for autobind address definition */
/* See unix(7) for autobind address definiation */
#define autobind_address_pattern "\\x00[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]";
int parse_unix_mode(const char *str_mode, int *mode, int fail)
@@ -40,7 +40,7 @@ int parse_unix_mode(const char *str_mode, int *mode, int fail)
static struct supported_cond supported_conds[] = {
{ "addr", true, false, false, either_cond },
{ NULL, false, false, false, local_cond }, /* sentinel */
{ NULL, false, false, false, local_cond }, /* sentinal */
};
void unix_rule::move_conditionals(struct cond_entry *conds)
@@ -326,9 +326,8 @@ int unix_rule::gen_policy_re(Profile &prof)
rule_t::warn_once(prof.name, "downgrading extended network unix socket rule to generic network rule\n");
/* TODO: add ability to abort instead of downgrade */
return RULE_OK;
} else {
warn_once(prof.name);
}
warn_once(prof.name);
return RULE_NOT_SUPPORTED;
}
@@ -356,7 +355,7 @@ int unix_rule::gen_policy_re(Profile &prof)
/* local label option */
if (!write_label(tmp, label))
goto fail;
/* separator */
/* seperator */
tmp << "\\x00";
buf = tmp.str();
@@ -377,7 +376,7 @@ int unix_rule::gen_policy_re(Profile &prof)
/* local label option */
if (!write_label(buffer, label))
goto fail;
/* separator */
/* seperator */
buffer << "\\x00";
/* create already masked off */

View File

@@ -241,6 +241,9 @@ B<DBUS ACCESS LIST> = Comma separated list of I<DBUS ACCESS>
B<DBUS ACCESS> = ( 'send' | 'receive' | 'bind' | 'eavesdrop' | 'r' | 'read' | 'w' | 'write' | 'rw' )
Some accesses are incompatible with some rules; see below.
B<AARE> = B<?*[]{}^>
See below for meanings.
B<UNIX RULE> = [ I<QUALIFIERS> ] 'unix' [ I<UNIX ACCESS EXPR> ] [ I<UNIX RULE CONDS> ] [ I<UNIX LOCAL EXPR> ] [ I<UNIX PEER EXPR> ]
B<UNIX ACCESS EXPR> = ( I<UNIX ACCESS> | I<UNIX ACCESS LIST> )
@@ -297,9 +300,6 @@ B<QUOTED FILEGLOB> = '"' I<UNQUOTED FILEGLOB> '"'
B<UNQUOTED FILEGLOB> = (must start with '/' (after variable expansion), B<AARE> have special meanings; see below. May include I<VARIABLE>. Rules with embedded spaces or tabs must be quoted. Rules must end with '/' to apply to directories.)
B<AARE> = B<?*[]{}^>
See section "Globbing (AARE)" below for meanings.
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' | 'x' )
@@ -1513,10 +1513,9 @@ F</etc/apparmor.d/tunables/alias>, which is included by
F</etc/apparmor.d/tunables/global>. F</etc/apparmor.d/tunables/global> is
typically included at the beginning of an AppArmor profile.
=head2 Globbing (AARE)
=head2 Globbing
File resources and other parameters accepting an AARE
may be specified with a globbing syntax similar to that
File resources may be specified with a globbing syntax similar to that
used by popular shells, such as csh(1), bash(1), zsh(1).
=over 4
@@ -1549,12 +1548,6 @@ will substitute for any single character not matching a, b or c
will expand to one rule to match ab, one rule to match cd
Can also include variables.
=item B<@{variable}>
will expand to all values assigned to the given variable.
=back
When AppArmor looks up a directory the pathname being looked up will

View File

@@ -98,62 +98,6 @@ cannot call the following system calls:
iopl(2) ptrace(2) reboot(2) setdomainname(2)
sethostname(2) swapoff(2) swapon(2) sysctl(2)
=head2 Complain mode
Instead of denying access to resources the profile does not have a rule for
AppArmor can "allow" the access and log a message for the operation
that triggers it. This is called I<complain mode>. It is important to
note that rules that are present in the profile are still applied, so
allow rules will still quiet or force audit messages, and deny rules
will still result in denials and quieting of denial messages (see
I<Turn off deny audit quieting> if this is a problem).
Complain mode can be used to develop profiles incrementally as an
application is exercised. The logged accesses can be added to the
profile and then can the application further excercised to discover further
additions that are needed. Because AppArmor allows the accesses the
application will behave as it would if AppArmor was not confining it.
B<Warning> complain mode does not provide any security, only
auditing, while it is enabled. It should not be used in a hostile
environment or bad behaviors may be logged and added to the profile
as if they are resource accesses that should be used by the
application.
B<Note> complain mode can be very noisy with new or empty profiles,
but with developed profiles might not log anything if the profile
covers the application behavior well. See I<Audit Rate Limiting> if
complain mode is generating too many log messages.
To set a profile and any children or hat profiles the profile may contain
into complain mode use
aa-complain /etc/apparmor.d/<the-application>
To manually set a specific profile in complain mode, add the
C<complain> flag, and then manually reload the profile:
profile foo flags=(complain) { ... }
Note that the C<complain> flag must also be added manually to any
hats or children profiles of the profile or they will continue to
use the previous mode.
To enable complain mode globally, run:
echo -n complain > /sys/module/apparmor/parameters/mode
or to set it on boot add:
apparmor.mode=complain
as a kernel boot paramenter.
B<Warning> Setting complain mode gloabally disables all apparmor
security protections. It can be useful during debugging or profile
development, but setting it selectively on a per profile basis is
safer.
=head1 ERRORS
When a confined process tries to access a file it does not have permission
@@ -214,12 +158,6 @@ To enable debug mode, run:
echo 1 > /sys/module/apparmor/parameters/debug
or to set it on boot add:
apparmor.debug=1
as a kernel boot paramenter.
=head2 Turn off deny audit quieting
By default, operations that trigger C<deny> rules are not logged.
@@ -229,12 +167,6 @@ To turn off deny audit quieting, run:
echo -n noquiet >/sys/module/apparmor/parameters/audit
or to set it on boot add:
apparmor.audit=noquiet
as a kernel boot paramenter.
=head2 Force audit mode
AppArmor can log a message for every operation that triggers a rule
@@ -251,14 +183,6 @@ To enable force audit mode globally, run:
echo -n all > /sys/module/apparmor/parameters/audit
or to set it on boot add:
apparmor.audit=all
as a kernel boot paramenter.
B<Audit Rate Limiting>
If auditd is not running, to avoid losing too many of the extra log
messages, you will likely have to turn off rate limiting by doing:

View File

@@ -396,23 +396,6 @@ This option tells the parser to not attempt to rebuild the cache on
failure, instead the parser continues on with processing the remaining
profiles.
=item --estimated-compile-size
Adjust the internal parameter used to estimate how agressive the parser
can be when compiling policy. This may include changes to how or when
caches are dropped or how many compile units (jobs) are launched. The
value should slightly larger than the largest Resident Set Size (RSS)
encountered for the type of policy being compiled.
A value that is too small may result in the parser exhausting system
resources when compiling large policy. A value too large may slow
policy compiles down.
The value specified may include a suffix of I<KB>, I<MB>, I<GB>, to
make it easier to adjust the size.
Note: config-file and command line options will override values chosen
by tuning affected by the option.
=item --config-file
Specify the config file to use instead of

View File

@@ -38,10 +38,6 @@
#define CAP_MAC_OVERRIDE 32
#endif
#ifndef CAP_AUDIT_READ
#define CAP_AUDIT_READ 37
#endif
#ifndef CAP_PERFMON
#define CAP_PERFMON 38
#endif

View File

@@ -183,7 +183,7 @@ int strn_escseq(const char **pos, const char *chrs, size_t n)
if (strchr(chrs, c))
return c;
/* unsupported escape sequence, backup to return that char */
/* unsupported escap sequence, backup to return that char */
pos--;
return -1;
}

View File

@@ -8,7 +8,7 @@ chfa.{h,cc} - code to build a highly compressed runtime readonly version
of an hfa.
aare_rules.{h,cc} - code to that binds parse -> expr-tree -> hfa generation
-> chfa generation into a basic interface for converting
rules to a runtime ready state machine.
rules to a runtime ready statemachine.
Regular Expression Scanner Generator
====================================
@@ -19,12 +19,12 @@ Notes in the scanner File Format
The file format used is based on the GNU flex table file format
(--tables-file option; see Table File Format in the flex info pages and
the flex sources for documentation). The magic number used in the header
is set to 0x1B5E783D instead of 0xF13C57B1 though, which is meant to
is set to 0x1B5E783D insted of 0xF13C57B1 though, which is meant to
indicate that the file format logically is not the same: the YY_ID_CHK
(check) and YY_ID_DEF (default) tables are used differently.
Flex uses state compression to store only the differences between states
for states that are similar. The amount of compression influences the parse
for states that are similar. The amount of compresion influences the parse
speed.
The following two states could be stored as in the tables outlined

View File

@@ -61,12 +61,12 @@ void aare_rules::add_to_rules(Node *tree, Node *perms)
expr_map[perms] = tree;
}
static Node *cat_with_null_separator(Node *l, Node *r)
static Node *cat_with_null_seperator(Node *l, Node *r)
{
return new CatNode(new CatNode(l, new CharNode(0)), r);
}
static Node *cat_with_oob_separator(Node *l, Node *r)
static Node *cat_with_oob_seperator(Node *l, Node *r)
{
return new CatNode(new CatNode(l, new CharNode(transchar(-1, true))), r);
}
@@ -85,9 +85,9 @@ bool aare_rules::add_rule_vec(int deny, uint32_t perms, uint32_t audit,
if (regex_parse(&subtree, rulev[i]))
goto err;
if (oob)
tree = cat_with_oob_separator(tree, subtree);
tree = cat_with_oob_seperator(tree, subtree);
else
tree = cat_with_null_separator(tree, subtree);
tree = cat_with_null_seperator(tree, subtree);
}
/*
@@ -97,11 +97,11 @@ bool aare_rules::add_rule_vec(int deny, uint32_t perms, uint32_t audit,
*/
exact_match = 1;
for (depth_first_traversal i(tree); i && exact_match; i++) {
if ((*i)->is_type(NODE_TYPE_STAR) ||
(*i)->is_type(NODE_TYPE_PLUS) ||
(*i)->is_type(NODE_TYPE_ANYCHAR) ||
(*i)->is_type(NODE_TYPE_CHARSET) ||
(*i)->is_type(NODE_TYPE_NOTCHARSET))
if (dynamic_cast<StarNode *>(*i) ||
dynamic_cast<PlusNode *>(*i) ||
dynamic_cast<AnyCharNode *>(*i) ||
dynamic_cast<CharSetNode *>(*i) ||
dynamic_cast<NotCharSetNode *>(*i))
exact_match = 0;
}
@@ -111,15 +111,15 @@ bool aare_rules::add_rule_vec(int deny, uint32_t perms, uint32_t audit,
accept = unique_perms.insert(deny, perms, audit, exact_match);
if (flags & DFA_DUMP_RULE_EXPR) {
const char *separator;
const char *seperator;
if (oob)
separator = "\\-x01";
seperator = "\\-x01";
else
separator = "\\x00";
seperator = "\\x00";
cerr << "rule: ";
cerr << rulev[0];
for (int i = 1; i < count; i++) {
cerr << separator;
cerr << seperator;
cerr << rulev[i];
}
cerr << " -> ";

View File

@@ -23,7 +23,7 @@
* it can be factored so that the set of important nodes is smaller.
* Having a reduced set of important nodes generally results in a dfa that
* is closer to minimum (fewer redundant states are created). It also
* results in fewer important nodes in the state set during subset
* results in fewer important nodes in a the state set during subset
* construction resulting in less memory used to create a dfa.
*
* Generally it is worth doing expression tree simplification before dfa
@@ -150,7 +150,7 @@ void Node::dump_syntax_tree(ostream &os)
}
/*
* Normalize the regex parse tree for factoring and cancellations. Normalization
* Normalize the regex parse tree for factoring and cancelations. Normalization
* reorganizes internal (alt and cat) nodes into a fixed "normalized" form that
* simplifies factoring code, in that it produces a canonicalized form for
* the direction being normalized so that the factoring code does not have
@@ -172,10 +172,10 @@ void Node::dump_syntax_tree(ostream &os)
* dir to !dir. Until no dir direction node meets the criterial.
* Then recurse to the children (which will have a different node type)
* to make sure they are normalized.
* Normalization of a child node is guaranteed to not affect the
* Normalization of a child node is guarenteed to not affect the
* normalization of the parent.
*
* For cat nodes the depth first traverse order is guaranteed to be
* For cat nodes the depth first traverse order is guarenteed to be
* maintained. This is not necessary for altnodes.
*
* Eg. For left normalization
@@ -210,7 +210,7 @@ int TwoChildNode::normalize_eps(int dir)
// Test for E | (E | E) and E . (E . E) which will
// result in an infinite loop
Node *c = child[!dir];
if (c->is_type(NODE_TYPE_TWOCHILD) &&
if (dynamic_cast<TwoChildNode *>(c) &&
&epsnode == c->child[dir] &&
&epsnode == c->child[!dir]) {
c->release();
@@ -229,7 +229,7 @@ void CatNode::normalize(int dir)
for (;;) {
if (normalize_eps(dir)) {
continue;
} else if (child[dir]->is_type(NODE_TYPE_CAT)) {
} else if (dynamic_cast<CatNode *>(child[dir])) {
// (ab)c -> a(bc)
rotate_node(this, dir);
} else {
@@ -248,11 +248,11 @@ void AltNode::normalize(int dir)
for (;;) {
if (normalize_eps(dir)) {
continue;
} else if (child[dir]->is_type(NODE_TYPE_ALT)) {
} else if (dynamic_cast<AltNode *>(child[dir])) {
// (a | b) | c -> a | (b | c)
rotate_node(this, dir);
} else if (child[dir]->is_type(NODE_TYPE_CHARSET) &&
child[!dir]->is_type(NODE_TYPE_CHAR)) {
} else if (dynamic_cast<CharSetNode *>(child[dir]) &&
dynamic_cast<CharNode *>(child[!dir])) {
// [a] | b -> b | [a]
Node *c = child[dir];
child[dir] = child[!dir];
@@ -344,7 +344,7 @@ static Node *alt_to_charsets(Node *t, int dir)
static Node *basic_alt_factor(Node *t, int dir)
{
if (!t->is_type(NODE_TYPE_ALT))
if (!dynamic_cast<AltNode *>(t))
return t;
if (t->child[dir]->eq(t->child[!dir])) {
@@ -355,8 +355,8 @@ static Node *basic_alt_factor(Node *t, int dir)
return tmp;
}
// (ab) | (ac) -> a(b|c)
if (t->child[dir]->is_type(NODE_TYPE_CAT) &&
t->child[!dir]->is_type(NODE_TYPE_CAT) &&
if (dynamic_cast<CatNode *>(t->child[dir]) &&
dynamic_cast<CatNode *>(t->child[!dir]) &&
t->child[dir]->child[dir]->eq(t->child[!dir]->child[dir])) {
// (ab) | (ac) -> a(b|c)
Node *left = t->child[dir];
@@ -369,7 +369,7 @@ static Node *basic_alt_factor(Node *t, int dir)
return left;
}
// a | (ab) -> a (E | b) -> a (b | E)
if (t->child[!dir]->is_type(NODE_TYPE_CAT) &&
if (dynamic_cast<CatNode *>(t->child[!dir]) &&
t->child[dir]->eq(t->child[!dir]->child[dir])) {
Node *c = t->child[!dir];
t->child[dir]->release();
@@ -379,7 +379,7 @@ static Node *basic_alt_factor(Node *t, int dir)
return c;
}
// ab | (a) -> a (b | E)
if (t->child[dir]->is_type(NODE_TYPE_CAT) &&
if (dynamic_cast<CatNode *>(t->child[dir]) &&
t->child[dir]->child[dir]->eq(t->child[!dir])) {
Node *c = t->child[dir];
t->child[!dir]->release();
@@ -394,7 +394,7 @@ static Node *basic_alt_factor(Node *t, int dir)
static Node *basic_simplify(Node *t, int dir)
{
if (t->is_type(NODE_TYPE_CAT) && &epsnode == t->child[!dir]) {
if (dynamic_cast<CatNode *>(t) && &epsnode == t->child[!dir]) {
// aE -> a
Node *tmp = t->child[dir];
t->child[dir] = NULL;
@@ -419,7 +419,7 @@ static Node *basic_simplify(Node *t, int dir)
*/
Node *simplify_tree_base(Node *t, int dir, bool &mod)
{
if (t->is_type(NODE_TYPE_IMPORTANT))
if (dynamic_cast<ImportantNode *>(t))
return t;
for (int i = 0; i < 2; i++) {
@@ -442,15 +442,15 @@ Node *simplify_tree_base(Node *t, int dir, bool &mod)
}
/* all tests after this must meet 2 alt node condition */
if (!t->is_type(NODE_TYPE_ALT) ||
!t->child[!dir]->is_type(NODE_TYPE_ALT))
if (!dynamic_cast<AltNode *>(t) ||
!dynamic_cast<AltNode *>(t->child[!dir]))
break;
// a | (a | b) -> (a | b)
// a | (b | (c | a)) -> (b | (c | a))
Node *p = t;
Node *i = t->child[!dir];
for (; i->is_type(NODE_TYPE_ALT); p = i, i = i->child[!dir]) {
for (; dynamic_cast<AltNode *>(i); p = i, i = i->child[!dir]) {
if (t->child[dir]->eq(i->child[dir])) {
Node *tmp = t->child[!dir];
t->child[!dir] = NULL;
@@ -475,19 +475,19 @@ Node *simplify_tree_base(Node *t, int dir, bool &mod)
int count = 0;
Node *subject = t->child[dir];
Node *a = subject;
if (subject->is_type(NODE_TYPE_CAT))
if (dynamic_cast<CatNode *>(subject))
a = subject->child[dir];
for (pp = p = t, i = t->child[!dir];
i->is_type(NODE_TYPE_ALT);) {
if ((i->child[dir]->is_type(NODE_TYPE_CAT) &&
dynamic_cast<AltNode *>(i);) {
if ((dynamic_cast<CatNode *>(i->child[dir]) &&
a->eq(i->child[dir]->child[dir])) ||
(a->eq(i->child[dir]))) {
// extract matching alt node
p->child[!dir] = i->child[!dir];
i->child[!dir] = subject;
subject = basic_simplify(i, dir);
if (subject->is_type(NODE_TYPE_CAT))
if (dynamic_cast<CatNode *>(subject))
a = subject->child[dir];
else
a = subject;
@@ -502,7 +502,7 @@ Node *simplify_tree_base(Node *t, int dir, bool &mod)
}
// last altnode in chain check other dir as well
if ((i->is_type(NODE_TYPE_CAT) &&
if ((dynamic_cast<CatNode *>(i) &&
a->eq(i->child[dir])) || (a->eq(i))) {
count++;
if (t == p) {
@@ -528,7 +528,7 @@ int debug_tree(Node *t)
{
int nodes = 1;
if (!t->is_type(NODE_TYPE_IMPORTANT)) {
if (!dynamic_cast<ImportantNode *>(t)) {
if (t->child[0])
nodes += debug_tree(t->child[0]);
if (t->child[1])
@@ -539,30 +539,30 @@ int debug_tree(Node *t)
static void count_tree_nodes(Node *t, struct node_counts *counts)
{
if (t->is_type(NODE_TYPE_ALT)) {
if (dynamic_cast<AltNode *>(t)) {
counts->alt++;
count_tree_nodes(t->child[0], counts);
count_tree_nodes(t->child[1], counts);
} else if (t->is_type(NODE_TYPE_CAT)) {
} else if (dynamic_cast<CatNode *>(t)) {
counts->cat++;
count_tree_nodes(t->child[0], counts);
count_tree_nodes(t->child[1], counts);
} else if (t->is_type(NODE_TYPE_PLUS)) {
} else if (dynamic_cast<PlusNode *>(t)) {
counts->plus++;
count_tree_nodes(t->child[0], counts);
} else if (t->is_type(NODE_TYPE_STAR)) {
} else if (dynamic_cast<StarNode *>(t)) {
counts->star++;
count_tree_nodes(t->child[0], counts);
} else if (t->is_type(NODE_TYPE_OPTIONAL)) {
} else if (dynamic_cast<OptionalNode *>(t)) {
counts->optional++;
count_tree_nodes(t->child[0], counts);
} else if (t->is_type(NODE_TYPE_CHAR)) {
} else if (dynamic_cast<CharNode *>(t)) {
counts->charnode++;
} else if (t->is_type(NODE_TYPE_ANYCHAR)) {
} else if (dynamic_cast<AnyCharNode *>(t)) {
counts->any++;
} else if (t->is_type(NODE_TYPE_CHARSET)) {
} else if (dynamic_cast<CharSetNode *>(t)) {
counts->charset++;
} else if (t->is_type(NODE_TYPE_NOTCHARSET)) {
} else if (dynamic_cast<NotCharSetNode *>(t)) {
counts->notcharset++;
}
}
@@ -635,8 +635,7 @@ Node *simplify_tree(Node *t, dfaflags_t flags)
void flip_tree(Node *node)
{
for (depth_first_traversal i(node); i; i++) {
if ((*i)->is_type(NODE_TYPE_CAT)) {
CatNode *cat = static_cast<CatNode *>(*i);
if (CatNode *cat = dynamic_cast<CatNode *>(*i)) {
swap(cat->child[0], cat->child[1]);
}
}

View File

@@ -222,43 +222,16 @@ typedef struct Cases {
ostream &operator<<(ostream &os, Node &node);
#define NODE_TYPE_NODE 0
#define NODE_TYPE_INNER (1 << 0)
#define NODE_TYPE_ONECHILD (1 << 1)
#define NODE_TYPE_TWOCHILD (1 << 2)
#define NODE_TYPE_LEAF (1 << 3)
#define NODE_TYPE_EPS (1 << 4)
#define NODE_TYPE_IMPORTANT (1 << 5)
#define NODE_TYPE_C (1 << 6)
#define NODE_TYPE_CHAR (1 << 7)
#define NODE_TYPE_CHARSET (1 << 8)
#define NODE_TYPE_NOTCHARSET (1 << 9)
#define NODE_TYPE_ANYCHAR (1 << 10)
#define NODE_TYPE_STAR (1 << 11)
#define NODE_TYPE_OPTIONAL (1 << 12)
#define NODE_TYPE_PLUS (1 << 13)
#define NODE_TYPE_CAT (1 << 14)
#define NODE_TYPE_ALT (1 << 15)
#define NODE_TYPE_SHARED (1 << 16)
#define NODE_TYPE_ACCEPT (1 << 17)
#define NODE_TYPE_MATCHFLAG (1 << 18)
#define NODE_TYPE_EXACTMATCHFLAG (1 << 19)
#define NODE_TYPE_DENYMATCHFLAG (1 << 20)
/* An abstract node in the syntax tree. */
class Node {
public:
Node(): nullable(false), type_flags(NODE_TYPE_NODE), label(0)
{
child[0] = child[1] = 0;
}
Node(Node *left): nullable(false), type_flags(NODE_TYPE_NODE), label(0)
Node(): nullable(false), label(0) { child[0] = child[1] = 0; }
Node(Node *left): nullable(false), label(0)
{
child[0] = left;
child[1] = 0;
}
Node(Node *left, Node *right): nullable(false),
type_flags(NODE_TYPE_NODE), label(0)
Node(Node *left, Node *right): nullable(false), label(0)
{
child[0] = left;
child[1] = right;
@@ -329,13 +302,6 @@ public:
NodeSet firstpos, lastpos, followpos;
/* child 0 is left, child 1 is right */
Node *child[2];
/*
* Bitmap that stores supported pointer casts for the Node, composed
* by the NODE_TYPE_* flags. This is used by is_type() as a substitute
* of costly dynamic_cast calls.
*/
unsigned type_flags;
bool is_type(unsigned type) { return type_flags & type; }
unsigned int label; /* unique number for debug etc */
/**
@@ -349,34 +315,25 @@ public:
class InnerNode: public Node {
public:
InnerNode(): Node() { type_flags |= NODE_TYPE_INNER; };
InnerNode(Node *left): Node(left) { type_flags |= NODE_TYPE_INNER; };
InnerNode(Node *left, Node *right): Node(left, right)
{
type_flags |= NODE_TYPE_INNER;
};
InnerNode(): Node() { };
InnerNode(Node *left): Node(left) { };
InnerNode(Node *left, Node *right): Node(left, right) { };
};
class OneChildNode: public InnerNode {
public:
OneChildNode(Node *left): InnerNode(left)
{
type_flags |= NODE_TYPE_ONECHILD;
};
OneChildNode(Node *left): InnerNode(left) { };
};
class TwoChildNode: public InnerNode {
public:
TwoChildNode(Node *left, Node *right): InnerNode(left, right)
{
type_flags |= NODE_TYPE_TWOCHILD;
};
TwoChildNode(Node *left, Node *right): InnerNode(left, right) { };
virtual int normalize_eps(int dir);
};
class LeafNode: public Node {
public:
LeafNode(): Node() { type_flags |= NODE_TYPE_LEAF; };
LeafNode(): Node() { };
virtual void normalize(int dir __attribute__((unused))) { return; }
};
@@ -385,7 +342,6 @@ class EpsNode: public LeafNode {
public:
EpsNode(): LeafNode()
{
type_flags |= NODE_TYPE_EPS;
nullable = true;
label = 0;
}
@@ -400,7 +356,7 @@ public:
void compute_lastpos() { }
int eq(Node *other)
{
if (other->is_type(NODE_TYPE_EPS))
if (dynamic_cast<EpsNode *>(other))
return 1;
return 0;
}
@@ -417,7 +373,7 @@ public:
*/
class ImportantNode: public LeafNode {
public:
ImportantNode(): LeafNode() { type_flags |= NODE_TYPE_IMPORTANT; }
ImportantNode(): LeafNode() { }
void compute_firstpos() { firstpos.insert(this); }
void compute_lastpos() { lastpos.insert(this); }
virtual void follow(Cases &cases) = 0;
@@ -430,7 +386,7 @@ public:
*/
class CNode: public ImportantNode {
public:
CNode(): ImportantNode() { type_flags |= NODE_TYPE_C; }
CNode(): ImportantNode() { }
int is_accept(void) { return false; }
int is_postprocess(void) { return false; }
};
@@ -438,7 +394,7 @@ public:
/* Match one specific character (/c/). */
class CharNode: public CNode {
public:
CharNode(transchar c): c(c) { type_flags |= NODE_TYPE_CHAR; }
CharNode(transchar c): c(c) { }
void follow(Cases &cases)
{
NodeSet **x = &cases.cases[c];
@@ -452,8 +408,8 @@ public:
}
int eq(Node *other)
{
if (other->is_type(NODE_TYPE_CHAR)) {
CharNode *o = static_cast<CharNode *>(other);
CharNode *o = dynamic_cast<CharNode *>(other);
if (o) {
return c == o->c;
}
return 0;
@@ -483,10 +439,7 @@ public:
/* Match a set of characters (/[abc]/). */
class CharSetNode: public CNode {
public:
CharSetNode(Chars &chars): chars(chars)
{
type_flags |= NODE_TYPE_CHARSET;
}
CharSetNode(Chars &chars): chars(chars) { }
void follow(Cases &cases)
{
for (Chars::iterator i = chars.begin(); i != chars.end(); i++) {
@@ -502,11 +455,8 @@ public:
}
int eq(Node *other)
{
if (!other->is_type(NODE_TYPE_CHARSET))
return 0;
CharSetNode *o = static_cast<CharSetNode *>(other);
if (chars.size() != o->chars.size())
CharSetNode *o = dynamic_cast<CharSetNode *>(other);
if (!o || chars.size() != o->chars.size())
return 0;
for (Chars::iterator i = chars.begin(), j = o->chars.begin();
@@ -548,10 +498,7 @@ public:
/* Match all except one character (/[^abc]/). */
class NotCharSetNode: public CNode {
public:
NotCharSetNode(Chars &chars): chars(chars)
{
type_flags |= NODE_TYPE_NOTCHARSET;
}
NotCharSetNode(Chars &chars): chars(chars) { }
void follow(Cases &cases)
{
if (!cases.otherwise)
@@ -575,11 +522,8 @@ public:
}
int eq(Node *other)
{
if (!other->is_type(NODE_TYPE_NOTCHARSET))
return 0;
NotCharSetNode *o = static_cast<NotCharSetNode *>(other);
if (chars.size() != o->chars.size())
NotCharSetNode *o = dynamic_cast<NotCharSetNode *>(other);
if (!o || chars.size() != o->chars.size())
return 0;
for (Chars::iterator i = chars.begin(), j = o->chars.begin();
@@ -621,7 +565,7 @@ public:
/* Match any character (/./). */
class AnyCharNode: public CNode {
public:
AnyCharNode() { type_flags |= NODE_TYPE_ANYCHAR; }
AnyCharNode() { }
void follow(Cases &cases)
{
if (!cases.otherwise)
@@ -635,7 +579,7 @@ public:
}
int eq(Node *other)
{
if (other->is_type(NODE_TYPE_ANYCHAR))
if (dynamic_cast<AnyCharNode *>(other))
return 1;
return 0;
}
@@ -645,11 +589,7 @@ public:
/* Match a node zero or more times. (This is a unary operator.) */
class StarNode: public OneChildNode {
public:
StarNode(Node *left): OneChildNode(left)
{
type_flags |= NODE_TYPE_STAR;
nullable = true;
}
StarNode(Node *left): OneChildNode(left) { nullable = true; }
void compute_firstpos() { firstpos = child[0]->firstpos; }
void compute_lastpos() { lastpos = child[0]->lastpos; }
void compute_followpos()
@@ -661,7 +601,7 @@ public:
}
int eq(Node *other)
{
if (other->is_type(NODE_TYPE_STAR))
if (dynamic_cast<StarNode *>(other))
return child[0]->eq(other->child[0]);
return 0;
}
@@ -678,16 +618,12 @@ public:
/* Match a node zero or one times. */
class OptionalNode: public OneChildNode {
public:
OptionalNode(Node *left): OneChildNode(left)
{
type_flags |= NODE_TYPE_OPTIONAL;
nullable = true;
}
OptionalNode(Node *left): OneChildNode(left) { nullable = true; }
void compute_firstpos() { firstpos = child[0]->firstpos; }
void compute_lastpos() { lastpos = child[0]->lastpos; }
int eq(Node *other)
{
if (other->is_type(NODE_TYPE_OPTIONAL))
if (dynamic_cast<OptionalNode *>(other))
return child[0]->eq(other->child[0]);
return 0;
}
@@ -702,9 +638,7 @@ public:
/* Match a node one or more times. (This is a unary operator.) */
class PlusNode: public OneChildNode {
public:
PlusNode(Node *left): OneChildNode(left)
{
type_flags |= NODE_TYPE_PLUS;
PlusNode(Node *left): OneChildNode(left) {
}
void compute_nullable() { nullable = child[0]->nullable; }
void compute_firstpos() { firstpos = child[0]->firstpos; }
@@ -717,7 +651,7 @@ public:
}
}
int eq(Node *other) {
if (other->is_type(NODE_TYPE_PLUS))
if (dynamic_cast<PlusNode *>(other))
return child[0]->eq(other->child[0]);
return 0;
}
@@ -733,10 +667,7 @@ public:
/* Match a pair of consecutive nodes. */
class CatNode: public TwoChildNode {
public:
CatNode(Node *left, Node *right): TwoChildNode(left, right)
{
type_flags |= NODE_TYPE_CAT;
}
CatNode(Node *left, Node *right): TwoChildNode(left, right) { }
void compute_nullable()
{
nullable = child[0]->nullable && child[1]->nullable;
@@ -764,7 +695,7 @@ public:
}
int eq(Node *other)
{
if (other->is_type(NODE_TYPE_CAT)) {
if (dynamic_cast<CatNode *>(other)) {
if (!child[0]->eq(other->child[0]))
return 0;
return child[1]->eq(other->child[1]);
@@ -799,10 +730,7 @@ public:
/* Match one of two alternative nodes. */
class AltNode: public TwoChildNode {
public:
AltNode(Node *left, Node *right): TwoChildNode(left, right)
{
type_flags |= NODE_TYPE_ALT;
}
AltNode(Node *left, Node *right): TwoChildNode(left, right) { }
void compute_nullable()
{
nullable = child[0]->nullable || child[1]->nullable;
@@ -817,7 +745,7 @@ public:
}
int eq(Node *other)
{
if (other->is_type(NODE_TYPE_ALT)) {
if (dynamic_cast<AltNode *>(other)) {
if (!child[0]->eq(other->child[0]))
return 0;
return child[1]->eq(other->child[1]);
@@ -852,10 +780,7 @@ public:
class SharedNode: public ImportantNode {
public:
SharedNode()
{
type_flags |= NODE_TYPE_SHARED;
}
SharedNode() { }
void release(void)
{
/* don't delete SharedNodes via release as they are shared, and
@@ -878,17 +803,14 @@ public:
*/
class AcceptNode: public SharedNode {
public:
AcceptNode() { type_flags |= NODE_TYPE_ACCEPT; }
AcceptNode() { }
int is_accept(void) { return true; }
int is_postprocess(void) { return false; }
};
class MatchFlag: public AcceptNode {
public:
MatchFlag(uint32_t flag, uint32_t audit): flag(flag), audit(audit)
{
type_flags |= NODE_TYPE_MATCHFLAG;
}
MatchFlag(uint32_t flag, uint32_t audit): flag(flag), audit(audit) { }
ostream &dump(ostream &os) { return os << "< 0x" << hex << flag << '>'; }
uint32_t flag;
@@ -897,18 +819,12 @@ public:
class ExactMatchFlag: public MatchFlag {
public:
ExactMatchFlag(uint32_t flag, uint32_t audit): MatchFlag(flag, audit)
{
type_flags |= NODE_TYPE_EXACTMATCHFLAG;
}
ExactMatchFlag(uint32_t flag, uint32_t audit): MatchFlag(flag, audit) {}
};
class DenyMatchFlag: public MatchFlag {
public:
DenyMatchFlag(uint32_t flag, uint32_t quiet): MatchFlag(flag, quiet)
{
type_flags |= NODE_TYPE_DENYMATCHFLAG;
}
DenyMatchFlag(uint32_t flag, uint32_t quiet): MatchFlag(flag, quiet) {}
};
/* Traverse the syntax tree depth-first in an iterator-like manner. */
@@ -917,7 +833,7 @@ class depth_first_traversal {
void push_left(Node *node) {
pos.push(node);
while (node->is_type(NODE_TYPE_INNER)) {
while (dynamic_cast<InnerNode *>(node)) {
pos.push(node->child[0]);
node = node->child[0];
}

View File

@@ -651,13 +651,13 @@ void DFA::minimize(dfaflags_t flags)
list<Partition *> partitions;
/* Set up the initial partitions
* minimum of - 1 non accepting, and 1 accepting
* minimium of - 1 non accepting, and 1 accepting
* if trans hashing is used the accepting and non-accepting partitions
* can be further split based on the number and type of transitions
* a state makes.
* If permission hashing is enabled the accepting partitions can
* be further divided by permissions. This can result in not
* obtaining a truly minimized dfa but comes close, and can speedup
* obtaining a truely minimized dfa but comes close, and can speedup
* minimization.
*/
int accept_count = 0;
@@ -753,7 +753,7 @@ void DFA::minimize(dfaflags_t flags)
/* Remap the dfa so it uses the representative states
* Use the first state of a partition as the representative state
* At this point all states with in a partition have transitions
* At this point all states with in a partion have transitions
* to states within the same partitions, however this can slow
* down compressed dfa compression as there are more states,
*/
@@ -813,7 +813,7 @@ void DFA::minimize(dfaflags_t flags)
}
/* Now that the states have been remapped, remove all states
* that are not the representative states for their partition, they
* that are not the representive states for their partition, they
* will have a label == -1
*/
for (Partition::iterator i = states.begin(); i != states.end();) {
@@ -875,7 +875,7 @@ static int diff_partition(State *state, Partition &part, int max_range, int uppe
/**
* diff_encode - compress dfa by differentially encoding state transitions
* @dfa_flags: flags controlling dfa creation
* @dfa_flags: flags controling dfa creation
*
* This function reduces the number of transitions that need to be stored
* by encoding transitions as the difference between the state and a
@@ -889,7 +889,7 @@ static int diff_partition(State *state, Partition &part, int max_range, int uppe
* - The number of state transitions needed to match an input of length
* m will be 2m
*
* To guarantee this the ordering and distance calculation is done in the
* To guarentee this the ordering and distance calculation is done in the
* following manner.
* - A DAG of the DFA is created starting with the start state(s).
* - A state can only be relative (have a differential encoding) to
@@ -1352,18 +1352,17 @@ int accept_perms(NodeSet *state, perms_t &perms, bool filedfa)
return error;
for (NodeSet::iterator i = state->begin(); i != state->end(); i++) {
if (!(*i)->is_type(NODE_TYPE_MATCHFLAG))
MatchFlag *match;
if (!(match = dynamic_cast<MatchFlag *>(*i)))
continue;
MatchFlag *match = static_cast<MatchFlag *>(*i);
if (match->is_type(NODE_TYPE_EXACTMATCHFLAG)) {
if (dynamic_cast<ExactMatchFlag *>(match)) {
/* exact match only ever happens with x */
if (filedfa && !is_merged_x_consistent(exact_match_allow,
match->flag))
error = 1;;
exact_match_allow |= match->flag;
exact_audit |= match->audit;
} else if (match->is_type(NODE_TYPE_DENYMATCHFLAG)) {
} else if (dynamic_cast<DenyMatchFlag *>(match)) {
perms.deny |= match->flag;
perms.quiet |= match->audit;
} else {

View File

@@ -189,7 +189,7 @@ struct DiffDag {
* accept: the accept permissions for the state
* trans: set of transitions from this state
* otherwise: the default state for transitions not in @trans
* partition: Is a temporary work variable used during dfa minimization.
* parition: Is a temporary work variable used during dfa minimization.
* it can be replaced with a map, but that is slower and uses more
* memory.
* proto: Is a temporary work variable used during dfa creation. It can

View File

@@ -76,7 +76,7 @@ static inline Chars* insert_char_range(Chars* cset, transchar a, transchar b)
%%
/* FIXME: Does not parse "[--]", "[---]", "[^^-x]". I don't actually know
which precise grammar Perl regexs use, and rediscovering that
which precise grammer Perl regexs use, and rediscovering that
is proving to be painful. */
regex : /* empty */ { *root = $$ = &epsnode; }

View File

@@ -206,7 +206,7 @@
* AppArmor mount rule encoding
*
* TODO:
* add semantic checking of options against specified filesystem types
* add semantic checking of options against specified filesytem types
* to catch mount options that can't be covered.
*
*
@@ -457,7 +457,7 @@ ostream &mnt_rule::dump(ostream &os)
else if (allow & AA_MAY_PIVOTROOT)
os << "pivotroot";
else
os << "error: unknown mount perm";
os << "error: unknonwn mount perm";
os << " (0x" << hex << flags << " - 0x" << inv_flags << ") ";
if (dev_type) {

View File

@@ -1,7 +1,7 @@
# parser.conf is a global AppArmor config file for the apparmor_parser
#
# It can be used to specify the default options for the parser, which
# can then be overridden by options passed on the command line.
# can then be overriden by options passed on the command line.
#
# Leading whitespace is ignored and lines that begin with # are treated
# as comments.
@@ -43,7 +43,7 @@
#skip-read-cache
#### Set Optimizations. Multiple Optimizations can be set, one per line ####
#### Set Optimizaions. Multiple Optimizations can be set, one per line ####
# For supported optimizations see
# apparmor_parser --help=O

View File

@@ -376,6 +376,7 @@ extern int skip_mode_force;
extern int abort_on_error;
extern int skip_bad_cache_rebuild;
extern int mru_skip_cache;
extern int debug_cache;
/* provided by parser_lex.l (cannot be used in tst builds) */
extern FILE *yyin;

View File

@@ -23,7 +23,7 @@
We support 2 types of includes
#include <name> which searches for the first occurrence of name in the
#include <name> which searches for the first occurance of name in the
apparmor directory path.
#include "name" which will search for a relative or absolute pathed
@@ -60,7 +60,7 @@
static char *path[MAX_PATH] = { NULL };
static int npath = 0;
/* default base directory is /etc/apparmor.d, it can be overridden
/* default base directory is /etc/apparmor.d, it can be overriden
with the -b option. */
const char *basedir;

View File

@@ -359,7 +359,7 @@ void sd_serialize_xtable(std::ostringstream &buf, char **table)
int len = strlen(table[i]) + 1;
/* if its a namespace make sure the second : is overwritten
* with 0, so that the namespace and name are \0 separated
* with 0, so that the namespace and name are \0 seperated
*/
if (*table[i] == ':') {
char *tmp = table[i] + 1;

View File

@@ -85,13 +85,10 @@ int mru_skip_cache = 1;
/* for jobs_max and jobs
* LONG_MAX : no limit
* LONG_MIN : auto = detect system processing cores
* -n : multiply by the number of CPUs to compile policy
* n : use that number of processes/threads to compile policy
*/
#define JOBS_AUTO LONG_MIN
#define DEFAULT_JOBS_MAX -8
#define DEFAULT_ESTIMATED_JOB_SIZE (50 * 1024 * 1024)
long estimated_job_size = DEFAULT_ESTIMATED_JOB_SIZE;
long jobs_max = DEFAULT_JOBS_MAX; /* 8 * cpus */
long jobs_max = -8; /* 8 * cpus */
long jobs = JOBS_AUTO; /* default: number of processor cores */
long njobs = 0;
long jobs_scale = 0; /* number of chance to resample online
@@ -133,7 +130,6 @@ static const char *config_file = "/etc/apparmor/parser.conf";
#define ARG_OVERRIDE_POLICY_ABI 141
#define EARLY_ARG_CONFIG_FILE 142
#define ARG_WERROR 143
#define ARG_ESTIMATED_COMPILE_SIZE 144
/* Make sure to update BOTH the short and long_options */
static const char *short_options = "ad::f:h::rRVvI:b:BCD:NSm:M:qQn:XKTWkL:O:po:j:";
@@ -188,7 +184,6 @@ struct option long_options[] = {
{"print-config-file", 0, 0, ARG_PRINT_CONFIG_FILE}, /* no short option */
{"override-policy-abi", 1, 0, ARG_OVERRIDE_POLICY_ABI}, /* no short option */
{"config-file", 1, 0, EARLY_ARG_CONFIG_FILE}, /* early option, no short option */
{"estimated-compile-size", 1, 0, ARG_ESTIMATED_COMPILE_SIZE}, /* no short option, not in help */
{NULL, 0, 0, 0},
};
@@ -419,19 +414,6 @@ static long process_jobs_arg(const char *arg, const char *val) {
return n;
}
static long str_to_size(const char *s)
{
if (*s == '\0')
return 1;
else if (strcmp(s, "KB") == 0)
return 1024;
else if (strcmp(s, "MB") == 0)
return 1024*1024;
else if (strcmp(s, "GB") == 0)
return 1024*1024*1024;
return -1;
}
#define EARLY_ARG 1
#define LATE_ARG 2
#define TWOPASS_ARG (EARLY_ARG | LATE_ARG)
@@ -452,7 +434,7 @@ int arg_pass(int c) {
return LATE_ARG;
}
/* process a single argument from getopt_long
/* process a single argment from getopt_long
* Returns: 1 if an action arg, else 0
*/
#define DUMP_HEADER " variables \tDump variables\n" \
@@ -769,21 +751,6 @@ static int process_arg(int c, char *optarg)
case ARG_PRINT_CONFIG_FILE:
printf("%s\n", config_file);
break;
case ARG_ESTIMATED_COMPILE_SIZE:
/* used to auto tune parser on low resource systems */
{
char *end;
long mult;
long long tmp = strtoll(optarg, &end, 0);
if (end == optarg ||
(errno == ERANGE && (tmp == LLONG_MIN || tmp == LLONG_MAX)) ||
(mult = str_to_size(end)) == -1) {
PERROR("%s: --estimated-compile-size invalid size '%s'", progname, optarg);
exit(1);
}
estimated_job_size = tmp * mult;
}
break;
default:
/* 'unrecognized option' error message gets printed by getopt_long() */
exit(1);
@@ -1296,7 +1263,7 @@ do { \
* from work_spawn and work_sync. We could throw a C++ exception, is it
* worth doing it to avoid the exit here.
*
* atm not all resources may be cleaned up at exit
* atm not all resources maybe cleanedup at exit
*/
int last_error = 0;
void handle_work_result(int retval)
@@ -1324,120 +1291,35 @@ static long compute_jobs(long n, long j)
return j;
}
static void setup_parallel_compile(long ncpus, long maxcpus)
static void setup_parallel_compile(void)
{
/* jobs and parallel_max set by default, config or args */
/* jobs and paralell_max set by default, config or args */
long n = sysconf(_SC_NPROCESSORS_ONLN);
long maxn = sysconf(_SC_NPROCESSORS_CONF);
if (n == -1)
/* unable to determine number of processors, default to 1 */
n = 1;
if (maxn == -1)
/* unable to determine number of processors, default to 1 */
maxn = 1;
if (jobs < 0 || jobs == JOBS_AUTO)
jobs_scale = 1;
jobs = compute_jobs(ncpus, jobs);
jobs_max = compute_jobs(maxcpus, jobs_max);
jobs = compute_jobs(n, jobs);
jobs_max = compute_jobs(maxn, jobs_max);
if (jobs > jobs_max) {
pwarn(WARN_JOBS, "%s: Capping number of jobs to %ld * # of cpus == '%ld'",
pwarn(WARN_JOBS, "%s: Warning capping number of jobs to %ld * # of cpus == '%ld'",
progname, jobs_max, jobs);
jobs = jobs_max;
} else if (jobs_scale && jobs < jobs_max)
/* the bigger the difference the more sample chances given */
jobs_scale = jobs_max + 1 - ncpus;
jobs_scale = jobs_max + 1 - n;
njobs = 0;
if (debug_jobs)
fprintf(stderr, "jobs: %ld\n", jobs);
}
/*
* Tune parameters to adjust the parser to adapt to low memory, low power
* systems.
* with a profile compile taking up to 10s of MB, launching a lot of
* parallel compiles is a bad idea on lauch 16 parallel compiles with
* only 50 MB free.
*
*/
#define PREFIX_TOTAL "MemTotal:"
#define PREFIX_FREE "MemFree:"
#define PREFIX_CACHE "Cached:"
static bool get_memstat(long long &mem_total, long long &mem_free,
long long &mem_cache)
{
char *line, buf[256];
autofclose FILE *f = NULL;
mem_total = mem_free = mem_cache = -1;
/* parse /proc/meminfo to get a rough idea of available mem,
look into libstatgrab as alternative */
f = fopen("/proc/meminfo", "r");
if (f == NULL) {
PDEBUG("Failed to open /proc/meminfo");
return false;
}
while ((line = fgets(buf, sizeof(buf), f)) != NULL) {
long long value;
if (sscanf(buf, "%*s %lld kB", &value) != 1)
continue;
if (strncmp(buf, PREFIX_FREE, strlen(PREFIX_FREE)) == 0)
mem_free = value * 1024;
else if (strncmp(buf, PREFIX_TOTAL, strlen(PREFIX_TOTAL)) == 0)
mem_total = value * 1024;
else if (strncmp(buf, PREFIX_CACHE, strlen(PREFIX_CACHE)) == 0)
mem_cache = value * 1024;
}
if (mem_free == -1 || mem_total == -1 || mem_cache == -1) {
PDEBUG("Failed to parse mem value");
return false;
}
mem_free += mem_cache;
return true;
}
static void auto_tune_parameters(void)
{
long long mem_total, mem_free, mem_cache;
long ncpus = sysconf(_SC_NPROCESSORS_ONLN);
long maxcpus = sysconf(_SC_NPROCESSORS_CONF);
if (ncpus == -1) {
PDEBUG("Unable to determine number of processors, default to 1");
ncpus = 1;
}
if (maxcpus == -1) {
PDEBUG("Unable to determine number of processors, default to 1");
maxcpus = 1;
}
/* only override if config or param hasn't overridden */
if (get_memstat(mem_total, mem_free, mem_cache) == true &&
jobs == JOBS_AUTO) {
long estimated_jobs = (long) (mem_free / estimated_job_size);
if (mem_free < 2) {
/* -j0 - no workers */
jobs = jobs_max = 0;
PDEBUG("Auto tune: --jobs=0");
} else if (estimated_jobs < ncpus) {
/* --jobs=estimate_jobs */
jobs = estimated_jobs;
PDEBUG("Auto tune: --jobs=%ld", estimated_jobs);
} else {
long long n = estimated_jobs / ncpus;
if (n < -DEFAULT_JOBS_MAX) {
/* --jobs=cpus*n */
jobs = -n;
PDEBUG("Auto tune: --jobs=%ld", jobs);
}
}
} else {
PDEBUG("Unable to get meminfo, using defaults");
}
setup_parallel_compile(ncpus, maxcpus);
}
struct dir_cb_data {
aa_kernel_interface *kernel_interface;
const char *dirname; /* name of the parent dir */
@@ -1545,7 +1427,7 @@ int main(int argc, char *argv[])
process_config_file(config_file);
optind = process_args(argc, argv);
auto_tune_parameters();
setup_parallel_compile();
setlocale(LC_MESSAGES, "");
bindtextdomain(PACKAGE, LOCALEDIR);

View File

@@ -541,7 +541,7 @@ static int process_profile_name_xmatch(Profile *prof)
int len;
tbuf.clear();
/* prepend \x00 to every value. This is
* done to separate the existence of the
* done to separate the existance of the
* xattr from a null value match.
*
* if an xattr exists, a single \x00 will

View File

@@ -847,13 +847,13 @@ int main(void)
MY_TEST(retval == 0, "get boolean variable 2");
retval = get_boolean_var("non_existant");
MY_TEST(retval < 0, "get nonexistent boolean variable");
MY_TEST(retval < 0, "get nonexistant boolean variable");
retval = get_boolean_var("stereopuff");
MY_TEST(retval < 0, "get boolean variable that's declared a set var");
retptr = get_set_var("daves_not_here_man");
MY_TEST(retptr == NULL, "get nonexistent set variable");
MY_TEST(retptr == NULL, "get non-existent set variable");
retptr = get_set_var("abuse");
MY_TEST(retptr == NULL, "get set variable that's declared a boolean");

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: apparmor@lists.ubuntu.com\n"
"POT-Creation-Date: 2020-10-14 03:51-0700\n"
"POT-Creation-Date: 2020-10-14 04:04-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@@ -179,7 +179,7 @@ void install_cache(const char *cachetmpname, const char *cachename)
}
if (rename(cachetmpname, cachename) < 0) {
pwarn(WARN_CACHE, "Failed to write cache: %s\n", cachename);
pwarn(WARN_CACHE, "Warning failed to write cache: %s\n", cachename);
unlink(cachetmpname);
}
else if (show_cache) {

View File

@@ -36,6 +36,7 @@ extern int cond_clear_cache; /* only applies if write is set */
extern int force_clear_cache; /* force clearing regargless of state */
extern int create_cache_dir; /* create the cache dir if missing? */
extern int mru_skip_cache;
extern int debug_cache;
void set_cache_tstamp(struct timespec t);
void update_mru_tstamp(FILE *file, const char *path);

View File

@@ -24,11 +24,7 @@
. /lib/apparmor/rc.apparmor.functions
# do not load in a container
if [ -x /usr/bin/systemd-detect-virt ] && \
systemd-detect-virt --quiet --container && \
! is_container_with_internal_policy; then
exit 0
fi
[ -x /usr/bin/systemd-detect-virt ] && systemd-detect-virt --quiet --container && ! is_container_with_internal_policy && exit 0 || true
[ -d /rofs/etc/apparmor.d ] && exit 0 # do not load if running liveCD
@@ -46,7 +42,7 @@ aafs=/sys/kernel/security/apparmor
params=$module/parameters
[ -r $params/enabled ] || exit 0 # do not load if missing
read -r enabled < $params/enabled || exit 1 # if this fails, something went wrong
read enabled < $params/enabled || exit 1 # if this fails, something went wrong
[ "$enabled" = "Y" ] || exit 0 # do not load if disabled
/sbin/apparmor_parser -r -W "$profile" || exit 0 # LP: #1058356

117
parser/rc.apparmor.debian Normal file
View File

@@ -0,0 +1,117 @@
#!/bin/sh
# ----------------------------------------------------------------------
# Copyright (c) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
# NOVELL (All rights reserved)
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, contact Novell, Inc.
# ----------------------------------------------------------------------
# rc.apparmor by Steve Beattie
#
# /etc/init.d/apparmor
#
# chkconfig: 2345 01 99
# description: AppArmor rc file. This rc script inserts the apparmor \
# module and runs the parser on the /etc/apparmor.d/ \
# directory.
#
### BEGIN INIT INFO
# Provides: apparmor
# Required-Start:
# Required-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: AppArmor initialization
# Description: AppArmor rc file. This rc script inserts the apparmor
# module and runs the parser on the /etc/apparmor.d/
# directory.
### END INIT INFO
APPARMOR_FUNCTIONS=/lib/apparmor/rc.apparmor.functions
aa_action() {
STRING=$1
shift
$*
rc=$?
if [ $rc -eq 0 ] ; then
aa_log_success_msg $"$STRING "
else
aa_log_failure_msg $"$STRING "
fi
return $rc
}
aa_log_success_msg() {
[ -n "$1" ] && echo -n $1
echo ": done."
}
aa_log_warning_msg() {
[ -n "$1" ] && echo -n $1
echo ": Warning."
}
aa_log_failure_msg() {
[ -n "$1" ] && echo -n $1
echo ": Failed."
}
aa_log_skipped_msg() {
[ -n "$1" ] && echo -n $1
echo ": Skipped."
}
usage() {
echo "Usage: $0 {start|stop|restart|try-restart|reload|force-reload|status|kill}"
}
# source apparmor function library
if [ -f "${APPARMOR_FUNCTIONS}" ]; then
. ${APPARMOR_FUNCTIONS}
else
aa_log_failure_msg "Unable to find AppArmor initscript functions"
exit 1
fi
test -x ${PARSER} || exit 0 # by debian policy
case "$1" in
start)
apparmor_start
rc=$?
;;
stop)
apparmor_stop
rc=$?
;;
restart|reload|force-reload)
apparmor_restart
rc=$?
;;
try-restart)
apparmor_try_restart
rc=$?
;;
kill)
apparmor_kill
rc=$?
;;
status)
apparmor_status
rc=$?
;;
*)
usage
exit 1
;;
esac
exit $rc

View File

@@ -68,7 +68,7 @@ is_apparmor_present() {
# something like `systemd-detect-virt --container`.
#
# The only known container environments capable of supporting internal policy
# are LXD and LXC environments, and Windows Subsystem for Linux.
# are LXD and LXC environment.
#
# Returns 0 if the container environment is capable of having its own internal
# policy and non-zero otherwise.
@@ -90,12 +90,6 @@ is_container_with_internal_policy() {
local ns_stacked
local ns_name
# WSL needs to be detected explicitly
if [ -x /usr/bin/systemd-detect-virt ] && \
[ "$(systemd-detect-virt --container)" = "wsl" ]; then
return 0
fi
if ! [ -f "$ns_stacked_path" ] || ! [ -f "$ns_name_path" ]; then
return 1
fi
@@ -117,6 +111,37 @@ is_container_with_internal_policy() {
return 0
}
# This set of patterns to skip needs to be kept in sync with
# AppArmor.pm::isSkippableFile()
# returns 0 if profile should NOT be skipped
# returns 1 on verbose skip
# returns 2 on silent skip
skip_profile() {
local profile="$1"
if [ "${profile%.rpmnew}" != "$profile" ] || \
[ "${profile%.rpmsave}" != "$profile" ] || \
[ "${profile%.orig}" != "$profile" ] || \
[ "${profile%.rej}" != "$profile" ] || \
[ "${profile%\~}" != "$profile" ] ; then
return 1
fi
# Silently ignore the dpkg, pacman, and xbps files
if [ "${profile%.dpkg-new}" != "$profile" ] || \
[ "${profile%.dpkg-old}" != "$profile" ] || \
[ "${profile%.dpkg-dist}" != "$profile" ] || \
[ "${profile%.dpkg-bak}" != "$profile" ] || \
[ "${profile%.dpkg-remove}" != "$profile" ] || \
[ "${profile%.pacsave}" != "$profile" ] || \
[ "${profile%.pacnew}" != "$profile" ] ; then
return 2
fi
if echo "$profile" | grep -E -q '^.+\.new-[0-9\.]+_[0-9]+$'; then
return 2
fi
return 0
}
__parse_profiles_dir() {
local parser_cmd="$1"
local profile_dir="$2"
@@ -132,11 +157,41 @@ __parse_profiles_dir() {
return 1
fi
# shellcheck disable=SC2086
if ! "$PARSER" $PARSER_OPTS "$parser_cmd" -- "$profile_dir"; then
status=1
aa_log_failure_msg "At least one profile failed to load"
fi
# Note: the parser automatically skips files that match skip_profile()
# when we pass it a directory, but not when we pass it an individual
# profile. So we need to use skip_profile only in the latter case,
# as long as the parser is in sync' with skip_profile().
"$PARSER" $PARSER_OPTS "$parser_cmd" -- "$profile_dir" || {
# FIXME: once the parser properly handles broken profiles
# (LP: #1377338), remove the following code and the
# skip_profile() function. For now, if the parser returns
# an error, just run it again separately on each profile.
for profile in "$profile_dir"/*; do
skip_profile "$profile"
skip=$?
if [ "$skip" -eq 2 ]; then
# Ignore skip status == 2 (silent skip)
continue
elif [ "$skip" -ne 0 ] ; then
aa_log_skipped_msg "$profile"
logger -t "AppArmor(init)" -p daemon.warn \
"Skipping profile $profile"
continue
fi
if [ ! -f "$profile" ] ; then
continue
fi
printf "%s\0" "$profile"
done | \
# Use xargs to parallelize calls to the parser over all CPUs
xargs -n1 -0r -P "$(getconf _NPROCESSORS_ONLN)" \
"$PARSER" $PARSER_OPTS "$parser_cmd" --
if [ $? -ne 0 ]; then
status=1
aa_log_failure_msg "At least one profile failed to load"
fi
}
return "$status"
}
@@ -160,6 +215,7 @@ parse_profiles() {
# run the parser on all of the apparmor profiles
if [ ! -f "$PARSER" ]; then
aa_log_failure_msg "AppArmor parser not found"
aa_log_action_end 1
exit 1
fi
@@ -171,6 +227,41 @@ parse_profiles() {
return "$STATUS"
}
profiles_names_list() {
# run the parser on all of the apparmor profiles
if [ ! -f "$PARSER" ]; then
aa_log_failure_msg "- AppArmor parser not found"
exit 1
fi
for profile_dir in $PROFILE_DIRS; do
if [ ! -d "$profile_dir" ]; then
aa_log_warning_msg "- Profile directory not found: $profile_dir"
continue
fi
for profile in "$profile_dir"/*; do
if skip_profile "$profile" && [ -f "$profile" ] ; then
LIST_ADD=$("$PARSER" -N "$profile" )
if [ $? -eq 0 ]; then
echo "$LIST_ADD"
fi
fi
done
done
}
failstop_system() {
level=$(runlevel | cut -d" " -f2)
if [ "$level" -ne "1" ] ; then
aa_log_failure_msg "- could not start AppArmor. Changing to runlevel 1"
telinit 1;
return 255;
fi
aa_log_failure_msg "- could not start AppArmor."
return 255
}
is_apparmor_loaded() {
if ! is_securityfs_mounted ; then
mount_securityfs
@@ -218,7 +309,7 @@ apparmor_start() {
fi
# if there is anything in the profiles file don't load
if ! read -r _ < "$SFS_MOUNTPOINT/profiles"; then
if ! read -r line < "$SFS_MOUNTPOINT/profiles"; then
parse_profiles load
else
aa_log_skipped_msg ": already loaded with profiles."
@@ -266,7 +357,7 @@ remove_profiles() {
}
apparmor_stop() {
aa_log_daemon_msg "Unloading AppArmor profiles"
aa_log_daemon_msg "Unloading AppArmor profiles "
remove_profiles
rc=$?
aa_log_end_msg "$rc"

125
parser/rc.apparmor.redhat Normal file
View File

@@ -0,0 +1,125 @@
#!/bin/sh
# ----------------------------------------------------------------------
# Copyright (c) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
# NOVELL (All rights reserved)
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, contact Novell, Inc.
# ----------------------------------------------------------------------
# rc.apparmor by Steve Beattie
#
# /etc/init.d/apparmor
#
# chkconfig: 2345 01 99
# description: AppArmor rc file. This rc script inserts the apparmor \
# module and runs the parser on the /etc/apparmor.d/ \
# directory.
#
### BEGIN INIT INFO
# Provides: apparmor
# Required-Start:
# Required-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: AppArmor initialization
# Description: AppArmor rc file. This rc script inserts the apparmor
# module and runs the parser on the /etc/apparmor.d/
# directory.
### END INIT INFO
APPARMOR_FUNCTIONS=/lib/apparmor/rc.apparmor.functions
# source function library
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
elif [ -f /lib/lsb/init-functions ]; then
. /lib/lsb/init-functions
else
exit 0
fi
usage() {
echo "Usage: $0 {start|stop|restart|try-restart|reload|force-reload|status|kill}"
}
aa_log_success_msg() {
echo -n "$*"
success
echo
}
aa_log_warning_msg() {
echo -n "$*"
warning
echo
}
aa_log_skipped_msg() {
echo -n "$*"
warning
echo
}
aa_log_failure_msg() {
echo -n "$*"
failure
echo
}
aa_action() {
STRING=$1
shift
action "${STRING} " "$@"
return $?
}
# source apparmor function library
if [ -f "${APPARMOR_FUNCTIONS}" ]; then
. ${APPARMOR_FUNCTIONS}
else
aa_log_failure_msg "Unable to find AppArmor initscript functions"
exit 1
fi
case "$1" in
start)
apparmor_start
rc=$?
;;
stop)
apparmor_stop
rc=$?
;;
restart|reload|force-reload)
apparmor_restart
rc=$?
;;
try-restart)
apparmor_try_restart
rc=$?
;;
kill)
apparmor_kill
rc=$?
;;
status)
apparmor_status
rc=$?
;;
*)
usage
exit 1
;;
esac
exit $rc

View File

@@ -112,7 +112,7 @@ static const char *const sig_names[MAXMAPPED_SIG + 1] = {
"lost",
"unused",
"exists", /* always last existence test mapped to MAXMAPPED_SIG */
"exists", /* always last existance test mapped to MAXMAPPED_SIG */
};

View File

@@ -240,7 +240,7 @@ and may grant confined processes specific mount operations.
The security model of the various versions of NFS is that files are
looked up by name as usual, but after that lookup, each file is only
identified by a file handle in successive accesses. The file handle at a
identified by a file handle in successive acesses. The file handle at a
minimum includes some sort of filesystem identifier and the file's inode
number. In Linux, the file handles used by most filesystems also
include the inode number of the parent directory; this may change in the
@@ -816,7 +816,7 @@ one (this option may be used even if no profile by that name exists):
\subsection{Anatomy of a Profile}
AppArmor profiles use a simple declarative language, fully described in
AppArmor profiles use a simple declaritive language, fully described in
the apparmor.d(5) manual page. By convention, profiles are stored in
/etc/{\H}apparmor.d/. The AppArmor parser supports a simple cpp-style
include mechanism to allow sharing pieces of policy. A simple profile

View File

@@ -23,13 +23,13 @@ tests: error_output caching minimize equality dirtest parser_sanity
GEN_TRANS_DIRS=simple_tests/generated_x/ simple_tests/generated_perms_leading/ simple_tests/generated_perms_safe/ simple_tests/generated_dbus
gen_xtrans: $(GEN_TRANS_DIRS)
./gen-xtrans.py
./gen-xtrans.pl
$(GEN_TRANS_DIRS):
mkdir $@
gen_dbus: $(GEN_TRANS_DIRS)
./gen-dbus.py
./gen-dbus.pl
error_output: $(PARSER)
LANG=C ./errors.py -p "$(PARSER)" $(PYTEST_ARG)

View File

@@ -10,7 +10,7 @@ against a different parser, or use a different set of profiles for the
simple.pl test, you can change those settings in 'uservars.conf'.
You can also override which parser is used through make by specifying
the PARSER variable. For example, to run the tests on the system parser,
the PARSER veriable. For example, to run the tests on the system parser,
run 'make PARSER=/sbin/apparmor_parser'.
Adding to the testsuite
@@ -61,7 +61,7 @@ The simple script looks for a few special comments in the profile,
expected parse result of PASS.
- #=TODO -- marks the test as being for a future item to implement and
thus are expected testsuite failures and should be ignored.
thus are expected testsuite failures and hsould be ignored.
- #=DISABLED -- skips the test, and marks it as a failed TODO task.
Useful if the particular testcase causes the parser to infinite

View File

@@ -73,13 +73,13 @@ class AAParserCachingCommon(testlib.AATestTemplate):
self.cmd_prefix = [config.parser, '--config-file=./parser.conf', '--base', self.tmp_dir, '--skip-kernel-load']
if not self.is_apparmorfs_mounted():
self.cmd_prefix.extend(('-M', './features_files/features.all'))
self.cmd_prefix += ['-M', './features_files/features.all']
# Otherwise get_cache_dir() will try to create /var/cache/apparmor
# and will fail when the test suite is run as non-root.
self.cmd_prefix.extend((
self.cmd_prefix += [
'--cache-loc', os.path.join(self.tmp_dir, 'cache')
))
]
# create directory for cached blobs
# NOTE: get_cache_dir() requires cmd_prefix to be fully initialized
@@ -98,8 +98,7 @@ class AAParserCachingCommon(testlib.AATestTemplate):
shutil.rmtree(self.tmp_dir)
def get_cache_dir(self, create=False):
cmd = [config.parser, '--print-cache-dir']
cmd.extend(self.cmd_prefix)
cmd = [config.parser, '--print-cache-dir'] + self.cmd_prefix
rc, report = self.run_cmd(cmd)
if rc != 0:
if "unrecognized option '--print-cache-dir'" not in report:
@@ -154,7 +153,7 @@ class AAParserBasicCachingTests(AAParserCachingCommon):
'''test profiles are not cached by default'''
cmd = list(self.cmd_prefix)
cmd.extend(('-q', '-r', self.profile))
cmd.extend(['-q', '-r', self.profile])
self.run_cmd_check(cmd)
self.assert_path_exists(os.path.join(self.cache_dir, PROFILE), expected=False)
@@ -162,7 +161,7 @@ class AAParserBasicCachingTests(AAParserCachingCommon):
'''test profiles are not cached with --skip-cache'''
cmd = list(self.cmd_prefix)
cmd.extend(('-q', '--write-cache', '--skip-cache', '-r', self.profile))
cmd.extend(['-q', '--write-cache', '--skip-cache', '-r', self.profile])
self.run_cmd_check(cmd)
self.assert_path_exists(os.path.join(self.cache_dir, PROFILE), expected=False)
@@ -170,7 +169,7 @@ class AAParserBasicCachingTests(AAParserCachingCommon):
'''test profiles are cached when requested'''
cmd = list(self.cmd_prefix)
cmd.extend(('-q', '--write-cache', '-r', self.profile))
cmd.extend(['-q', '--write-cache', '-r', self.profile])
self.run_cmd_check(cmd)
self.assert_path_exists(os.path.join(self.cache_dir, PROFILE))
@@ -178,7 +177,7 @@ class AAParserBasicCachingTests(AAParserCachingCommon):
'''test features file is written when caching'''
cmd = list(self.cmd_prefix)
cmd.extend(('-q', '--write-cache', '-r', self.profile))
cmd.extend(['-q', '--write-cache', '-r', self.profile])
self.run_cmd_check(cmd)
self.assert_path_exists(os.path.join(self.cache_dir, PROFILE))
self.assert_path_exists(os.path.join(self.cache_dir, '.features'))
@@ -189,7 +188,7 @@ class AAParserBasicCachingTests(AAParserCachingCommon):
self.require_apparmorfs()
cmd = list(self.cmd_prefix)
cmd.extend(('-q', '--write-cache', '-r', self.profile))
cmd.extend(['-q', '--write-cache', '-r', self.profile])
self.run_cmd_check(cmd)
self.assert_path_exists(os.path.join(self.cache_dir, PROFILE))
self.assert_path_exists(os.path.join(self.cache_dir, '.features'))
@@ -207,7 +206,7 @@ class AAParserAltCacheBasicTests(AAParserBasicCachingTests):
os.chmod(alt_cache_loc, 0o755)
self.unused_cache_loc = self.cache_dir
self.cmd_prefix.extend(('--cache-loc', alt_cache_loc))
self.cmd_prefix.extend(['--cache-loc', alt_cache_loc])
self.cache_dir = self.get_cache_dir()
def tearDown(self):
@@ -254,7 +253,7 @@ class AAParserCachingTests(AAParserCachingCommon):
def _generate_cache_file(self):
cmd = list(self.cmd_prefix)
cmd.extend(('-q', '--write-cache', '-r', self.profile))
cmd.extend(['-q', '--write-cache', '-r', self.profile])
self.run_cmd_check(cmd)
self.assert_path_exists(self.cache_file)
@@ -283,7 +282,7 @@ class AAParserCachingTests(AAParserCachingCommon):
self._generate_cache_file()
cmd = list(self.cmd_prefix)
cmd.extend(('-v', '-r', self.profile))
cmd.extend(['-v', '-r', self.profile])
self.run_cmd_check(cmd, expected_string='Cached reload succeeded')
def test_cache_not_loaded_when_skip_arg(self):
@@ -292,7 +291,7 @@ class AAParserCachingTests(AAParserCachingCommon):
self._generate_cache_file()
cmd = list(self.cmd_prefix)
cmd.extend(('-v', '--skip-cache', '-r', self.profile))
cmd.extend(['-v', '--skip-cache', '-r', self.profile])
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
def test_cache_not_loaded_when_skip_read_arg(self):
@@ -301,7 +300,7 @@ class AAParserCachingTests(AAParserCachingCommon):
self._generate_cache_file()
cmd = list(self.cmd_prefix)
cmd.extend(('-v', '--skip-read-cache', '-r', self.profile))
cmd.extend(['-v', '--skip-read-cache', '-r', self.profile])
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
def test_cache_not_loaded_when_features_differ(self):
@@ -312,7 +311,7 @@ class AAParserCachingTests(AAParserCachingCommon):
testlib.write_file(self.cache_dir, '.features', 'monkey\n')
cmd = list(self.cmd_prefix)
cmd.extend(('-v', '-r', self.profile))
cmd.extend(['-v', '-r', self.profile])
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
def test_cache_writing_does_not_overwrite_features_when_features_differ(self):
@@ -323,7 +322,7 @@ class AAParserCachingTests(AAParserCachingCommon):
features_file = testlib.write_file(self.cache_dir, '.features', 'monkey\n')
cmd = list(self.cmd_prefix)
cmd.extend(('-v', '--write-cache', '--skip-bad-cache', '-r', self.profile))
cmd.extend(['-v', '--write-cache', '--skip-bad-cache', '-r', self.profile])
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
self.assert_path_exists(features_file)
# ensure that the features does *not* match the current features set
@@ -335,7 +334,7 @@ class AAParserCachingTests(AAParserCachingCommon):
testlib.write_file(self.cache_dir, '.features', 'monkey\n')
cmd = list(self.cmd_prefix)
cmd.extend(('-v', '--write-cache', '--skip-bad-cache', '-r', self.profile))
cmd.extend(['-v', '--write-cache', '--skip-bad-cache', '-r', self.profile])
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
self.assert_path_exists(self.cache_file, expected=False)
@@ -350,7 +349,7 @@ class AAParserCachingTests(AAParserCachingCommon):
new_features_file = new_file + '/.features';
cmd = list(self.cmd_prefix)
cmd.extend(('-v', '--write-cache', '-r', self.profile))
cmd.extend(['-v', '--write-cache', '-r', self.profile])
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
self.assert_path_exists(features_file)
self.assert_path_exists(new_features_file)
@@ -363,7 +362,7 @@ class AAParserCachingTests(AAParserCachingCommon):
orig_stat = os.stat(cache_file)
cmd = list(self.cmd_prefix)
cmd.extend(('-v', '--write-cache', '-r', self.profile))
cmd.extend(['-v', '--write-cache', '-r', self.profile])
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
self.assert_path_exists(cache_file)
stat = os.stat(cache_file)
@@ -379,7 +378,7 @@ class AAParserCachingTests(AAParserCachingCommon):
check_file = testlib.write_file(self.cache_dir, 'monkey', 'monkey\n')
cmd = list(self.cmd_prefix)
cmd.extend(('-v', '--write-cache', '-r', self.profile))
cmd.extend(['-v', '--write-cache', '-r', self.profile])
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
self.assert_path_exists(check_file, expected=False)
@@ -417,7 +416,7 @@ class AAParserCachingTests(AAParserCachingCommon):
orig_stat = os.stat(self.cache_file)
cmd = list(self.cmd_prefix)
cmd.extend(('-v', '-r', self.profile))
cmd.extend(['-v', '-r', self.profile])
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
stat = os.stat(self.cache_file)
@@ -435,7 +434,7 @@ class AAParserCachingTests(AAParserCachingCommon):
orig_stat = os.stat(self.cache_file)
cmd = list(self.cmd_prefix)
cmd.extend(('-v', '-r', self.profile))
cmd.extend(['-v', '-r', self.profile])
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
stat = os.stat(self.cache_file)
@@ -453,7 +452,7 @@ class AAParserCachingTests(AAParserCachingCommon):
orig_stat = os.stat(self.cache_file)
cmd = list(self.cmd_prefix)
cmd.extend(('-v', '-r', '-W', self.profile))
cmd.extend(['-v', '-r', '-W', self.profile])
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
stat = os.stat(self.cache_file)
@@ -470,7 +469,7 @@ class AAParserCachingTests(AAParserCachingCommon):
orig_stat = os.stat(self.cache_file)
cmd = list(self.cmd_prefix)
cmd.extend(('-v', '-r', '-W', self.profile))
cmd.extend(['-v', '-r', '-W', self.profile])
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
stat = os.stat(self.cache_file)
@@ -490,7 +489,7 @@ class AAParserCachingTests(AAParserCachingCommon):
cmd = list(self.cmd_prefix)
cmd[0] = new_parser
cmd.extend(('-v', '-r', self.profile))
cmd.extend(['-v', '-r', self.profile])
self.run_cmd_check(cmd, expected_string='Cached reload succeeded for')
def _purge_cache_test(self, location):
@@ -498,7 +497,7 @@ class AAParserCachingTests(AAParserCachingCommon):
cache_file = testlib.write_file(self.cache_dir, location, 'monkey\n')
cmd = list(self.cmd_prefix)
cmd.extend(('-v', '--purge-cache', '-r', self.profile))
cmd.extend(['-v', '--purge-cache', '-r', self.profile])
self.run_cmd_check(cmd)
# no message is output
self.assert_path_exists(cache_file, expected=False)
@@ -527,7 +526,7 @@ class AAParserAltCacheTests(AAParserCachingTests):
os.chmod(alt_cache_loc, 0o755)
self.orig_cache_dir = self.cache_dir
self.cmd_prefix.extend(('--cache-loc', alt_cache_loc))
self.cmd_prefix.extend(['--cache-loc', alt_cache_loc])
self.cache_dir = self.get_cache_dir(create=True)
self.cache_file = os.path.join(self.cache_dir, PROFILE)
@@ -541,7 +540,7 @@ class AAParserAltCacheTests(AAParserCachingTests):
# skip tearDown check to ensure non-alt cache is empty
self.check_orig_cache = False
filelist = (PROFILE, '.features', 'monkey')
filelist = [PROFILE, '.features', 'monkey']
for f in filelist:
testlib.write_file(self.orig_cache_dir, f, 'monkey\n')

View File

@@ -31,8 +31,9 @@ do_tst() {
shift 2
#global tmpdir
${APPARMOR_PARSER} "$@" > "$tmpdir/out" 2>/dev/null
${APPARMOR_PARSER} "$@" > "$tmpdir/out.unsorted" 2>/dev/null
rc=$?
LC_ALL=C sort "$tmpdir/out.unsorted" > "$tmpdir/out"
if [ $rc -ne 0 ] && [ "$expected" != "fail" ] ; then
echo "failed: expected \"$expected\" but parser returned error"
return 1

View File

@@ -1,3 +1,3 @@
good_target
a_profile
b_profile
good_target

View File

@@ -568,7 +568,7 @@ verify_binary_equality "set rlimit memlock <= 2GB" \
# Unfortunately we can not just compare an empty profile and hat to a
# ie. "/t { ^test { /f r, }}"
# to the second profile with the equivalent rule inserted manually
# because policy write permission "w" actually expands to multiple permissions
# because policy write permission "w" actually expands to mutiple permissions
# under the hood, and the parser is not adding those permissions
# to the rules it auto generates
# So we insert the rule with "append" permissions, and rely on the parser

View File

@@ -26,7 +26,7 @@ class AAErrorTests(testlib.AATestTemplate):
self.maxDiff = None
self.cmd_prefix = [config.parser, '--config-file=./parser.conf', '-S', '-I', 'errors']
def _run_test(self, profile, message='', is_error=True):
def _run_test(self, profile, message=None, is_error=True):
cmd = self.cmd_prefix + [profile]
(rc, out, outerr) = self._run_cmd(cmd, stdout=subprocess.DEVNULL)
@@ -36,14 +36,8 @@ class AAErrorTests(testlib.AATestTemplate):
else:
self.assertEqual(rc, 0, report)
ignore_messages = (
'Cache read/write disabled: interface file missing. (Kernel needs AppArmor 2.4 compatibility patch.)\n',
)
for ign in ignore_messages:
if ign in outerr:
outerr = outerr.replace(ign, '')
self.assertEqual(message, outerr, report)
if message:
self.assertIn(message, outerr, report)
def test_okay(self):
self._run_test('errors/okay.sd', is_error=False)
@@ -51,40 +45,40 @@ class AAErrorTests(testlib.AATestTemplate):
def test_single(self):
self._run_test(
'errors/single.sd',
"AppArmor parser error for errors/single.sd in profile errors/single.sd at line 3: Could not open 'failure'\n",
"AppArmor parser error for errors/single.sd in profile errors/single.sd at line 3: Could not open 'failure'",
)
def test_double(self):
self._run_test(
'errors/double.sd',
"AppArmor parser error for errors/double.sd in profile errors/includes/busted at line 66: Could not open 'does-not-exist'\n",
"AppArmor parser error for errors/double.sd in profile errors/includes/busted at line 66: Could not open 'does-not-exist'",
)
def test_modefail(self):
self._run_test(
'errors/modefail.sd',
"AppArmor parser error for errors/modefail.sd in profile errors/modefail.sd at line 6: syntax error, unexpected TOK_ID, expecting TOK_MODE\n",
"AppArmor parser error for errors/modefail.sd in profile errors/modefail.sd at line 6: syntax error, unexpected TOK_ID, expecting TOK_MODE",
)
def test_multi_include(self):
self._run_test(
'errors/multi_include.sd',
"AppArmor parser error for errors/multi_include.sd in profile errors/multi_include.sd at line 12: Could not open 'failure'\n",
"AppArmor parser error for errors/multi_include.sd in profile errors/multi_include.sd at line 12: Could not open 'failure'",
)
def test_deprecation1(self):
self.cmd_prefix.append('--warn=deprecated')
self.cmd_prefix.extend(['--warn=deprecated'])
self._run_test(
'errors/deprecation1.sd',
"Warning from errors/deprecation1.sd (errors/deprecation1.sd line 6): The use of file paths as profile names is deprecated. See man apparmor.d for more information\n",
"Warning from errors/deprecation1.sd (errors/deprecation1.sd line 6): The use of file paths as profile names is deprecated. See man apparmor.d for more information",
is_error=False
)
def test_deprecation2(self):
self.cmd_prefix.append('--warn=deprecated')
self.cmd_prefix.extend(['--warn=deprecated'])
self._run_test(
'errors/deprecation2.sd',
"Warning from errors/deprecation2.sd (errors/deprecation2.sd line 6): The use of file paths as profile names is deprecated. See man apparmor.d for more information\n",
"Warning from errors/deprecation2.sd (errors/deprecation2.sd line 6): The use of file paths as profile names is deprecated. See man apparmor.d for more information",
is_error=False
)

167
parser/tst/gen-dbus.pl Executable file
View File

@@ -0,0 +1,167 @@
#!/usr/bin/perl
#
# Copyright (c) 2013
# Canonical, Ltd. (All rights reserved)
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, contact Canonical Ltd.
#
use strict;
use Locale::gettext;
use POSIX;
setlocale(LC_MESSAGES, "");
my $count=0;
my $prefix="simple_tests/generated_dbus";
my @quantifier = ("", "deny", "audit");
my @session = ("", "bus=session", "bus=system", "bus=accessibility");
my @path = ("", "path=/foo/bar", "path=\"/foo/bar\"");
my @interface = ("", "interface=com.baz", "interface=\"com.baz\"");
my @member = ("", "member=bar", "member=\"bar\"");
my @name = ("", "name=com.foo", "name=\"com.foo\"");
my @peer = map { "peer=($_)" } (@name, "label=/usr/bin/app",
"label=\"/usr/bin/app\"",
"name=com.foo label=/usr/bin/app",
"name=\"com.foo\" label=\"/usr/bin/app\"");
# @msg_perms are the permissions that are related to sending and receiving
# messages. @svc_perms are the permissions related to services.
my @base_msg_perms = ("r", "w", "rw", "read", "receive", "write", "send");
my @msg_perms = ("", @base_msg_perms, (map { "($_)" } @base_msg_perms),
"(write, read)", "(send receive)", "(send read)",
"(receive write)");
gen_files("message-rules", "PASS", \@quantifier, \@msg_perms, \@session,
[""], \@path, \@interface, \@member, \@peer);
gen_files("service-rules", "PASS", \@quantifier, ["bind"], \@session,
\@name, [""], [""], [""], [""]);
gen_files("eavesdrop-rules", "PASS", \@quantifier, ["eavesdrop"], \@session,
[""], [""], [""], [""], [""]);
gen_file("sloppy-formatting", "PASS", "", "(send , receive )", "bus=session",
"", "path =\"/foo/bar\"", "interface = com.foo", " member=bar",
"peer =( label= /usr/bin/app name =\"com.foo\")");
gen_file("sloppy-formatting", "PASS", "", "bind", "bus =session",
"name= com.foo", "", "", "", "");
gen_file("sloppy-formatting", "PASS", "", "eavesdrop", "bus = system",
"", "", "", "", "");
# Don't use the first element, which is empty, from each array since all empty
# conditionals would PASS but we want all FAILs
shift @msg_perms;
shift @name;
shift @path;
shift @interface;
shift @member;
shift @peer;
gen_files("message-incompat", "FAIL", \@quantifier, \@msg_perms, \@session,
\@name, [""], [""], [""], [""]);
gen_files("service-incompat", "FAIL", \@quantifier, ["bind"], \@session,
\@name, \@path, [""], [""], [""]);
gen_files("service-incompat", "FAIL", \@quantifier, ["bind"], \@session,
\@name, [""], \@interface, [""], [""]);
gen_files("service-incompat", "FAIL", \@quantifier, ["bind"], \@session,
\@name, [""], [""], \@member, [""]);
gen_files("service-incompat", "FAIL", \@quantifier, ["bind"], \@session,
\@name, [""], [""], [""], \@peer);
gen_files("eavesdrop-incompat", "FAIL", \@quantifier, ["eavesdrop"], \@session,
\@name, \@path, \@interface, \@member, \@peer);
gen_files("pairing-unsupported", "FAIL", \@quantifier, ["send", "bind"],
\@session, ["name=sn", "label=sl"], [""], [""], [""],
["peer=(name=pn)", "peer=(label=pl)"]);
# missing bus= prefix
gen_file("bad-formatting", "FAIL", "", "send", "session", "", "", "", "", "");
# incorrectly formatted permissions
gen_files("bad-perms", "FAIL", [""], ["send receive", "(send", "send)"],
["bus=session"], [""], [""], [""], [""], [""]);
# invalid permissions
gen_files("bad-perms", "FAIL", [""],
["a", "x", "Ux", "ix", "m", "k", "l", "(a)", "(x)"], [""], [""],
[""], [""], [""], [""]);
gen_file("duplicated-conditionals", "FAIL", "", "bus=1 bus=2");
gen_file("duplicated-conditionals", "FAIL", "", "name=1 name=2");
gen_file("duplicated-conditionals", "FAIL", "", "path=1 path=2");
gen_file("duplicated-conditionals", "FAIL", "", "interface=1 interface=2");
gen_file("duplicated-conditionals", "FAIL", "", "member=1 member=2");
gen_file("duplicated-conditionals", "FAIL", "", "peer=(name=1) peer=(name=2)");
gen_file("duplicated-conditionals", "FAIL", "", "peer=(label=1) peer=(label=2)");
gen_file("duplicated-conditionals", "FAIL", "", "peer=(name=1) peer=(label=2)");
print "Generated $count dbus tests\n";
sub print_rule($$$$$$$$$) {
my ($file, $quantifier, $perms, $session, $name, $path, $interface, $member, $peer) = @_;
print $file " ";
print $file " ${quantifier}" if ${quantifier};
print $file " dbus";
print $file " ${perms}" if ${perms};
print $file " ${session}" if ${session};
print $file " ${name}" if ${name};
print $file " ${path}" if ${path};
print $file " ${interface}" if ${interface};
print $file " ${member}" if ${member};
print $file " ${peer}" if ${peer};
print $file ",\n";
}
sub gen_file($$$$$$$$$$) {
my ($test, $xres, $quantifier, $perms, $session, $name, $path, $interface, $member, $peer) = @_;
my $file;
unless (open $file, ">${prefix}/$test-$count.sd") {
print("couldn't open $test\n");
exit 1;
}
print $file "#\n";
print $file "#=DESCRIPTION ${test}\n";
print $file "#=EXRESULT ${xres}\n";
print $file "#\n";
print $file "/usr/bin/foo {\n";
print_rule($file, $quantifier, $perms, $session, $name, $path, $interface,
$member, $peer);
print $file "}\n";
close($file);
$count++;
}
sub gen_files($$$$$$$$$$) {
my ($test, $xres, $quantifiers, $perms, $sessions, $names, $paths, $interfaces, $members, $peers) = @_;
foreach my $quantifier (@{$quantifiers}) {
foreach my $perm (@{$perms}) {
foreach my $session (@{$sessions}) {
foreach my $name (@{$names}) {
foreach my $path (@{$paths}) {
foreach my $interface (@{$interfaces}) {
foreach my $member (@{$members}) {
foreach my $peer (@{$peers}) {
gen_file($test, $xres, $quantifier, $perm, $session, $name,
$path, $interface, $member, $peer);
}
}
}
}
}
}
}
}
}

View File

@@ -1,157 +0,0 @@
#!/usr/bin/python3
#
# Copyright (c) 2013 Canonical, Ltd. (All rights reserved)
# Copyright (c) 2021 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
# License published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, contact Canonical Ltd.
#
from testlib import write_file
def get_rule (quantifier, perms, session, name, path, interface, member, peer):
result = ' '
for part in (quantifier, 'dbus', perms, session, name, path, interface, member, peer):
if part:
result += ' %s' % part
result += ',\n'
return result
def gen_file(test, xres, quantifier, perms, session, name, path, interface, member, peer):
global count
content = ''
content += '#\n'
content += '#=DESCRIPTION %s\n' % test
content += '#=EXRESULT %s\n' % xres
content += '#\n'
content += '/usr/bin/foo {\n'
content += get_rule(quantifier, perms, session, name, path, interface, member, peer)
content += '}\n'
write_file('simple_tests/generated_dbus', '%s-%s.sd' % (test, count), content)
count += 1
def gen_files (test, xres, quantifiers, perms, sessions, names, paths, interfaces, members, peers):
for quantifier in quantifiers:
for perm in perms:
for session in sessions:
for name in names:
for path in paths:
for interface in interfaces:
for member in members:
for peer in peers:
gen_file(test, xres, quantifier, perm, session, name, path, interface, member, peer)
count=0
quantifier = ('', 'deny', 'audit')
session = ('', 'bus=session', 'bus=system', 'bus=accessibility')
path = ['', 'path=/foo/bar', 'path="/foo/bar"']
interface = ['', 'interface=com.baz', 'interface="com.baz"']
member = ['', 'member=bar', 'member="bar"']
name = ['', 'name=com.foo', 'name="com.foo"']
peer = [
'peer=()',
'peer=(name=com.foo)',
'peer=(name="com.foo")',
'peer=(label=/usr/bin/app)',
'peer=(label="/usr/bin/app")',
'peer=(name=com.foo label=/usr/bin/app)',
'peer=(name="com.foo" label="/usr/bin/app")',
]
# msg_perms are the permissions that are related to sending and receiving
# messages.
msg_perms = [
'',
'r',
'w',
'rw',
'read',
'receive',
'write',
'send',
'(r)',
'(w)',
'(rw)',
'(read)',
'(receive)',
'(write)',
'(send)',
'(write, read)',
'(send receive)',
'(send read)',
'(receive write)',
]
empty_tup = ('',)
gen_files('message-rules', 'PASS', quantifier, msg_perms, session,
empty_tup, path, interface, member, peer)
gen_files('service-rules', 'PASS', quantifier, ['bind'], session,
name, empty_tup, empty_tup, empty_tup, empty_tup)
gen_files('eavesdrop-rules', 'PASS', quantifier, ['eavesdrop'], session,
empty_tup, empty_tup, empty_tup, empty_tup, empty_tup)
gen_file('sloppy-formatting', 'PASS', '', '(send , receive )', 'bus=session',
'', 'path ="/foo/bar"', 'interface = com.foo', ' member=bar',
'peer =( label= /usr/bin/app name ="com.foo")')
gen_file('sloppy-formatting', 'PASS', '', 'bind', 'bus =session',
'name= com.foo', '', '', '', '')
gen_file('sloppy-formatting', 'PASS', '', 'eavesdrop', 'bus = system',
'', '', '', '', '')
# Don't use the empty element from each array since all empty conditionals would PASS but we want all FAILs
msg_perms.remove('')
name.remove('')
path.remove('')
interface.remove('')
member.remove('')
peer.remove('peer=()')
gen_files('message-incompat', 'FAIL', quantifier, msg_perms, session, name, empty_tup, empty_tup, empty_tup, empty_tup)
gen_files('service-incompat', 'FAIL', quantifier, ('bind',), session, name, path, empty_tup, empty_tup, empty_tup)
gen_files('service-incompat', 'FAIL', quantifier, ('bind',), session, name, empty_tup, interface, empty_tup, empty_tup)
gen_files('service-incompat', 'FAIL', quantifier, ('bind',), session, name, empty_tup, empty_tup, member, empty_tup)
gen_files('service-incompat', 'FAIL', quantifier, ('bind',), session, name, empty_tup, empty_tup, empty_tup, peer)
gen_files('eavesdrop-incompat', 'FAIL', quantifier, ('eavesdrop',), session, name, path, interface, member, peer)
gen_files('pairing-unsupported', 'FAIL', quantifier, ('send', 'bind'),
session, ('name=sn', 'label=sl'), empty_tup, empty_tup, empty_tup,
('peer=(name=pn)', 'peer=(label=pl)'))
# missing bus= prefix
gen_file('bad-formatting', 'FAIL', '', 'send', 'session', '', '', '', '', '')
# incorrectly formatted permissions
gen_files('bad-perms', 'FAIL', empty_tup, ('send receive', '(send', 'send)'),
('bus=session',), empty_tup, empty_tup, empty_tup, empty_tup, empty_tup)
# invalid permissions
gen_files('bad-perms', 'FAIL', empty_tup,
('a', 'x', 'Ux', 'ix', 'm', 'k', 'l', '(a)', '(x)'), empty_tup, empty_tup,
empty_tup, empty_tup, empty_tup, empty_tup)
gen_file('duplicated-conditionals', 'FAIL', '', 'bus=1 bus=2', '', '', '', '', '', '')
gen_file('duplicated-conditionals', 'FAIL', '', 'name=1 name=2', '', '', '', '', '', '')
gen_file('duplicated-conditionals', 'FAIL', '', 'path=1 path=2', '', '', '', '', '', '')
gen_file('duplicated-conditionals', 'FAIL', '', 'interface=1 interface=2', '', '', '', '', '', '')
gen_file('duplicated-conditionals', 'FAIL', '', 'member=1 member=2', '', '', '', '', '', '')
gen_file('duplicated-conditionals', 'FAIL', '', 'peer=(name=1) peer=(name=2)', '', '', '', '', '', '')
gen_file('duplicated-conditionals', 'FAIL', '', 'peer=(label=1) peer=(label=2)', '', '', '', '', '', '')
gen_file('duplicated-conditionals', 'FAIL', '', 'peer=(name=1) peer=(label=2)', '', '', '', '', '', '')
print('Generated %s dbus tests' % count)

235
parser/tst/gen-xtrans.pl Executable file
View File

@@ -0,0 +1,235 @@
#!/usr/bin/perl
use strict;
use Locale::gettext;
use POSIX;
setlocale(LC_MESSAGES, "");
my $prefix="simple_tests/generated_x";
my $prefix_leading="simple_tests/generated_perms_leading";
my $prefix_safe="simple_tests/generated_perms_safe";
my @trans_types = ("p", "P", "c", "C", "u", "i");
my @modifiers = ("i", "u");
my %trans_modifiers = (
"p" => \@modifiers,
"P" => \@modifiers,
"c" => \@modifiers,
"C" => \@modifiers,
);
my @targets = ("", "target", "target2");
my @null_target = ("");
my %named_trans = (
"p" => \@targets,
"P" => \@targets,
"c" => \@targets,
"C" => \@targets,
"u" => \@null_target,
"i" => \@null_target,
);
my %safe_map = (
"p" => "unsafe",
"P" => "safe",
"c" => "unsafe",
"C" => "safe",
"u" => "",
"i" => "",
);
my %invert_safe = (
"safe" => "unsafe",
"unsafe" => "safe",
);
# audit qualifier disabled for now it really shouldn't affect the conflict
# test but it may be worth checking every once in awhile
#my @qualifiers = ("", "owner", "audit", "audit owner");
my @qualifiers = ("", "owner");
my $count = 0;
gen_conflicting_x();
gen_overlap_re_exact();
gen_dominate_re_re();
gen_ambiguous_re_re();
gen_leading_perms("exact", "/bin/cat", "/bin/cat");
gen_leading_perms("exact-re", "/bin/*", "/bin/*");
gen_leading_perms("overlap", "/*", "/bin/cat");
gen_leading_perms("dominate", "/**", "/*");
gen_leading_perms("ambiguous", "/a*", "/*b");
gen_safe_perms("exact", "PASS", "", "/bin/cat", "/bin/cat");
gen_safe_perms("exact-re", "PASS", "", "/bin/*", "/bin/*");
gen_safe_perms("overlap", "PASS", "", "/*", "/bin/cat");
gen_safe_perms("dominate", "PASS", "", "/**", "/*");
gen_safe_perms("ambiguous", "PASS", "", "/a*", "/*b");
gen_safe_perms("exact", "FAIL", "inv", "/bin/cat", "/bin/cat");
gen_safe_perms("exact-re", "FAIL", "inv", "/bin/*", "/bin/*");
gen_safe_perms("overlap", "PASS", "inv", "/*", "/bin/cat");
gen_safe_perms("dominate", "FAIL", "inv", "/**", "/*");
gen_safe_perms("ambiguous", "FAIL", "inv", "/a*", "/*b");
print "Generated $count xtransition interaction tests\n";
sub gen_list {
my @output;
foreach my $trans (@trans_types) {
if ($trans_modifiers{$trans}) {
foreach my $mod (@{$trans_modifiers{$trans}}) {
push @output, "${trans}${mod}x";
}
}
push @output, "${trans}x";
}
return @output;
}
sub print_rule($$$$$$) {
my ($file, $leading, $qual, $name, $perm, $target) = @_;
if ($leading) {
print $file "\t${qual} ${perm} ${name}";
} else {
print $file "\t${qual} ${name} ${perm}";
}
if ($target ne "") {
print $file " -> $target";
}
print $file ",\n";
}
sub gen_file($$$$$$$$$$$$) {
my ($name, $xres, $leading1, $qual1, $rule1, $perm1, $target1, $leading2, $qual2, $rule2, $perm2, $target2) = @_;
# print "$xres $rule1 $perm1 $target1 $rule2 $perm2 $target2\n";
my $file;
unless (open $file, ">$name") {
print("couldn't open $name\n");
exit 1;
}
print $file "#\n";
print $file "#=DESCRIPTION ${name}\n";
print $file "#=EXRESULT ${xres}\n";
print $file "#\n";
print $file "/usr/bin/foo {\n";
print_rule($file, $leading1, $qual1, $rule1, $perm1, $target1);
print_rule($file, $leading2, $qual2, $rule2, $perm2, $target2);
print $file "}\n";
close($file);
$count++;
}
#NOTE: currently we don't do px to cx, or cx to px conversion
# so
# /foo {
# /* px -> /foo//bar,
# /* cx -> bar,
#
# will conflict
#
#NOTE: conflict tests don't tests leading permissions or using unsafe keywords
# It is assumed that there are extra tests to verify 1 to 1 coorispondance
sub gen_files($$$$) {
my ($name, $rule1, $rule2, $default) = @_;
my @perms = gen_list();
# print "@perms\n";
foreach my $i (@perms) {
foreach my $t (@{$named_trans{substr($i, 0, 1)}}) {
foreach my $q (@qualifiers) {
foreach my $j (@perms) {
foreach my $u (@{$named_trans{substr($j, 0, 1)}}) {
foreach my $r (@qualifiers) {
my $file="${prefix}/${name}-$q$i$t-$r$j$u.sd";
# print "$file\n";
#override failures when transitions are the same
my $xres = ${default};
if ($i eq $j && $t eq $u) {
$xres = "PASS";
}
# print "foo $xres $rule1 $i $t $rule2 $j $u\n";
gen_file($file, $xres, 0, $q, $rule1, $i, $t, 0, $r, $rule2, $j, $u);
}
}
}
}
}
}
}
sub gen_conflicting_x {
gen_files("conflict", "/bin/cat", "/bin/cat", "FAIL");
}
sub gen_overlap_re_exact {
gen_files("exact", "/bin/cat", "/bin/*", "PASS");
}
# we currently don't support this, once supported change to "PASS"
sub gen_dominate_re_re {
gen_files("dominate", "/bin/*", "/bin/**", "FAIL");
}
sub gen_ambiguous_re_re {
gen_files("ambiguous", "/bin/a*", "/bin/*b", "FAIL");
}
# test that rules that lead with permissions don't conflict with
# the same rule using trailing permissions.
sub gen_leading_perms($$$) {
my ($name, $rule1, $rule2) = @_;
my @perms = gen_list();
foreach my $i (@perms) {
foreach my $t (@{$named_trans{substr($i, 0, 1)}}) {
foreach my $q (@qualifiers) {
my $file="${prefix_leading}/${name}-$q$i$t.sd";
# print "$file\n";
gen_file($file, "PASS", 0, $q, $rule1, $i, $t, 1, $q, $rule2, $i, $t);
}
}
}
}
# test for rules with leading safe or unsafe keywords.
# check they are equivalent to their counter part,
# or if $invert that they properly conflict with their counterpart
sub gen_safe_perms($$$$$) {
my ($name, $xres, $invert, $rule1, $rule2) = @_;
my @perms = gen_list();
foreach my $i (@perms) {
foreach my $t (@{$named_trans{substr($i, 0, 1)}}) {
foreach my $q (@qualifiers) {
my $qual = $safe_map{substr($i, 0, 1)};
if ($invert) {
$qual = $invert_safe{$qual};
}
if (! $invert || $qual) {
my $file="${prefix_safe}/${name}-$invert-$q${qual}-rule-$i$t.sd";
# print "$file\n";
gen_file($file, $xres, 0, "$q $qual", $rule1, $i, $t, 1, $q, $rule2, $i, $t);
$file="${prefix_safe}/${name}-$invert-$q$qual${i}-rule-$t.sd";
gen_file($file, $xres, 0, $q, $rule1, $i, $t, 1, "$q $qual", $rule2, $i, $t);
}
}
}
}
}

View File

@@ -1,219 +0,0 @@
#!/usr/bin/python3
# ------------------------------------------------------------------
#
# Copyright (C) 2010-2011 Canonical Ltd.
# Copyright (C) 2020 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
# License published by the Free Software Foundation.
#
# ------------------------------------------------------------------
from testlib import write_file
prefix = "simple_tests/generated_x"
prefix_leading = "simple_tests/generated_perms_leading"
prefix_safe = "simple_tests/generated_perms_safe"
trans_types = ("p", "P", "c", "C", "u", "i")
modifiers = ("i", "u")
trans_modifiers = {
"p": modifiers,
"P": modifiers,
"c": modifiers,
"C": modifiers,
}
targets = ("", "target", "target2")
# null_target uses "_" instead of "" because "" gets skipped in some for loops. Replace with "" when actually using the value.
null_target = ("_")
named_trans = {
"p": targets,
"P": targets,
"c": targets,
"C": targets,
"u": null_target,
"i": null_target,
}
safe_map = {
"p": "unsafe",
"P": "safe",
"c": "unsafe",
"C": "safe",
"u": "",
"i": "",
}
invert_safe = {
"safe": "unsafe",
"unsafe": "safe",
'': '',
}
# audit qualifier disabled for now it really shouldn't affect the conflict
# test but it may be worth checking every once in awhile
# qualifiers = ("", "owner", "audit", "audit owner")
qualifiers = ("", "owner")
count = 0
def gen_list():
output = []
for trans in trans_types:
if trans in trans_modifiers:
for mod in trans_modifiers[trans]:
output.append("%s%sx" % (trans, mod))
output.append("%sx" % trans)
return output
def test_gen_list():
''' test if gen_list returns the expected output '''
expected = "pix pux px Pix Pux Px cix cux cx Cix Cux Cx ux ix".split()
actual = gen_list()
if actual != expected:
raise Exception("gen_list produced unexpected result, expected %s, got %s" % (expected, actual))
def build_rule(leading, qual, name, perm, target):
rule = ''
if leading:
rule += "\t%s %s %s" % (qual, perm, name)
else:
rule += "\t%s %s %s" % (qual, name, perm)
if target != "":
rule += " -> %s" % target
rule += ",\n"
return rule
def gen_file (name, xres, leading1, qual1, rule1, perm1, target1, leading2, qual2, rule2, perm2, target2):
global count
count += 1
content = ''
content += "#\n"
content += "#=DESCRIPTION %s\n" % name
content += "#=EXRESULT %s\n" % xres
content += "#\n"
content += "/usr/bin/foo {\n"
content += build_rule(leading1, qual1, rule1, perm1, target1)
content += build_rule(leading2, qual2, rule2, perm2, target2)
content += "}\n"
write_file('', name, content)
# NOTE: currently we don't do px to cx, or cx to px conversion
# so
# /foo {
# /* px -> /foo//bar,
# /* cx -> bar,
#
# will conflict
#
# NOTE: conflict tests don't test leading permissions or using unsafe keywords
# It is assumed that there are extra tests to verify 1 to 1 correspondance
def gen_files(name, rule1, rule2, default):
perms = gen_list()
for i in perms:
for t in named_trans[i[0]]:
if t == '_':
t = ''
for q in qualifiers:
for j in perms:
for u in named_trans[j[0]]:
if u == '_':
u = ''
for r in qualifiers:
file = prefix + '/' + name + '-' + q + i + t + '-' + r + j + u + '.sd'
# override failures when transitions are the same
xres = default
if (i == j and t == u):
xres = "PASS"
gen_file(file, xres, 0, q, rule1, i, t, 0, r, rule2, j, u)
def gen_conflicting_x():
gen_files("conflict", "/bin/cat", "/bin/cat", "FAIL")
def gen_overlap_re_exact():
gen_files("exact", "/bin/cat", "/bin/*", "PASS")
# we currently don't support this, once supported change to "PASS"
def gen_dominate_re_re():
gen_files("dominate", "/bin/*", "/bin/**", "FAIL")
def gen_ambiguous_re_re():
gen_files("ambiguous", "/bin/a*", "/bin/*b", "FAIL")
# test that rules that lead with permissions don't conflict with
# the same rule using trailing permissions.
def gen_leading_perms (name, rule1, rule2):
perms = gen_list()
for i in perms:
for t in named_trans[i[0]]:
if t == '_':
t = ''
for q in qualifiers:
file = prefix_leading + '/' + name + '-' + q + i + t + ".sd"
gen_file(file, "PASS", 0, q, rule1, i, t, 1, q, rule2, i, t)
# test for rules with leading safe or unsafe keywords.
# check they are equivalent to their counterpart,
# or if $invert that they properly conflict with their counterpart
def gen_safe_perms(name, xres, invert, rule1, rule2):
perms = gen_list()
for i in perms:
for t in named_trans[i[0]]:
if t == '_':
t = ''
for q in qualifiers:
qual = safe_map[i[0]]
if invert:
qual = invert_safe[qual]
if (not invert or qual):
file = prefix_safe + '/' + name + '-' + invert + '-' + q + qual + '-' + 'rule-' + i + t + '.sd'
gen_file(file, xres, 0, '%s %s' % (q, qual), rule1, i, t, 1, q, rule2, i, t)
file = prefix_safe + '/' + name + '-' + invert + '-' + q + qual + i + '-' + 'rule-' + t + '.sd'
gen_file(file, xres, 0, q, rule1, i, t, 1, '%s %s' % (q, qual), rule2, i, t)
test_gen_list()
gen_conflicting_x()
gen_overlap_re_exact()
gen_dominate_re_re()
gen_ambiguous_re_re()
gen_leading_perms("exact", "/bin/cat", "/bin/cat")
gen_leading_perms("exact-re", "/bin/*", "/bin/*")
gen_leading_perms("overlap", "/*", "/bin/cat")
gen_leading_perms("dominate", "/**", "/*")
gen_leading_perms("ambiguous", "/a*", "/*b")
gen_safe_perms("exact", "PASS", "", "/bin/cat", "/bin/cat")
gen_safe_perms("exact-re", "PASS", "", "/bin/*", "/bin/*")
gen_safe_perms("overlap", "PASS", "", "/*", "/bin/cat")
gen_safe_perms("dominate", "PASS", "", "/**", "/*")
gen_safe_perms("ambiguous", "PASS", "", "/a*", "/*b")
gen_safe_perms("exact", "FAIL", "inv", "/bin/cat", "/bin/cat")
gen_safe_perms("exact-re", "FAIL", "inv", "/bin/*", "/bin/*")
gen_safe_perms("overlap", "PASS", "inv", "/*", "/bin/cat")
gen_safe_perms("dominate", "FAIL", "inv", "/**", "/*")
gen_safe_perms("ambiguous", "FAIL", "inv", "/a*", "/*b")
print ("Generated %s xtransition interaction tests" % count)

View File

@@ -5,7 +5,7 @@ APPARMOR_PARSER="${APPARMOR_PARSER:-../apparmor_parser}"
# Format of -D dfa-states
# dfa-states output is split into 2 parts:
# the accept state information
# the accept state infomation
# {state} (allow deny audit XXX) ignore XXX for now
# followed by the transition table information
# {Y} -> {Z}: 0xXX Char #0xXX is the hex dump of Char
@@ -43,7 +43,7 @@ APPARMOR_PARSER="${APPARMOR_PARSER:-../apparmor_parser}"
# These tests currently only look at the accept state permissions
#
# To view any of these DFAs as graphs replace --D dfa-states with -D dfa-graph
# strip of the test stuff around the parser command and use the dot
# strip of the test stuff around the parser command and use the the dot
# command to convert
# Eg.
# echo "/t { /a r, /b w, /c a, /d l, /e k, /f m, deny /** w, }" | ./apparmor_parser -QT -O minimize -D dfa-graph --quiet 2>min.graph
@@ -100,7 +100,7 @@ fi
echo "ok"
# same test as above except with deny 'w' perm added to /**, this does not
# eliminates the states with 'w' and 'a' because the quiet information is
# elimnates the states with 'w' and 'a' because the quiet information is
# being carried
#
# {1} <== (allow/deny/audit/quiet)
@@ -119,7 +119,7 @@ fi
echo "ok"
# same test as above except with audit deny 'w' perm added to /**, with the
# parameter this eliminates the states with 'w' and 'a' because
# parameter this elimnates the states with 'w' and 'a' because
# the quiet information is NOT being carried
#
# {1} <== (allow/deny/audit/quiet)
@@ -139,7 +139,7 @@ echo "ok"
# The x transition test profile is setup so that there are 3 conflicting x
# permissions, two are on paths that won't collide during dfa creation. The
# 3rd is a generic permission that should be overridden during dfa creation.
# 3rd is a generic permission that should be overriden during dfa creation.
#
# This should result in a dfa that specifies transitions on 'a' and 'b' to
# unique states that store the alternate accept information. However
@@ -190,7 +190,7 @@ fi
echo "ok"
# now try audit + denying x and make sure perms are cleared
# notice that the deny info is being carried, by an artificial trap state
# notice that the deny info is being carried, by an artifical trap state
# {1} <== (allow/deny/audit/quiet)
# {3} (0x 0/fe17f85/0/0)

View File

@@ -1,8 +0,0 @@
#
#=DESCRIPTION abi testing - empty/cut-off rule
#=EXRESULT FAIL
abi "
/does/not/exist {
}

View File

@@ -1,8 +0,0 @@
#
#=DESCRIPTION abi testing - empty/cut-off rule
#=EXRESULT FAIL
abi ",
/does/not/exist {
}

View File

@@ -1,8 +0,0 @@
#
#=DESCRIPTION abi testing - empty/cut-off rule
#=EXRESULT FAIL
abi ""
/does/not/exist {
}

View File

@@ -1,8 +0,0 @@
#
#=DESCRIPTION abi testing - empty/cut-off rule
#=EXRESULT FAIL
abi "",
/does/not/exist {
}

View File

@@ -1,8 +0,0 @@
#
#=DESCRIPTION abi testing - empty/cut-off rule
#=EXRESULT FAIL
abi <
/does/not/exist {
}

View File

@@ -1,8 +0,0 @@
#
#=DESCRIPTION abi testing - empty/cut-off rule
#=EXRESULT FAIL
abi <,
/does/not/exist {
}

View File

@@ -1,8 +0,0 @@
#
#=DESCRIPTION abi testing - empty/cut-off rule
#=EXRESULT FAIL
abi <>
/does/not/exist {
}

View File

@@ -1,8 +0,0 @@
#
#=DESCRIPTION abi testing - empty/cut-off rule
#=EXRESULT FAIL
abi <>,
/does/not/exist {
}

View File

@@ -1,5 +1,5 @@
#
#=DESCRIPTION validate some uses of capabilities.
#=DESCRIPTION validate some uses of capabilties.
#=EXRESULT PASS
# vim:syntax=subdomain
# Last Modified: Sun Apr 17 19:44:44 2005

View File

@@ -1,5 +1,5 @@
#
#=DESCRIPTION validate some uses of capabilities.
#=DESCRIPTION validate some uses of capabilties.
#=EXRESULT PASS
# vim:syntax=subdomain
# Last Modified: Sun Apr 17 19:44:44 2005

View File

@@ -1,5 +1,5 @@
#
#=DESCRIPTION validate some uses of capabilities.
#=DESCRIPTION validate some uses of capabilties.
#=EXRESULT PASS
# vim:syntax=subdomain
# Last Modified: Sun Apr 17 19:44:44 2005

View File

@@ -1,5 +1,5 @@
#
#=DESCRIPTION validate some uses of capabilities.
#=DESCRIPTION validate some uses of capabilties.
#=EXRESULT FAIL
# vim:syntax=subdomain
# Last Modified: Sun Apr 17 19:44:44 2005

View File

@@ -1,4 +1,4 @@
#=DESCRIPTION conditional else in invalid locations
#=DESCRIPTION conditional else in invlaid locations
#=EXRESULT FAIL
$BAR = false

View File

@@ -1,5 +1,5 @@
#
#=DESCRIPTION m and [upi]x do not conflict, separate rules
#=DESCRIPTION m and [upi]x do not conflict, seperate rules
#=EXRESULT PASS
# vim:syntax=apparmor
#

View File

@@ -1,5 +1,5 @@
#
#=DESCRIPTION m and [upi]x do not conflict, separate rules
#=DESCRIPTION m and [upi]x do not conflict, seperate rules
#=EXRESULT PASS
#
/usr/bin/foo {

View File

@@ -1,5 +1,5 @@
#
#=DESCRIPTION m and [upi]x do not conflict, separate rules
#=DESCRIPTION m and [upi]x do not conflict, seperate rules
#=EXRESULT PASS
#
/usr/bin/foo {

View File

@@ -1,5 +1,5 @@
#
#=DESCRIPTION netdomain tcp connect w/multiple from statements
#=DESCRIPTION netdomain tcp connect w/multiple from statments
#=EXRESULT FAIL
/tmp/tcp/tcp_client {
tcp_connect from 10.0.0.17/16:50-100 from 127.0.0.1 via eth1,

View File

@@ -1,6 +1,6 @@
#
# $Id$
#=DESCRIPTION Basic namespace test with named profile, duplicate mode bits
#=DESCRIPTION Basic namespace test wit named profile, duplicate mode bits
#=EXRESULT PASS
# vim:syntax=subdomain
# Last Modified: Sun Apr 17 19:44:44 2005

View File

@@ -1,5 +1,5 @@
#
#=DESCRIPTION simple max virtual memory size rlimit test
#=DESCRIPTION simple max virtual memory szie rlimit test
#=EXRESULT PASS
profile rlimit {

View File

@@ -86,7 +86,7 @@ class AATestTemplate(unittest.TestCase, metaclass=AANoCleanupMetaClass):
(rc, out, outerr) = self._run_cmd(command, input, stderr, stdout, stdin, timeout)
report = out + outerr
return rc, report
return [rc, report]
def _run_cmd(self, command, input=None, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
stdin=None, timeout=120):
@@ -96,7 +96,7 @@ class AATestTemplate(unittest.TestCase, metaclass=AANoCleanupMetaClass):
sp = subprocess.Popen(command, stdin=stdin, stdout=stdout, stderr=stderr,
close_fds=True, preexec_fn=subprocess_setup, universal_newlines=True)
except OSError as e:
return 127, str(e), ''
return [127, str(e), '']
timeout_communicate = TimeoutFunction(sp.communicate, timeout)
out, outerr = (None, None)
@@ -115,7 +115,7 @@ class AATestTemplate(unittest.TestCase, metaclass=AANoCleanupMetaClass):
if outerr is None:
outerr = ''
return rc, out, outerr
return (rc, out, outerr)
# Timeout handler using alarm() from John P. Speno's Pythonic Avocado

View File

@@ -42,8 +42,8 @@ class AAParserValgrindTests(testlib.AATestTemplate):
self.maxDiff = None
def _runtest(self, testname, config):
parser_args = ('-Q', '-I', config.testdir, '-M', './features_files/features.all')
failure_rc = (VALGRIND_ERROR_CODE, testlib.TIMEOUT_ERROR_CODE)
parser_args = ['-Q', '-I', config.testdir, '-M', './features_files/features.all']
failure_rc = [VALGRIND_ERROR_CODE, testlib.TIMEOUT_ERROR_CODE]
command = [config.valgrind]
command.extend(VALGRIND_ARGS)
command.append(config.parser)
@@ -68,11 +68,11 @@ def create_suppressions():
handle, name = tempfile.mkstemp(suffix='.suppressions', prefix='aa-parser-valgrind')
os.close(handle)
with open(name, "w+") as handle:
handle.write(VALGRIND_SUPPRESSIONS)
handle = open(name,"w+")
handle.write(VALGRIND_SUPPRESSIONS)
handle.close()
return name
def main():
rc = 0
p = ArgumentParser()

View File

@@ -47,10 +47,10 @@ else
PYTHONPATH=../utils/:$(PYTHON_DIST_BUILD_PATH)
PARSER?=../parser/apparmor_parser
# use ../utils logprof
LOGPROF?=LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) PYTHONPATH=$(PYTHONPATH) $(PYTHON) ../utils/aa-logprof --configdir ../utils/
LOGPROF?=LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) PYTHONPATH=$(PYTHONPATH) $(PYTHON) ../utils/aa-logprof
endif
# $(PWD) is wrong when using "make -C profiles" - explicitly set it here to get the right value
# $(PWD) is wrong when using "make -C profiles" - explicitely set it here to get the right value
PWD=$(shell pwd)
.PHONY: test-dependencies

View File

@@ -105,6 +105,9 @@
# glibc's *printf protections read the maps file
@{PROC}/@{pid}/{maps,auxv,status} r,
# libgcrypt reads some flags from /proc
@{PROC}/sys/crypto/* r,
# some applications will display license information
/usr/share/common-licenses/** r,

View File

@@ -29,8 +29,8 @@
# include <abstractions/ubuntu-browsers>
# include <abstractions/ubuntu-email>
#
# # Add if accessibility access is considered as required
# # (for message box in case exo-open fails)
# # Add if accesibility access is considered as required
# # (for message boxe in case exo-open fails)
# include <abstractions/dbus-accessibility>
#
# # < add additional allowed applications here >

View File

@@ -29,8 +29,8 @@
# include <abstractions/ubuntu-browsers>
# include <abstractions/ubuntu-email>
#
# # Add if accessibility access is considered as required
# # (for message box in case exo-open fails)
# # Add if accesibility access is considered as required
# # (for message boxe in case exo-open fails)
# include <abstractions/dbus-accessibility>
#
# # Add if audio support for message box is

View File

@@ -14,6 +14,8 @@
/etc/ssl/{engdef,engines}.d/ r,
/etc/ssl/{engdef,engines}.d/*.cnf r,
/usr/share/ssl/openssl.cnf r,
@{PROC}/sys/crypto/fips_enabled r,
# Include additions to the abstraction
include if exists <abstractions/openssl.d>

View File

@@ -42,5 +42,9 @@
/etc/certbot/archive/*/chain*.pem r,
/etc/certbot/archive/*/fullchain*.pem r,
# crypto policies used by various libraries
/etc/crypto-policies/*/*.txt r,
/usr/share/crypto-policies/*/*.txt r,
# Include additions to the abstraction
include if exists <abstractions/ssl_certs.d>

View File

@@ -14,7 +14,7 @@
# it is intended to be included in profiles for svnserve/apache2 and maybe
# some repository viewers like trac/viewvc
# no hooks exec by default; please define whatever you need explicitly.
# no hooks exec by default; please define whatever you need explicitely.
/srv/svn/**/conf/* r,
/srv/svn/**/format r,

View File

@@ -1,75 +0,0 @@
abi <abi/3.0>,
# requires <tunables/home>
owner @{HOME}/.config/trashrc rw,
owner @{HOME}/.config/trashrc.lock rwk,
owner @{HOME}/.config/#[0-9]*[0-9] rwk,
owner @{HOME}/.config/trashrc.* rwl -> @{HOME}/.config/#[0-9]*[0-9],
owner @{run}/user/@{uid}/#[0-9]*[0-9] rw,
owner @{run}/user/@{uid}/trash.so*.[0-9].slave-socket rwl -> @{run}/user/@{uid}/#[0-9]*[0-9],
# Home trash location
owner @{HOME}/.local/share/Trash/ rw,
owner @{HOME}/.local/share/Trash/#[0-9]*[0-9] rw,
owner @{HOME}/.local/share/Trash/directorysizes{,.*} rwl -> @{HOME}/.local/share/Trash/#[0-9]*[0-9],
owner @{HOME}/.local/share/Trash/files/{,**} rw,
owner @{HOME}/.local/share/Trash/info/ rw,
owner @{HOME}/.local/share/Trash/info/*.trashinfo{,.*} rw,
owner @{HOME}/.local/share/Trash/expunged/ rw,
owner @{HOME}/.local/share/Trash/expunged/[0-9]* rw,
owner @{HOME}/.local/share/Trash/expunged/[0-9]*/ rw,
owner @{HOME}/.local/share/Trash/expunged/[0-9]*/** rw,
# Partitions' trash location when the admin creates the .Trash/ folder in the top lvl dir
owner /media/*/.Trash/ rw,
owner /media/*/.Trash/@{uid}/ rw,
owner /media/*/.Trash/@{uid}/#[0-9]*[0-9] rw,
owner /media/*/.Trash/@{uid}/directorysizes{,.*} rwl -> /media/*/.Trash/@{uid}/#[0-9]*[0-9],
owner /media/*/.Trash/@{uid}/files/{,**} rw,
owner /media/*/.Trash/@{uid}/info/ rw,
owner /media/*/.Trash/@{uid}/info/*.trashinfo{,.*} rw,
owner /media/*/.Trash/@{uid}/expunged/ rw,
owner /media/*/.Trash/@{uid}/expunged/[0-9]* rw,
owner /media/*/.Trash/@{uid}/expunged/[0-9]*/ rw,
owner /media/*/.Trash/@{uid}/expunged/[0-9]*/** rw,
# Partitions' trash location when the admin doesn't create the .Trash/ folder in the top lvl dir
owner /media/*/.Trash-@{uid}/ rw,
owner /media/*/.Trash-@{uid}/#[0-9]*[0-9] rw,
owner /media/*/.Trash-@{uid}/directorysizes{,.*} rwl -> /media/*/.Trash-@{uid}/#[0-9]*[0-9],
owner /media/*/.Trash-@{uid}/files/{,**} rw,
owner /media/*/.Trash-@{uid}/info/ rw,
owner /media/*/.Trash-@{uid}/info/*.trashinfo{,.*} rw,
owner /media/*/.Trash-@{uid}/expunged/ rw,
owner /media/*/.Trash-@{uid}/expunged/[0-9]* rw,
owner /media/*/.Trash-@{uid}/expunged/[0-9]*/ rw,
owner /media/*/.Trash-@{uid}/expunged/[0-9]*/** rw,
# Removable media's trash location when the admin creates the .Trash/ folder in the top lvl dir
owner /media/*/*/.Trash/ rw,
owner /media/*/*/.Trash/@{uid}/ rw,
owner /media/*/*/.Trash/@{uid}/#[0-9]*[0-9] rw,
owner /media/*/*/.Trash/@{uid}/directorysizes{,.*} rwl -> /media/*/*/.Trash/@{uid}/#[0-9]*[0-9],
owner /media/*/*/.Trash/@{uid}/files/{,**} rw,
owner /media/*/*/.Trash/@{uid}/info/ rw,
owner /media/*/*/.Trash/@{uid}/info/*.trashinfo{,.*} rw,
owner /media/*/*/.Trash/@{uid}/expunged/ rw,
owner /media/*/*/.Trash/@{uid}/expunged/[0-9]* rw,
owner /media/*/*/.Trash/@{uid}/expunged/[0-9]*/ rw,
owner /media/*/*/.Trash/@{uid}/expunged/[0-9]*/** rw,
# Removable media's trash location when the admin doesn't create the .Trash/ folder in the top lvl dir
owner /media/*/*/.Trash-@{uid}/ rw,
owner /media/*/*/.Trash-@{uid}/#[0-9]*[0-9] rw,
owner /media/*/*/.Trash-@{uid}/directorysizes{,.*} rwl -> /media/*/*/.Trash-@{uid}/#[0-9]*[0-9],
owner /media/*/*/.Trash-@{uid}/files/{,**} rw,
owner /media/*/*/.Trash-@{uid}/info/ rw,
owner /media/*/*/.Trash-@{uid}/info/*.trashinfo{,.*} rw,
owner /media/*/*/.Trash-@{uid}/expunged/ rw,
owner /media/*/*/.Trash-@{uid}/expunged/[0-9]* rw,
owner /media/*/*/.Trash-@{uid}/expunged/[0-9]*/ rw,
owner /media/*/*/.Trash-@{uid}/expunged/[0-9]*/** rw,
include if exists <abstractions/trash.d>

View File

@@ -36,7 +36,6 @@
profile sanitized_helper {
include <abstractions/base>
include <abstractions/X>
include if exists <local/ubuntu-helpers>
# Allow all networking
network inet,

View File

@@ -7,14 +7,5 @@
@{sys}/class/video4linux/ r,
@{sys}/class/video4linux/** r,
owner /dev/shm/libv4l-* rw,
/dev/video[0-9]* rw,
@{sys}/devices/pci[0-9]*/**/usb[0-9]/**/video4linux/video[0-9]*/dev r,
@{sys}/devices/pci[0-9]*/**/usb[0-9]/**/{modalias,speed} r,
@{sys}/devices/virtual/dmi/id/sys_vendor r,
@{sys}/devices/virtual/dmi/id/product_{name,version} r,
@{sys}/devices/virtual/dmi/id/board_{vendor,name,version} r,
# Include additions to the abstraction
include if exists <abstractions/video.d>

View File

@@ -14,8 +14,5 @@
owner @{run}/user/*/wayland-[0-9]* rw,
owner @{run}/user/*/{mesa,mutter,sdl,wayland-cursor,weston,xwayland}-shared-* rw,
#For compositors based on wlroots
owner /dev/shm/wlroots-* rw,
# Include additions to the abstraction
include if exists <abstractions/wayland.d>

View File

@@ -41,7 +41,7 @@
include <abstractions/base>
# for opening with `exo-open`
# for openin with `exo-open`
include <abstractions/exo-open>
# for opening with `gio open <uri>`

View File

@@ -30,12 +30,16 @@ profile syslogd /{usr/,}{bin,sbin}/syslogd {
/dev/log wl,
/var/lib/*/dev/log wl,
/proc/kmsg r,
/dev/tty* w,
/dev/xconsole rw,
/etc/syslog.conf r,
/etc/syslog.d/ r,
/etc/syslog.d/* r,
/{usr/,}{bin,sbin}/syslogd rmix,
/var/log/** rw,
@{run}/syslog.pid krwl,
@{run}/syslogd.pid krwl,
@{run}/utmp rw,
/var/spool/compaq/nic/messages_fifo rw,

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