version 1.963, 2008/07/17 21:22:51
|
version 1.973, 2008/11/28 12:09:16
|
Line 27
|
Line 27
|
# |
# |
### |
### |
|
|
|
=pod |
|
|
|
=head1 NAME |
|
|
|
Apache::lonnet.pm |
|
|
|
=head1 SYNOPSIS |
|
|
|
This file is an interface to the lonc processes of |
|
the LON-CAPA network as well as set of elaborated functions for handling information |
|
necessary for navigating through a given cluster of LON-CAPA machines within a |
|
domain. There are over 40 specialized functions in this module which handle the |
|
reading and transmission of metadata, user information (ids, names, environments, roles, |
|
logs), file information (storage, reading, directories, extensions, replication, embedded |
|
styles and descriptors), educational resources (course descriptions, section names and |
|
numbers), url hashing (to assign roles on a url basis), and translating abbreviated symbols to |
|
and from more descriptive phrases or explanations. |
|
|
|
This is part of the LearningOnline Network with CAPA project |
|
described at http://www.lon-capa.org. |
|
|
|
=head1 Package Variables |
|
|
|
These are largely undocumented, so if you decipher one please note it here. |
|
|
|
=over 4 |
|
|
|
=item $processmarker |
|
|
|
Contains the time this process was started and this servers host id. |
|
|
|
=item $dumpcount |
|
|
|
Counts the number of times a message log flush has been attempted (regardless |
|
of success) by this process. Used as part of the filename when messages are |
|
delayed. |
|
|
|
=back |
|
|
|
=cut |
|
|
package Apache::lonnet; |
package Apache::lonnet; |
|
|
use strict; |
use strict; |
Line 34 use LWP::UserAgent();
|
Line 75 use LWP::UserAgent();
|
use HTTP::Date; |
use HTTP::Date; |
# use Date::Parse; |
# use Date::Parse; |
use vars qw(%perlvar %spareid %pr %prp $memcache %packagetab $tmpdir |
use vars qw(%perlvar %spareid %pr %prp $memcache %packagetab $tmpdir |
$_64bit %env); |
$_64bit %env %protocol); |
|
|
my (%badServerCache, $memcache, %courselogs, %accesshash, %domainrolehash, |
my (%badServerCache, $memcache, %courselogs, %accesshash, %domainrolehash, |
%userrolehash, $processmarker, $dumpcount, %coursedombuf, |
%userrolehash, $processmarker, $dumpcount, %coursedombuf, |
Line 61 require Exporter;
|
Line 102 require Exporter;
|
our @ISA = qw (Exporter); |
our @ISA = qw (Exporter); |
our @EXPORT = qw(%env); |
our @EXPORT = qw(%env); |
|
|
=pod |
|
|
|
=head1 Package Variables |
|
|
|
These are largely undocumented, so if you decipher one please note it here. |
|
|
|
=over 4 |
|
|
|
=item $processmarker |
|
|
|
Contains the time this process was started and this servers host id. |
|
|
|
=item $dumpcount |
|
|
|
Counts the number of times a message log flush has been attempted (regardless |
|
of success) by this process. Used as part of the filename when messages are |
|
delayed. |
|
|
|
=back |
|
|
|
=cut |
|
|
|
|
|
# --------------------------------------------------------------------- Logging |
# --------------------------------------------------------------------- Logging |
{ |
{ |
Line 643 sub spareserver {
|
Line 662 sub spareserver {
|
} |
} |
|
|
if (!$want_server_name) { |
if (!$want_server_name) { |
$spare_server="http://".&hostname($spare_server); |
my $protocol = 'http'; |
|
if ($protocol{$spare_server} eq 'https') { |
|
$protocol = $protocol{$spare_server}; |
|
} |
|
$spare_server = $protocol.'://'.&hostname($spare_server); |
} |
} |
return $spare_server; |
return $spare_server; |
} |
} |
Line 2596 sub get_course_adv_roles {
|
Line 2619 sub get_course_adv_roles {
|
} |
} |
} else { |
} else { |
my $key=&plaintext($role); |
my $key=&plaintext($role); |
if ($section) { $key.=' (Section '.$section.')'; } |
if ($section) { $key.=' ('.&Apache::lonlocal::mt('Section [_1]',$section).')'; } |
if ($returnhash{$key}) { |
if ($returnhash{$key}) { |
$returnhash{$key}.=','.$username.':'.$domain; |
$returnhash{$key}.=','.$username.':'.$domain; |
} else { |
} else { |
Line 3561 sub privileged {
|
Line 3584 sub privileged {
|
|
|
sub rolesinit { |
sub rolesinit { |
my ($domain,$username,$authhost)=@_; |
my ($domain,$username,$authhost)=@_; |
|
my %userroles; |
my $rolesdump=reply("dump:$domain:$username:roles",$authhost); |
my $rolesdump=reply("dump:$domain:$username:roles",$authhost); |
if (($rolesdump eq 'con_lost') || ($rolesdump eq '')) { return ''; } |
if (($rolesdump eq 'con_lost') || ($rolesdump eq '')) { return \%userroles; } |
my %allroles=(); |
my %allroles=(); |
my %allgroups=(); |
my %allgroups=(); |
my $now=time; |
my $now=time; |
my %userroles = ('user.login.time' => $now); |
%userroles = ('user.login.time' => $now); |
my $group_privs; |
my $group_privs; |
|
|
if ($rolesdump ne '') { |
if ($rolesdump ne '') { |
Line 4891 sub log_query {
|
Line 4915 sub log_query {
|
|
|
sub update_portfolio_table { |
sub update_portfolio_table { |
my ($uname,$udom,$file_name,$query,$group,$action) = @_; |
my ($uname,$udom,$file_name,$query,$group,$action) = @_; |
|
if ($group ne '') { |
|
$file_name =~s /^\Q$group\E//; |
|
} |
my $homeserver = &homeserver($uname,$udom); |
my $homeserver = &homeserver($uname,$udom); |
my $queryid= |
my $queryid= |
&reply("querysend:".$query.':'.&escape($uname.':'.$udom.':'.$group). |
&reply("querysend:".$query.':'.&escape($uname.':'.$udom.':'.$group). |
Line 5879 sub assigncustomrole {
|
Line 5906 sub assigncustomrole {
|
sub revokerole { |
sub revokerole { |
my ($udom,$uname,$url,$role,$deleteflag,$selfenroll,$context)=@_; |
my ($udom,$uname,$url,$role,$deleteflag,$selfenroll,$context)=@_; |
my $now=time; |
my $now=time; |
return &assignrole($udom,$uname,$url,$role,$now,$deleteflag,$selfenroll,$context); |
return &assignrole($udom,$uname,$url,$role,$now,undef,$deleteflag,$selfenroll,$context); |
} |
} |
|
|
# ---------------------------------------------------------- Revoke Custom Role |
# ---------------------------------------------------------- Revoke Custom Role |
Line 6144 sub modify_access_controls {
|
Line 6171 sub modify_access_controls {
|
} |
} |
} |
} |
} |
} |
|
my ($group); |
|
if (&is_course($domain,$user)) { |
|
($group,my $file) = split(/\//,$file_name,2); |
|
} |
$deloutcome = &del('file_permissions',\@deletions,$domain,$user); |
$deloutcome = &del('file_permissions',\@deletions,$domain,$user); |
$new_values{$file_name."\0".'accesscontrol'} = \%new_control; |
$new_values{$file_name."\0".'accesscontrol'} = \%new_control; |
$outcome = &put('file_permissions',\%new_values,$domain,$user); |
$outcome = &put('file_permissions',\%new_values,$domain,$user); |
# remove lock |
# remove lock |
my @del_lock = ($file_name."\0".'locked_access_records'); |
my @del_lock = ($file_name."\0".'locked_access_records'); |
my $dellockoutcome = &del('file_permissions',\@del_lock,$domain,$user); |
my $dellockoutcome = &del('file_permissions',\@del_lock,$domain,$user); |
my ($file,$group); |
|
if (&is_course($domain,$user)) { |
|
($group,$file) = split(/\//,$file_name,2); |
|
} else { |
|
$file = $file_name; |
|
} |
|
my $sqlresult = |
my $sqlresult = |
&update_portfolio_table($user,$domain,$file,'portfolio_access', |
&update_portfolio_table($user,$domain,$file_name,'portfolio_access', |
$group); |
$group); |
} else { |
} else { |
$outcome = "error: could not obtain lockfile\n"; |
$outcome = "error: could not obtain lockfile\n"; |
Line 8535 sub get_dns {
|
Line 8560 sub get_dns {
|
next if ($configline =~ /^(\#|\s*$ )/x); |
next if ($configline =~ /^(\#|\s*$ )/x); |
next if ($configline =~ /^\^/); |
next if ($configline =~ /^\^/); |
chomp($configline); |
chomp($configline); |
my ($id,$domain,$role,$name)=split(/:/,$configline); |
my ($id,$domain,$role,$name,$protocol)=split(/:/,$configline); |
$name=~s/\s//g; |
$name=~s/\s//g; |
if ($id && $domain && $role && $name) { |
if ($id && $domain && $role && $name) { |
$hostname{$id}=$name; |
$hostname{$id}=$name; |
push(@{$name_to_host{$name}}, $id); |
push(@{$name_to_host{$name}}, $id); |
$hostdom{$id}=$domain; |
$hostdom{$id}=$domain; |
if ($role eq 'library') { $libserv{$id}=$name; } |
if ($role eq 'library') { $libserv{$id}=$name; } |
|
if (defined($protocol)) { |
|
if ($protocol eq 'https') { |
|
$protocol{$id} = $protocol; |
|
} else { |
|
$protocol{$id} = 'http'; |
|
} |
|
} else { |
|
$protocol{$id} = 'http'; |
|
} |
} |
} |
} |
} |
} |
} |
Line 8984 when the connection is brought back up
|
Line 9018 when the connection is brought back up
|
=item * B<con_failed>: unable to contact remote host and unable to save message |
=item * B<con_failed>: unable to contact remote host and unable to save message |
for later delivery |
for later delivery |
|
|
=item * B<error:>: an error a occured, a description of the error follows the : |
=item * B<error:>: an error a occurred, a description of the error follows the : |
|
|
=item * B<no_such_host>: unable to fund a host associated with the user/domain |
=item * B<no_such_host>: unable to fund a host associated with the user/domain |
that was requested |
that was requested |
Line 9175 Inputs:
|
Line 9209 Inputs:
|
|
|
=item B<$uname> Student's loncapa login name |
=item B<$uname> Student's loncapa login name |
|
|
=item B<$uid> Student's id/student number |
=item B<$uid> Student/Employee ID |
|
|
=item B<$umode> Student's authentication mode |
=item B<$umode> Student's authentication mode |
|
|
Line 9564 Returns:
|
Line 9598 Returns:
|
'key_exists: <key>' -> failed to anything out of $storehash, as at |
'key_exists: <key>' -> failed to anything out of $storehash, as at |
least <key> already existed in the db (other |
least <key> already existed in the db (other |
requested keys may also already exist) |
requested keys may also already exist) |
'error: <msg>' -> unable to tie the DB or other erorr occured |
'error: <msg>' -> unable to tie the DB or other error occurred |
'con_lost' -> unable to contact request server |
'con_lost' -> unable to contact request server |
'refused' -> action was not allowed by remote machine |
'refused' -> action was not allowed by remote machine |
|
|