version 1.435, 2010/01/02 23:56:06
|
version 1.443, 2010/06/10 19:21:32
|
Line 42 use Crypt::IDEA;
|
Line 42 use Crypt::IDEA;
|
use LWP::UserAgent(); |
use LWP::UserAgent(); |
use Digest::MD5 qw(md5_hex); |
use Digest::MD5 qw(md5_hex); |
use GDBM_File; |
use GDBM_File; |
use Authen::Krb4; |
|
use Authen::Krb5; |
use Authen::Krb5; |
use localauth; |
use localauth; |
use localenroll; |
use localenroll; |
Line 976 sub read_profile {
|
Line 975 sub read_profile {
|
&GDBM_READER()); |
&GDBM_READER()); |
if ($hashref) { |
if ($hashref) { |
my @queries=split(/\&/,$what); |
my @queries=split(/\&/,$what); |
|
if ($namespace eq 'roles') { |
|
@queries = map { &unescape($_); } @queries; |
|
} |
my $qresult=''; |
my $qresult=''; |
|
|
for (my $i=0;$i<=$#queries;$i++) { |
for (my $i=0;$i<=$#queries;$i++) { |
Line 3870 sub dump_course_id_handler {
|
Line 3872 sub dump_course_id_handler {
|
$items->{'cloners'} = $cloneruname.':'.$clonerudom; |
$items->{'cloners'} = $cloneruname.':'.$clonerudom; |
$valchange = 1; |
$valchange = 1; |
} |
} |
|
unless ($canclone) { |
|
if ($items->{'owner'} =~ /:/) { |
|
if ($items->{'owner'} eq $cloner) { |
|
$canclone = 1; |
|
} |
|
} elsif ($cloner eq $udom.':'.$items->{'owner'}) { |
|
$canclone = 1; |
|
} |
|
if ($canclone) { |
|
$items->{'cloners'} = $cloneruname.':'.$clonerudom; |
|
$valchange = 1; |
|
} |
|
} |
} |
} |
} |
} |
if ($unpack || !$rtn_as_hash) { |
if ($unpack || !$rtn_as_hash) { |
Line 4070 sub dump_course_id_handler {
|
Line 4085 sub dump_course_id_handler {
|
} |
} |
®ister_handler("courseiddump", \&dump_course_id_handler, 0, 1, 0); |
®ister_handler("courseiddump", \&dump_course_id_handler, 0, 1, 0); |
|
|
|
sub course_lastaccess_handler { |
|
my ($cmd, $tail, $client) = @_; |
|
my $userinput = "$cmd:$tail"; |
|
my ($cdom,$cnum) = split(':',$tail); |
|
my (%lastaccess,$qresult); |
|
my $hashref = &tie_domain_hash($cdom, "nohist_courseids", &GDBM_WRCREAT()); |
|
if ($hashref) { |
|
while (my ($key,$value) = each(%$hashref)) { |
|
my ($unesc_key,$lasttime); |
|
$unesc_key = &unescape($key); |
|
if ($cnum) { |
|
next unless ($unesc_key =~ /\Q$cdom\E_\Q$cnum\E$/); |
|
} |
|
if ($unesc_key =~ /^lasttime:($LONCAPA::match_domain\_$LONCAPA::match_courseid)/) { |
|
$lastaccess{$1} = $value; |
|
} else { |
|
my $items = &Apache::lonnet::thaw_unescape($value); |
|
if (ref($items) eq 'HASH') { |
|
unless ($lastaccess{$unesc_key}) { |
|
$lastaccess{$unesc_key} = ''; |
|
} |
|
} else { |
|
my @courseitems = split(':',$value); |
|
$lastaccess{$unesc_key} = pop(@courseitems); |
|
} |
|
} |
|
} |
|
foreach my $cid (sort(keys(%lastaccess))) { |
|
$qresult.=&escape($cid).'='.$lastaccess{$cid}.'&'; |
|
} |
|
if (&untie_domain_hash($hashref)) { |
|
if ($qresult) { |
|
chop($qresult); |
|
} |
|
&Reply($client, \$qresult, $userinput); |
|
} else { |
|
&Failure($client, "error: ".($!+0)." untie(GDBM) Failed ". |
|
"while attempting lastacourseaccess\n", $userinput); |
|
} |
|
} else { |
|
&Failure($client, "error: ".($!+0)." tie(GDBM) Failed ". |
|
"while attempting lastcourseaccess\n", $userinput); |
|
} |
|
return 1; |
|
} |
|
®ister_handler("courselastaccess",\&course_lastaccess_handler, 0, 1, 0); |
|
|
# |
# |
# Puts an unencrypted entry in a namespace db file at the domain level |
# Puts an unencrypted entry in a namespace db file at the domain level |
# |
# |
Line 6331 sub make_new_child {
|
Line 6393 sub make_new_child {
|
my $cipherkey = pack("H32", $key); |
my $cipherkey = pack("H32", $key); |
$cipher = new IDEA($cipherkey); |
$cipher = new IDEA($cipherkey); |
print $client "ok:local\n"; |
print $client "ok:local\n"; |
&logthis('<font color="green"' |
&logthis('<font color="green">' |
. "Successful local authentication </font>"); |
. "Successful local authentication </font>"); |
$keymode = "local" |
$keymode = "local" |
} else { |
} else { |
Line 6553 sub rewrite_password_file {
|
Line 6615 sub rewrite_password_file {
|
|
|
# Returns the authorization type or nouser if there is no such user. |
# Returns the authorization type or nouser if there is no such user. |
# |
# |
sub get_auth_type |
sub get_auth_type { |
{ |
|
|
|
my ($domain, $user) = @_; |
my ($domain, $user) = @_; |
|
|
Debug("get_auth_type( $domain, $user ) \n"); |
Debug("get_auth_type( $domain, $user ) \n"); |
Line 6650 sub validate_user {
|
Line 6710 sub validate_user {
|
} else { |
} else { |
$validated = 0; |
$validated = 0; |
} |
} |
} |
} elsif ($howpwd eq "krb4") { # user is in kerberos 4 auth. domain. |
elsif ($howpwd eq "krb4") { # user is in kerberos 4 auth. domain. |
my $checkwithkrb5 = 0; |
if(! ($password =~ /$null/) ) { |
if ($dist =~/^fedora(\d+)$/) { |
my $k4error = &Authen::Krb4::get_pw_in_tkt($user, |
if ($1 > 11) { |
"", |
$checkwithkrb5 = 1; |
$contentpwd,, |
} |
'krbtgt', |
} elsif ($dist =~ /^suse([\d.]+)$/) { |
$contentpwd, |
if ($1 > 11.1) { |
1, |
$checkwithkrb5 = 1; |
$password); |
} |
if(!$k4error) { |
} |
$validated = 1; |
if ($checkwithkrb5) { |
} else { |
$validated = &krb5_authen($password,$null,$user,$contentpwd); |
$validated = 0; |
} else { |
&logthis('krb4: '.$user.', '.$contentpwd.', '. |
$validated = &krb4_authen($password,$null,$user,$contentpwd); |
&Authen::Krb4::get_err_txt($Authen::Krb4::error)); |
} |
} |
|
} else { |
|
$validated = 0; # Password has a match with null. |
|
} |
|
} elsif ($howpwd eq "krb5") { # User is in kerberos 5 auth. domain. |
} elsif ($howpwd eq "krb5") { # User is in kerberos 5 auth. domain. |
if(!($password =~ /$null/)) { # Null password not allowed. |
$validated = &krb5_authen($password,$null,$user,$contentpwd); |
my $krbclient = &Authen::Krb5::parse_name($user.'@' |
|
.$contentpwd); |
|
my $krbservice = "krbtgt/".$contentpwd."\@".$contentpwd; |
|
my $krbserver = &Authen::Krb5::parse_name($krbservice); |
|
my $credentials= &Authen::Krb5::cc_default(); |
|
$credentials->initialize(&Authen::Krb5::parse_name($user.'@' |
|
.$contentpwd)); |
|
my $krbreturn; |
|
if (exists(&Authen::Krb5::get_init_creds_password)) { |
|
$krbreturn = |
|
&Authen::Krb5::get_init_creds_password($krbclient,$password, |
|
$krbservice); |
|
$validated = (ref($krbreturn) eq 'Authen::Krb5::Creds'); |
|
} else { |
|
$krbreturn = |
|
&Authen::Krb5::get_in_tkt_with_password($krbclient,$krbserver, |
|
$password,$credentials); |
|
$validated = ($krbreturn == 1); |
|
} |
|
if (!$validated) { |
|
&logthis('krb5: '.$user.', '.$contentpwd.', '. |
|
&Authen::Krb5::error()); |
|
} |
|
} else { |
|
$validated = 0; |
|
} |
|
} elsif ($howpwd eq "localauth") { |
} elsif ($howpwd eq "localauth") { |
# Authenticate via installation specific authentcation method: |
# Authenticate via installation specific authentcation method: |
$validated = &localauth::localauth($user, |
$validated = &localauth::localauth($user, |
Line 6728 sub validate_user {
|
Line 6758 sub validate_user {
|
return $validated; |
return $validated; |
} |
} |
|
|
|
sub krb4_authen { |
|
my ($password,$null,$user,$contentpwd) = @_; |
|
my $validated = 0; |
|
if (!($password =~ /$null/) ) { # Null password not allowed. |
|
eval { |
|
require Authen::Krb4; |
|
}; |
|
if (!$@) { |
|
my $k4error = &Authen::Krb4::get_pw_in_tkt($user, |
|
"", |
|
$contentpwd,, |
|
'krbtgt', |
|
$contentpwd, |
|
1, |
|
$password); |
|
if(!$k4error) { |
|
$validated = 1; |
|
} else { |
|
$validated = 0; |
|
&logthis('krb4: '.$user.', '.$contentpwd.', '. |
|
&Authen::Krb4::get_err_txt($Authen::Krb4::error)); |
|
} |
|
} else { |
|
$validated = krb5_authen($password,$null,$user,$contentpwd); |
|
} |
|
} |
|
return $validated; |
|
} |
|
|
|
sub krb5_authen { |
|
my ($password,$null,$user,$contentpwd) = @_; |
|
my $validated = 0; |
|
if(!($password =~ /$null/)) { # Null password not allowed. |
|
my $krbclient = &Authen::Krb5::parse_name($user.'@' |
|
.$contentpwd); |
|
my $krbservice = "krbtgt/".$contentpwd."\@".$contentpwd; |
|
my $krbserver = &Authen::Krb5::parse_name($krbservice); |
|
my $credentials= &Authen::Krb5::cc_default(); |
|
$credentials->initialize(&Authen::Krb5::parse_name($user.'@' |
|
.$contentpwd)); |
|
my $krbreturn; |
|
if (exists(&Authen::Krb5::get_init_creds_password)) { |
|
$krbreturn = |
|
&Authen::Krb5::get_init_creds_password($krbclient,$password, |
|
$krbservice); |
|
$validated = (ref($krbreturn) eq 'Authen::Krb5::Creds'); |
|
} else { |
|
$krbreturn = |
|
&Authen::Krb5::get_in_tkt_with_password($krbclient,$krbserver, |
|
$password,$credentials); |
|
$validated = ($krbreturn == 1); |
|
} |
|
if (!$validated) { |
|
&logthis('krb5: '.$user.', '.$contentpwd.', '. |
|
&Authen::Krb5::error()); |
|
} |
|
} |
|
return $validated; |
|
} |
|
|
sub addline { |
sub addline { |
my ($fname,$hostid,$ip,$newline)=@_; |
my ($fname,$hostid,$ip,$newline)=@_; |
Line 7098 sub sethost {
|
Line 7187 sub sethost {
|
eq &Apache::lonnet::get_host_ip($hostid)) { |
eq &Apache::lonnet::get_host_ip($hostid)) { |
$currenthostid =$hostid; |
$currenthostid =$hostid; |
$currentdomainid=&Apache::lonnet::host_domain($hostid); |
$currentdomainid=&Apache::lonnet::host_domain($hostid); |
&logthis("Setting hostid to $hostid, and domain to $currentdomainid"); |
# &logthis("Setting hostid to $hostid, and domain to $currentdomainid"); |
} else { |
} else { |
&logthis("Requested host id $hostid not an alias of ". |
&logthis("Requested host id $hostid not an alias of ". |
$perlvar{'lonHostID'}." refusing connection"); |
$perlvar{'lonHostID'}." refusing connection"); |
Line 7848 string.
|
Line 7937 string.
|
|
|
=back |
=back |
|
|
|
=back |
|
|
|
|
=cut |
=cut |