No sudo in aa-logprof. Permission denied: '/etc/apparmor.d/tmpcio6o9zd~'
[UPDATE]
I think I discovered this one... I didn't provide sudo
on aa-logprof
, and it would certainly not be able to write into /etc/apparmor.d/
directory. So, my suggestion is to warn users that sudo
is necessary here instead randomly crashing (as problem is not with aa-logprof, right?). Or at least, in the end of the process, before saving, checking that not enough permissions exist to update the file (preferred in the beggining than the end).
======= [ORIGINAL ISSUE]
The aa-logprof
crashed after trying to save some successful configuration (using english locale, no translation issue I guess):
$ aa-logprof
...
many things here, then I choose to (S)ave Changes... and crash happens.
...
$ cat /tmp/apparmor-bugreport-lk_gy1li.txt
<pre>Traceback (most recent call last):
File "/usr/sbin/aa-logprof", line 51, in <module>
apparmor.do_logprof_pass(logmark)
File "/usr/lib/python3/dist-packages/apparmor/aa.py", line 1511, in do_logprof_pass
save_profiles()
File "/usr/lib/python3/dist-packages/apparmor/aa.py", line 1573, in save_profiles
write_profile_ui_feedback(profile_name)
File "/usr/lib/python3/dist-packages/apparmor/aa.py", line 2265, in write_profile_ui_feedback
write_profile(profile, is_attachment)
File "/usr/lib/python3/dist-packages/apparmor/aa.py", line 2276, in write_profile
newprof = tempfile.NamedTemporaryFile('w', suffix='~', delete=False, dir=profile_dir)
File "/usr/lib/python3.10/tempfile.py", line 698, in NamedTemporaryFile
file = _io.open(dir, mode, buffering=buffering,
File "/usr/lib/python3.10/tempfile.py", line 695, in opener
fd, name = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "/usr/lib/python3.10/tempfile.py", line 395, in _mkstemp_inner
fd = _os.open(file, flags, 0o600)
PermissionError: [Errno 13] Permission denied: '/etc/apparmor.d/tmpcio6o9zd~'
</pre>
Please consider reporting a bug at https://gitlab.com/apparmor/apparmor/-/issues
and attach this file.