Re: svn commit: r367687 - in head: sbin/nvmecontrol usr.sbin/mailwrapper usr.sbin/pkg

Brandon Bergren bdragon at FreeBSD.org
Sun Nov 15 18:12:34 UTC 2020


> --- 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 at FreeBSD.org


More information about the svn-src-all mailing list