Subject: Re: passwd fails for users not in wheel group
To: Laine Stump <lainestump@rcn.com>
From: Andrew Brown <atatat@atatdot.net>
List: netbsd-help
Date: 03/20/2001 20:51:20
>> just curious...if passwd by itself doesn't work, what about trying
>> passwd with the username of the user for whom you want to change the
>> passwd?  eg, as user foo, do "passwd foo".
>
>Oh man! Now I feel *really* stupid! In spite of my answer to Berndt,
>after following Andrews suggestion and seeing that it worked, I
>realized that in the cases I was testing, I *was* su-ing to root, then
>su-ing back to the user I wanted to test; I just did it so
>automatically that it didn't even register in my brain. Duh!
>
>So, yeah, if I telnet directly in as that user, it works.
>
>Anyway, this makes me believe even more that the behavior Berndt
>describes is incorrect, and should be changed - at the very least it
>would have prevented me from chasing phantoms for the last two days...

it's because passwd does this:

	username = getlogin();
	if (username == NULL)
		errx(1, "who are you ??");
	
	switch(argc) {
	case 0:
		break;
	case 1:
		username = argv[0];
		break;
	default:
		usage();
		exit(1);
	}

and because logging in as foo, then su-ing to root, then su-ing to bar
does nothing to change the value of getlogin() which is set to foo in
all that time.

>Thanks for giving me the smack in the side of the head that I needed,
>guys!

np.  :)

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
andrew@crossbar.com       * "information is power -- share the wealth."