Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 04-13-2004, 08:37 PM   #1
Registered: Sep 2003
Location: Dallas TX
Distribution: Red Hat
Posts: 59

Rep: Reputation: 15
PHP Authentication against /etc/shadow

I am fairly new with Linux (using RedHat 9 currently) and very new to php.
I hope I have this is the right area...

I am trying to do the following (in PHP)...

1. User submits a form that has their Username and Password
2. Page encrypts the password to check the username and password against the /etc/shadow file.
3. Page then allows the user to see his or her Disk Quotas and account details.

I have tried the following, but am getting an error "WARNING: fopen("/etc/shadow", "r") - Permission denied
(BTW all I am trying to do right now is see if the username is in the file)

the code is as follows:

$fd = fopen("/etc/shadow", "r") or die('File not availalbe');
while (!feof($fd))
$line = fgets($fd, 4096);
if ($line === $username)
echo "Match Found";
echo "No Match";

Any help would be greatly appreciated. I would like to do this without changing file permissions if I can.
Old 04-13-2004, 11:55 PM   #2
Registered: Sep 2003
Location: Dallas TX
Distribution: Red Hat
Posts: 59

Original Poster
Rep: Reputation: 15
I figured it out. Unfortunatly I had to reset the permissions, but nothing that was to major.


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/passwd & /etc/shadow through php? whysyn Linux - Software 4 11-29-2005 10:29 PM
Root Password Broken - authentication not catching /etc/shadow changes greennick Debian 18 09-23-2005 04:30 AM
authentication user by /etc/shadow Thomas23 Linux - Security 2 05-22-2004 10:52 AM
passwd / shadow issues -- Authentication failed BartonOC Linux - General 2 02-12-2004 08:50 PM
/etc/shadow in user authentication katana Linux - General 3 06-24-2001 11:02 PM

All times are GMT -5. The time now is 12:27 PM.

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