Message ID | 20221212174349.714152-1-lautrbach@redhat.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 7ff1d7f1c2a1 |
Headers | show |
Series | sepolicy: Call os.makedirs() with exist_ok=True | expand |
On Mon, Dec 12, 2022 at 12:49 PM Petr Lautrbach <lautrbach@redhat.com> wrote: > > 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/' > > Signed-off-by: Petr Lautrbach <lautrbach@redhat.com> Acked-by: James Carter <jwcart2@gmail.com> > --- > python/sepolicy/sepolicy/manpage.py | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/python/sepolicy/sepolicy/manpage.py b/python/sepolicy/sepolicy/manpage.py > index edeb3b77e759..1bff8f9acb49 100755 > --- a/python/sepolicy/sepolicy/manpage.py > +++ b/python/sepolicy/sepolicy/manpage.py > @@ -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 >
On Fri, Dec 16, 2022 at 4:24 PM James Carter <jwcart2@gmail.com> wrote: > > On Mon, Dec 12, 2022 at 12:49 PM Petr Lautrbach <lautrbach@redhat.com> wrote: > > > > 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/' > > > > Signed-off-by: Petr Lautrbach <lautrbach@redhat.com> > > Acked-by: James Carter <jwcart2@gmail.com> Merged. Thanks, Jim > > > --- > > python/sepolicy/sepolicy/manpage.py | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/python/sepolicy/sepolicy/manpage.py b/python/sepolicy/sepolicy/manpage.py > > index edeb3b77e759..1bff8f9acb49 100755 > > --- a/python/sepolicy/sepolicy/manpage.py > > +++ b/python/sepolicy/sepolicy/manpage.py > > @@ -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 > >
diff --git a/python/sepolicy/sepolicy/manpage.py b/python/sepolicy/sepolicy/manpage.py index edeb3b77e759..1bff8f9acb49 100755 --- a/python/sepolicy/sepolicy/manpage.py +++ b/python/sepolicy/sepolicy/manpage.py @@ -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
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/' Signed-off-by: Petr Lautrbach <lautrbach@redhat.com> --- python/sepolicy/sepolicy/manpage.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)