Commit graph

4675 commits

Author SHA1 Message Date
John Johansen
607e185d0c Merge branch 'cboltz-minus-one' into 'master'
replace -1 return codes with 255

Technically "return -1" returns 255, so we should write it that way.
(found by shellcheck)

PR: https://gitlab.com/apparmor/apparmor/merge_requests/256
Acked-by: John Johansen <john.johansen@canonical.com>
2018-11-03 14:08:25 +00:00
Christian Boltz
29da17310e
replace -1 return codes with 255
Technically "return -1" returns 255, so we should write it that way.

(found by shellcheck)
2018-11-02 17:00:33 +01:00
Christian Boltz
473d1f5daa Merge branch 'cboltz-postalias' into 'master'
allow locking /etc/aliases.db

See merge request apparmor/apparmor!250

Acked-by: intrigeri <intrigeri@debian.org>
2018-10-26 14:39:31 +00:00
Christian Boltz
f74edd5d5a
allow locking /etc/aliases.db
This is needed for "newaliases" on current openSUSE Tumbleweed / postfix 3.3.1
2018-10-25 20:59:25 +02:00
Christian Boltz
fd68a5eb64 Merge branch 'cboltz-profile-names' into 'master'
Add profile names to all profiles with {bin,sbin} attachment

See merge request apparmor/apparmor!242

Acked-by: intrigeri <intrigeri@debian.org>
2018-10-21 10:34:59 +00:00
John Johansen
d87b6a5f6e Merge branch 'dont-hard-code-libc-header-location' into 'master'
Don't hard code the location of netinet/in.h.

This "will break with non-glibc libcs on Debian and with glibc headers moved to
multiarch locations" (https://bugs.debian.org/798955). Patch based on the one
proposed by Helmut Grohne helmut@subdivi.de, amended to replace hard coded
"gcc" with "$(CC)".

Bug-Debian: https://bugs.debian.org/909966

nominated for 2.13.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/245
Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-21 06:29:05 +00:00
intrigeri
2d91211842 Don't hard code the location of netinet/in.h.
This "will break with non-glibc libcs on Debian and with glibc headers moved to
multiarch locations" (https://bugs.debian.org/798955). Patch based on the one
proposed by Helmut Grohne <helmut@subdivi.de>, amended to replace hard coded
"gcc" with "$(CC)".

Bug-Debian: https://bugs.debian.org/909966
2018-10-20 20:49:26 +00:00
intrigeri
f0dfb3cd74 Merge branch 'cboltz-rc-syntax-fix' into 'master'
Fix syntax error in rc.apparmor.functions

See merge request apparmor/apparmor!240
2018-10-20 16:00:07 +00:00
Christian Boltz
2863e20f37 Merge branch 'test-includes' into 'master'
profiles/Makefile: test abstractions against apparmor_parser

See merge request apparmor/apparmor!237

Acked-by: Christian Boltz <apparmor@cboltz.de> for trunk and 2.13.

Pre-acked for 2.10..2.12 after removing the --config-file option which is not supported in these branches.
2018-10-17 22:20:51 +00:00
Vincas Dargis
dc7ae28de0 profiles/Makefile: test abstractions against apparmor_parser
Update Makefile to test abstractions by generating temporary profile, to
check for missing (not backported) abstractions or other issues.
2018-10-17 20:05:51 +03:00
Christian Boltz
f920915dd3 Merge branch 'aa-notify-manpage' into 'master'
aa-notify man page: update user's configuration file path

See merge request apparmor/apparmor!239

Acked-by: Christian Boltz <apparmor@cboltz.de> for 2.10..master
2018-10-16 15:55:44 +00:00
Christian Boltz
b77116e6af
Add profile names to all profiles with {bin,sbin} attachment
Also adjust the signal rules in the dovecot-common and apache2-common
abstractions to match the profile names, and to really do that
(peer=...{bin,sbin}... didn't work, the correct syntax would have been
peer=...\{bin,sbin\}...)

This fixes the regression introduced by !149 / commit
4200932d8f
2018-10-15 20:57:33 +02:00
nl6720
2209e09aef aa-notify man page: update user's configuration file path
Signed-off-by: nl6720 <nl6720@gmail.com>
2018-10-15 16:44:00 +03:00
Christian Boltz
3bf11cee3e
Fix syntax error in rc.apparmor.functions
This bug was introduced in
- https://gitlab.com/apparmor/apparmor/merge_requests/230
- commit c974dd0d07 (master)
- commit 9987a7ec9c (2.13 branch)
2018-10-14 18:10:46 +02:00
John Johansen
4a2dad336a library: bump library version to keep it in sync with 2.13.1 release
Signed-off-by: John Johansen <john.johansen@canonical.com>
2018-10-13 16:40:05 -07:00
John Johansen
6242051a1c Merge branch 'cboltz-abi-exceptions' into 'master'
Add most abi/bad_*.sd tests to "exception not raised" list

Interestingly, abi/bad_6.sd is detected as invalid, and therefore not
added to the list.

I propose this for all branches that g[eo]t support for abi rules and the abi testcases.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/238
Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-13 21:31:31 +00:00
Christian Boltz
5c54f66279
Add most abi/bad_*.sd tests to "exception not raised" list
Interestingly, abi/bad_6.sd is detected as invalid, and therefore not
added to the list.
2018-10-13 20:23:57 +02:00
John Johansen
83df7c4747 parser: ignore feature abi rules
AppArmor 3.0 requires policy to use a feature abi rule for access to
new features. However some policy may start using abi rules even if
they don't have rules that require new features.  This is especially
true for out of tree policy being shipped in other packages.

Add enough support to older releases that the parser will ignore the
abi rule and warn that it is falling back to the apparmor 2.x
technique of using the system abi.

If the profile contains rules that the older parser does not
understand it will fail policy compilation at the unknown rule instead
of the abi rule.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/196
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2018-10-12 22:14:38 -07:00
John Johansen
4153663c42 parser: fix: ensure that a quotedid actually has both quotes
The handling for quotedid checked for the first quote but failed
to ensure the trailing quote was present.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/196
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2018-10-12 22:14:38 -07:00
John Johansen
04beee7633 parser: combine INCLUDE cases together and support escape sequences
We can reduce the INCLUDE/INCLUDE_EXISTS code dup by using a
variable for whether the name was enclosed by '<' and using
processid() to handle the whether the id is quoted or not.

In addition using processid allows include names to contain
escaoe sequences like \n and have them handled correctly.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/196
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2018-10-12 22:14:38 -07:00
John Johansen
eff672b2eb parser: refactor INCLUDE and INCLUDE_EXISTS to share a start condition
We can reduce code duplication by checking the current state to
determine the single parameter difference between include and
include if exists

PR: https://gitlab.com/apparmor/apparmor/merge_requests/196
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2018-10-12 22:14:38 -07:00
John Johansen
924d4e87ad Merge branch 'cboltz-nmbd-systemd' into 'master'
References: https://bugs.launchpad.net/ubuntu/+source/samba/+bug/1719354
(comment 8)

PR: https://gitlab.com/apparmor/apparmor/merge_requests/236
Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-12 22:00:11 +00:00
Christian Boltz
d4afbccb6a
nmbd profile: allow writing to /run/systemd/notify
References: https://bugs.launchpad.net/ubuntu/+source/samba/+bug/1719354
(comment 8)
2018-10-12 23:48:13 +02:00
John Johansen
c421a29c61 parser: do not output cache warning for stdin if not using cache
Currently if stdin is used the warning
  apparmor_parser: cannot use or update cache, disable, or force-complain via stdin

is always displayed but if caching has been disabled there is no need for
this message.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2018-10-11 22:11:39 -07:00
Christian Boltz
93445ca02d Merge branch 'cboltz-mergeprof-hasher-fun' into 'master'
Fix aa-mergeprof crash caused by accidentially initialzed hat

See merge request apparmor/apparmor!234

Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-11 19:49:24 +00:00
Christian Boltz
bc492533cc
Fix aa-mergeprof crash caused by accidentially initialzed hat
Hasher causes some fun in aa-mergeprof: If the profile in
/etc/apparmor.d/ has a hat or subprofile that doesn't exist in the
to-be-merged profile, aa-mergeprof crashes. This is caused by reading
self.other.aa[program][hat]['include'] which accidently "creates" that
profile inside the aa hasher as empty hasher (instead of ProfileStorage).

Later, the code loops over self.other.aa[profile].keys(), expects
everything to be ProfileStorage, and explodes [1] when for example
trying to run .delete_duplicates on the hasher (which obviously doesn't
provide this method).

This patch adds checks to all self.other.aa accesses in
CleanProf.remove_duplicate_rules() to avoid accidently creating new keys
in the hasher.

Interestingly this bug survived unnoticed for years (at least since
2.11).

[1] last lines of the backtrace:
  File ".../utils/apparmor/cleanprofile.py", line 42, in compare_profiles
    deleted += self.remove_duplicate_rules(profile)
  File ".../utils/apparmor/cleanprofile.py", line 65, in remove_duplicate_rules
    deleted += apparmor.delete_duplicates(self.other.aa[program][hat], inc)
  File ".../utils/apparmor/aa.py", line 1680, in delete_duplicates
    deleted += profile[rule_type].delete_duplicates(include[incname][incname][rule_type])
AttributeError: 'collections.defaultdict' object has no attribute 'delete_duplicates'
2018-10-11 19:49:26 +02:00
John Johansen
fbb1a1735d Merge branch 'cboltz-gitignore' into 'master'
.gitignore profiles/apparmor.d/local/* except README

The old patter . doesn't match lsb_release and nvidia_modprobe, and
the only file we ship in local is a README. This patch adjusts the
pattern to ignore everything except README.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/227

Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-11 17:20:30 +00:00
Christian Boltz
aeee9a1aab
.gitignore profiles/apparmor.d/local/* except README
The old patter *.* doesn't match lsb_release and nvidia_modprobe, and
the only file we ship in local is a README. This patch adjusts the
pattern to ignore everything except README.
2018-10-11 12:59:16 +02:00
Christian Boltz
999263c831 Merge branch 'cboltz-extra-profiles-samba' into 'master'
delete smbd and nmbd from extra profiles

See merge request apparmor/apparmor!229

Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-11 10:23:30 +00:00
John Johansen
a992a22668 Merge branch 'cboltz-dovecot-ssl-params' into 'master'
add new location for ssl-params file

(probably Ubuntu-only? The ssl-params file doesn't exist on my openSUSE
installation)

References: https://bugs.launchpad.net/apparmor-profiles/+bug/1796966
I propose this patch for 2.10..master

PR: https://gitlab.com/apparmor/apparmor/merge_requests/231
Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-09 23:52:53 +00:00
John Johansen
958cc28876 libapparmor: Finish removing LD_RUN_PATH from Makefile.perl
commit 94dfe15b28 attempted to remove
LD_RUN_PATH unfortunately

   But all it actually does is cause the Makefile.perl to embed the rpath
    "" instead. Which is still an rpath, only I guess an even worse one.

    --
    Eli Schwartz
    Arch Linux Bug Wrangler and Trusted User

This is because it cleared the setting of the variable LD_RUN_PATH
which was expanded in the command

$(INST_DYNAMIC) : $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVEDEP) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
	$(RM_F) $@
	 LD_RUN_PATH="$(LD_RUN_PATH)" $(LD)  $(LDDLFLAGS) $(LDFROM) $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) \
	  $(PERL_ARCHIVE) $(LDLOADLIBS) $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) \
	  $(INST_DYNAMIC_FIX)
	$(CHMOD) $(PERM_RWX) $@

resulting in LD_RUN_PATH="" being passed to the command.

Finish removing LD_RUN_PATH from Makefile.perl by removing it from
the command invocation if it is present.

Note: we use \x24 instead of $ in the regex as there seems to be a bug
and no level of escaping $ would allow it to be used.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2018-10-09 16:42:17 -07:00
Christian Boltz
772a8702e0 Merge branch 'sys-by-default' into 'master'
Make @{sys} available by default

See merge request apparmor/apparmor!228

Acked-by: Christian Boltz <apparmor@cboltz.de> for 2.10..master
2018-10-09 22:30:10 +00:00
Christian Boltz
16a98d26d0
add new location for ssl-params file
(probably Ubuntu-only? The ssl-params file doesn't exist on my openSUSE
installation)

References: https://bugs.launchpad.net/apparmor-profiles/+bug/1796966
2018-10-09 23:24:51 +02:00
John Johansen
c974dd0d07 Merge branch 'void' into 'master'
rc.apparmor.functions: skip XBPS conffile artifacts

PR: https://gitlab.com/apparmor/apparmor/merge_requests/230

Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-09 20:33:32 +00:00
Cameron Nemo
918e19238a
rc.apparmor.functions: skip XBPS conffile artifacts 2018-10-09 12:39:24 -07:00
Vincas Dargis
aa06528790 Make @{sys} available by default
Move @{sys} into tunables/kernelvars to make it readily available for
all profiles by default. In order to avoid duplicate variable
declaration, other tunable includes where modified accordingly.
Additionally, apparmor_api/is_enable has updated comment with regards to
@{sys} availability. tunables/sys is now marked as deprecated and should
not be used as it is noop, left only for backwards compatibility.

This is preparation for fixing bug:
https://bugs.launchpad.net/apparmor/+bug/1728551

Thanks to Christian Boltz for original idea to implement this in
non-breaking manner.
2018-10-09 19:27:55 +03:00
Petr Vorel
025c7dc6a1
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>
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2018-10-09 09:02:25 -07:00
Christian Boltz
516bc47495
delete smbd and nmbd from extra profiles
We ship newer versions of these profiles in apparmor.d, so there's no
reason to keep the outdated ones (no serious change since > 10 years) in
the extra directory.
2018-10-08 21:06:03 +02:00
Christian Boltz
34cf085036 Merge branch 'fix-bison' into 'master'
parser: fix Makefile hardcoded paths to flex and bison

Closes #4

See merge request apparmor/apparmor!224

Acked-by: Christian Boltz <apparmor@cboltz.de> for 2.10..master
2018-10-05 19:03:34 +00:00
John Johansen
17e059a253 parser: fix Makefile hardcoded paths to flex and bison
The hardcoded paths for flex and python can break builds on systems
where those tools are stored in an alternate location. Use which
to lookup where flex and bison are available.

This fixes issue #4

Signed-off-by: John Johansen <john.johansen@canonical.com>
2018-10-05 11:48:11 -07:00
John Johansen
5718aa04ed Merge branch 'opencl-nvidia-update' into 'master'
Use nvidia_modprobe named profile inside opencl-nvidia abstraction

Commit 8f9bd5b0 rightfully removed PUx
transition into nvidia-modprobe executable due to security concerns. To
overcome this, commit 327420b1 added
named nvidia_modprobe profile, which allows to use this abstraction
without requiring additional rules to make OpenCL work with NVIDIA
drivers.

Add rule to allow Px transition into nvidia_modprobe profile for
nvidia-modprobe executable.

I propose this for 2.13..master (opencl* are only available in 2.13...). Please check if nvidia_modprobe is already backported.

https://gitlab.com/apparmor/apparmor/merge_requests/219

Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-05 06:46:43 +00:00
John Johansen
97c1591f0e Merge branch 'aa-notify' into 'master'
aa-notify: Read user's configuration file from XDG_CONFIG_HOME

Legacy path ~/.apparmor/notify.conf is preferred if it exists, otherwise $XDG_CONFIG_HOME/apparmor/notify.conf, with fallback to ~/.config/apparmor/notify.conf, is used.

See merge request https://gitlab.com/apparmor/apparmor/merge_requests/215

Signed-off-by: nl6720 nl6720@gmail.com
Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-05 06:34:39 +00:00
Christian Boltz
f76a718f28 Merge branch 'profile-usr.sbin.smbd' into 'master'
Add missing paths to usr.sbin.nmbd, usr.sbin.smbd and abstractions/samba

See merge request apparmor/apparmor!210

Acked-by: Christian Boltz <apparmor@cboltz.de> for 2.10..master
2018-10-04 20:34:06 +00:00
Vincas Dargis
e4b1cadf63 Use nvidia_modprobe named profile inside opencl-nvidia abstraction
Commit 8f9bd5b0e3 rightfully removed PUx
transition into nvidia-modprobe executable due to security concerns. To
overcome this, commit 327420b151 added
named nvidia_modprobe profile, which allows to use this abstraction
without requiring additional rules to make OpenCL work with NVIDIA
drivers.

Add rule to allow Px transition into nvidia_modprobe profile for
nvidia-modprobe executable.
2018-10-03 19:59:21 +03:00
nl6720
1fb9acc59e aa-notify: Read user's configuration file from XDG_CONFIG_HOME
Legacy path ~/.apparmor/notify.conf is preferred if it exists, otherwise
$XDG_CONFIG_HOME/apparmor/notify.conf, with fallback to
~/.config/apparmor/notify.conf, is used.

Signed-off-by: nl6720 <nl6720@gmail.com>
2018-10-03 12:38:28 +03:00
John Johansen
22fca3c217 Merge branch 'cboltz-log-to-profile-empty' into 'master'
test-libapparmor-test_multi.py: test for known-empty log

Add a check to logfile_to_profile() that checks the parsed log against a
list of input logs (log_to_profile_known_empty_log) that produce an
empty output.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/214

Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-03 06:47:21 +00:00
John Johansen
e7133731cf Merge branch 'nvidia-modprobe' into 'master'
Add nvidia_modprobe named profile

nvidia-modprobe is setuid executable is used to create various device
files and load the the NVIDIA kernel module
(https://github.com/NVIDIA/nvidia-modprobe).
Add named profile to be used in application profiles for confining
potentially risky setuid application.
I propose this to 2.10..master.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/213

Acked-by: Christian Boltz <apparmor@cboltz.de>
Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-03 06:45:16 +00:00
John Johansen
dada29a50c Merge branch 'profile-usr.sbin.dnsmasq' into 'master'
usr.sbin.dnsmasq: add /srv/tftp

See merge request apparmor/apparmor!211

Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-03 06:40:51 +00:00
John Johansen
05e620903a Merge branch 'cboltz-abi' into 'master'
Add basic support for abi rules to the tools

 Add basic support for abi rules to the tools

Add basic "understand and keep" support for abi rules, where "understand" means to not error out when seeing an abi rule, and "keep" simply means to keep the original abi rule when serializing a profile.

On the long term, abi rules should be parsed (similar to include rules), but for now, this patch is the smallest possible changeset and easy to backport.

Note that the only added test is via cleanprof_test.* which is used by minitools_test.py - and does not run if you do a 'make check'. Oh, and of course the simple_tests/abi/ files also get parsed by test-parser-simple-tests.py.

Also note that serialize_profile_from_old_profile() (which no longer exists in master, "only" in <= 2.13) would in theory also need support for abi rules. In practise, making this another case of "serialize_profile_from_old_profile() has known issues" is probably fine, but we should at least test that "(V)iew changes" doesn't break if an abi rule is present.

I propose this patch for 2.10..master.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/202
Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-03 06:35:05 +00:00
Vincas Dargis
327420b151 Add nvidia_modprobe named profile
nvidia-modprobe is setuid executable is used to create various device
files and load the the NVIDIA kernel module
(https://github.com/NVIDIA/nvidia-modprobe).

Add named profile to be used in application profiles for confining
potentially risky setuid application.
2018-10-02 20:29:10 +03:00