On Fri, 2021-03-12 at 15:38 +0100, Michal Privoznik wrote:
> On 3/12/21 11:51 AM, Andrea Bolognani wrote:
> > On Mon, 2021-03-01 at 12:49 +0100, Michal Privoznik wrote:
> > > @@ -213,11 +213,16 @@ int main(int argc, char **argv)
> > > }
> > > tmproot = true;
> > >
> > > - if (chmod(root, 0755) < 0) {
> > > - g_printerr("%s: cannot chown temporary dir: %s\n",
> > > - argv[0], g_strerror(errno));
> > > - goto cleanup;
> > > - }
> > > + } else if (g_mkdir_with_parents(root, 0755) < 0) {
> > > + g_printerr("%s: cannot create dir: %s\n",
> > > + argv[0], g_strerror(errno));
> > > + goto cleanup;
> > > + }
> > > +
> > > + if (chmod(root, 0755) < 0) {
> > > + g_printerr("%s: cannot chmod temporary dir: %s\n",
> > > + argv[0], g_strerror(errno));
> > > + goto cleanup;
> > > }
> >
> > Wouldn't it make sense to leave the chmod() bit where it was?
> > g_mkdir_with_parents() already accepts the mode as a parameter, so
> > calling chmod() again seems unnecessary.
>
> Well, if the dir exists but doesn't have right perms then
> g_mkdir_with_parents() does nothing and we need that explicit chmod().
Fair point, I hadn't considered that :)
--
Andrea Bolognani / Red Hat / Virtualization