Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

how validate users using passwd file?

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
linux_saul_mex
Posts: 2
Joined: 2014-08-25 01:53

how validate users using passwd file?

#1 Post by linux_saul_mex »

Hi i need do a small interfaz, it works under bash.
I read the user name and password from the terminal then i need validate this data.
my principal dude is:
how look in the /etc/passwd file a user and passwd?
the problem is the password is encrypted and i need compare with the data i read.
Note:
Only i can use BASH because it is school homework.

User avatar
dasein
Posts: 7680
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: how validate users using passwd file?

#2 Post by dasein »

linux_saul_mex wrote:Only i can use BASH because it is school homework.
If it's homework, then I'm pretty sure that your instructor wants you to figure out the answer on your own. That's kind of the whole point of homework.

linux_saul_mex
Posts: 2
Joined: 2014-08-25 01:53

Re: how validate users using passwd file?

#3 Post by linux_saul_mex »

dasein wrote: If it's homework, then I'm pretty sure that your instructor wants you to figure out the answer on your own. That's kind of the whole point of homework.
Yes you are right but this is a one way by do the homework.(search and question on forums).

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: how validate users using passwd file?

#4 Post by Head_on_a_Stick »

Code: Select all

man passwd
Maybe?
Or even (brace yourself):

Code: Select all

apropos passwd
:D
deadbang

User avatar
dasein
Posts: 7680
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: how validate users using passwd file?

#5 Post by dasein »

linux_saul_mex wrote:
dasein wrote: If it's homework, then I'm pretty sure that your instructor wants you to figure out the answer on your own. That's kind of the whole point of homework.
Yes you are right but this is a one way by do the homework.(search and question on forums).
Search, yes. Validate an idea, yes. Ask someone to answer the question for you, no. (Google dyodh for details.)

User avatar
saulgoode
Posts: 1445
Joined: 2007-10-22 11:34
Been thanked: 4 times

Re: how validate users using passwd file?

#6 Post by saulgoode »

linux_saul_mex wrote:Hi i need do a small interfaz, it works under bash.
I read the user name and password from the terminal then i need validate this data.
my principal dude is:
how look in the /etc/passwd file a user and passwd?
Password information is not present in /etc/passwd. It is stored in encrypted form in /etc/shadow. /etc/shadow will not help you with your script because it is readable only by root; regular users running your script will not be able access the shadow passwords.

Since this is a homework assignment, I will not provide a direct answer (also, you've not provided enough information for me to do so effectively), however, I will point out that one way to do this would be to use expect to execute 'su' and automatically provide the password in response to the prompt.

You might also be able to invoke PAM somewhat directly. I don't use PAM so I can't say for sure that this will work from BASH (though it is often done in other languages).
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian Kernighan

Post Reply