aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorLibravatar rusty-snake <41237666+rusty-snake@users.noreply.github.com>2021-02-17 16:10:36 +0000
committerLibravatar GitHub <noreply@github.com>2021-02-17 16:10:36 +0000
commitbdabc874f3fadcfc2780a699464a0b923e71c0fc (patch)
tree05cd723aec9273a29d8585a86e46df3dd649fd7b /contrib
parentMerge pull request #3995 from glitsj16/jitsi-meet-desktop (diff)
parentsort.py: Remove whitespace in status output (diff)
downloadfirejail-bdabc874f3fadcfc2780a699464a0b923e71c0fc.tar.gz
firejail-bdabc874f3fadcfc2780a699464a0b923e71c0fc.tar.zst
firejail-bdabc874f3fadcfc2780a699464a0b923e71c0fc.zip
Merge pull request #3985 from rusty-snake/sort.py-updates
Sort.py updates
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/sort.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/contrib/sort.py b/contrib/sort.py
index 5df353549..9e5062c3c 100755
--- a/contrib/sort.py
+++ b/contrib/sort.py
@@ -80,7 +80,7 @@ def fix_profile(filename):
80 lines = profile.read().split("\n") 80 lines = profile.read().split("\n")
81 was_fixed = False 81 was_fixed = False
82 fixed_profile = [] 82 fixed_profile = []
83 for line in lines: 83 for lineno, line in enumerate(lines):
84 if line[:12] in ("private-bin ", "private-etc ", "private-lib "): 84 if line[:12] in ("private-bin ", "private-etc ", "private-lib "):
85 fixed_line = f"{line[:12]}{sort_alphabetical(line[12:])}" 85 fixed_line = f"{line[:12]}{sort_alphabetical(line[12:])}"
86 elif line[:13] in ("seccomp.drop ", "seccomp.keep "): 86 elif line[:13] in ("seccomp.drop ", "seccomp.keep "):
@@ -95,6 +95,10 @@ def fix_profile(filename):
95 fixed_line = line 95 fixed_line = line
96 if fixed_line != line: 96 if fixed_line != line:
97 was_fixed = True 97 was_fixed = True
98 print(
99 f"{filename}:{lineno + 1}:-{line}\n"
100 f"{filename}:{lineno + 1}:+{fixed_line}"
101 )
98 fixed_profile.append(fixed_line) 102 fixed_profile.append(fixed_line)
99 if was_fixed: 103 if was_fixed:
100 profile.seek(0) 104 profile.seek(0)
@@ -108,6 +112,7 @@ def fix_profile(filename):
108 112
109def main(args): 113def main(args):
110 exit_code = 0 114 exit_code = 0
115 print(f"sort.py: checking {len(args)} {'profiles' if len(args) != 1 else 'profile'}...")
111 for filename in args: 116 for filename in args:
112 try: 117 try:
113 if exit_code not in (1, 101): 118 if exit_code not in (1, 101):
@@ -120,8 +125,8 @@ def main(args):
120 except PermissionError: 125 except PermissionError:
121 print(f"[ Error ] Can't read/write `{filename}'") 126 print(f"[ Error ] Can't read/write `{filename}'")
122 exit_code = 1 127 exit_code = 1
123 except: 128 except Exception as err:
124 print(f"[ Error ] An error occurred while processing `{filename}'") 129 print(f"[ Error ] An error occurred while processing `{filename}': {err}")
125 exit_code = 1 130 exit_code = 1
126 return exit_code 131 return exit_code
127 132