aa-genprof should display a clear error message instead of a stack trace if it doesn't have write permissions to the profile directory

Bug #1489196 reported by Moshe Kaplan
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
AppArmor
New
Undecided
Unassigned
apparmor (Ubuntu)
Confirmed
Wishlist
Unassigned

Bug Description

When attempting to run aa-genprof, I received the following stack trace:

user@user-desktop:~$ aa-genprof airodump-ng
Writing updated profile for /home/user/aircrack/src/airodump-ng.
Traceback (most recent call last):
  File "/usr/sbin/aa-genprof", line 109, in <module>
    apparmor.autodep(program)
  File "/usr/lib/python3/dist-packages/apparmor/aa.py", line 597, in autodep
    write_profile_ui_feedback(pname)
  File "/usr/lib/python3/dist-packages/apparmor/aa.py", line 4307, in write_profile_ui_feedback
    write_profile(profile)
  File "/usr/lib/python3/dist-packages/apparmor/aa.py", line 4316, in write_profile
    newprof = tempfile.NamedTemporaryFile('w', suffix='~', delete=False, dir=profile_dir)
  File "/usr/lib/python3.4/tempfile.py", line 599, in NamedTemporaryFile
    (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
  File "/usr/lib/python3.4/tempfile.py", line 339, in _mkstemp_inner
    fd = _os.open(file, flags, 0o600)
PermissionError: [Errno 13] Permission denied: '/etc/apparmor.d/tmpj_2nnooj~'

Practically, this was caused by accidentally not running aa-genprof as root. But it would be much more useful for a user if AppArmor instead displayed a helpful error message, like: "Unable to create file in profile directory(%s). Try running aa-genprof as root." % profile_dir

Tags: aa-tools
Christian Boltz (cboltz)
tags: added: aa-tools
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in apparmor (Ubuntu):
status: New → Confirmed
Mathew Hodson (mhodson)
Changed in apparmor (Ubuntu):
importance: Undecided → Wishlist
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.