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.
#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);
}
#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);
}
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);
}
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);
}
#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);
}
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);
}
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) {
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);
}
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) {
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);
}
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) {
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) {
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) {