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,$passw d,$uid,$gid,$qu ota,$comment,$g cos,$dir,$shell ) =
getpwnam("root" ); #get user nobody's details
$< = $uid;
use User::pwent;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrow ser);
sub authUser {
# set sub variables
my($username,$u serpass,$passwo rd) = @_;
if ( crypt($password ,$userpass) eq $userpass ) {
return 1;
} else {
return 0;
}
}
....
# Set UserInfo
my $user = getpwnam($mailb ox);
my $username = $user->name;
my $userpass = $user->passwd;
my $userdir = $user->dir;
my $useruid = $user->uid;
my $usergid = $user->gid;
---
Thanks,
Jason Williard
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,$passw d,$uid,$gid,$qu ota,$comment,$g cos,$dir,$shell ) =
getpwnam("root" ); #get user nobody's details
$< = $uid;
use User::pwent;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrow ser);
sub authUser {
# set sub variables
my($username,$u serpass,$passwo rd) = @_;
if ( crypt($password ,$userpass) eq $userpass ) {
return 1;
} else {
return 0;
}
}
....
# Set UserInfo
my $user = getpwnam($mailb ox);
my $username = $user->name;
my $userpass = $user->passwd;
my $userdir = $user->dir;
my $useruid = $user->uid;
my $usergid = $user->gid;
---
Thanks,
Jason Williard