From owner-svn-src-all@freebsd.org Sun Nov 15 19:34:16 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 93A5346656E; Sun, 15 Nov 2020 19:34:16 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CZ2T42cQlz3Lwq; Sun, 15 Nov 2020 19:34:16 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 9E0F2B18; Sun, 15 Nov 2020 14:34:14 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 15 Nov 2020 14:34:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsco.org; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm1; bh=v 2ZRpgfQPzO+P9OX4TNAsGHvCpvlWQArS5bESUFtnqg=; b=uiwirdxS56MPCGi4l cEANtY4zW5VKW9XK7iPP4ciaqGXlQvBUdsRLSnfS/uxkWlKv+n/Y1Pmv7UimCvXE fV4rQ0iya5WARxVMLEu1L0zvdXi5J2MKXk22XEEFbyp6iaHuXKQjKbjLfOniLvhy RQ0adf7ywyJsl6qjoX4l+hpVyTpwWPD9CeO8zoGebnOXplqQApnVg0ka8JtMJYS9 qHW9qUMDsr3grxeTKQDjphSWGEozTcWtXJk8q6cNgws333YJVRmW8coQRKFr2GOS hXFIUw3nwYGjACOQIAW4X64oSSKk9HNiwLGxihVMXB4ifexG7yQubTikTM/+3Je2 JDZbw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=v2ZRpgfQPzO+P9OX4TNAsGHvCpvlWQArS5bESUFtn qg=; b=gCIbDhaKEPlfxdLB95VH6LT9RnlhX7uCkgjzfWuBkp44SeNZXyRzJ524p qwlSoJ2G2iRP+7GHctv/Ioq3jXk9JdISIfbYmMkw9xZOCfciJLz4otfTAwtsoJim gZd5eP2J3H1kA71X7V0uo86cufFftrfiIaiw3NxNqn8bKvCjfvNs2aULw6zMeJZh JlINObO3aOAXeA045dYDLqCikAFzrd2+HAJHQQ+HY7I6z8WxQr8Yu1bp1i+/L6jw c9Yc3eQupsFiL9oe4SnPHDwoEPp+GVXOJ6eZE7ODJBLMTxtIyjOSRnUAuQ30Uukj IG7roonf4POe2Nxf3/wRpbrwFQlnQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvledgudeftdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecuufhorhhtvgguuchrvggtihhpshculdegtddmne cujfgurheptggguffhjgffgffkfhfvofesthhqmhdthhdtjeenucfhrhhomhepufgtohht thcunfhonhhguceoshgtohhtthhlsehsrghmshgtohdrohhrgheqnecuggftrfgrthhtvg hrnhepudduveekheehiedukeekleelvedufeevfeetudfgtdffteffleehheffueffgfeh necuffhomhgrihhnpehfrhgvvggsshgurdhorhhgnecukfhppeekrdegiedrkeelrddvud efnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshgt ohhtthhlsehsrghmshgtohdrohhrgh X-ME-Proxy: Received: from [192.168.0.114] (unknown [8.46.89.213]) by mail.messagingengine.com (Postfix) with ESMTPA id 9C0ED3280060; Sun, 15 Nov 2020 14:34:13 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: svn commit: r367701 - head/lib/libutil From: Scott Long In-Reply-To: Date: Sun, 15 Nov 2020 12:34:13 -0700 Cc: Jessica Clarke , Scott Long , src-committers , svn-src-all , svn-src-head Content-Transfer-Encoding: quoted-printable Message-Id: References: <202011150748.0AF7mqW3016900@repo.freebsd.org> <329C4753-BB97-4C67-8CDA-39EB67E16CE8@freebsd.org> <44B80F15-2BE7-4B7C-BC3D-B65511480E58@freebsd.org> To: Brandon Bergren X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Rspamd-Queue-Id: 4CZ2T42cQlz3Lwq X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Nov 2020 19:34:16 -0000 It is a magical namespace, in that it comes from libc, not from the = kernel. Please make sure that you=E2=80=99ve installed a more recent = libc, I guess? I just did a full build and install, and I=E2=80=99m = unable to replicate the problem. Maybe there=E2=80=99s a static-linked = pkg running around somewhere? I=E2=80=99m at a loss for better ideas. Scott > On Nov 15, 2020, at 12:30 PM, Brandon Bergren = 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,0xfffffbfffda98,0x810809000,14) =3D 0 = (0x0) > __sysctl("sysctl.oidfmt = user.localbase",4,0xfffffbfffdef8,0xfffffbfffd690,0x0,0) =3D 0 (0x0) > __sysctl("sysctl.name { 8.21 = }",4,0xfffffbfffc8f8,0xfffffbfffc480,0x0,0) =3D 0 (0x0) > __sysctl("sysctl.oidfmt = user.localbase",4,0xfffffbfffd0f8,0xfffffbfffc488,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,0x0,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 = wrote: >>>=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 |-c |-r ] [-C ] [-R ] [-o = var=3Dvalue] [-4|-6] [] >>>=20 >>> For more information on available commands and options see 'pkg = help'. >>> 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 = wrote: >>>>>>=20 >>>>>> I felt similar concerns, but my misunderstanding of strlcpy() = drove the >>>>>> result. Since the use case for getlocalbase() lends itself to = also use >>>>>> strlcat()/strlcpy(), I was trying to replicate the API semantics = of those, >>>>>> at least to the limit of my understanding. Thanks for the = feedback, I=E2=80=99ll >>>>>> look at it some more. >>>>>=20 >>>>> Thanks. ENOMEM also feels inappropriate as no allocation is taking >>>>> place. Perhaps ENAMETOOLONG, which is used in similar cases for = things >>>>> like gethostbyname? Though sysctlbyname uses ENOMEM instead... = sigh. >>>>>=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 = (giving >>>>> 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