AppArmor does not support non-standard home directory locations - automatic discovery of home directories

Bug #151190 reported by Michael Kofler
34
Affects Status Importance Assigned to Milestone
apparmor (Ubuntu)
Fix Released
Wishlist
Jamie Strandboge

Bug Description

Binary package hint: cups-pdf

my home directory is /myhome/kofler (/myhome being a separate partition)

for this (I agree: special) case, cups-pdf in unable to create ~/PDF or ~/PDF/name.pdf because of apparmor

/var/log/messages

Oct 10 08:22:41 merkur kernel: [ 1599.236000] audit(1191997361.468:7): type=1503 operation="capable" name="dac_override" pid=13061 profile="/usr/lib/cups/backend/cups-pdf"
Oct 10 08:22:41 merkur kernel: [ 1599.236000] audit(1191997361.468:8): type=1503 operation="capable" name="dac_read_search" pid=13061 profile="/usr/lib/cups/backend/cups-pdf"
Oct 10 08:22:41 merkur kernel: [ 1599.236000] audit(1191997361.468:9): type=1503 operation="inode_mkdir" requested_mask="w" denied_mask="w" name="/myhome/kofler/PDF/" pid=13062 profile="/usr/lib/cups/backend/cups-pdf"
Oct 10 08:27:53 merkur kernel: [ 1910.692000] audit(1191997672.986:10): type=1503 operation="capable" name="dac_override" pid=13121 profile="/usr/lib/cups/backend/cups-pdf"
Oct 10 08:27:53 merkur kernel: [ 1910.692000] audit(1191997672.986:11): type=1503 operation="capable" name="dac_read_search" pid=13121 profile="/usr/lib/cups/backend/cups-pdf"
Oct 10 08:27:53 merkur kernel: [ 1910.692000] audit(1191997672.986:12): type=1503 operation="inode_mkdir" requested_mask="w" denied_mask="w" name="/myhome/kofler/PDF/" pid=13122 profile="/usr/lib/cups/backend/cups-pdf"
Oct 10 08:39:56 merkur kernel: [ 2633.620000] audit(1191998396.027:13): type=1503 operation="capable" name="dac_override" pid=13151 profile="/usr/lib/cups/backend/cups-pdf"
Oct 10 08:39:56 merkur kernel: [ 2633.620000] audit(1191998396.027:14): type=1503 operation="capable" name="dac_read_search" pid=13151 profile="/usr/lib/cups/backend/cups-pdf"
Oct 10 08:39:56 merkur kernel: [ 2633.712000] audit(1191998396.027:15): type=1503 operation="inode_create" requested_mask="w" denied_mask="w" name="/myhome/kofler/PDF/035.pdf" pid=13154 profile="/usr/lib/cups/backend/cups-pdf"

Revision history for this message
hunger (hunger) wrote :

I think this is not a bug but intended behaviour. Apparmor is all about restricting access to locations on disc after all;-)

I'd recommend tuning /etc/apparmor.d/tunables/home to include your custom homedir location(s). That should fix all of the apparmor profiles for your setup (even though it might not, apparmor is still pretty raw in ubuntu IMHO). Well, any breakage after the change I proposed is a new bug:-)

Best regards,
Tobias

Revision history for this message
Patrice Vetsel (vetsel-patrice) wrote :

Please put cupsd in complain mode for apparmor with :
sudo aa-complain cupsd

and retry your bug.

Changed in cups-pdf:
status: New → Incomplete
Revision history for this message
Michael Kofler (michael-kofler) wrote :

/var/log/messages with sudo aa-complain cupsd

Oct 12 10:32:03 merkur kernel: [ 7942.556000] audit(1192177922.828:17): type=1502 operation="capable" name="dac_override" pid=6971 profile="/usr/lib/cups/backend/cups-pdf"
Oct 12 10:32:03 merkur kernel: [ 7942.628000] audit(1192177922.828:18): type=1502 operation="inode_create" requested_mask="w" denied_mask="w" name="/myhome/kofler/PDF/Welcome_to_LWN_net__LWN_net_.pdf" pid=6974 profile="/usr/lib/cups/backend/cups-pdf"
Oct 12 10:32:03 merkur kernel: [ 7942.884000] audit(1192177923.328:19): type=1502 operation="setattr" requested_mask="w" denied_mask="w" attribute="mode,ctime," name="/myhome/kofler/PDF/Welcome_to_LWN_net__LWN_net_.pdf" pid=6972 profile="/usr/lib/cups/backend/cups-pdf"

@hunger:

if I change @HOMEDIRS in /etc/apparmor.d/tunables/home like this:

@{HOMEDIRS}=/home/ /myhome/

PDF generation works fine; no negative side-effects so far

thanks for the hint!

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

It would be nice if there is an easy way to configure AppArmor for non-standard home (and system) directory locations, by some config tool or automatically whenever a new user gets added. Also the post-install script of AppArmor could discover where user home directories are placed and adapt the AppArmor configuration.

Changed in cups-pdf:
importance: Undecided → Wishlist
status: Incomplete → Confirmed
Mathias Gug (mathiaz)
Changed in apparmor:
status: Confirmed → Triaged
Revision history for this message
Mathias Gug (mathiaz) wrote :

I've added a note to the AppArmor (https://help.ubuntu.com/community/AppArmor) guide about customizing profiles with non-standard home directories.

Revision history for this message
hunger (hunger) wrote :

Actually I think it is a bad idea to automagically change apparmour settings around: Its sole purpose is to restrict access after all.

Either you care about the extra security layer apparmor provides: You will not want random scripts to change settings around for you. E.g. I have a couple of system users with non-standard homedirs: I do want apparmor to prvent some service from writting there. So please don't try to make apparmor clever and auto-add homedirs!

If you do not care for this extra security layer then you can just deinstall the whole thing and don't need to worry about it.

It is great that Mathias documented this though!

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

I agree that we can't automagically change apparmor settings at runtime. However, we should discuss ways to improve this usability issue. This topic is planned for Lucid UDS.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

This was actually fixed for Lucid in 2.5~pre+bzr1362-0ubuntu2 where apparmor will use the /etc/apparmor.d/tunables/home.d directory and prepopulate HOMEDIRS on upgrades.

Changed in apparmor (Ubuntu):
assignee: nobody → Jamie Strandboge (jdstrand)
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.