From mboxrd@z Thu Jan 1 00:00:00 1970 From: Doug Goldstein Subject: Re: [PATCH 1/2] libxl: fix _SC_GETPW_R_SIZE_MAX usage Date: Tue, 12 Jan 2016 21:19:38 -0600 Message-ID: <5695C24A.80903@cardoe.com> References: <1452604467-65746-1-git-send-email-roger.pau@citrix.com> <1452604467-65746-2-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0103203379116361854==" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aJByQ-0000ib-CB for xen-devel@lists.xenproject.org; Wed, 13 Jan 2016 03:19:50 +0000 Received: by mail-yk0-f170.google.com with SMTP id x67so475937044ykd.2 for ; Tue, 12 Jan 2016 19:19:47 -0800 (PST) In-Reply-To: <1452604467-65746-2-git-send-email-roger.pau@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Roger Pau Monne , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --===============0103203379116361854== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="8KvsDWrLbNchCnn6eNhiRitnho1UKbxrV" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --8KvsDWrLbNchCnn6eNhiRitnho1UKbxrV Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 1/12/16 7:14 AM, Roger Pau Monne wrote: > According to the FreeBSD sysconf man page [0] if the variable is associ= ated > with functionality that is not supported, -1 is returned and errno is n= ot > modified. Modify libxl__dm_runas_helper so it's able to correctly > deal with this situation by setting the initial buffer value to 2048. >=20 > [0] https://www.freebsd.org/cgi/man.cgi?query=3Dsysconf >=20 > Signed-off-by: Roger Pau Monn=C3=A9 > --- > tools/libxl/libxl_dm.c | 7 +++++++ > 1 file changed, 7 insertions(+) >=20 > diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c > index 0aaefd9..ec8fb51 100644 > --- a/tools/libxl/libxl_dm.c > +++ b/tools/libxl/libxl_dm.c > @@ -728,7 +728,14 @@ static int libxl__dm_runas_helper(libxl__gc *gc, c= onst char *username) > long buf_size; > int ret; > =20 > + errno =3D 0; > buf_size =3D sysconf(_SC_GETPW_R_SIZE_MAX); > + if (buf_size < 0 && errno =3D=3D 0) { > + buf_size =3D 2048; > + LOG(DEBUG, > +"sysconf(_SC_GETPW_R_SIZE_MAX) is not supported, using a buffer size o= f %ld", > + buf_size); > + } > if (buf_size < 0) { > LOGE(ERROR, "sysconf(_SC_GETPW_R_SIZE_MAX) returned error %ld"= , > buf_size); >=20 So on Linux the behavior is somewhat similar [1]. But I took a peek at the libvirt code for doing the similar thing and I notice that they just default if the value is returned as less than 0 [2]. Reading both man pages it seems like that would be the better bet instead of failing how the current code is. Your fix probably makes it fail less but it could still error out senselessly. Just a suggestion for an improvement overall= =2E [1] http://man7.org/linux/man-pages/man3/sysconf.3.html#RETURN_VALUE [2] http://libvirt.org/git/?p=3Dlibvirt.git;a=3Dblob;f=3Dsrc/util/virutil.c;h= =3Dbb9604a0c1ffb9c99e454e84878a8c376f773046;hb=3DHEAD#l935 --=20 Doug Goldstein --8KvsDWrLbNchCnn6eNhiRitnho1UKbxrV Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0 iQJ8BAEBCgBmBQJWlcJNXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRBNTM5MEQ2RTNFMTkyNzlCNzVDMzIwOTVB MkJDMDNEQzg3RUQxQkQ0AAoJEKK8A9yH7RvUG6oP/0aSt2tNNhJOwf1vTk/ETlUa rtzDMzZHa/OE9eY2wJ5Yp5fy2HiiXr6QkCXTOGtDAGt05EHnIOo4qbSD5A8weCr3 X1hpfqfiXp4SqZ+ntDWDychnZRZBRc5SaydXLwgO31agKHwEbYwP39QLlGvAZvqY TSvqCVppLhf17fUyeDh7thohfx5GsDWwZ8TCihdq5btL4wHrZQi3R7XjdBqJPLlH /SBZn/KO9rzdK/3c4RDdrGvnzryl4bWsYmW/Z7hHOTPh4a6Ci76JPORJlFmcYOUe mYe3BfRdpgdNRwLu2h0uHv4kqQULvI7/Rgu+m84P2/gxj5WYbhOWSlyRNWKdp5sG 5Od5wCRS7CYI9A/kZ8NBmh1jnDrY2JVJ3yFS1w6iGe8zd1LzYwXeOAS3Mls8eLox 0C68o0GVTwgGetGqQBBJBejGx5bERQTVthAtssyqhbgJ5FVXoT21tf8EIuqZdqHZ HlrAaWGxXFBl/H/GOvS0URbVcgo5mSgxIqw2aJOSzxliX8R9fbiKqiUilVX13j8N 6gRCBXmYf3QlD7Gct6PeUM8fGNHkwbx1L1GUSPd8MblTpZxYfAW/cjnoP/6bnuZ8 z2SW6jdRTktFb5Gn4ChTCR2OYLn6Bt1gzvW5daBQmBvo1uQyo/H08vEjPYHE48AI ri6ghvrfhrIyURMac657 =Q19J -----END PGP SIGNATURE----- --8KvsDWrLbNchCnn6eNhiRitnho1UKbxrV-- --===============0103203379116361854== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============0103203379116361854==--