Unix administration - HPUX password change problem

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > November 2005 > HPUX password change problem





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author HPUX password change problem
Shijith

2005-10-24, 3:49 pm

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

Bill Marcum

2005-10-24, 3:49 pm

On 20 Oct 2005 21:43:59 -0700, Shijith
<shijithlal@gmail.com> wrote:
> 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.
>

If you wrote the application, how can anyone else know what is wrong
without seeing the source code? How does your application test whether
it is running as root before it asks for the old password?


--
Eggheads unite! You have nothing to lose but your yolks.
-- Adlai Stevenson
Shijith

2005-11-01, 8:03 am

I am using PAM to change the password. Actulayy PAM module is
responsible for changing password. I am attaching the source code here

#include <security/pam_appl.h>
#include <stdio.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
/*
* 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("user","mypass");
printf( "Res = %d", res);
return 0;

}

I entered a correct entry in pam.conf file also

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com