[LON-CAPA-cvs] cvs: loncom / lchtmldir lond
foxr
lon-capa-cvs@mail.lon-capa.org
Fri, 03 May 2002 03:21:25 -0000
foxr Thu May 2 23:21:25 2002 EDT
Modified files:
/loncom lond lchtmldir
Log:
Fixes for BUG 259:
lhctmldir - New script to created author construction space directories
for users.
lond - Centralized auth mode info in a sub.
call lchtmldir as appropriate when a user gains authorhip access.
Index: loncom/lond
diff -u loncom/lond:1.77 loncom/lond:1.78
--- loncom/lond:1.77 Sat Apr 27 09:10:47 2002
+++ loncom/lond Thu May 2 23:21:25 2002
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.77 2002/04/27 13:10:47 foxr Exp $
+# $Id: lond,v 1.78 2002/05/03 03:21:25 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -604,21 +604,13 @@
} elsif ($userinput =~ /^currentauth/) {
if ($wasenc==1) {
my ($cmd,$udom,$uname)=split(/:/,$userinput);
- my $proname=propath($udom,$uname);
- my $passfilename="$proname/passwd";
- if (-e $passfilename) {
- my $pf = IO::File->new($passfilename);
- my $realpasswd=<$pf>;
- chomp($realpasswd);
- my ($howpwd,$contentpwd)=split(/:/,$realpasswd);
- my $availablecontent='';
- if ($howpwd eq 'krb4') {
- $availablecontent=$contentpwd;
- }
- print $client "$howpwd:$availablecontent\n";
- } else {
- print $client "unknown_user\n";
- }
+ my $result = GetAuthType($udom, $user);
+ if($result eq "nouser") {
+ print $client "unknown_user\n";
+ }
+ else {
+ print $client "$result\n"
+ }
} else {
print $client "refused\n";
}
@@ -1071,7 +1063,11 @@
if (tie(%hash,'GDBM_File',"$proname/$namespace.db",&GDBM_WRCREAT,0640)) {
foreach $pair (@pairs) {
($key,$value)=split(/=/,$pair);
+ &ManagePermissions($key, $udom, $uname,
+ &GetAuthType( $udom,
+ $uname));
$hash{$key}=$value;
+
}
if (untie(%hash)) {
print $client "ok\n";
@@ -1464,6 +1460,63 @@
# process death.
exit;
}
+}
+
+
+#
+# Checks to see if the input roleput request was to set
+# an author role. If so, invokes the lchtmldir script to set
+# up a correct public_html
+# Parameters:
+# request - The request sent to the rolesput subchunk.
+# We're looking for /domain/_au
+# domain - The domain in which the user is having roles doctored.
+# user - Name of the user for which the role is being put.
+# authtype - The authentication type associated with the user.
+#
+sub ManagePermissions
+{
+ my $request = shift;
+ my $domain = shift;
+ my $user = shift;
+ my $authtype= shift;
+
+ # See if the request is of the form /$domain/_au
+
+ if($request =~ /^(\/$domain\/_au)$/) { # It's an author rolesput...
+ my $execdir = $perlvar{'lonDaemons'};
+ my $userhome= "/home/$user" ;
+ Debug("system $execdir/lchtmldir $userhome $system $authtype");
+ system("$execdir/lchtmldir $userhome $user $authtype");
+ }
+}
+#
+# GetAuthType - Determines the authorization type of a user in a domain.
+
+# Returns the authorization type or nouser if there is no such user.
+#
+sub GetAuthType
+{
+ my $domain = shift;
+ my $user = shift;
+
+ my $proname = &propath($domain, $user);
+ my $passwdfile = "$proname/passwd";
+ if( -e $passwdfile ) {
+ my $pf = IO::File->new($passwdfile);
+ my $realpassword = <$pf>;
+ chomp($realpassword);
+ my ($authtype, $contentpwd) = split(/:/, $realpassword);
+ my $availinfo = '';
+ if($authtype eq 'krb4') {
+ $availinfo = $contentpwd;
+ }
+ return "$authtype:$availinfo";
+ }
+ else {
+ return "nouser";
+ }
+
}
# ----------------------------------- POD (plain old documentation, CPAN style)
Index: loncom/lchtmldir
diff -u loncom/lchtmldir:1.1 loncom/lchtmldir:1.2
--- loncom/lchtmldir:1.1 Sat Apr 27 08:01:50 2002
+++ loncom/lchtmldir Thu May 2 23:21:25 2002
@@ -115,10 +115,10 @@
}
-if( $authentication ne "unix" &&
- $authentication ne "internal" &&
- $authentication ne "krb4" &&
- $authentication ne "localauth") {
+if( $authentication ne "unix:" &&
+ $authentication ne "internal:" &&
+ $authentication ne "krb4:" &&
+ $authentication ne "localauth:") {
if($DEBUG) {
print("Invalid authentication parameter: ".$authentication."\n");
print("Should be one of: unix, internal, krb4, localauth\n");
@@ -211,7 +211,7 @@
# Based on the authentiation mode, set the ownership of the directory.
-if($authentication eq "unix") { # Unix mode authentication...
+if($authentication eq "unix:") { # Unix mode authentication...
&System("/bin/chown -R $username".":".$username." ".$fulldir);
@@ -219,15 +219,15 @@
}
-elsif ($authentication eq "internal") { # Internal authentication.
+elsif ($authentication eq "internal:") { # Internal authentication.
&System("/bin/chown -R www:www $fulldir");
}
-elsif ($authentication eq "krb4") { # Kerberos version 4 authentication
- &System("/bin/chwon -R $username".':'.$username." ".$fulldir);
+elsif ($authentication eq "krb4:") { # Kerberos version 4 authentication
+ &System("/bin/chown -R $username".':'.$username." ".$fulldir);
&JoinGroup($username);
}
-elsif ($authentication eq "localauth") { # Local authentiation
+elsif ($authentication eq "localauth:") { # Local authentiation
&System("/bin/chown -R $username".':'.$username." $fulldir");
}
else {