[apparmor] [patch] - performance again... small changes

Peter Maloney peter.maloney at brockmann-consult.de
Thu Nov 27 08:28:12 UTC 2014


>> diff -ur orig/aa.py p1a/aa.py
>> --- orig/aa.py	2014-10-16 22:03:42.000000000 +0200
>> +++ p1a/aa.py	2014-11-24 22:55:56.522927379 +0100
>> @@ -147,29 +147,27 @@
>>      sys.exit(1)
>>  
>>  def check_for_apparmor():
>> -    """Finds and returns the mointpoint for apparmor None otherwise"""
>> +    """Finds and returns the mountpoint for apparmor None otherwise"""
>>      filesystem = '/proc/filesystems'
>>      mounts = '/proc/mounts'
>>      support_securityfs = False
>>      aa_mountpoint = None
>> -    regex_securityfs = re.compile('^\S+\s+(\S+)\s+securityfs\s')
>>      if valid_path(filesystem):
>>          with open_file_read(filesystem) as f_in:
>>              for line in f_in:
>>                  if 'securityfs' in line:
>>                      support_securityfs = True
>> *-    if valid_path(mounts):*
>> -        with open_file_read(mounts) as f_in:
>> -            for line in f_in:
>> -                if support_securityfs:
>> -                    match = regex_securityfs.search(line)
>> -                    if match:
>> -                        mountpoint = match.groups()[0] + '/apparmor'
>> -                        if valid_path(mountpoint):
>> +                    break
>> +        if support_securityfs:
>> +            with open_file_read(mounts) as f_in:
>> +                for line in f_in:
>> +                    split = line.split()
>> +                    if len(split) > 2 and split[2] == 'securityfs':
>> +                        mountpoint = split[1] + '/apparmor'
>> +                        # Check if apparmor is actually mounted there
>> +                        if valid_path(mountpoint) and valid_path(mountpoint + '/profiles'):
>>                              aa_mountpoint = mountpoint
>> -    # Check if apparmor is actually mounted there
>> -    if not valid_path(aa_mountpoint + '/profiles'):
>> -        aa_mountpoint = None
>> +                            break
>>      return aa_mountpoint
>>  
>>  def which(file):
>

Oh and actually I don't know why "if valid_path(mounts):" was removed. I
think that was supposed to be kept since we open it as a file. Here is a
new patch (attached)

+    if valid_path(mounts) and support_securityfs:


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20141127/641fcfa8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p1a-securityfsthing.patch
Type: text/x-patch
Size: 1806 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20141127/641fcfa8/attachment.bin>


More information about the AppArmor mailing list