Index: ossp-pkg/tabea/tabea.cgi RCS File: /v/ossp/cvs/ossp-pkg/tabea/tabea.cgi,v rcsdiff -q -kk '-r1.34' '-r1.35' -u '/v/ossp/cvs/ossp-pkg/tabea/tabea.cgi,v' 2>/dev/null --- tabea.cgi 2002/07/05 13:06:35 1.34 +++ tabea.cgi 2002/07/09 15:08:02 1.35 @@ -257,6 +257,8 @@ " " . " " . "" ; + + &logging("Starting program"); return $text; } @@ -274,10 +276,13 @@ if (! &validpassword($username, $password, $cfghash{'BaseDir'}.$cfghash{'PasswdFile'}) ) { $cgi->param(-name => 'username', -value => ""); $cgi->param(-name => 'password', -value => ""); + &logging("User $username password error"); $form = ''; goto NEXTFORM; } + &logging("User $username login successfull"); + my $templatesfiles = &get_name_files($cfghash{'BaseDir'} . $cfghash{'ConfigDir'}, $username, 4); my $configsfiles = &get_name_files($cfghash{'BaseDir'} . $cfghash{'ConfigDir'}, $username, 6); @@ -446,9 +451,11 @@ my $filename = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $editfile; $text .= &editconfig($filename, 'w', $username) . $cgi->hidden(-name => 'editfile', -default => $filename ); + &logging("Edit file $filename"); } else { $text .= "Missing filename

\n" . $cgi->submit(-name => 'dialog_mainw', -value => 'Back'); + &logging("Missing filename"); } return $text; @@ -478,9 +485,12 @@ $password = ""; } + &logging("Saving $file"); + goto NEXTFORM; } else { $text .= "Cannot save file

\n"; + &logging("Cannot save $file"); } $text .= $cgi->submit(-name => 'dialog_mainw', -value => 'Back'); @@ -588,14 +598,17 @@ } $text .= "Creating the new file $newpath

"; system("touch $newpath") && die "Cannot create new file"; + &logging("Creating new file $newpath"); $text .= "Setting new file rights for $newpath

"; system("chmod u=rw $newpath") && die "Cannot set new file rights"; system("chmod o=$filerights $newpath") && die "Cannot set new file rights"; + &logging("Changing filerights of $newpath"); $text .= "


"; $form = 'mainw'; goto NEXTFORM; } else { $text .= "Cannot write file. File exists

\n"; + &logging("Cannot write $newpath File exists"); } $text .= $cgi->submit(-name => 'dialog_mainw', -value => 'Back'); @@ -652,11 +665,13 @@ else { $text .= "You can only change file rights in your own directory

\n" . $cgi->submit(-name => 'dialog', -value => 'Back'); + &logging("Changing filerights of $namefile not allowed"); } } else { $text .= "Missing filename

\n" . $cgi->submit(-name => 'dialog_mainw', -value => 'Back'); + &logging("Cannot change rights of empty filename"); } return $text; @@ -686,8 +701,10 @@ } else { die "Unknown file rights"; + &logging("Cannot change to unknown file rights"); } system("chmod o=$filerights $filename") && die "Cannot set new file rights"; + &logging("Changing file rights of $filename to $newrights"); $form = 'mainw'; goto NEXTFORM; @@ -772,15 +789,18 @@ $delfile =~ m{^([a-zA-Z0-9!"$%^&*()-_=+#~]+)/(.+)}sg; if ($1 eq $username) { system("rm $fpath") && die "Cannot delete file"; + &logging("Deleting $fpath"); $form = 'mainw'; goto NEXTFORM; } else { $text .= "You can only delete file in your own directory

\n"; + &loggong("Just delete your own files not $fpath"); } } else { $text .= "Missing filename

\n"; + &loggin("Missing filename"); } $text .= $cgi->submit(-name => 'dialog_mainw', -value => 'Back'); @@ -803,6 +823,7 @@ if ($runfile eq '') { $text .= "No configuration selected

\n" ; + &logging("Cannot run configuration without configuration"); $text .= $cgi->submit(-name => 'dialog_mainw', -value => 'Back'); return $text; } @@ -819,6 +840,7 @@ "Run command: " . $rcommand . "
"; system("$rcommand > $output 2>&1"); + &logging("Running command $rcommand"); $fileoutput = IO::File->new("<$output"); if (defined $fileoutput) { @@ -838,6 +860,7 @@ } else { $text .= "Run command not working

\n"; + &logging("Run command $rcommand not working"); } $text .= $cgi->submit(-name => 'dialog_mainw', -value => 'Back'); @@ -855,6 +878,7 @@ my @userlistarray = split(/\s/, $userlist); $akt_user = $username; + &logging("Using admin section"); $text .= "" . "
". @@ -1001,12 +1025,14 @@ my $akt_u_p; + &logging("Changing password of user $user"); $valid = &validpassword($user, $old_password, $cfghash{'BaseDir'}.$cfghash{'PasswdFile'}); if ( ($username eq $cfghash{'TabeaUser'}) && ($user ne $cfghash{'TabeaUser'}) ) { $valid = 1; } if ( !$valid ) { $cptext .= "The password is incorrect.

\n"; + &logging("Password is incorrect"); if ( $cgi->param('username') eq $cfghash{'TabeaUser'}) { $cptext .= $cgi->submit(-name => 'dialog_admin', -value => 'Back'); } else { @@ -1027,6 +1053,7 @@ $pwdfp = IO::File->new(">$pwdfile"); print $pwdfp $pwfiletext; $pwdfp->close(); + &logging("Writing new password for user $user"); if ( $user =~ $username) {$password=$new1_password;} $form = 'mainw'; goto NEXTFORM; @@ -1034,6 +1061,7 @@ $cptext .= "The password you typed do not match. Type the same password. ". "in both boxes

\n". $cgi->submit(-name => 'dialog_mainw', -value => 'Back'); + &logging("The password in the two boxes are not the same"); } } ENDE: @@ -1107,6 +1135,7 @@ "
Username wrong

" . "
" . $cgi->submit(-name => 'dialog_admin', -value => 'Back'); + &logging("Username is wrong"); } else { $pwdin = IO::File->new("<$pwdfile"); while (<$pwdin>) { @@ -1145,7 +1174,8 @@ $ntext .= "" . "User $nuser created

" . - $cgi->submit(-name => 'dialog_admin', -value => 'Back'); + $cgi->submit(-name => 'dialog_admin', -value => 'Back'); + &logging("New use $nuser created"); } else { @@ -1153,6 +1183,7 @@ "
User exists

" . "
" . $cgi->submit(-name => 'dialog_admin', -value => 'Back'); + &logging("Cannot create user $nuser. The user exists.") } } @@ -1219,6 +1250,7 @@ "" . "

" . $cgi->submit(-name => 'dialog_admin', -value => 'Back'); + &logging("The Tabea user cannot be deleted"); } @@ -1314,6 +1346,7 @@ foreach (@copfilesarray) { system("cp $deldir$_ $destdir$duser.$_") && die "Copy failed"; + &logging("The files of $duser saved"); } } @@ -1329,6 +1362,7 @@ $pwdin = IO::File->new(">$pwdfile"); print $pwdin $pwdfiletext; $pwdin->close(); + &logging("User $duser deleted"); $d3text .= "
" . @@ -1345,6 +1379,7 @@ ######################################################################################## my $text; + &logging("Editing Tabea configuration"); $text .= &editconfig($cfghash{'BaseDir'} . "tabea.cfg", 'w', $cfghash{'TabeaUser'} ); $text .= $cgi->hidden(-name => 'editfile', -default => $cfghash{'BaseDir'} . "tabea.cfg" ); @@ -1367,6 +1402,7 @@ system("cp $srcf $dstf") && die "Cannot copy file"; system("chmod o= $dstf") && die "Cannot change file rights"; + &logging("Copying $srcf to $dstf"); $form = 'mainw'; goto NEXTFORM; @@ -1511,6 +1547,7 @@ $filein->close(); } else { + &logging("Cannot open $file"); die "Can't open $file"; } @@ -1553,3 +1590,35 @@ return $texte; } ######################################################################################## + + +######################################################################################## +sub logging{ +######################################################################################## + my ($logtext) = @_; + my $logfile = $cfghash{'BaseDir'} . $cfghash{'LogFile'}; + my $logout; + my $entry; + +# if ( $cfghash{'Logging'} =~ /^[Yy}[Ee][Ss]$/ ) { + + my ($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime(time); + my $month = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec') [($mon)]; + my $Year = $year + 1900; + my $Day = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat') [($wday)]; + + $entry = "[" . $Day . " " . $month . " " . + $mday . " " . $hour . ":".$min. ":" . $sec . " " . $Year . "] "; + + $entry .= $logtext . "\n"; + + $logout = IO::File->new($logfile, "a"); + if (defined $logout) { + print $logout $entry; + } else { + die "Cannot open log file $logfile"; + } + +# } +} +########################################################################################