"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Mark Jamsek <mark@jamsek.com>
Subject:
Re: tweak gotd getpwnam err message
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Thu, 29 Dec 2022 20:47:56 +1100

Download raw body.

Thread
On 22-12-29 10:24AM, Omar Polo wrote:
> first, use fatalx instead of fatal.  The ERRORS section of getpwnam(3)
> doesn't give the idea errno is set to something useful.
> 
> Second, there's a typo (it's getpwnam(3), not getpwuid(3)) but while
> here i've simplified the message.
> 
> ok?

minor suggestion inline but ok either way

> diff /home/op/w/got
> commit - 9bd4acdbfe311b4b5045d0166f795ddbb5c27cbc
> path + /home/op/w/got
> blob - 97731f1e9b245bfea3cec151f3d56b6c81205390
> file + gotd/gotd.c
> --- gotd/gotd.c
> +++ gotd/gotd.c
> @@ -2160,7 +2160,7 @@ main(int argc, char **argv)
>  
>  	pw = getpwnam(gotd.user_name);
>  	if (pw == NULL)
> -		fatal("getpwuid: user %s not found", gotd.user_name);
> +		fatalx("user %s not found", gotd.user_name);

should we quote <user> like we do elsewhere?

		fatalx("user '%s' not found", gotd.user_name);

>  
>  	if (pw->pw_uid == 0) {
>  		fatalx("cannot run %s as %s: the user running %s "
> 

-- 
Mark Jamsek <fnc.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68