Date: Sun, 15 Nov 2020 13:36:01 -0600 From: "Brandon Bergren" <bdragon@FreeBSD.org> To: "Scott Long" <scottl@samsco.org> Cc: "Jessica Clarke" <jrtc27@freebsd.org>, "Scott Long" <scottl@FreeBSD.org>, src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>, svn-src-head <svn-src-head@freebsd.org> Subject: Re: svn commit: r367701 - head/lib/libutil Message-ID: <76667692-13ef-4522-ab23-240a1f6d57f3@www.fastmail.com> In-Reply-To: <A572CEDC-5869-4BAF-95D1-6B9AC50C0ED6@samsco.org> References: <202011150748.0AF7mqW3016900@repo.freebsd.org> <D5492BB4-A282-4E35-B02F-1216769FDA51@freebsd.org> <A39C12CC-D3D6-4166-9089-7466FA1C2B2D@samsco.org> <329C4753-BB97-4C67-8CDA-39EB67E16CE8@freebsd.org> <EBD050A5-70AE-43E8-A9E1-CCD3BCA11180@samsco.org> <f9904238-3923-40c1-b478-c5249821ed09@www.fastmail.com> <44B80F15-2BE7-4B7C-BC3D-B65511480E58@freebsd.org> <a54c3d86-8499-4c2b-a83f-9db79a12e3ec@www.fastmail.com> <A572CEDC-5869-4BAF-95D1-6B9AC50C0ED6@samsco.org>
next in thread | previous in thread | raw e-mail | index | archive | help
That would explain why I see what I see -- I did not install an updated = libc yet. On Sun, Nov 15, 2020, at 1:34 PM, Scott Long wrote: > It is a magical namespace, in that it comes from libc, not from the=20= > kernel. Please make sure that you=E2=80=99ve installed a more recent = libc, I=20 > guess? I just did a full build and install, and I=E2=80=99m unable to= =20 > replicate the problem. Maybe there=E2=80=99s a static-linked pkg runn= ing=20 > around somewhere? I=E2=80=99m at a loss for better ideas. >=20 > Scott >=20 >=20 > > On Nov 15, 2020, at 12:30 PM, Brandon Bergren <bdragon@FreeBSD.org> = wrote: > >=20 > > I think the problem is that user.* is somehow magically namespaced, = so doing a "dumb" sysctlbyname will get the wrong one. > >=20 > > sysctl (the tool) does: > > __sysctl("sysctl.name2oid user.localbase",2,0xfffffbfffde98,0xfffffb= fffda98,0x810809000,14) =3D 0 (0x0) > > __sysctl("sysctl.oidfmt user.localbase",4,0xfffffbfffdef8,0xfffffbff= fd690,0x0,0) =3D 0 (0x0) > > __sysctl("sysctl.name { 8.21 }",4,0xfffffbfffc8f8,0xfffffbfffc480,0x= 0,0) =3D 0 (0x0) > > __sysctl("sysctl.oidfmt user.localbase",4,0xfffffbfffd0f8,0xfffffbff= fc488,0x0,0) =3D 0 (0x0) > > __sysctl("user.localbase",2,0x0,0xfffffbfffc480,0x0,0) =3D 0 (0x0) > > __sysctl("user.localbase",2,0x81080a000,0xfffffbfffd0f8,0x0,0) =3D 0= (0x0) > >=20 > > and picks up /usr/local. > >=20 > > whereas libutil is currently just doing > > __sysctlbyname("user.localbase",14,0xfffffbfffd4f8,0xfffffbfffd440,0= x0,0) =3D 0 (0x0) > >=20 > > which is returning the builtin "" from the static kernel variable. > >=20 > > On Sun, Nov 15, 2020, at 1:26 PM, Jessica Clarke wrote: > >> On 15 Nov 2020, at 19:10, Brandon Bergren <bdragon@FreeBSD.org> wro= te: > >>>=20 > >>> On powerpc64 and powerpc64le, there is some really weird behavior = happening around the sysctl itself: > >>>=20 > >>> root@crow:~ # pkg > >>> The package management tool is not yet installed on your system. > >>> Do you want to fetch and install it now? [y/N]: N > >>> root@crow:~ # sysctl user.localbase > >>> user.localbase: /usr/local > >>> root@crow:~ # pkg > >>> The package management tool is not yet installed on your system. > >>> Do you want to fetch and install it now? [y/N]: N > >>> root@crow:~ # sysctl user.localbase=3D/usr/local > >>> user.localbase: /usr/local -> /usr/local > >>> root@crow:~ # pkg > >>> pkg: not enough arguments > >>> Usage: pkg [-v] [-d] [-l] [-N] [-j <jail name or id>|-c <chroot pa= th>|-r <rootdir>] [-C <configuration file>] [-R <repo config dir>] [-o v= ar=3Dvalue] [-4|-6] <command> [<args>] > >>>=20 > >>> For more information on available commands and options see 'pkg he= lp'. > >>> root@crow:~ #=20 > >>>=20 > >>>=20 > >>> I would double check very closely that the sysctl is being called = correctly, the sysctl tool manages to read it out, but libutil does not.= > >>=20 > >> That's odd. What does truss say? > >>=20 > >> Jess > >>=20 > >>> On Sun, Nov 15, 2020, at 1:06 PM, Scott Long wrote: > >>>>=20 > >>>>> On Nov 15, 2020, at 12:01 PM, Jessica Clarke <jrtc27@freebsd.org= > wrote: > >>>>>>=20 > >>>>>> I felt similar concerns, but my misunderstanding of strlcpy() d= rove the > >>>>>> result. Since the use case for getlocalbase() lends itself to = also use > >>>>>> strlcat()/strlcpy(), I was trying to replicate the API semantic= s of those, > >>>>>> at least to the limit of my understanding. Thanks for the feed= back, I=E2=80=99ll > >>>>>> look at it some more. > >>>>>=20 > >>>>> Thanks. ENOMEM also feels inappropriate as no allocation is taki= ng > >>>>> place. Perhaps ENAMETOOLONG, which is used in similar cases for = things > >>>>> like gethostbyname? Though sysctlbyname uses ENOMEM instead... s= igh. > >>>>>=20 > >>>>=20 > >>>> Yep, I wasn=E2=80=99t happy with ENOMEM either but I couldn=E2=80= =99t find anything better. > >>>>=20 > >>>>> Also, if pathlen has already been checked against SSIZE_MAX (giv= ing > >>>>> EINVAL) and tmplen against pathlen there's no need to then check= tmplen > >>>>> against SSIZE_MAX. > >>>>>=20 > >>>>=20 > >>>> Done. > >>>>=20 > >>>>> I'd be happy to give a review on Phabricator if/when you have a = new > >>>>> patch. > >>>>>=20 > >>>>=20 > >>>> https://reviews.freebsd.org/D27227 > >>>>=20 > >>>> Thanks, > >>>> Scott > >>>>=20 > >>>>=20 > >>>=20 > >>> --=20 > >>> Brandon Bergren > >>> bdragon@FreeBSD.org > >>=20 > >>=20 > >=20 > > --=20 > > Brandon Bergren > > bdragon@FreeBSD.org >=20 > --=20 Brandon Bergren bdragon@FreeBSD.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?76667692-13ef-4522-ab23-240a1f6d57f3>