Additional PAM cleanup:
* src/userdel.c, src/newusers.c, src/chpasswd.c, src/chfn.c, src/groupmems.c, src/usermod.c, src/groupdel.c, src/chgpasswd.c, src/useradd.c, src/groupmod.c, src/groupadd.c, src/chage.c, src/chsh.c: If the username cannot be determined, report it as such (not a PAM authentication failure).
This commit is contained in:
parent
49f0d8b680
commit
bab84a13ff
@ -56,7 +56,8 @@
|
||||
src/useradd.c, src/groupmod.c, src/groupadd.c, src/chage.c,
|
||||
src/chsh.c: Simplify the PAM error handling. Do not keep the pamh
|
||||
handle, but terminate the PAM transaction as soon as possible if
|
||||
there are no PAM session opened.
|
||||
there are no PAM session opened. If the username cannot be
|
||||
determined, report it as such (not a PAM authentication failure).
|
||||
* src/useradd.c, src/userdel.c, src/usermod.c: It is no more
|
||||
needed to initialize retval to PAM_SUCCESS.
|
||||
|
||||
|
@ -509,11 +509,14 @@ static void check_perms (void)
|
||||
#ifdef USE_PAM
|
||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||
if (NULL == pampw) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
} else {
|
||||
retval = pam_start ("chage", pampw->pw_name, &conv, &pamh);
|
||||
fprintf (stderr,
|
||||
_("%s: Cannot determine your user name.\n"),
|
||||
Prog);
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
|
||||
retval = pam_start ("chage", pampw->pw_name, &conv, &pamh);
|
||||
|
||||
if (PAM_SUCCESS == retval) {
|
||||
retval = pam_authenticate (pamh, 0);
|
||||
}
|
||||
|
@ -377,11 +377,14 @@ static void check_perms (const struct passwd *pw)
|
||||
#else /* !USE_PAM */
|
||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||
if (NULL == pampw) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
} else {
|
||||
retval = pam_start ("chfn", pampw->pw_name, &conv, &pamh);
|
||||
fprintf (stderr,
|
||||
_("%s: Cannot determine your user name.\n"),
|
||||
Prog);
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
|
||||
retval = pam_start ("chfn", pampw->pw_name, &conv, &pamh);
|
||||
|
||||
if (PAM_SUCCESS == retval) {
|
||||
retval = pam_authenticate (pamh, 0);
|
||||
}
|
||||
|
@ -256,11 +256,14 @@ static void check_perms (void)
|
||||
|
||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||
if (NULL == pampw) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
} else {
|
||||
retval = pam_start ("chgpasswd", pampw->pw_name, &conv, &pamh);
|
||||
fprintf (stderr,
|
||||
_("%s: Cannot determine your user name.\n"),
|
||||
Prog);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
retval = pam_start ("chgpasswd", pampw->pw_name, &conv, &pamh);
|
||||
|
||||
if (PAM_SUCCESS == retval) {
|
||||
retval = pam_authenticate (pamh, 0);
|
||||
}
|
||||
|
@ -250,11 +250,14 @@ static void check_perms (void)
|
||||
|
||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||
if (NULL == pampw) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
} else {
|
||||
retval = pam_start ("chpasswd", pampw->pw_name, &conv, &pamh);
|
||||
fprintf (stderr,
|
||||
_("%s: Cannot determine your user name.\n"),
|
||||
Prog);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
retval = pam_start ("chpasswd", pampw->pw_name, &conv, &pamh);
|
||||
|
||||
if (PAM_SUCCESS == retval) {
|
||||
retval = pam_authenticate (pamh, 0);
|
||||
}
|
||||
|
@ -306,11 +306,14 @@ static void check_perms (const struct passwd *pw)
|
||||
#else /* !USE_PAM */
|
||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||
if (NULL == pampw) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
} else {
|
||||
retval = pam_start ("chsh", pampw->pw_name, &conv, &pamh);
|
||||
fprintf (stderr,
|
||||
_("%s: Cannot determine your user name.\n"),
|
||||
Prog);
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
|
||||
retval = pam_start ("chsh", pampw->pw_name, &conv, &pamh);
|
||||
|
||||
if (PAM_SUCCESS == retval) {
|
||||
retval = pam_authenticate (pamh, 0);
|
||||
}
|
||||
|
@ -575,11 +575,14 @@ static void check_perms (void)
|
||||
|
||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||
if (NULL == pampw) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
} else {
|
||||
retval = pam_start ("groupadd", pampw->pw_name, &conv, &pamh);
|
||||
fprintf (stderr,
|
||||
_("%s: Cannot determine your user name.\n"),
|
||||
Prog);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
retval = pam_start ("groupadd", pampw->pw_name, &conv, &pamh);
|
||||
|
||||
if (PAM_SUCCESS == retval) {
|
||||
retval = pam_authenticate (pamh, 0);
|
||||
}
|
||||
|
@ -346,11 +346,13 @@ int main (int argc, char **argv)
|
||||
struct passwd *pampw;
|
||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||
if (pampw == NULL) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
} else {
|
||||
retval = pam_start ("groupdel", pampw->pw_name,
|
||||
&conv, &pamh);
|
||||
fprintf (stderr,
|
||||
_("%s: Cannot determine your user name.\n"),
|
||||
Prog);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
retval = pam_start ("groupdel", pampw->pw_name, &conv, &pamh);
|
||||
}
|
||||
|
||||
if (PAM_SUCCESS == retval) {
|
||||
|
@ -445,12 +445,14 @@ static void check_perms (void)
|
||||
|
||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||
if (NULL == pampw) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
} else {
|
||||
retval = pam_start ("groupmems", pampw->pw_name,
|
||||
&conv, &pamh);
|
||||
fprintf (stderr,
|
||||
_("%s: Cannot determine your user name.\n"),
|
||||
Prog);
|
||||
fail_exit (1);
|
||||
}
|
||||
|
||||
retval = pam_start ("groupmems", pampw->pw_name, &conv, &pamh);
|
||||
|
||||
if (PAM_SUCCESS == retval) {
|
||||
retval = pam_authenticate (pamh, 0);
|
||||
}
|
||||
|
@ -711,11 +711,13 @@ int main (int argc, char **argv)
|
||||
struct passwd *pampw;
|
||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||
if (NULL == pamh) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
} else {
|
||||
retval = pam_start ("groupmod", pampw->pw_name,
|
||||
&conv, &pamh);
|
||||
fprintf (stderr,
|
||||
_("%s: Cannot determine your user name.\n"),
|
||||
Prog);
|
||||
fail_exit (1);
|
||||
}
|
||||
|
||||
retval = pam_start ("groupmod", pampw->pw_name, &conv, &pamh);
|
||||
}
|
||||
|
||||
if (PAM_SUCCESS == retval) {
|
||||
|
@ -571,11 +571,14 @@ static void check_perms (void)
|
||||
|
||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||
if (NULL == pampw) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
} else {
|
||||
retval = pam_start ("newusers", pampw->pw_name, &conv, &pamh);
|
||||
fprintf (stderr,
|
||||
_("%s: Cannot determine your user name.\n"),
|
||||
Prog);
|
||||
fail_exit (1);
|
||||
}
|
||||
|
||||
retval = pam_start ("newusers", pampw->pw_name, &conv, &pamh);
|
||||
|
||||
if (PAM_SUCCESS == retval) {
|
||||
retval = pam_authenticate (pamh, 0);
|
||||
}
|
||||
|
@ -1795,11 +1795,13 @@ int main (int argc, char **argv)
|
||||
struct passwd *pampw;
|
||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||
if (pampw == NULL) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
} else {
|
||||
retval = pam_start ("useradd", pampw->pw_name,
|
||||
&conv, &pamh);
|
||||
fprintf (stderr,
|
||||
_("%s: Cannot determine your user name.\n"),
|
||||
Prog);
|
||||
fail_exit (1);
|
||||
}
|
||||
|
||||
retval = pam_start ("useradd", pampw->pw_name, &conv, &pamh);
|
||||
}
|
||||
|
||||
if (PAM_SUCCESS == retval) {
|
||||
|
@ -840,11 +840,13 @@ int main (int argc, char **argv)
|
||||
struct passwd *pampw;
|
||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||
if (pampw == NULL) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
} else {
|
||||
retval = pam_start ("userdel", pampw->pw_name,
|
||||
&conv, &pamh);
|
||||
fprintf (stderr,
|
||||
_("%s: Cannot determine your user name.\n"),
|
||||
Prog);
|
||||
exit (E_PW_UPDATE);
|
||||
}
|
||||
|
||||
retval = pam_start ("userdel", pampw->pw_name, &conv, &pamh);
|
||||
}
|
||||
|
||||
if (PAM_SUCCESS == retval) {
|
||||
|
@ -1661,11 +1661,13 @@ int main (int argc, char **argv)
|
||||
struct passwd *pampw;
|
||||
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
|
||||
if (pampw == NULL) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
} else {
|
||||
retval = pam_start ("usermod", pampw->pw_name,
|
||||
&conv, &pamh);
|
||||
fprintf (stderr,
|
||||
_("%s: Cannot determine your user name.\n"),
|
||||
Prog);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
retval = pam_start ("usermod", pampw->pw_name, &conv, &pamh);
|
||||
}
|
||||
|
||||
if (PAM_SUCCESS == retval) {
|
||||
|
Loading…
Reference in New Issue
Block a user