Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 475118 - [hardened-dev overlay] sys-app/apparmor-2.8.1 - init script tries to remove already removed profiles
Summary: [hardened-dev overlay] sys-app/apparmor-2.8.1 - init script tries to remove a...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Michael Palimaka (kensington)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-28 15:53 UTC by Balazs Nemeth
Modified: 2013-06-29 13:33 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Balazs Nemeth 2013-06-28 15:53:21 UTC
The current init script has this function called get_active_profiles().

The problem with that is that for example during restart or stopping the service ( remove_profiles() invokes it ) it tries to remove the active profiles one-by-one, however there are profiles which have subprofiles, see example below.

gaia3 balage # cat /sys/kernel/security/apparmor/profiles 
/usr/sbin/ntpd (enforce)
/usr/sbin/syslog-ng (enforce)
/usr/sbin/sshd (enforce)
/usr/sbin/sshd//PRIVSEP_MONITOR (enforce)
/usr/sbin/sshd//PRIVSEP (enforce)
/usr/sbin/sshd//EXEC (enforce)
/usr/sbin/sshd//AUTHENTICATED (enforce)
/usr/sbin/dnsmasq (enforce)

Now as you see the profile "/usr/sbin/sshd" will be removed first, however it will automatically remove the subprofiles too, so when the init script tries to remove the subprofiles, they have been already removed and printf will throw an error.

I don't know what solution would be elegant here but this small patch fixed it for me.

--- apparmor-init       2013-05-27 10:09:34.342964855 +0200
+++ /etc/init.d/apparmor        2013-06-03 16:06:27.152291221 +0200
@@ -103,7 +103,7 @@
 }
 
 get_active_profiles() {
-       PROFILES=`sed -e "s/ (\(enforce\|complain\))//" "${SECURITYFS}/profiles"`
+       PROFILES=`sed -e "s/ (\(enforce\|complain\))//" "${SECURITYFS}/profiles" | grep -v \/\/`
        echo $PROFILES
 }

Reproducible: Always
Comment 1 Michael Palimaka (kensington) gentoo-dev 2013-06-29 13:33:51 UTC
Thanks for the report. I have rewritten the init script to act as a wrapper around upstream's RC functions. This will improve consistency with other distros and will solve a couple of bugs like this one.

http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=670625009874671eb04622eca3b1fe3a3ccf274c