From: Ian Campbell <ian.campbell@citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: xen-devel@lists.xensource.com, Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH v7] run QEMU as non-root
Date: Wed, 30 Sep 2015 09:28:04 +0100 [thread overview]
Message-ID: <1443601684.16718.146.camel@citrix.com> (raw)
In-Reply-To: <22026.50541.73223.810233@mariner.uk.xensource.com>
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@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2015-09-30 8:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-23 17:08 [PATCH v7] run QEMU as non-root Stefano Stabellini
2015-07-27 13:19 ` Fabio Fantoni
2015-08-07 15:36 ` Wei Liu
2015-08-07 15:26 ` Wei Liu
2015-09-29 16:43 ` Stefano Stabellini
2015-09-29 17:07 ` Ian Jackson
2015-09-30 8:28 ` Ian Campbell [this message]
2015-09-30 15:43 ` Stefano Stabellini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443601684.16718.146.camel@citrix.com \
--to=ian.campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.