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

Re: [Xen-devel] [PATCH v7] run QEMU as non-root



On Tue, 2015-09-29 at 18:07 +0100, Ian Jackson wrote:
> Stefano Stabellini writes ("Re: [PATCH v7] run QEMU as non-root"):
> > On Fri, 7 Aug 2015, Wei Liu wrote:
> > > Please use for / while to loop.
> > 
> > The goto retry loop is a very common patter for error handling, but I
> > can turn it into a loop if you are keen on it.
> 
> I'm afraid I agree with Wei here.
> 
> > > Also you might want to save and restore errno.
> > 
> > Across the getpwnam_r call? Or across the loop? Or across the function
> > libxl__dm_runas_helper?
> 
> I don't understand either.  Also I don't understand why you set errno
> to 0.

getpwnam(7) says:

RETURN VALUE
       The getpwnam() and getpwuid() functions return a pointer to a
       passwd structure, or NULL if the matching entry is not  found
       or  an error occurs.  If an error occurs, errno is set approâ
       priately.  If one wants to check errno  after  the  call,  it
       should be set to zero before the call.

But this code is using the _r variants, on which the manpage later says:

       On  success,  getpwnam_r()  and getpwuid_r() return zero, and
       set *result to pwd.   If  no  matching  password  record  was
       found,  these  functions  return 0 and store NULL in *result.
       In case of error, an error number is returned,  and  NULL  is
       stored in *result.

So I guess the errno is either a leftover from not using _r in an earlier
version or from applying the first para above to the wrong functions.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.