Added action logging
authorJamie Cameron <jcameron@webmin.com>
Sat, 26 Sep 2009 17:33:48 +0000 (10:33 -0700)
committerJamie Cameron <jcameron@webmin.com>
Sat, 26 Sep 2009 17:33:48 +0000 (10:33 -0700)
at/CHANGELOG
at/delete_job.cgi
at/lang/en
at/log_parser.pl [new file with mode: 0755]

index 003b8fb..5a02e3f 100644 (file)
@@ -7,3 +7,5 @@ Added checkboxes and a button for deleting multiple scheduled commands at once.
 ---- Changes since 1.390 ----
 Converted all user interface code to use the new Webmin UI library.
 When editing a job, only the actual command entered is shown by default - the full command can be displayed using a new link.
+---- Changes since 1.490 ----
+Added action logging for scheduled commands created and deleted using this module.
index ca156a2..1f0a7e2 100755 (executable)
@@ -24,11 +24,13 @@ if ($in{'run'}) {
        print &text('run_output'),"<p>\n";
        @uinfo = getpwnam($job->{'user'});
        print "<pre>";
-       $got = &proc::safe_process_exec_logged($temp, $uinfo[2], $uinfo[3],
-                                        STDOUT, undef, 1);
+       &additional_log('exec', undef, $job->{'cmd'});
+       $got = &proc::safe_process_exec($temp, $uinfo[2], $uinfo[3],
+                                       STDOUT, undef, 1);
        if (!$got) { print "<i>$text{'run_none'}</i>\n"; }
        unlink($temp);
        print "</pre>\n";
+       &webmin_log("exec", "job", $job->{'user'}, $job);
 
        &ui_print_footer("", $text{'index_return'});
        }
index 8c7c04f..93eca91 100644 (file)
@@ -58,3 +58,9 @@ allow_eusers=No users entered
 
 deletes_err=Failed to cancel commands
 deletes_enone=None selected
+
+log_allow=Changed allowed users
+log_create_job=Created scheduled command for $1
+log_delete_job=Cancelled scheduled command for $1
+log_exec_job=Executed scheduled command for $1
+log_delete_jobs=Cancelled $1 scheduled commands
diff --git a/at/log_parser.pl b/at/log_parser.pl
new file mode 100755 (executable)
index 0000000..1996daa
--- /dev/null
@@ -0,0 +1,25 @@
+# log_parser.pl
+# Functions for parsing this module's logs
+
+do 'at-lib.pl';
+
+# parse_webmin_log(user, script, action, type, object, &params, [long])
+# Converts logged information from this module into human-readable form
+sub parse_webmin_log
+{
+local ($user, $script, $action, $type, $object, $p, $long) = @_;
+if ($type eq "job") {
+       return &text('log_'.$action.'_job',
+                    "<tt>".&html_escape($object)."</tt>");
+       }
+elsif ($type eq "jobs") {
+       return &text('log_'.$action.'_jobs', $object);
+       }
+elsif ($action eq 'allow') {
+       return $text{'log_allow'};
+       }
+else {
+       return undef;
+       }
+}
+