Commit graph

5033 commits

Author SHA1 Message Date
Tyler Hicks
7df48adae5 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>
2019-08-05 15:14:35 +00:00
Christian Boltz
39ac1e8ca3 Merge branch 'cboltz-exec-without-target' into 'master'
logparser.py: don't error out on exec events without target

See merge request apparmor/apparmor!405

Acked-by: John Johansen <john.johansen@canonical.com>
2019-08-02 12:00:44 +00:00
Tyler Hicks
5bd75cd0b7 Merge branch 'test-policy-cache-old-libapparmor' into 'master'
tests: Allow aa_policy_cache.c to build against old libapparmors

See merge request apparmor/apparmor!407

Acked-by: John Johansen <john.johansen@canonical.com>
2019-08-01 22:46:58 +00:00
Tyler Hicks
2893a6af05 Merge branch 'nnp-test' into 'master'
tests: Add NO_NEW_PRIVS regression tests

See merge request apparmor/apparmor!408

Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2019-08-01 22:41:15 +00:00
Tyler Hicks
7670336a82 libapparmor, tests: Be explicit about value-if-true in ternary operator
Improve readability by being explicit about the value to use when the
conditional evaluates to true.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Suggested-by: John Johansen <john.johansen@canonical.com>
2019-08-01 22:31:07 +00:00
Tyler Hicks
83d0b99729 Merge branch 'parser-cachedir-usage-typo' into 'master'
parser: Fix minor typo in usage

See merge request apparmor/apparmor!406

Acked-by: John Johansen <john.johansen@canonical.com>
2019-08-01 21:11:19 +00:00
Tyler Hicks
a77ba80838 tests: Allow aa_policy_cache.c to build against old libapparmors
Commit ad81ea0e67 ("tests: Add option to dump policy cache dir with
the libapparmor wrapper") modified aa_policy_cache.c to call
aa_policy_cache_dir_path_preview(). That added a hard dependency on
libapparmor >= 2.13, which is the first version to add
policy_cache_dir_path_preview() to libapparmor. The dependency makes it
impossible to build and run the upstream regression tests against an
installed libapparmor older than 2.13 due to aa_policy_cache.c failing
to build.

Add a compatible aa_policy_cache_dir_path_preview() when building
aa_policy_cache.c against a libapparmor older than 2.13 and newer than
or equal to 2.10.

Fixes: ad81ea0e67 ("tests: Add option to dump policy cache dir with the libapparmor wrapper")
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2019-08-01 16:40:14 +00:00
Tyler Hicks
50e34b45c2 parser: Fix minor typo in usage
Correct the long option used to print the cache directory.

Fixes: e9d9395f91 ("parser: Add option to print the cache directory")
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2019-08-01 15:04:49 +00:00
Tyler Hicks
9160204008 tests: Add NO_NEW_PRIVS regression tests
Test the profile transition limits imposed by NO_NEW_PRIVS to ensure
that behavior doesn't unexpectedly change.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2019-08-01 14:58:32 +00:00
Christian Boltz
a0c1eb0abd
logparser.py: don't error out on exec events without target
commit 7297e2f6a8 assumed that exec events
always have a "target=...", but this is only true for events in complain
mode. In enforce mode, the log line doesn't include "target=...".

This commits sets an empty target instead of erroring out on every exec
event in enforce mode.

Also adjust ask_exec() in aa.py to only update
hashlog[aamode][target_profile]['final_name'] if target_profile is set
(hashlog[aamode][''] doesn't exist and trying to write to it would error
out)
2019-07-27 22:48:30 +02:00
Christian Boltz
dc3d11bf0a
add log testcases for exec with and without target=
- in complain mode, exec events include target=...
- in enforce mode, the log message doesn't include target=...

Note that the utils tests skip exec events (they'd be interactive),
therefore exec*.profile doesn't contain an exec rule.
2019-07-27 22:23:15 +02:00
Christian Boltz
db1f391844 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
2019-07-09 19:45:08 +00:00
Xiang Fei Ding
654d96a3f7
parser: allow overriding which ar(1) is invoked
When cross compiling apparmor-parser, Makefile will use ar for
creating the static library. However, ar produces libraries on
the build platform. The right ar could be prefixed with the target
platform triples.

Signed-off-by: Xiang Fei Ding <dingxiangfei2009@gmail.com>
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
Ref: https://github.com/NixOS/nixpkgs/pull/63999
Bug: https://gitlab.com/apparmor/apparmor/issues/41
2019-07-08 12:28:30 -07:00
Christian Boltz
8f74ac02ca
Fix crash on unbalanced parenthesis in filename
convert_regexp() needs to escape '(' and ')' in filenames taken from a
logfile to get rid of their special meaning, and to avoid a crash on
unbalanced parenthesis (which makes the regex invalid if they are not
escaped).

Note: The added tests include an example log line, but the tests itsself
don't/didn't trigger the crash because they don't call convert_regexp().

Fixes: https://bugs.launchpad.net/bugs/1835311
2019-07-07 22:24:12 +02:00
John Johansen
0349cf2d0a libapparmor: logparse: fix RECORD_INVALID for valid log
v2:
- parse partial log line broken at \n
- add testcase_dbus_10.* for partial log line
- remove quotes from  testcasw_dbus_09.profile

The following log format has been seen in the wild, and currently results
in a RECORD_INVALID

    [4835959.046111] audit: type=1107 audit(1561053426.749:186): pid=640 uid=103 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call"  bus="system" path="/org/freedesktop/systemd1" interface="org.freedesktop.systemd1.Manager" member="LookupDynamicUserByName" mask="send" name="org.freedesktop.systemd1" pid=20596 label="/usr/sbin/sshd" peer_pid=1 peer_label="unconfined"
                      exe="/usr/bin/dbus-daemon" sauid=103 hostname=? addr=? terminal=?'

Test parsing the above message with and without the \n embedded between
peer_label= and exec=

Acked-by: Seth Arnold <seth.arnold@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-07-02 01:01:37 -07:00
Christian Boltz
8a8130d4dd Merge branch 'cboltz-whitespace-fix' into 'master'
Fix whitespace in ssl_* abstractions

See merge request apparmor/apparmor!399

Acked-by: John Johansen <john.johansen@canonical.com>
2019-06-30 07:16:06 +00:00
Christian Boltz
2d74c42c75
Fix whitespace in ssl_* abstractions
Drop superfluous whitespace introduced by
4d275bab69 and
3016ffb336
2019-06-29 23:23:07 +02:00
Christian Boltz
b0575b077b Merge branch 'master' into 'master'
Add for Certbot on openSUSE Leap

The default path is `/etc/certbot/archive/{some domain}/{file name}.pem`

See merge request apparmor/apparmor!397


Acked-by: Christian Boltz <apparmor@cboltz.de>
2019-06-29 21:05:39 +00:00
Richard Chen
4d275bab69 Update ssl_keys 2019-06-28 07:31:10 +00:00
Richard Chen
3016ffb336 Add for CertBot on openSUSE Leap 2019-06-28 07:30:10 +00:00
Christian Boltz
0d327abf3a Merge branch 'cboltz-postfix-profiles' into 'master'
postfix/master needs to execute postfix/error

See merge request apparmor/apparmor!392

Acked-by: Seth Arnold <seth.arnold@canonical.com>
2019-06-27 14:41:41 +00:00
Christian Boltz
5aa17c1fa4 Merge branch 'cboltz-sfs-mountpoint' into 'master'
Fix and simplify setting SFS_MOUNTPOINT

See merge request apparmor/apparmor!394

Acked-by: Seth Arnold <seth.arnold@canonical.com>
2019-06-27 14:33:57 +00:00
Steve Beattie
7c7a4bc531
regression tests/mult_mount: bump size of created disk image
The mult_mount test creates a small disk image, formats it, and mounts
it in multiple locations in preparation for the tests. However, the
created raw file (80KB) is too small to make a working file system if
4K blocks are used by mkfs. In Ubuntu 19.10, the default was recently
changed for mkfs to default to always using 4K blocks, causing the
script to fail.

We could force mkfs to use 1K blocks, but instead, in case some future
version of mkfs decides not to support 1K blocks at all, we bump up the
size of the disk image to 512KB; large enough to work with 4K blocks
yet small enough to be workable in small scale test environments.

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Bug: https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1834192
MR: https://gitlab.com/apparmor/apparmor/merge_requests/396
2019-06-26 08:36:04 -07:00
Christian Boltz
61c27d8808
Fix and simplify setting SFS_MOUNTPOINT
Instead of setting SFS_MOUNTPOINT in is_apparmor_loaded() (which is
called in most cases) and in is_container_with_internal_policy() (which
covers/fixes the remaining cases), set it globally.

This also fixes a bug in is_container_with_internal_policy() (introduced
in f10e72a14f) where the variable
definition tried to use the no longer existing $MODULE variable and
therefore got a wrong path for $SFS_MOUNTPOINT.

Besides this bug, there's a minor behaviour change / improvement if
securityfs isn't mounted - "file not found" error messages will now
contain the full/correct path ;-)

This change/cleanup is a follow-up of
https://gitlab.com/apparmor/apparmor/merge_requests/363 and some IRC
discussions 2019-04-16.
2019-06-21 19:22:15 +02:00
Christian Boltz
f250e94240
postfix/master needs to execute postfix/error 2019-06-20 14:37:46 +02:00
John Johansen
a45d2c9dcd libapparmor: bump revision to match 2.13.3 release revision.
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-18 14:08:57 -07:00
Christian Boltz
ff287e9238 abstractions/dri-common: allow reading /dev/dri/
Fixes https://gitlab.com/apparmor/apparmor/issues/29

PR: https://gitlab.com/apparmor/apparmor/merge_requests/382
Signed-off-by: Christian Boltz <apparmor@cboltz.de>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-14 01:10:38 -07:00
Christian Boltz
c866bc276b update freshclam profile
freshclam needs to write more files in /var/lib/clamav/, and also needs
to write its pid file.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/381
Signed-off-by: Christian Boltz <apparmor@cboltz.de>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-14 01:05:16 -07:00
John Johansen
9144e39d25 Revert "utils/test-network.py: fix failing testcase"
This reverts commit 378519d23f.
this commit was meant for the 2.13 branch not master

Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-14 01:05:16 -07:00
Steve Beattie
378519d23f utils/test-network.py: fix failing testcase
When dc010bc034 was
backported to the apparmor-2.13 branch (in commit
75236d62e2), it did not take into
account cb8c3377ba, which creates the
common/list_af_names.sh script as used in the test case, was not also
backported to the apparmor-2.13 branch.

Change the test case to get the list of network AF names via the same
make invocation taken by the utils/vim/create-apparmor.vim.py script
before the common/list_af_names.sh existed.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/391
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-14 00:04:00 -07:00
John Johansen
48e9f0ee2e Merge branch 'cboltz-postfix-profiles' into 'master'
update postfix profiles

On openSUSE Leap 15.1, the postfix binaries live in /usr/lib/postfix/bin/ which was not covered in the postfix.\* attachment and mrix rules.

Also add several permissions to the postfix.\* profiles needed on openSUSE Leap 15.1.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/380
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-14 04:31:14 +00:00
Jamie Strandboge
f10e72a14f set SFS_MOUNTPOINT in is_container_with_internal_policy()
is_container_with_internal_policy() is called independently of
apparmor_*() in the systemd unit and potentially other consumers of
rc.apparmor.functions. When the unit and rc.apparmor.functions functions
were rewritten, they were written so that SFS_MOUNTPOINT was only set in
is_apparmor_loaded(), but this is only called in apparmor_start(),
remove_profiles(), apparmor_kill(), apparmor_restart(), apparmor_try_restart()
and apparmor_status() and not is_container_with_internal_policy().

While it is clear that is_container_with_internal_policy() is meant to
be called before apparmor_start(), is is unclear why SFS_MOUNTPOINT is
only defined in is_apparmor_loaded(). There are several ways to fix
this:

1. update is_container_with_internal_policy() to call is_apparmor_loaded()
2. identify the callers of is_container_with_internal_policy() and have
   them call is_apparmor_loaded()
3. reorganize the code to remove duplicate calls and assignments
4. define SFS_MOUNTPOINT along with SECURITYFS and MODULE, at the top
   level
5. also define SFS_MOUNTPOINT in is_container_with_internal_policy()

'1' would result in redundant calls in many common cases since the
systemd unit would call is_apparmor_loaded() both in
is_container_with_internal_policy() and prior to other calls.

'2' would like break consumers of rc.apparmor.funcions, like
Debian/Ubuntu's profile-load.

'3' is perhaps ok, but requires more effort and is regression-prone.

'4' seems the simplest, most correct fix

'5' is what this patch implements, which is as simple as '4' but tries
to maintain the original author's intent of when to set SFS_MOUNTPOINT.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/363
Signed-off-by: Jamie Strandboge <jamie@strandboge.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-13 21:21:21 -07:00
John Johansen
5fd07de9f4 Merge branch 'cboltz-syslog-ng' into 'master'
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
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-14 00:39:30 +00:00
John Johansen
5b2f4e8b66 Merge branch 'master' into 'master'
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](https://matrix.to/#/!pNJIrowvqsuGgjXsEY:matrix.org/%2415477566201815716pmube:matrix.org?via=matrix.org&via=alea.gnuu.de)

PR: https://gitlab.com/apparmor/apparmor/merge_requests/334
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-14 00:32:55 +00:00
Mike Salvatore
82ff86bfbf Add a build-dep target to tests/regression/apparmor/Makefile
Add a target to install build dependencies for the apparmor regression
tests. Currently supports Ubuntu and Debian distros.

Signed-off-by: Mike Salvatore <mike.salvatore@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-13 17:29:00 -07:00
Steve Beattie
03c08cf989
utils: remove conflicting action in Swedish translation
The translated action character for Deny conflicted with the
untranslated action character for Finish in the Swedish translation.
Remote it, and hope for more action translations.

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 15:03:06 -07:00
Steve Beattie
3ee468864d
Translations: merge updates from launchpad
Omnibus collection of translations updates.

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:45:25 -07:00
Launchpad Translations on behalf of apparmor-dev
9d226f5887
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:39:52 -07:00
Launchpad Translations on behalf of apparmor-dev
01656486ef
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:39:52 -07:00
Launchpad Translations on behalf of apparmor-dev
90a4b301bd
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:39:52 -07:00
Launchpad Translations on behalf of apparmor-dev
3b1c320cfc
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:30:01 -07:00
Launchpad Translations on behalf of apparmor-dev
5a62c68743
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:30:00 -07:00
Launchpad Translations on behalf of apparmor-dev
78c09e4337
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:30:00 -07:00
Launchpad Translations on behalf of apparmor-dev
2c614d4413
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:30:00 -07:00
Launchpad Translations on behalf of apparmor-dev
d14723b78c
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:30:00 -07:00
Launchpad Translations on behalf of apparmor-dev
fe2faeb24f
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:30:00 -07:00
Launchpad Translations on behalf of apparmor-dev
9650201928
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:29:59 -07:00
Launchpad Translations on behalf of apparmor-dev
2b936e25a8
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:29:59 -07:00
Launchpad Translations on behalf of apparmor-dev
02ba8523c6
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:29:59 -07:00
Launchpad Translations on behalf of apparmor-dev
72bcf23c5d
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:29:59 -07:00