[apparmor] [patch] [36/38] Drop several now unused functions and variables from aamode.py
Christian Boltz
apparmor at cboltz.de
Fri Aug 12 21:07:23 UTC 2016
Hello,
after switching to FileRule, several functions in aamode.py are no
longer used and can be deleted:
- print_mode()
- sub_mode_to_str()
- is_user_mode()
split_mode()
- mode_to_str()
- flatten_mode()
- owner_flatten_mode()
- mode_to_str_user()
- log_str_to_mode()
The AA_EXEC_TYPE and ALL_AA_EXEC_TYPE variables are also unused now.
[ 36-cleanup-aamode.diff ]
--- utils/apparmor/aamode.py 2016-08-07 23:26:02.578965371 +0200
+++ utils/apparmor/aamode.py 2016-08-07 23:20:02.912696696 +0200
@@ -45,11 +45,6 @@
#AA_OTHER_SHIFT = 14
#AA_USER_MASK = 16384 - 1
-AA_EXEC_TYPE = (AA_MAY_EXEC | AA_EXEC_UNSAFE | AA_EXEC_INHERIT |
- AA_EXEC_UNCONFINED | AA_EXEC_PROFILE | AA_EXEC_CHILD | AA_EXEC_NT)
-
-ALL_AA_EXEC_TYPE = AA_EXEC_TYPE
-
MODE_HASH = {'x': AA_MAY_EXEC, 'X': AA_MAY_EXEC,
'w': AA_MAY_WRITE, 'W': AA_MAY_WRITE,
'r': AA_MAY_READ, 'R': AA_MAY_READ,
@@ -133,67 +128,6 @@
mode = mode.replace('::', '')
return mode
-def print_mode(mode):
- user, other = split_mode(mode)
- string = sub_mode_to_str(user) + '::' + sub_mode_to_str(other)
-
- return string
-
-def sub_mode_to_str(mode):
- string = ''
- # w(write) implies a(append)
- if mode & AA_MAY_WRITE:
- mode = mode - AA_MAY_APPEND
- #string = ''.join(mode)
-
- if mode & AA_EXEC_MMAP:
- string += 'm'
- if mode & AA_MAY_READ:
- string += 'r'
- if mode & AA_MAY_WRITE:
- string += 'w'
- if mode & AA_MAY_APPEND:
- string += 'a'
- if mode & AA_MAY_LINK:
- string += 'l'
- if mode & AA_MAY_LOCK:
- string += 'k'
-
- # modes P and C must appear before I and U else invalid syntax
- if mode & (AA_EXEC_PROFILE | AA_EXEC_NT):
- if mode & AA_EXEC_UNSAFE:
- string += 'p'
- else:
- string += 'P'
-
- if mode & AA_EXEC_CHILD:
- if mode & AA_EXEC_UNSAFE:
- string += 'c'
- else:
- string += 'C'
-
- if mode & AA_EXEC_UNCONFINED:
- if mode & AA_EXEC_UNSAFE:
- string += 'u'
- else:
- string += 'U'
-
- if mode & AA_EXEC_INHERIT:
- string += 'i'
-
- if mode & AA_MAY_EXEC:
- string += 'x'
-
- return string
-
-def is_user_mode(mode):
- user, other = split_mode(mode)
-
- if user and not other:
- return True
- else:
- return False
-
def split_mode(mode):
user = set()
for i in mode:
@@ -203,45 +137,6 @@
other = AA_OTHER_REMOVE(other)
return user, other
-def mode_to_str(mode):
- mode = flatten_mode(mode)
- return sub_mode_to_str(mode)
-
-def flatten_mode(mode):
- if not mode:
- return set()
-
- user, other = split_mode(mode)
- mode = user | other
- mode |= (AA_OTHER(mode))
-
- return mode
-
-def owner_flatten_mode(mode):
- mode = flatten_mode(mode)
- return mode
-
-def mode_to_str_user(mode):
- user, other = split_mode(mode)
- string = ''
-
- if not user:
- user = set()
- if not other:
- other = set()
-
- if user - other:
- if other:
- string = sub_mode_to_str(other) + '+'
- string += 'owner ' + sub_mode_to_str(user - other)
-
- elif is_user_mode(mode):
- string = 'owner ' + sub_mode_to_str(user)
- else:
- string = sub_mode_to_str(flatten_mode(mode))
-
- return string
-
def log_str_to_mode(profile, string, nt_name):
mode = str_to_mode(string)
# If contains nx and nix
Regards,
Christian Boltz
--
P.S.: In der kommenden Version sollen die besten Eigenschaften von
Windows CE, Me und NT vereinigt werden zu "Windows CEMENT". Wenn das
mal nicht'n stabiles OS wird. ;-))))) [Ratti in suse-linux]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20160812/3e9e3f3c/attachment.pgp>
More information about the AppArmor
mailing list