version 1.283, 2005/05/02 23:34:41
|
version 1.302, 2005/12/09 20:54:23
|
Line 48 use localauth;
|
Line 48 use localauth;
|
use localenroll; |
use localenroll; |
use localstudentphoto; |
use localstudentphoto; |
use File::Copy; |
use File::Copy; |
|
use File::Find; |
use LONCAPA::ConfigFileEdit; |
use LONCAPA::ConfigFileEdit; |
use LONCAPA::lonlocal; |
use LONCAPA::lonlocal; |
use LONCAPA::lonssl; |
use LONCAPA::lonssl; |
Line 112 my %Dispatcher;
|
Line 113 my %Dispatcher;
|
# |
# |
my $lastpwderror = 13; # Largest error number from lcpasswd. |
my $lastpwderror = 13; # Largest error number from lcpasswd. |
my @passwderrors = ("ok", |
my @passwderrors = ("ok", |
"lcpasswd must be run as user 'www'", |
"pwchange_failure - lcpasswd must be run as user 'www'", |
"lcpasswd got incorrect number of arguments", |
"pwchange_failure - lcpasswd got incorrect number of arguments", |
"lcpasswd did not get the right nubmer of input text lines", |
"pwchange_failure - lcpasswd did not get the right nubmer of input text lines", |
"lcpasswd too many simultaneous pwd changes in progress", |
"pwchange_failure - lcpasswd too many simultaneous pwd changes in progress", |
"lcpasswd User does not exist.", |
"pwchange_failure - lcpasswd User does not exist.", |
"lcpasswd Incorrect current passwd", |
"pwchange_failure - lcpasswd Incorrect current passwd", |
"lcpasswd Unable to su to root.", |
"pwchange_failure - lcpasswd Unable to su to root.", |
"lcpasswd Cannot set new passwd.", |
"pwchange_failure - lcpasswd Cannot set new passwd.", |
"lcpasswd Username has invalid characters", |
"pwchange_failure - lcpasswd Username has invalid characters", |
"lcpasswd Invalid characters in password", |
"pwchange_failure - lcpasswd Invalid characters in password", |
"lcpasswd User already exists", |
"pwchange_failure - lcpasswd User already exists", |
"lcpasswd Something went wrong with user addition.", |
"pwchange_failure - lcpasswd Something went wrong with user addition.", |
"lcpasswd Password mismatch", |
"pwchange_failure - lcpasswd Password mismatch", |
"lcpasswd Error filename is invalid"); |
"pwchange_failure - lcpasswd Error filename is invalid"); |
|
|
|
|
# The array below are lcuseradd error strings.: |
# The array below are lcuseradd error strings.: |
Line 1363 sub du_handler {
|
Line 1364 sub du_handler {
|
# etc. |
# etc. |
# |
# |
if (-d $ududir) { |
if (-d $ududir) { |
# And as Shakespeare would say to make |
my $total_size=0; |
# assurance double sure, |
my $code=sub { |
# use execute_command to ensure that the command is not executed in |
if ($_=~/\.\d+\./) { return;} |
# a shell that can screw us up. |
if ($_=~/\.meta$/) { return;} |
|
$total_size+=(stat($_))[7]; |
my $duout = execute_command("du -ks $ududir"); |
}; |
$duout=~s/[^\d]//g; #preserve only the numbers |
chdir($ududir); |
&Reply($client,"$duout\n","$cmd:$ududir"); |
find($code,$ududir); |
|
$total_size=int($total_size/1024); |
|
&Reply($client,"$total_size\n","$cmd:$ududir"); |
} else { |
} else { |
|
|
&Failure($client, "bad_directory:$ududir\n","$cmd:$ududir"); |
&Failure($client, "bad_directory:$ududir\n","$cmd:$ududir"); |
|
|
} |
} |
return 1; |
return 1; |
} |
} |
Line 1413 sub ls_handler {
|
Line 1414 sub ls_handler {
|
if(-d $ulsdir) { |
if(-d $ulsdir) { |
if (opendir(LSDIR,$ulsdir)) { |
if (opendir(LSDIR,$ulsdir)) { |
while ($ulsfn=readdir(LSDIR)) { |
while ($ulsfn=readdir(LSDIR)) { |
undef $obs, $rights; |
undef($obs); |
|
undef($rights); |
my @ulsstats=stat($ulsdir.'/'.$ulsfn); |
my @ulsstats=stat($ulsdir.'/'.$ulsfn); |
#We do some obsolete checking here |
#We do some obsolete checking here |
if(-e $ulsdir.'/'.$ulsfn.".meta") { |
if(-e $ulsdir.'/'.$ulsfn.".meta") { |
open(FILE, $ulsdir.'/'.$ulsfn.".meta"); |
open(FILE, $ulsdir.'/'.$ulsfn.".meta"); |
my @obsolete=<FILE>; |
my @obsolete=<FILE>; |
foreach my $obsolete (@obsolete) { |
foreach my $obsolete (@obsolete) { |
if($obsolete =~ m|(<obsolete>)(on)|) { $obs = 1; } |
if($obsolete =~ m/(<obsolete>)(on|1)/) { $obs = 1; } |
if($obsolete =~ m|(<copyright>)(default)|) { $rights = 1; } |
if($obsolete =~ m|(<copyright>)(default)|) { $rights = 1; } |
} |
} |
} |
} |
Line 1480 sub ls2_handler {
|
Line 1482 sub ls2_handler {
|
if(-d $ulsdir) { |
if(-d $ulsdir) { |
if (opendir(LSDIR,$ulsdir)) { |
if (opendir(LSDIR,$ulsdir)) { |
while ($ulsfn=readdir(LSDIR)) { |
while ($ulsfn=readdir(LSDIR)) { |
undef $obs, $rights; |
undef($obs); |
|
undef($rights); |
my @ulsstats=stat($ulsdir.'/'.$ulsfn); |
my @ulsstats=stat($ulsdir.'/'.$ulsfn); |
#We do some obsolete checking here |
#We do some obsolete checking here |
if(-e $ulsdir.'/'.$ulsfn.".meta") { |
if(-e $ulsdir.'/'.$ulsfn.".meta") { |
open(FILE, $ulsdir.'/'.$ulsfn.".meta"); |
open(FILE, $ulsdir.'/'.$ulsfn.".meta"); |
my @obsolete=<FILE>; |
my @obsolete=<FILE>; |
foreach my $obsolete (@obsolete) { |
foreach my $obsolete (@obsolete) { |
if($obsolete =~ m|(<obsolete>)(on)|) { $obs = 1; } |
if($obsolete =~ m/(<obsolete>)(on|1)/) { $obs = 1; } |
if($obsolete =~ m|(<copyright>)(default)|) { |
if($obsolete =~ m|(<copyright>)(default)|) { |
$rights = 1; |
$rights = 1; |
} |
} |
Line 1701 sub change_password_handler {
|
Line 1704 sub change_password_handler {
|
&Failure( $client, "non_authorized\n",$userinput); |
&Failure( $client, "non_authorized\n",$userinput); |
} |
} |
} elsif ($howpwd eq 'unix') { |
} elsif ($howpwd eq 'unix') { |
# Unix means we have to access /etc/password |
my $result = &change_unix_password($uname, $npass); |
&Debug("auth is unix"); |
|
my $execdir=$perlvar{'lonDaemons'}; |
|
&Debug("Opening lcpasswd pipeline"); |
|
my $pf = IO::File->new("|$execdir/lcpasswd > " |
|
."$perlvar{'lonDaemons'}" |
|
."/logs/lcpasswd.log"); |
|
print $pf "$uname\n$npass\n$npass\n"; |
|
close $pf; |
|
my $err = $?; |
|
my $result = ($err>0 ? 'pwchange_failure' : 'ok'); |
|
&logthis("Result of password change for $uname: ". |
&logthis("Result of password change for $uname: ". |
&lcpasswdstrerror($?)); |
$result); |
&Reply($client, "$result\n", $userinput); |
&Reply($client, "$result\n", $userinput); |
} else { |
} else { |
# this just means that the current password mode is not |
# this just means that the current password mode is not |
Line 1812 sub add_user_handler {
|
Line 1805 sub add_user_handler {
|
# Implicit inputs: |
# Implicit inputs: |
# The authentication systems describe above have their own forms of implicit |
# The authentication systems describe above have their own forms of implicit |
# input into the authentication process that are described above. |
# input into the authentication process that are described above. |
|
# NOTE: |
|
# This is also used to change the authentication credential values (e.g. passwd). |
|
# |
# |
# |
sub change_authentication_handler { |
sub change_authentication_handler { |
|
|
Line 1831 sub change_authentication_handler {
|
Line 1827 sub change_authentication_handler {
|
my $oldauth = &get_auth_type($udom, $uname); # Get old auth info. |
my $oldauth = &get_auth_type($udom, $uname); # Get old auth info. |
my $passfilename = &password_path($udom, $uname); |
my $passfilename = &password_path($udom, $uname); |
if ($passfilename) { # Not allowed to create a new user!! |
if ($passfilename) { # Not allowed to create a new user!! |
my $result=&make_passwd_file($uname, $umode,$npass,$passfilename); |
# If just changing the unix passwd. need to arrange to run |
# |
# passwd since otherwise make_passwd_file will run |
# If the current auth mode is internal, and the old auth mode was |
# lcuseradd which fails if an account already exists |
# unix, or krb*, and the user is an author for this domain, |
# (to prevent an unscrupulous LONCAPA admin from stealing |
# re-run manage_permissions for that role in order to be able |
# an existing account by overwriting it as a LonCAPA account). |
# to take ownership of the construction space back to www:www |
|
# |
if(($oldauth =~/^unix/) && ($umode eq "unix")) { |
|
my $result = &change_unix_password($uname, $npass); |
if( (($oldauth =~ /^unix/) && ($umode eq "internal")) || |
&logthis("Result of password change for $uname: ".$result); |
(($oldauth =~ /^internal/) && ($umode eq "unix")) ) { |
if ($result eq "ok") { |
if(&is_author($udom, $uname)) { |
&Reply($client, "$result\n") |
&Debug(" Need to manage author permissions..."); |
} else { |
&manage_permissions("/$udom/_au", $udom, $uname, "$umode:"); |
&Failure($client, "$result\n"); |
} |
} |
|
} else { |
|
my $result=&make_passwd_file($uname, $umode,$npass,$passfilename); |
|
# |
|
# If the current auth mode is internal, and the old auth mode was |
|
# unix, or krb*, and the user is an author for this domain, |
|
# re-run manage_permissions for that role in order to be able |
|
# to take ownership of the construction space back to www:www |
|
# |
|
|
|
|
|
if( (($oldauth =~ /^unix/) && ($umode eq "internal")) || |
|
(($oldauth =~ /^internal/) && ($umode eq "unix")) ) { |
|
if(&is_author($udom, $uname)) { |
|
&Debug(" Need to manage author permissions..."); |
|
&manage_permissions("/$udom/_au", $udom, $uname, "$umode:"); |
|
} |
|
} |
|
&Reply($client, $result, $userinput); |
} |
} |
|
|
|
|
&Reply($client, $result, $userinput); |
|
} else { |
} else { |
&Failure($client, "non_authorized\n", $userinput); # Fail the user now. |
&Failure($client, "non_authorized\n", $userinput); # Fail the user now. |
} |
} |
Line 1960 sub update_resource_handler {
|
Line 1973 sub update_resource_handler {
|
alarm(0); |
alarm(0); |
} |
} |
rename($transname,$fname); |
rename($transname,$fname); |
|
use Cache::Memcached; |
|
my $memcache= |
|
new Cache::Memcached({'servers'=>['127.0.0.1:11211']}); |
|
my $url=$fname; |
|
$url=~s-^/home/httpd/html--; |
|
my $id=&escape('meta:'.$url); |
|
$memcache->delete($id); |
} |
} |
} |
} |
&Reply( $client, "ok\n", $userinput); |
&Reply( $client, "ok\n", $userinput); |
Line 2445 sub increment_user_value_handler {
|
Line 2465 sub increment_user_value_handler {
|
my @pairs=split(/\&/,$what); |
my @pairs=split(/\&/,$what); |
foreach my $pair (@pairs) { |
foreach my $pair (@pairs) { |
my ($key,$value)=split(/=/,$pair); |
my ($key,$value)=split(/=/,$pair); |
|
$value = &unescape($value); |
# We could check that we have a number... |
# We could check that we have a number... |
if (! defined($value) || $value eq '') { |
if (! defined($value) || $value eq '') { |
$value = 1; |
$value = 1; |
} |
} |
$hashref->{$key}+=$value; |
$hashref->{$key}+=$value; |
|
if ($namespace eq 'nohist_resourcetracker') { |
|
if ($hashref->{$key} < 0) { |
|
$hashref->{$key} = 0; |
|
} |
|
} |
} |
} |
if (untie(%$hashref)) { |
if (untie(%$hashref)) { |
&Reply( $client, "ok\n", $userinput); |
&Reply( $client, "ok\n", $userinput); |
Line 3483 sub get_id_handler {
|
Line 3509 sub get_id_handler {
|
®ister_handler("idget", \&get_id_handler, 0, 1, 0); |
®ister_handler("idget", \&get_id_handler, 0, 1, 0); |
|
|
# |
# |
|
# Puts broadcast e-mail sent by Domain Coordinator in nohist_dcmail database |
|
# |
|
# Parameters |
|
# $cmd - Command keyword that caused us to be dispatched. |
|
# $tail - Tail of the command. Consists of a colon separated: |
|
# domain - the domain whose dcmail we are recording |
|
# email Consists of key=value pair |
|
# where key is unique msgid |
|
# and value is message (in XML) |
|
# $client - Socket open on the client. |
|
# |
|
# Returns: |
|
# 1 - indicating processing should continue. |
|
# Side effects |
|
# reply is written to $client. |
|
# |
|
sub put_dcmail_handler { |
|
my ($cmd,$tail,$client) = @_; |
|
my $userinput = "$cmd:$tail"; |
|
|
|
my ($udom,$what)=split(/:/,$tail); |
|
chomp($what); |
|
my $hashref = &tie_domain_hash($udom, "nohist_dcmail", &GDBM_WRCREAT()); |
|
if ($hashref) { |
|
my ($key,$value)=split(/=/,$what); |
|
$hashref->{$key}=$value; |
|
} |
|
if (untie(%$hashref)) { |
|
&Reply($client, "ok\n", $userinput); |
|
} else { |
|
&Failure($client, "error: ".($!+0)." untie(GDBM) Failed ". |
|
"while attempting dcmailput\n", $userinput); |
|
} |
|
return 1; |
|
} |
|
®ister_handler("dcmailput", \&put_dcmail_handler, 0, 1, 0); |
|
|
|
# |
|
# Retrieves broadcast e-mail from nohist_dcmail database |
|
# Returns to client an & separated list of key=value pairs, |
|
# where key is msgid and value is message information. |
|
# |
|
# Parameters |
|
# $cmd - Command keyword that caused us to be dispatched. |
|
# $tail - Tail of the command. Consists of a colon separated: |
|
# domain - the domain whose dcmail table we dump |
|
# startfilter - beginning of time window |
|
# endfilter - end of time window |
|
# sendersfilter - & separated list of username:domain |
|
# for senders to search for. |
|
# $client - Socket open on the client. |
|
# |
|
# Returns: |
|
# 1 - indicating processing should continue. |
|
# Side effects |
|
# reply (& separated list of msgid=messageinfo pairs) is |
|
# written to $client. |
|
# |
|
sub dump_dcmail_handler { |
|
my ($cmd, $tail, $client) = @_; |
|
|
|
my $userinput = "$cmd:$tail"; |
|
my ($udom,$startfilter,$endfilter,$sendersfilter) = split(/:/,$tail); |
|
chomp($sendersfilter); |
|
my @senders = (); |
|
if (defined($startfilter)) { |
|
$startfilter=&unescape($startfilter); |
|
} else { |
|
$startfilter='.'; |
|
} |
|
if (defined($endfilter)) { |
|
$endfilter=&unescape($endfilter); |
|
} else { |
|
$endfilter='.'; |
|
} |
|
if (defined($sendersfilter)) { |
|
$sendersfilter=&unescape($sendersfilter); |
|
@senders = map { &unescape($_) } split(/\&/,$sendersfilter); |
|
} |
|
|
|
my $qresult=''; |
|
my $hashref = &tie_domain_hash($udom, "nohist_dcmail", &GDBM_WRCREAT()); |
|
if ($hashref) { |
|
while (my ($key,$value) = each(%$hashref)) { |
|
my $match = 1; |
|
$key = &unescape($key); |
|
my ($timestamp,$subj,$uname,$udom) = split(/:/,&unescape($key),5); |
|
$timestamp = &unescape($timestamp); |
|
$subj = &unescape($subj); |
|
$uname = &unescape($uname); |
|
$udom = &unescape($udom); |
|
unless ($startfilter eq '.' || !defined($startfilter)) { |
|
if ($timestamp < $startfilter) { |
|
$match = 0; |
|
} |
|
} |
|
unless ($endfilter eq '.' || !defined($endfilter)) { |
|
if ($timestamp > $endfilter) { |
|
$match = 0; |
|
} |
|
} |
|
unless (@senders < 1) { |
|
unless (grep/^$uname:$udom$/,@senders) { |
|
$match = 0; |
|
} |
|
} |
|
if ($match == 1) { |
|
$qresult.=$key.'='.$value.'&'; |
|
} |
|
} |
|
if (untie(%$hashref)) { |
|
chop($qresult); |
|
&Reply($client, "$qresult\n", $userinput); |
|
} else { |
|
&Failure($client, "error: ".($!+0)." untie(GDBM) Failed ". |
|
"while attempting dcmaildump\n", $userinput); |
|
} |
|
} else { |
|
&Failure($client, "error: ".($!+0)." tie(GDBM) Failed ". |
|
"while attempting dcmaildump\n", $userinput); |
|
} |
|
return 1; |
|
} |
|
|
|
®ister_handler("dcmaildump", \&dump_dcmail_handler, 0, 1, 0); |
|
|
|
# |
|
# Puts domain roles in nohist_domainroles database |
|
# |
|
# Parameters |
|
# $cmd - Command keyword that caused us to be dispatched. |
|
# $tail - Tail of the command. Consists of a colon separated: |
|
# domain - the domain whose roles we are recording |
|
# role - Consists of key=value pair |
|
# where key is unique role |
|
# and value is start/end date information |
|
# $client - Socket open on the client. |
|
# |
|
# Returns: |
|
# 1 - indicating processing should continue. |
|
# Side effects |
|
# reply is written to $client. |
|
# |
|
|
|
sub put_domainroles_handler { |
|
my ($cmd,$tail,$client) = @_; |
|
|
|
my $userinput = "$cmd:$tail"; |
|
my ($udom,$what)=split(/:/,$tail); |
|
chomp($what); |
|
my @pairs=split(/\&/,$what); |
|
my $hashref = &tie_domain_hash($udom, "nohist_domainroles", &GDBM_WRCREAT()); |
|
if ($hashref) { |
|
foreach my $pair (@pairs) { |
|
my ($key,$value)=split(/=/,$pair); |
|
$hashref->{$key}=$value; |
|
} |
|
if (untie(%$hashref)) { |
|
&Reply($client, "ok\n", $userinput); |
|
} else { |
|
&Failure($client, "error: ".($!+0)." untie(GDBM) Failed ". |
|
"while attempting domroleput\n", $userinput); |
|
} |
|
} else { |
|
&Failure( $client, "error: ".($!+0)." tie(GDBM) Failed ". |
|
"while attempting domroleput\n", $userinput); |
|
} |
|
|
|
return 1; |
|
} |
|
|
|
®ister_handler("domroleput", \&put_domainroles_handler, 0, 1, 0); |
|
|
|
# |
|
# Retrieves domain roles from nohist_domainroles database |
|
# Returns to client an & separated list of key=value pairs, |
|
# where key is role and value is start and end date information. |
|
# |
|
# Parameters |
|
# $cmd - Command keyword that caused us to be dispatched. |
|
# $tail - Tail of the command. Consists of a colon separated: |
|
# domain - the domain whose domain roles table we dump |
|
# $client - Socket open on the client. |
|
# |
|
# Returns: |
|
# 1 - indicating processing should continue. |
|
# Side effects |
|
# reply (& separated list of role=start/end info pairs) is |
|
# written to $client. |
|
# |
|
sub dump_domainroles_handler { |
|
my ($cmd, $tail, $client) = @_; |
|
|
|
my $userinput = "$cmd:$tail"; |
|
my ($udom,$startfilter,$endfilter,$rolesfilter) = split(/:/,$tail); |
|
chomp($rolesfilter); |
|
my @roles = (); |
|
if (defined($startfilter)) { |
|
$startfilter=&unescape($startfilter); |
|
} else { |
|
$startfilter='.'; |
|
} |
|
if (defined($endfilter)) { |
|
$endfilter=&unescape($endfilter); |
|
} else { |
|
$endfilter='.'; |
|
} |
|
if (defined($rolesfilter)) { |
|
$rolesfilter=&unescape($rolesfilter); |
|
@roles = split(/\&/,$rolesfilter); |
|
} |
|
|
|
my $hashref = &tie_domain_hash($udom, "nohist_domainroles", &GDBM_WRCREAT()); |
|
if ($hashref) { |
|
my $qresult = ''; |
|
while (my ($key,$value) = each(%$hashref)) { |
|
my $match = 1; |
|
my ($start,$end) = split(/:/,&unescape($value)); |
|
my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,&unescape($key)); |
|
unless ($startfilter eq '.' || !defined($startfilter)) { |
|
if ($start >= $startfilter) { |
|
$match = 0; |
|
} |
|
} |
|
unless ($endfilter eq '.' || !defined($endfilter)) { |
|
if ($end <= $endfilter) { |
|
$match = 0; |
|
} |
|
} |
|
unless (@roles < 1) { |
|
unless (grep/^$trole$/,@roles) { |
|
$match = 0; |
|
} |
|
} |
|
if ($match == 1) { |
|
$qresult.=$key.'='.$value.'&'; |
|
} |
|
} |
|
if (untie(%$hashref)) { |
|
chop($qresult); |
|
&Reply($client, "$qresult\n", $userinput); |
|
} else { |
|
&Failure($client, "error: ".($!+0)." untie(GDBM) Failed ". |
|
"while attempting domrolesdump\n", $userinput); |
|
} |
|
} else { |
|
&Failure($client, "error: ".($!+0)." tie(GDBM) Failed ". |
|
"while attempting domrolesdump\n", $userinput); |
|
} |
|
return 1; |
|
} |
|
|
|
®ister_handler("domrolesdump", \&dump_domainroles_handler, 0, 1, 0); |
|
|
|
|
# Process the tmpput command I'm not sure what this does.. Seems to |
# Process the tmpput command I'm not sure what this does.. Seems to |
# create a file in the lonDaemons/tmp directory of the form $id.tmp |
# create a file in the lonDaemons/tmp directory of the form $id.tmp |
# where Id is the client's ip concatenated with a sequence number. |
# where Id is the client's ip concatenated with a sequence number. |
Line 4386 sub ReadHostTable {
|
Line 4667 sub ReadHostTable {
|
open (CONFIG,"$perlvar{'lonTabDir'}/hosts.tab") || die "Can't read host file"; |
open (CONFIG,"$perlvar{'lonTabDir'}/hosts.tab") || die "Can't read host file"; |
my $myloncapaname = $perlvar{'lonHostID'}; |
my $myloncapaname = $perlvar{'lonHostID'}; |
Debug("My loncapa name is : $myloncapaname"); |
Debug("My loncapa name is : $myloncapaname"); |
|
my %name_to_ip; |
while (my $configline=<CONFIG>) { |
while (my $configline=<CONFIG>) { |
if ($configline !~ /^\s*\#/ && $configline !~ /^\s*$/ ) { |
if ($configline !~ /^\s*\#/ && $configline !~ /^\s*$/ ) { |
my ($id,$domain,$role,$name)=split(/:/,$configline); |
my ($id,$domain,$role,$name)=split(/:/,$configline); |
$name=~s/\s//g; |
$name=~s/\s//g; |
my $ip = gethostbyname($name); |
my $ip; |
if (length($ip) ne 4) { |
if (!exists($name_to_ip{$name})) { |
&logthis("Skipping host $id name $name no IP $ip found\n"); |
$ip = gethostbyname($name); |
next; |
if (!$ip || length($ip) ne 4) { |
|
&logthis("Skipping host $id name $name no IP found\n"); |
|
next; |
|
} |
|
$ip=inet_ntoa($ip); |
|
$name_to_ip{$name} = $ip; |
|
} else { |
|
$ip = $name_to_ip{$name}; |
} |
} |
$ip=inet_ntoa($ip); |
|
$hostid{$ip}=$id; # LonCAPA name of host by IP. |
$hostid{$ip}=$id; # LonCAPA name of host by IP. |
$hostdom{$id}=$domain; # LonCAPA domain name of host. |
$hostdom{$id}=$domain; # LonCAPA domain name of host. |
$hostip{$id}=$ip; # IP address of host. |
$hostip{$id}=$ip; # IP address of host. |
Line 4762 $SIG{USR2} = \&UpdateHosts;
|
Line 5050 $SIG{USR2} = \&UpdateHosts;
|
|
|
ReadHostTable; |
ReadHostTable; |
|
|
|
my $dist=`$perlvar{'lonDaemons'}/distprobe`; |
|
|
# -------------------------------------------------------------- |
# -------------------------------------------------------------- |
# Accept connections. When a connection comes in, it is validated |
# Accept connections. When a connection comes in, it is validated |
# and if good, a child process is created to process transactions |
# and if good, a child process is created to process transactions |
Line 4837 sub make_new_child {
|
Line 5127 sub make_new_child {
|
# my $tmpsnum=0; # Now global |
# my $tmpsnum=0; # Now global |
#---------------------------------------------------- kerberos 5 initialization |
#---------------------------------------------------- kerberos 5 initialization |
&Authen::Krb5::init_context(); |
&Authen::Krb5::init_context(); |
&Authen::Krb5::init_ets(); |
unless (($dist eq 'fedora4') || ($dist eq 'suse9.3')) { |
|
&Authen::Krb5::init_ets(); |
|
} |
|
|
&status('Accepted connection'); |
&status('Accepted connection'); |
# ============================================================================= |
# ============================================================================= |
Line 5047 sub is_author {
|
Line 5339 sub is_author {
|
# user - Name of the user for which the role is being put. |
# user - Name of the user for which the role is being put. |
# authtype - The authentication type associated with the user. |
# authtype - The authentication type associated with the user. |
# |
# |
sub manage_permissions |
sub manage_permissions { |
{ |
|
|
|
|
|
my ($request, $domain, $user, $authtype) = @_; |
my ($request, $domain, $user, $authtype) = @_; |
|
|
&Debug("manage_permissions: $request $domain $user $authtype"); |
&Debug("manage_permissions: $request $domain $user $authtype"); |
|
|
# See if the request is of the form /$domain/_au |
# See if the request is of the form /$domain/_au |
if($request =~ /^(\/$domain\/_au)$/) { # It's an author rolesput... |
if($request =~ /^(\/\Q$domain\E\/_au)$/) { # It's an author rolesput... |
my $execdir = $perlvar{'lonDaemons'}; |
my $execdir = $perlvar{'lonDaemons'}; |
my $userhome= "/home/$user" ; |
my $userhome= "/home/$user" ; |
&logthis("system $execdir/lchtmldir $userhome $user $authtype"); |
&logthis("system $execdir/lchtmldir $userhome $user $authtype"); |
Line 5449 sub thisversion {
|
Line 5738 sub thisversion {
|
sub subscribe { |
sub subscribe { |
my ($userinput,$clientip)=@_; |
my ($userinput,$clientip)=@_; |
my $result; |
my $result; |
my ($cmd,$fname)=split(/:/,$userinput); |
my ($cmd,$fname)=split(/:/,$userinput,2); |
my $ownership=&ishome($fname); |
my $ownership=&ishome($fname); |
if ($ownership eq 'owner') { |
if ($ownership eq 'owner') { |
# explitly asking for the current version? |
# explitly asking for the current version? |
Line 5493 sub subscribe {
|
Line 5782 sub subscribe {
|
} |
} |
return $result; |
return $result; |
} |
} |
|
# Change the passwd of a unix user. The caller must have |
|
# first verified that the user is a loncapa user. |
|
# |
|
# Parameters: |
|
# user - Unix user name to change. |
|
# pass - New password for the user. |
|
# Returns: |
|
# ok - if success |
|
# other - Some meaningfule error message string. |
|
# NOTE: |
|
# invokes a setuid script to change the passwd. |
|
sub change_unix_password { |
|
my ($user, $pass) = @_; |
|
|
|
&Debug("change_unix_password"); |
|
my $execdir=$perlvar{'lonDaemons'}; |
|
&Debug("Opening lcpasswd pipeline"); |
|
my $pf = IO::File->new("|$execdir/lcpasswd > " |
|
."$perlvar{'lonDaemons'}" |
|
."/logs/lcpasswd.log"); |
|
print $pf "$user\n$pass\n$pass\n"; |
|
close $pf; |
|
my $err = $?; |
|
return ($err < @passwderrors) ? $passwderrors[$err] : |
|
"pwchange_falure - unknown error"; |
|
|
|
|
|
} |
|
|
|
|
sub make_passwd_file { |
sub make_passwd_file { |
my ($uname, $umode,$npass,$passfilename)=@_; |
my ($uname, $umode,$npass,$passfilename)=@_; |
Line 5552 sub make_passwd_file {
|
Line 5870 sub make_passwd_file {
|
print $se "$npass\n"; |
print $se "$npass\n"; |
print $se "$lc_error_file\n"; # Status -> unique file. |
print $se "$lc_error_file\n"; # Status -> unique file. |
} |
} |
my $error = IO::File->new("< $lc_error_file"); |
if (-r $lc_error_file) { |
my $useraddok = <$error>; |
&Debug("Opening error file: $lc_error_file"); |
$error->close; |
my $error = IO::File->new("< $lc_error_file"); |
unlink($lc_error_file); |
my $useraddok = <$error>; |
|
$error->close; |
chomp $useraddok; |
unlink($lc_error_file); |
|
|
if($useraddok > 0) { |
chomp $useraddok; |
my $error_text = &lcuseraddstrerror($useraddok); |
|
&logthis("Failed lcuseradd: $error_text"); |
if($useraddok > 0) { |
$result = "lcuseradd_failed:$error_text\n"; |
my $error_text = &lcuseraddstrerror($useraddok); |
} else { |
&logthis("Failed lcuseradd: $error_text"); |
my $pf = IO::File->new(">$passfilename"); |
$result = "lcuseradd_failed:$error_text\n"; |
if($pf) { |
} else { |
print $pf "unix:\n"; |
my $pf = IO::File->new(">$passfilename"); |
} else { |
if($pf) { |
$result = "pass_file_failed_error"; |
print $pf "unix:\n"; |
|
} else { |
|
$result = "pass_file_failed_error"; |
|
} |
} |
} |
|
} else { |
|
&Debug("Could not locate lcuseradd error: $lc_error_file"); |
|
$result="bug_lcuseradd_no_output_file"; |
} |
} |
} |
} |
} elsif ($umode eq 'none') { |
} elsif ($umode eq 'none') { |