<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic PAM Error (Change password) in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/pam-error-change-password/m-p/3648562#M102377</link>
    <description>I wrote a sample program to test PAM functionality in HP Unix 11i. (basically pam_chauthtok).&lt;BR /&gt;&lt;BR /&gt;It is prefectly working in most of the Unix flavours but not in HP UX 11i.&lt;BR /&gt;&lt;BR /&gt;My program&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#define DEBUG&lt;BR /&gt;#include &lt;SECURITY&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;PWD.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#include &lt;STRING.H&gt;&lt;BR /&gt;/*&lt;BR /&gt; * PAM call back function to read the password values&lt;BR /&gt; */&lt;BR /&gt;&lt;BR /&gt;extern int convert(int num_msg,struct pam_message **msg,struct&lt;BR /&gt;pam_response **resp,void *appdata_ptr)&lt;BR /&gt;{&lt;BR /&gt; // Initialize PAM response object and set password&lt;BR /&gt; struct pam_response *temp;&lt;BR /&gt; temp = (struct pam_response *)calloc(num_msg,sizeof(struct pam_response));&lt;BR /&gt; temp[0].resp_retcode = 0;&lt;BR /&gt; temp[0].resp = strdup((const char*)appdata_ptr);&lt;BR /&gt; *resp = temp;&lt;BR /&gt; return PAM_SUCCESS;&lt;BR /&gt;}&lt;BR /&gt;static struct pam_conv conv = {convert,NULL};&lt;BR /&gt;/*&lt;BR /&gt; * Function used to change the password of a user&lt;BR /&gt; */&lt;BR /&gt;int changePasswd(char *user,char *pass)&lt;BR /&gt;{&lt;BR /&gt; pam_handle_t *pamh=NULL;&lt;BR /&gt; int retval;&lt;BR /&gt; struct pam_response *pp=NULL;&lt;BR /&gt; conv.appdata_ptr = pass;&lt;BR /&gt; // initialize PAM&lt;BR /&gt; retval = pam_start("fisclsnr", user, &amp;amp;conv, &amp;amp;pamh);&lt;BR /&gt; if (retval == PAM_SUCCESS)&lt;BR /&gt; {&lt;BR /&gt;     // Change password (auth tocken)&lt;BR /&gt;     retval = pam_chauthtok(pamh, PAM_SILENT);&lt;BR /&gt; }&lt;BR /&gt; if (retval != PAM_SUCCESS)&lt;BR /&gt; {&lt;BR /&gt;     return -1;&lt;BR /&gt; }&lt;BR /&gt; // End PAM Session&lt;BR /&gt; if (pam_end(pamh,retval) != PAM_SUCCESS)&lt;BR /&gt; {&lt;BR /&gt;     pamh = NULL;&lt;BR /&gt;     return -1;&lt;BR /&gt; }&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt;     int res = changePasswd("user","123");&lt;BR /&gt;     printf( "Res = %d", res);&lt;BR /&gt;     return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If I am trying to change the password of a normal user it doesnot work.&lt;BR /&gt;(&lt;BR /&gt;    retval = pam_chauthtok(pamh, PAM_SILENT);&lt;BR /&gt;    retval is not 0. Error code is PAM_PERM_DENIED&lt;BR /&gt; }&lt;BR /&gt;But change password of root user works fine.&lt;BR /&gt;   (  int res = changePasswd("user","123");&lt;BR /&gt;     value of res is 0 and password changed )&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; I add more debug meesages on "convert"&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt; 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??&lt;BR /&gt;&lt;BR /&gt;&lt;/STRING.H&gt;&lt;/STDLIB.H&gt;&lt;/PWD.H&gt;&lt;/STDIO.H&gt;&lt;/SECURITY&gt;</description>
    <pubDate>Thu, 13 Oct 2005 04:39:45 GMT</pubDate>
    <dc:creator>shijith_1</dc:creator>
    <dc:date>2005-10-13T04:39:45Z</dc:date>
    <item>
      <title>PAM Error (Change password)</title>
      <link>https://community.hpe.com/t5/operating-system-linux/pam-error-change-password/m-p/3648562#M102377</link>
      <description>I wrote a sample program to test PAM functionality in HP Unix 11i. (basically pam_chauthtok).&lt;BR /&gt;&lt;BR /&gt;It is prefectly working in most of the Unix flavours but not in HP UX 11i.&lt;BR /&gt;&lt;BR /&gt;My program&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#define DEBUG&lt;BR /&gt;#include &lt;SECURITY&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;PWD.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#include &lt;STRING.H&gt;&lt;BR /&gt;/*&lt;BR /&gt; * PAM call back function to read the password values&lt;BR /&gt; */&lt;BR /&gt;&lt;BR /&gt;extern int convert(int num_msg,struct pam_message **msg,struct&lt;BR /&gt;pam_response **resp,void *appdata_ptr)&lt;BR /&gt;{&lt;BR /&gt; // Initialize PAM response object and set password&lt;BR /&gt; struct pam_response *temp;&lt;BR /&gt; temp = (struct pam_response *)calloc(num_msg,sizeof(struct pam_response));&lt;BR /&gt; temp[0].resp_retcode = 0;&lt;BR /&gt; temp[0].resp = strdup((const char*)appdata_ptr);&lt;BR /&gt; *resp = temp;&lt;BR /&gt; return PAM_SUCCESS;&lt;BR /&gt;}&lt;BR /&gt;static struct pam_conv conv = {convert,NULL};&lt;BR /&gt;/*&lt;BR /&gt; * Function used to change the password of a user&lt;BR /&gt; */&lt;BR /&gt;int changePasswd(char *user,char *pass)&lt;BR /&gt;{&lt;BR /&gt; pam_handle_t *pamh=NULL;&lt;BR /&gt; int retval;&lt;BR /&gt; struct pam_response *pp=NULL;&lt;BR /&gt; conv.appdata_ptr = pass;&lt;BR /&gt; // initialize PAM&lt;BR /&gt; retval = pam_start("fisclsnr", user, &amp;amp;conv, &amp;amp;pamh);&lt;BR /&gt; if (retval == PAM_SUCCESS)&lt;BR /&gt; {&lt;BR /&gt;     // Change password (auth tocken)&lt;BR /&gt;     retval = pam_chauthtok(pamh, PAM_SILENT);&lt;BR /&gt; }&lt;BR /&gt; if (retval != PAM_SUCCESS)&lt;BR /&gt; {&lt;BR /&gt;     return -1;&lt;BR /&gt; }&lt;BR /&gt; // End PAM Session&lt;BR /&gt; if (pam_end(pamh,retval) != PAM_SUCCESS)&lt;BR /&gt; {&lt;BR /&gt;     pamh = NULL;&lt;BR /&gt;     return -1;&lt;BR /&gt; }&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt;     int res = changePasswd("user","123");&lt;BR /&gt;     printf( "Res = %d", res);&lt;BR /&gt;     return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If I am trying to change the password of a normal user it doesnot work.&lt;BR /&gt;(&lt;BR /&gt;    retval = pam_chauthtok(pamh, PAM_SILENT);&lt;BR /&gt;    retval is not 0. Error code is PAM_PERM_DENIED&lt;BR /&gt; }&lt;BR /&gt;But change password of root user works fine.&lt;BR /&gt;   (  int res = changePasswd("user","123");&lt;BR /&gt;     value of res is 0 and password changed )&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; I add more debug meesages on "convert"&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt; 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??&lt;BR /&gt;&lt;BR /&gt;&lt;/STRING.H&gt;&lt;/STDLIB.H&gt;&lt;/PWD.H&gt;&lt;/STDIO.H&gt;&lt;/SECURITY&gt;</description>
      <pubDate>Thu, 13 Oct 2005 04:39:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/pam-error-change-password/m-p/3648562#M102377</guid>
      <dc:creator>shijith_1</dc:creator>
      <dc:date>2005-10-13T04:39:45Z</dc:date>
    </item>
  </channel>
</rss>

