@@ -117,8 +117,8 @@ static int ll_create_full_ruleset(void) {
117
117
return ruleset_fd ;
118
118
}
119
119
120
- static int ll_fs (const char * allowed_path , const __u64 allowed_access ,
121
- const char * caller ) {
120
+ static int _ll_fs (const char * allowed_path , const __u64 allowed_access ,
121
+ const char * caller ) {
122
122
if (!ll_is_supported ())
123
123
return 0 ;
124
124
@@ -155,6 +155,16 @@ static int ll_fs(const char *allowed_path, const __u64 allowed_access,
155
155
return error ;
156
156
}
157
157
158
+ // TODO: Add support for the ${PATH} macro.
159
+ static int ll_fs (const char * allowed_path , const __u64 allowed_access ,
160
+ const char * caller ) {
161
+ char * expanded_path = expand_macros (allowed_path );
162
+ int error = _ll_fs (expanded_path , allowed_access , caller );
163
+
164
+ free (expanded_path );
165
+ return error ;
166
+ }
167
+
158
168
int ll_read (const char * allowed_path ) {
159
169
__u64 allowed_access =
160
170
LANDLOCK_ACCESS_FS_READ_DIR |
@@ -192,58 +202,6 @@ int ll_exec(const char *allowed_path) {
192
202
return ll_fs (allowed_path , allowed_access , __func__ );
193
203
}
194
204
195
- int ll_basic_system (void ) {
196
- assert (cfg .homedir );
197
-
198
- if (!ll_is_supported ())
199
- return 0 ;
200
-
201
- if (ll_ruleset_fd == -1 )
202
- ll_ruleset_fd = ll_create_full_ruleset ();
203
-
204
- int error ;
205
- char * rundir ;
206
- if (asprintf (& rundir , "/run/user/%d" , getuid ()) == -1 )
207
- errExit ("asprintf" );
208
-
209
- error =
210
- ll_read ("/" ) || // whole system read
211
- ll_special ("/" ) || // sockets etc.
212
-
213
- ll_write ("/tmp" ) || // write access
214
- ll_write ("/dev" ) ||
215
- ll_write ("/run/shm" ) ||
216
- ll_write (cfg .homedir ) ||
217
- ll_write (rundir ) ||
218
-
219
- ll_exec ("/opt" ) || // exec access
220
- ll_exec ("/bin" ) ||
221
- ll_exec ("/sbin" ) ||
222
- ll_exec ("/lib" ) ||
223
- ll_exec ("/lib32" ) ||
224
- ll_exec ("/libx32" ) ||
225
- ll_exec ("/lib64" ) ||
226
- ll_exec ("/usr/bin" ) ||
227
- ll_exec ("/usr/sbin" ) ||
228
- ll_exec ("/usr/games" ) ||
229
- ll_exec ("/usr/lib" ) ||
230
- ll_exec ("/usr/lib32" ) ||
231
- ll_exec ("/usr/libx32" ) ||
232
- ll_exec ("/usr/lib64" ) ||
233
- ll_exec ("/usr/local/bin" ) ||
234
- ll_exec ("/usr/local/sbin" ) ||
235
- ll_exec ("/usr/local/games" ) ||
236
- ll_exec ("/usr/local/lib" ) ||
237
- ll_exec ("/run/firejail" ); // appimage and various firejail features
238
-
239
- if (error ) {
240
- fprintf (stderr , "Error: %s: failed to set --landlock rules\n" ,
241
- __func__ );
242
- }
243
- free (rundir );
244
- return error ;
245
- }
246
-
247
205
int ll_restrict (uint32_t flags ) {
248
206
if (!ll_is_supported ())
249
207
return 0 ;
@@ -293,9 +251,6 @@ void ll_add_profile(int type, const char *data) {
293
251
assert (type < LL_MAX );
294
252
assert (data );
295
253
296
- if (!ll_is_supported ())
297
- return ;
298
-
299
254
while (* data == ' ' || * data == '\t' )
300
255
data ++ ;
301
256
0 commit comments