aa-cleanprof "An unexpected error occoured!" during the command

Bug #1863415 reported by Detlev Roeben
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
AppArmor
New
Undecided
Unassigned

Bug Description

during the command: sudo aa-cleanprof /usr/sbin/mysqld
"An unexpected error occoured!"
Bug-report reads:
###
AppArmorBug
Python 3.7.3: /usr/bin/python3
Sat Feb 15 12:40:23 2020

A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.

 /usr/sbin/aa-cleanprof in <module>()
   27 parser = argparse.ArgumentParser(description=_('Cleanup the profiles for the given programs'))
   28 parser.add_argument('-d', '--dir', type=str, help=_('path to profiles'))
   29 parser.add_argument('program', type=str, nargs='+', help=_('name of program'))
   30 parser.add_argument('-s', '--silent', action='store_true', help=_('Silently overwrite with a clean profile'))
   31 parser.add_argument('--no-reload', dest='do_reload', action='store_false', default=True, help=_('Do not reload the profile after modifying it'))
   32 args = parser.parse_args()
   33
   34 clean = apparmor.tools.aa_tools('cleanprof', args)
   35
   36 clean.cleanprof_act()
clean = <apparmor.tools.aa_tools object>
clean.cleanprof_act = <bound method aa_tools.cleanprof_act of <apparmor.tools.aa_tools object>>

 /usr/lib/python3/dist-packages/apparmor/tools.py in cleanprof_act(self=<apparmor.tools.aa_tools object>)
   98 program = aaui.UI_GetString(_('The given program cannot be found, please try with the fully qualified path name of the program: '), '')
   99 else:
  100 aaui.UI_Info(_("%s does not exist, please double-check the path.") % program)
  101 sys.exit(1)
  102
  103 if program and apparmor.profile_exists(program):
  104 self.clean_profile(program)
  105
  106 else:
  107 if '/' not in program:
program = '/usr/sbin/mysqld'
global apparmor = <module 'apparmor.aa' from '/usr/lib/python3/dist-packages/apparmor/aa.py'>
apparmor.profile_exists = <function profile_exists>

 /usr/lib/python3/dist-packages/apparmor/aa.py in profile_exists(program='/usr/sbin/mysqld')
  715 # Check the disk for profile
  716 prof_path = get_profile_filename_from_attachment(program, True)
  717 #print(prof_path)
  718 if os.path.isfile(prof_path):
  719 # Add to cache of profile
  720 raise AppArmorBug('Reached strange condition in profile_exists(), please open a bugreport!')
  721 # active_profiles[program] = prof_path
  722 # return True
  723 return False
  724
global AppArmorBug = <class 'apparmor.common.AppArmorBug'>
AppArmorBug: Reached strange condition in profile_exists(), please open a bugreport!
    __cause__ = None
    __class__ = <class 'apparmor.common.AppArmorBug'>
    __context__ = None
    __delattr__ = <method-wrapper '__delattr__' of AppArmorBug object>
    __dict__ = {}
    __dir__ = <built-in method __dir__ of AppArmorBug object>
    __doc__ = 'This class represents AppArmor exceptions "that should never happen"'
    __eq__ = <method-wrapper '__eq__' of AppArmorBug object>
    __format__ = <built-in method __format__ of AppArmorBug object>
    __ge__ = <method-wrapper '__ge__' of AppArmorBug object>
    __getattribute__ = <method-wrapper '__getattribute__' of AppArmorBug object>
    __gt__ = <method-wrapper '__gt__' of AppArmorBug object>
    __hash__ = <method-wrapper '__hash__' of AppArmorBug object>
    __init__ = <method-wrapper '__init__' of AppArmorBug object>
    __init_subclass__ = <built-in method __init_subclass__ of type object>
    __le__ = <method-wrapper '__le__' of AppArmorBug object>
    __lt__ = <method-wrapper '__lt__' of AppArmorBug object>
    __module__ = 'apparmor.common'
    __ne__ = <method-wrapper '__ne__' of AppArmorBug object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of AppArmorBug object>
    __reduce_ex__ = <built-in method __reduce_ex__ of AppArmorBug object>
    __repr__ = <method-wrapper '__repr__' of AppArmorBug object>
    __setattr__ = <method-wrapper '__setattr__' of AppArmorBug object>
    __setstate__ = <built-in method __setstate__ of AppArmorBug object>
    __sizeof__ = <built-in method __sizeof__ of AppArmorBug object>
    __str__ = <method-wrapper '__str__' of AppArmorBug object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __suppress_context__ = False
    __traceback__ = <traceback object>
    __weakref__ = None
    args = ('Reached strange condition in profile_exists(), please open a bugreport!',)
    with_traceback = <built-in method with_traceback of AppArmorBug object>

The above is a description of an error in a Python program. Here is
the original traceback:

Traceback (most recent call last):
  File "/usr/sbin/aa-cleanprof", line 36, in <module>
    clean.cleanprof_act()
  File "/usr/lib/python3/dist-packages/apparmor/tools.py", line 103, in cleanprof_act
    if program and apparmor.profile_exists(program):
  File "/usr/lib/python3/dist-packages/apparmor/aa.py", line 720, in profile_exists
    raise AppArmorBug('Reached strange condition in profile_exists(), please open a bugreport!')
apparmor.common.AppArmorBug: Reached strange condition in profile_exists(), please open a bugreport!

Please consider reporting a bug at https://bugs.launchpad.net/apparmor/
and attach this file.
###

best regards
detlev

Revision history for this message
Christian Boltz (cboltz) wrote :

Thanks for the bugreport!

The profile that probably triggers this is /etc/apparmor.d/usr.sbin.mysqld

My guess is that this file is empty or contains only comments - at least I can reproduce the problem when using such a file. Can you please confirm that your /etc/apparmor.d/usr.sbin.mysqld indeed only contains comments? (Or simply attach it ;-)

Revision history for this message
Detlev Roeben (tux11) wrote : Re: [Bug 1863415] Re: aa-cleanprof "An unexpected error occoured!" during the command

Dear Christian,

thank you for the quick analysis.

Oh how embarrassing, 8-)
you are absolutely right. The file only contains text.

I think this is not a bug in apparmor but maybe in the python script.

Best wishes for you and thanks again

Detlev

Am 16.02.20 um 21:47 schrieb Christian Boltz:
> Thanks for the bugreport!
>
> The profile that probably triggers this is
> /etc/apparmor.d/usr.sbin.mysqld
>
> My guess is that this file is empty or contains only comments - at least
> I can reproduce the problem when using such a file. Can you please
> confirm that your /etc/apparmor.d/usr.sbin.mysqld indeed only contains
> comments? (Or simply attach it ;-)
>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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