Re: [PATCH 4/4] qemu_shim: Always pre-create root dir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux