Handle hostnames with upper-case letters
[webmin.git] / inittab / save_inittab.cgi
1 #!/usr/local/bin/perl
2
3 require "./inittab-lib.pl";
4 &ReadParse();
5 @inittab = &parse_inittab();
6 ($init) = grep { $_->{'id'} eq $in{'oldid'} } @inittab
7         if ($in{'oldid'} ne '');
8
9 &lock_file($config{ 'inittab_file' });
10 if ($in{ 'button' } eq $text{ 'edit_inittab_del' } ) {
11         # Just delete the entry
12         &delete_inittab($init);
13         }
14 else {
15         # Validate and store inputs
16         &error($text{'save_inittab_noid'}) if(!$in{'id'});
17         if ($in{'id'} ne $in{'oldid'}) {
18                 ($clash) = grep { $_->{'id'} eq $in{'id'} } @inittab;
19                 &error($text{'save_inittab_already'}) if ($clash);
20                 }
21         $init->{'id'} = $in{'id'};
22         $init->{'comment'} = $in{'comment'};
23         foreach $l ( 0..6, "a", "b", "c" ) {
24                 push(@levels, $l) if ($in{$l});
25                 }
26         $init->{'levels'} = \@levels;
27         $init->{'action'} = $in{'action'};
28         $init->{'process'} = $in{'process'};
29
30         if ($in{'oldid'} ne '') {
31                 # Update the entry
32                 &modify_inittab($init);
33                 }
34         else {
35                 # Add a new entry
36                 &create_inittab($init);
37                 }
38         }
39 &unlock_file($config{ 'inittab_file' });
40
41 if ( $in{ 'button' } eq $text{ 'edit_inittab_del' }) {
42         &webmin_log("delete", "inittab", $in{ 'oldid' }, \%in);
43         }
44 elsif ( $number == -1 ) {
45         &webmin_log("create", "inittab", $in{ 'id' }, \%in);
46         }
47 else {
48         &webmin_log("modify", "inittab", $in{ 'id' }, \%in);
49         }
50
51 &redirect("");
52