diff options
Diffstat (limited to 'contrib/jail_prober.py')
-rwxr-xr-x | contrib/jail_prober.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/contrib/jail_prober.py b/contrib/jail_prober.py index 9205d9b3e..f89f97ac4 100755 --- a/contrib/jail_prober.py +++ b/contrib/jail_prober.py | |||
@@ -70,6 +70,19 @@ def get_args(profile_path): | |||
70 | return profile | 70 | return profile |
71 | 71 | ||
72 | 72 | ||
73 | def absolute_include(word): | ||
74 | home = os.environ['HOME'] | ||
75 | path = home + '/.config/firejail/' | ||
76 | |||
77 | option, filename = word.split('=') | ||
78 | absolute_filename = path + filename | ||
79 | |||
80 | if not os.path.isfile(absolute_filename): | ||
81 | absolute_filename = '${CFG}/' + filename | ||
82 | |||
83 | return option + '=' + absolute_filename | ||
84 | |||
85 | |||
73 | def arg_converter(arg_list, style): | 86 | def arg_converter(arg_list, style): |
74 | """ | 87 | """ |
75 | Convert between firejail command-line arguments (--example=something) and | 88 | Convert between firejail command-line arguments (--example=something) and |
@@ -94,9 +107,12 @@ def arg_converter(arg_list, style): | |||
94 | if style == 'to_profile': | 107 | if style == 'to_profile': |
95 | new_args = [word[2:] for word in new_args] | 108 | new_args = [word[2:] for word in new_args] |
96 | 109 | ||
97 | # Remove invalid '--include' args if converting to command-line form | ||
98 | elif style == 'to_commandline': | 110 | elif style == 'to_commandline': |
99 | new_args = [word for word in new_args if 'include' not in word] | 111 | new_args = [ |
112 | absolute_include(word) if word.startswith('--include') | ||
113 | else word | ||
114 | for word in new_args | ||
115 | ] | ||
100 | 116 | ||
101 | return new_args | 117 | return new_args |
102 | 118 | ||
@@ -148,8 +164,12 @@ def run_firejail(program, all_args): | |||
148 | 164 | ||
149 | 165 | ||
150 | def main(): | 166 | def main(): |
151 | profile_path = sys.argv[1] | 167 | try: |
152 | program = sys.argv[2] | 168 | profile_path = sys.argv[1] |
169 | program = sys.argv[2] | ||
170 | except IndexError: | ||
171 | print('USAGE: jail_prober.py <PROFILE-PATH> <PROGRAM>') | ||
172 | sys.exit() | ||
153 | # Quick error check and extract arguments | 173 | # Quick error check and extract arguments |
154 | check_params(profile_path) | 174 | check_params(profile_path) |
155 | profile = get_args(profile_path) | 175 | profile = get_args(profile_path) |