sepolicy: Call os.makedirs() with exist_ok=True
PATCH 1/1 sepolicy: Call os.makedirs() with exist_ok=True
Since commit 7494bb1298b3 ("sepolicy: generate man pages in parallel") man pages are generated in parallel and there's a race between os.path.exists() and os.makedirs().
The check os.path.exists() is not necessary when os.makedirs() is called with exist_ok=True.
Fixes:/usr/bin/sepolicy manpage -a -p /__w/usr/share/man/man8/ -w -r /__w/
FileExistsError: [Errno 17] File exists: '/__w/usr/share/man/man8/'
--- python/sepolicy/sepolicy/manpage.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
python/sepolicy/sepolicy/manpage.py +1 -2
@@ -376,8 +376,7 @@ class ManPage: self.fcdict = sepolicy.get_fcdict(self.fcpath) - if not os.path.exists(path): - os.makedirs(path) + os.makedirs(path, exist_ok=True) self.path = path
Signature · 1 line
2.38.1
Quoted 5 lines · Petr Lautrbach
Since commit
7494bb1298b3("sepolicy: generate man pages in parallel") man pages are generated in parallel and there's a race betweenos.path.exists()andos.makedirs().
Quoted 8 lines
The check
os.path.exists()is not necessary whenos.makedirs()is called with exist_ok=True.Fixes:
/usr/bin/sepolicymanpage -a -p /__w/usr/share/man/man8/ -w -r /__w/
FileExistsError: [Errno 17] File exists: '/__w/usr/share/man/man8/'Signed-off-by Petr Lautrbach <[email protected]>
Quoted 21 lines
--- python/sepolicy/sepolicy/manpage.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)python/sepolicy/sepolicy/manpage.py +1
-3@@ -376,8 +376,7 @@ class ManPage: self.fcdict = sepolicy.get_fcdict(self.fcpath) - if not os.path.exists(path): - os.makedirs(path) + os.makedirs(path, exist_ok=True) self.path = path --2.38.1
Quoted 10 lines · James Carter
Quoted 8 lines · Petr Lautrbach
Since commit
7494bb1298b3("sepolicy: generate man pages in parallel") man pages are generated in parallel and there's a race betweenos.path.exists()andos.makedirs().The check
os.path.exists()is not necessary whenos.makedirs()is called with exist_ok=True.
Quoted 7 lines
Quoted 5 lines
Fixes:
/usr/bin/sepolicymanpage -a -p /__w/usr/share/man/man8/ -w -r /__w/
FileExistsError: [Errno 17] File exists: '/__w/usr/share/man/man8/'Signed-off-by Petr Lautrbach <[email protected]>Acked-by James Carter <[email protected]>
Merged.
Thanks,
Jim
Quoted 22 lines
Quoted 22 lines
--- python/sepolicy/sepolicy/manpage.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)python/sepolicy/sepolicy/manpage.py +1
-3@@ -376,8 +376,7 @@ class ManPage: self.fcdict = sepolicy.get_fcdict(self.fcpath) - if not os.path.exists(path): - os.makedirs(path) + os.makedirs(path, exist_ok=True) self.path = path --2.38.1