home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / programm / 3823 < prev    next >
Encoding:
Text File  |  1992-07-21  |  1.3 KB  |  42 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!noc.near.net!wpi.WPI.EDU!nntp!aej
  3. From: aej@manyjars.WPI.EDU (Allan E Johannesen)
  4. Subject: Re: Changing a User's Password
  5. In-Reply-To: 's message of Monday, 20 Jul 1992 15:40:06 CDT
  6. Message-ID: <AEJ.92Jul21085956@manyjars.WPI.EDU>
  7. Sender: news@wpi.WPI.EDU (USENET News System)
  8. Nntp-Posting-Host: manyjars.wpi.edu
  9. Organization: Worcester Polytechnic Institute, Worcester, MA 01609-2280
  10. References: <92202.154006NIBMSCM@NDSUVM1.BITNET>
  11. Date: Tue, 21 Jul 1992 13:59:56 GMT
  12. Lines: 28
  13.  
  14. >>>>> On Monday, 20 Jul 1992 15:40:06 CDT, <NIBMSCM@NDSUVM1.BITNET> said:
  15.  
  16. NIBMSCM> I am trying to set up new users on a Sun System from within a
  17. NIBMSCM> 'C' program.  Everything seems to be working fine except I am
  18. NIBMSCM> not able to set up a password for the new user.  Some how I
  19. NIBMSCM> need each users password setup before they logon for the
  20. NIBMSCM> first time.
  21.  
  22. Use crypt() to generate one.  e.g.
  23.  
  24. char
  25.   *ky="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./",
  26.   salt[2],
  27.   result[14];
  28.  
  29. char *
  30. generate_passwd(input)
  31. char *
  32.   input;
  33. { int
  34.     now;
  35.   time(&now);
  36.   salt[0] = ky[now % 64];
  37.   salt[1] = ky[(now / 64) % 64];
  38.   return(strcpy(result,crypt(input,salt))); }
  39.  
  40. The above chooses a "random" salt and runs a word across the crypt.
  41. My assumption was that you just wanted the mechanics.
  42.