3 # Save global logging options
5 require './bind8-lib.pl';
6 $access{'defaults'} || &error($text{'logging_ecannot'});
7 &error_setup($text{'files_err'});
10 &lock_file(&make_chroot($config{'named_conf'}));
11 $conf = &get_config();
12 $logging = &find("logging", $conf);
14 if ($in{'mode'} eq 'cats') {
16 for($i=0; defined($cat = $in{"cat_$i"}); $i++) {
18 @cchan = split(/\0/, $in{"cchan_$i"});
19 push(@category, { 'name' => 'category',
23 [ map { { 'name' => $_ } } @cchan ] });
25 @channel = &find("channel", $logging->{'members'}) if ($logging);
29 for($i=0; defined($cname = $in{"cname_$i"}); $i++) {
31 $cname =~ /^\S+$/ || &error(&text('logging_ename', $cname));
33 if ($in{"to_$i"} == 0) {
34 $in{"file_$i"} || &error($text{'logging_efile'});
35 $in{"file_$i"} =~ /^\// ||
36 &error($text{'logging_efile2'});
37 local @fvals = ( $in{"file_$i"} );
38 if ($in{"vmode_$i"} == 1) {
39 push(@fvals, 'versions', 'unlimited');
41 elsif ($in{"vmode_$i"} == 2) {
42 $in{"ver_$i"} =~ /^\d+$/ ||
43 &error(&text('logging_ever', $in{"ver_$i"}));
44 push(@fvals, 'versions', $in{"ver_$i"});
46 if ($in{"smode_$i"}) {
47 $in{"size_$i"} =~ /^\d+[kmg]*$/i ||
48 &error(&text('logging_esize', $in{"size_$i"}));
49 push(@fvals, 'size', $in{"size_$i"});
51 push(@mems, { 'name' => 'file',
52 'values' => \@fvals });
54 elsif ($in{"to_$i"} == 1) {
55 push(@mems, { 'name' => 'syslog',
56 'values' => [ $in{"syslog_$i"} ] });
59 push(@mems, { 'name' => 'null' });
61 if ($in{"sev_$i"} eq 'debug') {
62 push(@mems, { 'name' => 'severity',
63 'values' => [ 'debug', $in{"debug_$i"} ] });
65 elsif ($in{"sev_$i"}) {
66 push(@mems, { 'name' => 'severity',
67 'values' => [ $in{"sev_$i"} ] });
69 foreach $p ('print-category', 'print-severity', 'print-time') {
70 push(@mems, { 'name' => $p,
71 'values' => [ $in{"$p-$i"} ] }) if ($in{"$p-$i"});
73 push(@channel, { 'name' => 'channel',
74 'values' => [ $cname ],
76 'members' => \@mems } );
78 @category = &find("category", $logging->{'members'}) if ($logging);
81 # Write out the logging section, creating if needed
83 &save_directive($logging, 'channel', \@channel, 1);
84 &save_directive($logging, 'category', [ ], 1);
85 &save_directive($logging, 'category', [ reverse(@category) ], 1);
88 $logging = { 'name' => 'logging',
90 'members' => [ @channel, @category ] };
91 &save_directive(&get_config_parent(), 'logging', [ $logging ], 0);
94 &unlock_file(&make_chroot($config{'named_conf'}));
95 &webmin_log("logging", undef, undef, \%in);