LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-19-2004, 02:53 PM   #1
monzter
LQ Newbie
 
Registered: Aug 2004
Posts: 4

Rep: Reputation: 0
crypt() not match wiht shadow in RH


I try to make automated system to adduser with php
but when I run useradd command
I can not log in that user with password that I key
such "useradd monzter -p 1234"
but when I log in server their told me "wrong password"

I don't know why??

pls Help Thanks
 
Old 08-19-2004, 05:42 PM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Passwords are stored encrypted in /etc/shadow. But the "useradd -p 1234" program puts "1234" unencrypted in /etc/shadow. (check it with "grep monzter /etc/shadow" (as root))

So, when you log in, the "login" program encrypts "1234", and compares the result to the unencrypted "1234" in /etc/shadow. This fails (of course).

The man page for "useradd" mentions that the "-p" option needs an already encrypted password as returned by the crypt() function.

PHP has the crypt() function also, so try that. But you may need to process the returned string some more, using the pack() and/or base64_encode() functions, I'm not sure.

Also keep in mind that your Linux-system maybe setup to use password encrypted with the MD5 algorythm (many do that nowadays) instead of crypt(). MD5 is also available in PHP.

Here's a page that talks about encrypting passwords for LDAP with PHP. This may (partly) apply to /etc/shadow.

http://www.openldap.org/faq/data/cache/347.html
 
Old 08-20-2004, 12:35 PM   #3
monzter
LQ Newbie
 
Registered: Aug 2004
Posts: 4

Original Poster
Rep: Reputation: 0
So, what function that I should user to crypt password for redhat 9
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/etc/shadow- (notice the dash after the word shadow) shellcode Linux - Security 1 09-03-2004 04:54 AM
Microsofts Annouces 2 exploits wiht SP 2 djgerbavore General 2 08-18-2004 09:23 AM
problem wiht wget true_atlantis Linux - Software 5 01-13-2004 07:52 PM
problems wiht my mouse watashiwaotaku7 *BSD 1 06-10-2003 03:41 PM
DSL wiht Suse 7.3 Azam Linux - Newbie 0 03-08-2002 05:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration