From 1884ea22a90d225950d81c804f1771b42ae55f54 Mon Sep 17 00:00:00 2001 From: smitsohu Date: Wed, 8 Jun 2022 15:42:35 +0200 Subject: CVE-2022-31214: fixing the fix, one more time the previous commit "CVE-2022-31214: fixing the fix" made private-etc=fonts,fonts and similar commands fail with an error fix that regression by tolerating already existing directories --- src/firejail/fs_etc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/firejail/fs_etc.c b/src/firejail/fs_etc.c index e87d3b726..77fa00d6b 100644 --- a/src/firejail/fs_etc.c +++ b/src/firejail/fs_etc.c @@ -104,7 +104,10 @@ static void build_dirs(char *src, char *dst, size_t src_prefix_len, size_t dst_p *q = '\0'; *r = '/'; r = q; - mkdir_attr(dst, s.st_mode, 0, 0); + if (mkdir(dst, 0700) != 0 && errno != EEXIST) + errExit("mkdir"); + if (chmod(dst, s.st_mode) != 0) + errExit("chmod"); } if (!last) { // If we're not at the final terminating null, restore -- cgit v1.2.3-70-g09d2