mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 16:37:19 +09:00
umask-util: add helper that resets umask until end of current code block
This commit is contained in:
@@ -24,3 +24,6 @@ assert_cc((S_IFMT & 0777) == 0);
|
||||
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);
|
||||
|
||||
@@ -2216,13 +2216,12 @@ static int copy_devnodes(const char *dest) {
|
||||
"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)
|
||||
@@ -2299,11 +2298,10 @@ static int copy_devnodes(const char *dest) {
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -2500,12 +2498,11 @@ static int setup_kmsg(int kmsg_socket) {
|
||||
_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
|
||||
|
||||
@@ -81,13 +81,12 @@ int make_inaccessible_nodes(
|
||||
{ "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
|
||||
|
||||
@@ -765,7 +765,6 @@ static void test_rename_noreplace(void) {
|
||||
|
||||
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;
|
||||
|
||||
@@ -774,6 +773,8 @@ static void test_chmod_and_chown(void) {
|
||||
|
||||
log_info("/* %s */", __func__);
|
||||
|
||||
BLOCK_WITH_UMASK(0000);
|
||||
|
||||
assert_se(mkdtemp_malloc(NULL, &d) >= 0);
|
||||
|
||||
p = strjoina(d, "/reg");
|
||||
|
||||
Reference in New Issue
Block a user