Subject: Re: A small problem with passwd
To: None <simmons%darykon@nwnexus.wa.com>
From: Kenneth Stailey <kstailey@leidecker.gsfc.nasa.gov>
List: netbsd-help
Date: 03/23/1995 11:12:18
> False alarm. What I didn't mention, because I thought it was
> unimportant, was that I was running passwd after having su'd to one
> of the user login-names. Apparently passwd doesn't like you to do
> this. If I rlogin to the user account, passwd works fine.
>
> Can someone explain to this novice why this is true?
from passwd.c:
username = getlogin();
.
.
.
exit(local_passwd(username));
from local_passwd.c:
local_passwd(uname)
char *uname;
{
.
.
pw = getpwnam(uname)
.
.
uid = getuid();
+> if (uid && uid != pw->pw_uid) {
| (void)fprintf(stderr, "passwd: %s\n", strerror(EACCES));
| return(1);
| }
|
| pw->pw_uid ultimately comes from looking up your account in the
| utmp file via getlogin(). So if you log in as root, su to fred
| with a uid of 100, then the if statement evalutates into:
|
+> if (100 && 100 != 0) {
(void)fprintf(stderr, "passwd: you're shitting me\n");
return(1);
}