Subject: Re: getpwent(3) funcs return static structure
To: None <current-users@NetBSD.ORG>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: current-users
Date: 04/03/1997 07:48:54
>>>> It would be nice to be able to have multiple superuser accounts
>>>> without the system getting confused.

> What is the problematic program?

In my experience, the major problems are rlogin/rsh/rcp, which have to
be taught to use something smarter than getpwuid(getuid()), and ssh,
which in its current implementation is damn near unfixable.

For the r* utilities, what I have normally done is something like

	user = getenv("USER")
	if user!=0 and (pw=getpwnam(user))!=0
		if getuid()==0 or getuid()==pw->pw_uid
			use pw
	pw = getpwnam(getuid())
		if pw!=0
			use pw
	give "who are you" error and die

One could argue it should also call getlogin(), but the only cases
where getlogin() will succeed and getenv("USER") fail are when
something is severely broken or someone is trying to get fancy with the
code; in neither case do I consider it a major problem for the code to
fall back to getpwuid(getuid()) instead.

For ssh, to date I've just given up and had all the root logins share a
single .ssh directory.  Someday I will rewrite enough of ssh to fix
this bug.  (The ssh people don't seem to think it's a bug, growl.)

					der Mouse

		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B