2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-29 05:17:59 +00:00

8146 Commits

Author SHA1 Message Date
pyllyukko
ab1a455f05
usr.bin.passwd profile fixes
* passwd -e LOGIN was failing
* Allow execution of /usr/sbin/nscd
  See: bee77ffc29/lib/nscd.c (L23-L27)
* Allow pam_passwdqc to read /etc/passwdqc.conf and passwdqc filter
  files (see https://www.openwall.com/passwdqc/)
* Allow setuid & fsetid capabilities
* Allow locking with /etc/shadow.PID & /etc/shadow.lock
* Allow shadow backup /etc/shadow- and whatever /etc/shadow+ is used for
2025-03-02 16:51:33 +02:00
Christian Boltz
ce87b44bae
glob_pattern: allow -
One of the possible matches in glob_pattern was `\w+` which matched for
example `none`.

However, it doesn't match `revokefs-fuse` because of the `-`. Therefore
change `\w+` to [\w-]+.

While on it, add two more tests - one for `none` with some options, and
one with `revokefs-fuse`.
2025-02-28 23:47:05 +01:00
Christian Boltz
c1712c882c
Expand nested (...) in glob_pattern
This duplicates a few bytes, but makes the regex easier to read.
2025-02-28 23:20:46 +01:00
Ryan Lee
59124362d3 profiles: allow fusermount3 to mount in directories used by flatpak
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-27 16:50:19 -08:00
Ryan Lee
930218193b utils: remove the skip_*_profiles testing bypass
The utils should be able to skip profiles that it can't parse now,
so this test suite bypass mechanism should no longer be necessary.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-27 16:48:46 -08:00
Ryan Lee
e80d5bd3d4 utils: test in test-minitools for resiliency against unparseable profiles
Since all the tools that load profiles go through the same module, this should
be sufficient as a first pass.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-27 16:48:41 -08:00
Ryan Lee
e71e27be70 utils: make read_profiles robust against profiles it doesn't understand
This will allow the other tools to continue working on other profiles, even
if some of them use syntax that the utils currently can't handle.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-27 16:46:22 -08:00
Georgia Garcia
bf2054d963 Merge utils: tests: cleanups and allow profile skipping in test-logprof and test-minitools
The utils cannot parse some profile constructs yet, so allow some profiles to be ignored in those tests.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1563
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-02-27 21:35:59 +00:00
Ryan Lee
df0358062d utils: test: expand mechanism for ignoring profiles in tests
The utils cannot parse some of the newer profile constructs yet, so
generalize a pre-existing mechanism for skipping profiles to use that mechanism in the other tests that need it

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-27 13:05:00 -08:00
John Johansen
0e8377cde9 Merge test-translations: include "ignore" in exec prompts + make debugging hotkey conflicts easier
This is a follow-up of adding the "ignore" option to exec prompts in
https://gitlab.com/apparmor/apparmor/-/merge_requests/1543

To make future handling of hotkey conflicts easier,
- display all hotkey conflicts at once instead of erroring out at the first conflict.
- display all options involved in a hotkey conflict to make fixing it easier.

Since 1543 was picked into 4.1, I propose the same for this MR.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1557
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-02-25 02:47:20 +00:00
Ryan Lee
dbe13a0b9d Merge Avoid blhc "CPPFLAGS missing" false positive
Similarly to apparmor/apparmor!403, we don't really need to pass these flags
here, but if we don't, blhc raises a false positive, and I don't want to get
used to ignoring blhc failures on Debian's GitLab CI.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1558
Approved-by: Alex Murray <alex.murray@canonical.com>
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: Ryan Lee <rlee287@yahoo.com>
2025-02-24 17:02:27 +00:00
Christian Boltz
db7e3109cc
test-translations: include "ignore" in exec prompts
This is a follow-up of adding the "ignore" option to exec prompts in
https://gitlab.com/apparmor/apparmor/-/merge_requests/1543
2025-02-24 13:35:08 +01:00
Christian Boltz
3e7e9bf01f
test-translations: display all hotkey conflicts at once
... instead of erroring out at the first conflict.

Also display all options involved in a hotkey conflict to make fixing it
easier.
2025-02-24 13:35:05 +01:00
Christian Boltz
d52b301ee8 Merge Import translations from launchpad
This imports translations from launchpad up to commit

revno: 2523
committer: Launchpad Translations on behalf of apparmor-dev
branch nick: apparmor
timestamp: Fri 2025-02-21 09:32:26 +0000
message:
  Launchpad automatic translations update.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1559
Approved-by: Christian Boltz <apparmor@cboltz.de>
Merged-by: Christian Boltz <apparmor@cboltz.de>
2025-02-24 12:32:43 +00:00
Alex Murray
db87670698
tests/profiles/tinyproxy: use local http server for functional test
Instead of relying on neverssl.com spin up a local http server and test
tinyproxy against that to ensure the test can run even if the wider internet is
not accessible.

Signed-off-by: Alex Murray <alex.murray@canonical.com>
2025-02-24 22:08:04 +10:30
John Johansen
2a87a92136 Import translations from launchpad
This imports translations from launchpad up to commit

revno: 2523
committer: Launchpad Translations on behalf of apparmor-dev
branch nick: apparmor
timestamp: Fri 2025-02-21 09:32:26 +0000
message:
  Launchpad automatic translations update.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-02-24 01:28:04 -08:00
Ryan Lee
bc0426ef18 Fixes for wpa_supplicant profile based on LP: #2098838
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-21 08:55:36 -08:00
intrigeri
187c244056 Avoid blhc "CPPFLAGS missing" false positive
Similarly to apparmor/apparmor!403, we don't really need to pass these flags
here, but if we don't, blhc raises a false positive, and I don't want to get
used to ignoring blhc failures on Debian's GitLab CI.
2025-02-20 22:35:37 +00:00
Georgia Garcia
45a945acd3 Merge profiles: allow ro mounts in fusermount3 profile
These are needed by e.g. AppImages

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1556
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-02-20 18:07:58 +00:00
Georgia Garcia
472181ae75 Merge profiles: fix sbuild to work with the unprivileged_unshare profile
sbuild is an unconfined profile allowing it to bypass the unprivlieged
user namespace restriction.

unconfined profiles use a pix transition which means that when the
unprivileged_unshare profile is enabled, the binaries in an unconfined
profile calling unshare will cause a transition to the unprivileged_unshare
profile.

This will break sbuild because it needs capabilities within the
user namespace.

However we cannot just add a x transition rule to unconfined profiles, as
the transitions won't be respected. Instead, we have to make the profile
a default allow profile and add a transition that will override
the default pix transition of allow all.

We have to add the attached_disconnected and mediated_deleted flags
because sbuild is manipulating mounts.

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

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1555
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-02-20 17:56:47 +00:00
Ryan Lee
a20409cf1e profiles: allow ro mounts in fusermount3 profile
These are needed by e.g. AppImages

Closes: https://bugs.launchpad.net/bugs/2098993
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-20 09:49:27 -08:00
Ryan Lee
1b87b7be5e Replace terminfo lines in profiles with the terminfo abstraction
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-19 17:14:28 -08:00
Ryan Lee
c45ce5502e Add terminfo abstraction with terminfo paths searched by ncurses
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-19 16:48:19 -08:00
John Johansen
7abfc1baf7 profiles: fix sbuild to work with the unprivileged_unshare profile
sbuild is an unconfined profile allowing it to by-pass the unprivlieged
user namespace restritction.

unconfined profiles us a pix transition which means when the
unprivileged_unshare profile is enabled, the binaries in an unconfined
profile calls unshare it will transition to the unprivileged_unshare
profile.

This will break sbuild because it needs capabilities within the
user namespace.

However we can not just add a x transition rule to unconfined profiles,
the transitions won't be respected. Instead we have to make the profile
a default allow profile, and add a transition that will override
the default pix transition of allow all.

We have to add the attached_disconnected and mediated_deleted flags
because sbuild is manipulating mounts.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-02-19 16:05:57 -08:00
John Johansen
125ef7a8cb utils: genprof/logprof - fix missing newline nit in MR1543
This is a trivial fix for
  MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1543

instead of waiting longer for the auther to fix, the MR was merged
and this manual fixup done.

Fixes: dfe9d713f ("aa-logprof/aa-genprof: allow ignoring executions")
Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-02-19 10:53:47 -08:00
John Johansen
71282550bb Merge aa-logprof/aa-genprof: allow ignoring executions
fixes https://gitlab.com/apparmor/apparmor/-/issues/302

Closes #302
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1543
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-02-19 18:48:50 +00:00
John Johansen
a5df123056 Merge profiles: add missing fowner capability to the tar profile
This manifested with chmod calls failing in autopkgtests of dbus and snapd.

Given the magnitude of regressions that might be caused by bugs in this profile, @alex_murray has suggested disabling the profile by default (i.e. moving it into `extras/`).

Reported-by: Alex Murray <alex.murray@canonical.com>
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1553
Approved-by: Alex Murray <alex.murray@canonical.com>
Merged-by: John Johansen <john@jjmx.net>
2025-02-19 18:18:41 +00:00
Ryan Lee
09573220d2 profiles: add missing fowner capability to the tar profile
This manifested with chmod calls failing in autopkgtests of dbus and snapd

Reported-by: Alex Murray <alex.murray@canonical.com>
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-18 17:11:55 -08:00
John Johansen
46335d58cf Merge rule_ents from conditional block are dropped
In the following policy, "ptrace" would be dropped during merging:
```
$FOO=true
/bin/true {
  if $FOO {
      ptrace,
  }
}
```

Current behavior:
```
----- Debugging built structures -----
Name:		/bin/true
Local To:	<NULL>
Mode: 
```

With patch:
```
----- Debugging built structures -----
Name:		/bin/true
Local To:	<NULL>
Mode: 
ptrace,
```

I am quite new to the AA code base, so please let me know if I'm missing something obvious and this is intended behavior :)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1551
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-02-18 22:33:32 +00:00
Georgia Garcia
de61d374ec Merge Miscellaneous typofixes identified by lintian
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1552
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-02-18 21:33:25 +00:00
Georgia Garcia
792aca634e Merge Perl typemap for const char* subprofiles[]
The original plan was to have a minimal subset for Perl excluding the stuff requiring language-dependent typemaps, but it turns out that there was only one thing that required that, and it was simple enough to copy over from the SWIG repo itself. This MR contains the single non-language-generic part of the SWIG updates.

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1341
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-02-18 21:32:07 +00:00
Ryan Lee
eff9f442a3 binutils: aa-status processess->processes typofix
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-18 11:54:42 -08:00
Ryan Lee
4286423fe2 parser: hfa.cc debug promt->prompt typofix
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-18 11:53:35 -08:00
doublez13
dad66f663b rule_ents from conditional block are dropped
In the following policy, "ptrace" would be dropped during merging:

$FOO=true
/bin/true {
  if $FOO {
      ptrace,
  }
}

Current behavior:
----- Debugging built structures -----
Name:		/bin/true
Local To:	<NULL>
Mode: 

With patch:
----- Debugging built structures -----
Name:		/bin/true
Local To:	<NULL>
Mode: 
ptrace,
2025-02-18 16:47:36 +00:00
Ryan Lee
5730fb6d2d Perl typemap for const char* subprofiles[]
This is the only language-dependent nontrivial portion of the SWIG
bindings, and this should be good enough for anyone who is still using the
Perl bindings now

Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
2025-02-18 08:44:07 -08:00
John Johansen
8711c7754b Merge tests: provide better output on failures
When a test fails because of an unexpected success (XFAIL), do not display the empty error log as that may confuse the reader just as it had confused the author.

In addition, when something legitimately fails then display tail of trace log as that may show some useful information.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1548
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-02-18 15:06:33 +00:00
John Johansen
84bf3dee2d Merge tests: mark three regression tests as fixed
The the `attach_disconnectd` test is now passing on Ubuntu 24.04+.
The `posix_ipc` is passing everywhere.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1547
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-02-18 15:04:12 +00:00
Zygmunt Krynicki
c56cbad5ea tests: remove XFAIL/mqeue, stale
There is no mqueue in Makefile TESTS anywhere. This is a red herring.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-02-17 17:32:08 +01:00
Zygmunt Krynicki
5f8863c7ca tests: mark ptrace test as fixed
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-02-17 16:37:16 +01:00
Zygmunt Krynicki
c268e5d11b tests: display tail of bash.trace on failure
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-02-17 16:07:06 +01:00
Zygmunt Krynicki
473e791e4e tests: do not display bash.err on XFAIL passes
This makes no sense since the test has passed and there's nothing to look at in the log.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-02-17 16:04:12 +01:00
Zygmunt Krynicki
083dc9652b tests: mark posix_ipc test as fixed
The test used to fail on some versions of Ubuntu but it now passes
everywhere.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-02-17 16:03:46 +01:00
Zygmunt Krynicki
3987bf0f33 tests: mark attach_disconnected as fixed
The test is now passing on Ubuntu 24.04+

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2025-02-17 16:03:32 +01:00
John Johansen
e085a23b40 Merge aa-notify: rename polkit files and template info from com.ubuntu
We should be using apparmor controlled domains for these files.

Rename the template file from
  com.ubuntu.pkexec.aa-notify.policy
to
  net.apparmor.pkexec.aa-notify.policy

And update the template file and the install file so that the files
that are generated use net.apparmor instead of com.ubuntu

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

Closes #486
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1541
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: John Johansen <john@jjmx.net>
2025-02-15 01:23:40 +00:00
John Johansen
a410f347a3 aa-notify: rename polkit files and template info from com.ubuntu
We should be using apparmor controlled domains for these files.

Rename the template file from
  com.ubuntu.pkexec.aa-notify.policy
to
  net.apparmor.pkexec.aa-notify.policy

And update the template file and the install file so that the files
that are generated use net.apparmor instead of com.ubuntu

Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-02-14 11:49:49 -08:00
John Johansen
b5ff20b5f1 Merge tunable: add letter, alphanumeric character, hex and words variables.
Follow up from !1544 with the other basic variables.

Variables such as `@{rand6}` and `@{word6}` are very commonly used as they allow us to restrict access from rules such as: `/tmp/*`, `/tmp/??????`

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1546
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-02-14 19:34:00 +00:00
John Johansen
697e53d752 Merge aa-notify: fix package build install of polkit files
The install of the polkit action files for aa-notify leaks build root
information.

From OBS
  apparmor-utils.noarch: E: file-contains-buildroot (Badness: 10000) /usr/share/polkit-1/actions/com.ubuntu.pkexec.aa-notify.policy

this is present on Ubuntu as well
    <annotate key="org.freedesktop.policykit.exec.path">/build/apparmor-ZUzkoL/apparmor-4.1.0~beta4/debian/tmp/usr/lib/python3/dist-packages/apparmor/update_profile.py</annotate>

this occurs because the {LIB_PATH} template variable is being replaced
with the self.install_lib. Make sure we strip the build prefix if
we are generating the files in a build environment instead of doing
a direct install.

Closes: https://gitlab.com/apparmor/apparmor/-/issues/486
Signed-off-by: John Johansen <john.johansen@canonical.com>

Closes #486
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1540
Approved-by: Ryan Lee <rlee287@yahoo.com>
Merged-by: John Johansen <john@jjmx.net>
2025-02-14 19:32:27 +00:00
John Johansen
dc583bc1d4 Merge abstraction: add devices-usb & devices-usb-read
Needed for https://gitlab.com/apparmor/apparmor/-/merge_requests/1433

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1545
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
2025-02-14 19:31:40 +00:00
Alexandre Pujol
8af71cd5f5
tunable: add letter, alphanumeric character, hex and words variables. 2025-02-14 19:56:28 +01:00
Alexandre Pujol
4591ed63ba
abstraction: add devices-usb & devices-usb-read 2025-02-14 19:44:25 +01:00