1834441 Members
2438 Online
110067 Solutions
New Discussion

Password change problem

 
shijith_1
Occasional Contributor

Password change problem

Hi all,

I wrote an application in HP UX to change the password like passwd
command. When I try to change the password of a user, it asks for Old
password. Note that I am running my application as root. But in the
same michine the "passwd" command works fine.

Is there is any configuration file exist where I can put my
application name to work perfectly? Any one have any Idea about this?

Note: The same program works perfectly in all other machines including
AIX Linux etc.

Thanks
7 REPLIES 7
Joseph Loo
Honored Contributor

Re: Password change problem

hi,

not sure which arguments u use with passwd, maybe u like to reply it in this post.

regards.
what you do not see does not mean you should not believe
Steven E. Protter
Exalted Contributor

Re: Password change problem

perhaps

passwd -d username
passwd -f username

That might work.

HP-UX is proprietary
HP-UX works differently in certain ways.
I think that in spite of this its a better OS.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
shijith_1
Occasional Contributor

Re: Password change problem

No there is no problem when I am using "passwd" command. It works fine with passwd username

I worte a program named "mypaswd" using PAM.
I enter the correct PAM configuration entry in /etc/pam.conf for my program.

entry looks like

mypasswd account required /usr/lib/security/libpam_unix.1
When I am trying to change the password using "mypasswd" program by entering

"mypasswd username"

It asks for old password.

Note that the source code of "mypasswd" is taken some open source implementation of passwd command using PAM. And it woks fine for all other platforms
FERRARI MARCO
Advisor

Re: Password change problem

Did you login as root or as another user and then su to root ?
Could you attach the source if it's open source so that we can examine it ?
TIA,
Marco
James George_1
Trusted Contributor

Re: Password change problem

Hi

It is possible that the user passwd has reached the expiration time. change the passwd for that user manually and then try running the application if you want to change it again through your application. You should be fine. OR, disable passwd aging for this user.

Rgds
James
forum is for techies .....heaven is for those who are born again !!
HGN
Honored Contributor

Re: Password change problem

Hi

Is the server in trusted mode, in that case you need to edit the tcb database
goto /tcb/files/auth/r and vi the file root then remove the special characters u_pwd after that you can try to change the passwd and it will not ask for the old password.

If not a trusted system then you can edit the passwd file directly and remove the special characters. Make sure you alwyas make and a copy and have session logged in.

Rgds

HGN
shijith_1
Occasional Contributor

Re: Password change problem

>>>Did you login as root or as another user >>>and then su to root ?
>>>Could you attach the source if it's open >>>source so that we can examine it ?

Here I am attaching the source

#include
#include
#include
#include
#include
/*
* PAM call back function to read the password values
*/

extern int convert(int num_msg,struct pam_message **msg,struct
pam_response **resp,void *appdata_ptr)
{
// Initialize PAM response object and set password
struct pam_response *temp;
temp = (struct pam_response *)calloc(num_msg,sizeof(struct
pam_response));
temp[0].resp_retcode = 0;
temp[0].resp = strdup((const char*)appdata_ptr);
*resp = temp;
return PAM_SUCCESS;
}

static struct pam_conv conv = {convert,NULL};
/*
* Function used to change the password of a user
*/
int changePasswd(char *user,char *pass)
{
pam_handle_t *pamh=NULL;
int retval;
struct pam_response *pp=NULL;
conv.appdata_ptr = pass;
// initialize PAM
retval = pam_start("myapp", user, &conv, &pamh);
if (retval == PAM_SUCCESS)
{
// Change password (auth tocken)
retval = pam_chauthtok(pamh, PAM_SILENT);
}
if (retval != PAM_SUCCESS)
{
return -1;
}
// End PAM Session
if (pam_end(pamh,retval) != PAM_SUCCESS)
{
pamh = NULL;
return -1;
}
return 0;
}

int main()
{
int res = changePasswd("user1","password");
printf( "Res = %d", res);
return 0;

}