[BusyBox] can't add root user: passwd: unknown uid 0
Rob Landley
rob at landley.net
Fri Jul 29 06:34:39 UTC 2005
On Friday 29 July 2005 00:18, michael at michaelshiloh.com wrote:
> (Repost. I asked this question yesterday and have had no replies.
> If I have broken some rule please let me know how so that I can
> mend my ways.)
>
> Hi.
>
> I have busybox version 1.0. Shell seems OK and all the stuff I've played
> with seems to work, except for the users and groups:
>
> # rm /etc/passwd /etc/shadow /etc/group
> # rmdir /root
> # touch /etc/passwd /etc/shadow /etc/group
> # adduser -h /root root
> passwd: unknown uid 0
>
> Any tips?
Hmmm... Apparently it's calling passwd before adding the user to the list,
and passwd is (rightly) complaining that the current user isn't
in /etc/passwd.
The code snippet that's barfing is this, from loginutils/passwd.c:
pw = getpwnam(name);
if (!pw) {
bb_error_msg_and_die("Unknown user %s\n", name);
}
if (!amroot && pw->pw_uid != getuid()) {
syslog(LOG_WARNING, "can't change pwd for `%s'", name);
bb_error_msg_and_die("Permission denied.\n");
}
The question is, how is adduser.c shelling out to passwd except at the _end_
of execution? (Is it actually adding the user to the list, and just failing
to set the password? Does addpass -D make a difference? Can you confirm
that you're using the busybox version of addpass and not some other version
calling busybox's passwd?)
Rob
P.S. Why is if_i_am_not_root() _not_ just an #*%&#* inline test? It's an if
statement and an error message used from exactly one place, this does not
deserve a function...
More information about the busybox
mailing list