Skip to content

Commit 8efcfb2

Browse files
okunzcopybara-github
authored andcommitted
policybuilder: Add convenience function AllowInotify for the inotify API.
This change introduces a new `PolicyBuilder::AllowInotify()` method that permits the full inotify API, including `inotify_init`, `inotify_init1`, `inotify_add_watch`, `inotify_rm_watch`, and close. The existing `AllowInotifyInit()` only covers the initialization syscalls and will be removed in a second step. PiperOrigin-RevId: 800042599 Change-Id: I0b775af1450fc49e03b63a4e30ed46cb4e55e411
1 parent 514576e commit 8efcfb2

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

sandboxed_api/sandbox2/policybuilder.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,24 @@ PolicyBuilder& PolicyBuilder::AllowInotifyInit() {
303303
});
304304
}
305305

306+
PolicyBuilder& PolicyBuilder::AllowInotify() {
307+
return AllowSyscalls({
308+
#ifdef __NR_inotify_init
309+
__NR_inotify_init,
310+
#endif
311+
#ifdef __NR_inotify_init1
312+
__NR_inotify_init1,
313+
#endif
314+
#ifdef __NR_inotify_add_watch
315+
__NR_inotify_add_watch,
316+
#endif
317+
#ifdef __NR_inotify_rm_watch
318+
__NR_inotify_rm_watch,
319+
#endif
320+
__NR_close,
321+
});
322+
}
323+
306324
PolicyBuilder& PolicyBuilder::AllowSelect() {
307325
return AllowSyscalls({
308326
#ifdef __NR_select

sandboxed_api/sandbox2/policybuilder.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,16 @@ class PolicyBuilder final {
239239
// - inotify_init1
240240
PolicyBuilder& AllowInotifyInit();
241241

242+
// Appends code to allow the inotify API.
243+
//
244+
// Allows these syscalls:
245+
// - inotify_init
246+
// - inotify_init1
247+
// - inotify_add_watch
248+
// - inotify_rm_watch
249+
// - close
250+
PolicyBuilder& AllowInotify();
251+
242252
// Appends code to allow synchronous I/O multiplexing.
243253
//
244254
// Allows these syscalls:

0 commit comments

Comments
 (0)