<?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 Re: Changing user's password programmatically in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547307#M724828</link>
    <description>Hi Herv?&lt;BR /&gt;&lt;BR /&gt;So it is up to me to choose the "salt" value, great...&lt;BR /&gt;i have tried this and i got the 13 characters output, which starts with "My_2_Salt_Characters".. then i replaced the password entry for one account with the new password... when i tried to login i had login incorrect. &lt;BR /&gt;Is there anything missing of the procedure i described: -&lt;BR /&gt;1- getpwnam&lt;BR /&gt;2- crypt&lt;BR /&gt;3- putpwent&lt;BR /&gt;&lt;BR /&gt;thanks,&lt;BR /&gt;Ahmed</description>
    <pubDate>Mon, 02 Jul 2001 07:17:20 GMT</pubDate>
    <dc:creator>Ahmed Atef</dc:creator>
    <dc:date>2001-07-02T07:17:20Z</dc:date>
    <item>
      <title>Changing user's password programmatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547305#M724826</link>
      <description>Hi &lt;BR /&gt;I'm trying to write small C code to change the user's password automatically using getpwent(3C), crypt(3C) and then putpwent(3C) ... actually "Clay" has guided me to use these function calls sometime back..&lt;BR /&gt;&lt;BR /&gt;now i have a question, The "salt" value in crypt function "second argument", on which base i choose this value?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Ahmed</description>
      <pubDate>Mon, 02 Jul 2001 06:42:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547305#M724826</guid>
      <dc:creator>Ahmed Atef</dc:creator>
      <dc:date>2001-07-02T06:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Changing user's password programmatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547306#M724827</link>
      <description>Hi &lt;BR /&gt;&lt;BR /&gt;The salt is a two caracters word which is a &lt;BR /&gt;crypt argument. You can use random to &lt;BR /&gt;calcultate each letter.&lt;BR /&gt;&lt;BR /&gt;This salt is use to be a key for crypt function&lt;BR /&gt;After crypt a password you can see that salt&lt;BR /&gt;is on the two first signs of the passwd 13&lt;BR /&gt;caracters.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Herv?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Jul 2001 07:04:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547306#M724827</guid>
      <dc:creator>Herve BRANGIER</dc:creator>
      <dc:date>2001-07-02T07:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Changing user's password programmatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547307#M724828</link>
      <description>Hi Herv?&lt;BR /&gt;&lt;BR /&gt;So it is up to me to choose the "salt" value, great...&lt;BR /&gt;i have tried this and i got the 13 characters output, which starts with "My_2_Salt_Characters".. then i replaced the password entry for one account with the new password... when i tried to login i had login incorrect. &lt;BR /&gt;Is there anything missing of the procedure i described: -&lt;BR /&gt;1- getpwnam&lt;BR /&gt;2- crypt&lt;BR /&gt;3- putpwent&lt;BR /&gt;&lt;BR /&gt;thanks,&lt;BR /&gt;Ahmed</description>
      <pubDate>Mon, 02 Jul 2001 07:17:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547307#M724828</guid>
      <dc:creator>Ahmed Atef</dc:creator>
      <dc:date>2001-07-02T07:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: Changing user's password programmatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547308#M724829</link>
      <description>Ahmed,&lt;BR /&gt;&lt;BR /&gt;I try that :&lt;BR /&gt;&lt;BR /&gt;1) getpwnam&lt;BR /&gt;2) crypt new passwd with a salt&lt;BR /&gt;3) putpwent&lt;BR /&gt;4) try to login : works well !!!&lt;BR /&gt;&lt;BR /&gt;Look at this small piece of code :&lt;BR /&gt;&lt;BR /&gt;---- CUT HERE -----&lt;BR /&gt;&lt;BR /&gt;#include &lt;PWD.H&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;&lt;BR /&gt;main ()&lt;BR /&gt;{&lt;BR /&gt;struct passwd * my_pwstr;&lt;BR /&gt;char * new_pwd;&lt;BR /&gt;/* You need to open you passwd file for update */&lt;BR /&gt;FILE *pwfile = fopen ("/etc/passwd","r+");&lt;BR /&gt;&lt;BR /&gt;my_pwstr = getpwnam ("cg");&lt;BR /&gt;&lt;BR /&gt;printf ("\nEncrypted passwd : %s\n",my_pwstr -&amp;gt;pw_passwd);&lt;BR /&gt;&lt;BR /&gt;new_pwd = crypt ("azerty","q2"); /* new pwd is "azerty" and salt is "q2" */&lt;BR /&gt;&lt;BR /&gt;printf ("New encrypted passwd : %s\n",new_pwd);&lt;BR /&gt;&lt;BR /&gt;strcpy (my_pwstr-&amp;gt;pw_passwd, new_pwd);&lt;BR /&gt;&lt;BR /&gt;putpwent (my_pwstr,pwfile);&lt;BR /&gt;&lt;BR /&gt;fclose (pwfile);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;----- CUT HERE ------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I made no control on file opening and other error&lt;BR /&gt;but it works well. You just need to add a &lt;BR /&gt;function to calculate your salt.&lt;BR /&gt;&lt;BR /&gt;Good luck&lt;BR /&gt;&lt;BR /&gt;Herv?&lt;BR /&gt;&lt;BR /&gt;&lt;/STDIO.H&gt;&lt;/PWD.H&gt;</description>
      <pubDate>Mon, 02 Jul 2001 07:41:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547308#M724829</guid>
      <dc:creator>Herve BRANGIER</dc:creator>
      <dc:date>2001-07-02T07:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Changing user's password programmatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547309#M724830</link>
      <description>&lt;BR /&gt;Ahmed&lt;BR /&gt;&lt;BR /&gt;I just see something : Clay and, now, I help&lt;BR /&gt;you... don't forget to assign points to our&lt;BR /&gt;reply if we help you. &lt;BR /&gt;&lt;BR /&gt;An information : I don't know where you get new&lt;BR /&gt;password. Don't forget that you can't take &lt;BR /&gt;passwd field gave by getpwnam : it is encrypted&lt;BR /&gt;You need to use a new one not encrypted.&lt;BR /&gt;&lt;BR /&gt;Herv?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Jul 2001 07:50:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547309#M724830</guid>
      <dc:creator>Herve BRANGIER</dc:creator>
      <dc:date>2001-07-02T07:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Changing user's password programmatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547310#M724831</link>
      <description>Definitly i will assign points once i solve this problem, thanks for the reminder :-)&lt;BR /&gt;&lt;BR /&gt;my code is almost typical of what you did the difference is that i'm getting the username and the new password from the command line.&lt;BR /&gt;&lt;BR /&gt;it is not only the problem that i can't login but the user home directory got corrupted after i apply the crypt call this in case the old password is NULL "means that no characters between the two':' in /etc/passwd!!! &lt;BR /&gt;&lt;BR /&gt;i'm attaching my code as well...</description>
      <pubDate>Mon, 02 Jul 2001 08:07:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547310#M724831</guid>
      <dc:creator>Ahmed Atef</dc:creator>
      <dc:date>2001-07-02T08:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Changing user's password programmatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547311#M724832</link>
      <description>Sorry ... here is the attachmenet&lt;BR /&gt;&lt;BR /&gt;Thanks, again&lt;BR /&gt;Ahmed</description>
      <pubDate>Mon, 02 Jul 2001 08:08:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547311#M724832</guid>
      <dc:creator>Ahmed Atef</dc:creator>
      <dc:date>2001-07-02T08:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Changing user's password programmatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547312#M724833</link>
      <description>Ok Ok .. sorry for this silly mistake .. argv[3] should be argv[2] :-) ... i'm sorry again for this overlooked mistake .. but still it doesn't work if i have previously null password ....</description>
      <pubDate>Mon, 02 Jul 2001 08:19:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547312#M724833</guid>
      <dc:creator>Ahmed Atef</dc:creator>
      <dc:date>2001-07-02T08:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: Changing user's password programmatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547313#M724834</link>
      <description>Okay i solved it ...&lt;BR /&gt;When the password has less than 13 characters value the amount of memory allocated will be less than 13 characters so unpredicted results will occure,&lt;BR /&gt;To solve this we need to malloc or realloc 13 characters of memory and return the pointer to pw_passwd..&lt;BR /&gt;&lt;BR /&gt;It works fine now...&lt;BR /&gt;Thanks and i will assign the points right now..&lt;BR /&gt;&lt;BR /&gt;Ahmed</description>
      <pubDate>Mon, 02 Jul 2001 08:40:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547313#M724834</guid>
      <dc:creator>Ahmed Atef</dc:creator>
      <dc:date>2001-07-02T08:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Changing user's password programmatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547314#M724835</link>
      <description>Ahmed,&lt;BR /&gt;&lt;BR /&gt;It seems to work well now but have a look to &lt;BR /&gt;your passwd file : when you use putpwent you&lt;BR /&gt;add a new line on passwd file.&lt;BR /&gt;The problem is that if you have two lines the&lt;BR /&gt;first is read and not the others and it seems&lt;BR /&gt;that the first is the old one.&lt;BR /&gt;I made modification in your program (using grep&lt;BR /&gt;in the system call) to delete all "user" lines&lt;BR /&gt;when copying /etc/passwd to /tmp/passwd.&lt;BR /&gt;&lt;BR /&gt;I join the file...&lt;BR /&gt;&lt;BR /&gt;Bye&lt;BR /&gt;&lt;BR /&gt;Herv?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Jul 2001 08:48:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547314#M724835</guid>
      <dc:creator>Herve BRANGIER</dc:creator>
      <dc:date>2001-07-02T08:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Changing user's password programmatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547315#M724836</link>
      <description>&lt;BR /&gt;Another information :&lt;BR /&gt;&lt;BR /&gt;return of crypt () is ALWAYS 13 caracters &lt;BR /&gt;you can crypt 1 to 8 caracters and the result&lt;BR /&gt;is 2 + 11 caracters (salt + encrypted form).&lt;BR /&gt;So you have exactly 13 caracters in pw_passwd.&lt;BR /&gt;&lt;BR /&gt;Herv?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Jul 2001 09:03:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547315#M724836</guid>
      <dc:creator>Herve BRANGIER</dc:creator>
      <dc:date>2001-07-02T09:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: Changing user's password programmatically</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547316#M724837</link>
      <description>Herv?&lt;BR /&gt;&lt;BR /&gt;Yea, actually my program is not in the final state ... i know i have  to remove the old entry before updating by the new one .. also i need to check for the /etc/passwd file after updating to check whether there is errors or not .... &lt;BR /&gt;&lt;BR /&gt;thank you again for ur help :-)&lt;BR /&gt;&lt;BR /&gt;Ahmed</description>
      <pubDate>Mon, 02 Jul 2001 10:13:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/changing-user-s-password-programmatically/m-p/2547316#M724837</guid>
      <dc:creator>Ahmed Atef</dc:creator>
      <dc:date>2001-07-02T10:13:07Z</dc:date>
    </item>
  </channel>
</rss>

