Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Nov 2020 12:12:05 -0600
From:      "Brandon Bergren" <bdragon@FreeBSD.org>
To:        "Scott Long" <scottl@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   =?UTF-8?Q?Re:_svn_commit:_r367687_-_in_head:_sbin/nvmecontrol_usr.sbin/m?= =?UTF-8?Q?ailwrapper_usr.sbin/pkg?=
Message-ID:  <f70eeaa9-1aa4-4fcf-a958-2c780fe9555d@www.fastmail.com>
In-Reply-To: <202011141801.0AEI1FCM000287@repo.freebsd.org>
References:  <202011141801.0AEI1FCM000287@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> --- head/usr.sbin/pkg/pkg.c	Sat Nov 14 17:57:50 2020	(r367686)
> +++ head/usr.sbin/pkg/pkg.c	Sat Nov 14 18:01:14 2020	(r367687)
> @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
>  #include <errno.h>
>  #include <fcntl.h>
>  #include <fetch.h>
> +#include <libutil.h>
>  #include <paths.h>
>  #include <stdbool.h>
>  #include <stdlib.h>
> @@ -1037,6 +1038,7 @@ main(int argc, char *argv[])
>  {
>  	char pkgpath[MAXPATHLEN];
>  	const char *pkgarg;
> +	size_t len;
>  	int i;
>  	bool bootstrap_only, force, yes;
>  
> @@ -1045,8 +1047,11 @@ main(int argc, char *argv[])
>  	pkgarg = NULL;
>  	yes = false;
>  
> -	snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg",
> -	    getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE);
> +	if ((len = getlocalbase(pkgpath, MAXPATHLEN)) != 0) {
> +		fprintf(stderr, "Cannot determine local path\n");
> +		exit(EXIT_FAILURE);
> +	}

This logic is broken, it is failing on kernels that DO have user.localbase.

> +	strlcat(pkgpath, "/sbin/pkg", MAXPATHLEN - len);
>  
>  	if (argc > 1 && strcmp(argv[1], "bootstrap") == 0) {
>  		bootstrap_only = true;
>

-- 
  Brandon Bergren
  bdragon@FreeBSD.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?f70eeaa9-1aa4-4fcf-a958-2c780fe9555d>