#!/usr/bin/perl # hostconfig-lib.pl # These are functions specific to the hostconfig file # used by darwin # written by Michael A. Peters <mpeters@mac.com> sub hostconfig_settings { #### # # This subroutine reads the hostconfig file into an array # and outputs a second array containing matched pairs of # the startup action and what the startup action is set to # #### local($conffile, @hconf); $conffile = "$config{'hostconfig'}"; open(LOCAL, "<".$conffile); @conf = <LOCAL>; close(LOCAL); @conf = grep /^\w/, @conf; while (<@conf>) { push @hconf, [ split /=/ ]; } return @hconf; } sub hostconfig_gather { #### # # Gathers information about an action item that is set in the hostconfig # file. # # It takes one arguement- the type of info wanted (description or # scriptname) # # It outputs a hash where the action item is the key, and what was # requested is the value. # # Thus, we can use the hash to find out what startup script is # associated with the MAILSERVER action or what description goes with # that action. # # Originally I wanted to output an array with two elements where the # first was one type of hash, and the second element was the second type # of hash, but I couldn't get that to work (array of hashes) # #### local ($hash_type, @startupdir, $plist, @action_to_description, @action_to_script, @sec_action_to_description, @sec_action_to_script, $element, @ls, @script, $a, $action_name, @param, $description); my($hash_type) = @_; @startupdir = (); @startupdir = split (/:/, $config{'startup_dirs'}); $plist = $config{'plist'}; @action_to_description = (); @action_to_script = (); @sec_action_to_description = (); @sec_action_to_script = (); foreach $element (@startupdir) { if ( -d "$element" ) { opendir (LOCAL, $element); @ls = readdir LOCAL; closedir LOCAL; shift @ls; shift @ls; foreach $a (@ls) { #we need BOTH an executable and a plist- or its useless. #executable script has to be in a directory of the same #name for some reason if (( -x "$element/$a/$a") && ( -e "$element/$a/$plist")) { #Get the startup action associated with script open (SCRIPT, "$element/$a/$a"); @script = <SCRIPT>; close SCRIPT; @script = grep /:=/, @script; # we are looking at a line in the script that looks like: #if [ "${WEBMIN:=-NO-}" = "-YES-" ]; then # and we want to extract the WEBMIN part as the action_name if ( $script[0] =~ /\$\{(.*):/ ) { $action_name = $1; } else { #shouldn't happen $action_name = ""; } open (PLIST, "$element/$a/$plist"); @param = <PLIST>; close PLIST; @param = grep /Description[ \t]*=/, @param; # we are looking at a line in the plist that looks like: #\t\tDescription\t\t= "Webmin System Administration Daemon"; # and we want to extract the contents of the quotes if ( $param[0] =~ /\"(.*)\"/ ) { $description = $1; } else { $description = ""; } # make the primary hash if ( $action_name ne "" ) { $action_to_description{$action_name} = "$description"; $action_to_script{$action_name} = "$element/$a/$a"; } # make the secondary hash shift @script; if ( $script[0] ne "" ) { foreach $secondary (@script) { if ( $secondary =~ /\$\{(.*):/ ) { $action_name = $1; $sec_action_to_description{$action_name} = "$description"; $sec_action_to_script{$action_name} = "$element/$a/$a"; } } } } #ends the: if (( -x "$element/$a/$a") && ( -e "$element/$a/$plist") } #ends the: foreach $a (@ls) } #ends the: if ( -d "$element" ) } #ends the: foreach $element (@startupdir) # now we have two sets of each hash # elements in sec_blah that are not already in blah # need to be integrated into blah # # We have to do this because some scripts use several action_name just # for that particular script, and sometimes what one action is set to is # used in how another script acts even though that is not the action for # that script. # # Thus, if a action_item is in the secondary array and is not in the # primary, we know that it is a case where more than one action belongs # to a script- but if its in both, the action probably belongs to the # script in the primary. while (($key,$value) = each %action_to_description) { $sec_action_to_description{$key} = "$value"; } while (($key,$value) = each %action_to_script) { $sec_action_to_script{$key} = "$value"; } if ( $hash_type eq "description" ) { return %sec_action_to_description; } elsif ( $hash_type eq "startscript" ) { return %sec_action_to_script; } } sub hostconfig_table { #### # # This sub writes a table row in html for index.cgi. # It takes the startup action, setting, and provides # as its arguements- and outputs a string. # #### local($ahref, $setting, $link, $description); my($ahref, $setting, $description) = @_; local @cols; if ($access{'bootup'} == 1) { push(@cols, &ui_link("edit_hostconfig.cgi?0+$ahref", $ahref) ); } else { push(@cols, $ahref); } if ( $setting eq "-NO-" ) { push(@cols, "<font color=#ff0000>$setting</font>"); } elsif ( $setting ne "" ) { push(@cols, $setting); } else { push(@cols, ""); } push(@cols, $description); if ( $ahref ne "" ) { return &ui_columns_row(\@cols); } else { return "<!-- this is annoying- I'll have to track it down.. -->"; } } sub hostconfig_editaction { #### # # This sub takes either one or two arguements- the first (action name) # is required, the second is the StartupItems script affected by # the setting of the action. # # If there is no script, the current setting is used as the default in # a text field for editing. # # If there is a script, but the setting is something like automatic in # the Network script where there isn't an alternative, then radio button # choice between the defined setting and a custom one is offered. # # If, as is the case with most scripts, there is a -NO- and -YES- # option, then those two choices are offered as a radio button option # and a text box option just in case a custom answer is needed. # # Returns a string # #### local(@sconf, @sfile, @possible_settings, $current, $setting, $line, $option_selected, $buttons, $pre); my($action_item, $startupfile) = @_; # get current setting $line = "$config{'hostconfig'}"; open(HCONF, "<".$line); @sconf = <HCONF>; close(HCONF); @sconf = grep /^$action_item=/, @sconf; ($dontcare, $current) = split(/=/, $sconf[0]); if ( $current eq "" ) { $current = "udefined"; } #get rid of quotes $current =~ s/\"//g; $current =~ s/\n//; @possible_settings = (); $option_selected = ""; $buttons = ""; $option_selected = ""; # get possible settings if ( $startupfile ne "" ) { open(LOCAL, "<".$startupfile); @sfile = <LOCAL>; close(LOCAL); # # I really need to write a parser to get # this done- so that I can deal with # case options. # # But this is better than nothing... # @sfile = grep /\{$action_item:=/, @sfile; for $element (@sfile) { # We are looking at a line that looks like #if [ "${WEBMIN:=-NO-}" = "-YES-" ]; then # We want the -NO- and -YES- if ( $element =~ /\"\$\{$action_item:=(.*)\}\"[ \t]*=[ \t]*\"(.*)\"/ ) { push @possible_settings, ($1, $2); } } # get rid of duplicate entries %unique = map { $_ => 1 } @possible_settings; @possible_settings = keys %unique; } # end of :if ( $startupfile ne "" ) if ( $possible_settings[0] eq "" ) { $buttons = "<input type=text name=choice value=\"$current\">"; } else { foreach $setting (@possible_settings) { if ( $setting ne $current ) { if ( $buttons eq "" ) { $pre = ""; } else { $pre = "$buttons<br>\n"; } $buttons = "$pre<input type=radio name=choice value=\"$setting\">$setting"; } else { $option_selected = "yes"; if ( $buttons eq "" ) { $pre = ""; } else { $pre = "$buttons<br>\n"; } $buttons = "$pre<input type=radio name=choice value=\"$setting\" checked>$setting"; } } #end foreach # add custom text option if ( $option_selected eq "yes" ) { $buttons = "$buttons<br>\n<input type=radio name=choice value=custom> <input type=text name=custom size=60 value=\"\">"; } else { $buttons = "$buttons<br>\n<input type=radio name=choice value=custom checked> <input type=text name=custom size=60 value=\"$current\">"; } } # add hidden value $buttons = "$buttons\n<input type=hidden name=action value=$action_item>\n"; return $buttons; } sub hostconfig_createtext { # simply outputs the text in the create new action table my($text_line,$required_field) = @_; if ( $required_field ne "" ) { $output="<td><font size=-1 color=#ff0000>*</font><b>$text_line</b></td>\n"; } else { $output="<td><b>$text_line</b></td>\n"; } return $output; } 1;
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
help | Folder | 0755 |
|
|
images | Folder | 0755 |
|
|
lang | Folder | 0755 |
|
|
CHANGELOG | File | 1.8 KB | 0644 |
|
acl_security.pl | File | 869 B | 0755 |
|
atboot.pl | File | 5.66 KB | 0755 |
|
backup_config.pl | File | 975 B | 0755 |
|
cgi_args.pl | File | 668 B | 0755 |
|
change_rl.cgi | File | 486 B | 0755 |
|
config-aix | File | 204 B | 0644 |
|
config-cobalt-linux-2.2-4.0 | File | 242 B | 0644 |
|
config-cobalt-linux-5.0-ALL | File | 257 B | 0644 |
|
config-coherent-linux | File | 277 B | 0644 |
|
config-corel-linux | File | 179 B | 0644 |
|
config-debian-linux | File | 195 B | 0644 |
|
config-freebsd | File | 154 B | 0644 |
|
config-freebsd-5.0-ALL | File | 251 B | 0644 |
|
config-generic-linux | File | 238 B | 0644 |
|
config-gentoo-linux | File | 166 B | 0644 |
|
config-hpux | File | 233 B | 0644 |
|
config-irix | File | 186 B | 0644 |
|
config-macos | File | 267 B | 0644 |
|
config-mandrake-linux | File | 277 B | 0644 |
|
config-msc-linux | File | 272 B | 0644 |
|
config-netbsd | File | 106 B | 0644 |
|
config-open-linux | File | 208 B | 0644 |
|
config-openSUSE-Linux-15.0-ALL | File | 236 B | 0644 |
|
config-openbsd | File | 106 B | 0644 |
|
config-openmamba-linux | File | 277 B | 0644 |
|
config-openserver | File | 208 B | 0644 |
|
config-osf1 | File | 214 B | 0644 |
|
config-pardus-linux | File | 238 B | 0644 |
|
config-redhat-linux | File | 277 B | 0644 |
|
config-slackware-linux | File | 129 B | 0644 |
|
config-solaris | File | 195 B | 0644 |
|
config-solaris-10-ALL | File | 225 B | 0644 |
|
config-suse-linux | File | 187 B | 0644 |
|
config-suse-linux-7.1-ALL | File | 236 B | 0644 |
|
config-syno-linux | File | 247 B | 0644 |
|
config-trustix-linux | File | 262 B | 0644 |
|
config-turbo-linux | File | 257 B | 0644 |
|
config-united-linux | File | 197 B | 0644 |
|
config-unixware | File | 178 B | 0644 |
|
config-windows | File | 115 B | 0644 |
|
config.info | File | 1.31 KB | 0644 |
|
config.info.ca | File | 1.54 KB | 0644 |
|
config.info.cs | File | 1.27 KB | 0644 |
|
config.info.de | File | 1.46 KB | 0644 |
|
config.info.es | File | 1.31 KB | 0644 |
|
config.info.eu | File | 1.35 KB | 0644 |
|
config.info.fa | File | 1.78 KB | 0644 |
|
config.info.fr | File | 1.18 KB | 0644 |
|
config.info.hu | File | 0 B | 0644 |
|
config.info.ja | File | 1.57 KB | 0644 |
|
config.info.ko | File | 1.19 KB | 0644 |
|
config.info.nl | File | 1.25 KB | 0644 |
|
config.info.no | File | 1.41 KB | 0644 |
|
config.info.pl | File | 1.22 KB | 0644 |
|
config.info.ru | File | 2.05 KB | 0644 |
|
config.info.sk | File | 0 B | 0644 |
|
config.info.sv | File | 549 B | 0644 |
|
config.info.tr | File | 515 B | 0644 |
|
config.info.uk | File | 1.45 KB | 0644 |
|
config.info.zh | File | 388 B | 0644 |
|
config.info.zh_TW | File | 727 B | 0644 |
|
create-boot.pl | File | 424 B | 0755 |
|
defaultacl | File | 40 B | 0644 |
|
delboot.pl | File | 688 B | 0755 |
|
delete-boot.pl | File | 379 B | 0755 |
|
delete_action.cgi | File | 907 B | 0755 |
|
edit_action.cgi | File | 5.12 KB | 0755 |
|
edit_hostconfig.cgi | File | 6.2 KB | 0755 |
|
edit_launchd.cgi | File | 2.05 KB | 0755 |
|
edit_rc.cgi | File | 1.84 KB | 0755 |
|
edit_systemd.cgi | File | 2.4 KB | 0755 |
|
edit_upstart.cgi | File | 2.3 KB | 0755 |
|
fix_action.cgi | File | 600 B | 0755 |
|
hostconfig-lib.pl | File | 8.53 KB | 0755 |
|
index.cgi | File | 13.7 KB | 0755 |
|
init-lib.pl | File | 68 KB | 0644 |
|
log_parser.pl | File | 1.37 KB | 0755 |
|
mass_launchd.cgi | File | 1.94 KB | 0755 |
|
mass_rcs.cgi | File | 1.54 KB | 0755 |
|
mass_start_stop.cgi | File | 2.81 KB | 0755 |
|
mass_systemd.cgi | File | 2.68 KB | 0755 |
|
mass_upstarts.cgi | File | 1.94 KB | 0755 |
|
modifyhostconfig.cgi | File | 1.07 KB | 0755 |
|
module.info | File | 305 B | 0644 |
|
module.info.af | File | 0 B | 0644 |
|
module.info.af.auto | File | 156 B | 0644 |
|
module.info.ar | File | 0 B | 0644 |
|
module.info.ar.auto | File | 207 B | 0644 |
|
module.info.be | File | 0 B | 0644 |
|
module.info.be.auto | File | 246 B | 0644 |
|
module.info.bg | File | 0 B | 0644 |
|
module.info.bg.auto | File | 253 B | 0644 |
|
module.info.ca | File | 0 B | 0644 |
|
module.info.ca.auto | File | 174 B | 0644 |
|
module.info.cs | File | 0 B | 0644 |
|
module.info.cs.auto | File | 168 B | 0644 |
|
module.info.da | File | 0 B | 0644 |
|
module.info.da.auto | File | 150 B | 0644 |
|
module.info.de | File | 0 B | 0644 |
|
module.info.de.auto | File | 148 B | 0644 |
|
module.info.el | File | 0 B | 0644 |
|
module.info.el.auto | File | 277 B | 0644 |
|
module.info.es | File | 0 B | 0644 |
|
module.info.es.auto | File | 173 B | 0644 |
|
module.info.eu | File | 0 B | 0644 |
|
module.info.eu.auto | File | 142 B | 0644 |
|
module.info.fa | File | 0 B | 0644 |
|
module.info.fa.auto | File | 201 B | 0644 |
|
module.info.fi | File | 0 B | 0644 |
|
module.info.fi.auto | File | 177 B | 0644 |
|
module.info.fr | File | 0 B | 0644 |
|
module.info.fr.auto | File | 169 B | 0644 |
|
module.info.he | File | 0 B | 0644 |
|
module.info.he.auto | File | 171 B | 0644 |
|
module.info.hr | File | 0 B | 0644 |
|
module.info.hr.auto | File | 158 B | 0644 |
|
module.info.hu | File | 0 B | 0644 |
|
module.info.hu.auto | File | 184 B | 0644 |
|
module.info.it | File | 0 B | 0644 |
|
module.info.it.auto | File | 139 B | 0644 |
|
module.info.ja | File | 0 B | 0644 |
|
module.info.ja.auto | File | 202 B | 0644 |
|
module.info.ko | File | 0 B | 0644 |
|
module.info.ko.auto | File | 156 B | 0644 |
|
module.info.lt | File | 0 B | 0644 |
|
module.info.lt.auto | File | 172 B | 0644 |
|
module.info.lv | File | 0 B | 0644 |
|
module.info.lv.auto | File | 177 B | 0644 |
|
module.info.ms | File | 0 B | 0644 |
|
module.info.ms.auto | File | 142 B | 0644 |
|
module.info.mt | File | 0 B | 0644 |
|
module.info.mt.auto | File | 141 B | 0644 |
|
module.info.nl | File | 0 B | 0644 |
|
module.info.nl.auto | File | 160 B | 0644 |
|
module.info.no | File | 0 B | 0644 |
|
module.info.no.auto | File | 148 B | 0644 |
|
module.info.pl | File | 0 B | 0644 |
|
module.info.pl.auto | File | 163 B | 0644 |
|
module.info.pt | File | 0 B | 0644 |
|
module.info.pt.auto | File | 199 B | 0644 |
|
module.info.pt_BR | File | 0 B | 0644 |
|
module.info.pt_BR.auto | File | 208 B | 0644 |
|
module.info.ro | File | 0 B | 0644 |
|
module.info.ro.auto | File | 176 B | 0644 |
|
module.info.ru | File | 0 B | 0644 |
|
module.info.ru.auto | File | 249 B | 0644 |
|
module.info.sk | File | 0 B | 0644 |
|
module.info.sk.auto | File | 172 B | 0644 |
|
module.info.sl | File | 0 B | 0644 |
|
module.info.sl.auto | File | 158 B | 0644 |
|
module.info.sv | File | 0 B | 0644 |
|
module.info.sv.auto | File | 154 B | 0644 |
|
module.info.th | File | 0 B | 0644 |
|
module.info.th.auto | File | 270 B | 0644 |
|
module.info.tr | File | 0 B | 0644 |
|
module.info.tr.auto | File | 218 B | 0644 |
|
module.info.uk | File | 0 B | 0644 |
|
module.info.uk.auto | File | 283 B | 0644 |
|
module.info.ur | File | 0 B | 0644 |
|
module.info.ur.auto | File | 200 B | 0644 |
|
module.info.vi | File | 0 B | 0644 |
|
module.info.vi.auto | File | 195 B | 0644 |
|
module.info.zh | File | 0 B | 0644 |
|
module.info.zh.auto | File | 140 B | 0644 |
|
module.info.zh_TW | File | 0 B | 0644 |
|
module.info.zh_TW.auto | File | 149 B | 0644 |
|
prefs.info | File | 55 B | 0644 |
|
rbac-mapping | File | 80 B | 0644 |
|
reboot.cgi | File | 725 B | 0755 |
|
save_action.cgi | File | 6.37 KB | 0755 |
|
save_hostconfig_action.cgi | File | 4.63 KB | 0755 |
|
save_launchd.cgi | File | 1.72 KB | 0755 |
|
save_local.cgi | File | 706 B | 0755 |
|
save_rc.cgi | File | 2.48 KB | 0755 |
|
save_services.cgi | File | 1.44 KB | 0755 |
|
save_startscript.cgi | File | 1.9 KB | 0755 |
|
save_systemd.cgi | File | 2.03 KB | 0755 |
|
save_upstart.cgi | File | 2.15 KB | 0755 |
|
shutdown.cgi | File | 591 B | 0755 |
|
start_stop.cgi | File | 890 B | 0755 |
|
syslog_logs.pl | File | 350 B | 0755 |
|
uninstall.pl | File | 1.91 KB | 0755 |
|
updateboot.pl | File | 936 B | 0755 |
|
win32.pl | File | 1.93 KB | 0755 |
|