3 # Save logcheck.sh options
5 require './sentry-lib.pl';
7 &error_setup($text{'logcheck_err'});
9 # Get the current cron job
10 &foreign_require("cron", "cron-lib.pl");
11 @jobs = &cron::list_cron_jobs();
13 $job = $j if ($j->{'command'} =~ /$config{'logcheck'}/);
16 # Validate and save inputs
17 $conf = &get_logcheck_config();
18 &lock_config_files($conf);
19 $in{'to'} =~ /^\S+$/ || &error($text{'logcheck_eto'});
20 if ($in{'runparts'}) {
21 # Being run from a script that we cannot change
23 elsif (!$in{'active'} && !$job) {
24 # Cron job is not setup yet, and doesn't need to be .. do nothing
27 # Create or update the cron job
29 $job = { 'command' => $config{'logcheck'},
33 $job->{'active'} = $in{'active'};
34 &cron::parse_times_input($job, \%in);
35 &lock_file(&cron::cron_file($job));
37 &cron::create_cron_job($job);
40 &cron::change_cron_job($job);
42 &unlock_file(&cron::cron_file($job));
44 $to = &find_value("SYSADMIN", $conf);
45 if ($to =~ /^\$(\S+)$/) {
46 &save_config($conf, $1, $in{'to'});
49 &save_config($conf, "SYSADMIN", $in{'to'});
52 &unlock_config_files($conf);
54 $hacking = &find_value("HACKING_FILE", $conf, 1);
55 $hacking = &find_value("CRACKING_FILE", $conf, 1) if (!$hacking);
57 $in{'hacking'} =~ s/\r//g;
58 $in{'hacking'} =~ s/\n*$/\n/;
59 &open_tempfile(HACKING, ">$hacking");
60 &print_tempfile(HACKING, $in{'hacking'});
61 &close_tempfile(HACKING);
62 &unlock_file($hacking);
64 $violations = &find_value("VIOLATIONS_FILE", $conf, 1);
65 &lock_file($violations);
66 $in{'violations'} =~ s/\r//g;
67 $in{'violations'} =~ s/\n*$/\n/;
68 &open_tempfile(VIOLATIONS, ">$violations");
69 &print_tempfile(VIOLATIONS, $in{'violations'});
70 &close_tempfile(VIOLATIONS);
71 &unlock_file($violations);
73 $violations_ign = &find_value("VIOLATIONS_IGNORE_FILE", $conf, 1);
74 &lock_file($violations_ign);
75 $in{'violations_ign'} =~ s/\r//g;
76 $in{'violations_ign'} =~ s/\n*$/\n/;
77 &open_tempfile(IGNORE, ">$violations_ign");
78 &print_tempfile(IGNORE, $in{'violations_ign'});
79 &close_tempfile(IGNORE);
80 &unlock_file($violations_ign);
82 $ignore = &find_value("IGNORE_FILE", $conf, 1);
84 $in{'ignore'} =~ s/\r//g;
85 $in{'ignore'} =~ s/\n*$/\n/;
86 &open_tempfile(IGNORE, ">$ignore");
87 &print_tempfile(IGNORE, $in{'ignore'});
88 &close_tempfile(IGNORE);
89 &unlock_file($ignore);
91 &webmin_log("logcheck");