3 # saves modifications to the StartupItems/script/script or
4 # the StartupItems/script/StartupItems.plist
6 # Even though it would be MUCH faster to pass the file to be edited
7 # in the form, forms are filled out by the browser, not the server.
9 # A malicious user could manipulate the form to write to
10 # any file they darned well please. While a user who has webmin access
11 # to the bootup scripts could do a fair amount of damage anyway, I still
12 # would rather limit the possible files the cgi will write to to the
13 # actual bootup scripts.
15 # Written by Michael A. Peters <mpeters@mac.com> for
16 # webmin init module, based on save_local.cgi of same
17 # module. Written for Darwin/OS X.
19 require './init-lib.pl';
20 require './hostconfig-lib.pl';
22 $access{'bootup'} == 1 || &error("You are not allowed to edit the bootup script");
25 $action=$in{'action'};
27 if ( $in{'plist'} ne "" ) {
28 $in{'plist'} =~ s/\r//g;
29 $towrite = $in{'plist'};
30 %temphash = &hostconfig_gather(startscript);
31 $tempfile = $temphash{"$action"};
32 $dir = dirname("$tempfile");
33 $file = "$dir/$config{'plist'}";
34 $redirect = "edit_hostconfig.cgi?0+$action";
35 -e $file || &error("$file doesn't seem to exist");
37 elsif ( $in{'startup'} ne "" ) {
38 $in{'startup'} =~ s/\r//g;
39 $towrite = $in{'startup'};
40 %temphash = &hostconfig_gather(startscript);
41 $file = $temphash{"$action"};
42 $redirect = "edit_hostconfig.cgi?0+$action";
43 -e $file || &error("$file doesn't seem to exist");
45 elsif ( $in{'hostconfig'} ne "" ) {
46 $in{'hostconfig'} =~ s/\r//g;
47 $towrite = $in{'hostconfig'};
48 $file = $config{'hostconfig'};
49 $redirect = "edit_hostconfig.cgi?2";
52 &error("I do not know what you want me to do");
56 &open_tempfile(LOCAL, "> $file");
57 &print_tempfile(LOCAL, $towrite);
58 &close_tempfile(LOCAL);
60 &webmin_log("startup", undef, undef, \%in);
61 &redirect("$redirect");