--- loncom/auth/lonauth.pm 2006/10/06 14:29:44 1.82.2.1 +++ loncom/auth/lonauth.pm 2006/10/06 14:28:45 1.84 @@ -1,7 +1,7 @@ # The LearningOnline Network # User Authentication Module # -# $Id: lonauth.pm,v 1.82.2.1 2006/10/06 14:29:44 albertel Exp $ +# $Id: lonauth.pm,v 1.84 2006/10/06 14:28:45 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -40,7 +40,7 @@ use Apache::lonnet; use Apache::lonmenu(); use Fcntl qw(:flock); use Apache::lonlocal; - +use GDBM_File; my %FORM; # ------------------------------------------------------------ Successful login @@ -171,19 +171,19 @@ sub success { } $env{'user.environment'} = "$lonids/$cookie.id"; - open(my $idf,">$lonids/$cookie.id"); - unless (flock($idf,LOCK_EX)) { + + if (tie(my %disk_env,'GDBM_File',"$lonids/$cookie.id", + &GDBM_WRCREAT(),0640)) { + &add_to_env(\%disk_env,\%initial_env); + &add_to_env(\%disk_env,\%userenv,'environment.'); + &add_to_env(\%disk_env,$userroles); + &add_to_env(\%disk_env,$extra_env); + untie(%disk_env); + } else { &Apache::lonnet::logthis("WARNING: ". - 'Could not obtain exclusive lock in lonauth: '.$!); - close($idf); + 'Could not create environment storage in lonauth: '.$!); return 'error: '.$!; } - - &add_to_env($idf,\%initial_env); - &add_to_env($idf,\%userenv,'environment.'); - &add_to_env($idf,$userroles); - &add_to_env($idf,$extra_env); - close($idf); } $env{'request.role'}='cm'; $env{'request.role.adv'}=$env{'user.adv'}; @@ -252,8 +252,8 @@ ENDSUCCESS sub add_to_env { my ($idf,$env_data,$prefix) = @_; while (my ($key,$value) = each(%$env_data)) { - print $idf (&escape($prefix.$key).'='.&escape($value)."\n"); - $env{$prefix.$key} = $value; + $idf->{$prefix.$key} = $value; + $env{$prefix.$key} = $value; } }