From nobody Fri Feb 04 22:44:54 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 47F8919B450E; Fri, 4 Feb 2022 22:44:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Jr9bC1Rzjz3v8s; Fri, 4 Feb 2022 22:44:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644014695; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ai5kYjkaEn2ybjQj5IBwCDYG9p0W89YWyK9D44KKV/I=; b=SCAhXBEaS07rh2Wyi1tmX/ZShHTyfKg09YvmuVnTZblClMAE5l9hnQZhlLtdrMU+wATnTE yHNW4dUhEqUW7ZLrJs0R/8lMc/p4O+2gNp0GXF/K+ZWcamjfuwkI0/7M5u3Y2ssCPqMNQC yAZ6BnK7uA5FCbSVemB8mB+PEzBkSD5pNlZHbXsXJwqPdRh03O1TKEv5lwYoL7J0pH0RTi vXk993sw2SC4bW/p+O3slQN1q5frPtnwMsOkloYR+mZxmMgXSX8Qv5jVtKjngrebgjO1op jKx0z9SEtgaRojYMG7lGWA7raVShjvc30tZ2OXaQH4p3OAWN0ZrLAYl4aO3G0Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1205A143A7; Fri, 4 Feb 2022 22:44:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 214MisBV019665; Fri, 4 Feb 2022 22:44:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 214Mis6p019664; Fri, 4 Feb 2022 22:44:54 GMT (envelope-from git) Date: Fri, 4 Feb 2022 22:44:54 GMT Message-Id: <202202042244.214Mis6p019664@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Stefan E=C3=9Fer?= Subject: git: c454c5716357 - main - whereis: fix fetching of user.cs_path sysctl variable List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c454c57163574ace86b49626b06637e93e05d5e6 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644014695; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ai5kYjkaEn2ybjQj5IBwCDYG9p0W89YWyK9D44KKV/I=; b=NRG31BXHA21ofmRzXh9XNNl/EJ2BS6X+7O0s/XPxW2DN5w4PINpRlY9+FBtsvNYiMo+2an qvDz4A6CJKF1ZDjr2fehUA7hf55nTnAB/9gSLvtdUXT2NWBA9g+lWNdcLNRA+uB9dUmD5Q 1dQE1zbvaRQfGXo8otSAhviECdHQpn+RE76ZJVlpeCcv3VPr9766NHxCa1u1AfzTcD4x45 B7k/rgNbS6rQH9ybauz/iSPnzN7SGhd5UVAtBcYltecfeq6O2BMdabBLoD7KleUs7Wlq4M 9KwyP8K0sKf9eRecVx04gLL0aEDFw1ZA3aUTNVt6vi2dnknynF8aXr5u1BD9/w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644014695; a=rsa-sha256; cv=none; b=l458AWFgadoMpWdn9V5QnYRgoHvL57j70RVaSI9gl7u2C8k3Zx8IAeJgnerLCijKgIWqpY Zb18Xi24Mw6m13nnJBTu5+YeMVGEC1EbqZwvLhcr8ZpDeX6Euy6tw1mYakXkmTQSC2qoga ZD4HMKOalrx4fTzAfIPBCTWZ34icSeFuyc3BKYV57LEJCmvBd1GJZGEhrw/71vmunXuBnY HFVgkc6s3tZsNUJPrizs+fRmSK9fM4ZFVfAa6F8DynUS/nCbdBx6JXSm9+ZxEwCK3NjYd1 sLwLyuQSCzK0n7yIiTzpQwMXzmMC+gTznGNOgfhfuoVgMUm6Xk9tO8GScg49fg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=c454c57163574ace86b49626b06637e93e05d5e6 commit c454c57163574ace86b49626b06637e93e05d5e6 Author: Stefan Eßer AuthorDate: 2022-02-04 22:37:12 +0000 Commit: Stefan Eßer CommitDate: 2022-02-04 22:44:34 +0000 whereis: fix fetching of user.cs_path sysctl variable The current implementation of sysctlbyname() does not support the user sub-tree. This function exits with a return value of 0, but sets the passed string buffer to an empty string. As a result, the whereis program did not use the value of the sysctl variable "user.cs_path", but only the value of the environment variable "PATH". This update makes whereis use the sysctl function with a fixed OID, which already supports the user sub-tree. MFC after: 3 days --- usr.bin/whereis/whereis.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/usr.bin/whereis/whereis.c b/usr.bin/whereis/whereis.c index 48426d376181..abf94b7860e2 100644 --- a/usr.bin/whereis/whereis.c +++ b/usr.bin/whereis/whereis.c @@ -261,6 +261,7 @@ defaults(void) DIR *dir; struct stat sb; struct dirent *dirp; + const int oid[2] = {CTL_USER, USER_CS_PATH}; /* default to -bms if none has been specified */ if (!opt_b && !opt_m && !opt_s) @@ -269,13 +270,12 @@ defaults(void) /* -b defaults to default path + /usr/libexec + * user's path */ if (!bindirs) { - if (sysctlbyname("user.cs_path", (void *)NULL, &s, - (void *)NULL, 0) == -1) - err(EX_OSERR, "sysctlbyname(\"user.cs_path\")"); + if (sysctl(oid, 2, NULL, &s, NULL, 0) == -1) + err(EX_OSERR, "sysctl(\"user.cs_path\")"); if ((b = malloc(s + 1)) == NULL) abort(); - if (sysctlbyname("user.cs_path", b, &s, (void *)NULL, 0) == -1) - err(EX_OSERR, "sysctlbyname(\"user.cs_path\")"); + if (sysctl(oid, 2, b, &s, NULL, 0) == -1) + err(EX_OSERR, "sysctl(\"user.cs_path\")"); nele = 0; decolonify(b, &bindirs, &nele); bindirs = realloc(bindirs, (nele + 2) * sizeof(char *));