yppasswd prompts the root password, when a user tries to change the password of another user.
Environment
Red Hat Enterprise Linux 5
Red Hat Enterprise Linux 6
Red Hat Enterprise Linux 7
Issue
- I want a normal user to be able to change the password of another user with yppasswd, but it always prompts the root password.
- Even using the sudo command, it prompts the root password before changing it.
Resolution
It is not possible.
yppasswd command always prompts the root password in advance, even when the root user tries to change the password of a normal user.
Diagnostic Steps
Related code in yp-tools package.
In src/yppasswd.c,
fprintf (stdout, _("Changing NIS account information for %s on %s.\n"),
pwd->pw_name, master);
/* Get old password */
if ((pwd->pw_passwd != NULL && strlen (pwd->pw_passwd) > 0) ||
(pwd->pw_uid != uid)) <<== the old password is set, or trying to change the password of another user.
{
char prompt[130];
char *hashpass, *cp;
if (pwd->pw_uid != uid) <<== if changing the password of another user, it prompts the root password.
snprintf (prompt, sizeof (prompt), _("Please enter root password:"));
else
snprintf (prompt, sizeof (prompt), _("Please enter %spassword:"),
p_flag ? _("old ") : "");
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments