version 1.489.2.41, 2021/06/20 16:24:09
|
version 1.489.2.47, 2024/12/29 16:44:03
|
Line 1795 sub read_lonnet_global {
|
Line 1795 sub read_lonnet_global {
|
} |
} |
if ($what eq 'perlvar') { |
if ($what eq 'perlvar') { |
if (!exists($packagevars{$what}{'lonBalancer'})) { |
if (!exists($packagevars{$what}{'lonBalancer'})) { |
if ($dist =~ /^(centos|rhes|fedora|scientific|oracle)/) { |
if ($dist =~ /^(centos|rhes|fedora|scientific|oracle|rocky|alma)/) { |
my $othervarref=LONCAPA::Configuration::read_conf('httpd.conf'); |
my $othervarref=LONCAPA::Configuration::read_conf('httpd.conf'); |
if (ref($othervarref) eq 'HASH') { |
if (ref($othervarref) eq 'HASH') { |
$items->{'lonBalancer'} = $othervarref->{'lonBalancer'}; |
$items->{'lonBalancer'} = $othervarref->{'lonBalancer'}; |
Line 2407 sub update_passwd_history {
|
Line 2407 sub update_passwd_history {
|
return; |
return; |
} |
} |
|
|
|
sub inst_unamemap_check { |
|
my ($cmd, $tail, $client) = @_; |
|
my $userinput = "$cmd:$tail"; |
|
my %rulecheck; |
|
my $outcome; |
|
my ($udom,$uname,@rules) = split(/:/,$tail); |
|
$udom = &unescape($udom); |
|
$uname = &unescape($uname); |
|
@rules = map {&unescape($_);} (@rules); |
|
eval { |
|
local($SIG{__DIE__})='DEFAULT'; |
|
$outcome = &localenroll::unamemap_check($udom,$uname,\@rules,\%rulecheck); |
|
}; |
|
if (!$@) { |
|
if ($outcome eq 'ok') { |
|
my $result=''; |
|
foreach my $key (keys(%rulecheck)) { |
|
$result.=&escape($key).'='.&Apache::lonnet::freeze_escape($rulecheck{$key}).'&'; |
|
} |
|
&Reply($client,\$result,$userinput); |
|
} else { |
|
&Reply($client,"error\n", $userinput); |
|
} |
|
} else { |
|
&Failure($client,"unknown_cmd\n",$userinput); |
|
} |
|
} |
|
®ister_handler("instunamemapcheck",\&inst_unamemap_check,0,1,0); |
|
|
|
|
# |
# |
# Determines if this is the home server for a user. The home server |
# Determines if this is the home server for a user. The home server |
# for a user will have his/her lon-capa passwd file. Therefore all we need |
# for a user will have his/her lon-capa passwd file. Therefore all we need |
Line 5118 sub tmp_put_handler {
|
Line 5148 sub tmp_put_handler {
|
} |
} |
my ($id,$store); |
my ($id,$store); |
$tmpsnum++; |
$tmpsnum++; |
if (($context eq 'resetpw') || ($context eq 'createaccount')) { |
my $numtries = 0; |
$id = &md5_hex(&md5_hex(time.{}.rand().$$)); |
my $execdir=$perlvar{'lonDaemons'}; |
|
if (($context eq 'resetpw') || ($context eq 'createaccount') || |
|
($context eq 'sso') || ($context eq 'link') || ($context eq 'retry')) { |
|
$id = &md5_hex(&md5_hex(time.{}.rand().$$.$tmpsnum)); |
|
while ((-e "$execdir/tmp/$id.tmp") && ($numtries <10)) { |
|
undef($id); |
|
$id = &md5_hex(&md5_hex(time.{}.rand().$$.$tmpsnum)); |
|
$numtries ++; |
|
} |
} else { |
} else { |
$id = $$.'_'.$clientip.'_'.$tmpsnum; |
$id = $$.'_'.$clientip.'_'.$tmpsnum; |
} |
} |
$id=~s/\W/\_/g; |
$id=~s/\W/\_/g; |
$record=~s/\n//g; |
$record=~s/\n//g; |
my $execdir=$perlvar{'lonDaemons'}; |
if (($id ne '') && |
if ($store=IO::File->new(">$execdir/tmp/$id.tmp")) { |
($store=IO::File->new(">$execdir/tmp/$id.tmp"))) { |
print $store $record; |
print $store $record; |
close $store; |
close $store; |
&Reply($client, \$id, $userinput); |
&Reply($client, \$id, $userinput); |
Line 5453 sub enrollment_enabled_handler {
|
Line 5491 sub enrollment_enabled_handler {
|
my ($cmd, $tail, $client) = @_; |
my ($cmd, $tail, $client) = @_; |
my $userinput = $cmd.":".$tail; # For logging purposes. |
my $userinput = $cmd.":".$tail; # For logging purposes. |
|
|
|
|
my ($cdom) = split(/:/, $tail, 2); # Domain we're asking about. |
my ($cdom) = split(/:/, $tail, 2); # Domain we're asking about. |
|
my $outcome; |
my $outcome = &localenroll::run($cdom); |
eval { |
|
local($SIG{__DIE__})='DEFAULT'; |
|
$outcome = &localenroll::run($cdom); |
|
}; |
&Reply($client, \$outcome, $userinput); |
&Reply($client, \$outcome, $userinput); |
|
|
return 1; |
return 1; |
} |
} |
®ister_handler("autorun", \&enrollment_enabled_handler, 0, 1, 0); |
®ister_handler("autorun", \&enrollment_enabled_handler, 0, 1, 0); |
Line 5491 sub validate_instcode_handler {
|
Line 5530 sub validate_instcode_handler {
|
my ($dom,$instcode,$owner) = split(/:/, $tail); |
my ($dom,$instcode,$owner) = split(/:/, $tail); |
$instcode = &unescape($instcode); |
$instcode = &unescape($instcode); |
$owner = &unescape($owner); |
$owner = &unescape($owner); |
my ($outcome,$description,$credits) = |
my ($outcome,$description,$credits); |
&localenroll::validate_instcode($dom,$instcode,$owner); |
eval { |
|
local($SIG{__DIE__})='DEFAULT'; |
|
($outcome,$description,$credits) = |
|
&localenroll::validate_instcode($dom,$instcode,$owner); |
|
}; |
my $result = &escape($outcome).'&'.&escape($description).'&'. |
my $result = &escape($outcome).'&'.&escape($description).'&'. |
&escape($credits); |
&escape($credits); |
&Reply($client, \$result, $userinput); |
&Reply($client, \$result, $userinput); |
Line 5526 sub validate_instcrosslist_handler {
|
Line 5569 sub validate_instcrosslist_handler {
|
$instcode = &unescape($instcode); |
$instcode = &unescape($instcode); |
$inst_xlist = &unescape($inst_xlist); |
$inst_xlist = &unescape($inst_xlist); |
$coowner = &unescape($coowner); |
$coowner = &unescape($coowner); |
my $outcome = &localenroll::validate_crosslist_access($dom,$instcode, |
my $outcome; |
$inst_xlist,$coowner); |
eval { |
&Reply($client, \$outcome, $userinput); |
local($SIG{__DIE__})='DEFAULT'; |
|
$outcome = &localenroll::validate_crosslist_access($dom,$instcode, |
|
$inst_xlist,$coowner); |
|
}; |
|
|
|
&Reply($client, \$outcome, $userinput); |
return 1; |
return 1; |
} |
} |
®ister_handler("autovalidateinstcrosslist", \&validate_instcrosslist_handler, 0, 1, 0); |
®ister_handler("autovalidateinstcrosslist", \&validate_instcrosslist_handler, 0, 1, 0); |
Line 5552 sub get_sections_handler {
|
Line 5599 sub get_sections_handler {
|
my $userinput = "$cmd:$tail"; |
my $userinput = "$cmd:$tail"; |
|
|
my ($coursecode, $cdom) = split(/:/, $tail); |
my ($coursecode, $cdom) = split(/:/, $tail); |
my @secs = &localenroll::get_sections($coursecode,$cdom); |
my $seclist; |
my $seclist = &escape(join(':',@secs)); |
eval { |
|
local($SIG{__DIE__})='DEFAULT'; |
|
my @secs = &localenroll::get_sections($coursecode,$cdom); |
|
$seclist = &escape(join(':',@secs)); |
|
}; |
&Reply($client, \$seclist, $userinput); |
&Reply($client, \$seclist, $userinput); |
|
|
|
|
return 1; |
return 1; |
} |
} |
®ister_handler("autogetsections", \&get_sections_handler, 0, 1, 0); |
®ister_handler("autogetsections", \&get_sections_handler, 0, 1, 0); |
Line 5577 sub get_sections_handler {
|
Line 5625 sub get_sections_handler {
|
# Returns: |
# Returns: |
# 1 - Processing should continue. |
# 1 - Processing should continue. |
# |
# |
|
|
sub validate_course_owner_handler { |
sub validate_course_owner_handler { |
my ($cmd, $tail, $client) = @_; |
my ($cmd, $tail, $client) = @_; |
my $userinput = "$cmd:$tail"; |
my $userinput = "$cmd:$tail"; |
Line 5584 sub validate_course_owner_handler {
|
Line 5633 sub validate_course_owner_handler {
|
|
|
$owner = &unescape($owner); |
$owner = &unescape($owner); |
$coowners = &unescape($coowners); |
$coowners = &unescape($coowners); |
my $outcome = &localenroll::new_course($inst_course_id,$owner,$cdom,$coowners); |
my $outcome; |
|
eval { |
|
local($SIG{__DIE__})='DEFAULT'; |
|
$outcome = &localenroll::new_course($inst_course_id,$owner,$cdom,$coowners); |
|
}; |
&Reply($client, \$outcome, $userinput); |
&Reply($client, \$outcome, $userinput); |
|
|
|
|
|
|
return 1; |
return 1; |
} |
} |
®ister_handler("autonewcourse", \&validate_course_owner_handler, 0, 1, 0); |
®ister_handler("autonewcourse", \&validate_course_owner_handler, 0, 1, 0); |
Line 5614 sub validate_course_section_handler {
|
Line 5664 sub validate_course_section_handler {
|
my ($cmd, $tail, $client) = @_; |
my ($cmd, $tail, $client) = @_; |
my $userinput = "$cmd:$tail"; |
my $userinput = "$cmd:$tail"; |
my ($inst_course_id, $cdom) = split(/:/, $tail); |
my ($inst_course_id, $cdom) = split(/:/, $tail); |
|
my $outcome; |
my $outcome=&localenroll::validate_courseID($inst_course_id,$cdom); |
eval { |
|
local($SIG{__DIE__})='DEFAULT'; |
|
$outcome=&localenroll::validate_courseID($inst_course_id,$cdom); |
|
}; |
&Reply($client, \$outcome, $userinput); |
&Reply($client, \$outcome, $userinput); |
|
|
|
|
return 1; |
return 1; |
} |
} |
®ister_handler("autovalidatecourse", \&validate_course_section_handler, 0, 1, 0); |
®ister_handler("autovalidatecourse", \&validate_course_section_handler, 0, 1, 0); |
Line 5785 sub create_auto_enroll_password_handler
|
Line 5836 sub create_auto_enroll_password_handler
|
my ($authparam, $cdom) = split(/:/, $userinput); |
my ($authparam, $cdom) = split(/:/, $userinput); |
|
|
my ($create_passwd,$authchk); |
my ($create_passwd,$authchk); |
($authparam, |
eval { |
$create_passwd, |
local($SIG{__DIE__})='DEFAULT'; |
$authchk) = &localenroll::create_password($authparam,$cdom); |
($authparam, |
|
$create_passwd, |
|
$authchk) = &localenroll::create_password($authparam,$cdom); |
|
}; |
&Reply($client, &escape($authparam.':'.$create_passwd.':'.$authchk)."\n", |
&Reply($client, &escape($authparam.':'.$create_passwd.':'.$authchk)."\n", |
$userinput); |
$userinput); |
|
|
Line 6024 sub get_institutional_code_format_handle
|
Line 6077 sub get_institutional_code_format_handle
|
my ($key,$value) = split/=/,$_; |
my ($key,$value) = split/=/,$_; |
$instcodes{&unescape($key)} = &unescape($value); |
$instcodes{&unescape($key)} = &unescape($value); |
} |
} |
my $formatreply = &localenroll::instcode_format($cdom, |
my $formatreply; |
\%instcodes, |
eval { |
\%codes, |
local($SIG{__DIE__})='DEFAULT'; |
\@codetitles, |
$formatreply = &localenroll::instcode_format($cdom, |
\%cat_titles, |
\%instcodes, |
\%cat_order); |
\%codes, |
|
\@codetitles, |
|
\%cat_titles, |
|
\%cat_order); |
|
}; |
if ($formatreply eq 'ok') { |
if ($formatreply eq 'ok') { |
my $codes_str = &Apache::lonnet::hash2str(%codes); |
my $codes_str = &Apache::lonnet::hash2str(%codes); |
my $codetitles_str = &Apache::lonnet::array2str(@codetitles); |
my $codetitles_str = &Apache::lonnet::array2str(@codetitles); |
Line 6089 sub get_possible_instcodes_handler {
|
Line 6146 sub get_possible_instcodes_handler {
|
my $reply; |
my $reply; |
my $cdom = $tail; |
my $cdom = $tail; |
my (@codetitles,%cat_titles,%cat_order,@code_order); |
my (@codetitles,%cat_titles,%cat_order,@code_order); |
my $formatreply = &localenroll::possible_instcodes($cdom, |
my $formatreply; |
\@codetitles, |
eval { |
\%cat_titles, |
local($SIG{__DIE__})='DEFAULT'; |
\%cat_order, |
$formatreply = &localenroll::possible_instcodes($cdom, |
\@code_order); |
\@codetitles, |
|
\%cat_titles, |
|
\%cat_order, |
|
\@code_order); |
|
}; |
if ($formatreply eq 'ok') { |
if ($formatreply eq 'ok') { |
my $result = join('&',map {&escape($_);} (@codetitles)).':'; |
my $result = join('&',map {&escape($_);} (@codetitles)).':'; |
$result .= join('&',map {&escape($_);} (@code_order)).':'; |
$result .= join('&',map {&escape($_);} (@code_order)).':'; |
Line 6217 sub get_institutional_selfcreate_rules {
|
Line 6278 sub get_institutional_selfcreate_rules {
|
} |
} |
®ister_handler("instemailrules",\&get_institutional_selfcreate_rules,0,1,0); |
®ister_handler("instemailrules",\&get_institutional_selfcreate_rules,0,1,0); |
|
|
|
sub get_unamemap_rules { |
|
my ($cmd, $tail, $client) = @_; |
|
my $userinput = "$cmd:$tail"; |
|
my $dom = &unescape($tail); |
|
my (%rules_hash,@rules_order); |
|
my $outcome; |
|
eval { |
|
local($SIG{__DIE__})='DEFAULT'; |
|
$outcome = &localenroll::unamemap_rules($dom,\%rules_hash,\@rules_order); |
|
}; |
|
if (!$@) { |
|
if ($outcome eq 'ok') { |
|
my $result; |
|
foreach my $key (keys(%rules_hash)) { |
|
$result .= &escape($key).'='.&Apache::lonnet::freeze_escape($rules_hash{$key}).'&'; |
|
} |
|
$result =~ s/\&$//; |
|
$result .= ':'; |
|
if (@rules_order > 0) { |
|
foreach my $item (@rules_order) { |
|
$result .= &escape($item).'&'; |
|
} |
|
} |
|
$result =~ s/\&$//; |
|
&Reply($client,\$result,$userinput); |
|
} else { |
|
&Reply($client,"error\n", $userinput); |
|
} |
|
} else { |
|
&Failure($client,"unknown_cmd\n",$userinput); |
|
} |
|
} |
|
®ister_handler("unamemaprules",\&get_unamemap_rules,0,1,0); |
|
|
sub institutional_username_check { |
sub institutional_username_check { |
my ($cmd, $tail, $client) = @_; |
my ($cmd, $tail, $client) = @_; |
Line 6739 undef $perlvarref;
|
Line 6833 undef $perlvarref;
|
# ----------------------------- Make sure this process is running from user=www |
# ----------------------------- Make sure this process is running from user=www |
my $wwwid=getpwnam('www'); |
my $wwwid=getpwnam('www'); |
if ($wwwid!=$<) { |
if ($wwwid!=$<) { |
my $emailto="$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}"; |
my $emailto="$perlvar{'lonAdmEMail'} $perlvar{'lonSysEMail'}"; |
my $subj="LON: $currenthostid User ID mismatch"; |
my $subj="LON: $currenthostid User ID mismatch"; |
system("echo 'User ID mismatch. lond must be run as user www.' |". |
system("echo 'User ID mismatch. lond must be run as user www.' |". |
" mail -s '$subj' $emailto > /dev/null"); |
" mail -s '$subj' $emailto > /dev/null"); |
Line 7192 sub make_new_child {
|
Line 7286 sub make_new_child {
|
&Authen::Krb5::init_context(); |
&Authen::Krb5::init_context(); |
|
|
my $no_ets; |
my $no_ets; |
if ($dist =~ /^(?:centos|rhes|scientific|oracle)(\d+)$/) { |
if ($dist =~ /^(?:centos|rhes|scientific|oracle|rocky|alma)(\d+)/) { |
if ($1 >= 7) { |
if ($1 >= 7) { |
$no_ets = 1; |
$no_ets = 1; |
} |
} |
Line 7358 sub make_new_child {
|
Line 7452 sub make_new_child {
|
Debug("Main: Got $user_input\n"); |
Debug("Main: Got $user_input\n"); |
$keep_going = &process_request($user_input); |
$keep_going = &process_request($user_input); |
alarm(0); |
alarm(0); |
&status('Listening to '.$clientname." ($keymode)"); |
&status('Listening to '.$clientname." ($keymode)"); |
} |
} |
|
|
# --------------------------------------------- client unknown or fishy, refuse |
# --------------------------------------------- client unknown or fishy, refuse |
Line 7374 sub make_new_child {
|
Line 7468 sub make_new_child {
|
|
|
&logthis("<font color='red'>CRITICAL: " |
&logthis("<font color='red'>CRITICAL: " |
."Disconnect from $clientip ($clientname)</font>"); |
."Disconnect from $clientip ($clientname)</font>"); |
|
|
|
|
# this exit is VERY important, otherwise the child will become |
# this exit is VERY important, otherwise the child will become |
# a producer of more and more children, forking yourself into |
# a producer of more and more children, forking yourself into |
# process death. |
# process death. |
Line 7595 sub validate_user {
|
Line 7689 sub validate_user {
|
} elsif ((($domdefaults{'auth_def'} eq 'krb4') || |
} elsif ((($domdefaults{'auth_def'} eq 'krb4') || |
($domdefaults{'auth_def'} eq 'krb5')) && |
($domdefaults{'auth_def'} eq 'krb5')) && |
($domdefaults{'auth_arg_def'} ne '')) { |
($domdefaults{'auth_arg_def'} ne '')) { |
$howpwd = $domdefaults{'auth_def'}; |
# |
$contentpwd = $domdefaults{'auth_arg_def'}; |
# Don't attempt authentication for username and password supplied |
|
# for user without an account if uername contains @ to avoid |
|
# call to &Authen::Krb5::parse_name() which will result in con_lost |
|
# |
|
unless ($user =~ /\@/) { |
|
$howpwd = $domdefaults{'auth_def'}; |
|
$contentpwd = $domdefaults{'auth_arg_def'}; |
|
} |
} |
} |
} |
} |
} |
} |
Line 7940 sub currentversion {
|
Line 8041 sub currentversion {
|
if (-e $ulsdir) { |
if (-e $ulsdir) { |
if(-d $ulsdir) { |
if(-d $ulsdir) { |
if (opendir(LSDIR,$ulsdir)) { |
if (opendir(LSDIR,$ulsdir)) { |
|
if (-e $fname) { |
|
$version=0; |
|
} |
my $ulsfn; |
my $ulsfn; |
while ($ulsfn=readdir(LSDIR)) { |
while ($ulsfn=readdir(LSDIR)) { |
# see if this is a regular file (ignore links produced earlier) |
# see if this is a regular file (ignore links produced earlier) |