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

Compare commits

...

227 Commits

Author SHA1 Message Date
John Johansen
af9d04d24b Prepare for AppArmor 3.0.9 release
- update version file
- update library version

Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-02-27 17:30:35 -08:00
John Johansen
39e7c30ae4 Merge [3.x] Update samba profiles
samba-dcerpcd requires access to `/var/cache/samba/names.tdb`.

audit: type=1400 audit(1676835286.187:62): apparmor="DENIED" operation="open" profile="samba-dcerpcd" name="/var/cache/samba/names.tdb" pid=6948 comm="samba-dcerpcd" requested_mask="wrc" denied_mask="wrc" fsuid=0 ouid=0

See also https://bbs.archlinux.org/viewtopic.php?id=281411

Since `usr.sbin.winbindd` already has a rule for it, and `usr.sbin.nmbd`
has similar ones, simply add `/var/cache/samba/*.tdb rwk` to
`abstractions/samba`.

(cherry picked from commit 763c4ecd23,
with cleanup of now-superfluous rules in usr.sbin.nmbd and
usr.sbin.winbindd dropped)

Also allow access to samba pid files directly in /run/

This is a backport of !987, with the cleanup of now-superfluous rules removed.

I propose this patch for 3.x (also for 2.13 if it cleanly applies)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/988
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2023-02-27 11:56:47 -08:00
nl6720
d266f7f84c profiles/apparmor.d/samba*: allow access to pid files directly in /run/
On Arch Linux, `samba-dcerpcd.pid` is in `/run/`, not `/run/samba/`.

   apparmor="DENIED" operation="mknod" profile="samba-dcerpcd" name="/run/samba-dcerpcd.pid" pid=80920 comm="samba-dcerpcd" requested_mask="c" denied_mask="c" fsuid=0 ouid=0

The same is true for `nmbd.pid`, `smbd.pid` and probably others too.

(cherry picked from commit 6f0d2ef7fe)
2023-02-27 11:54:35 -08:00
nl6720
4f0dd10e5e profiles/apparmor.d/abstractions/samba: allow modifying /var/cache/samba/*.tdb
samba-dcerpcd requires access to `/var/cache/samba/names.tdb`.

    audit: type=1400 audit(1676835286.187:62): apparmor="DENIED" operation="open" profile="samba-dcerpcd" name="/var/cache/samba/names.tdb" pid=6948 comm="samba-dcerpcd" requested_mask="wrc" denied_mask="wrc" fsuid=0 ouid=0

See also https://bbs.archlinux.org/viewtopic.php?id=281411

Since `usr.sbin.winbindd` already has a rule for it, and `usr.sbin.nmbd`
has similar ones, simply add `/var/cache/samba/*.tdb rwk` to
`abstractions/samba`.

(cherry picked from commit 763c4ecd23,
with cleanup of now-superfluous rules in usr.sbin.nmbd and
usr.sbin.winbindd dropped)
2023-02-27 11:54:22 -08:00
John Johansen
a5f8b065a8 Merge Add abstractions/groff with lots of groff/nroff helpers
contributed by Werner Fink via
https://bugzilla.opensuse.org/show_bug.cgi?id=1065388 comment 25

Note that - compared to the file in bugzilla - I removed the `rix` rules
for /usr/bin/groff and /usr/bin/nroff so that people can choose to ix,
Px or Cx groff/nroff as they wish, and then include the abstraction
inside the target profile to allow executing all the helpers.

I also added `include if exists <abstractions/groff.d>`

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/973
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 238eb8150b)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-02-26 13:57:50 -08:00
John Johansen
9f9edbeeb2 Merge abstractions/openssl: allow reading /etc/ssl/openssl-*.cnf
openSUSE Tumbleweed uses /etc/ssl/openssl-1_1.cnf to make the migration
to openssl 3 possible.

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

I propose this patch for at least 3.1 and master, ideally for all branches (as long as it can easily be merged)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/984
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit f223ed063e)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-02-25 17:07:03 -08:00
Georgia Garcia
147c4f4703 libapparmor: add support for class in logparsing
We want to use the class field to identify operations such as
posix_mqueue

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
(cherry picked from commit 5cc7a26e78)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-02-24 04:17:16 -08:00
Georgia Garcia
dd5edd8f9f libapparmor: add support for requested and denied on logparsing
In order to decrease the number of characters in the audit logs
from the kernel, we will drop the "_mask" from the fields
"requested_mask" and "denied_mask".

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
(cherry picked from commit a05c9483f3)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-02-24 04:17:03 -08:00
Christian Boltz
56d1b65e7f Merge abstractioms/nvidia: add new cache directory
Some applications (like Firefox or Steam, but for some reason not
glxgears) now writes to ~/.cache/nvidia/*:

```
type=AVC msg=audit(1676115846.764:605): apparmor="DENIED" operation="open" profile="firefox" name="/home/vincas/.cache/nvidia/GLCache/2c0cfcdab4d7b05f8130d8f
ba8838943/ec9a05ca3988cfd1/1fee83e04c0ea4d8.toc" pid=26827 comm="firefox" requested_mask="rac" denied_mask="rac" fsuid=1000 ouid=1000^]FSUID="vincas" OUID="v
incas"
```

```
type=AVC msg=audit(1676134465.264:2166): apparmor="DENIED" operation="open" profile="steam" name="/home/vincas/.cache/nvidia/GLCache/95f6d95b1adf9af310bc94af5f19e509/6b24ef0587ddc7e4/23b502f99abb563c.toc" pid=56082 comm="steam" requested_mask="wr" denied_mask="wr" fsuid=1000 ouid=1000^]FSUID="vincas" OUID="vincas"
```

Update nvidia abstraction to allow create caches in .cache subdirectory.

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


(cherry picked from commit d713f75086)

15b92cd2 abstractioms/nvidia: add new cache directory
2023-02-16 17:42:10 +00:00
Christian Boltz
c919db4042 Merge nvidia_modprobe: update for driver families and /sys path
Debian have split NVIDIA drivers into current, tesla and legacy:

```
$ apt-file search /etc/nvidia/ | grep -P -o -e
"(?<=/etc/nvidia/).[^/]*/" | sort -u
current/
current-open/
legacy-340xx/
legacy-390xx/
tesla/
tesla-418/
tesla-450/
tesla-460/
tesla-470/
tesla-510/
```

These paths are used by nvidia_modprobe -> kmod:

```
type=AVC msg=audit(1676135718.796:2592): apparmor="DENIED" operation="open" profile="nvidia_modprobe//kmod" name="/etc/nvidia/tesla-470/nvidia-blacklists-nouveau.conf" pid=62094 comm="modprobe" requested_mask="r" denied_mask="r" fsuid=0 ouid=0FSUID="root" OUID="root"
type=AVC msg=audit(1676135718.796:2593): apparmor="DENIED" operation="open" profile="nvidia_modprobe//kmod" name="/etc/nvidia/tesla-470/nvidia-options.conf" pid=62094 comm="modprobe" requested_mask="r" denied_mask="r" fsuid=0 ouid=0FSUID="root" OUID="root"
type=AVC msg=audit(1676135718.796:2594): apparmor="DENIED" operation="open" profile="nvidia_modprobe//kmod" name="/etc/nvidia/tesla-470/nvidia-modprobe.conf" pid=62094 comm="modprobe" requested_mask="r" denied_mask="r" fsuid=0 ouid=0FSUID="root" OUID="root"
```

Also, additional /sys path is accessed:

```
type=AVC msg=audit(1676136251.680:2956): apparmor="DENIED" operation="open" profile="nvidia_modprobe//kmod" name="/sys/module/drm/initstate" pid=63642 comm="modprobe" requested_mask="r" denied_mask="r" fsuid=0 ouid=0FSUID="root" OUID="root"
```

Update nvidia_modprobe profile to this these denials.

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


(cherry picked from commit 94d2faab71)

8e50c351 nvidia_modprobe: update for driver families and /sys path
2023-02-14 18:39:39 +00:00
John Johansen
b6cfad04c0 Merge postfix-tlsmgr: allow reading openssl.cnf
Seen/needed on openSUSE Tumbleweed

I propose this patch for all branches.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/981
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 3e89b4aab2)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-02-09 00:18:10 -08:00
John Johansen
24bdf3855f Merge avahi-daemon needs attach_disconnected
... for var/lib/nscd/passwd and var/lib/nscd/group

I propose this patch for all branches.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/960
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 2c72dd5541)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-02-03 21:28:37 -08:00
John Johansen
a9ef414655 Merge nscd: allow using systemd-userdb
If systemd-userdb is used to configure some users, nscd needs to read
the userdb files.

See also https://www.freedesktop.org/software/systemd/man/nss-systemd.html
for the list of possible filenames (and symlinks).

Fixes: http://bugzilla.opensuse.org/show_bug.cgi?id=1207698

I propose this patch for all branches.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/977
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit 5df8da3c37)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-02-01 19:56:31 -08:00
John Johansen
2b97de1b2c Merge Fix mode not being printed when debugging AF_UNIX socket rules.
This was due to the values being defined in both af_unix and af_rule leaving the latter values unset.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/979
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit da7d3a2101)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-02-01 19:51:47 -08:00
Georgia Garcia
a80e3dc432 Merge Fix spacing when printing out AF_UNIX addresses
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/978
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
(cherry picked from commit 608560ee43)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-02-01 19:51:42 -08:00
John Johansen
de739160c1 Merge Fix: Opening links with Brave
Resolves #292.

This fix is the same as !830 but for Brave.
Opening links in Brave now works as intended.

Note that now a separate denial is caused, related to WidevineCDM, is produced:
```
[ERROR:content_main_runner_impl.cc(415)] Unable to load CDM /home/username/.config/BraveSoftware/Brave-Browser/WidevineCdm/4.10.2557.0/_platform_specific/linux_x64/libwidevinecdm.so (error: /home/username/.config/BraveSoftware/Brave-Browser/WidevineCdm/4.10.2557.0/_platform_specific/linux_x64/libwidevinecdm.so: failed to map segment from shared object)
```

In the syslog:
```
audit: type=1400 audit(1671108748.090:117): apparmor="DENIED" operation="file_mmap" profile="/usr/bin/evince//sanitized_helper" name="/home/username/.config/BraveSoftware/Brave-Browser/WidevineCdm/4.10.2557.0/_platform_specific/linux_x64/libwidevinecdm.so" pid=65765 comm="brave" requested_mask="m" denied_mask="m" fsuid=1000 ouid=100
```

I'm not sure if granting permission(s) for this is desirable. In either case, the potential relevant changes are out of the scope of this MR.

If I disable WidevineCDM in Brave, I get the following denial on cap sys_admin:
```
audit: type=1400 audit(1671112807.666:174): apparmor="DENIED" operation="capable" profile="/usr/bin/evince//sanitized_helper" pid=112098 comm="brave" capability=21  capname="sys_admin"
```
which is fine, as mentioned by @jjohansen [here](https://gitlab.com/apparmor/apparmor/-/merge_requests/830#note_831915024).

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

(cherry picked from commit 5fd8c25745)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-01-25 13:10:34 -08:00
John Johansen
698c3f313f Merge libapparmor: add scanner support for dbus method
In the [merge request that adds AppArmor support on D-Bus Broker](https://github.com/bus1/dbus-broker/pull/286), the word "method" is used instead of "member" on the auditing logs.
So we are adding support to parse "method" the same way as "member" on D-Bus audit logs.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/958
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit a96fa35bd5)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-01-25 13:10:23 -08:00
John Johansen
ca6191d158 Merge Extend crypto and ssl_certs abstractions
- ssl_certs: /{etc,usr/share}/pki/trust/ has more than the 'anchors' subdirectory
- crypoto: allow reading /etc/gcrypt/hwf.deny

I propose this patch for 3.0..master (2.13 doesn't have abstractions/crypto).

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/961
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit bb30df7843)

d15bfa99 Extend crypto and ssl_certs abstractions
2023-01-24 23:10:34 +00:00
Christian Boltz
d2905d907a Merge Add pipewire client.conf to audio abstractions
Fixes: https://bugs.launchpad.net/bugs/2003702

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


(cherry picked from commit dedb5d94cb)

b5a7641d Add pipewire client.conf to audio abstractions
2023-01-23 20:35:26 +00:00
Christian Boltz
da9a4aa20a Merge profiles: dnsmasq: add Waydroid pid file
Waydroid uses LXC and some lxc-net equivalent scripts. Allow that.

b910c89174/data/scripts/waydroid-net.sh
https://web.archive.org/web/20221202141315/https://docs.waydro.id/debugging/known-issues

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


(cherry picked from commit d61ccafcb3)

977e45c1 profiles: dnsmasq: add Waydroid pid file
2023-01-22 18:11:51 +00:00
John Johansen
e7bf292343 Merge regression tests: fix bogon patch characters in Makefile
Commit 8cf3534a5 ("tests regression: fix failure on older versions of
Make") from https://gitlab.com/apparmor/apparmor/-/merge_requests/639
was incorrectly applied, including the `+` prefixes from the proposed
patch. This causes the sysctl syscall() checks to not correctly be
applied and results in a mismatch of expectations in the
syscall_sysctl.sh test script, causing it and the testsuite to fail.

Thus, remove the bogon `+` characters from the Makefile, to make
USE_SYSCTL be set correctly.

Fixes: 8cf3534a5 ("tests regression: fix failure on older versions of Make")
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/963
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Approved-by: Christian Boltz <apparmor@cboltz.de>
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit f0bc1a89a4)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-01-04 16:45:46 -08:00
John Johansen
099ad8186a Merge aa-status: Fix malformed json output with unconfined processes
As reported in issue #295, the json output from aa-status would be invalid if
there were profiles defined for processes that were unconfined. Fix this by
ensuring the json for the processes array is closed properly.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/964
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit dfc9847f89)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2023-01-04 09:34:39 -08:00
Georgia Garcia
aa10832801 Merge log parsing fixes
small fixes on log parsing

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/959
Approved-by: Jon Tourville <jon.tourville@canonical.com>
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
(cherry picked from commit 4f2d2a8cab)
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2022-12-16 16:58:06 -03:00
John Johansen
504df28245 Merge parser: Fix invalid reference to transitions when building the chfa
States are not guaranteed to have transitions, but when inserting
a state into the chfa table there is an unconditional dereference
to the states first transition.

This will result in a bad reference and could result in an OOB
flag being set on the state when it shouldn't be.

Fixes: 16b67ddbd ("add ability to use out of band transitions"
Closes: https://gitlab.com/apparmor/apparmor/-/issues/290
Reported-by: Nobel Barakat <nobelbarakat@google.com>
Reported-by: Oleksandr Tymoshenko <ovt@google.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>

Closes #290
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/956
Approved-by: Seth Arnold <seth.arnold@gmail.com>
Merged-by: John Johansen <john@jjmx.net>

(cherry picked from commit a7bce9be98)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-12-09 23:04:43 -08:00
John Johansen
a072082626 Merge smbd: allow reading /var/lib/nscd/netgroup
(reported on the opensuse-factory mailinglist)

I propose this patch for 2.13..master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/948
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(cherry picked from commit ba01d479e2)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-11-29 12:56:50 -08:00
Christian Boltz
6d3cb1b78d Merge abstractions/nvidia: allow reading @{pid}/comm
On Debian Sid, NVIDIA driver spams log with:

```
type=AVC msg=audit(1669542108.552:11855): apparmor="DENIED"
operation="open" profile="qtox" name="/proc/21222/comm" pid=21222
comm="qtox" requested_mask="r" denied_mask="r" fsuid=1000
ouid=1000FSUID="vincas" OUID="vincas"
```

```
type=AVC msg=audit(1669541506.703:11329): apparmor="DENIED"
operation="open" profile="skypeforlinux" name="/proc/19851/comm"
pid=19851 comm="skypeforlinux" requested_mask="r" denied_mask="r"
fsuid=1000 ouid=1000FSUID="vincas" OUID="vincas"
```

Read is initiated within libnvidia-glcore.so:

```
Thread 1 "qtox" hit Catchpoint 1 (call to syscall openat), 0x00007fb797b16ed0 in __libc_open64 (file=file@entry=0x7fb742adbb50 "/proc/self/comm", oflag=0) at ../sysdeps/unix/sysv/linux/open64.c:41
41	in ../sysdeps/unix/sysv/linux/open64.c
$27 = 0x7fb742adbb50 "/proc/self/comm"
0  0x00007fb797b16ed0 in __libc_open64 (file=file@entry=0x7fb742adbb50 "/proc/self/comm", oflag=0) at ../sysdeps/unix/sysv/linux/open64.c:41
1  0x00007fb797aa0862 in __GI__IO_file_open (fp=fp@entry=0x55795176e600, filename=filename@entry=0x7fb742adbb50 "/proc/self/comm", posix_mode=<optimized out>, prot=prot@entry=438, read_write=8, is32not64=<optimized out>) at ./libio/fileops.c:188
2  0x00007fb797aa0a1b in _IO_new_file_fopen (fp=fp@entry=0x55795176e600, filename=filename@entry=0x7fb742adbb50 "/proc/self/comm", mode=<optimized out>, mode@entry=0x7fb7428effe2 "r", is32not64=is32not64@entry=1) at ./libio/fileops.c:280
3  0x00007fb797a950f9 in __fopen_internal (filename=0x7fb742adbb50 "/proc/self/comm", mode=0x7fb7428effe2 "r", is32=1) at ./libio/iofopen.c:75
4  0x00007fb7423d791f in ?? () from /lib/x86_64-linux-gnu/libnvidia-glcore.so.470.141.03
5  0x00007fb7423d4515 in ?? () from /lib/x86_64-linux-gnu/libnvidia-glcore.so.470.141.03
6  0x00007fb7423d0226 in ?? () from /lib/x86_64-linux-gnu/libnvidia-glcore.so.470.141.03
7  0x00007fb7423e1961 in ?? () from /lib/x86_64-linux-gnu/libnvidia-glcore.so.470.141.03
8  0x00007fb74824bc79 in ?? () from /lib/x86_64-linux-gnu/libGLX_nvidia.so.0
9  0x00007fb7482b1c56 in ?? () from /lib/x86_64-linux-gnu/libGLX_nvidia.so.0
10 0x000000000000001d in ?? ()
11 0x00005579518975f0 in ?? ()
12 0x0000000000000001 in ?? ()
13 0x00007fb74824b1eb in ?? () from /lib/x86_64-linux-gnu/libGLX_nvidia.so.0
14 0x00005579518975f0 in ?? ()
15 0x00007fb79b2dda79 in call_init (env=0x7ffd92d7aac8, argv=0x7ffd92d7aab8, argc=-1831363648, l=0x7fb748516f70) at ./elf/dl-init.c:56
16 call_init (l=0x7fb748516f70, argc=-1831363648, argv=0x7ffd92d7aab8, env=0x7ffd92d7aac8) at ./elf/dl-init.c:26
17 0x00007fb79b2ddba4 in _dl_init (main_map=0x5579518975f0, argc=1, argv=0x7ffd92d7aab8, env=0x7ffd92d7aac8) at ./elf/dl-init.c:117
18 0x00007fb797b6def4 in __GI__dl_catch_exception (exception=<optimized out>, operate=<optimized out>, args=<optimized out>) at ./elf/dl-error-skeleton.c:182
19 0x00007fb79b2e430e in dl_open_worker (a=a@entry=0x7ffd92d79f20) at ./elf/dl-open.c:808
20 0x00007fb797b6de9a in __GI__dl_catch_exception (exception=<optimized out>, operate=<optimized out>, args=<optimized out>) at ./elf/dl-error-skeleton.c:208
21 0x00007fb79b2e46a8 in _dl_open (file=0x557951888020 "libGLX_nvidia.so.0", mode=<optimized out>, caller_dlopen=0x7fb78d7d4d27, nsid=<optimized out>, argc=1, argv=0x7ffd92d7aab8, env=0x7ffd92d7aac8) at ./elf/dl-open.c:884
22 0x00007fb797aa42d8 in dlopen_doit (a=a@entry=0x7ffd92d7a190) at ./dlfcn/dlopen.c:56
23 0x00007fb797b6de9a in __GI__dl_catch_exception (exception=exception@entry=0x7ffd92d7a0f0, operate=<optimized out>, args=<optimized out>) at ./elf/dl-error-skeleton.c:208
24 0x00007fb797b6df4f in __GI__dl_catch_error (objname=0x7ffd92d7a148, errstring=0x7ffd92d7a150, mallocedp=0x7ffd92d7a147, operate=<optimized out>, args=<optimized out>) at ./elf/dl-error-skeleton.c:227
25 0x00007fb797aa3dc7 in _dlerror_run (operate=operate@entry=0x7fb797aa4280 <dlopen_doit>, args=args@entry=0x7ffd92d7a190) at ./dlfcn/dlerror.c:138
26 0x00007fb797aa4389 in dlopen_implementation (dl_caller=<optimized out>, mode=<optimized out>, file=<optimized out>) at ./dlfcn/dlopen.c:71
27 ___dlopen (file=<optimized out>, mode=<optimized out>) at ./dlfcn/dlopen.c:81
28 0x00007fb78d7d4d27 in ?? () from /lib/x86_64-linux-gnu/libGLX.so.0
29 0x00007fb78d7d6335 in ?? () from /lib/x86_64-linux-gnu/libGLX.so.0
30 0x00007fb78d7cf9f8 in glXChooseFBConfig () from /lib/x86_64-linux-gnu/libGLX.so.0
31 0x00007fb748646f6a in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so
32 0x00007fb748644450 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so
33 0x00007fb7486421b7 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so
34 0x00007fb79838262d in QOpenGLContext::create() () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
35 0x00007fb74bb4303c in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes/KDEPlasmaPlatformTheme.so
36 0x00007fb797eb7aaf in qt_call_pre_routines () at kernel/qcoreapplication.cpp:317
37 QCoreApplicationPrivate::init (this=<optimized out>) at kernel/qcoreapplication.cpp:849
38 0x00007fb7983379dc in QGuiApplicationPrivate::init() () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
39 0x00007fb798b684c9 in QApplicationPrivate::init() () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
40 0x0000557950f1d597 in main ()
```

Add read rule to allow reading @{pid}/comm.

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


(cherry picked from commit 2597fd5db8)

948cbb56 abstractions/nvidia: allow reading @{pid}/comm
2022-11-27 13:07:09 +00:00
Christian Boltz
8ec5f81382 Merge lsb_release: allow cat and cut
lsb_release fails on Debian Sid:

```
$ sudo aa-exec -p lsb_release lsb_release
/usr/bin/lsb_release: 70: cut: Permission denied
/usr/bin/lsb_release: 70: cut: Permission denied
```

```
$ sudo aa-exec -p lsb_release lsb_release -h
/usr/bin/lsb_release: 11: cat: Permission denied
```

```
type=AVC msg=audit(1669540199.087:2680): apparmor="DENIED"
operation="exec" profile="lsb_release" name="/usr/bin/cut" pid=17419
comm="lsb_release" requested_mask="x" denied_mask="x" fsuid=0
ouid=0FSUID="root" OUID="root"
```

```
type=AVC msg=audit(1669540392.244:2944): apparmor="DENIED"
operation="exec" profile="lsb_release" name="/usr/bin/cat" pid=17847
comm="lsb_release" requested_mask="x" denied_mask="x" fsuid=0
ouid=0FSUID="root" OUID="root"
```

Update profile to allow lsb_release script to invoke required
executables.

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


(cherry picked from commit 495f68c797)

f596a176 lsb_release: allow cat and cut
2022-11-27 13:00:32 +00:00
John Johansen
1312cf4768 libapparmor: fix expect library version to bump in 3.0.8 release
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-11-21 17:09:28 -08:00
John Johansen
474a12ebe8 Prepare for AppArmor 3.0.8 release
- update version file
- update library version

Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-11-21 16:54:32 -08:00
Christian Ehrhardt
8b8fe03f1e Allow access to possible cpus for glibc-2.36
Glibc in 2.36 and later will [1] access sysfs at
/sys/devices/system/cpu/possible when usig sysconf
for _SC_NPROCESSORS_CONF.

That will make a lot of different code, for example
anything linked against libnuma, trigger this apparmor
denial.

  apparmor="DENIED" operation="open" class="file" ...
  name="/sys/devices/system/cpu/possible" ...
  requested_mask="r" denied_mask="r" fsuid=0 ouid=0

This entry seems rather safe, and it follows others
that are already in place. Instead of fixing each
software individually this should go into the base
profile as well.

Initially reported via
https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1989073
Fixes: https://gitlab.com/apparmor/apparmor/-/issues/267
MR: none - ML
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit c159d0925a)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-11-14 21:47:41 -08:00
John Johansen
57994dfcda Merge Adds WSL programmatic management of /etc/resolv.conf.
When WSL automatically generates a resolv.conf for an instance, the /etc/resolv.conf file is a symlink to /mnt/wsl/resolv.conf. This patch adds an entry for this to the other policies to handle such management.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/935
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit 8fa77e9e6c)

5232eaa2 Adds /mnt/wsl/resolv.conf to nameservices.
2022-11-08 18:14:08 +00:00
John Johansen
18cf5bffde Merge Allow reading /sys/devices/system/cpu/possible
... in the dnsmasq//libvirt_leaseshelper profile

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

I propose this patch for 3.0, 3.1 and master.

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


(cherry picked from commit 37f0f77425)

ace8e044 Allow reading /sys/devices/system/cpu/possible
2022-11-08 18:11:37 +00:00
John Johansen
d71b9ade1a Merge [3.0] Use open instead of codecs.open to fix line breaks
`codecs.open()` splits lines at unexpected characters like 0x1d.

Switch `open_file_*()` to use `open()` which does not have this problem.
(Note: 3.1 and master already use `open()`.)

This fixes the test failure introduced in the 3.0 branch in commit
ea681c4638 which contains an example log
with a 0x1d character.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/945
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2022-11-06 15:33:07 +00:00
Christian Boltz
e6ed0b6c42 Use open instead of codecs.open to fix line breaks
`codecs.open()` splits lines at unexpected characters like 0x1d.

Switch `open_file_*()` to use `open()` which does not have this problem.
(Note: 3.1 and master already use `open()`.)

This fixes the test failure introduced in the 3.0 branch in commit
ea681c4638 which contains an example log
with a 0x1d character.
2022-11-04 20:23:43 +01:00
John Johansen
e92a8c8f1b Merge Hardcode and check the expected libapparmor.so name/number
... to prevent wrong/unexpected numbering (like
https://gitlab.com/apparmor/apparmor/-/issues/266) in future releases.

I propose this patch for master and 3.1.

Backporting to 3.0 and 2.x might also make sense, but of course needs a different .so number.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/915
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
(backported from commit bed1471144)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-10-29 03:13:35 -07:00
John Johansen
ea681c4638 Merge libapparmor: allow parsing of logs with 0x1d + uppercase items
audit.log lines on Arch have an additional FSUID="username" OUID="username",
separated from the previous part of the log line with 0x1d.

Extend the log parsing to accept 0x1d as whitespace, and to recognize
(and ignore) FSUID and OUID.

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

Also add one of the log lines from #271 as test_multi test case.

I propose this patch for 3.0..master.

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

(cherry picked from commit 0d61139e2a)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-10-29 03:07:27 -07:00
John Johansen
010b0bd081 Merge syslog-ng: allow reading *.journal in flatter directory structure
On openSUSE Leap 15.4 (and probably also 15.3), the journal lives in
/var/log/journal/*.journal - without an additional subdirectory level.

I propose this patch for 2.13..master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/932
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2022-10-28 05:57:26 -07:00
Christian Boltz
6a0f7e813c Merge samba-rpcd-spoolss: allow mkdir /var/cache/samba/printing/
Fixes: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1993572

I propose this fix for 3.0..master.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/937
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>


(cherry picked from commit fab4b4e762)

6920daea samba-rpcd-spoolss: allow mkdir /var/cache/samba/printing/
2022-10-27 22:34:25 +00:00
Christian Boltz
d9ea198fe4 Merge abstactions/kde: update for kwinrc, kdedefaults/* files
GUI applications such as KDE dragon player, qTox, LibreOffice tries to
access .config/kwinrc, .config/kdedefaults/kwinrc and
.config/kdedefaults/kdeglobals.

Update abstractions/kde to fix denials for applications running under
KDE.

Some examples:
```
type=AVC msg=audit(1666458796.112:5561): apparmor="DENIED" operation="open" profile="libreoffice-soffice" name="/home/vincas/.config/kdedefaults/kdeglobals" pid=43868 comm="soffice.bin" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000FSUID="vincas" OUID="vincas"
type=AVC msg=audit(1666458796.204:5683): apparmor="DENIED" operation="open" profile="libreoffice-soffice" name="/home/vincas/.config/kdedefaults/kwinrc" pid=43868 comm="soffice.bin" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000FSUID="vincas" OUID="vincas"

```
```
type=AVC msg=audit(1666462415.255:3640): apparmor="DENIED" operation="open" profile="kde-dragon-player" name="/home/vincas/.config/kdedefaults/kdeglobals" pid=8344 comm="dragon" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000FSUID="vincas" OUID="vincas"
type=AVC msg=audit(1666462415.343:3641): apparmor="DENIED" operation="open" profile="kde-dragon-player" name="/home/vincas/.config/kdedefaults/kwinrc" pid=8344 comm="dragon" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000FSUID="vincas" OUID="vincas"
```

```
type=AVC msg=audit(1666459466.968:5852): apparmor="DENIED" operation="open" profile="qtox" name="/home/vincas/.config/kdedefaults/kdeglobals" pid=44561 comm="qtox" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000FSUID="vincas" OUID="vincas"
type=AVC msg=audit(1666459467.076:6057): apparmor="DENIED" operation="open" profile="qtox" name="/home/vincas/.config/kdedefaults/kwinrc" pid=44561 comm="qtox" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000FSUID="vincas" OUID="vincas"
type=AVC msg=audit(1666459467.076:6058): apparmor="DENIED" operation="open" profile="qtox" name="/home/vincas/.config/kwinrc" pid=44561 comm="qtox" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000FSUID="vincas" OUID="vincas"

```

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


(cherry picked from commit 18d1b06b0c)

d9dc0b61 abstactions/kde: update for kwinrc, kdedefaults/* files
2022-10-22 19:28:51 +00:00
Christian Boltz
7ebb259610 Merge [2.13+3.0] Use string startswith() and endswith() methods
... instead of slicing to check for prefixes and suffixes.

This change prevents a crash in aa-mergeprof - if `replacement` is empty,
trying to access `replacement[0]` causes an IndexError.
Using `.startswith()` works without crashing.

This backports parts of the severity.py changes in
commit 091c6ad59d
by Mark Grassi.

I propose this fix for 2.13 and 3.0. (3.1 and master already have this fix.)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/931
Approved-by: Jon Tourville <jon.tourville@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2022-10-11 16:18:27 +00:00
Christian Boltz
e1714b9631 Use string startswith() and endswith() methods
... instead of slicing to check for prefixes and suffixes.

This change prevents a crash in aa-mergeprof - if `replacement` is empty,
trying to access `replacement[0]` causes an IndexError.
Using `.startswith()` works without crashing.

This backports parts of the severity.py changes in
commit 091c6ad59d
by Mark Grassi.
2022-10-09 20:46:35 +02:00
Christian Boltz
e8c7f0f84f Merge parser: fix DISTRO variable in Makefile
A single '$()' results in variable expansion, which makes
"$(rpm --eval ..)" always an empty string.

Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>

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


(cherry picked from commit 05d7bdd655)

1df547ee parser: fix DISTRO variable in Makefile
2022-10-07 19:54:21 +00:00
John Johansen
505a3fbc59 Merge profiles/apparmor.d: Update samba profile
Fixes: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1990692
Signed-off-by: Spyros Seimenis <spyros.seimenis@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/926
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit e1cc90f3a2)

96aff5a5 profiles/apparmor.d: Update samba profile
2022-10-01 10:20:44 +00:00
Christian Boltz
b4c7e18f55 Merge profiles: permit php-fpm pid files directly under run/
The upstream php-fpm.conf file carries the following pid file example
path:
  [global]
  ; Pid file
  ; Note: the default prefix is @EXPANDED_LOCALSTATEDIR@
  ; Default Value: none
  ;pid = run/php-fpm.pid

Add this path to profiles/apparmor.d/php-fpm, alongside the current
nested "@{run}/php{,-fpm}/php*-fpm.pid" wildcard.

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

Suggested-by: Ali Abdallah <ali.abdallah@suse.com>
Signed-off-by: David Disseldorp <ddiss@suse.de>

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


(cherry picked from commit d024100efe)

d8533ec8 profiles: permit php-fpm pid files directly under run/
2022-08-26 10:36:24 +00:00
John Johansen
66118dc3e0 Merge dnsmasq: Add missing r permissions for libvirt_leaseshelper
Note: This was reported for /usr/libexec/libvirt_leaseshelper, but since
this is probably unrelated to the path or a path change, this commit
also adds r permissions for the previous path.

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

I propose this patch for 3.0 and master (optionally also for 2.12 and 2.13 - please tell me if you want that after reviewing the patch, or just merge ;-)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/905
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>


(cherry picked from commit f51049ea2e)

c9c5208f dnsmasq: Add missing r permissions for libvirt_leaseshelper
2022-08-22 21:45:07 +00:00
Christian Boltz
79044b98e4 Merge dnsmasq: allow paths for podman dnsname plugin in rootless mode
In rootless mode, files needed to access are under /run/user/, so those needs to be defined separately.

similar change than https://gitlab.com/apparmor/apparmor/-/merge_requests/800 but adds permissions for rootless mode.

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


(cherry picked from commit 406b6398af)

86069dd9 dnsmasq: allow paths for podman dnsname plugin in rootless mode
2022-08-22 11:57:35 +00:00
Christian Boltz
ae1c30e337 Merge Set (instead of compare) exresult
Interestingly this accidentally worked because `if exresult` is true for
both a non-empty string ("PASS") as well as a real `True` value.

Found by Mark Grassi as part of
https://gitlab.com/apparmor/apparmor/-/merge_requests/906

I propose this patch for all branches.

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


(cherry picked from commit c06ea77445)

5a2fb856 Set (instead of compare) exresult
2022-08-16 19:26:43 +00:00
John Johansen
0ead606d9e Prepoare for AppArmor 3.0.7 release
- update version file

Signed-off-by: John Johansen <john.johansen@canonical.com>
2022-08-09 01:56:58 -07:00
Georgia Garcia
20c28f25ce Merge Fix setuptools version detection in buildpath.py
libraries/libapparmor/swig/python/test/buildpath.py:
The changes introduced in
cc7f549665
targetted a wrong setuptools version (61.2).
The change in build directory naming has been introduced with 62.0.

Fixes #259 
Fixes #39

Closes #39 and #259
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/904
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>


(cherry picked from commit a555ccd9f4)

fda39098 Fix setuptools version detection in buildpath.py
1ff0c2c7 Use basepath.py in profiles Makefile
2022-08-03 17:22:25 +00:00
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
221 changed files with 2492 additions and 571 deletions

10
.gitignore vendored
View File

@@ -4,6 +4,8 @@ binutils/aa-enabled
binutils/aa-enabled.1
binutils/aa-exec
binutils/aa-exec.1
binutils/aa-features-abi
binutils/aa-features-abi.1
binutils/aa-status
binutils/aa-status.8
binutils/cJSON.o
@@ -12,6 +14,7 @@ parser/po/*.mo
parser/af_names.h
parser/cap_names.h
parser/generated_cap_names.h
parser/generated_af_names.h
parser/tst_lib
parser/tst_misc
parser/tst_regex
@@ -157,6 +160,7 @@ libraries/libapparmor/swig/perl/libapparmor_wrap.c
libraries/libapparmor/swig/perl/libapparmor_wrap.o
libraries/libapparmor/swig/perl/pm_to_blib
libraries/libapparmor/swig/python/LibAppArmor.py
libraries/libapparmor/swig/python/LibAppArmor.egg-info/
libraries/libapparmor/swig/python/build/
libraries/libapparmor/swig/python/libapparmor_wrap.c
libraries/libapparmor/swig/python/Makefile
@@ -173,7 +177,7 @@ libraries/libapparmor/swig/ruby/LibAppArmor_wrap.c
libraries/libapparmor/swig/ruby/LibAppArmor_wrap.o
libraries/libapparmor/swig/ruby/Makefile
libraries/libapparmor/swig/ruby/Makefile.in
libraries/libapparmor/swig/ruby/Makefile.new
libraries/libapparmor/swig/ruby/Makefile.bak
libraries/libapparmor/swig/ruby/Makefile.ruby
libraries/libapparmor/swig/ruby/mkmf.log
libraries/libapparmor/testsuite/.deps
@@ -201,8 +205,12 @@ utils/*.tmp
utils/po/*.mo
utils/apparmor/*.pyc
utils/apparmor/rule/*.pyc
utils/apparmor.egg-info/
utils/build/
utils/htmlcov/
utils/test/common_test.pyc
utils/test/.coverage
utils/test/coverage-report.txt
utils/test/htmlcov/
utils/vim/apparmor.vim
utils/vim/apparmor.vim.5

View File

@@ -1,7 +1,7 @@
---
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 zlib1g-dev
- 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

View File

@@ -156,12 +156,12 @@ install-arch: arch
install -m 755 -d ${SBINDIR}
ln -sf aa-status ${SBINDIR}/apparmor_status
install -m 755 ${SBINTOOLS} ${SBINDIR}
ln -sf aa-status.8 ${DESTDIR}/${MANDIR}/man8/apparmor_status.8
.PHONY: install-indep
install-indep: indep
$(MAKE) -C po install NAME=${NAME} DESTDIR=${DESTDIR}
$(MAKE) install_manpages DESTDIR=${DESTDIR}
ln -sf aa-status.8 ${DESTDIR}/${MANDIR}/man8/apparmor_status.8
ifndef VERBOSE
.SILENT: clean

View File

@@ -83,7 +83,7 @@ if B<aa-enabled> doesn't have enough privileges to read the apparmor control fil
=item B<10>
AppArmor is enabled but does not have access to shared LSM interaces.
AppArmor is enabled but does not have access to shared LSM interfaces.
=item B<64>

View File

@@ -32,7 +32,7 @@ B<aa-features-abi> [OPTIONS] <SOURCE> [OUTPUT OPTIONS]
B<aa-features-abi> is used to extract a features abi and output to
either stdout or a specified file. A SOURCE_OPTION must be specified.
If an output option is not specified the features abi is writen to
If an output option is not specified the features abi is written to
stdout.
=head1 OPTIONS

View File

@@ -20,7 +20,7 @@ void print_help(const char *command)
{
printf(_("%s: [options]\n"
" options:\n"
" -x | --exclusive Shared interfaces must be availabe\n"
" -x | --exclusive Shared interfaces must be available\n"
" -q | --quiet Don't print out any messages\n"
" -h | --help Print help\n"),
command);

View File

@@ -124,7 +124,7 @@ static char **parse_args(int argc, char **argv)
{"stdout", no_argument, 0, ARG_STDOUT},
};
while ((opt = getopt_long(argc, argv, "+dvhxl:w:", long_opts, NULL)) != -1) {
while ((opt = getopt_long(argc, argv, "+dvhxf:l:w:", long_opts, NULL)) != -1) {
switch (opt) {
case 'd':
opt_debug = true;
@@ -181,7 +181,7 @@ int main(int argc, char **argv)
error("failed to extract features abi from the kernel");
}
if (opt_file) {
int in = open(opt_file, O_RDONLY);
in = open(opt_file, O_RDONLY);
if (in == -1)
error("failed to open file '%s'", opt_file);
rc = aa_features_new_from_file(&features, in);

View File

@@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -134,7 +135,16 @@ static int get_profiles(struct profile **profiles, size_t *n) {
while (getline(&line, &len, fp) != -1) {
struct profile *_profiles;
autofree char *status = NULL;
autofree char *name = strdup(aa_splitcon(line, &status));
autofree char *name = NULL;
char *tmpname = aa_splitcon(line, &status);
if (!tmpname) {
dfprintf(stderr, "Error: failed profile name split of '%s'.\n", line);
ret = AA_EXIT_INTERNAL_ERROR;
// skip this entry and keep processing
continue;
}
name = strdup(tmpname);
if (status)
status = strdup(status);
@@ -524,16 +534,19 @@ static int detailed_output(FILE *json) {
} else {
fprintf(json, "%s\"%s\": [{\"profile\": \"%s\", \"pid\": \"%s\", \"status\": \"%s\"}",
// first element will be a unique executable
i == 0 && j == 0 ? "" : "], ",
j == 0 ? "" : "], ",
filtered[j].exe, filtered[j].profile, filtered[j].pid, filtered[j].mode);
}
}
if (j > 0) {
fprintf(json, "]");
}
}
free_processes(filtered, nfiltered);
}
if (json) {
fprintf(json, "%s}}\n", nprocesses > 0 ? "]" : "");
fprintf(json, "}}\n");
}
exit:

View File

@@ -1,13 +1,14 @@
# Copyright (C) 2015 Canonical Ltd
# This file is distributed under the same license as the AppArmor package.
# John Johansen <john.johansen@canonical.com>, 2015.
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Canonical Ltd
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, 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"
"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"
@@ -16,51 +17,57 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../aa_enabled.c:26
#: ../aa_enabled.c:21
#, c-format
msgid ""
"%s: [options]\n"
" options:\n"
" -x | --exclusive Shared interfaces must be availabe\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
#: ../aa_enabled.c:37
#, c-format
msgid "No - not available on this system.\n"
msgstr ""
#: ../aa_enabled.c:74
#: ../aa_enabled.c:41
#, c-format
msgid "No - disabled at boot.\n"
msgstr ""
#: ../aa_enabled.c:77
#: ../aa_enabled.c:45
#, c-format
msgid "Maybe - policy interface not available.\n"
msgstr ""
#: ../aa_enabled.c:81
#: ../aa_enabled.c:50
#, c-format
msgid "Maybe - insufficient permissions to determine availability.\n"
msgstr ""
#: ../aa_enabled.c:84
#: ../aa_enabled.c:54
#, c-format
msgid "Error - '%s'\n"
msgid "Partially - public shared interfaces are not available.\n"
msgstr ""
#: ../aa_enabled.c:58
#, c-format
msgid "Error - %s\n"
msgstr ""
#: ../aa_enabled.c:73
#, c-format
msgid "unknown or incompatible options\n"
msgstr ""
#: ../aa_enabled.c:87
#, c-format
msgid "unknown option '%s'\n"
msgstr ""
#: ../aa_enabled.c:98
#, c-format
msgid "Yes\n"
msgstr ""

55
binutils/po/aa_exec.pot Normal file
View File

@@ -0,0 +1,55 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Canonical Ltd
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: apparmor@lists.ubuntu.com\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"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../aa_exec.c:50
#, c-format
msgid ""
"USAGE: %s [OPTIONS] <prog> <args>\n"
"\n"
"Confine <prog> with the specified PROFILE.\n"
"\n"
"OPTIONS:\n"
" -p PROFILE, --profile=PROFILE\t\tPROFILE to confine <prog> with\n"
" -n NAMESPACE, --namespace=NAMESPACE\tNAMESPACE to confine <prog> in\n"
" -d, --debug\t\t\t\tshow messages with debugging information\n"
" -i, --immediate\t\t\tchange profile immediately instead of at exec\n"
" -v, --verbose\t\t\t\tshow messages with stats\n"
" -h, --help\t\t\t\tdisplay this help\n"
"\n"
msgstr ""
#: ../aa_exec.c:65
#, c-format
msgid "[%ld] aa-exec: ERROR: "
msgstr ""
#: ../aa_exec.c:76
#, c-format
msgid "[%ld] aa-exec: DEBUG: "
msgstr ""
#: ../aa_exec.c:89
#, c-format
msgid "[%ld] "
msgstr ""
#: ../aa_exec.c:107
#, c-format
msgid "[%ld] exec"
msgstr ""

View File

@@ -0,0 +1,51 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Canonical Ltd
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: apparmor@lists.ubuntu.com\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"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../aa_features_abi.c:53
#, c-format
msgid ""
"USAGE: %s [OPTIONS] <SOURCE> [OUTPUT OPTIONS]\n"
"\n"
"Output AppArmor feature abi from SOURCE to OUTPUT\n"
"OPTIONS:\n"
" -d, --debug show messages with debugging information\n"
" -v, --verbose show messages with stats\n"
" -h, --help display this help\n"
"SOURCE:\n"
" -f F, --file=F load features abi from file F\n"
" -x, --extract extract features abi from the kernel\n"
"OUTPUT OPTIONS:\n"
" --stdout default, write features to stdout\n"
" -w F, --write=F write features abi to the file F instead of stdout\n"
"\n"
msgstr ""
#: ../aa_features_abi.c:73
#, c-format
msgid "%s: ERROR: "
msgstr ""
#: ../aa_features_abi.c:85
#, c-format
msgid "%s: DEBUG: "
msgstr ""
#: ../aa_features_abi.c:98
msgid "\n"
msgstr ""

View File

@@ -1 +1 @@
3.0.0
3.0.9

View File

@@ -58,7 +58,7 @@ if test "$with_perl" = "yes"; then
AC_PATH_PROG(PERL, perl)
test -z "$PERL" && AC_MSG_ERROR([perl is required when enabling perl bindings])
perl_includedir="`$PERL -e 'use Config; print $Config{archlib}'`/CORE"
AC_CHECK_FILE($perl_includedir/perl.h, enable_perl=yes, enable_perl=no)
AS_IF([test -e "$perl_includedir/perl.h"], enable_perl=yes, enable_perl=no)
fi

View File

@@ -70,6 +70,10 @@ AppArmor extensions to the system are not available.
AppArmor is available on the system but has been disabled at boot.
=item B<EBUSY>
AppArmor is available but only via private interfaces.
=item B<ENOENT>
AppArmor is available (and maybe even enforcing policy) but the interface is

View File

@@ -159,6 +159,8 @@ typedef struct
char *fs_type;
char *flags;
char *src_name;
char *class;
} aa_log_record;
/**

View File

@@ -21,6 +21,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#ifdef __cplusplus

View File

@@ -13,7 +13,7 @@ AC_DEFUN([AC_PYTHON_DEVEL],[
PYTHON_VERSION=""
fi
AC_PATH_PROG([PYTHON_CONFIG],[`basename [$PYTHON]-config`])
AC_PATH_TOOL([PYTHON_CONFIG],[`basename [$PYTHON]-config`])
if test -z "$PYTHON_CONFIG"; then
AC_MSG_ERROR([Cannot find python$PYTHON_VERSION-config in your system path])
fi
@@ -66,17 +66,17 @@ variable to configure. See ``configure --help'' for reference.
fi
#
# Check if you have distutils, else fail
# Check if you have setuptools, else fail
#
AC_MSG_CHECKING([for the distutils Python package])
ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
if test -z "$ac_distutils_result"; then
AC_MSG_CHECKING([for the setuptools Python package])
ac_setuptools_result=`$PYTHON -c "import setuptools" 2>&1`
if test -z "$ac_setuptools_result"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([cannot import Python module "distutils".
AC_MSG_ERROR([cannot import Python module "setuptools".
Please check your Python installation. The error was:
$ac_distutils_result])
$ac_setuptools_result])
PYTHON_VERSION=""
fi
@@ -88,8 +88,8 @@ $ac_distutils_result])
PYTHON_CPPFLAGS=`$PYTHON_CONFIG --includes`
fi
if test -z "$PYTHON_CPPFLAGS"; then
python_path=`$PYTHON -c "import sys; import distutils.sysconfig;\
sys.stdout.write('%s\n' % distutils.sysconfig.get_python_inc());"`
python_path=`$PYTHON -c "import sys; import sysconfig;\
sys.stdout.write('%s\n' % sysconfig.get_path('include'));"`
if test -n "${python_path}"; then
python_path="-I$python_path"
fi
@@ -108,8 +108,8 @@ sys.stdout.write('%s\n' % distutils.sysconfig.get_python_inc());"`
if test -z "$PYTHON_LDFLAGS"; then
# (makes two attempts to ensure we've got a version number
# from the interpreter)
py_version=`$PYTHON -c "import sys; from distutils.sysconfig import *; \
sys.stdout.write('%s\n' % ''.join(get_config_vars('VERSION')))"`
py_version=`$PYTHON -c "import sys; import sysconfig; \
sys.stdout.write('%s\n' % ''.join(sysconfig.get_config_vars('VERSION')))"`
if test "$py_version" == "[None]"; then
if test -n "$PYTHON_VERSION"; then
py_version=$PYTHON_VERSION
@@ -119,8 +119,8 @@ sys.stdout.write("%s\n" % sys.version[[:3]])"`
fi
fi
PYTHON_LDFLAGS=`$PYTHON -c "import sys; from distutils.sysconfig import *; \
sys.stdout.write('-L' + get_python_lib(0,1) + ' -lpython\n')"`$py_version`$PYTHON -c \
PYTHON_LDFLAGS=`$PYTHON -c "import sys; import sysconfig; \
sys.stdout.write('-L' + sysconfig.get_path('stdlib') + ' -lpython\n')"`$py_version`$PYTHON -c \
"import sys; sys.stdout.write('%s' % getattr(sys,'abiflags',''))"`
fi
AC_MSG_RESULT([$PYTHON_LDFLAGS])
@@ -131,8 +131,8 @@ sys.stdout.write('-L' + get_python_lib(0,1) + ' -lpython\n')"`$py_version`$PYTHO
#
AC_MSG_CHECKING([for Python site-packages path])
if test -z "$PYTHON_SITE_PKG"; then
PYTHON_SITE_PKG=`$PYTHON -c "import sys; import distutils.sysconfig; \
sys.stdout.write('%s\n' % distutils.sysconfig.get_python_lib(0,0));"`
PYTHON_SITE_PKG=`$PYTHON -c "import sys; import sysconfig; \
sys.stdout.write('%s\n' % sysconfig.get_path('purelib'));"`
fi
AC_MSG_RESULT([$PYTHON_SITE_PKG])
AC_SUBST([PYTHON_SITE_PKG])
@@ -146,8 +146,8 @@ sys.stdout.write('%s\n' % distutils.sysconfig.get_python_lib(0,0));"`
PYTHON_EXTRA_LIBS=''
fi
if test -z "$PYTHON_EXTRA_LIBS"; then
PYTHON_EXTRA_LIBS=`$PYTHON -c "import sys; import distutils.sysconfig; \
conf = distutils.sysconfig.get_config_var; \
PYTHON_EXTRA_LIBS=`$PYTHON -c "import sys; import sysconfig; \
conf = sysconfig.get_config_var; \
sys.stdout.write('%s %s %s\n' % (conf('BLDLIBRARY'), conf('LOCALMODLIBS'), conf('LIBS')))"`
fi
AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
@@ -162,8 +162,8 @@ sys.stdout.write('%s %s %s\n' % (conf('BLDLIBRARY'), conf('LOCALMODLIBS'), conf(
PYTHON_EXTRA_LDFLAGS=''
fi
if test -z "$PYTHON_EXTRA_LDFLAGS"; then
PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import sys; import distutils.sysconfig; \
conf = distutils.sysconfig.get_config_var; \
PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import sys; import sysconfig; \
conf = sysconfig.get_config_var; \
sys.stdout.write('%s\n' % conf('LINKFORSHARED'))"`
fi
AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])

View File

@@ -26,9 +26,10 @@ INCLUDES = $(all_includes)
# For more information, see:
# http://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html
#
AA_LIB_CURRENT = 8
AA_LIB_REVISION = 0
AA_LIB_AGE = 7
AA_LIB_CURRENT = 9
AA_LIB_REVISION = 5
AA_LIB_AGE = 8
EXPECTED_SO_NAME = libapparmor.so.1.8.5
SUFFIXES = .pc.in .pc
@@ -38,7 +39,7 @@ include $(COMMONDIR)/Make.rules
BUILT_SOURCES = grammar.h scanner.h af_protos.h
AM_LFLAGS = -v
AM_YFLAGS = -d -p aalogparse_
AM_CFLAGS = -Wall $(EXTRA_WARNINGS) -fPIC
AM_CFLAGS = -Wall $(EXTRA_WARNINGS) -fPIC -flto-partition=none
AM_CPPFLAGS = -D_GNU_SOURCE -I$(top_srcdir)/include/
scanner.h: scanner.l
$(LEX) -v $<
@@ -77,4 +78,8 @@ tst_kernel_LDFLAGS = -pthread
check_PROGRAMS = tst_aalogmisc tst_features tst_kernel
TESTS = $(check_PROGRAMS)
.PHONY: check-local
check-local:
test -f ./.libs/$(EXPECTED_SO_NAME) || { echo '*** unexpected .so name/number for libapparmor (expected $(EXPECTED_SO_NAME), the actual filename is shown below) ***' ; ls -l ./.libs/libapparmor.so.*.* ; exit 1; }
EXTRA_DIST = grammar.y scanner.l libapparmor.map libapparmor.pc

View File

@@ -194,6 +194,8 @@ static int features_dir_cb(int dirfd, const char *name, struct stat *st,
if (features_snprintf(fst, "%s {", name) == -1)
return -1;
/* Handle symlink here. See _aa_dirat_for_each in private.c */
if (S_ISREG(st->st_mode)) {
ssize_t len;
size_t remaining;

View File

@@ -38,7 +38,7 @@
#if (YYDEBUG != 0)
#define debug_unused_ /* nothing */
#else
#define no_debug_unused_ unused_
#define debug_unused_ unused_
#endif
aa_log_record *ret_record;
@@ -46,7 +46,7 @@ aa_log_record *ret_record;
/* Since we're a library, on any errors we don't want to print out any
* error messages. We should probably add a debug interface that does
* emit messages when asked for. */
void aalogparse_error(unused_ void *scanner, no_debug_unused_ char const *s)
void aalogparse_error(unused_ void *scanner, debug_unused_ char const *s)
{
#if (YYDEBUG != 0)
printf("ERROR: %s\n", s);
@@ -159,7 +159,9 @@ aa_record_event_type lookup_aa_event(unsigned int type)
%token TOK_KEY_NAMESPACE
%token TOK_KEY_ERROR
%token TOK_KEY_FSUID
%token TOK_KEY_FSUID_UPPER
%token TOK_KEY_OUID
%token TOK_KEY_OUID_UPPER
%token TOK_KEY_UID
%token TOK_KEY_AUID
%token TOK_KEY_SAUID
@@ -185,7 +187,9 @@ aa_record_event_type lookup_aa_event(unsigned int type)
%token TOK_KEY_FSTYPE
%token TOK_KEY_FLAGS
%token TOK_KEY_SRCNAME
%token TOK_KEY_CLASS
%token TOK_SOCKLOGD_KERNEL
%token TOK_SYSLOG_KERNEL
%token TOK_SYSLOG_USER
@@ -232,24 +236,28 @@ dmesg_type: TOK_DMESG_STAMP TOK_AUDIT TOK_COLON key_type audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($1); }
;
syslog_id: TOK_ID TOK_SYSLOG_KERNEL { free($1); }
| TOK_SOCKLOGD_KERNEL { }
;
syslog_type:
syslog_date TOK_ID TOK_SYSLOG_KERNEL audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($2); }
| syslog_date TOK_ID TOK_SYSLOG_KERNEL key_type audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($2); }
| syslog_date TOK_ID TOK_SYSLOG_KERNEL TOK_DMESG_STAMP audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($2); free($4); }
| syslog_date TOK_ID TOK_SYSLOG_KERNEL TOK_DMESG_STAMP key_type audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($2); free($4); }
syslog_date syslog_id audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; }
| syslog_date syslog_id key_type audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; }
| syslog_date syslog_id TOK_DMESG_STAMP audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($3); }
| syslog_date syslog_id TOK_DMESG_STAMP key_type audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($3); }
/* needs update: hard newline in handling mutiline log messages */
| syslog_date TOK_ID TOK_SYSLOG_KERNEL TOK_DMESG_STAMP TOK_AUDIT TOK_COLON key_type audit_id audit_user_msg_partial_tail
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($2); }
| syslog_date TOK_ID TOK_SYSLOG_KERNEL TOK_DMESG_STAMP TOK_AUDIT TOK_COLON key_type audit_id audit_user_msg_tail
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($2); }
| syslog_date TOK_ID TOK_SYSLOG_KERNEL TOK_DMESG_STAMP TOK_AUDIT TOK_COLON key_type audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($2); free($4); }
| syslog_date TOK_ID TOK_SYSLOG_KERNEL TOK_AUDIT TOK_COLON key_type audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($2); }
| syslog_date syslog_id TOK_DMESG_STAMP TOK_AUDIT TOK_COLON key_type audit_id audit_user_msg_partial_tail
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($3); }
| syslog_date syslog_id TOK_DMESG_STAMP TOK_AUDIT TOK_COLON key_type audit_id audit_user_msg_tail
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($3); }
| syslog_date syslog_id TOK_DMESG_STAMP TOK_AUDIT TOK_COLON key_type audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($3); }
| syslog_date syslog_id TOK_AUDIT TOK_COLON key_type audit_id key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; }
| syslog_date TOK_ID TOK_SYSLOG_USER key_list
{ ret_record->version = AA_RECORD_SYNTAX_V2; free($2); }
;
@@ -346,6 +354,10 @@ key: TOK_KEY_OPERATION TOK_EQUALS TOK_QUOTED_STRING
{ ret_record->fsuid = $3;}
| TOK_KEY_OUID TOK_EQUALS TOK_DIGITS
{ ret_record->ouid = $3;}
| TOK_KEY_FSUID_UPPER TOK_EQUALS TOK_QUOTED_STRING
{ free($3);} /* Ignore - fsuid username */
| TOK_KEY_OUID_UPPER TOK_EQUALS TOK_QUOTED_STRING
{ free($3);} /* Ignore - ouid username */
| TOK_KEY_SAUID TOK_EQUALS TOK_DIGITS
{ /* Ignore - Source audit ID from user AVC messages */ }
| TOK_KEY_HOSTNAME TOK_EQUALS safe_string
@@ -420,6 +432,8 @@ key: TOK_KEY_OPERATION TOK_EQUALS TOK_QUOTED_STRING
ret_record->event = AA_RECORD_INVALID;
ret_record->info = $1;
}
| TOK_KEY_CLASS TOK_EQUALS TOK_QUOTED_STRING
{ ret_record->class = $3; }
;
apparmor_event:

View File

@@ -43,10 +43,137 @@
__asm__ (".symver " #real "," #name "@" #version)
#define default_symbol_version(real, name, version) \
__asm__ (".symver " #real "," #name "@@" #version)
#define DLLEXPORT __attribute__((visibility("default"),externally_visible))
#define UNCONFINED "unconfined"
#define UNCONFINED_SIZE strlen(UNCONFINED)
/*
* AppArmor kernel interfaces. Potentially used by this code to
* implement the various library functions.
*
*
* /sys/module/apparmor/parameters/ *
*
* Available on all kernels, some options may not be available and policy
* may block access.
* audit - normal,quiet_denied,quiet,noquiet,all
* debug (bool) - turn on debug messages if enabled during compile
* hash_policy (bool) - provide a hash of loaded policy
* logsyscall (bool) - ignored
* paranoid_load (bool) - whether full policy checks are done. Should only
* be disabled for embedded device kernels
* audit_header (bool) - include "apparmor=<mode> in messages"
* enabled (bool) - whether apparmor is enabled. This can be
* different than whether apparmor is available.
* See virtualization and LSM stacking.
* lock_policy (bool) - one way trigger. Once set policy can not be
* loaded, replace, removed.
* mode - global policy namespace control of whether
* apparmor is in "enforce", "complain"
* path_max - maximum path size. Can always be read but
* can only be set on some kernels.
*
* securityfs/apparmor - usually mounted at /sys/kernel/security/apparmor/ *
* .access - transactional interface used to query kernel
* .ns_level - RO policy namespace level of current task
* .ns_name - RO current policy namespace of current task
* .ns_stacked - RO boolean if stacking is in use with the namespace
* .null - special device file used to redirect closed fds to
* profiles - RO virtualized text list of visible loaded profiles
* .remove - WO names of profiles to remove
* .replace - WO binary policy to replace (will load if not present)
* .load - WO binary policy to load (will fail if already present)
* revision - RO unique incrementing revision number for policy
* .stacked - RO boolean if label is currently stacked
* features/ - RO feature set supported by kernel
* policy/ - RO policy loaded into kernel
*
*
* /proc/<tid>/attr/apparmor/ *
* New proc attr interface compatible with LSM stacking. Available even
* when LSM stacking is not in use.
* current - see /proc/<tid>/attr/current
* exec - see /proc/<tid>/attr/exec
* prev - see /proc/<tid>/attr/prev
*
* /proc/<tid>/attr/ * Old proc attr interface shared between LSMs goes
* to first registered LSM that wants the proc interface, but can be
* virtualized by setting the display LSM. So if LSM stacking is in
* use this interface may belong to another LSM. Use
* /proc/<tid>/attr/apparmor/ *
* first if possible, and do NOT use if
* /sys/module/apparmor/parameters/enabled=N.
* Note: older version of the library only used this interface and did not
* check if it was available. Which could lead to weird failures if
* another LSM has claimed it. This version of the library tries to
* fix this problem, but unfortunately it is impossible to completely
* address, because access to interfaces required to determine
* whether apparmor owns the interface may be restricted, either
* by existing apparmor policy that has not been updated to use the
* new interface or by another LSM.
* current - current confinement
* display - LSM stacking. Which LSM currently owns the interface.
* exec - label to switch to at exec
* fscreate - unused by apparmor
* keycreate - unused by apparmor
* prev - when in HAT set to parent label
* sockcreate - unused by apparmor
*
*
* Below /proc/ interface combinations are documented on how the library
* currently behaves and how it used to behave. This serves to document
* known failure points as we can not entirely fix this mess.
* Note: userspace applications using the interface directly have all
* the issues/failures of AppArmor 2.x unless they have specifically
* been updated to deal with this mess.
*
*
* AppArmor 2.x Lib
*
* LSM AA sys sys proc/ proc/ user
* Stk | Blt | LSM | enabl | avail | aa/ | * | space |
* ----+-----+-------+-------+-------+-------+-------+-------+--------+
* N | N | - | - | - | - | N | AA2.x | - |
* N | N | other | - | - | - | N | AA2.x | FAIL |
* N | N | other |denied | - | - | N | AA2.x | FAIL |
* N | Y | - | N | - | - | N | AA2.x | - |
* N | Y | other | - | - | - | N | AA2.x | FAIL |
* N | Y | AA | - | - | - | Y | AA2.x | PASS |
* Y | N | - | - | - | - | N | AA2.x | - |
* Y | N | other | - | - | - | N | AA2.x | FAIL |
* Y | Y | - | N | - | - | N | AA2.x | - |
* Y | Y | other | - | - | - | N | AA2.x | FAIL |
* Y | Y | AA | - | - | - | Y | AA2.x | PASS |
* Y | Y | major | - | - | - | Y | AA2.x | PASS |
* Y | Y | minor | - | - | - | N | AA2.x | FAIL |
*
*
* AppArmor 3.x Lib - adds stacking support.
*
* Will FAIL in a few cases because it can not determine if apparmor
* is enabled and has control of the old interface. Not failing in these
* cases where AppArmor is available will result in regressions where
* the library will not work correctly with old kernels. In these
* cases its better that apparmor userspace is not used.
*
* AppArmor 3.x will avoid the failure cases if any of enabled, avail
* or the new proc interfaces are available to the task. AppArmor 3.x
* will also automatically add permissions to access the new proc
* interfaces so change_hat and change_profile won't experience these
* failures, it will only happen for confined applications hitting the
* interfaces and not using change_hat or change_profile.
*
* LSM AA sys sys proc/ proc/
* Stk | Blt | LSM | enabl | avail | aa/ | * |
* ----+-----+-------+-------+-------+-------+-------+-----------------
* Y/N | N | other | denied| NA | NA | Y | old interface avail
* Y/N | Y | other | denied| NA | NA | Y | old interface avail
* Y | Y | minor | denied| NA | NA | Y | old interface avail
* Y | Y | minor | denied| NA | denied| Y | old interface avail
* Y/N | Y | minor | denied| denied| denied| Y | old interface avail
*/
/**
* aa_find_mountpoint - find where the apparmor interface filesystem is mounted
* @mnt: returns buffer with the mountpoint string
@@ -93,25 +220,34 @@ int aa_find_mountpoint(char **mnt)
return rc;
}
// done as a macro so we can paste the param
/**
* pararm_check_base - return boolean value for PARAM
* PARAM: parameter to check
*
* Returns: 1 == Y
* 0 == N
* <0 == error
*
* done as a macro so we can paste the param
*/
#define param_check_base(PARAM) \
({ \
int rc, fd; \
fd = open("/sys/module/apparmor/parameters/" PARAM, O_RDONLY); \
if (fd == -1) { \
rc = errno; \
rc = -errno; \
} else { \
char buffer[2]; \
int size = read(fd, &buffer, 2); \
rc = errno; \
rc = -errno; \
close(fd); \
errno = rc; \
errno = -rc; \
if (size > 0) { \
if (buffer[0] == 'Y') \
rc = 0; \
rc = 1; \
else \
rc = ECANCELED; \
rc = 0; \
} \
} \
(rc); \
@@ -130,31 +266,37 @@ static void param_check_enabled_init_once(void)
static int param_check_enabled()
{
if (pthread_once(&param_enabled_ctl, param_check_enabled_init_once) == 0)
if (pthread_once(&param_enabled_ctl, param_check_enabled_init_once) == 0 && param_enabled >= 0)
return param_enabled;
/* fallback if not initialized OR we recorded an error when
* initializing.
*/
return param_check_base("enabled");
}
static int is_enabled(void)
{
return !param_check_enabled();
return param_check_enabled() == 1;
}
static void param_check_private_enabled_init_once(void)
{
param_enabled = param_check_base("private_enabled");
param_private_enabled = param_check_base("available");
}
static int param_check_private_enabled()
{
if (pthread_once(&param_private_enabled_ctl, param_check_private_enabled_init_once) == 0)
if (pthread_once(&param_private_enabled_ctl, param_check_private_enabled_init_once) == 0 && param_private_enabled >= 0)
return param_private_enabled;
return param_check_base("private_enabled");
/* fallback if not initialized OR we recorded an error when
* initializing.
*/
return param_check_base("available");
}
static int is_private_enabled(void)
{
return !param_check_private_enabled();
return param_check_private_enabled() == 1;
}
/**
@@ -174,15 +316,17 @@ int aa_is_enabled(void)
bool private = false;
rc = param_check_enabled();
if (rc) {
if (rc == ENOENT)
errno = ENOSYS;
else
errno = rc;
if (rc < 1) {
if (!is_private_enabled()) {
if (rc == 0)
errno = ECANCELED;
else if (rc == -ENOENT)
errno = ENOSYS;
else
errno = -rc;
if (!is_private_enabled())
return 0;
}
/* actually available but only on private interfaces */
private = true;
}
@@ -227,41 +371,128 @@ static inline pid_t aa_gettid(void)
* present.
*/
static pthread_once_t proc_attr_base_ctl = PTHREAD_ONCE_INIT;
static char *proc_attr_base = "/proc/%d/attr/%s";
static char *proc_attr_base_stacking = "/proc/%d/attr/apparmor/%s";
static char *proc_attr_base_unavailable = "/proc/%d/attr/apparmor/unavailable/%s";
static const char *proc_attr_base_old = "/proc/%d/attr/%s";
static const char *proc_attr_new_dir = "/proc/%d/attr/apparmor/";
static const char *proc_attr_base_stacking = "/proc/%d/attr/apparmor/%s";
static const char *proc_attr_base_unavailable = "/proc/%d/attr/apparmor/unavailable/%s";
static const char *proc_attr_base = NULL;
static int proc_stacking_present = -1; /* unknown */
static void proc_attr_base_init_once(void)
{
autofree char *tmp;
/* if we fail we just fall back to the default value */
if (asprintf(&tmp, "/proc/%d/attr/apparmor/current", aa_gettid())) {
autoclose int fd = open(tmp, O_RDONLY);
if (fd != -1)
if (asprintf(&tmp, proc_attr_new_dir, aa_gettid()) > 0) {
struct stat sb;
if (stat(tmp, &sb) == 0) {
proc_attr_base = proc_attr_base_stacking;
} else if (!is_enabled() && is_private_enabled()) {
/* new stacking interfaces aren't available and apparmor
* is disabled, but available. do not use the
* /proc/<pid>/attr/ * interfaces as they could be
* in use by another LSM
proc_stacking_present = 1;
return;
} else if (errno == ENOENT) {
/* no stacking - try falling back */
proc_stacking_present = 0;
} else if (errno == EACCES) {
/* the dir exists, but access is denied */
proc_stacking_present = 1;
proc_attr_base = proc_attr_base_stacking;
} /* else
denied by policy, or other error try falling back */
} else {
/* failed allocation - proc_attr_base stays NULL */
return;
}
/* check for new interface failed, see if we can fallback */
if (param_check_enabled() == 0) {
/* definate NO (not just an error) on enabled. Do not fall
* back to old shared proc interface
*
* First try an alternate check for private proc interface
*/
int enabled = param_check_private_enabled();
if (enabled == 1) {
/* the private interface exists and we can't
* fallback so just keep trying on the new
* interface.
*/
proc_attr_base = proc_attr_base_stacking;
} else if (enabled == 0) {
/* definite NO - no interface available */
proc_attr_base = proc_attr_base_unavailable;
} else {
/* error can't determine, proc_attr_base stays NULL */
}
} else if (param_check_enabled() == 1) {
/* apparmor is enabled, we can use the old interface */
proc_attr_base = proc_attr_base_old;
} else if (errno != EACCES) {
/* this shouldn't happen unless apparmor is not builtin
* or proc isn't mounted
*/
proc_attr_base = proc_attr_base_unavailable;
}
/* else default to pre-assigned value */
} /* else
denied by policy - proc_attr_base stays NULL */
return;
}
static char *procattr_path(pid_t pid, const char *attr)
{
char *path = NULL;
const char *tmp;
/* TODO: rework this with futex or userspace RCU so we can update
* the base value instead of continually using the same base
* after we have hit an error
*/
/* ignore failure, we just fallback to the default value */
(void) pthread_once(&proc_attr_base_ctl, proc_attr_base_init_once);
if (asprintf(&path, proc_attr_base, pid, attr) > 0)
if (proc_attr_base)
tmp = proc_attr_base;
else if (proc_stacking_present)
/* couldn't determine during init */
tmp = proc_attr_base_stacking;
else
/* couldn't determine during init and no stacking */
tmp = proc_attr_base_old;
if (asprintf(&path, tmp, pid, attr) > 0)
return path;
return NULL;
}
static int procattr_open(pid_t tid, const char *attr, int flags)
{
char *tmp;
int fd;
tmp = procattr_path(tid, attr);
if (!tmp) {
return -1;
}
fd = open(tmp, flags);
free(tmp);
/* Test is we can fallback to the old interface (this is ugly).
* If we haven't tried the old interface already
* proc_attr_base == proc_attr_base_old - no fallback
* else if is_enabled()
* apparmor is available on the old interface
* we do NOT use is_private_enabled() as
* 1. the new private interface would have been tried first above
* 2. that can be true even when another LSM is using the
* old interface where is_enabled() is only successful if
* the old interface is available to apparmor.
*/
if (fd == -1 && tmp != proc_attr_base_old && param_check_enabled() != 0) {
if (asprintf(&tmp, proc_attr_base_old, tid, attr) < 0)
return -1;
fd = open(tmp, flags);
free(tmp);
}
return fd;
}
/**
* parse_unconfined - check for the unconfined label
* @con: the confinement context
@@ -371,12 +602,7 @@ int aa_getprocattr_raw(pid_t tid, const char *attr, char *buf, int len,
goto out;
}
tmp = procattr_path(tid, attr);
if (!tmp)
goto out;
fd = open(tmp, O_RDONLY);
free(tmp);
fd = procattr_open(tid, attr, O_RDONLY);
if (fd == -1) {
goto out;
}
@@ -487,18 +713,13 @@ static int setprocattr(pid_t tid, const char *attr, const char *buf, int len)
{
int rc = -1;
int fd, ret;
char *ctl = NULL;
if (!buf) {
errno = EINVAL;
goto out;
}
ctl = procattr_path(tid, attr);
if (!ctl)
goto out;
fd = open(ctl, O_WRONLY);
fd = procattr_open(tid, attr, O_WRONLY);
if (fd == -1) {
goto out;
}
@@ -519,9 +740,6 @@ static int setprocattr(pid_t tid, const char *attr, const char *buf, int len)
(void)close(fd);
out:
if (ctl) {
free(ctl);
}
return rc;
}
@@ -607,7 +825,7 @@ int aa_change_onexec(const char *profile)
}
/* create an alias for the old change_hat@IMMUNIX_1.0 symbol */
extern typeof((__change_hat)) __old_change_hat __attribute__((alias ("__change_hat")));
DLLEXPORT extern typeof((__change_hat)) __old_change_hat __attribute__((alias ("__change_hat")));
symbol_version(__old_change_hat, change_hat, IMMUNIX_1.0);
default_symbol_version(__change_hat, change_hat, APPARMOR_1.0);
@@ -1005,7 +1223,7 @@ int query_label(uint32_t mask, char *query, size_t size, int *allowed,
/* export multiple aa_query_label symbols to compensate for downstream
* releases with differing symbol versions. */
extern typeof((query_label)) __aa_query_label __attribute__((alias ("query_label")));
DLLEXPORT extern typeof((query_label)) __aa_query_label __attribute__((alias ("query_label")));
symbol_version(__aa_query_label, aa_query_label, APPARMOR_1.1);
default_symbol_version(query_label, aa_query_label, APPARMOR_2.9);

View File

@@ -103,6 +103,8 @@ void free_record(aa_log_record *record)
free(record->flags);
if (record->src_name != NULL)
free(record->src_name);
if (record->class != NULL)
free(record->class);
free(record);
}

View File

@@ -6,14 +6,14 @@
IMMUNIX_1.0 {
global:
change_hat;
change_hat; __old_change_hat;
local:
*;
};
APPARMOR_1.0 {
global:
change_hat;
change_hat; __change_hat;
parse_record;
free_record;
local:
@@ -24,7 +24,7 @@ APPARMOR_1.1 {
global:
aa_is_enabled;
aa_find_mountpoint;
aa_change_hat;
aa_change_hat; __old_change_hat;
aa_change_hatv;
aa_change_hat_vargs;
aa_change_profile;
@@ -37,7 +37,7 @@ APPARMOR_1.1 {
free_record;
aa_getprocattr_raw;
aa_getprocattr;
aa_query_label;
aa_query_label; __aa_query_label;
# no more symbols here, please
@@ -47,7 +47,7 @@ APPARMOR_1.1 {
APPARMOR_2.9 {
global:
aa_query_label;
aa_query_label; query_label;
local:
*;
} APPARMOR_1.1;
@@ -117,6 +117,7 @@ APPARMOR_2.13.1 {
APPARMOR_3.0 {
global:
aa_features_new_from_file;
aa_features_write_to_fd;
aa_features_value;
local:
@@ -126,6 +127,7 @@ APPARMOR_3.0 {
PRIVATE {
global:
_aa_is_blacklisted;
_aa_asprintf;
_aa_autofree;
_aa_autoclose;
_aa_autofclose;

View File

@@ -45,6 +45,8 @@ struct aa_policy_cache {
static int clear_cache_cb(int dirfd, const char *path, struct stat *st,
void *data unused)
{
/* Handle symlink here. See _aa_dirat_for_each in private.c */
if (S_ISREG(st->st_mode)) {
/* remove regular files */
return unlinkat(dirfd, path, 0);

View File

@@ -452,7 +452,8 @@ int _aa_overlaydirat_for_each(int dirfd[], int n, void *data,
*
* The cb function is called with the DIR in use and the name of the
* file in that directory. If the file is to be opened it should
* use the openat, fstatat, and related fns.
* use the openat, fstatat, and related fns. If the file is a symlink
* _aa_dirat_for_each currently tries to traverse it for the caller
*
* Returns: 0 on success, else -1 and errno is set to the error code
*/
@@ -474,7 +475,7 @@ int _aa_dirat_for_each(int dirfd, const char *name, void *data,
return -1;
}
num_dirs = readdirfd(cb_dirfd, &namelist, NULL);
num_dirs = readdirfd(cb_dirfd, &namelist, alphasort);
if (num_dirs == -1) {
PDEBUG("scandirat of directory '%s' failed: %m\n", name);
return -1;
@@ -485,14 +486,34 @@ int _aa_dirat_for_each(int dirfd, const char *name, void *data,
autofree struct dirent *dir = namelist[i];
struct stat my_stat;
if (rc)
continue;
if (fstatat(cb_dirfd, dir->d_name, &my_stat, 0)) {
if (fstatat(cb_dirfd, dir->d_name, &my_stat, AT_SYMLINK_NOFOLLOW)) {
PDEBUG("stat failed for '%s': %m\n", dir->d_name);
rc = -1;
continue;
}
/* currently none of the callers handle symlinks, and this
* same basic code was applied to each. So for this patch
* just drop it here.
*
* Going forward we need to start handling symlinks as
* they have meaning.
* In the case of
* cache: they act as a place holder for files that have been
* combined into a single binary. This enables the
* file based cache lookup time find that relation
* and dedup, so multiple loads aren't done.
* profiles: just a profile in an alternate location, but
* should do dedup detection when doing dir reads
* so we don't double process.
*/
if (S_ISLNK(my_stat.st_mode)) {
/* just traverse the symlink */
if (fstatat(cb_dirfd, dir->d_name, &my_stat, 0)) {
PDEBUG("symlink target stat failed for '%s': %m\n", dir->d_name);
rc = -1;
continue;
}
}
if (cb(cb_dirfd, dir->d_name, &my_stat, data)) {
PDEBUG("dir_for_each callback failed for '%s'\n",

View File

@@ -72,7 +72,7 @@ void string_buf_append(unsigned int length, char *text)
%}
ws [ \t\r\n]
ws [ \t\r\n\x1d]
equals "="
digit [[:digit:]]
@@ -121,6 +121,8 @@ key_namespace "namespace"
key_mask "mask"
key_denied_mask "denied_mask"
key_requested_mask "requested_mask"
key_denied "denied"
key_requested "requested"
key_attribute "attribute"
key_task "task"
key_parent "parent"
@@ -138,7 +140,9 @@ key_sock_type "sock_type"
key_protocol "protocol"
key_error "error"
key_fsuid "fsuid"
key_fsuid_upper "FSUID"
key_ouid "ouid"
key_ouid_upper "OUID"
key_uid "uid"
key_auid "auid"
key_sauid "sauid"
@@ -161,17 +165,20 @@ key_dest "dest"
key_path "path"
key_interface "interface"
key_member "member"
key_method "method"
key_signal "signal"
key_peer "peer"
key_fstype "fstype"
key_flags "flags"
key_srcname "srcname"
key_class "class"
audit "audit"
/* network addrs */
ip_addr [a-f[:digit:].:]{3,}
/* syslog tokens */
socklogd_kernel kern.notice{colon}
syslog_kernel kernel{colon}
syslog_user [[:alnum:]_-]+\[[[:digit:]]+\]{colon}
syslog_yyyymmdd {digit}{4}{minus}{digit}{2}{minus}{digit}{2}
@@ -306,6 +313,8 @@ yy_flex_debug = 0;
{key_mask} { return(TOK_KEY_MASK); }
{key_denied_mask} { return(TOK_KEY_DENIED_MASK); }
{key_requested_mask} { return(TOK_KEY_REQUESTED_MASK); }
{key_denied} { return(TOK_KEY_DENIED_MASK); }
{key_requested} { return(TOK_KEY_REQUESTED_MASK); }
{key_attribute} { BEGIN(sub_id); return(TOK_KEY_ATTRIBUTE); }
{key_task} { return(TOK_KEY_TASK); }
{key_parent} { return(TOK_KEY_PARENT); }
@@ -323,7 +332,9 @@ yy_flex_debug = 0;
{key_protocol} { return(TOK_KEY_PROTOCOL); }
{key_error} { return(TOK_KEY_ERROR); }
{key_fsuid} { return(TOK_KEY_FSUID); }
{key_fsuid_upper} { return(TOK_KEY_FSUID_UPPER); }
{key_ouid} { return(TOK_KEY_OUID); }
{key_ouid_upper} { return(TOK_KEY_OUID_UPPER); }
{key_uid} { return(TOK_KEY_UID); }
{key_auid} { return(TOK_KEY_AUID); }
{key_sauid} { return(TOK_KEY_SAUID); }
@@ -345,12 +356,15 @@ yy_flex_debug = 0;
{key_path} { return(TOK_KEY_PATH); }
{key_interface} { return(TOK_KEY_INTERFACE); }
{key_member} { return(TOK_KEY_MEMBER); }
{key_method} { return(TOK_KEY_MEMBER); }
{key_signal} { BEGIN(sub_id); return(TOK_KEY_SIGNAL); }
{key_peer} { BEGIN(safe_string); return(TOK_KEY_PEER); }
{key_fstype} { return(TOK_KEY_FSTYPE); }
{key_flags} { BEGIN(safe_string); return(TOK_KEY_FLAGS); }
{key_srcname} { BEGIN(safe_string); return(TOK_KEY_SRCNAME); }
{key_class} { BEGIN(safe_string); return(TOK_KEY_CLASS); }
{socklogd_kernel} { BEGIN(dmesg_timestamp); return(TOK_SOCKLOGD_KERNEL); }
{syslog_kernel} { BEGIN(dmesg_timestamp); return(TOK_SYSLOG_KERNEL); }
{syslog_user} { return(TOK_SYSLOG_USER); }
{syslog_month} { yylval->t_str = strdup(yytext); return(TOK_DATE_MONTH); }
@@ -365,6 +379,7 @@ yy_flex_debug = 0;
<hostname>{
{ws}+ { /* eat whitespace */ }
{socklogd_kernel} { BEGIN(dmesg_timestamp); return(TOK_SOCKLOGD_KERNEL); }
{syslog_hostname} { yylval->t_str = strdup(yytext); BEGIN(INITIAL); return(TOK_ID); }
}

View File

@@ -14,14 +14,14 @@ MOSTLYCLEANFILES=libapparmor_wrap.c LibAppArmor.py
all-local: libapparmor_wrap.c setup.py
if test ! -f libapparmor_wrap.c; then cp $(srcdir)/libapparmor_wrap.c . ; fi
CC="$(CC)" CFLAGS="$(PYTHON_CPPFLAGS) $(EXTRA_WARNINGS)" LDSHARED="$(CC) -shared" LDFLAGS="$(PYTHON_LDFLAGS)" $(PYTHON) setup.py build
CC="$(CC)" CFLAGS="$(PYTHON_CPPFLAGS) $(EXTRA_WARNINGS)" LDSHARED="$(CC) -shared" LDFLAGS="$(PYTHON_LDFLAGS) $(LDFLAGS)" $(PYTHON) setup.py build
install-exec-local:
$(PYTHON) setup.py install --root="/$(DESTDIR)" --prefix="$(prefix)"
clean-local:
if test -x "$(PYTHON)"; then $(PYTHON) setup.py clean; fi
rm -rf build
rm -rf build LibAppArmor.egg-info
if test $(top_srcdir) != $(top_builddir) ; then rm -f libapparmor_wrap.c ; fi
endif

View File

@@ -1,4 +1,4 @@
from distutils.core import setup, Extension
from setuptools import setup, Extension
import string
setup(name = 'LibAppArmor',

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 distutils.util; import platform; print(\"lib.%s-%s\" %(distutils.util.get_platform(), platform.python_version()[:3]))")'
PYTHON_DIST_BUILD_PATH = '$(builddir)/../build/$$($(PYTHON) buildpath.py)'
TESTS = test_python.py
TESTS_ENVIRONMENT = \

View File

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

View File

@@ -34,6 +34,7 @@ OUTPUT_MAP = {
'Local port': 'net_local_port',
'Foreign port': 'net_foreign_port',
'Audit subid': 'audit_sub_id',
'Class': '_class',
}
# FIXME: pull this automatically out of LibAppArmor, but swig
@@ -108,7 +109,7 @@ class AAPythonBindingsTests(unittest.TestCase):
'''parse the swig created record and construct a dict from it'''
new_record = dict()
for key in [x for x in dir(record) if not (x.startswith('_') or x == 'this')]:
for key in [x for x in dir(record) if not (x.startswith('__') or x == 'this')]:
value = getattr(record, key)
if key == "event" and value in EVENT_MAP:
new_record[key] = EVENT_MAP[value]

View File

@@ -9,7 +9,9 @@ LibAppArmor_wrap.c : $(srcdir)/../SWIG/libapparmor.i
MOSTLYCLEANFILES=LibAppArmor_wrap.c
Makefile.ruby: extconf.rb
mv Makefile Makefile.bak
PREFIX=$(prefix) $(RUBY) $< --with-LibAppArmor-include=$(top_srcdir)/include
mv Makefile.bak Makefile
LibAppArmor.so: LibAppArmor_wrap.c Makefile.ruby
$(MAKE) -fMakefile.ruby
@@ -22,7 +24,7 @@ install-exec-local: Makefile.ruby
clean-local:
if test -f Makefile.ruby; then $(MAKE) -fMakefile.ruby clean; fi
rm -f Makefile.ruby Makefile.new
rm -f Makefile.ruby Makefile.bak
rm -f *.o *.so *.log
endif

View File

@@ -2,16 +2,8 @@
require 'mkmf'
# hack 1: ruby black magic to write a Makefile.new instead of a Makefile
alias open_orig open
def open(path, mode=nil, perm=nil)
path = 'Makefile.new' if path == 'Makefile'
if block_given?
open_orig(path, mode, perm) { |io| yield(io) }
else
open_orig(path, mode, perm)
end
end
# hack 1: Before extconf.rb gets called, Makefile gets backed up, and
# restored afterwards (see Makefile.am)
if ENV['PREFIX']
prefix = CONFIG['prefix']
@@ -27,7 +19,7 @@ if find_library('apparmor', 'parse_record', '../../src/.libs') and
# hack 2: strip all rpath references
open('Makefile.ruby', 'w') do |out|
IO.foreach('Makefile.new') do |line|
IO.foreach('Makefile') do |line|
out.puts line.gsub(/-Wl,-R'[^']*'/, '')
end
end

View File

@@ -134,6 +134,8 @@ int print_results(aa_log_record *record)
print_string("Flags", record->flags);
print_string("Src name", record->src_name);
print_string("Class", record->class);
print_long("Epoch", record->epoch, 0);
print_long("Audit subid", (long) record->audit_sub_id, 0);
return(0);

View File

@@ -0,0 +1 @@
type=AVC msg=audit(1661734785.992:270): apparmor="ALLOWED" operation="open" profile="/usr/bin/dolphin" name="/home/otis/.config/kdedefaults/kdeglobals" pid=3483 comm="dolphin" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0FSUID="otis" OUID="root"

View File

@@ -0,0 +1,15 @@
START
File: 0x1d-uppercase-FSUID-OUID.in
Event type: AA_RECORD_ALLOWED
Audit ID: 1661734785.992:270
Operation: open
Mask: r
Denied Mask: r
fsuid: 1000
ouid: 0
Profile: /usr/bin/dolphin
Name: /home/otis/.config/kdedefaults/kdeglobals
Command: dolphin
PID: 3483
Epoch: 1661734785
Audit subid: 270

View File

@@ -0,0 +1,4 @@
/usr/bin/dolphin {
/home/otis/.config/kdedefaults/kdeglobals r,
}

View File

@@ -0,0 +1 @@
audit.log:type=AVC msg=audit(1630913351.586:4): apparmor="STATUS" info="AppArmor Filesystem Enabled" pid=1 comm="swapper/0"

View File

@@ -0,0 +1,3 @@
START
File: status-filesystem-enabled.in
Event type: AA_RECORD_INVALID

View File

@@ -0,0 +1 @@
Dec 15 17:32:17 kinetic kernel: [4835959.046111] audit: type=1107 audit(1671125537.724:209): pid=7308 uid=0 auid=4294967295 ses=4294967295 msg='apparmor="DENIED" operation="dbus_method_call" bus="session" path="/org/freedesktop/DBus" interface="org.freedesktop.DBus" method="Hello" mask="send" label="/tmp/apparmor/tests/regression/apparmor/dbus_message" peer_label="unconfined" exe="/usr/local/bin/dbus-broker" sauid=0 hostname=? addr=? terminal=?'

View File

@@ -0,0 +1,15 @@
START
File: testcase_dbus_11.in
Event type: AA_RECORD_DENIED
Audit ID: 1671125537.724:209
Operation: dbus_method_call
Denied Mask: send
Profile: /tmp/apparmor/tests/regression/apparmor/dbus_message
Peer profile: unconfined
Command: /usr/local/bin/dbus-broker
DBus bus: session
DBus path: /org/freedesktop/DBus
DBus interface: org.freedesktop.DBus
DBus member: Hello
Epoch: 1671125537
Audit subid: 209

View File

@@ -0,0 +1,4 @@
/tmp/apparmor/tests/regression/apparmor/dbus_message {
dbus send bus=session path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=Hello peer=(label=unconfined),
}

View File

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

View File

@@ -0,0 +1,15 @@
START
File: testcase_socklogd_mkdir.in
Event type: AA_RECORD_ALLOWED
Audit ID: 1631392703.952:3
Operation: mkdir
Mask: c
Denied Mask: c
fsuid: 1000
ouid: 1000
Profile: /usr/sbin/sshd
Name: /run/user/1000/kakoune/
Command: sshd
PID: 2545
Epoch: 1631392703
Audit subid: 3

View File

@@ -0,0 +1,4 @@
/usr/sbin/sshd {
owner /run/user/1000/kakoune/ w,
}

View File

@@ -54,7 +54,7 @@ endif
CPPFLAGS += -D_GNU_SOURCE
STDLIB_INCLUDE:="\#include <stdlib.h>"
HAVE_REALLOCARRAY:=$(shell echo $(STDLIB_INCLUDE) | cpp ${CPPFLAGS} | grep -q reallocarray && echo true)
HAVE_REALLOCARRAY:=$(shell echo $(STDLIB_INCLUDE) | ${CPP} ${CPPFLAGS} - - | grep -q reallocarray && echo true)
WARNINGS = -Wall
CXX_WARNINGS = ${WARNINGS} ${EXTRA_WARNINGS}
@@ -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}
@@ -102,7 +104,7 @@ SRCS = parser_common.c parser_include.c parser_interface.c parser_lex.c \
af_rule.cc af_unix.cc policy_cache.c default_features.c
HDRS = parser.h parser_include.h immunix.h mount.h dbus.h lib.h profile.h \
rule.h common_optarg.h signal.h ptrace.h network.h af_rule.h af_unix.h \
policy_cache.h
policy_cache.h file_cache.h
TOOLS = apparmor_parser
OBJECTS = $(patsubst %.cc, %.o, $(SRCS:.c=.o))
@@ -215,10 +217,10 @@ apparmor_parser: $(OBJECTS) $(AAREOBJECTS) $(LIBAPPARMOR_A)
$(CXX) $(LDFLAGS) $(EXTRA_CFLAGS) -o $@ $(OBJECTS) $(LIBS) \
${LEXLIB} $(AAREOBJECTS) $(AARE_LDFLAGS) $(AALIB)
parser_yacc.c parser_yacc.h: parser_yacc.y parser.h profile.h
parser_yacc.c parser_yacc.h: parser_yacc.y parser.h profile.h file_cache.h
$(YACC) $(YFLAGS) -o parser_yacc.c parser_yacc.y
parser_lex.c: parser_lex.l parser_yacc.h parser.h profile.h mount.h dbus.h policy_cache.h
parser_lex.c: parser_lex.l parser_yacc.h parser.h profile.h mount.h dbus.h policy_cache.h file_cache.h
$(LEX) ${LEXFLAGS} -o$@ $<
parser_lex.o: parser_lex.c parser.h parser_yacc.h
@@ -230,13 +232,13 @@ parser_misc.o: parser_misc.c parser.h parser_yacc.h profile.h cap_names.h $(APPA
parser_yacc.o: parser_yacc.c parser_yacc.h $(APPARMOR_H)
$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
parser_main.o: parser_main.c parser.h parser_version.h policy_cache.h libapparmor_re/apparmor_re.h $(APPARMOR_H)
parser_main.o: parser_main.c parser.h parser_version.h policy_cache.h file_cache.h libapparmor_re/apparmor_re.h $(APPARMOR_H)
$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
parser_interface.o: parser_interface.c parser.h profile.h libapparmor_re/apparmor_re.h
$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
parser_include.o: parser_include.c parser.h parser_include.h
parser_include.o: parser_include.c parser.h parser_include.h file_cache.h
$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
parser_merge.o: parser_merge.c parser.h profile.h
@@ -257,7 +259,7 @@ parser_policy.o: parser_policy.c parser.h parser_yacc.h profile.h
parser_alias.o: parser_alias.c parser.h profile.h
$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
parser_common.o: parser_common.c parser.h
parser_common.o: parser_common.c parser.h file_cache.h
$(CXX) $(EXTRA_CFLAGS) -c -o $@ $<
mount.o: mount.cc mount.h parser.h immunix.h rule.h
@@ -307,10 +309,18 @@ parser_version.h: Makefile
# as well as the filtering that occurs for network protocols that
# apparmor should not mediate.
af_names.h: ../common/list_af_names.sh
../common/list_af_names.sh | LC_ALL=C sed -n -e 's/[ \t]\?AF_MAX[ \t]\+[0-9]\+,//g' -e 's/[ \t]\+\?AF_\([A-Z0-9_]\+\)[ \t]\+\([0-9]\+\),/#ifndef AF_\1\n# define AF_\1 \2\n#endif\nAA_GEN_NET_ENT("\L\1", \UAF_\1)\n/pg' > $@
../common/list_af_names.sh | LC_ALL=C sed -n -e 's/AF_MAX[ \t]\+\([0-9]\+\),\?.*/\n#define AA_AF_MAX \1\n/p' >> $@
# cat $@
generated_af_names.h: ../common/list_af_names.sh
../common/list_af_names.sh > $@
af_names.h: generated_af_names.h base_af_names.h
cat base_af_names.h | diff -u - generated_af_names.h | grep -v '^.AF_MAX' | grep '^\+[^+]' ; \
if [ $$? -eq 1 ] ; then \
cat base_af_names.h | LC_ALL=C sed -n -e 's/[ \t]\?AF_MAX[ \t]\+[0-9]\+,//g' -e 's/[ \t]\+\?AF_\([A-Z0-9_]\+\)[ \t]\+\([0-9]\+\),/#ifndef AF_\1\n# define AF_\1 \2\n#endif\nAA_GEN_NET_ENT("\L\1", \UAF_\1)\n/pg' > $@ ; \
cat base_af_names.h | LC_ALL=C sed -n -e 's/AF_MAX[ \t]\+\([0-9]\+\),\?.*/\n#define AA_AF_MAX \1\n/p' >> $@ ; \
else \
echo "Error: new AF names detected; please update base_af_names.h with values from generated_af_names.h" ; \
exit 1 ; \
fi
generated_cap_names.h: /usr/include/linux/capability.h
../common/list_capabilities.sh | LC_ALL=C sed -n -e "s/[ \\t]\\?CAP_\\([A-Z0-9_]\\+\\)/\{\"\\L\\1\", \\UCAP_\\1, NO_BACKMAP_CAP, CAPFLAG_BASE_FEATURE\},\\n/pg" > $@
@@ -376,11 +386,11 @@ DISTRO=$(shell if [ -f /etc/slackware-version ] ; then \
elif [ -f /etc/debian_version ] ; then \
echo debian ;\
elif which rpm > /dev/null ; then \
if [ "$(rpm --eval '0%{?suse_version}')" != "0" ] ; then \
if [ "$$(rpm --eval '0%{?suse_version}')" != "0" ] ; then \
echo suse ;\
elif [ "$(rpm --eval '%{_host_vendor}')" = redhat ] ; then \
elif [ "$$(rpm --eval '%{_host_vendor}')" = redhat ] ; then \
echo rhel4 ;\
elif [ "$(rpm --eval '0%{?fedora}')" != "0" ] ; then \
elif [ "$$(rpm --eval '0%{?fedora}')" != "0" ] ; then \
echo rhel4 ;\
else \
echo unknown ;\
@@ -411,6 +421,7 @@ install-indep: indep
install -m 755 -d ${DESTDIR}/var/lib/apparmor
install -m 755 -d $(APPARMOR_BIN_PREFIX)
install -m 755 rc.apparmor.functions $(APPARMOR_BIN_PREFIX)
install -m 755 profile-load $(APPARMOR_BIN_PREFIX)
$(MAKE) -C po install NAME=${NAME} DESTDIR=${DESTDIR}
$(MAKE) install_manpages DESTDIR=${DESTDIR}
@@ -434,7 +445,7 @@ clean: pod_clean
rm -f $(YACC_C_FILES)
rm -f parser_version.h
rm -f $(NAME)*.tar.gz $(NAME)*.tgz
rm -f af_names.h
rm -f af_names.h generated_af_names.h
rm -f cap_names.h generated_cap_names.h
rm -rf techdoc.aux techdoc.out techdoc.log techdoc.pdf techdoc.toc techdoc.txt techdoc/
$(MAKE) -s -C $(AAREDIR) clean

View File

@@ -111,8 +111,7 @@ unix_rule::unix_rule(unsigned int type_p, bool audit_p, bool denied):
unix_rule::unix_rule(int mode_p, struct cond_entry *conds,
struct cond_entry *peer_conds):
af_rule("unix"), addr(NULL), peer_addr(NULL),
audit(0), deny(0)
af_rule("unix"), addr(NULL), peer_addr(NULL)
{
move_conditionals(conds);
move_peer_conditionals(peer_conds);
@@ -136,7 +135,7 @@ ostream &unix_rule::dump_local(ostream &os)
{
af_rule::dump_local(os);
if (addr)
os << "addr='" << addr << "'";
os << " addr='" << addr << "'";
return os;
}
@@ -144,7 +143,7 @@ ostream &unix_rule::dump_peer(ostream &os)
{
af_rule::dump_peer(os);
if (peer_addr)
os << "addr='" << peer_addr << "'";
os << " addr='" << peer_addr << "'";
return os;
}
@@ -194,14 +193,18 @@ void unix_rule::downgrade_rule(Profile &prof) {
yyerror(_("Memory allocation error."));
if (sock_type_n != -1)
mask = 1 << sock_type_n;
if (deny) {
prof.net.deny[AF_UNIX] |= mask;
if (!audit)
prof.net.quiet[AF_UNIX] |= mask;
} else {
if (!deny) {
prof.net.allow[AF_UNIX] |= mask;
if (audit)
prof.net.audit[AF_UNIX] |= mask;
} else {
/* deny rules have to be dropped because the downgrade makes
* the rule less specific meaning it will make the profile more
* restrictive and may end up denying accesses that might be
* allowed by the profile.
*/
if (warnflags & WARN_RULE_NOT_ENFORCED)
rule_t::warn_once(prof.name, "deny unix socket rule not enforced, can't be downgraded to generic network rule\n");
}
}

View File

@@ -36,9 +36,6 @@ class unix_rule: public af_rule {
public:
char *addr;
char *peer_addr;
int mode;
int audit;
bool deny;
unix_rule(unsigned int type_p, bool audit_p, bool denied);
unix_rule(int mode, struct cond_entry *conds,

View File

@@ -148,7 +148,7 @@ capabilities(7))
B<NETWORK RULE> = [ I<QUALIFIERS> ] 'network' [ I<DOMAIN> ] [ I<TYPE> | I<PROTOCOL> ]
B<DOMAIN> = ( 'unix' | 'inet' | 'ax25' | 'ipx' | 'appletalk' | 'netrom' | 'bridge' | 'atmpvc' | 'x25' | 'inet6' | 'rose' | 'netbeui' | 'security' | 'key' | 'netlink' | 'packet' | 'ash' | 'econet' | 'atmsvc' | 'rds' | 'sna' | 'irda' | 'pppox' | 'wanpipe' | 'llc' | 'ib' | 'mpls' | 'can' | 'tipc' | 'bluetooth' | 'iucv' | 'rxrpc' | 'isdn' | 'phonet' | 'ieee802154' | 'caif' | 'alg' | 'nfc' | 'vsock' | 'kcm' | 'qipcrtr' | 'smc' | 'xdp' ) ','
B<DOMAIN> = ( 'unix' | 'inet' | 'ax25' | 'ipx' | 'appletalk' | 'netrom' | 'bridge' | 'atmpvc' | 'x25' | 'inet6' | 'rose' | 'netbeui' | 'security' | 'key' | 'netlink' | 'packet' | 'ash' | 'econet' | 'atmsvc' | 'rds' | 'sna' | 'irda' | 'pppox' | 'wanpipe' | 'llc' | 'ib' | 'mpls' | 'can' | 'tipc' | 'bluetooth' | 'iucv' | 'rxrpc' | 'isdn' | 'phonet' | 'ieee802154' | 'caif' | 'alg' | 'nfc' | 'vsock' | 'kcm' | 'qipcrtr' | 'smc' | 'xdp' | 'mctp' ) ','
B<TYPE> = ( 'stream' | 'dgram' | 'seqpacket' | 'rdm' | 'raw' | 'packet' )
@@ -842,7 +842,7 @@ and other operations that are typically reserved for the root user.
AppArmor supports simple coarse grained network mediation. The network
rule restrict all socket(2) based operations. The mediation done is
a course grained check on whether a socket of a given type and family
a coarse-grained check on whether a socket of a given type and family
can be created, read, or written. There is no mediation based of port
number or protocol beyond tcp, udp, and raw. Network netlink(7) rules may
only specify type 'dgram' and 'raw'.
@@ -1273,7 +1273,7 @@ I<auto> keyword. Eg.
To indicate that the rule only applies to auto binding of unix domain
sockets. It is important to note this only applies to the I<bind>
permission as once the socket is bound to an address it is
indistiguishable from a socket that have an addr bound with a
indistinguishable from a socket that have an addr bound with a
specified name. When the I<auto> keyword is used with other permissions
or as part of a peer addr it will be replaced with a pattern that
can match an autobound socket. Eg. For some kernels
@@ -1752,7 +1752,7 @@ If the policy abi is specified as B<kernel> then the running kernel's
abi will be used. This should never be used in shipped policy as it
can cause system breakage when a new kernel is installed.
=head3 ABI compatability with AppArmor 2.x
=head3 ABI compatibility with AppArmor 2.x
AppArmor 3 remains compatible with AppArmor 2.x by detecting when a
profile does not have a feature ABI specified. In this case the policy

View File

@@ -71,6 +71,13 @@ fi
case "$1" in
start)
if [ -x /usr/bin/systemd-detect-virt ] && \
systemd-detect-virt --quiet --container && \
! is_container_with_internal_policy; then
aa_log_daemon_msg "Not starting AppArmor in container"
aa_log_end_msg 0
exit 0
fi
apparmor_start
rc=$?
;;
@@ -79,6 +86,13 @@ case "$1" in
rc=$?
;;
restart|reload|force-reload)
if [ -x /usr/bin/systemd-detect-virt ] && \
systemd-detect-virt --quiet --container && \
! is_container_with_internal_policy; then
aa_log_daemon_msg "Not starting AppArmor in container"
aa_log_end_msg 0
exit 0
fi
apparmor_restart
rc=$?
;;

View File

@@ -352,12 +352,15 @@ Eg.
-jx4 OR --jobs=x4 sets the jobs to # of cpus * 4
-jx1 is equivalent to -jauto
The default value is the number of cpus in the system.
The default value is the number of cpus in the system. Note that if jobs
is a positive integer number the --jobs-max parameter is automatically
set to the same value.
=item --max-jobs n
Set a hard cap on the value that can be specified by the --jobs flag.
It takes the same set of options available to the --jobs option, and
When --jobs is set to a scaling value (ie. auto or xN) the specify a
hard cap on the value that can be specified by the --jobs flag. It
takes the same set of options available to the --jobs option, and
defaults to 8*cpus
=item -O n, --optimize=n

View File

@@ -27,7 +27,7 @@
=head1 NAME
AppArmor profile xattr(7) matching
apparmor_xattrs - AppArmor profile xattr(7) matching
=head1 DESCRIPTION

46
parser/base_af_names.h Normal file
View File

@@ -0,0 +1,46 @@
AF_UNSPEC 0,
AF_UNIX 1,
AF_INET 2,
AF_AX25 3,
AF_IPX 4,
AF_APPLETALK 5,
AF_NETROM 6,
AF_BRIDGE 7,
AF_ATMPVC 8,
AF_X25 9,
AF_INET6 10,
AF_ROSE 11,
AF_NETBEUI 13,
AF_SECURITY 14,
AF_KEY 15,
AF_NETLINK 16,
AF_PACKET 17,
AF_ASH 18,
AF_ECONET 19,
AF_ATMSVC 20,
AF_RDS 21,
AF_SNA 22,
AF_IRDA 23,
AF_PPPOX 24,
AF_WANPIPE 25,
AF_LLC 26,
AF_IB 27,
AF_MPLS 28,
AF_CAN 29,
AF_TIPC 30,
AF_BLUETOOTH 31,
AF_IUCV 32,
AF_RXRPC 33,
AF_ISDN 34,
AF_PHONET 35,
AF_IEEE802154 36,
AF_CAIF 37,
AF_ALG 38,
AF_NFC 39,
AF_VSOCK 40,
AF_KCM 41,
AF_QIPCRTR 42,
AF_SMC 43,
AF_XDP 44,
AF_MCTP 45,
AF_MAX 46,

View File

@@ -8,6 +8,8 @@
{"bpf", CAP_BPF, CAP_SYS_ADMIN, CAPFLAG_BASE_FEATURE},
{"checkpoint_restore", CAP_CHECKPOINT_RESTORE, CAP_SYS_ADMIN, CAPFLAG_BASE_FEATURE},
{"chown", CAP_CHOWN, NO_BACKMAP_CAP, CAPFLAG_BASE_FEATURE},
{"dac_override", CAP_DAC_OVERRIDE, NO_BACKMAP_CAP, CAPFLAG_BASE_FEATURE},

View File

@@ -19,8 +19,25 @@
#ifndef __AA_CAPABILITY_H
#define __AA_CAPABILITY_H
#include <cstdint>
#include <linux/capability.h>
#define NO_BACKMAP_CAP 0xff
#ifndef CAP_AUDIT_WRITE
#define CAP_AUDIT_WRITE 29
#endif
#ifndef CAP_AUDIT_CONTROL
#define CAP_AUDIT_CONTROL 30
#endif
#ifndef CAP_SETFCAP
#define CAP_SETFCAP 31
#endif
#ifndef CAP_MAC_OVERRIDE
#define CAP_MAC_OVERRIDE 32
#endif
#ifndef CAP_PERFMON
#define CAP_PERFMON 38
#endif
@@ -29,6 +46,10 @@
#define CAP_BPF 39
#endif
#ifndef CAP_CHECKPOINT_RESTORE
#define CAP_CHECKPOINT_RESTORE 40
#endif
typedef enum capability_flags {
CAPFLAGS_CLEAR = 0,
CAPFLAG_BASE_FEATURE = 1,

52
parser/file_cache.h Normal file
View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 2021
* 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.
*/
#ifndef __AA_FILE_CACHE_H
#define __AA_FILE_CACHE_H
#include <set>
#include <string>
using namespace std;
/* TODO: have includecache be a frontend for file cache, don't just
* store name.
*/
class IncludeCache_t {
public:
set<string> cache;
IncludeCache_t() = default;
virtual ~IncludeCache_t() = default;
/* return true if in set */
bool find(const char *name) {
return cache.find(name) != cache.end();
}
bool insert(const char *name) {
pair<set<string>::iterator,bool> res = cache.insert(name);
if (res.second == false) {
return false;
}
/* inserted */
return true;
}
};
#endif /* __AA_FILE_CACHE_H */

View File

@@ -193,9 +193,8 @@ void CHFA::insert_state(vector<pair<size_t, size_t> > &free_list,
State *default_state = dfa.nonmatching;
ssize_t base = 0;
int resize;
StateTrans &trans = from->trans;
ssize_t c = trans.begin()->first.c;
ssize_t c;
ssize_t prev = 0;
ssize_t x = first_free;
@@ -204,6 +203,7 @@ void CHFA::insert_state(vector<pair<size_t, size_t> > &free_list,
if (trans.empty())
goto do_insert;
c = trans.begin()->first.c;
repeat:
resize = 0;
/* get the first free entry that won't underflow */
@@ -251,10 +251,18 @@ repeat:
first_free = next;
}
do_insert:
/* these flags will only be set on states that have transitions */
if (c < 0) {
base |= MATCH_FLAG_OOB_TRANSITION;
}
do_insert:
/* While a state without transitions could have the diff encode
* flag set, it would be pointless resulting in just an extra
* state transition in the encoding chain, and so it should be
* considered an error
* TODO: add check that state without transitions isn't being
* given a diffencode flag
*/
if (from->flags & DiffEncodeFlag)
base |= DiffEncodeBit32;
default_base.push_back(make_pair(default_state, base));

View File

@@ -543,9 +543,9 @@ public:
int min_match_len()
{
if (contains_oob()) {
return 0;
}
/* Inverse match does not match any oob char at this time
* so only count characters
*/
return 1;
}

View File

@@ -65,10 +65,15 @@
### policy to be used in AppArmor 3.x without the warning
### Warning from stdin (stdin line 1): apparmor_parser: File 'example'
### missing feature abi, falling back to default policy feature abi.
### For more info please see
### https://gitlab.com/apparmor/apparmor/-/wikis/AppArmorpolicyfeaturesabi
### Turn off abi rule warnings without pinning the abi
#warn=no-abi
### Only a single feature ABI rule should be used at a time.
## Pin older policy to the 5.4 kernel abi
#policy-features=/etc/apparmor.d/abi/kernel-5.4-outoftree-network
#policy-features=/etc/apparmor.d/abi/kernel-5.4-vanilla
## Pin older policy to the 5.4 kernel abi + out of tree network and af_unix
#policy-features=/etc/apparmor.d/abi/kernel-5.4-vanilla
#policy-features=/etc/apparmor.d/abi/kernel-5.4-outoftree-network

View File

@@ -32,6 +32,7 @@
#include <sys/apparmor.h>
#include "file_cache.h"
#include "immunix.h"
#include "libapparmor_re/apparmor_re.h"
#include "libapparmor_re/aare_rules.h"
@@ -353,6 +354,8 @@ extern char *profile_ns;
extern char *current_filename;
extern FILE *ofile;
extern int read_implies_exec;
extern IncludeCache_t *g_includecache;
extern void pwarnf(bool werr, const char *fmt, ...) __attribute__((__format__(__printf__, 2, 3)));
extern void common_warn_once(const char *name, const char *msg, const char **warned_name);

View File

@@ -20,6 +20,7 @@
#include <stdarg.h>
#include "parser.h"
#include "file_cache.h"
/* Policy versioning is determined by a combination of 3 values:
* policy_version: version of txt policy
@@ -95,6 +96,8 @@ char *current_filename = NULL;
FILE *ofile = NULL;
IncludeCache_t *g_includecache;
#ifdef FORCE_READ_IMPLIES_EXEC
int read_implies_exec = 1;
#else

View File

@@ -151,7 +151,7 @@ void parse_default_paths(void)
add_search_dir(basedir);
}
FILE *search_path(char *filename, char **fullpath)
FILE *search_path(char *filename, char **fullpath, bool *skip)
{
FILE *newf = NULL;
char *buf = NULL;
@@ -161,15 +161,27 @@ FILE *search_path(char *filename, char **fullpath)
perror("asprintf");
exit(1);
}
if (g_includecache->find(buf)) {
/* hit do not want to re-include */
*skip = true;
return NULL;
}
newf = fopen(buf, "r");
if (newf && fullpath)
*fullpath = buf;
else
free(buf);
buf = NULL;
if (newf)
if (newf) {
/* ignore failing to insert into cache */
(void) g_includecache->insert(buf);
if (fullpath)
*fullpath = buf;
else
free(buf);
break;
}
free(buf);
buf = NULL;
}
*skip = false;
return newf;
}

View File

@@ -27,7 +27,7 @@ extern void init_base_dir(void);
extern void set_base_dir(char *dir);
extern void parse_default_paths(void);
extern int do_include_preprocessing(char *profilename);
FILE *search_path(char *filename, char **fullpath);
FILE *search_path(char *filename, char **fullpath, bool *skip);
extern void push_include_stack(char *filename);
extern void pop_include_stack(void);

View File

@@ -44,6 +44,7 @@
#include "parser_yacc.h"
#include "lib.h"
#include "policy_cache.h"
#include "file_cache.h"
#ifdef PDEBUG
#undef PDEBUG
@@ -134,10 +135,19 @@ static int include_dir_cb(int dirfd unused, const char *name, struct stat *st,
if (is_blacklisted(name, path))
return 0;
if (g_includecache->find(path)) {
PDEBUG("skipping reinclude of \'%s\' in \'%s\'\n", path,
d->filename);
return 0;
}
/* Handle symlink here. See _aa_dirat_for_each in private.c */
if (S_ISREG(st->st_mode)) {
if (!(yyin = fopen(path,"r")))
yyerror(_("Could not open '%s' in '%s'"), path, d->filename);
PDEBUG("Opened include \"%s\" in \"%s\"\n", path, d->filename);
(void) g_includecache->insert(path);
update_mru_tstamp(yyin, path);
push_include_stack(path);
yypush_buffer_state(yy_create_buffer(yyin, YY_BUF_SIZE));
@@ -151,16 +161,29 @@ void include_filename(char *filename, int search, bool if_exists)
FILE *include_file = NULL;
struct stat my_stat;
autofree char *fullpath = NULL;
bool cached;
if (search) {
if (preprocess_only)
include_file = search_path(filename, &fullpath, &cached);
if (!include_file && cached) {
goto skip;
} else if (preprocess_only) {
fprintf(yyout, "\n\n##included <%s>\n", filename);
include_file = search_path(filename, &fullpath);
} else if (!include_file && preprocess_only) {
fprintf(yyout, "\n\n##failed include <%s>\n", filename);
}
} else if (g_includecache->find(filename)) {
/* duplicate entry skip */
goto skip;
} else {
if (preprocess_only)
fprintf(yyout, "\n\n##included \"%s\"\n", filename);
fullpath = strdup(filename);
include_file = fopen(fullpath, "r");
if (include_file)
/* ignore failure to insert into cache */
(void) g_includecache->insert(filename);
}
if (!include_file) {
@@ -181,6 +204,7 @@ void include_filename(char *filename, int search, bool if_exists)
yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE ));
} else if (S_ISDIR(my_stat.st_mode)) {
struct cb_struct data = { fullpath, filename };
update_mru_tstamp(include_file, fullpath);
fclose(include_file);
include_file = NULL;
if (dirat_for_each(AT_FDCWD, fullpath, &data, include_dir_cb)) {
@@ -188,6 +212,13 @@ void include_filename(char *filename, int search, bool if_exists)
" '%s' in '%s'"), fullpath, filename);;
}
}
return;
skip:
if (preprocess_only)
fprintf(yyout, "\n\n##skipped duplicate include <%s>\n", filename);
return;
}
static char *lsntrim(char *s, int l)
@@ -712,7 +743,7 @@ include/{WS} {
}
}
<INITIAL,SUB_ID,SUB_ID_WS,SUB_VALUE,LIST_VAL_MODE,EXTCOND_MODE,LIST_COND_VAL,LIST_COND_PAREN_VAL,LIST_COND_MODE,EXTCONDLIST_MODE,ASSIGN_MODE,NETWORK_MODE,CHANGE_PROFILE_MODE,MOUNT_MODE,DBUS_MODE,SIGNAL_MODE,PTRACE_MODE,UNIX_MODE,RLIMIT_MODEINCLUDE,INCLUDE_EXISTS,ABI_MODE>{
<INITIAL,SUB_ID,SUB_ID_WS,SUB_VALUE,LIST_VAL_MODE,EXTCOND_MODE,LIST_COND_VAL,LIST_COND_PAREN_VAL,LIST_COND_MODE,EXTCONDLIST_MODE,ASSIGN_MODE,NETWORK_MODE,CHANGE_PROFILE_MODE,MOUNT_MODE,DBUS_MODE,SIGNAL_MODE,PTRACE_MODE,UNIX_MODE,RLIMIT_MODE,INCLUDE,INCLUDE_EXISTS,ABI_MODE>{
(.|\n) {
DUMP_PREPROCESS;
/* Something we didn't expect */

View File

@@ -50,6 +50,7 @@
#include "common_optarg.h"
#include "policy_cache.h"
#include "libapparmor_re/apparmor_re.h"
#include "file_cache.h"
#define OLD_MODULE_NAME "subdomain"
#define PROC_MODULES "/proc/modules"
@@ -259,7 +260,7 @@ optflag_table_t warnflag_table[] = {
{ 1, "jobs", "enable job control warnings", WARN_JOBS },
{ 1, "dangerous", "warn on dangerous policy", WARN_DANGEROUS },
{ 1, "unexpected", "warn when an unexpected condition is found", WARN_UNEXPECTED },
{ 1, "format", "warn on unnecessary or confusing formating", WARN_FORMAT },
{ 1, "format", "warn on unnecessary or confusing formatting", WARN_FORMAT },
{ 1, "missing", "warn when missing qualifier and a default is used", WARN_MISSING },
{ 1, "override", "warn when overriding", WARN_OVERRIDE },
{ 1, "dev", "turn on warnings that are useful for profile development", WARN_DEV },
@@ -730,6 +731,8 @@ static int process_arg(int c, char *optarg)
jobs = process_jobs_arg("-j", optarg);
if (jobs == 0)
jobs_max = 0;
else if (jobs != JOBS_AUTO && jobs < LONG_MAX)
jobs_max = jobs;
break;
case ARG_MAX_JOBS:
jobs_max = process_jobs_arg("max-jobs", optarg);
@@ -1000,6 +1003,8 @@ void reset_parser(const char *filename)
aa_features_unref(policy_features);
policy_features = NULL;
clear_cap_flag(CAPFLAG_POLICY_FEATURE);
delete g_includecache;
g_includecache = new IncludeCache_t();
}
int test_for_dir_mode(const char *basename, const char *linkdir)
@@ -1159,9 +1164,11 @@ int process_profile(int option, aa_kernel_interface *kernel_interface,
/* cache file generated by load_policy */
retval = load_policy(option, kernel_interface, cachetmp);
if (retval == 0 && write_cache) {
if (cachetmp == -1) {
if (force_complain) {
pwarn(WARN_CACHE, "Caching disabled for: '%s' due to force complain\n", basename);
} else if (cachetmp == -1) {
unlink(cachetmpname);
pwarn(WARN_CACHE, "Warning failed to create cache: %s\n",
pwarn(WARN_CACHE, "Failed to create cache: %s\n",
basename);
} else {
install_cache(cachetmpname, writecachename);
@@ -1295,6 +1302,8 @@ static void setup_parallel_compile(void)
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(n, jobs);
jobs_max = compute_jobs(maxn, jobs_max);
@@ -1302,7 +1311,7 @@ static void setup_parallel_compile(void)
pwarn(WARN_JOBS, "%s: Warning capping number of jobs to %ld * # of cpus == '%ld'",
progname, jobs_max, jobs);
jobs = jobs_max;
} else if (jobs < jobs_max)
} else if (jobs_scale && jobs < jobs_max)
/* the bigger the difference the more sample chances given */
jobs_scale = jobs_max + 1 - n;
@@ -1323,6 +1332,8 @@ static int profile_dir_cb(int dirfd unused, const char *name, struct stat *st,
{
int rc = 0;
/* Handle symlink here. See _aa_dirat_for_each in private.c */
if (!S_ISDIR(st->st_mode) && !is_blacklisted(name, NULL)) {
struct dir_cb_data *cb_data = (struct dir_cb_data *)data;
autofree char *path = NULL;
@@ -1345,6 +1356,8 @@ static int binary_dir_cb(int dirfd unused, const char *name, struct stat *st,
{
int rc = 0;
/* Handle symlink here. See _aa_dirat_for_each in private.c */
if (!S_ISDIR(st->st_mode) && !is_blacklisted(name, NULL)) {
struct dir_cb_data *cb_data = (struct dir_cb_data *)data;
autofree char *path = NULL;
@@ -1537,7 +1550,7 @@ int main(int argc, char *argv[])
if ((retval = dirat_for_each(AT_FDCWD, profilename,
&cb_data, cb))) {
last_error = errno;
PDEBUG("Failed loading profiles from %s\n",
PERROR("There was an error while loading profiles from %s\n",
profilename);
if (abort_on_error)
break;

View File

@@ -326,7 +326,8 @@ bool add_cap_feature_mask(struct aa_features *features, capability_flags flags)
value = aa_features_value(features, "caps/mask", &valuelen);
if (!value)
return false;
/* nothing to add, just use existing set */
return true;
n = 0;
for (capstr = strn_token(value, len);

View File

@@ -29,6 +29,7 @@
#include <errno.h>
#include <sys/apparmor.h>
#include "lib.h"
#include "parser.h"
#include "profile.h"
#include "parser_yacc.h"
@@ -145,6 +146,56 @@ void add_entry_to_policy(Profile *prof, struct cod_entry *entry)
prof->entries = entry;
}
static bool add_proc_access(Profile *prof, const char *rule)
{
/* FIXME: should use @{PROC}/@{PID}/attr/{apparmor/,}{current,exec} */
struct cod_entry *new_ent;
/* allow probe for new interfaces */
char *buffer = strdup("/proc/*/attr/apparmor/");
if (!buffer) {
PERROR("Memory allocation error\n");
return FALSE;
}
new_ent = new_entry(buffer, AA_MAY_READ, NULL);
if (!new_ent) {
free(buffer);
PERROR("Memory allocation error\n");
return FALSE;
}
add_entry_to_policy(prof, new_ent);
/* allow probe if apparmor is enabled for the old interface */
buffer = strdup("/sys/module/apparmor/parameters/enabled");
if (!buffer) {
PERROR("Memory allocation error\n");
return FALSE;
}
new_ent = new_entry(buffer, AA_MAY_READ, NULL);
if (!new_ent) {
free(buffer);
PERROR("Memory allocation error\n");
return FALSE;
}
add_entry_to_policy(prof, new_ent);
/* allow setting on new and old interfaces */
buffer = strdup(rule);
if (!buffer) {
PERROR("Memory allocation error\n");
return FALSE;
}
new_ent = new_entry(buffer, AA_MAY_WRITE, NULL);
if (!new_ent) {
free(buffer);
PERROR("Memory allocation error\n");
return FALSE;
}
add_entry_to_policy(prof, new_ent);
return TRUE;
}
#define CHANGEPROFILE_PATH "/proc/*/attr/{apparmor/,}{current,exec}"
void post_process_file_entries(Profile *prof)
{
struct cod_entry *entry;
@@ -170,22 +221,11 @@ void post_process_file_entries(Profile *prof)
}
/* if there are change_profile rules, this implies that we need
* access to /proc/self/attr/current
* access to some /proc/ interfaces
*/
if (cp_mode & AA_CHANGE_PROFILE) {
/* FIXME: should use @{PROC}/@{PID}/attr/{apparmor/,}{current,exec} */
struct cod_entry *new_ent;
char *buffer = strdup("/proc/*/attr/{apparmor/,}{current,exec}");
if (!buffer) {
PERROR("Memory allocation error\n");
if (!add_proc_access(prof, CHANGEPROFILE_PATH))
exit(1);
}
new_ent = new_entry(buffer, AA_MAY_WRITE, NULL);
if (!new_ent) {
PERROR("Memory allocation error\n");
exit(1);
}
add_entry_to_policy(prof, new_ent);
}
}
@@ -202,19 +242,13 @@ void post_process_rule_entries(Profile *prof)
*/
static int profile_add_hat_rules(Profile *prof)
{
struct cod_entry *entry;
/* don't add hat rules if not hat or profile doesn't have hats */
if (!prof->flags.hat && prof->hat_table.empty())
return 0;
/* add entry to hat */
entry = new_entry(strdup(CHANGEHAT_PATH), AA_MAY_WRITE, NULL);
if (!entry)
if (!add_proc_access(prof, CHANGEHAT_PATH))
return ENOMEM;
add_entry_to_policy(prof, entry);
return 0;
}

View File

@@ -468,20 +468,26 @@ static int process_profile_name_xmatch(Profile *prof)
{
std::string tbuf;
pattern_t ptype;
const char *name;
char *name;
struct cond_entry *entry;
const char *xattr_value;
/* don't filter_slashes for profile names */
if (prof->attachment)
if (prof->attachment) {
name = prof->attachment;
else
name = local_name(prof->name);
} else {
/* don't filter_slashes for profile names, do on attachment */
name = strdup(local_name(prof->name));
if (!name)
return FALSE;
}
filter_slashes(name);
ptype = convert_aaregex_to_pcre(name, 0, glob_default, tbuf,
&prof->xmatch_len);
if (ptype == ePatternBasic)
prof->xmatch_len = strlen(name);
if (!prof->attachment)
free(name);
if (ptype == ePatternInvalid) {
PERROR(_("%s: Invalid profile name '%s' - bad regular expression\n"), progname, name);
@@ -505,6 +511,7 @@ static int process_profile_name_xmatch(Profile *prof)
list_for_each(prof->altnames, alt) {
int len;
tbuf.clear();
filter_slashes(alt->name);
ptype = convert_aaregex_to_pcre(alt->name, 0,
glob_default,
tbuf, &len);
@@ -516,7 +523,7 @@ static int process_profile_name_xmatch(Profile *prof)
}
if (prof->xattrs.list) {
if (!(features_supports_domain_xattr && kernel_supports_oob)) {
warn_once_xattr(name);
warn_once_xattr(prof->name);
free_cond_entry_list(prof->xattrs);
goto build;
}
@@ -642,6 +649,7 @@ static int process_dfa_entry(aare_rules *dfarules, struct cod_entry *entry)
int pos;
vec[0] = tbuf.c_str();
if (entry->link_name) {
filter_slashes(entry->link_name);
ptype = convert_aaregex_to_pcre(entry->link_name, 0, glob_default, lbuf, &pos);
if (ptype == ePatternInvalid)
return FALSE;

View File

@@ -44,20 +44,6 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <linux/capability.h>
#ifndef CAP_AUDIT_WRITE
#define CAP_AUDIT_WRITE 29
#endif
#ifndef CAP_AUDIT_CONTROL
#define CAP_AUDIT_CONTROL 30
#endif
#ifndef CAP_SETFCAP
#define CAP_SETFCAP 31
#endif
#ifndef CAP_MAC_OVERRIDE
#define CAP_MAC_OVERRIDE 32
#endif
#define CIDR_32 htonl(0xffffffff)
#define CIDR_24 htonl(0xffffff00)
@@ -220,6 +206,7 @@ void add_local_entry(Profile *prof);
struct cond_entry_list cond_entry_list;
int boolean;
struct prefixes prefix;
IncludeCache_t *includecache;
}
%type <id> TOK_ID
@@ -334,9 +321,17 @@ opt_id: { /* nothing */ $$ = NULL; }
opt_id_or_var: { /* nothing */ $$ = NULL; }
| id_or_var { $$ = $1; }
profile_base: TOK_ID opt_id_or_var opt_cond_list flags TOK_OPEN rules TOK_CLOSE
profile_base: TOK_ID opt_id_or_var opt_cond_list flags TOK_OPEN
{
Profile *prof = $6;
/* mid rule action
* save current cache, restore at end of block
*/
$<includecache>$ = g_includecache;
g_includecache = new IncludeCache_t();
}
rules TOK_CLOSE
{
Profile *prof = $7;
bool self_stack = false;
if (!prof) {
@@ -387,6 +382,10 @@ profile_base: TOK_ID opt_id_or_var opt_cond_list flags TOK_OPEN rules TOK_CLOSE
post_process_file_entries(prof);
post_process_rule_entries(prof);
prof->flags.debug(cerr);
/* restore previous blocks include cache */
delete g_includecache;
g_includecache = $<includecache>6;
$$ = prof;
};
@@ -1775,12 +1774,17 @@ static int abi_features_base(struct aa_features **features, char *filename, bool
autofclose FILE *f = NULL;
struct stat my_stat;
char *fullpath = NULL;
bool cached;
if (search) {
if (strcmp(filename, "kernel") == 0)
return aa_features_new_from_kernel(features);
f = search_path(filename, &fullpath);
PDEBUG("abi lookup '%s' -> '%s' f %p\n", filename, fullpath, f);
f = search_path(filename, &fullpath, &cached);
PDEBUG("abi lookup '%s' -> '%s' f %p cached %d\n", filename, fullpath, f, cached);
if (!f && cached) {
*features = NULL;
return 0;
}
} else {
f = fopen(filename, "r");
PDEBUG("abi relpath '%s' f %p\n", filename, f);
@@ -1809,10 +1813,15 @@ static void abi_features(char *filename, bool search)
yyerror(_("failed to find features abi '%s': %m"), filename);
}
if (policy_features) {
if (!aa_features_is_equal(tmp_features, policy_features)) {
pwarn(WARN_ABI, _("%s: %s features abi '%s' differs from policy declared feature abi, using the features abi declared in policy\n"), progname, current_filename, filename);
if (tmp_features) {
if (!aa_features_is_equal(tmp_features, policy_features)) {
pwarn(WARN_ABI, _("%s: %s features abi '%s' differs from policy declared feature abi, using the features abi declared in policy\n"), progname, current_filename, filename);
}
aa_features_unref(tmp_features);
}
aa_features_unref(tmp_features);
} else if (!tmp_features) {
/* skipped reinclude, but features not set */
yyerror(_("failed features abi not set but include cache skipped\n"));
} else {
/* first features abi declaration */
policy_features = tmp_features;

View File

@@ -1,5 +1,5 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR NOVELL, Inc.
# Copyright (C) YEAR Canonical Ltd
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: apparmor@lists.ubuntu.com\n"
"POT-Creation-Date: 2014-09-13 00:11-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"
@@ -17,95 +17,106 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../parser_include.c:113 ../parser_include.c:111
#: ../parser_include.c:113 ../parser_include.c:111 ../parser_include.c:96
msgid "Error: Out of memory.\n"
msgstr ""
#: ../parser_include.c:123 ../parser_include.c:121
#: ../parser_include.c:123 ../parser_include.c:121 ../parser_include.c:106
#, c-format
msgid "Error: basedir %s is not a directory, skipping.\n"
msgstr ""
#: ../parser_include.c:137
#: ../parser_include.c:137 ../parser_include.c:122
#, c-format
msgid "Error: Could not add directory %s to search path.\n"
msgstr ""
#: ../parser_include.c:147 ../parser_include.c:151
#: ../parser_include.c:147 ../parser_include.c:151 ../parser_include.c:136
msgid "Error: Could not allocate memory.\n"
msgstr ""
#: ../parser_interface.c:69 ../parser_interface.c:72 ../parser_interface.c:49
#: ../parser_interface.c:52
msgid "Bad write position\n"
msgstr ""
#: ../parser_interface.c:72 ../parser_interface.c:75 ../parser_interface.c:52
#: ../parser_interface.c:55
msgid "Permission denied\n"
msgstr ""
#: ../parser_interface.c:75 ../parser_interface.c:78 ../parser_interface.c:55
#: ../parser_interface.c:58
msgid "Out of memory\n"
msgstr ""
#: ../parser_interface.c:78 ../parser_interface.c:81 ../parser_interface.c:58
#: ../parser_interface.c:61
msgid "Couldn't copy profile: Bad memory address\n"
msgstr ""
#: ../parser_interface.c:81 ../parser_interface.c:84 ../parser_interface.c:61
#: ../parser_interface.c:64
msgid "Profile doesn't conform to protocol\n"
msgstr ""
#: ../parser_interface.c:84 ../parser_interface.c:87 ../parser_interface.c:64
#: ../parser_interface.c:67
msgid "Profile does not match signature\n"
msgstr ""
#: ../parser_interface.c:87 ../parser_interface.c:90 ../parser_interface.c:67
#: ../parser_interface.c:70
msgid "Profile version not supported by Apparmor module\n"
msgstr ""
#: ../parser_interface.c:90 ../parser_interface.c:93 ../parser_interface.c:70
#: ../parser_interface.c:73
msgid "Profile already exists\n"
msgstr ""
#: ../parser_interface.c:93 ../parser_interface.c:96 ../parser_interface.c:73
#: ../parser_interface.c:76
msgid "Profile doesn't exist\n"
msgstr ""
#: ../parser_interface.c:96 ../parser_interface.c:99 ../parser_interface.c:76
#: ../parser_interface.c:79
msgid "Permission denied; attempted to load a profile while confined?\n"
msgstr ""
#: ../parser_interface.c:99 ../parser_interface.c:102 ../parser_interface.c:79
#: ../parser_interface.c:82
#, c-format
msgid "Unknown error (%d): %s\n"
msgstr ""
#: ../parser_interface.c:116 ../parser_interface.c:119
#: ../parser_interface.c:96
#: ../parser_interface.c:116 ../parser_interface.c:119 ../parser_interface.c:96
#: ../parser_interface.c:100
#, c-format
msgid "%s: Unable to add \"%s\". "
msgstr ""
#: ../parser_interface.c:121 ../parser_interface.c:124
#: ../parser_interface.c:101
#: ../parser_interface.c:101 ../parser_interface.c:105
#, c-format
msgid "%s: Unable to replace \"%s\". "
msgstr ""
#: ../parser_interface.c:126 ../parser_interface.c:129
#: ../parser_interface.c:106
#: ../parser_interface.c:106 ../parser_interface.c:110
#, c-format
msgid "%s: Unable to remove \"%s\". "
msgstr ""
#: ../parser_interface.c:131 ../parser_interface.c:134
#: ../parser_interface.c:111
#: ../parser_interface.c:111 ../parser_interface.c:115
#, c-format
msgid "%s: Unable to write to stdout\n"
msgstr ""
#: ../parser_interface.c:135 ../parser_interface.c:138
#: ../parser_interface.c:115
#: ../parser_interface.c:115 ../parser_interface.c:119
#, c-format
msgid "%s: Unable to write to output file\n"
msgstr ""
@@ -113,24 +124,25 @@ msgstr ""
#: ../parser_interface.c:138 ../parser_interface.c:162
#: ../parser_interface.c:141 ../parser_interface.c:165
#: ../parser_interface.c:118 ../parser_interface.c:142
#: ../parser_interface.c:123 ../parser_interface.c:147
#, c-format
msgid "%s: ASSERT: Invalid option: %d\n"
msgstr ""
#: ../parser_interface.c:147 ../parser_interface.c:150
#: ../parser_interface.c:127
#: ../parser_interface.c:127 ../parser_interface.c:132
#, c-format
msgid "Addition succeeded for \"%s\".\n"
msgstr ""
#: ../parser_interface.c:151 ../parser_interface.c:154
#: ../parser_interface.c:131
#: ../parser_interface.c:131 ../parser_interface.c:136
#, c-format
msgid "Replacement succeeded for \"%s\".\n"
msgstr ""
#: ../parser_interface.c:155 ../parser_interface.c:158
#: ../parser_interface.c:135
#: ../parser_interface.c:135 ../parser_interface.c:140
#, c-format
msgid "Removal succeeded for \"%s\".\n"
msgstr ""
@@ -141,7 +153,7 @@ msgid "PANIC bad increment buffer %p pos %p ext %p size %d res %p\n"
msgstr ""
#: ../parser_interface.c:656 ../parser_interface.c:658
#: ../parser_interface.c:446
#: ../parser_interface.c:446 ../parser_interface.c:476
#, c-format
msgid "profile %s network rules not enforced\n"
msgstr ""
@@ -186,7 +198,7 @@ msgid "%s: Unable to write entire profile entry\n"
msgstr ""
#: ../parser_interface.c:839 ../parser_interface.c:831
#: ../parser_interface.c:593
#: ../parser_interface.c:593 ../parser_interface.c:579
#, c-format
msgid "%s: Unable to write entire profile entry to cache\n"
msgstr ""
@@ -196,7 +208,7 @@ msgstr ""
msgid "Could not open '%s'"
msgstr ""
#: parser_lex.l:104 parser_lex.l:167 parser_lex.l:173
#: parser_lex.l:104 parser_lex.l:167 parser_lex.l:173 parser_lex.l:174
#, c-format
msgid "fstat failed for '%s'"
msgstr ""
@@ -222,7 +234,7 @@ msgstr ""
msgid "Found unexpected character: '%s'"
msgstr ""
#: parser_lex.l:386 parser_lex.l:418 parser_lex.l:428
#: parser_lex.l:386 parser_lex.l:418 parser_lex.l:428 parser_lex.l:474
msgid "Variable declarations do not accept trailing commas"
msgstr ""
@@ -242,6 +254,7 @@ msgid "%s: Could not allocate memory for subdomainbase mount point\n"
msgstr ""
#: ../parser_main.c:577 ../parser_main.c:616 ../parser_main.c:479
#: ../parser_main.c:1444
#, c-format
msgid ""
"Warning: unable to find a suitable fs in %s, is it mounted?\n"
@@ -249,6 +262,7 @@ msgid ""
msgstr ""
#: ../parser_main.c:597 ../parser_main.c:635 ../parser_main.c:498
#: ../parser_main.c:822
#, c-format
msgid ""
"%s: Sorry. You need root privileges to run this program.\n"
@@ -256,6 +270,7 @@ msgid ""
msgstr ""
#: ../parser_main.c:604 ../parser_main.c:642 ../parser_main.c:505
#: ../parser_main.c:828
#, c-format
msgid ""
"%s: Warning! You've set this program setuid root.\n"
@@ -264,7 +279,7 @@ msgid ""
msgstr ""
#: ../parser_main.c:704 ../parser_main.c:813 ../parser_main.c:836
#: ../parser_main.c:946 ../parser_main.c:860
#: ../parser_main.c:946 ../parser_main.c:860 ../parser_main.c:1038
#, c-format
msgid "Error: Could not read profile %s: %s.\n"
msgstr ""
@@ -286,26 +301,36 @@ msgstr ""
#: parser_yacc.y:1166 parser_yacc.y:1170 parser_yacc.y:1180 parser_yacc.y:1190
#: parser_yacc.y:1298 parser_yacc.y:1376 parser_yacc.y:1479 parser_yacc.y:1490
#: parser_yacc.y:1565 parser_yacc.y:1583 parser_yacc.y:1590 parser_yacc.y:1639
#: ../network.c:314 ../af_unix.cc:203
#: ../network.c:314 ../af_unix.cc:203 ../parser_misc.c:215 ../parser_misc.c:939
#: parser_yacc.y:343 parser_yacc.y:367 parser_yacc.y:533 parser_yacc.y:543
#: parser_yacc.y:660 parser_yacc.y:741 parser_yacc.y:750 parser_yacc.y:1171
#: parser_yacc.y:1219 parser_yacc.y:1255 parser_yacc.y:1264 parser_yacc.y:1268
#: parser_yacc.y:1278 parser_yacc.y:1288 parser_yacc.y:1382 parser_yacc.y:1460
#: parser_yacc.y:1592 parser_yacc.y:1597 parser_yacc.y:1674 parser_yacc.y:1692
#: parser_yacc.y:1699 parser_yacc.y:1748 ../network.c:315 ../af_unix.cc:194
msgid "Memory allocation error."
msgstr ""
#: ../parser_main.c:740 ../parser_main.c:872 ../parser_main.c:757
#: ../parser_main.c:975
#, c-format
msgid "Cached load succeeded for \"%s\".\n"
msgstr ""
#: ../parser_main.c:744 ../parser_main.c:876 ../parser_main.c:761
#: ../parser_main.c:979
#, c-format
msgid "Cached reload succeeded for \"%s\".\n"
msgstr ""
#: ../parser_main.c:910 ../parser_main.c:1058 ../parser_main.c:967
#: ../parser_main.c:1132
#, c-format
msgid "%s: Errors found in file. Aborting.\n"
msgstr ""
#: ../parser_misc.c:426 ../parser_misc.c:597 ../parser_misc.c:339
#: ../parser_misc.c:532
msgid ""
"Uppercase qualifiers \"RWLIMX\" are deprecated, please convert to lowercase\n"
"See the apparmor.d(5) manpage for details.\n"
@@ -313,14 +338,17 @@ msgstr ""
#: ../parser_misc.c:467 ../parser_misc.c:474 ../parser_misc.c:638
#: ../parser_misc.c:645 ../parser_misc.c:380 ../parser_misc.c:387
#: ../parser_misc.c:573 ../parser_misc.c:580
msgid "Conflict 'a' and 'w' perms are mutually exclusive."
msgstr ""
#: ../parser_misc.c:491 ../parser_misc.c:662 ../parser_misc.c:404
#: ../parser_misc.c:597
msgid "Exec qualifier 'i' invalid, conflicting qualifier already specified"
msgstr ""
#: ../parser_misc.c:502 ../parser_misc.c:673 ../parser_misc.c:415
#: ../parser_misc.c:608
#, c-format
msgid ""
"Unconfined exec qualifier (%c%c) allows some dangerous environment variables "
@@ -329,22 +357,26 @@ msgstr ""
#: ../parser_misc.c:510 ../parser_misc.c:551 ../parser_misc.c:681
#: ../parser_misc.c:722 ../parser_misc.c:423 ../parser_misc.c:464
#: ../parser_misc.c:616 ../parser_misc.c:657
#, c-format
msgid "Exec qualifier '%c' invalid, conflicting qualifier already specified"
msgstr ""
#: ../parser_misc.c:537 ../parser_misc.c:545 ../parser_misc.c:708
#: ../parser_misc.c:716 ../parser_misc.c:450 ../parser_misc.c:458
#: ../parser_misc.c:643 ../parser_misc.c:651
#, c-format
msgid "Exec qualifier '%c%c' invalid, conflicting qualifier already specified"
msgstr ""
#: ../parser_misc.c:593 ../parser_misc.c:764 ../parser_misc.c:506
#: ../parser_misc.c:699
#, c-format
msgid "Internal: unexpected mode character '%c' in input"
msgstr ""
#: ../parser_misc.c:615 ../parser_misc.c:786 ../parser_misc.c:528
#: ../parser_misc.c:721
#, c-format
msgid "Internal error generated invalid perm 0x%llx\n"
msgstr ""
@@ -356,10 +388,12 @@ msgid "AppArmor parser error: %s\n"
msgstr ""
#: ../parser_merge.c:92 ../parser_merge.c:91 ../parser_merge.c:83
#: ../parser_merge.c:71
msgid "Couldn't merge entries. Out of Memory\n"
msgstr ""
#: ../parser_merge.c:111 ../parser_merge.c:113 ../parser_merge.c:105
#: ../parser_merge.c:93
#, c-format
msgid "profile %s: has merged rule %s with conflicting x modifiers\n"
msgstr ""
@@ -368,114 +402,117 @@ msgstr ""
msgid "Profile attachment must begin with a '/'."
msgstr ""
#: parser_yacc.y:260 parser_yacc.y:302 parser_yacc.y:348
#: parser_yacc.y:260 parser_yacc.y:302 parser_yacc.y:348 parser_yacc.y:407
msgid ""
"Profile names must begin with a '/', namespace or keyword 'profile' or 'hat'."
msgstr ""
#: parser_yacc.y:296 parser_yacc.y:338 parser_yacc.y:384
#: parser_yacc.y:296 parser_yacc.y:338 parser_yacc.y:384 parser_yacc.y:449
#, c-format
msgid "Failed to create alias %s -> %s\n"
msgstr ""
#: parser_yacc.y:417 parser_yacc.y:460 parser_yacc.y:506
#: parser_yacc.y:417 parser_yacc.y:460 parser_yacc.y:506 parser_yacc.y:581
msgid "Profile flag chroot_relative conflicts with namespace_relative"
msgstr ""
#: parser_yacc.y:421 parser_yacc.y:464 parser_yacc.y:510
#: parser_yacc.y:421 parser_yacc.y:464 parser_yacc.y:510 parser_yacc.y:585
msgid "Profile flag mediate_deleted conflicts with delegate_deleted"
msgstr ""
#: parser_yacc.y:424 parser_yacc.y:467 parser_yacc.y:513
#: parser_yacc.y:424 parser_yacc.y:467 parser_yacc.y:513 parser_yacc.y:588
msgid "Profile flag attach_disconnected conflicts with no_attach_disconnected"
msgstr ""
#: parser_yacc.y:427 parser_yacc.y:470 parser_yacc.y:516
#: parser_yacc.y:427 parser_yacc.y:470 parser_yacc.y:516 parser_yacc.y:591
msgid "Profile flag chroot_attach conflicts with chroot_no_attach"
msgstr ""
#: parser_yacc.y:441 parser_yacc.y:484 parser_yacc.y:530
#: parser_yacc.y:441 parser_yacc.y:484 parser_yacc.y:530 parser_yacc.y:607
msgid "Profile flag 'debug' is no longer valid."
msgstr ""
#: parser_yacc.y:463 parser_yacc.y:506 parser_yacc.y:552
#: parser_yacc.y:463 parser_yacc.y:506 parser_yacc.y:552 parser_yacc.y:629
#, c-format
msgid "Invalid profile flag: %s."
msgstr ""
#: parser_yacc.y:498 parser_yacc.y:520 parser_yacc.y:548 parser_yacc.y:594
#: parser_yacc.y:673
msgid "Assert: `rule' returned NULL."
msgstr ""
#: parser_yacc.y:501 parser_yacc.y:546 parser_yacc.y:552 parser_yacc.y:584
#: parser_yacc.y:598 parser_yacc.y:630
#: parser_yacc.y:598 parser_yacc.y:630 parser_yacc.y:677 parser_yacc.y:709
msgid ""
"Invalid mode, in deny rules 'x' must not be preceded by exec qualifier 'i', "
"'p', or 'u'"
msgstr ""
#: parser_yacc.y:524 parser_yacc.y:556 parser_yacc.y:602
#: parser_yacc.y:524 parser_yacc.y:556 parser_yacc.y:602 parser_yacc.y:681
msgid ""
"Invalid mode, 'x' must be preceded by exec qualifier 'i', 'p', 'c', or 'u'"
msgstr ""
#: parser_yacc.y:549 parser_yacc.y:587 parser_yacc.y:633
#: parser_yacc.y:549 parser_yacc.y:587 parser_yacc.y:633 parser_yacc.y:712
msgid "Invalid mode, 'x' must be preceded by exec qualifier 'i', 'p', or 'u'"
msgstr ""
#: parser_yacc.y:574 parser_yacc.y:612 parser_yacc.y:614 parser_yacc.y:660
#: parser_yacc.y:739
msgid "Assert: `network_rule' return invalid protocol."
msgstr ""
#: parser_yacc.y:649 parser_yacc.y:696 parser_yacc.y:786
#: parser_yacc.y:649 parser_yacc.y:696 parser_yacc.y:786 parser_yacc.y:867
msgid "Assert: `change_profile' returned NULL."
msgstr ""
#: parser_yacc.y:680 parser_yacc.y:720 parser_yacc.y:810
#: parser_yacc.y:680 parser_yacc.y:720 parser_yacc.y:810 parser_yacc.y:905
msgid "Assert: 'hat rule' returned NULL."
msgstr ""
#: parser_yacc.y:689 parser_yacc.y:729 parser_yacc.y:819
#: parser_yacc.y:689 parser_yacc.y:729 parser_yacc.y:819 parser_yacc.y:914
msgid "Assert: 'local_profile rule' returned NULL."
msgstr ""
#: parser_yacc.y:824 parser_yacc.y:885 parser_yacc.y:992
#: parser_yacc.y:824 parser_yacc.y:885 parser_yacc.y:992 parser_yacc.y:1077
#, c-format
msgid "Unset boolean variable %s used in if-expression"
msgstr ""
#: parser_yacc.y:882 parser_yacc.y:986 parser_yacc.y:1092
#: parser_yacc.y:882 parser_yacc.y:986 parser_yacc.y:1092 parser_yacc.y:1181
msgid "unsafe rule missing exec permissions"
msgstr ""
#: parser_yacc.y:901 parser_yacc.y:954 parser_yacc.y:1060
#: parser_yacc.y:901 parser_yacc.y:954 parser_yacc.y:1060 parser_yacc.y:1148
msgid "subset can only be used with link rules."
msgstr ""
#: parser_yacc.y:903 parser_yacc.y:956 parser_yacc.y:1062
#: parser_yacc.y:903 parser_yacc.y:956 parser_yacc.y:1062 parser_yacc.y:1150
msgid "link and exec perms conflict on a file rule using ->"
msgstr ""
#: parser_yacc.y:905 parser_yacc.y:958 parser_yacc.y:1064
#: parser_yacc.y:905 parser_yacc.y:958 parser_yacc.y:1064 parser_yacc.y:1152
msgid "link perms are not allowed on a named profile transition.\n"
msgstr ""
#: parser_yacc.y:921 parser_yacc.y:1003 parser_yacc.y:1109
#: parser_yacc.y:921 parser_yacc.y:1003 parser_yacc.y:1109 parser_yacc.y:1198
#, c-format
msgid "missing an end of line character? (entry: %s)"
msgstr ""
#: parser_yacc.y:975 parser_yacc.y:985 parser_yacc.y:1057 parser_yacc.y:1067
#: parser_yacc.y:1145 parser_yacc.y:1155
#: parser_yacc.y:1145 parser_yacc.y:1155 parser_yacc.y:1234 parser_yacc.y:1244
msgid "Invalid network entry."
msgstr ""
#: parser_yacc.y:1039 parser_yacc.y:1048 parser_yacc.y:1254 parser_yacc.y:1510
#: parser_yacc.y:1617
#, c-format
msgid "Invalid capability %s."
msgstr ""
#: parser_yacc.y:1066 parser_yacc.y:1269 parser_yacc.y:1525
#: parser_yacc.y:1066 parser_yacc.y:1269 parser_yacc.y:1525 parser_yacc.y:1637
#, c-format
msgid "AppArmor parser error for %s%s%s at line %d: %s\n"
msgstr ""
@@ -491,17 +528,20 @@ msgid "%s: Illegal open {, nesting groupings not allowed\n"
msgstr ""
#: ../parser_regex.c:265 ../parser_regex.c:274 ../parser_regex.c:278
#: ../parser_regex.c:306
#, c-format
msgid "%s: Regex grouping error: Invalid number of items between {}\n"
msgstr ""
#: ../parser_regex.c:271 ../parser_regex.c:280 ../parser_regex.c:284
#: ../parser_regex.c:312
#, c-format
msgid ""
"%s: Regex grouping error: Invalid close }, no matching open { detected\n"
msgstr ""
#: ../parser_regex.c:337 ../parser_regex.c:343 ../parser_regex.c:361
#: ../parser_regex.c:403
#, c-format
msgid ""
"%s: Regex grouping error: Unclosed grouping or character class, expecting "
@@ -514,16 +554,19 @@ msgid "%s: Internal buffer overflow detected, %d characters exceeded\n"
msgstr ""
#: ../parser_regex.c:355 ../parser_regex.c:361 ../parser_regex.c:377
#: ../parser_regex.c:419
#, c-format
msgid "%s: Unable to parse input line '%s'\n"
msgstr ""
#: ../parser_regex.c:397 ../parser_regex.c:405 ../parser_regex.c:421
#: ../parser_regex.c:487
#, c-format
msgid "%s: Invalid profile name '%s' - bad regular expression\n"
msgstr ""
#: ../parser_policy.c:202 ../parser_policy.c:402 ../parser_policy.c:375
#: ../parser_policy.c:383
#, c-format
msgid "ERROR merging rules for profile %s, failed to load\n"
msgstr ""
@@ -537,16 +580,19 @@ msgid ""
msgstr ""
#: ../parser_policy.c:279 ../parser_policy.c:359 ../parser_policy.c:332
#: ../parser_policy.c:340
#, c-format
msgid "ERROR processing regexs for profile %s, failed to load\n"
msgstr ""
#: ../parser_policy.c:306 ../parser_policy.c:389 ../parser_policy.c:362
#: ../parser_policy.c:370
#, c-format
msgid "ERROR expanding variables for profile %s, failed to load\n"
msgstr ""
#: ../parser_policy.c:390 ../parser_policy.c:382 ../parser_policy.c:355
#: ../parser_policy.c:363
#, c-format
msgid "ERROR adding hat access rule for profile %s\n"
msgstr ""
@@ -576,7 +622,7 @@ msgstr ""
msgid "%s: Errors found in combining rules postprocessing. Aborting.\n"
msgstr ""
#: parser_lex.l:180 parser_lex.l:186
#: parser_lex.l:180 parser_lex.l:186 parser_lex.l:187
#, c-format
msgid "Could not process include directory '%s' in '%s'"
msgstr ""
@@ -586,7 +632,8 @@ msgid "Feature buffer full."
msgstr ""
#: ../parser_main.c:1115 ../parser_main.c:1132 ../parser_main.c:1024
#: ../parser_main.c:1041
#: ../parser_main.c:1041 ../parser_main.c:1332 ../parser_main.c:1354
#: ../parser_misc.c:280 ../parser_misc.c:299 ../parser_misc.c:308
msgid "Out of memory"
msgstr ""
@@ -615,11 +662,11 @@ msgstr ""
msgid "Internal error generated invalid DBus perm 0x%x\n"
msgstr ""
#: parser_yacc.y:575 parser_yacc.y:621
#: parser_yacc.y:575 parser_yacc.y:621 parser_yacc.y:700
msgid "deny prefix not allowed"
msgstr ""
#: parser_yacc.y:612 parser_yacc.y:658
#: parser_yacc.y:612 parser_yacc.y:658 parser_yacc.y:737
msgid "owner prefix not allowed"
msgstr ""
@@ -635,41 +682,41 @@ msgstr ""
msgid "owner prefix not allow on capability rules"
msgstr ""
#: parser_yacc.y:1357 parser_yacc.y:1613
#: parser_yacc.y:1357 parser_yacc.y:1613 parser_yacc.y:1722
#, c-format
msgid "invalid mount conditional %s%s"
msgstr ""
#: parser_yacc.y:1374 parser_yacc.y:1628
#: parser_yacc.y:1374 parser_yacc.y:1628 parser_yacc.y:1737
msgid "bad mount rule"
msgstr ""
#: parser_yacc.y:1381 parser_yacc.y:1635
#: parser_yacc.y:1381 parser_yacc.y:1635 parser_yacc.y:1744
msgid "mount point conditions not currently supported"
msgstr ""
#: parser_yacc.y:1398 parser_yacc.y:1650
#: parser_yacc.y:1398 parser_yacc.y:1650 parser_yacc.y:1759
#, c-format
msgid "invalid pivotroot conditional '%s'"
msgstr ""
#: ../parser_regex.c:241 ../parser_regex.c:236
#: ../parser_regex.c:241 ../parser_regex.c:236 ../parser_regex.c:264
#, c-format
msgid ""
"%s: Regex grouping error: Invalid close ], no matching open [ detected\n"
msgstr ""
#: ../parser_regex.c:257 ../parser_regex.c:256
#: ../parser_regex.c:257 ../parser_regex.c:256 ../parser_regex.c:284
#, c-format
msgid "%s: Regex grouping error: Exceeded maximum nesting of {}\n"
msgstr ""
#: ../parser_policy.c:366 ../parser_policy.c:339
#: ../parser_policy.c:366 ../parser_policy.c:339 ../parser_policy.c:347
#, c-format
msgid "ERROR processing policydb rules for profile %s, failed to load\n"
msgstr ""
#: ../parser_policy.c:396 ../parser_policy.c:369
#: ../parser_policy.c:396 ../parser_policy.c:369 ../parser_policy.c:377
#, c-format
msgid "ERROR replacing aliases for profile %s, failed to load\n"
msgstr ""
@@ -689,51 +736,244 @@ msgstr ""
msgid "Error: Could not read cache file '%s', skipping...\n"
msgstr ""
#: ../parser_misc.c:575
#: ../parser_misc.c:575 ../parser_misc.c:768
#, c-format
msgid "Internal: unexpected %s mode character '%c' in input"
msgstr ""
#: ../parser_misc.c:599
#: ../parser_misc.c:599 ../parser_misc.c:792
#, c-format
msgid "Internal error generated invalid %s perm 0x%x\n"
msgstr ""
#: parser_yacc.y:703
#: parser_yacc.y:703 parser_yacc.y:784
msgid "owner prefix not allowed on mount rules"
msgstr ""
#: parser_yacc.y:720
#: parser_yacc.y:720 parser_yacc.y:801
msgid "owner prefix not allowed on dbus rules"
msgstr ""
#: parser_yacc.y:736
#: parser_yacc.y:736 parser_yacc.y:817
msgid "owner prefix not allowed on signal rules"
msgstr ""
#: parser_yacc.y:752
#: parser_yacc.y:752 parser_yacc.y:833
msgid "owner prefix not allowed on ptrace rules"
msgstr ""
#: parser_yacc.y:768
#: parser_yacc.y:768 parser_yacc.y:849 parser_yacc.y:869
msgid "owner prefix not allowed on unix rules"
msgstr ""
#: parser_yacc.y:794
#: parser_yacc.y:794 parser_yacc.y:885
msgid "owner prefix not allowed on capability rules"
msgstr ""
#: parser_yacc.y:1293
#: parser_yacc.y:1293 parser_yacc.y:1377
#, c-format
msgid "dbus rule: invalid conditional group %s=()"
msgstr ""
#: parser_yacc.y:1371
#: parser_yacc.y:1371 parser_yacc.y:1455
#, c-format
msgid "unix rule: invalid conditional group %s=()"
msgstr ""
#: ../parser_regex.c:368
#: ../parser_regex.c:368 ../parser_regex.c:410
#, c-format
msgid "%s: Regex error: trailing '\\' escape character\n"
msgstr ""
#: ../parser_common.c:112
#, c-format
msgid "%s from %s (%s%sline %d): %s"
msgstr ""
#: ../parser_common.c:113
msgid "Warning converted to Error"
msgstr ""
#: ../parser_common.c:113
msgid "Warning"
msgstr ""
#: ../parser_interface.c:524
#, c-format
msgid "Unable to open stdout - %s\n"
msgstr ""
#: ../parser_interface.c:533
#, c-format
msgid "Unable to open output file - %s\n"
msgstr ""
#: parser_lex.l:326
msgid "Failed to process filename\n"
msgstr ""
#: parser_lex.l:720
#, c-format
msgid "Lexer found unexpected character: '%s' (0x%x) in state: %s"
msgstr ""
#: ../parser_main.c:915
#, c-format
msgid "Unable to print the cache directory: %m\n"
msgstr ""
#: ../parser_main.c:951
#, c-format
msgid "Error: Could not load profile %s: %s\n"
msgstr ""
#: ../parser_main.c:961
#, c-format
msgid "Error: Could not replace profile %s: %s\n"
msgstr ""
#: ../parser_main.c:966
#, c-format
msgid "Error: Invalid load option specified: %d\n"
msgstr ""
#: ../parser_main.c:1077
#, c-format
msgid "Could not get cachename for '%s'\n"
msgstr ""
#: ../parser_main.c:1434
msgid "Kernel features abi not found"
msgstr ""
#: ../parser_main.c:1438
msgid "Failed to add kernel capabilities to known capabilities set"
msgstr ""
#: ../parser_main.c:1465
#, c-format
msgid "Failed to clear cache files (%s): %s\n"
msgstr ""
#: ../parser_main.c:1474
msgid ""
"The --create-cache-dir option is deprecated. Please use --write-cache.\n"
msgstr ""
#: ../parser_main.c:1479
#, c-format
msgid "Failed setting up policy cache (%s): %s\n"
msgstr ""
#: ../parser_misc.c:904
#, c-format
msgid "Namespace not terminated: %s\n"
msgstr ""
#: ../parser_misc.c:906
#, c-format
msgid "Empty namespace: %s\n"
msgstr ""
#: ../parser_misc.c:908
#, c-format
msgid "Empty named transition profile name: %s\n"
msgstr ""
#: ../parser_misc.c:910
#, c-format
msgid "Unknown error while parsing label: %s\n"
msgstr ""
#: parser_yacc.y:306
msgid "Failed to setup default policy feature abi"
msgstr ""
#: parser_yacc.y:308
#, c-format
msgid ""
"%s: File '%s' missing feature abi, falling back to default policy feature "
"abi\n"
msgstr ""
#: parser_yacc.y:313
msgid "Failed to add policy capabilities to known capabilities set"
msgstr ""
#: parser_yacc.y:350
msgid "Profile names must begin with a '/' or a namespace"
msgstr ""
#: parser_yacc.y:372
msgid "Profile attachment must begin with a '/' or variable."
msgstr ""
#: parser_yacc.y:375
#, c-format
msgid "profile id: invalid conditional group %s=()"
msgstr ""
#: parser_yacc.y:404
msgid ""
"The use of file paths as profile names is deprecated. See man apparmor.d for "
"more information\n"
msgstr ""
#: parser_yacc.y:573
#, c-format
msgid "Profile flag '%s' conflicts with '%s'"
msgstr ""
#: parser_yacc.y:954
msgid "RLIMIT 'cpu' no units specified using default units of seconds\n"
msgstr ""
#: parser_yacc.y:966
msgid ""
"RLIMIT 'rttime' no units specified using default units of microseconds\n"
msgstr ""
#: parser_yacc.y:1582
msgid "Exec condition is required when unsafe or safe keywords are present"
msgstr ""
#: parser_yacc.y:1584
msgid "Exec condition must begin with '/'."
msgstr ""
#: parser_yacc.y:1643
#, c-format
msgid "AppArmor parser error at line %d: %s\n"
msgstr ""
#: parser_yacc.y:1790
#, c-format
msgid "Could not open '%s': %m"
msgstr ""
#: parser_yacc.y:1795
#, c-format
msgid "fstat failed for '%s': %m"
msgstr ""
#: parser_yacc.y:1809
#, c-format
msgid "failed to find features abi '%s': %m"
msgstr ""
#: parser_yacc.y:1813
#, c-format
msgid ""
"%s: %s features abi '%s' differs from policy declared feature abi, using the "
"features abi declared in policy\n"
msgstr ""
#: ../parser_regex.c:98 ../parser_regex.c:238
#, c-format
msgid "%s: Invalid glob type %d\n"
msgstr ""
#: ../parser_regex.c:693
#, c-format
msgid "The current kernel does not support stacking of named transitions: %s\n"
msgstr ""

48
parser/profile-load Executable file
View File

@@ -0,0 +1,48 @@
#!/bin/sh
# profile-load
#
# ----------------------------------------------------------------------
# Copyright (c) 2010-2015 Canonical, Ltd.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# 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.
# ----------------------------------------------------------------------
#
# Helper for loading an AppArmor profile in pre-start scripts.
[ -z "$1" ] && exit 1 # require a profile name
. /lib/apparmor/rc.apparmor.functions
# do not load in a container
[ -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
profile=/etc/apparmor.d/"$1"
[ -e "$profile" ] || exit 0 # skip when missing profile
module=/sys/module/apparmor
[ -d $module ] || exit 0 # do not load without AppArmor in kernel
[ -x /sbin/apparmor_parser ] || exit 0 # do not load without parser
aafs=/sys/kernel/security/apparmor
[ -d $aafs ] || exit 0 # do not load if unmounted
[ -w $aafs/.load ] || exit 1 # fail if cannot load profiles
params=$module/parameters
[ -r $params/enabled ] || exit 0 # do not load if missing
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

View File

@@ -181,10 +181,10 @@ __parse_profiles_dir() {
if [ ! -f "$profile" ] ; then
continue
fi
echo "$profile"
printf "%s\0" "$profile"
done | \
# Use xargs to parallelize calls to the parser over all CPUs
xargs -n1 -d"\n" --max-procs="$(getconf _NPROCESSORS_ONLN)" \
xargs -n1 -0r -P "$(getconf _NPROCESSORS_ONLN)" \
"$PARSER" $PARSER_OPTS "$parser_cmd" --
if [ $? -ne 0 ]; then
status=1

View File

@@ -17,8 +17,8 @@ endif
all: tests
.PHONY: tests error_output gen_dbus gen_xtrans parser_sanity caching minimize equality valgrind
tests: error_output caching minimize equality parser_sanity
.PHONY: tests error_output gen_dbus gen_xtrans parser_sanity caching minimize equality dirtest valgrind
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
@@ -46,6 +46,9 @@ minimize: $(PARSER)
equality: $(PARSER)
LANG=C APPARMOR_PARSER="$(PARSER) $(PARSER_ARGS)" ./equality.sh
dirtest: $(PARSER)
LANG=C APPARMOR_PARSER="$(PARSER) $(PARSER_ARGS)" ./dirtest.sh
valgrind: $(PARSER) gen_xtrans gen_dbus
LANG=C ./valgrind_simple.py -p "$(PARSER) $(PARSER_ARGS)" -v simple_tests

73
parser/tst/dirtest.sh Executable file
View File

@@ -0,0 +1,73 @@
#!/bin/sh
#
# Copyright (c) 2022
# 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.
#
# simple test to ensure dir is being iterated as expected
# yes this needs to be improved and reworked
# passed in by Makefile
#APPARMOR_PARSER="${APPARMOR_PARSER:-../apparmor_parser}"
do_tst() {
local msg="$1"
local expected="$2"
local rc=0
shift 2
#global tmpdir
${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
fi
if [ $rc -eq 0 ] && [ "$expected" = "fail" ] ; then
echo "succeeded unexpectedly: expected \"$expected\" but parser returned success"
return 1
fi
if ! diff -q "$tmpdir/out" dirtest/dirtest.out ; then
echo "failed: expected \"$expected\" but output comparison failed"
diff -u dirtest/dirtest.out "$tmpdir/out"
return 1
fi
return 0
}
tmpdir=$(mktemp -d "$tmpdir.XXXXXXXX")
chmod 755 "$tmpdir"
export tmpdir
rc=0
# pass - no parser errors and output matches
# error - parser error and output matches
# fail - comparison out parser output failed
do_tst "good dir list" pass -N dirtest/gooddir/ || rc=1
do_tst "bad link in dir" fail -N dirtest/badlink/ || rc=1
do_tst "bad profile in dir" fail -N dirtest/badprofile/ || rc=1
rm -rf "$tmpdir"
if [ $rc -eq 0 ] ; then
echo "PASS"
fi
exit $rc

View File

@@ -0,0 +1 @@
foo

View File

@@ -0,0 +1 @@
../goodtarget

View File

@@ -0,0 +1,2 @@
profile a_profile {
}

View File

@@ -0,0 +1,2 @@
profile b_profile {
}

View File

@@ -0,0 +1,3 @@
profile bad_profile {
file
}

View File

@@ -0,0 +1 @@
../goodtarget

View File

@@ -0,0 +1,2 @@
profile a_profile {
}

View File

@@ -0,0 +1,2 @@
profile b_profile {
}

View File

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

View File

@@ -0,0 +1 @@
../goodtarget

View File

@@ -0,0 +1,2 @@
profile a_profile {
}

View File

@@ -0,0 +1,2 @@
profile b_profile {
}

View File

@@ -0,0 +1,2 @@
profile good_target {
}

View File

@@ -618,6 +618,31 @@ verify_binary_equality "mount rules slash filtering" \
"@{FOO}=/foo
/t { mount /dev//@{FOO} -> /mnt/bar, }"
# verify slash filtering for link rules
verify_binary_equality "link rules slash filtering" \
"/t { link /dev/foo -> /mnt/bar, }" \
"/t { link ///dev/foo -> /mnt/bar, }" \
"/t { link /dev/foo -> /mnt//bar, }" \
"/t { link /dev///foo -> ////mnt/bar, }" \
"@{BAR}=/mnt/
/t { link /dev///foo -> @{BAR}/bar, }" \
"@{FOO}=/dev/
/t { link @{FOO}//foo -> /mnt/bar, }" \
"@{FOO}=/dev/
@{BAR}=/mnt/
/t { link @{FOO}/foo -> @{BAR}/bar, }"
verify_binary_equality "attachment slash filtering" \
"/t /bin/foo { }" \
"/t /bin//foo { }" \
"@{BAR}=/bin/
/t @{BAR}/foo { }" \
"@{FOO}=/foo
/t /bin/@{FOO} { }" \
"@{BAR}=/bin/
@{FOO}=/foo
/t @{BAR}/@{FOO} { }"
if [ $fails -ne 0 ] || [ $errors -ne 0 ]
then
printf "ERRORS: %d\nFAILS: %d\n" $errors $fails 2>&1

View File

@@ -0,0 +1,7 @@
#
#=DESCRIPTION includes testing - recursive include should not fail
#=EXRESULT PASS
#
/does/not/exist {
#include <includes/recursive.include>
}

View File

@@ -0,0 +1,10 @@
#
#=DESCRIPTION includes testing - recursive include should not fail
#=EXRESULT PASS
#
#include <includes/recursive.preamble>
/does/not/exist {
/foo r,
}

View File

@@ -0,0 +1,6 @@
# helper for include_tests/recursive_2.sd
/foo rw,
#include <includes/recursive.include>
/no/such/path r,

View File

@@ -0,0 +1,4 @@
# helper for include_tests/recursive_3.sd
#include <includes/recursive.preamble>

View File

@@ -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)
@@ -180,7 +180,7 @@ def read_features_dir(path):
if not os.path.exists(path) or not os.path.isdir(path):
return result
for name in os.listdir(path):
for name in sorted(os.listdir(path)):
entry = os.path.join(path, name)
result += '%s {' % name
if os.path.isfile(entry):

View File

@@ -41,7 +41,7 @@ ifdef USE_SYSTEM
LOGPROF?=aa-logprof
else
# PYTHON_DIST_BUILD_PATH based on libapparmor/swig/python/test/Makefile.am
PYTHON_DIST_BUILD_PATH = ../libraries/libapparmor/swig/python/build/$$($(PYTHON) -c "import distutils.util; import platform; print(\"lib.%s-%s\" %(distutils.util.get_platform(), platform.python_version()[:3]))")
PYTHON_DIST_BUILD_PATH = ../libraries/libapparmor/swig/python/build/$$($(PYTHON) ../libraries/libapparmor/swig/python/test/buildpath.py)
LIBAPPARMOR_PATH=../libraries/libapparmor/src/.libs/
LD_LIBRARY_PATH=$(LIBAPPARMOR_PATH):$(PYTHON_DIST_BUILD_PATH)
PYTHONPATH=../utils/:$(PYTHON_DIST_BUILD_PATH)

View File

@@ -17,6 +17,7 @@
# .ICEauthority files required for X authentication, per user
owner @{HOME}/.ICEauthority r,
owner @{run}/user/*/ICEauthority r,
# .Xauthority files required for X connections, per user
owner @{HOME}/.Xauthority r,
@@ -29,7 +30,7 @@
owner @{run}/user/*/xauth_* r,
# the unix socket to use to connect to the display
/tmp/.X11-unix/* r,
/tmp/.X11-unix/* rw,
unix (connect, receive, send)
type=stream
peer=(addr="@/tmp/.X11-unix/X[0-9]*"),
@@ -51,6 +52,8 @@
# Xcompose
owner @{HOME}/.XCompose r,
/var/cache/libx11/compose/* r,
deny /var/cache/libx11/compose/* wlk,
# mouse themes
/etc/X11/cursors/ r,

View File

@@ -6,6 +6,10 @@
include <abstractions/nameservice>
# Allow other processes to read our /proc entries
ptrace (readby),
# Allow other processes to trace us by default
ptrace (tracedby),
# Allow unconfined processes to send us signals by default
signal (receive) peer=unconfined,
# Allow apache to send us signals by default

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