dev-setup: rework make_inaccessible_nodes() around openat() and friends

Let's operate on fds rather than paths. Make some tweaks to the logic on
top:

1. Mark the resulting dir as read-only after we are done.
2. Use the new inode_type_to_string() calls to determine the inode
   names.
3. If an inode already exists, try to adjust the access mode, just in
   case.
4. Use FOREACH_ARRAY()
This commit is contained in:
Lennart Poettering
2024-01-06 08:27:51 +09:00
committed by Yu Watanabe
parent 0d1706b5fa
commit a6a7983dbf
2 changed files with 38 additions and 21 deletions
+1
View File
@@ -25,6 +25,7 @@ int main(int argc, char *argv[]) {
assert_se(mkdir_p(f, 0755) >= 0);
assert_se(make_inaccessible_nodes(f, 1, 1) >= 0);
assert_se(make_inaccessible_nodes(f, 1, 1) >= 0); /* 2nd call should be a clean NOP */
f = prefix_roota(p, "/run/systemd/inaccessible/reg");
assert_se(stat(f, &st) >= 0);