2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-02 15:25:27 +00:00

Compare commits

...

36 Commits

Author SHA1 Message Date
John Johansen
ac03ae4e72 Release: Bump revision for 2.10.6 release
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-12-07 04:39:38 -08:00
Christian Boltz
085d4cd0e2 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:09:41 -08:00
Christian Boltz
f305bb1831 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:07:16 -07:00
Christian Boltz
9f0415e1ab Add CAP_BPF and CAP_PERFMON to severity.db
These capabilities were introduced in Linux 5.8

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/589
References: https://bugs.launchpad.net/bugs/1890547
(cherry picked from commit ae01250209)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-15 03:06:48 -07:00
John Johansen
0acc2cd67c parser: call filter slashes for mount conditionals
The mnt_point and devices conditionals in mount rules are generally
paths and should have slashes filtered after variable expansion.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/607
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit a1978fb1b2)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-09 02:46:08 -07:00
John Johansen
41091fd411 parser: call filter slashes for the dbus path conditional
Similar to unix addr rules, the dbus path conditional is more a path
than a profile name and should get its slashes filtered after variable
expansion.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/607
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 35f6d49ec6)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-09 02:46:08 -07:00
John Johansen
b5ffee530b parser: enable variable expansion for mount type= and options=
Currently mount options type= and options= do not expand variables
but they should. Fix it.

Note: this does not treat either as paths because their use is
too device dependent for it to be safe to filter slashes.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/99
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/638
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 882380ad3d)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-09 02:46:08 -07:00
Patrick Steinhardt
ab49c3dbb0 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.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
(cherry picked from commit 47263a3a74)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-03 13:22:57 -07:00
Patrick Steinhardt
92a6360570 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)
2020-10-03 12:26:37 -07:00
John Johansen
f4346f63f6 parser: Fix expansion of variables in unix rules addr= conditional
The parser is not treating unix addr as a path and filtering slashes
after variable expansion. This can lead to errors where

@{foo}=/a/
unix bind addr=@{foo}/bar,

will always fail because addr is being matched as /a//bar instead of
/a/bar.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/607
Fixes: https://bugs.launchpad.net/apparmor/+bug/1856738
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit 6af05006d9)
2020-09-29 12:02:32 -07:00
John Johansen
6eef48828c regression tests: Don't build syscall_sysctl if missing kernel headers
sys/sysctl.h is not guaranteed to exist anymore since
https://sourceware.org/pipermail/glibc-cvs/2020q2/069366.html

which is a follow on to the kernel commit
61a47c1ad3a4 sysctl: Remove the sysctl system call

While the syscall_sysctl currently checks if the kernel supports
sysctrs before running the tests. The tests can't even build if the
kernel headers don't have the sysctl defines.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/119
Fixes: https://bugs.launchpad.net/apparmor/+bug/1897288
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/637
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 2e5a266eb7)
2020-09-29 11:58:02 -07:00
Ian Johnson
8e0cfd04f4 docs: fix typo in man doc of unix rules
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
(cherry picked from commit f4220a19be)
2020-01-31 22:24:18 -08:00
Christian Boltz
bb9bc18a0e Merge branch 'cboltz-abstractions-kerberos' into 'master'
abstractions/kerberosclient: allow reading /etc/krb5.conf.d/

See merge request apparmor/apparmor!425

Acked-by: Steve Beattie <steve@nxnw.org> for 2.10..master
Acked-by: John Johansen <john.johansen@canonical.com> for 2.10..master


(cherry picked from commit 663546c284)

dffed831 abstractions/kerberosclient: allow reading /etc/krb5.conf.d/
2019-11-18 21:36:17 +00:00
Christian Boltz
e3b04d4f81 Merge branch 'cboltz-status-parenthesis' into 'master'
aa-status: handle profile names containing '('

Closes #51

See merge request apparmor/apparmor!415

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

(cherry picked from commit b76567ce10)

41d26b01 aa-status: handle profile names containing '('
2019-09-23 18:56:15 +00:00
Paulo Gomes
9bdd2a3f6f Fix capability mispelling.
PR: https://gitlab.com/apparmor/apparmor/merge_requests/421
(cherry picked from commit 2d19d4d159)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-09-20 02:17:47 -07:00
Tyler Hicks
46fb957dd4 parser: Fix typoed example dbus rule in apparmor.d(5) man page
Remove extra closing parenthesis.

Bug: https://launchpad.net/bugs/1838991
Fixes: 46586a6334 ("parser: Add example dbus rule for unconfined peers")
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>

(cherry picked from commit 7df48adae5)
Ref: https://gitlab.com/apparmor/apparmor/merge_requests/410
Acked-by: Christian Boltz <apparmor@cboltz.de>
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2019-08-05 17:12:39 +00:00
Christian Boltz
f59bc8b952 Merge branch 'cboltz-unbalanced-parenthesis' into 'master'
Fix crash on unbalanced parenthesis in filename

See merge request apparmor/apparmor!402

Seth Arnold <seth.arnold@canonical.com> for 2.10..master

(cherry picked from commit db1f391844)

8f74ac02 Fix crash on unbalanced parenthesis in filename
2019-07-09 19:46:08 +00:00
Christian Boltz
5278708ea0 Merge branch 'cboltz-2.13-certbot' into 'apparmor-2.13'
[2.10..2.13] Add for Certbot on openSUSE Leap

See merge request apparmor/apparmor!398

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

(cherry picked from commit 14a11e67a5)

8b766451 Add for Certbot on openSUSE Leap
2019-06-30 07:15:17 +00:00
John Johansen
6a871a5082 Release: Bumper version for the 2.10.5 release
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-18 13:18:17 -07:00
Petr Vorel
3dd6034839 dnsmasq: Add permission to open log files
--log-facility option needs to have permission to open files.
Use '*' to allow using more files (for using more dnsmasq instances).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Jamie Strandboge <jamie@canonical.com>
(cherry picked from commit 025c7dc6a1)
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-18 04:23:40 -07:00
Christian Boltz
84791175e8 syslog-ng: add abstractions/python for python-parser
When running syslog-ng with a defined python-parser, it needs access to
python libraries.

For details about python-parser, see
https://www.syslog-ng.com/community/b/blog/posts/format-your-log-messages-in-python

References: https://github.com/balabit/syslog-ng/issues/2625
PR: https://gitlab.com/apparmor/apparmor/merge_requests/361
(cherry picked from commit 234a924480)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-13 17:43:17 -07:00
Jörg Sommer
f1bca36c18 parser: Fix parsing of arrow “px -> …”
The parser failed to read the profile name after the the arrow. Rules with
`-> foo-bar;` failed with “Found unexpected character: '-'”. Rules with
`-> @{tgt};` compiled fine, but failed at runtime with “profile transition
not found”.

The patch was written by sbeattie and published on
https://paste.ubuntu.com/p/tzxxmVwGJ8/

https://matrix.to/#/!pNJIrowvqsuGgjXsEY:matrix.org/$15477566201815716pmube:matrix.org?via=matrix.org&via=alea.gnuu.de
PR: https://gitlab.com/apparmor/apparmor/merge_requests/334
(cherry picked from commit 0e0663e99e)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-13 17:37:41 -07:00
John Johansen
5a2db81f93 libapparmor python: Fix 'aa_log_record' object has no attribute '__getattr__'
When building with swig 4 we are seeing the error

AttributeError: 'aa_log_record' object has no attribute '__getattr__'

Which forces swig to use modern classes which do not generate __getattr__
methods.

issue: https://gitlab.com/apparmor/apparmor/issues/33
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit a6ac6f4cfc)
2019-06-04 21:52:49 -07:00
John Johansen
d86c290e85 tests/regression: fix mount test to use next available loop device
looping through the first 16 loop devices to find a free device will
fail if those mount devices are taken, and unfortunately there are
now services that use an excessive amount of loop devices causing
the regression test to fail.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/379
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
(cherry picked from commit ab0f2af1da)
2019-05-11 22:28:24 -07:00
Christian Boltz
593b1fb930 Merge branch 'cboltz-gitignore' into 'master'
Add several libapparmor/swig/ruby files to gitignore

See merge request apparmor/apparmor!366

(cherry picked from commit 9c11ce37c6)

7ed1a16a Add several libapparmor/swig/ruby files to gitignore
2019-04-26 16:17:09 +00:00
Goldwyn Rodrigues
b27e323ded identd: Add network netlink dgram
identd requires access to network netlink dgram.

(cherry picked from commit 1d75abba3f)
PR: https://gitlab.com/apparmor/apparmor/merge_requests/353
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-03-29 01:09:09 -07:00
Simon Deziel
6377b1c492 dovecot: master SIGTERM child that are slow to die
When doing a service reload, I noticed the following:

    ```Mar 22 15:52:27 smtp dovecot: master: Warning: SIGHUP received - reloading configuration
    Mar 22 15:52:27 smtp dovecot: imap(simon): Server shutting down. in=35309 out=232805
    Mar 22 15:52:27 smtp dovecot: imap(simon): Server shutting down. in=24600 out=1688166
    Mar 22 15:52:27 smtp dovecot: imap(simon): Server shutting down. in=14026 out=95516
    Mar 22 15:52:27 smtp dovecot: imap(simon): Server shutting down. in=13776 out=141513
    Mar 22 15:52:33 smtp dovecot: master: Warning: Processes aren't dying after reload, sending SIGTERM.
    Mar 22 15:52:33 smtp dovecot: master: Error: service(imap): kill(5806, 15) failed: Permission denied
    Mar 22 15:52:33 smtp dovecot: master: Error: service(imap-login): kill(5804, 15) failed: Permission denied
    Mar 22 15:52:33 smtp dovecot: master: Error: service(config): kill(506, 15) failed: Permission denied
    Mar 22 15:52:33 smtp kernel: [65542.184326] audit: type=1400 audit(1553284353.609:82): apparmor="DENIED" operation="signal" profile="dovecot" pid=414 comm="dovecot" requested_mask="send" denied_mask="send" signal=term peer="/usr/lib/dovecot/imap"
    Mar 22 15:52:33 smtp kernel: [65542.197596] audit: type=1400 audit(1553284353.625:83): apparmor="DENIED" operation="signal" profile="dovecot" pid=414 comm="dovecot" requested_mask="send" denied_mask="send" signal=term peer="/usr/lib/dovecot/imap-login"
    Mar 22 15:52:33 smtp kernel: [65542.197635] audit: type=1400 audit(1553284353.625:84): apparmor="DENIED" operation="signal" profile="dovecot" pid=414 comm="dovecot" requested_mask="send" denied_mask="send" signal=term peer="/usr/lib/dovecot/config"
    Mar 22 15:52:36 smtp dovecot: imap(simon): Server shutting down. in=17882 out=104004
    ```

The server was heavily loaded which is probably why it ended up trying to SIGTERM those.

Signed-off-by: Simon Deziel <simon@sdeziel.info>
(cherry picked from commit f01fd38ca0)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-03-22 16:08:46 -07:00
Christian Boltz
4b33ae0e03 Merge branch 'dovecot-fixes-no-doveadm' into 'master'
misc dovecot fixes (take #2)

See merge request apparmor/apparmor!336

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

(cherry picked from commit e68beb988a)

a57f01d8 dovecot: allow FD passing between dovecot and dovecot's anvil
d0aa863f dovecot: allow chroot'ing the auth processes
9afeb225 dovecot: let dovecot/anvil rw the auth-penalty socket
17db8f38 dovecot: auth processes need to read from postfix auth socket
6a7c49b1 dovecot: add abstractions/ssl_certs to lmtp
2019-02-17 21:05:09 +00:00
John Johansen
47e348d5c5 Merge: [2.10] Add two parser files to .bzrignore
parser/libapparmor_re/parse.cc is autogenerated during build parser/tst_lib gets compiled during "make check"

Both files get deleted by make clean.

This is the only remaining difference between 2.10 and newer .gitignore files, and the two files already get generated in 2.10.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/319
(cherry picked from commit 9d5934f5)
Signed-off-by: John Johansen john.johansen@canonical.com
2019-01-29 10:53:27 +00:00
Christian Boltz
4b56928dc9 Add two parser files to .bzrignore
- parser/libapparmor_re/parse.cc is autogenerated during build
- parser/tst_lib gets compiled during "make check"

Both files get deleted by make clean.


Acked-by: John Johansen <john.johansen@canonical.com> for trunk and 2.11.

(cherry picked from commit 9d5934f5ff)
2019-01-27 21:46:04 +01:00
Marius Tomaschewski
88d513a8ca abstractions/nameservice: allow /run/netconfig/resolv.conf
Latest netconfig in openSUSE writes /run/netconfig/resolv.conf, and only
has a symlink to it in /etc

References: https://bugzilla.opensuse.org/show_bug.cgi?id=1097370
Acked-by: Christian Boltz <apparmor@cboltz.de>
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit b0bacba9db)
2019-01-24 02:46:52 -08:00
Jamie Strandboge
30a3e58464 Merge branch 'update-fonts' into 'master'
Update fonts for Debian and openSUSE

- Allow to read conf-avail dir itself.
- Add various openSUSE-specific font config directories.

See merge request !96 (merged) for details.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/309
(cherry picked from commit 7bd3029f25)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-01-23 20:13:24 -08:00
Christian Boltz
8916f1f4ad Merge branch 'fix-compose-cache' into 'master'
qt5-compose-cache-write: fix anonymous shared memory access

See merge request apparmor/apparmor!301

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

(cherry picked from commit 027dcdb23f)

12504024 qt5-compose-cache-write: fix anonymous shared memory access
2019-01-14 20:51:53 +00:00
Christian Boltz
ba67b0cc98 Merge branch 'fix-qt5-settings' into 'master'
qt5-settings-write: fix anonymous shared memory access

See merge request apparmor/apparmor!302

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

(cherry picked from commit 3e3c90152f)

f1200873 qt5-settings-write: fix anonymous shared memory access
8f6a8fb1 Refactor qt5-settings-write
2019-01-14 20:49:05 +00:00
Christian Boltz
6ff8c1ec1a Merge branch 'var-lib-dehydrated' into 'master'
abstractions/ssl_{certs,keys}: dehydrated uses /var/lib on Debian

See merge request apparmor/apparmor!299

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

(cherry picked from commit 1f53de174d)

1306f9a6 abstractions/ssl_{certs,keys}: dehydrated uses /var/lib on Debian
c5a89d5d abstractions/ssl_{certs,keys}: sort the alternation for dehydrated and drop...
04b2842e abstractions/ssl_{certs,keys}: allow reading ocsp.der maintained by dehydrated for OCSP stapling
2019-01-03 17:33:35 +00:00
John Johansen
384ce01def parser: fix abi rule core dump
abi rule skipping is core dumping on some bad abi rule file names.

[  112s] #   Failed test './simple_tests//abi/bad_10.sd: Produced core dump (signal 6): abi testing - abi path quotes in <> with spaces'
[  112s] #   at simple.pl line 126.
[  112s]
[  112s] #   Failed test './simple_tests//abi/bad_11.sd: Produced core dump (signal 6): abi testing - abi path quotes in <> with spaces'
[  112s] #   at simple.pl line 126.
[  112s]
[  112s] #   Failed test './simple_tests//abi/bad_12.sd: Produced core dump (signal 6): abi testing - abi path quotes in <> with spaces'
[  112s] #   at simple.pl line 126.

This is caused by calling processquoted without ensuring that that the
length being processed is valid.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2019-01-02 13:44:35 -08:00
38 changed files with 130 additions and 42 deletions

8
.gitignore vendored
View File

@@ -8,6 +8,7 @@ binutils/po/*.mo
parser/po/*.mo parser/po/*.mo
parser/af_names.h parser/af_names.h
parser/cap_names.h parser/cap_names.h
parser/tst_lib
parser/tst_misc parser/tst_misc
parser/tst_regex parser/tst_regex
parser/tst_symtab parser/tst_symtab
@@ -56,6 +57,7 @@ parser/*.7.html
parser/*.5.html parser/*.5.html
parser/*.8.html parser/*.8.html
parser/apparmor_parser parser/apparmor_parser
parser/libapparmor_re/parse.cc
parser/libapparmor_re/regexp.cc parser/libapparmor_re/regexp.cc
parser/techdoc.aux parser/techdoc.aux
parser/techdoc.log parser/techdoc.log
@@ -161,8 +163,14 @@ libraries/libapparmor/swig/python/test/test-suite.log
libraries/libapparmor/swig/python/test/test_python.py libraries/libapparmor/swig/python/test/test_python.py
libraries/libapparmor/swig/python/test/test_python.py.log libraries/libapparmor/swig/python/test/test_python.py.log
libraries/libapparmor/swig/python/test/test_python.py.trs libraries/libapparmor/swig/python/test/test_python.py.trs
libraries/libapparmor/swig/ruby/LibAppArmor.so
libraries/libapparmor/swig/ruby/LibAppArmor_wrap.c
libraries/libapparmor/swig/ruby/LibAppArmor_wrap.o
libraries/libapparmor/swig/ruby/Makefile libraries/libapparmor/swig/ruby/Makefile
libraries/libapparmor/swig/ruby/Makefile.in libraries/libapparmor/swig/ruby/Makefile.in
libraries/libapparmor/swig/ruby/Makefile.new
libraries/libapparmor/swig/ruby/Makefile.ruby
libraries/libapparmor/swig/ruby/mkmf.log
libraries/libapparmor/testsuite/.deps libraries/libapparmor/testsuite/.deps
libraries/libapparmor/testsuite/.libs libraries/libapparmor/testsuite/.libs
libraries/libapparmor/testsuite/Makefile libraries/libapparmor/testsuite/Makefile

View File

@@ -1 +1 @@
2.10.4 2.10.6

View File

@@ -20,6 +20,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
__BEGIN_DECLS __BEGIN_DECLS

View File

@@ -90,6 +90,7 @@ APPARMOR_2.10 {
PRIVATE { PRIVATE {
global: global:
_aa_is_blacklisted; _aa_is_blacklisted;
_aa_asprintf;
_aa_autofree; _aa_autofree;
_aa_autoclose; _aa_autoclose;
_aa_autofclose; _aa_autofclose;

View File

@@ -109,7 +109,7 @@ class AAPythonBindingsTests(unittest.TestCase):
new_record = dict() 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 = record.__getattr__(key) value = getattr(record, key)
if key == "event" and value in EVENT_MAP: if key == "event" and value in EVENT_MAP:
new_record[key] = EVENT_MAP[value] new_record[key] = EVENT_MAP[value]
elif key == "version": elif key == "version":

View File

@@ -0,0 +1 @@
type=AVC msg=audit(1562529588.082:3153): apparmor="DENIED" operation="open" profile="unbalanced_parenthesis" name="/dev/shm/test(me" pid=888 comm="cat" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000

View File

@@ -0,0 +1,15 @@
START
File: unbalanced_parenthesis.in
Event type: AA_RECORD_DENIED
Audit ID: 1562529588.082:3153
Operation: open
Mask: r
Denied Mask: r
fsuid: 1000
ouid: 1000
Profile: unbalanced_parenthesis
Name: /dev/shm/test(me
Command: cat
PID: 888
Epoch: 1562529588
Audit subid: 3153

View File

@@ -0,0 +1,4 @@
profile unbalanced_parenthesis {
owner /dev/shm/test(me r,
}

View File

@@ -151,9 +151,11 @@ int unix_rule::expand_variables(void)
error = expand_entry_variables(&addr); error = expand_entry_variables(&addr);
if (error) if (error)
return error; return error;
filter_slashes(addr);
error = expand_entry_variables(&peer_addr); error = expand_entry_variables(&peer_addr);
if (error) if (error)
return error; return error;
filter_slashes(peer_addr);
return 0; return 0;
} }

View File

@@ -1032,7 +1032,7 @@ Example AppArmor DBus rules:
peer=(name=(com.example.ExampleName1|com.example.ExampleName2)), peer=(name=(com.example.ExampleName1|com.example.ExampleName2)),
# Allow receive access for all unconfined peers # Allow receive access for all unconfined peers
dbus receive peer=(label=unconfined)), dbus receive peer=(label=unconfined),
# Allow eavesdropping on the system bus # Allow eavesdropping on the system bus
dbus eavesdrop bus=system, dbus eavesdrop bus=system,
@@ -1152,7 +1152,7 @@ E.G.
network unix stream, => unix stream, network unix stream, => unix stream,
Fine grained mediation rules however can not be lossly converted back Fine grained mediation rules however can not be losslessly converted back
to the coarse grained network rule; e.g. to the coarse grained network rule; e.g.
unix bind addr=@example, unix bind addr=@example,

View File

@@ -179,6 +179,7 @@ int dbus_rule::expand_variables(void)
error = expand_entry_variables(&path); error = expand_entry_variables(&path);
if (error) if (error)
return error; return error;
filter_slashes(path);
error = expand_entry_variables(&interface); error = expand_entry_variables(&interface);
if (error) if (error)
return error; return error;

View File

@@ -486,18 +486,32 @@ ostream &mnt_rule::dump(ostream &os)
/* does not currently support expansion of vars in options */ /* does not currently support expansion of vars in options */
int mnt_rule::expand_variables(void) int mnt_rule::expand_variables(void)
{ {
struct value_list *ent;
int error = 0; int error = 0;
error = expand_entry_variables(&mnt_point); error = expand_entry_variables(&mnt_point);
if (error) if (error)
return error; return error;
filter_slashes(mnt_point);
error = expand_entry_variables(&device); error = expand_entry_variables(&device);
if (error) if (error)
return error; return error;
filter_slashes(device);
error = expand_entry_variables(&trans); error = expand_entry_variables(&trans);
if (error) if (error)
return error; return error;
list_for_each(dev_type, ent) {
error = expand_entry_variables(&ent->value);
if (error)
return error;
}
list_for_each(opts, ent) {
error = expand_entry_variables(&ent->value);
if (error)
return error;
}
return 0; return 0;
} }

View File

@@ -364,6 +364,7 @@ extern int post_process_entry(struct cod_entry *entry);
extern int process_policydb(Profile *prof); extern int process_policydb(Profile *prof);
extern int process_policy_ents(Profile *prof); extern int process_policy_ents(Profile *prof);
extern void filter_slashes(char *path);
/* parser_variable.c */ /* parser_variable.c */
int expand_entry_variables(char **name); int expand_entry_variables(char **name);

View File

@@ -317,9 +317,12 @@ LT_EQUAL <=
<ABI_MODE>{ <ABI_MODE>{
(\<(([^"\>\t\r\n]+)|{QUOTED_ID})\>|{QUOTED_ID}|{IDS}) { /* <filename> | <"filename"> | "filename" | filename */ (\<(([^"\>\t\r\n]+)|{QUOTED_ID})\>|{QUOTED_ID}|{IDS}) { /* <filename> | <"filename"> | "filename" | filename */
int lt = *yytext == '<' ? 1 : 0; int lt = *yytext == '<' ? 1 : 0;
char *filename = processid(yytext + lt, yyleng - lt*2); char *filename;
bool exists = YYSTATE == INCLUDE_EXISTS; bool exists = YYSTATE == INCLUDE_EXISTS;
if (yyleng - lt < 1)
yyerror(_("Bad filename\n"));
filename = processid(yytext + lt, yyleng - lt*2);
if (!filename) if (!filename)
yyerror(_("Failed to process filename\n")); yyerror(_("Failed to process filename\n"));
yylval.id = filename; yylval.id = filename;
@@ -594,7 +597,7 @@ include/{WS} {
{CARET} { PUSH_AND_RETURN(SUB_ID, TOK_CARET); } {CARET} { PUSH_AND_RETURN(SUB_ID, TOK_CARET); }
{ARROW} { RETURN_TOKEN(TOK_ARROW); } {ARROW} { PUSH_AND_RETURN(SUB_ID_WS, TOK_ARROW); }
{EQUALS} { PUSH_AND_RETURN(ASSIGN_MODE, TOK_EQUALS); } {EQUALS} { PUSH_AND_RETURN(ASSIGN_MODE, TOK_EQUALS); }

View File

@@ -47,7 +47,7 @@ enum error_type {
* that's a distinct namespace in linux) and trailing slashes. * that's a distinct namespace in linux) and trailing slashes.
* NOTE: modifies in place the contents of the path argument */ * NOTE: modifies in place the contents of the path argument */
static void filter_slashes(char *path) void filter_slashes(char *path)
{ {
char *sptr, *dptr; char *sptr, *dptr;
BOOL seen_slash = 0; BOOL seen_slash = 0;

View File

@@ -55,6 +55,8 @@
# Xcompose # Xcompose
owner @{HOME}/.XCompose r, owner @{HOME}/.XCompose r,
/var/cache/libx11/compose/* r,
deny /var/cache/libx11/compose/* wlk,
# mouse themes # mouse themes
/etc/X11/cursors/ r, /etc/X11/cursors/ r,

View File

@@ -18,7 +18,9 @@
/usr/share/fonts/** r, /usr/share/fonts/** r,
/etc/fonts/** r, /etc/fonts/** r,
/usr/share/fontconfig/conf.avail/** r, # Debian, openSUSE paths are different
/usr/share/{fontconfig,fonts-config,*-fonts}/conf.avail/{,**} r,
/usr/share/ghostscript/fonts/{,**} r,
/opt/kde3/share/fonts/** r, /opt/kde3/share/fonts/** r,

View File

@@ -22,6 +22,8 @@
/etc/krb5.keytab rk, /etc/krb5.keytab rk,
/etc/krb5.conf r, /etc/krb5.conf r,
/etc/krb5.conf.d/ r,
/etc/krb5.conf.d/* r,
# config files found via strings on libs # config files found via strings on libs
/etc/krb.conf r, /etc/krb.conf r,

View File

@@ -39,7 +39,7 @@
/etc/resolv.conf r, /etc/resolv.conf r,
# On systems where /etc/resolv.conf is managed programmatically, it is # On systems where /etc/resolv.conf is managed programmatically, it is
# a symlink to /{,var/}run/(whatever program is managing it)/resolv.conf. # a symlink to /{,var/}run/(whatever program is managing it)/resolv.conf.
/{,var/}run/{resolvconf,NetworkManager,systemd/resolve,connman}/resolv.conf r, /{,var/}run/{resolvconf,NetworkManager,systemd/resolve,connman,netconfig}/resolv.conf r,
/etc/resolvconf/run/resolv.conf r, /etc/resolvconf/run/resolv.conf r,
/etc/samba/lmhosts r, /etc/samba/lmhosts r,

View File

@@ -3,5 +3,6 @@
# User files # User files
owner @{HOME}/.cache/qt_compose_cache_{little,big}_endian_* rw, owner @{HOME}/.cache/qt_compose_cache_{little,big}_endian_* rwl -> @{HOME}/.cache/#[0-9]*[0-9],
owner @{HOME}/.cache/#[0-9]*[0-9] rw, # QSaveFile (anonymous shared memory)

View File

@@ -3,9 +3,9 @@
# User files # User files
owner @{HOME}/.config/#[0-9]* rw, owner @{HOME}/.config/#[0-9]*[0-9] rw,
owner @{HOME}/.config/QtProject.conf rw, owner @{HOME}/.config/QtProject.conf rwl -> @{HOME}/.config/#[0-9]*[0-9],
owner @{HOME}/.config/QtProject.conf.?????? l -> @{HOME}/.config/#[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9], # for temporary files like QtProject.conf.Aqrgeb
owner @{HOME}/.config/QtProject.conf.?????? rw, # for temporary files like QtProject.conf.Aqrgeb owner @{HOME}/.config/QtProject.conf.?????? rwl -> @{HOME}/.config/#[0-9]*[0-9],
owner @{HOME}/.config/QtProject.conf.lock rwk, owner @{HOME}/.config/QtProject.conf.lock rwk,

View File

@@ -29,11 +29,16 @@
/var/lib/acme/certs/*/cert r, /var/lib/acme/certs/*/cert r,
# dehydrated # dehydrated
/etc/dehydrated/certs/*/cert-*.pem r, /{etc,var/lib}/dehydrated/certs/*/cert*.pem r,
/etc/dehydrated/certs/*/chain-*.pem r, /{etc,var/lib}/dehydrated/certs/*/chain*.pem r,
/etc/dehydrated/certs/*/fullchain-*.pem r, /{etc,var/lib}/dehydrated/certs/*/fullchain*.pem r,
/{etc,var/lib}/dehydrated/certs/*/ocsp*.der r,
# certbot # certbot
/etc/letsencrypt/archive/*/cert*.pem r, /etc/letsencrypt/archive/*/cert*.pem r,
/etc/letsencrypt/archive/*/chain*.pem r, /etc/letsencrypt/archive/*/chain*.pem r,
/etc/letsencrypt/archive/*/fullchain*.pem r, /etc/letsencrypt/archive/*/fullchain*.pem r,
/etc/certbot/archive/*/cert*.pem r,
/etc/certbot/archive/*/chain*.pem r,
/etc/certbot/archive/*/fullchain*.pem r,

View File

@@ -22,7 +22,9 @@
/var/lib/acme/keys/** r, /var/lib/acme/keys/** r,
# dehydrated # dehydrated
/etc/dehydrated/certs/*/privkey-*.pem r, /{etc,var/lib}/dehydrated/certs/*/privkey*.pem r,
# certbot / letsencrypt # certbot / letsencrypt
/etc/letsencrypt/archive/*/privkey*.pem r, /etc/letsencrypt/archive/*/privkey*.pem r,
/etc/certbot/archive/*/privkey*.pem r,

View File

@@ -21,6 +21,7 @@ profile syslog-ng /{usr/,}sbin/syslog-ng {
#include <abstractions/nameservice> #include <abstractions/nameservice>
#include <abstractions/mysql> #include <abstractions/mysql>
#include <abstractions/openssl> #include <abstractions/openssl>
#include <abstractions/python>
capability chown, capability chown,
capability dac_override, capability dac_override,

View File

@@ -18,7 +18,10 @@
capability setuid, capability setuid,
capability sys_chroot, capability sys_chroot,
unix (receive, send) type=stream peer=(label=dovecot),
/run/dovecot/anvil rw, /run/dovecot/anvil rw,
/run/dovecot/anvil-auth-penalty rw,
/usr/lib/dovecot/anvil mr, /usr/lib/dovecot/anvil mr,
# Site-specific additions and overrides. See local/README for details. # Site-specific additions and overrides. See local/README for details.

View File

@@ -25,6 +25,7 @@
capability dac_override, capability dac_override,
capability dac_read_search, capability dac_read_search,
capability setuid, capability setuid,
capability sys_chroot,
/etc/my.cnf r, /etc/my.cnf r,
/etc/my.cnf.d/ r, /etc/my.cnf.d/ r,
@@ -32,6 +33,7 @@
/etc/dovecot/* r, /etc/dovecot/* r,
/usr/lib/dovecot/auth mr, /usr/lib/dovecot/auth mr,
/var/lib/dovecot/auth-chroot/* r,
# kerberos replay cache # kerberos replay cache
/var/tmp/imap_* rw, /var/tmp/imap_* rw,
@@ -40,6 +42,7 @@
/var/tmp/smtp_* rw, /var/tmp/smtp_* rw,
/run/dovecot/auth-master rw, /run/dovecot/auth-master rw,
/run/dovecot/auth-userdb rw,
/run/dovecot/auth-worker rw, /run/dovecot/auth-worker rw,
/run/dovecot/login/login rw, /run/dovecot/login/login rw,
/{var/,}run/dovecot/auth-token-secret.dat{,.tmp} rw, /{var/,}run/dovecot/auth-token-secret.dat{,.tmp} rw,
@@ -47,7 +50,7 @@
/{var/,}run/dovecot/stats-user rw, /{var/,}run/dovecot/stats-user rw,
/{var/,}run/dovecot/anvil-auth-penalty rw, /{var/,}run/dovecot/anvil-auth-penalty rw,
/var/spool/postfix/private/auth w, /var/spool/postfix/private/auth rw,
# Site-specific additions and overrides. See local/README for details. # Site-specific additions and overrides. See local/README for details.
#include <local/usr.lib.dovecot.auth> #include <local/usr.lib.dovecot.auth>

View File

@@ -17,6 +17,7 @@
#include <abstractions/nameservice> #include <abstractions/nameservice>
#include <abstractions/dovecot-common> #include <abstractions/dovecot-common>
#include <abstractions/openssl> #include <abstractions/openssl>
#include <abstractions/ssl_certs>
#include <abstractions/ssl_keys> #include <abstractions/ssl_keys>
capability dac_override, capability dac_override,

View File

@@ -40,6 +40,8 @@
/usr/sbin/dnsmasq mr, /usr/sbin/dnsmasq mr,
/var/log/*dnsmasq.log w,
/{,var/}run/*dnsmasq*.pid w, /{,var/}run/*dnsmasq*.pid w,
/{,var/}run/dnsmasq-forwarders.conf r, /{,var/}run/dnsmasq-forwarders.conf r,
/{,var/}run/dnsmasq/ r, /{,var/}run/dnsmasq/ r,

View File

@@ -31,7 +31,9 @@
capability sys_chroot, capability sys_chroot,
capability sys_resource, capability sys_resource,
signal send set=(int,quit) peer=/usr/lib/dovecot/*, signal send set=(int,quit,term) peer=/usr/lib/dovecot/*,
unix (receive, send) type=stream peer=(label=/usr/lib/dovecot/anvil),
/etc/dovecot/** r, /etc/dovecot/** r,
/etc/mtab r, /etc/mtab r,

View File

@@ -17,6 +17,7 @@
capability net_bind_service, capability net_bind_service,
capability setgid, capability setgid,
capability setuid, capability setuid,
network netlink dgram,
/etc/identd.conf r, /etc/identd.conf r,
/etc/identd.key r, /etc/identd.key r,
/etc/identd.pid w, /etc/identd.pid w,

View File

@@ -48,6 +48,9 @@ endif # USE_SYSTEM
CFLAGS += -g -O0 -Wall -Wstrict-prototypes CFLAGS += -g -O0 -Wall -Wstrict-prototypes
USE_SYSCTL:=$(shell echo "#include <sys/sysctl.h>" | cpp -dM >/dev/null 2>/dev/null && echo true)
SRC=access.c \ SRC=access.c \
introspect.c \ introspect.c \
changeprofile.c \ changeprofile.c \
@@ -109,7 +112,6 @@ SRC=access.c \
syscall_sethostname.c \ syscall_sethostname.c \
syscall_setdomainname.c \ syscall_setdomainname.c \
syscall_setscheduler.c \ syscall_setscheduler.c \
syscall_sysctl.c \
sysctl_proc.c \ sysctl_proc.c \
tcp.c \ tcp.c \
unix_fd_client.c \ unix_fd_client.c \
@@ -124,6 +126,12 @@ ifneq (,$(findstring $(shell uname -i),i386 i486 i586 i686 x86 x86_64))
SRC+=syscall_ioperm.c syscall_iopl.c SRC+=syscall_ioperm.c syscall_iopl.c
endif endif
#only do sysctl syscall test if defines installed and OR supported by the
# kernel
ifeq ($(USE_SYSCTL),true)
SRC+=syscall_sysctl.c
endif
#only do dbus if proper libs are installl #only do dbus if proper libs are installl
ifneq (,$(shell pkg-config --exists dbus-1 && echo TRUE)) ifneq (,$(shell pkg-config --exists dbus-1 && echo TRUE))
SRC+=dbus_eavesdrop.c dbus_message.c dbus_service.c dbus_unrequested_reply.c SRC+=dbus_eavesdrop.c dbus_message.c dbus_service.c dbus_unrequested_reply.c

View File

@@ -67,21 +67,9 @@ if [ ! -b /dev/loop0 ] ; then
modprobe loop modprobe loop
fi fi
# kinda ugly way of atomically finding a free loop device # find the next free loop device and mount it
for i in $(seq 0 15) loop_device=$(losetup -f) || fatalerror 'Unable to find a free loop device'
do /sbin/losetup "$loop_device" ${mount_file} > /dev/null 2> /dev/null
if [ "$loop_device" = "unset" ]
then
if /sbin/losetup /dev/loop$i ${mount_file} > /dev/null 2> /dev/null
then
loop_device=/dev/loop$i;
fi
fi
done
if [ "$loop_device" = "unset" ]
then
fatalerror 'Unable to find a free loop device'
fi
# TEST 1. Make sure can mount and umount unconfined # TEST 1. Make sure can mount and umount unconfined

View File

@@ -148,11 +148,18 @@ test_sysctl_proc()
# check if the kernel supports CONFIG_SYSCTL_SYSCALL # check if the kernel supports CONFIG_SYSCTL_SYSCALL
# generally we want to encourage kernels to disable it, but if it's # generally we want to encourage kernels to disable it, but if it's
# enabled we want to test against it # enabled we want to test against it
settest syscall_sysctl # In addition test that sysctl exists in the kernel headers, if it does't
if ! res="$(${test} ro 2>&1)" && [ "$res" = "FAIL: sysctl read failed - Function not implemented" ] ; then # then we can't even built the syscall_sysctl test
echo " WARNING: syscall sysctl not implemented, skipping tests ..." if echo "#include <sys/sysctl.h>" | cpp -dM >/dev/null 2>/dev/null ; then
settest syscall_sysctl
if ! res="$(${test} ro 2>&1)" && [ "$res" = "FAIL: sysctl read failed - Function not implemented" ] ; then
echo " WARNING: syscall sysctl not implemented, skipping tests ..."
else
test_syscall_sysctl
fi
else else
test_syscall_sysctl echo " WARNING: syscall sysctl not supported by kernel headers, skipping tests ..."
fi fi
# now test /proc/sys/ paths # now test /proc/sys/ paths

View File

@@ -109,7 +109,7 @@ def get_profiles():
sys.exit(4) sys.exit(4)
for p in f.readlines(): for p in f.readlines():
match = re.search("^([^\(]+)\s+\((\w+)\)$", p) match = re.search("^(.+)\s+\((\w+)\)$", p)
profiles[match.group(1)] = match.group(2) profiles[match.group(1)] = match.group(2)
f.close() f.close()

View File

@@ -213,6 +213,9 @@ def hasher():
def convert_regexp(regexp): def convert_regexp(regexp):
regex_paren = re.compile('^(.*){([^}]*)}(.*)$') regex_paren = re.compile('^(.*){([^}]*)}(.*)$')
regexp = regexp.strip() regexp = regexp.strip()
regexp = regexp.replace('(', '\\(').replace(')', '\\)') # escape '(' and ')'
new_reg = re.sub(r'(?<!\\)(\.|\+|\$)', r'\\\1', regexp) new_reg = re.sub(r'(?<!\\)(\.|\+|\$)', r'\\\1', regexp)
while regex_paren.search(new_reg): while regex_paren.search(new_reg):

View File

@@ -2,6 +2,7 @@
# #
# Copyright (C) 2002-2005 Novell/SUSE # Copyright (C) 2002-2005 Novell/SUSE
# Copyright (C) 2014 Canonical Ltd. # Copyright (C) 2014 Canonical Ltd.
# Copyright (C) 2020 Christian Boltz
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public # modify it under the terms of version 2 of the GNU General Public
@@ -28,6 +29,8 @@
CAP_SETGID 9 CAP_SETGID 9
CAP_SETUID 9 CAP_SETUID 9
CAP_FOWNER 9 CAP_FOWNER 9
CAP_BPF 9
CAP_CHECKPOINT_RESTORE 9
# Denial of service, bypass audit controls, information leak # Denial of service, bypass audit controls, information leak
CAP_SYS_TIME 8 CAP_SYS_TIME 8
CAP_NET_ADMIN 8 CAP_NET_ADMIN 8
@@ -49,6 +52,7 @@
CAP_BLOCK_SUSPEND 8 CAP_BLOCK_SUSPEND 8
CAP_DAC_READ_SEARCH 7 CAP_DAC_READ_SEARCH 7
CAP_AUDIT_READ 7 CAP_AUDIT_READ 7
CAP_PERFMON 7
# unused # unused
CAP_NET_BROADCAST 0 CAP_NET_BROADCAST 0

View File

@@ -19,7 +19,7 @@ danger_caps = ["audit_control",
"audit_write", "audit_write",
"mac_override", "mac_override",
"mac_admin", "mac_admin",
"set_fcap", "setfcap",
"sys_admin", "sys_admin",
"sys_module", "sys_module",
"sys_rawio"] "sys_rawio"]