useradd: assume uid 0 == root as fallback
In absence of /etc/passwd, eg when bootstrapping a chroot, resolving uid 0 to a name may not work. Therefore just assume "root".
This commit is contained in:
parent
dce030ffb8
commit
d12d300c98
@ -2507,14 +2507,14 @@ int main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
struct passwd *pampw;
|
struct passwd *pampw;
|
||||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||||
if (pampw == NULL) {
|
if (pampw == NULL && getuid ()) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: Cannot determine your user name.\n"),
|
_("%s: Cannot determine your user name.\n"),
|
||||||
Prog);
|
Prog);
|
||||||
fail_exit (1);
|
fail_exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = pam_start ("useradd", pampw->pw_name, &conv, &pamh);
|
retval = pam_start ("useradd", pampw?pampw->pw_name:"root", &conv, &pamh);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PAM_SUCCESS == retval) {
|
if (PAM_SUCCESS == retval) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user