- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- PAM Error (Change password)
Operating System - Linux
1753524
Members
4777
Online
108795
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2005 09:39 PM
10-12-2005 09:39 PM
PAM Error (Change password)
I wrote a sample program to test PAM functionality in HP Unix 11i. (basically pam_chauthtok).
It is prefectly working in most of the Unix flavours but not in HP UX 11i.
My program
#define DEBUG
#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("fisclsnr", 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","123");
printf( "Res = %d", res);
return 0;
}
If I am trying to change the password of a normal user it doesnot work.
(
retval = pam_chauthtok(pamh, PAM_SILENT);
retval is not 0. Error code is PAM_PERM_DENIED
}
But change password of root user works fine.
( int res = changePasswd("user","123");
value of res is 0 and password changed )
I add more debug meesages on "convert"
function. It shows that, if the username specified is not root, then an Old password request recieved at convert function. But if it is root ,then no Old password request.
In both case I am running the program as root. I could not understand why this happend? Anyone have any Idea ??? any solution to implement a custom "passwd" program??
It is prefectly working in most of the Unix flavours but not in HP UX 11i.
My program
#define DEBUG
#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("fisclsnr", 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","123");
printf( "Res = %d", res);
return 0;
}
If I am trying to change the password of a normal user it doesnot work.
(
retval = pam_chauthtok(pamh, PAM_SILENT);
retval is not 0. Error code is PAM_PERM_DENIED
}
But change password of root user works fine.
( int res = changePasswd("user","123");
value of res is 0 and password changed )
I add more debug meesages on "convert"
function. It shows that, if the username specified is not root, then an Old password request recieved at convert function. But if it is root ,then no Old password request.
In both case I am running the program as root. I could not understand why this happend? Anyone have any Idea ??? any solution to implement a custom "passwd" program??
- Tags:
- libpam
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP