for (_cleanup_umask_ mode_t _saved_umask_ = umask(mask) | S_IFMT; \
FLAGS_SET(_saved_umask_, S_IFMT); \
_saved_umask_ &= 0777)
+
+#define BLOCK_WITH_UMASK(mask) \
+ _unused_ _cleanup_umask_ mode_t _saved_umask_ = umask(mask);
"tty\0"
"net/tun\0";
- _unused_ _cleanup_umask_ mode_t u;
const char *d;
int r = 0;
assert(dest);
- u = umask(0000);
+ BLOCK_WITH_UMASK(0000);
/* Create /dev/net, so that we can create /dev/net/tun in it */
if (userns_mkdir(dest, "/dev/net", 0755, 0, 0) < 0)
}
static int make_extra_nodes(const char *dest) {
- _unused_ _cleanup_umask_ mode_t u;
size_t i;
int r;
- u = umask(0000);
+ BLOCK_WITH_UMASK(0000);
for (i = 0; i < arg_n_extra_nodes; i++) {
_cleanup_free_ char *path = NULL;
_cleanup_(unlink_and_freep) char *from = NULL;
_cleanup_free_ char *fifo = NULL;
_cleanup_close_ int fd = -1;
- _unused_ _cleanup_umask_ mode_t u;
int r;
assert(kmsg_socket >= 0);
- u = umask(0000);
+ BLOCK_WITH_UMASK(0000);
/* We create the kmsg FIFO as as temporary file in /run, but immediately delete it after bind mounting it to
* /proc/kmsg. While FIFOs on the reading side behave very similar to /proc/kmsg, their writing side behaves
{ "inaccessible/blk", S_IFBLK | 0000 },
};
- _unused_ _cleanup_umask_ mode_t u;
int r;
if (!parent_dir)
parent_dir = "/run/systemd";
- u = umask(0000);
+ BLOCK_WITH_UMASK(0000);
/* Set up inaccessible (and empty) file nodes of all types. This are used to as mount sources for over-mounting
* ("masking") file nodes that shall become inaccessible and empty for specific containers or services. We try
static void test_chmod_and_chown(void) {
_cleanup_(rm_rf_physical_and_freep) char *d = NULL;
- _unused_ _cleanup_umask_ mode_t u = umask(0000);
struct stat st;
const char *p;
log_info("/* %s */", __func__);
+ BLOCK_WITH_UMASK(0000);
+
assert_se(mkdtemp_malloc(NULL, &d) >= 0);
p = strjoina(d, "/reg");