LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 04-28-2008, 09:12 AM   #1
jova626
LQ Newbie
 
Registered: Apr 2008
Posts: 5

Rep: Reputation: 0
How to accept a encrypted password in perl.


Hello All,
I am new to Perl and somewhat new to linux command line. Anyway I am in the process of creating a Perl script that will take a username and password that was given by the user of the script and it will create the user with the password. I am experiencing some trouble with the -p option with the useradd command. I cannot seem to get the useradd to accept the password. Does anyone have any solutions or alternatives to the problem that I am having? Below is excerpt of my code.



#!/usr/bin/perl
.
.
.
.
@result = `useradd -p openssl passwd testpass $username`

.
.
.
.
.
 
Old 04-28-2008, 10:52 AM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
If you check out the manpage for useradd, it says the "passwd" field is the value of the user's password passed through crypt. You will probably have to make a system() call to "crypt" before you try the "useradd" command.
 
Old 04-28-2008, 10:58 AM   #3
jova626
LQ Newbie
 
Registered: Apr 2008
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks I figured it out and have it working. One more question I looked at the manpage and saw that passwd used "crypt(3)". Now is that 3 the the second agrument it uses with the password that you want created?
 
Old 04-28-2008, 11:13 AM   #4
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
(3) - synonymous with man3 - denotes the manpage section it's under. I believe the man3 section is for system utilities. A quick Google search should yield what the different manpage sections are reserved for.
 
Old 04-28-2008, 02:40 PM   #5
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
The crypt(3) means crypt in Section 3 of the manpages (which details libc functions). This is the same as CORE::crypt provided by Perl. Anyway, here is a thread detailing a previous attempt at what you are doing.

I will say here what I said there: instead of doing the hashing and writing manually, it would be better to find something more reliable on CPAN (e.g., Passwd::Unix).
 
  


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
useradd -p <encrypted password> jeewiz Linux - Newbie 1 01-19-2007 09:17 AM
Encrypted Password alejandroye Linux - Security 2 03-01-2006 03:12 PM
su doesn't accept my password CGameProgrammer Linux - General 7 10-13-2004 01:07 PM
su root doesn't accept password Scheike Linux - General 2 09-10-2003 07:38 AM
Perl: Getting a script to accept arguments JStew Programming 10 03-10-2003 07:56 AM


All times are GMT -5. The time now is 02:09 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration