Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Using getpwnam() with CGI
I am trying to create a script to install spam filters on a per user basis.
The script will have a web UI where the user should be able to login and
enable or disable the filters.  My original script, which was a command-line
perl script, used User::pwent getpwnam() to get the user's encrypted
password from the shadow file and compare it with the encrypted password
that the user submitted.  This worked perfectly.  Unfortunately, when I run
it from a command line, the passwd object passed by getpwnam() is always 'x'
which it is grabbing from the passwd file.  Does anyone know how I can fix
this?

Here are the important parts of the code:

#!/usr/bin/suidperl -U
$current_id = $<; #get the current user id
 my($name,$passwd,$uid,$gid,$quota,$comme
nt,$gcos,$dir,$shell) =
getpwnam("root"); #get user nobody's details
$< = $uid;

use User::pwent;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

sub authUser {
# set sub variables
my($username,$userpass,$password) = @_;
if ( crypt($password,$userpass) eq $userpass ) {
return 1;
} else {
return 0;
}
}

...

# Set UserInfo
my $user = getpwnam($mailbox);
my $username = $user->name;
my $userpass = $user->passwd;
my $userdir  = $user->dir;
my $useruid  = $user->uid;
my $usergid  = $user->gid;


---
Thanks,
Jason Williard



Report this thread to moderator Post Follow-up to this message
Old Post
Jason Williard
04-23-05 01:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL CGI Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:27 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.