OSSP CVS Repository

ossp - Difference in ossp-pkg/tabea/tabea.cgi versions 1.34 and 1.35
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/tabea/tabea.cgi 1.34 -> 1.35

--- tabea.cgi    2002/07/05 13:06:35     1.34
+++ tabea.cgi    2002/07/09 15:08:02     1.35
@@ -257,6 +257,8 @@
     "    </td>" .
     "  </tr>" .
     "</table>" ;
+    
+    &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 .= "<font color=red>Missing filename<br><br>\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 .= "<font color=red>Cannot save file<br><br>\n";
+        &logging("Cannot save $file");
     }
 
     $text .= $cgi->submit(-name => 'dialog_mainw', -value => 'Back');
@@ -588,14 +598,17 @@
         }
         $text .= "Creating the new file $newpath<br><br>";
         system("touch $newpath") && die "Cannot create new file";
+        &logging("Creating new file $newpath");
         $text .= "Setting new file rights for $newpath<br><br>";
         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 .= "<br><br><br>";
         $form = 'mainw';
         goto NEXTFORM;
     } else {
         $text .= "<font color=red>Cannot write file. File exists<br><br>\n";
+        &logging("Cannot write $newpath File exists");
     }
     $text .= $cgi->submit(-name => 'dialog_mainw', -value => 'Back');
 
@@ -652,11 +665,13 @@
         else {
             $text .= "<font color=red>You can only change file rights in your own directory<br><br>\n" .
                      $cgi->submit(-name => 'dialog', -value => 'Back');
+                     &logging("Changing filerights of $namefile not allowed");
         }
     }
     else {
         $text .= "<font color=red>Missing filename<br><br>\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!"<A3>$%^&*()-_=+#~]+)/(.+)}sg;
         if ($1 eq $username) {
             system("rm $fpath") && die "Cannot delete file";
+            &logging("Deleting $fpath");
             $form = 'mainw';
             goto NEXTFORM;
         }
         else {
             $text .= "<font color=red>You can only delete file in your own directory<br><br>\n";
+            &loggong("Just delete your own files not $fpath");
         }
     }
     else {
         $text .= "<font color=red>Missing filename<br><br>\n";
+        &loggin("Missing filename");
     }
 
     $text .= $cgi->submit(-name => 'dialog_mainw', -value => 'Back');
@@ -803,6 +823,7 @@
 
     if ($runfile eq '') {
         $text .= "<font color=red>No configuration selected <br><br>\n" ;
+        &logging("Cannot run configuration without configuration");
         $text .= $cgi->submit(-name => 'dialog_mainw', -value => 'Back');
         return $text;
     }
@@ -819,6 +840,7 @@
              "Run command: " . $rcommand . "<br>";
 
     system("$rcommand > $output 2>&1");
+    &logging("Running command $rcommand");
 
     $fileoutput = IO::File->new("<$output");
     if (defined $fileoutput) {
@@ -838,6 +860,7 @@
     }
     else {
         $text .= "<font color=red>Run command not working<br><br>\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 .= "<table>" .
     "<td>".
 
@@ -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 .= "<font color=red>The password is incorrect.<br><br>\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 .= "<font color=red>The password you typed do not match. Type the same password. ".
             "in both boxes<br><br>\n".
             $cgi->submit(-name => 'dialog_mainw', -value => 'Back');
+            &logging("The password in the two boxes are not the same");
         } 
     }
     ENDE:
@@ -1107,6 +1135,7 @@
         "<br>Username wrong<br><br>" .
         "</font>" .
         $cgi->submit(-name => 'dialog_admin', -value => 'Back');
+        &logging("Username is wrong");
     } else {
         $pwdin = IO::File->new("<$pwdfile");
         while (<$pwdin>) {
@@ -1145,7 +1174,8 @@
            
             $ntext .= "<font color=red>" .
                 "User $nuser created</font><br><br>" .
-                $cgi->submit(-name => 'dialog_admin', -value => 'Back');
+                $cgi->submit(-name => 'dialog_admin', -value => 'Back');    
+                &logging("New use $nuser created");
                 
 
         } else {
@@ -1153,6 +1183,7 @@
             "<br>User exists <br><br>" .
             "</font>" .
             $cgi->submit(-name => 'dialog_admin', -value => 'Back');
+            &logging("Cannot create user $nuser. The user exists.")
         }
     }
 
@@ -1219,6 +1250,7 @@
         "</font>" .
         "<br><br>" .
         $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 .= "<br>" .
 
@@ -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";
+        }
+
+#    }
+}
+########################################################################################

CVSTrac 2.0.1