diff --git a/adsl-client/adsl-client-lib.pl b/adsl-client/adsl-client-lib.pl index d6c342d37..397346632 100755 --- a/adsl-client/adsl-client-lib.pl +++ b/adsl-client/adsl-client-lib.pl @@ -12,7 +12,7 @@ sub get_config { local @rv; local $lnum = 0; -open(FILE, $config{'pppoe_conf'}) || return undef; +open(FILE, "<".$config{'pppoe_conf'}) || return undef; while() { s/\r|\n//g; s/^\s*#.*$//; diff --git a/apache/apache-lib.pl b/apache/apache-lib.pl index a1d6ea52e..e03962574 100755 --- a/apache/apache-lib.pl +++ b/apache/apache-lib.pl @@ -1599,7 +1599,7 @@ local @st = stat($errorlog); my $start = time(); while(time() - $start < $timeout) { sleep(1); - open(ERRORLOG, $errorlog); + open(ERRORLOG, "<".$errorlog); seek(ERRORLOG, $st[7], 0); local $/ = undef; local $rest = ; @@ -1634,7 +1634,7 @@ elsif (-x $config{'apachectl_path'}) { else { # kill the process $pidfile = &get_pid_file(); - open(PID, $pidfile) || return &text('stop_epid', $pidfile); + open(PID, "<".$pidfile) || return &text('stop_epid', $pidfile); =~ /(\d+)/ || return &text('stop_epid2', $pidfile); close(PID); &kill_logged('TERM', $1) || return &text('stop_esig', $1); diff --git a/apache/edit_global.cgi b/apache/edit_global.cgi index e6e8eb2bc..3db03123d 100755 --- a/apache/edit_global.cgi +++ b/apache/edit_global.cgi @@ -33,7 +33,7 @@ if ($in{'type'} == 6) { print &ui_links_row(\@links); print &ui_columns_start([ $text{'global_type'}, $text{'global_ext'} ]); - open(MIME, $mfile); + open(MIME, "<$mfile"); $line = 0; while() { chop; diff --git a/apache/edit_gmime_type.cgi b/apache/edit_gmime_type.cgi index b7ef7420d..011c31d5e 100755 --- a/apache/edit_gmime_type.cgi +++ b/apache/edit_gmime_type.cgi @@ -7,7 +7,7 @@ require './apache-lib.pl'; $access{'global'}==1 || &error($text{'mime_ecannot'}); if (defined($in{'line'})) { &ui_print_header(undef, $text{'mime_edit'}, ""); - open(MIME, $in{'file'}); + open(MIME, "<$in{'file'}"); for($i=0; $i<=$in{'line'}; $i++) { $line = ; } diff --git a/apache/find_htaccess.cgi b/apache/find_htaccess.cgi index ca21a3152..d654b6b79 100755 --- a/apache/find_htaccess.cgi +++ b/apache/find_htaccess.cgi @@ -34,7 +34,8 @@ foreach $v (&find_directive_struct("VirtualHost", $conf)) { if ($in{'from'} == 0) { # search under all directories for($i=0; $i<@dirs; $i++) { - open(FIND, "find $dirs[$i] -name $files[$i] -print |"); + open(FIND, "find ".quotemeta($dirs[$i]). + " -name ".quotemeta($files[$i])." -print |"); while() { s/\r|\n//g; push(@rv, $_); @@ -44,7 +45,9 @@ if ($in{'from'} == 0) { } else { # search under the given directory only - foreach $f (&unique(@files)) { push(@args, "-name $f"); } + foreach $f (&unique(@files)) { + push(@args, "-name ".quotemeta($f)); + } $args = join(' -o ', @args); open(FIND, "find ".quotemeta($in{'dir'})." $args -print |"); while() { diff --git a/apache/index.cgi b/apache/index.cgi index d8d034f2b..2d85d1b18 100755 --- a/apache/index.cgi +++ b/apache/index.cgi @@ -41,7 +41,7 @@ if (!$config{'httpd_conf'} && !(-e "$conf/httpd.conf") && opendir(CONF, $conf); foreach $f (readdir(CONF)) { if ($f =~ /^(.*)-dist$/) { - open(DIST, "$conf/$f"); + open(DIST, "<$conf/$f"); @dist = ; close(DIST); &open_tempfile(REAL, ">$conf/$1"); diff --git a/apache/save_gmime_type.cgi b/apache/save_gmime_type.cgi index 015fd870f..fbb741292 100755 --- a/apache/save_gmime_type.cgi +++ b/apache/save_gmime_type.cgi @@ -12,7 +12,7 @@ if ($in{'type'} !~ /^(\S+)\/(\S+)$/) { } &lock_file($in{'file'}); -open(MIME, $in{'file'}); +open(MIME, "<$in{'file'}"); @mime = ; close(MIME); $line = "$in{'type'} ".join(" ", split(/\s+/, $in{'exts'}))."\n"; diff --git a/at/freebsd-lib.pl b/at/freebsd-lib.pl index 05d59e88a..76bbb0bf0 100755 --- a/at/freebsd-lib.pl +++ b/at/freebsd-lib.pl @@ -15,7 +15,7 @@ while(my $f = readdir($DIR)) { 'date' => hex($2) * 60, 'user' => scalar(getpwuid($st[4])), 'created' => $st[9] }; - open(my $FILE, $p); + open(my $FILE, "<".$p); while(<$FILE>) { $job->{'cmd'} .= $_; } diff --git a/at/irix-lib.pl b/at/irix-lib.pl index 1400c63c1..61f154f96 100755 --- a/at/irix-lib.pl +++ b/at/irix-lib.pl @@ -14,7 +14,7 @@ while($f = readdir(DIR)) { 'date' => $1, 'user' => scalar(getpwuid($st[4])), 'created' => $st[9] }; - open(FILE, $p); + open(FILE, "<".$p); while() { $job->{'cmd'} .= $_; } diff --git a/at/openserver-lib.pl b/at/openserver-lib.pl index bce9d0580..43e60fb98 100755 --- a/at/openserver-lib.pl +++ b/at/openserver-lib.pl @@ -14,7 +14,7 @@ while($f = readdir(DIR)) { 'date' => $1, 'user' => scalar(getpwuid($st[4])), 'created' => $st[9] }; - open(FILE, $p); + open(FILE, "<".$p); while() { $job->{'cmd'} .= $_; } diff --git a/backup-config/backup-config-lib.pl b/backup-config/backup-config-lib.pl index debb545e9..c8a69c89e 100755 --- a/backup-config/backup-config-lib.pl +++ b/backup-config/backup-config-lib.pl @@ -495,7 +495,7 @@ else { } # Validate archive -open(FILE, $file); +open(FILE, "<".$file); my $two; read(FILE, $two, 2); close(FILE); @@ -537,7 +537,7 @@ my %mfiles; my @files; while($m = readdir(DIR)) { next if ($m eq "." || $m eq ".." || !$hasmod{$m}); - open(MAN, "$manifests_dir/$m"); + open(MAN, "<$manifests_dir/$m"); my @mfiles; while() { s/\r|\n//g; diff --git a/backup-config/backup.cgi b/backup-config/backup.cgi index 9b91782d2..0af584fac 100755 --- a/backup-config/backup.cgi +++ b/backup-config/backup.cgi @@ -49,7 +49,7 @@ else { } print "Content-type: application/x-gzip\n\n"; my $buf; - open(TEMP, $temp); + open(TEMP, "<$temp"); while(read(TEMP, $buf, 1024)) { print $buf; } diff --git a/bacula-backup/bacula-backup-lib.pl b/bacula-backup/bacula-backup-lib.pl index b66178287..3aca81865 100755 --- a/bacula-backup/bacula-backup-lib.pl +++ b/bacula-backup/bacula-backup-lib.pl @@ -66,7 +66,7 @@ if (!defined($config_file_cache{$file})) { local @rv = ( ); local $parent = { 'members' => \@rv }; local $lnum = 0; - open(CONF, $_[0]) || return undef; + open(CONF, "<".$_[0]) || return undef; local @lines = ; close(CONF); for(my $i=0; $i<@lines; $i++) { @@ -813,7 +813,7 @@ return undef; sub get_bacula_version_cached { -open(CACHE, "$module_config_directory/version"); +open(CACHE, "<$module_config_directory/version"); chop($version = ); close(CACHE); return $version || &get_bacula_version(); diff --git a/bandwidth/rotate.pl b/bandwidth/rotate.pl index 83067122f..b667cbf32 100755 --- a/bandwidth/rotate.pl +++ b/bandwidth/rotate.pl @@ -32,7 +32,7 @@ $time_now = time(); # Scan the entries in the log file &pre_process(); -open(LOG, $bandwidth_log); +open(LOG, "<".$bandwidth_log); while() { if (&process_line($_, \@hours, $time_now)) { # Found a valid line @@ -57,7 +57,7 @@ foreach $hour (@hours) { # Truncate the file (if it exists) and notify syslog if (-r $bandwidth_log) { - open(LOG, ">$bandwidth_log"); + open(LOG, ">".$bandwidth_log); close(LOG); } &foreign_call($syslog_module, "signal_syslog"); diff --git a/bsdexports/bsdexports-lib.pl b/bsdexports/bsdexports-lib.pl index f8cb7c49c..ecbc517ce 100755 --- a/bsdexports/bsdexports-lib.pl +++ b/bsdexports/bsdexports-lib.pl @@ -27,7 +27,7 @@ else { sub list_exports { local(@rv, $lnum, $_); -open(EXP, $config{'exports_file'}); +open(EXP, "<".$config{'exports_file'}); $lnum = -1; $index = 0; while() { $lnum++; diff --git a/bsdfdisk/bsdfdisk-lib.pl b/bsdfdisk/bsdfdisk-lib.pl index 87a31f9ab..da9c9b6c5 100644 --- a/bsdfdisk/bsdfdisk-lib.pl +++ b/bsdfdisk/bsdfdisk-lib.pl @@ -97,7 +97,7 @@ foreach my $dev (glob("/dev/ada[0-9]"), } # Get disk model from dmesg - open(DMESG, "/var/run/dmesg.boot"); + open(DMESG, ") { if (/^(\S+):\s+(\S+\s+)?<(.*)>/ && $1 eq $disk->{'short'}) { $disk->{'model'} = $3; diff --git a/changepass.pl b/changepass.pl index 7294826d1..e196c6c74 100755 --- a/changepass.pl +++ b/changepass.pl @@ -9,7 +9,7 @@ if (!-d $config) { print STDERR "The config directory $config does not exist\n"; exit 2; } -if (!open(CONF, "$config/miniserv.conf")) { +if (!open(CONF, "<$config/miniserv.conf")) { print STDERR "Failed to open $config/miniserv.conf : $!\n"; print STDERR "Maybe $config is not the Webmin config directory.\n"; exit 3; @@ -20,7 +20,7 @@ while() { close(CONF); # Update the users file -if (!open(USERS, $config{'userfile'})) { +if (!open(USERS, "<".$config{'userfile'})) { print STDERR "Failed to open Webmin users file $config{'userfile'} : $!\n"; exit 4; } @@ -43,7 +43,7 @@ srand(time() ^ $$); $salt = chr(int(rand(26))+65).chr(int(rand(26))+65); $uinfo->[1] = crypt($pass, $salt); $uinfo->[6] = time(); -if (!open(USERS, "> $config{'userfile'}")) { +if (!open(USERS, ">$config{'userfile'}")) { print STDERR "Failed to open Webmin users file $config{'userfile'} : $!\n"; exit 6; } @@ -54,7 +54,7 @@ close(USERS); print "Updated password of Webmin user $user\n"; # Send a signal to have miniserv reload it's config -if (open(PID, $config{'pidfile'})) { +if (open(PID, "<".$config{'pidfile'})) { $pid = ; $pid =~ s/\r|\n//; close(PID); diff --git a/cluster-shell/index.cgi b/cluster-shell/index.cgi index 2588c41b2..61192c65c 100755 --- a/cluster-shell/index.cgi +++ b/cluster-shell/index.cgi @@ -12,7 +12,7 @@ print &ui_table_start(undef, undef, 2); print &ui_table_row($text{'index_cmd'}, &ui_textbox("cmd", undef, 60)); -open(COMMANDS, $commands_file); +open(COMMANDS, "<$commands_file"); chop(@commands = ); close(COMMANDS); if (@commands) { diff --git a/cluster-software/cluster-software-lib.pl b/cluster-software/cluster-software-lib.pl index 44ab6b965..1568829aa 100755 --- a/cluster-software/cluster-software-lib.pl +++ b/cluster-software/cluster-software-lib.pl @@ -97,7 +97,7 @@ return $_[0]->{'desc'} || $_[0]->{'realhost'} || $_[0]->{'host'}; # Returns an array of open categories sub get_heiropen { -open(HEIROPEN, "$module_config_directory/heiropen.$_[0]"); +open(HEIROPEN, "<$module_config_directory/heiropen.$_[0]"); local @heiropen = ; chop(@heiropen); close(HEIROPEN); diff --git a/cluster-useradmin/edit_user.cgi b/cluster-useradmin/edit_user.cgi index cea00282d..5d2a2d51b 100755 --- a/cluster-useradmin/edit_user.cgi +++ b/cluster-useradmin/edit_user.cgi @@ -35,7 +35,7 @@ foreach $h (@hosts) { push(@shlist, $u->{'shell'}) if ($u->{'shell'}); } } -open(SHELLS, "/etc/shells"); +open(SHELLS, ") { s/\r|\n//g; s/#.*$//; diff --git a/cluster-useradmin/user_form.cgi b/cluster-useradmin/user_form.cgi index 43b3262bd..aa084610d 100755 --- a/cluster-useradmin/user_form.cgi +++ b/cluster-useradmin/user_form.cgi @@ -21,7 +21,7 @@ foreach $h (@hosts) { push(@glist, $g) if (!$donegroup{$g->{'group'}}++); } } -open(SHELLS, "/etc/shells"); +open(SHELLS, ") { s/\r|\n//g; s/#.*$//; diff --git a/cluster-usermin/edit_mod.cgi b/cluster-usermin/edit_mod.cgi index 3b1409150..345a410d8 100755 --- a/cluster-usermin/edit_mod.cgi +++ b/cluster-usermin/edit_mod.cgi @@ -80,7 +80,7 @@ if ($type eq 'mod') { print $text{'edit_osall'}; } else { - open(OSLIST, "$root_directory/os_list.txt"); + open(OSLIST, "<$root_directory/os_list.txt"); while() { chop; if (/^([^\t]+)\t+([^\t]+)\t+(\S+)\t+(\S+)\t*(.*)$/) { diff --git a/cluster-usermin/install.cgi b/cluster-usermin/install.cgi index 519638a39..4e812f31c 100755 --- a/cluster-usermin/install.cgi +++ b/cluster-usermin/install.cgi @@ -63,7 +63,7 @@ elsif ($in{source} == 2) { $grant = $in{'grant'} ? undef : [ split(/\s+/, $in{'grantto'}) ]; # Check validity -open(MFILE, $pfile); +open(MFILE, "<$pfile"); read(MFILE, $two, 2); close(MFILE); if ($two eq "\037\235") { diff --git a/cluster-usermin/upgrade.cgi b/cluster-usermin/upgrade.cgi index 4b46e7b14..5e949ed4e 100755 --- a/cluster-usermin/upgrade.cgi +++ b/cluster-usermin/upgrade.cgi @@ -37,7 +37,7 @@ elsif ($in{'source'} == 2) { $file = &tempname(); &http_download($usermin::update_host, $usermin::update_port, '/index6.html', $file, \$error); $error && &inst_error($error); - open(FILE, $file); + open(FILE, "<$file"); while() { if (/usermin-([0-9\.]+)\.tar\.gz/) { $site_version = $1; @@ -138,7 +138,7 @@ else { } # gunzip the file if needed -open(FILE, $file); +open(FILE, "<$file"); read(FILE, $two, 2); close(FILE); if ($two eq "\037\213") { diff --git a/cluster-webmin/edit_mod.cgi b/cluster-webmin/edit_mod.cgi index 094a29cbc..ad768a1b3 100755 --- a/cluster-webmin/edit_mod.cgi +++ b/cluster-webmin/edit_mod.cgi @@ -85,7 +85,7 @@ if ($type eq 'mod') { print $text{'edit_osall'}; } else { - open(OSLIST, "$root_directory/os_list.txt"); + open(OSLIST, "<$root_directory/os_list.txt"); while() { chop; if (/^([^\t]+)\t+([^\t]+)\t+(\S+)\t+(\S+)\t*(.*)$/) { diff --git a/cluster-webmin/install.cgi b/cluster-webmin/install.cgi index 768048a71..96029f61e 100755 --- a/cluster-webmin/install.cgi +++ b/cluster-webmin/install.cgi @@ -63,7 +63,7 @@ elsif ($in{source} == 2) { $grant = $in{'grant'} ? undef : [ split(/\s+/, $in{'grantto'}) ]; # Check validity -open(MFILE, $pfile); +open(MFILE, "<$pfile"); read(MFILE, $two, 2); close(MFILE); if ($two eq "\037\235") { diff --git a/cluster-webmin/upgrade.cgi b/cluster-webmin/upgrade.cgi index 4a0a21ab7..29153a713 100755 --- a/cluster-webmin/upgrade.cgi +++ b/cluster-webmin/upgrade.cgi @@ -200,7 +200,7 @@ else { } # gunzip the file if needed -open(FILE, $file); +open(FILE, "<$file"); read(FILE, $two, 2); close(FILE); if ($two eq "\037\213") { diff --git a/copyconfig.pl b/copyconfig.pl index 6b02ddc89..d10404656 100755 --- a/copyconfig.pl +++ b/copyconfig.pl @@ -119,7 +119,7 @@ sub read_file { local($arr); $arr = $_[1]; -open(ARFILE, $_[0]) || return 0; +open(ARFILE, "<".$_[0]) || return 0; while() { s/\r|\n//g; if (!/^#/ && /^([^=]+)=(.*)$/) { $$arr{$1} = $2; } @@ -134,7 +134,7 @@ sub write_file { local($arr); $arr = $_[1]; -open(ARFILE, "> $_[0]"); +open(ARFILE, ">".$_[0]); foreach $k (keys %$arr) { print ARFILE "$k=$$arr{$k}\n"; } diff --git a/cpan/cpan-lib.pl b/cpan/cpan-lib.pl index bd46f00f3..9989e3da6 100755 --- a/cpan/cpan-lib.pl +++ b/cpan/cpan-lib.pl @@ -65,7 +65,7 @@ foreach $d (&expand_usr64($Config{'privlib'}), # Add the files in the .packlist local (%donefile, $l); - open(FILE, $f); + open(FILE, "<".$f); while($l = ) { chop($l); $l =~ s/^\/tmp\/[^\/]+//; @@ -239,7 +239,7 @@ local $pf = $f; local $ver = $_[0]->{'version'}; $pf =~ s/\.pm$/\.pod/; local ($got_version, $got_name); -open(MOD, $pf) || open(MOD, $f); +open(MOD, "<".$pf) || open(MOD, "<".$f); while() { if (/^=head1\s+name/i && !$got_name) { $in_name = 1; diff --git a/cpan/download.cgi b/cpan/download.cgi index 3f170c742..5830edfa4 100755 --- a/cpan/download.cgi +++ b/cpan/download.cgi @@ -125,7 +125,7 @@ elsif ($in{'source'} == 3) { print "

\n"; # Make sure it is valid - open(PFILE, $packages_file); + open(PFILE, "<$packages_file"); read(PFILE, $two, 2); close(PFILE); if ($two ne "\037\213") { @@ -273,7 +273,7 @@ foreach $d (@dirs) { system("$cmd >/dev/null 2>&1 ) { last if /MakeMaker post_initialize section/; if (/^#\s+PREREQ_PM\s+=>\s+(.+)/) { diff --git a/create-module.pl b/create-module.pl index c86163370..d86cb4734 100755 --- a/create-module.pl +++ b/create-module.pl @@ -105,7 +105,7 @@ if ($createsig) { # Fill an associative array with name=value pairs from a file sub read_file { -open(ARFILE, $_[0]) || return 0; +open(ARFILE, "<".$_[0]) || return 0; while() { s/\r|\n//g; if (!/^#/ && /^([^=]*)=(.*)$/) { @@ -123,7 +123,7 @@ sub write_file { local(%old, @order); &read_file($_[0], \%old, \@order); -open(ARFILE, ">$_[0]"); +open(ARFILE, ">".$_[0]); foreach $k (@order) { print ARFILE $k,"=",$_[1]->{$k},"\n" if (exists($_[1]->{$k})); } diff --git a/cron/cron-lib.pl b/cron/cron-lib.pl index 7c2222e1b..1bcc983c1 100755 --- a/cron/cron-lib.pl +++ b/cron/cron-lib.pl @@ -701,7 +701,7 @@ sub save_envs { local($i, @tab, $line); @tab = &read_crontab($_[0]); -open(TAB, ">$cron_temp_file"); +open(TAB, ">".$cron_temp_file); for($i=1; $i<@_; $i+=2) { print TAB "$_[$i]=$_[$i+1]\n"; } @@ -1231,7 +1231,7 @@ local $perl_path = &get_perl_path(); &open_tempfile(CMD, ">$_[0]"); &print_tempfile(CMD, <) { \$root = \$1 if (/^root=(.*)/); } diff --git a/cron/cron_editor.pl b/cron/cron_editor.pl index 6c3607f33..51cd1a9e4 100755 --- a/cron/cron_editor.pl +++ b/cron/cron_editor.pl @@ -5,8 +5,8 @@ sleep(1); # This is needed because the stupid crontab -e command # checks the mtime before and after editing, and if they are # the same it assumes no change has been made!! -open(SRC, $ENV{"CRON_EDITOR_COPY"}); -open(DST, ">$ARGV[0]") || die "Failed to open $ARGV[0] : $!"; +open(SRC, "<".$ENV{"CRON_EDITOR_COPY"}); +open(DST, ">".$ARGV[0]) || die "Failed to open $ARGV[0] : $!"; while() { if (!/^#.*DO NOT EDIT/i && !/^#.*installed on/i && !/^#.*Cron version/i) { diff --git a/custom/custom-lib.pl b/custom/custom-lib.pl index 524b803e7..d4d92208e 100755 --- a/custom/custom-lib.pl +++ b/custom/custom-lib.pl @@ -20,7 +20,7 @@ while($f = readdir(DIR)) { # Read custom-command file $cmd{'file'} = "$mcd/$f"; $cmd{'id'} = $1; - open(FILE, $cmd{'file'}); + open(FILE, "<".$cmd{'file'}); chop($cmd{'cmd'} = ); chop($cmd{'desc'} = ); local @o = split(/\s+/, ); @@ -38,7 +38,7 @@ while($f = readdir(DIR)) { # Read file-editor file $cmd{'file'} = "$mcd/$f"; $cmd{'id'} = $1; - open(FILE, $cmd{'file'}); + open(FILE, "<".$cmd{'file'}); chop($cmd{'edit'} = ); chop($cmd{'desc'} = ); chop($cmd{'user'} = ); @@ -56,7 +56,7 @@ while($f = readdir(DIR)) { # Read SQL file $cmd{'file'} = "$mcd/$f"; $cmd{'id'} = $1; - open(FILE, $cmd{'file'}); + open(FILE, "<".$cmd{'file'}); chop($cmd{'desc'} = ); chop($cmd{'type'} = ); chop($cmd{'db'} = ); @@ -82,14 +82,14 @@ while($f = readdir(DIR)) { } close(FILE); $cmd{'index'} = scalar(@rv); - open(HTML, "$mcd/$cmd{'id'}.html"); + open(HTML, "<$mcd/$cmd{'id'}.html"); while() { $cmd{'html'} .= $_; } close(HTML); # Read cluster hosts file - open(CLUSTER, "$mcd/$cmd{'id'}.hosts"); + open(CLUSTER, "<$mcd/$cmd{'id'}.hosts"); while() { s/\r|\n//g; push(@{$cmd{'hosts'}}, $_); @@ -308,7 +308,7 @@ if ($file !~ /^\// && $file !~ /\|\s*$/) { $file = "$uinfo[7]/$file"; } } -open(FILE, $file); +open(FILE, "<".$file); while() { s/\r|\n//g; next if (/^#/); diff --git a/dfsadmin/dfs-lib.pl b/dfsadmin/dfs-lib.pl index f1aed75cf..3b9ec25f3 100755 --- a/dfsadmin/dfs-lib.pl +++ b/dfsadmin/dfs-lib.pl @@ -7,7 +7,7 @@ use WebminCore; %access = &get_module_acl(); $default_type = 'nfs'; -if ($config{'fstypes_file'} && open(TYPES, $config{'fstypes_file'})) { +if ($config{'fstypes_file'} && open(TYPES, "<".$config{'fstypes_file'})) { if ( =~ /^(\S+)/) { $default_type = $1; } @@ -21,7 +21,7 @@ sub list_shares { local $lnum = 0; local @rv; -open(DFS, $config{'dfstab_file'}); +open(DFS, "<".$config{'dfstab_file'}); while() { s/\r|\n//g; s/#.*$//; if (/^\s*\S*share\s+(.*)/) { diff --git a/dhcpd/dhcpd-lib.pl b/dhcpd/dhcpd-lib.pl index bdb31d1f9..6b8538d86 100755 --- a/dhcpd/dhcpd-lib.pl +++ b/dhcpd/dhcpd-lib.pl @@ -70,7 +70,7 @@ sub tokenize_file { local $lines = 0; local ($line, $cmode); -open(FILE, $_[0]); +open(FILE, "<".$_[0]); while($line = ) { # strip comments $line =~ s/\r|\n//g; diff --git a/dhcpd/edit_iface.cgi b/dhcpd/edit_iface.cgi index 6d9cdbe3a..6247fe7fc 100755 --- a/dhcpd/edit_iface.cgi +++ b/dhcpd/edit_iface.cgi @@ -10,7 +10,7 @@ $access{'noconfig'} && &error($text{'iface_ecannot'}); if ($config{'interfaces_type'} eq 'mandrake') { if (-r "/etc/conf.linuxconf") { # Older mandrake's init script uses a linuxconf setting - open(FILE, "/etc/conf.linuxconf"); + open(FILE, ") { if (/DHCP.interface\s+(.*)/) { $iface = $1; diff --git a/dhcpd/index.cgi b/dhcpd/index.cgi index 93ad6a1d5..c3b9d06e8 100755 --- a/dhcpd/index.cgi +++ b/dhcpd/index.cgi @@ -12,14 +12,14 @@ $display_max = $config{'display_max'} || 1000000000; &ReadParse(); $horder = $in{'horder'}; $norder = $in{'norder'}; -if ($horder eq "" && open(INDEX, "$module_config_directory/hindex.".$remote_user)) { +if ($horder eq "" && open(INDEX, "<$module_config_directory/hindex.".$remote_user)) { chop($horder = ); close(INDEX); } if (!$horder) { $horder = 0; } -if ($norder eq "" && open(INDEX, "$module_config_directory/nindex.".$remote_user)) { +if ($norder eq "" && open(INDEX, "<$module_config_directory/nindex.".$remote_user)) { chop($norder = ); close(INDEX); } diff --git a/dovecot/dovecot-lib.pl b/dovecot/dovecot-lib.pl index e5a19b33f..5ea1510bd 100755 --- a/dovecot/dovecot-lib.pl +++ b/dovecot/dovecot-lib.pl @@ -37,7 +37,7 @@ local $filedir = $file; $filedir =~ s/\/[^\/]+$//; local $lnum = 0; local ($section, @sections); -open(CONF, $file); +open(CONF, "<".$file); local @lines = ; close(CONF); local $_; diff --git a/exim/exim-lib.pl b/exim/exim-lib.pl index 9e56f1935..143d35614 100755 --- a/exim/exim-lib.pl +++ b/exim/exim-lib.pl @@ -82,7 +82,7 @@ sub create_aliases_file($) if ( ! -e $file ) { - open(CONF,"> $file"); + open(CONF, ">$file"); print CONF < ) { if ( /^([^\*\#\s:]+):?\s+(.*)$/ ) diff --git a/exports/exports-lib.pl b/exports/exports-lib.pl index 3ab6c913f..8509479b4 100755 --- a/exports/exports-lib.pl +++ b/exports/exports-lib.pl @@ -17,7 +17,7 @@ sub list_exports { my (@rv, $pos, $h, $o, $line); return @list_exports_cache if (@list_exports_cache); -open(EXP, $config{'exports_file'}); +open(EXP, "<".$config{'exports_file'}); my $lnum = 0; while(my $line = ) { my $slnum = $lnum; diff --git a/fdisk/fdisk-lib.pl b/fdisk/fdisk-lib.pl index b25a1f74f..a95834ac1 100755 --- a/fdisk/fdisk-lib.pl +++ b/fdisk/fdisk-lib.pl @@ -51,7 +51,7 @@ if (scalar(@list_disks_partitions_cache)) { local (@pscsi, @dscsi, $dscsi_mode); if (-r "/proc/scsi/sg/devices" && -r "/proc/scsi/sg/device_strs") { # Get device info from various /proc/scsi files - open(DEVICES, "/proc/scsi/sg/devices"); + open(DEVICES, ") { s/\r|\n//g; local @l = split(/\t+/, $_); @@ -63,7 +63,7 @@ if (-r "/proc/scsi/sg/devices" && -r "/proc/scsi/sg/device_strs") { } close(DEVICES); local $i = 0; - open(DEVNAMES, "/proc/scsi/sg/device_strs"); + open(DEVNAMES, ") { s/\r|\n//g; local @l = split(/\t+/, $_); @@ -77,7 +77,7 @@ if (-r "/proc/scsi/sg/devices" && -r "/proc/scsi/sg/device_strs") { } else { # Check /proc/scsi/scsi for SCSI disk models - open(SCSI, "/proc/scsi/scsi"); + open(SCSI, "; close(SCSI); if ($lines[0] =~ /^Attached\s+domains/i) { @@ -122,7 +122,7 @@ else { } local (@disks, @devs, $d); -if (open(PARTS, "/proc/partitions")) { +if (open(PARTS, ") { @@ -154,7 +154,7 @@ if (open(PARTS, "/proc/partitions")) { elsif (/\d+\s+\d+\s+\d+\s+hd([a-z]+)\s/) { # IDE disk (but skip CDs) local $n = $1; - if (open(MEDIA, "/proc/ide/hd$n/media")) { + if (open(MEDIA, "; close(MEDIA); if ($media =~ /^disk/ && !$_[0]) { @@ -368,7 +368,7 @@ while() { # Mylex raid device local ($mc, $md) = ($2, $3); $disk->{'desc'} = &text('select_mylex', $mc, $md); - open(RD, "/proc/rd/c$mc/current_status"); + open(RD, ") { if (/^Configuring\s+(.*)/i) { $disk->{'model'} = $1; @@ -386,7 +386,7 @@ while() { # Compaq RAID device local ($ic, $id) = ($2, $3); $disk->{'desc'} = &text('select_cpq', $ic, $id); - open(IDA, -d "/proc/driver/array" ? "/proc/driver/array/ida$ic" : "/proc/driver/cpqarray/ida$ic"); + open(IDA, -d "/proc/driver/array" ? ") { if (/^(\S+):\s+(.*)/ && $1 eq "ida$ic") { $disk->{'model'} = $2; @@ -400,7 +400,7 @@ while() { # Compaq Smart Array RAID local ($ic, $id) = ($2, $3); $disk->{'desc'} = &text('select_smart', $ic, $id); - open(CCI, "/proc/driver/cciss/cciss$ic"); + open(CCI, ") { if (/^\s*(\S+):\s*(.*)/ && $1 eq "cciss$ic") { $disk->{'model'} = $2; diff --git a/fetchmail/fetchmail-lib.pl b/fetchmail/fetchmail-lib.pl index 4de3a4294..d14b55a82 100755 --- a/fetchmail/fetchmail-lib.pl +++ b/fetchmail/fetchmail-lib.pl @@ -37,7 +37,7 @@ local $lnum = 0; local ($line, @rv, @toks); # Tokenize the file -open(FILE, $_[0]); +open(FILE, "<".$_[0]); while($line = ) { $line =~ s/\r|\n//g; $line =~ s/^\s*#.*$//; diff --git a/fetchmail/index.cgi b/fetchmail/index.cgi index ef5358caa..b687ba7dd 100755 --- a/fetchmail/index.cgi +++ b/fetchmail/index.cgi @@ -44,7 +44,7 @@ if ($config{'config_file'}) { # Show the fetchmail daemon form foreach $pf ($config{'pid_file'}, "$uinfo[7]/.fetchmail.pid", "$uinfo[7]/.fetchmail") { - if (open(PID, $pf) && ($line=) && + if (open(PID, "<$pf") && ($line=) && (($pid,$interval) = split(/\s+/, $line)) && $pid && kill(0, $pid)) { $running++; diff --git a/filter/autoreply-file-lib.pl b/filter/autoreply-file-lib.pl index e2dbf6d54..e36f8b935 100755 --- a/filter/autoreply-file-lib.pl +++ b/filter/autoreply-file-lib.pl @@ -6,7 +6,7 @@ sub read_autoreply { local ($file, $simple) = @_; local @lines; -open(FILE, $file); +open(FILE, "<".$file); while() { if (/^Reply-Tracking:\s*(.*)/) { $simple->{'replies'} = $1; diff --git a/firewall/edit_rule.cgi b/firewall/edit_rule.cgi index 44f35a626..17e190992 100755 --- a/firewall/edit_rule.cgi +++ b/firewall/edit_rule.cgi @@ -456,7 +456,7 @@ local ($name, $value) = @_; local @stdprotos = ( 'tcp', 'udp', "icmp${ipvx_icmp}", undef ); $value ||= "tcp"; local @otherprotos; -open(PROTOS, "/etc/protocols"); +open(PROTOS, ") { s/\r|\n//g; s/#.*$//; diff --git a/firewall/firewall-lib.pl b/firewall/firewall-lib.pl index 8bb72dd54..99efadfc2 100755 --- a/firewall/firewall-lib.pl +++ b/firewall/firewall-lib.pl @@ -66,7 +66,7 @@ elsif ($file eq "direct") { # Read active rules $file = $direct; } -open(FILE, $file); +open(FILE, "<".$file); local $cmt; LINE: while() { diff --git a/fsdump/backup.pl b/fsdump/backup.pl index f4b0ed416..7c5526d67 100755 --- a/fsdump/backup.pl +++ b/fsdump/backup.pl @@ -85,7 +85,7 @@ else { if ($temp) { # Read output - open(OUT, $temp); + open(OUT, "<".$temp); while() { s/\r//g; $out .= $_; diff --git a/grub/grub-lib.pl b/grub/grub-lib.pl index 36fbaf205..6e02f7f79 100755 --- a/grub/grub-lib.pl +++ b/grub/grub-lib.pl @@ -18,7 +18,7 @@ sub get_menu_config { local $lnum = 0; local (@rv, $title); -open(CONF, $config{'menu_file'}); +open(CONF, "<".$config{'menu_file'}); while() { s/#.*$//; s/\r|\n//g; @@ -216,7 +216,7 @@ else { # Just use the existing file $dm = $config{'device_map'}; } -open(MAP, $dm); +open(MAP, "<".$dm); while() { s/\r|\n//g; s/#.*$//; diff --git a/heartbeat/heartbeat-lib.pl b/heartbeat/heartbeat-lib.pl index 2865acd7e..1558ade54 100755 --- a/heartbeat/heartbeat-lib.pl +++ b/heartbeat/heartbeat-lib.pl @@ -13,7 +13,7 @@ $authkeys = $config{'authkeys'} ? $config{'authkeys'} $resource_d = $config{'resource_d'} ? $config{'resource_d'} : "$config{'ha_dir'}/resource.d"; -open(VERSION, "$module_config_directory/version"); +open(VERSION, "<$module_config_directory/version"); chop($heartbeat_version = ); close(VERSION); @@ -21,7 +21,7 @@ sub get_ha_config { local @rv; local $lnum = 0; -open(CONF, $ha_cf); +open(CONF, "<".$ha_cf); while() { s/\s+$//; s/#.*$//; @@ -101,7 +101,7 @@ sub list_resources() { local @rv; local $lnum = 0; -open(RES, $haresources); +open(RES, "<".$haresources); while() { s/\s+$//; s/#.*$//; @@ -160,7 +160,7 @@ return join(" ", @l); sub get_auth_config { local $rv; -open(AUTH, $authkeys); +open(AUTH, "<".$authkeys); while() { s/\r|\n//g; s/#.*$//; diff --git a/hpuxexports/hpux-lib.pl b/hpuxexports/hpux-lib.pl index a44051e2e..ae727a1d7 100755 --- a/hpuxexports/hpux-lib.pl +++ b/hpuxexports/hpux-lib.pl @@ -7,7 +7,7 @@ sub list_exports { local (@rv, $pos, $lnum, $h, $o, $line); return @list_exports_cache if (@list_exports_cache); -open(EXP, $config{'exports_file'}); +open(EXP, "<".$config{'exports_file'}); $lnum = 0; while($line = ) { local $slnum = $lnum; diff --git a/hpuxexports/hpuxexports-lib.pl b/hpuxexports/hpuxexports-lib.pl index 20e7db850..de05bbf19 100755 --- a/hpuxexports/hpuxexports-lib.pl +++ b/hpuxexports/hpuxexports-lib.pl @@ -11,7 +11,7 @@ use Socket; sub list_exports { local(@rv); -open(EXP, $config{exports_file}); +open(EXP, "<".$config{exports_file}); while() { chop; s/#.*//g; if (!/\S/) { next; } @@ -28,7 +28,7 @@ return @rv; sub get_exports { local(@rv); -open(EXP, $config{exports_file}); +open(EXP, "<".$config{exports_file}); while() { chop; s/#.*//g; if (!/\S/) { next; } @@ -64,7 +64,7 @@ if ($_[1]) { &print_tempfile(EXP, "-$_[1]\n"); }; sub modify_export { local(@exp); -open(EXP, $config{exports_file}); +open(EXP, "<".$config{exports_file}); @exp = ; close(EXP); &open_tempfile(EXP, "> $config{exports_file}"); @@ -90,7 +90,7 @@ foreach (@exp) { sub delete_export { local(@exp); -open(EXP, $config{exports_file}); +open(EXP, "<".$config{exports_file}); @exp = ; close(EXP); &open_tempfile(EXP, "> $config{exports_file}"); diff --git a/htaccess-htpasswd/htaccess-lib.pl b/htaccess-htpasswd/htaccess-lib.pl index be7fa37e1..480226dec 100755 --- a/htaccess-htpasswd/htaccess-lib.pl +++ b/htaccess-htpasswd/htaccess-lib.pl @@ -61,7 +61,7 @@ sub list_directories { my @rv; my $fh; -open($fh, $directories_file) || return (); +open($fh, "<".$directories_file) || return (); while(<$fh>) { s/\r|\n//g; my @dir = split(/\t+/, $_); diff --git a/htpasswd-file/htpasswd-file-lib.pl b/htpasswd-file/htpasswd-file-lib.pl index 4ed77fdd4..0da0f786a 100755 --- a/htpasswd-file/htpasswd-file-lib.pl +++ b/htpasswd-file/htpasswd-file-lib.pl @@ -26,7 +26,7 @@ if (!defined($list_authusers_cache{$file})) { local $_; my $lnum = 0; my $count = 0; - if (open(HTPASSWD, $file)) { + if (open(HTPASSWD, "<".$file)) { while() { if (/^(#?)\s*([^:]+):(\S*)/) { push(@{$list_authusers_cache{$file}}, @@ -56,7 +56,7 @@ if (!defined($list_authusers_cache{$file})) { local $_; my $lnum = 0; my $count = 0; - if (open(HTPASSWD, $file)) { + if (open(HTPASSWD, "<".$file)) { while() { if (/^(#?)\s*(\S+):(\S+):(\S*)/) { push(@{$list_authusers_cache{$file}}, @@ -201,7 +201,7 @@ if (!defined($list_authgroups_cache{$file})) { local $_; my $lnum = 0; my $count = 0; - open(HTPASSWD, $file); + open(HTPASSWD, "<".$file); while() { if (/^(#?)\s*(\S+):\s*(.*)/) { push(@{$list_authgroups_cache{$file}}, diff --git a/idmapd/idmapd-lib.pl b/idmapd/idmapd-lib.pl index d62c345e7..9e318bb02 100755 --- a/idmapd/idmapd-lib.pl +++ b/idmapd/idmapd-lib.pl @@ -9,7 +9,7 @@ use WebminCore; # Returns the idmapd config sub get_config { local %conf; - open(FILE, $config{'idmapd_conf'}); + open(FILE, "<".$config{'idmapd_conf'}); while() { chomp; s/#.*//; diff --git a/idmapd/save.cgi b/idmapd/save.cgi index 31773a93a..ed6d1b001 100755 --- a/idmapd/save.cgi +++ b/idmapd/save.cgi @@ -12,7 +12,7 @@ require './idmapd-lib.pl'; # Write the config file &lock_file($config{'idmapd_conf'}); -open(FILE, "> $config{'idmapd_conf'}"); +open(FILE, ">$config{'idmapd_conf'}"); print FILE "[General]\n"; print FILE "Pipefs-Directory = $in{'pipefsdir'}\n"; print FILE "Domain = $in{'domain'}\n"; diff --git a/inetd/inetd-generic-lib.pl b/inetd/inetd-generic-lib.pl index f5511c5b4..c20d2b38b 100755 --- a/inetd/inetd-generic-lib.pl +++ b/inetd/inetd-generic-lib.pl @@ -7,7 +7,7 @@ sub list_services local(@rv, $l); $l = 0; system("$config{'get_services_command'}") if ($config{'get_services_command'}); -open(SERVICES, $config{services_file}); +open(SERVICES, "<".$config{services_file}); while() { chop; s/#.*$//g; if (/^(\S+)\s+([0-9]+)\/(\S+)\s*(.*)$/) { @@ -47,7 +47,7 @@ system("$config{'put_services_command'}") if ($config{'put_services_command'}); sub modify_service { local(@serv); -open(SERVICES, $config{services_file}); +open(SERVICES, "<".$config{services_file}); @serv = ; close(SERVICES); $serv[$_[0]] = "$_[1]\t$_[2]/$_[3]".($_[4] ? "\t$_[4]\n" : "\n"); @@ -61,7 +61,7 @@ system("$config{'put_services_command'}") if ($config{'put_services_command'}); sub delete_service { local(@serv); -open(SERVICES, $config{services_file}); +open(SERVICES, "<".$config{services_file}); @serv = ; close(SERVICES); splice(@serv, $_[0], 1); @@ -76,7 +76,7 @@ system("$config{'put_services_command'}") if ($config{'put_services_command'}); sub list_protocols { local(@rv); -open(PROT, $config{protocols_file}); +open(PROT, "<".$config{protocols_file}); while() { chop; s/#.*$//g; if (!/\S/) { next; } @@ -111,7 +111,7 @@ closedir(DIR); # parse each file foreach $f (@files) { $l = 0; - open(INET, $f); + open(INET, "<".$f); while() { chop; if (/^(#+|##)?\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\??\/\S+|internal)\s*(.*)$/) { @@ -144,7 +144,7 @@ sub create_inet sub modify_inet { local(@inet); -open(INET, $_[9]); +open(INET, "<".$_[9]); @inet = ; close(INET); $inet[$_[0]] = ($_[1] ? "" : "#")."$_[2]\t$_[3]\t$_[4]\t$_[5]\t$_[6]\t$_[7]". @@ -160,7 +160,7 @@ $inet[$_[0]] = ($_[1] ? "" : "#")."$_[2]\t$_[3]\t$_[4]\t$_[5]\t$_[6]\t$_[7]". sub delete_inet { local(@inet); -open(INET, $_[1]); +open(INET, "<".$_[1]); @inet = ; close(INET); splice(@inet, $_[0], 1); diff --git a/inetd/inetd-lib.pl b/inetd/inetd-lib.pl index 7432e10ca..cac1477b5 100755 --- a/inetd/inetd-lib.pl +++ b/inetd/inetd-lib.pl @@ -34,7 +34,7 @@ sub list_rpcs { local(@rv, $l); $l = 0; -open(RPC, $config{rpc_file}); +open(RPC, "<".$config{rpc_file}); while() { chop; s/#.*$//g; if (/^(\S+)\s+(\d+)\s*(.*)$/) { @@ -61,7 +61,7 @@ sub create_rpc sub modify_rpc { local(@rpcs); -open(RPC, $config{rpc_file}); +open(RPC, "<".$config{rpc_file}); @rpcs = ; close(RPC); $rpcs[$_[0]] = "$_[1]\t$_[2]".($_[3] ? "\t$_[3]\n" : "\n"); @@ -76,7 +76,7 @@ $rpcs[$_[0]] = "$_[1]\t$_[2]".($_[3] ? "\t$_[3]\n" : "\n"); sub delete_rpc { local(@rpcs); -open(RPC, $config{rpc_file}); +open(RPC, "<".$config{rpc_file}); @rpcs = ; close(RPC); splice(@rpcs, $_[0], 1); diff --git a/inetd/inetd-solaris-10-lib.pl b/inetd/inetd-solaris-10-lib.pl index 85a7a0605..b031935bd 100755 --- a/inetd/inetd-solaris-10-lib.pl +++ b/inetd/inetd-solaris-10-lib.pl @@ -6,7 +6,7 @@ sub list_services local(@rv, $l); $l = 0; system("$config{'get_services_command'}") if ($config{'get_services_command'}); -open(SERVICES, $config{services_file}); +open(SERVICES, "<".$config{services_file}); while() { chop; s/#.*$//g; if (/^(\S+)\s+([0-9]+)\/(\S+)\s*(.*)$/) { @@ -53,7 +53,7 @@ sub modify_service local(@serv, $p); $p = $_[3]; $p =~ s/6.*$//; -open(SERVICES, $config{services_file}); +open(SERVICES, "<".$config{services_file}); @serv = ; close(SERVICES); $serv[$_[0]] = "$_[1]\t$_[2]/$p".($_[4] ? "\t$_[4]\n" : "\n"); @@ -67,7 +67,7 @@ system("$config{'put_services_command'}") if ($config{'put_services_command'}); sub delete_service { local(@serv); -open(SERVICES, $config{services_file}); +open(SERVICES, "<".$config{services_file}); @serv = ; close(SERVICES); splice(@serv, $_[0], 1); @@ -82,7 +82,7 @@ system("$config{'put_services_command'}") if ($config{'put_services_command'}); sub list_protocols { local(@rv); -open(PROT, $config{protocols_file}); +open(PROT, "<".$config{protocols_file}); while() { chop; s/#.*$//g; if (!/\S/) { next; } diff --git a/init/delboot.pl b/init/delboot.pl index 66bf0170a..e245d29e6 100755 --- a/init/delboot.pl +++ b/init/delboot.pl @@ -9,7 +9,7 @@ $ucproduct = ucfirst($product); if ($init_mode eq "local") { # Remove from /etc/webmin/start from boot time rc script - open(LOCAL, $config{'local_script'}); + open(LOCAL, "<".$config{'local_script'}); @local = ; close(LOCAL); $start = "$config_directory/start"; diff --git a/init/edit_hostconfig.cgi b/init/edit_hostconfig.cgi index 039cb3bf5..b1a4cb287 100755 --- a/init/edit_hostconfig.cgi +++ b/init/edit_hostconfig.cgi @@ -46,7 +46,7 @@ if ($ty == 0) { # } print "

\n"; print "
\n"; @@ -60,7 +60,7 @@ if ($ty == 0) { # } print "\n"; print "
\n"; @@ -148,7 +148,7 @@ if ($ty == 2) { "$config{'hostconfig'}"),"
\n"; print "\n"; print "
\n"; diff --git a/init/hostconfig-lib.pl b/init/hostconfig-lib.pl index 338ab4567..08727e143 100755 --- a/init/hostconfig-lib.pl +++ b/init/hostconfig-lib.pl @@ -17,7 +17,7 @@ sub hostconfig_settings #### local($conffile, @hconf); $conffile = "$config{'hostconfig'}"; -open(LOCAL, $conffile); +open(LOCAL, "<".$conffile); @conf = ; close(LOCAL); @conf = grep /^\w/, @conf; @@ -210,7 +210,7 @@ my($action_item, $startupfile) = @_; # get current setting $line = "$config{'hostconfig'}"; -open(HCONF, $line); +open(HCONF, "<".$line); @sconf = ; close(HCONF); @sconf = grep /^$action_item=/, @sconf; @@ -229,7 +229,7 @@ $option_selected = ""; # get possible settings if ( $startupfile ne "" ) { - open(LOCAL, $startupfile); + open(LOCAL, "<".$startupfile); @sfile = ; close(LOCAL); # diff --git a/init/init-lib.pl b/init/init-lib.pl index d83cd17dd..099b69f5b 100755 --- a/init/init-lib.pl +++ b/init/init-lib.pl @@ -373,7 +373,7 @@ sub get_inittab_runlevel local %iconfig = &foreign_config("inittab"); local @rv; local $id = $config{'inittab_id'}; -if (open(TAB, $iconfig{'inittab_file'})) { +if (open(TAB, "<".$iconfig{'inittab_file'})) { # Read the inittab file while() { if (/^$id:(\d+):/ && $1) { @rv = ( $1 ); } @@ -419,7 +419,7 @@ in with supported parameters to the action, like 'start' and 'stop'. sub init_description { # Read contents of script, extract start/stop commands -open(FILE, $_[0]); +open(FILE, "<".$_[0]); local @lines = ; close(FILE); local $data = join("", @lines); @@ -495,7 +495,7 @@ sub chkconfig_info { local @rv; local $desc; -open(FILE, $_[0]); +open(FILE, "<".$_[0]); while() { if (/^#\s*chkconfig:\s+(\S+)\s+(\d+)\s+(\d+)/) { @rv = ( $1 eq '-' ? [ ] : [ split(//, $1) ], $2, $3 ); @@ -525,7 +525,7 @@ if ($init_mode eq "upstart") { quotemeta($name)." 2>&1"); if (!$?) { my $cfile = "/etc/init/$name.conf"; - open(CONF, $cfile); + open(CONF, "<".$cfile); while() { if (/^(#*)\s*start/) { return $1 ? 1 : 2; @@ -572,7 +572,7 @@ elsif ($init_mode eq "local") { # Look for entry in rc.local local $fn = "$module_config_directory/$name.sh"; local $cmd = "$fn start"; - open(LOCAL, $config{'local_script'}); + open(LOCAL, "<".$config{'local_script'}); while() { s/\r|\n//g; $found++ if ($_ eq $cmd); @@ -1207,7 +1207,7 @@ elsif ($mode eq "rc") { } elsif ($mode eq "osx") { # Delete OSX hostconfig entry - open(LOCAL, $config{'hostconfig'}); + open(LOCAL, "<".$config{'hostconfig'}); my @local = ; close(LOCAL); my $start = $name."=-"; @@ -1912,7 +1912,7 @@ foreach my $l (split(/\r?\n/, $out)) { if ($l =~ /process\s+(\d+)/) { $s->{'pid'} = $1; } - open(CONF, "/etc/init/$s->{'name'}.conf"); + open(CONF, "{'name'}.conf"); while() { if (/^description\s+"([^"]+)"/ && !$s->{'desc'}) { $s->{'desc'} = $1; @@ -2378,7 +2378,7 @@ sub get_action_args { my ($file) = @_; my %hasarg; -open(FILE, $file); +open(FILE, "<".$file); while() { if (/^\s*(['"]?)([a-z]+)\1\)/i) { $hasarg{$2}++; diff --git a/init/modifyhostconfig.cgi b/init/modifyhostconfig.cgi index 69c4f341f..22a5e357f 100755 --- a/init/modifyhostconfig.cgi +++ b/init/modifyhostconfig.cgi @@ -34,7 +34,7 @@ $hostc = $config{'hostconfig'}; # modify and write the hostconfig file @new = (); &lock_file($config{'hostconfig'}); -open(LOCAL, "$hostc"); +open(LOCAL, "<$hostc"); @old = ; close(LOCAL); foreach $line (@old) { diff --git a/init/save_hostconfig_action.cgi b/init/save_hostconfig_action.cgi index 96e91bf53..47e8acd5f 100755 --- a/init/save_hostconfig_action.cgi +++ b/init/save_hostconfig_action.cgi @@ -28,7 +28,7 @@ if (not $in{'action_name'}=~ /^[A-Z][A-Z0-9_]*$/ ) { } else { #make sure action name is not in use - open(LOCAL, $config{'hostconfig'}); + open(LOCAL, "<$config{'hostconfig'}"); @temp = ; close(LOCAL); foreach $element (@temp) { diff --git a/init/uninstall.pl b/init/uninstall.pl index 57c4b4a44..b29c9310f 100755 --- a/init/uninstall.pl +++ b/init/uninstall.pl @@ -14,7 +14,7 @@ local $ucproduct = ucfirst($product); if ($init_mode eq "osx") { # Remove from hostconfig file - open(LOCAL, $config{'hostconfig'}); + open(LOCAL, "<".$config{'hostconfig'}); @local = ; close(LOCAL); $start = "WEBMIN=-"; @@ -32,7 +32,7 @@ if ($init_mode eq "osx") { } elsif ($init_mode eq "local") { # Remove from boot time rc script - open(LOCAL, $config{'local_script'}); + open(LOCAL, "<".$config{'local_script'}); @local = ; close(LOCAL); $start = "$config_directory/start"; diff --git a/inittab/inittab-lib.pl b/inittab/inittab-lib.pl index 08386d6bf..523a7c79a 100755 --- a/inittab/inittab-lib.pl +++ b/inittab/inittab-lib.pl @@ -10,7 +10,7 @@ sub parse_inittab { local @rv; local $lnum = 0; -open(INITTAB, $config{'inittab_file'}); +open(INITTAB, "<".$config{'inittab_file'}); while() { s/\r|\n//g; #s/#.*$//g; diff --git a/install-module.pl b/install-module.pl index 98d5a3fb9..db5a556f6 100755 --- a/install-module.pl +++ b/install-module.pl @@ -18,7 +18,7 @@ if (@ARGV > 2 || !@ARGV) { $file = $ARGV[0]; $config = $ARGV[1] ? $ARGV[1] : "/etc/webmin"; -r $file || die "$file does not exist"; -open(CONF, "$config/miniserv.conf") || +open(CONF, "<$config/miniserv.conf") || die "Failed to read $config/miniserv.conf - maybe $config is not a Webmin config directory"; while() { s/\r|\n//g; diff --git a/ipfilter/ipfilter-lib.pl b/ipfilter/ipfilter-lib.pl index 2202f8874..b4448728d 100755 --- a/ipfilter/ipfilter-lib.pl +++ b/ipfilter/ipfilter-lib.pl @@ -6,7 +6,7 @@ use WebminCore; &foreign_require("net", "net-lib.pl"); # Get the detected ipf version -if (open(VERSION, "$module_config_directory/version")) { +if (open(VERSION, "<$module_config_directory/version")) { chop($ipf_version = ); close(VERSION); } @@ -47,7 +47,7 @@ local $file = $_[0] || $config{'ipf_conf'}; return $get_config_cache{$file} if ($get_config_cache{$file}); local @rv; local $lnum = 0; -open(FILE, $file); +open(FILE, "<".$file); while() { # Read each line, splitting into words s/\r|\n//g; @@ -951,7 +951,7 @@ sub get_ipnat_config { local $file = $_[0] || $config{'ipnat_conf'}; return $get_ipnat_config_cache{$file} if ($get_ipnat_config_cache{$file}); -open(FILE, $file); +open(FILE, "<".$file); while() { # Read each line, splitting into words s/\r|\n//g; @@ -1191,7 +1191,7 @@ sub list_protocols { local @stdprotos = ( 'tcp', 'udp', 'icmp' ); local @otherprotos; -open(PROTOS, "/etc/protocols"); +open(PROTOS, ") { s/\r|\n//g; s/#.*$//; diff --git a/ipfw/ipfw-lib.pl b/ipfw/ipfw-lib.pl index 10313e4b0..dd0d6a080 100755 --- a/ipfw/ipfw-lib.pl +++ b/ipfw/ipfw-lib.pl @@ -54,7 +54,7 @@ elsif ($has_net_lib) { @tcpflags = ( "fin", "syn", "rst", "psh", "ack", "urg" ); # Get the detected ipfw version -if (open(VERSION, "$module_config_directory/version")) { +if (open(VERSION, "<$module_config_directory/version")) { chop($ipfw_version = ); close(VERSION); } @@ -72,7 +72,7 @@ if ($_[0] =~ /\|$/) { local @rv; local $cmt; local $lnum = -1; -open(LIST, $file); +open(LIST, "<".$file); while() { ${$_[1]} .= $_ if ($_[1]); $lnum++; @@ -460,7 +460,7 @@ sub list_protocols { local @stdprotos = ( 'tcp', 'udp', 'icmp' ); local @otherprotos; -open(PROTOS, "/etc/protocols"); +open(PROTOS, ") { s/\r|\n//g; s/#.*$//; @@ -687,7 +687,7 @@ if (defined($get_ipfw_format_cache)) { return $get_ipfw_format_cache; } local $fmt; -if (open(FILE, $ipfw_file)) { +if (open(FILE, "<".$ipfw_file)) { # Check existing format while() { if (/^(\d+)\s/) { diff --git a/ipsec/import.cgi b/ipsec/import.cgi index 8ed80d053..7181e2ab8 100755 --- a/ipsec/import.cgi +++ b/ipsec/import.cgi @@ -14,7 +14,7 @@ if ($in{'mode'} == 0) { } else { $in{'file'} || &error($text{'import_efile'}); - open(FILE, $in{'file'}) || &error($text{'import_eopen'}); + open(FILE, "<$in{'file'}") || &error($text{'import_eopen'}); while() { s/\r|\n//g; push(@data, $_); diff --git a/ipsec/ipsec-lib.pl b/ipsec/ipsec-lib.pl index 7d6bdcc10..dd1fc79c6 100755 --- a/ipsec/ipsec-lib.pl +++ b/ipsec/ipsec-lib.pl @@ -16,7 +16,7 @@ local $file = $_[0] || $config{'file'}; local (@rv, $sect); local $lnum = 0; local $fh = "CONF".$get_config_fh++; -open($fh, $file); +open($fh, "<".$file); while(<$fh>) { s/\r|\n//g; s/#.*$//; @@ -182,7 +182,7 @@ return @rv; sub read_policy { local @rv; -open(FILE, "$config{'policies_dir'}/$_[0]"); +open(FILE, "<$config{'policies_dir'}/$_[0]"); while() { push(@rv, "$1/$2") if (/^\s*([0-9\.]+)\/(\d+)/); } @@ -261,7 +261,7 @@ sleep(5); # Look for new error messages local $i; for($i=0; $i<@ipsec_logfiles; $i++) { - open(LOG, $ipsec_logfiles[$i]) || next; + open(LOG, "<".$ipsec_logfiles[$i]) || next; seek(LOG, $ipsec_logfile_sizes[$i], 0); while() { s/\r|\n//g; @@ -292,7 +292,7 @@ return $out =~ /(FreeS\/WAN|Openswan|StrongSWAN|Libreswan)\s+([^ \n\(]+)/i ? ($2 sub got_secret { local $gotkey; -open(SEC, $config{'secrets'}) || return 0; +open(SEC, "<".$config{'secrets'}) || return 0; while() { s/\r|\n//g; s/#.*$//; @@ -356,7 +356,7 @@ sub list_secrets if (!scalar(@list_secrets_cache)) { local (@lines); local $lnum = 0; - open(SEC, $config{'secrets'}); + open(SEC, "<".$config{'secrets'}); while() { s/\r|\n//g; s/^\s*#.*$//; diff --git a/jabber/edit_file.cgi b/jabber/edit_file.cgi index 1243d0135..3dd069925 100755 --- a/jabber/edit_file.cgi +++ b/jabber/edit_file.cgi @@ -11,7 +11,7 @@ print "\n"; print "\n"; print "\n"; print "
$text{'file_header'}

\n"; $fnum++; } @@ -144,7 +142,7 @@ sub show_nis_table { local @f = @{$_[1]->{'files'}}; local $lines = 0; -open(FILE, $f[0]); +open(FILE, "<$f[0]"); while() { s/\r|\n//g; s/^\s*#.*$//; diff --git a/nis/nis-lib.pl b/nis/nis-lib.pl index f7ab8d867..c9548fbaf 100755 --- a/nis/nis-lib.pl +++ b/nis/nis-lib.pl @@ -28,7 +28,7 @@ return "$iconfig{'init_dir'}/$_[0]"; sub get_nsswitch_conf { local @rv; -open(SWITCH, $config{'nsswitch_conf'}); +open(SWITCH, "<".$config{'nsswitch_conf'}); while() { s/\r|\n//g; s/#.*$//g; @@ -141,7 +141,7 @@ sub parse_ypserv_conf { local (%opts, @hosts); local $lnum = 0; -open(CONF, $ypserv_conf); +open(CONF, "<".$ypserv_conf); while() { s/\r|\n//g; s/#.*$//; @@ -183,7 +183,7 @@ sub parse_yp_makefile # First parse joined lines local $lnum = 0; local (@lines, $llast); -open(MAKE, $yp_makefile); +open(MAKE, "<".$yp_makefile); while() { s/\r|\n//g; local $slash = (s/\\$//); diff --git a/nis/old_edit_passwd_shadow.cgi b/nis/old_edit_passwd_shadow.cgi index e2793e64c..1a9b994b1 100755 --- a/nis/old_edit_passwd_shadow.cgi +++ b/nis/old_edit_passwd_shadow.cgi @@ -9,7 +9,7 @@ use Time::Local; # Build list of available shells @shlist = ("/bin/sh", "/bin/csh", "/bin/false"); -open(SHELLS, "/etc/shells"); +open(SHELLS, ") { s/\r|\n//g; s/#.*$//; diff --git a/nis/open-linux-lib.pl b/nis/open-linux-lib.pl index e40b9b69e..24e02682c 100755 --- a/nis/open-linux-lib.pl +++ b/nis/open-linux-lib.pl @@ -20,7 +20,7 @@ return $rv; sub get_client_config { local $nis; -open(CONF, $config{'client_conf'}); +open(CONF, "<".$config{'client_conf'}); while() { s/\r|\n//g; s/#.*$//g; @@ -228,7 +228,7 @@ sub parse_nisupdate_conf { local @rv; local $lnum = 0; -open(CONF, $_[0]); +open(CONF, "<".$_[0]); while() { s/\r|\n//g; if (/^\s*(#*)(\s*\$rule{['"]([^"']+)['"]}.*)/) { diff --git a/nis/openmamba-linux-lib.pl b/nis/openmamba-linux-lib.pl index 3b9b32e12..fcd1076ac 100755 --- a/nis/openmamba-linux-lib.pl +++ b/nis/openmamba-linux-lib.pl @@ -20,7 +20,7 @@ return $rv; sub get_client_config { local $nis; -open(CONF, $config{'client_conf'}); +open(CONF, "<".$config{'client_conf'}); while() { s/\r|\n//g; s/#.*$//g; @@ -160,7 +160,7 @@ printf " \n", $var->{'MINGID'}->{'value'}; print " $text{'server_slaves'}\n"; -open(SLAVES, "/var/yp/ypservers"); +open(SLAVES, ") { s/\s//g; push(@slaves, $_) if ($_); diff --git a/nis/redhat-linux-lib.pl b/nis/redhat-linux-lib.pl index 2f9a2d204..91867d221 100755 --- a/nis/redhat-linux-lib.pl +++ b/nis/redhat-linux-lib.pl @@ -20,7 +20,7 @@ return $rv; sub get_client_config { local $nis; -open(CONF, $config{'client_conf'}); +open(CONF, "<".$config{'client_conf'}); while() { s/\r|\n//g; s/#.*$//g; @@ -160,7 +160,7 @@ printf " \n", $var->{'MINGID'}->{'value'}; print " $text{'server_slaves'}\n"; -open(SLAVES, "/var/yp/ypservers"); +open(SLAVES, ") { s/\s//g; push(@slaves, $_) if ($_); diff --git a/nis/slackware-linux-lib.pl b/nis/slackware-linux-lib.pl index 5da6d6107..9efa2e413 100755 --- a/nis/slackware-linux-lib.pl +++ b/nis/slackware-linux-lib.pl @@ -21,7 +21,7 @@ return $rv; sub get_client_config { local $nis; -open(CONF, $config{'client_conf'}); +open(CONF, "<".$config{'client_conf'}); while() { s/\r|\n//g; s/#.*$//g; @@ -36,7 +36,7 @@ while() { } } close(CONF); -if (open(DOMAIN, $default_domain)) { +if (open(DOMAIN, "<".$default_domain)) { chop($nis->{'domain'} = ); close(DOMAIN); } @@ -157,7 +157,7 @@ printf " \n", $var->{'MINGID'}->{'value'}; print " $text{'server_slaves'}\n"; -open(SLAVES, "/var/yp/ypservers"); +open(SLAVES, ") { s/\s//g; push(@slaves, $_) if ($_); diff --git a/nis/solaris-lib.pl b/nis/solaris-lib.pl index 368e43710..15788e668 100755 --- a/nis/solaris-lib.pl +++ b/nis/solaris-lib.pl @@ -19,11 +19,11 @@ return $rv; sub get_client_config { local $nis; -open(DOM, "/etc/defaultdomain"); +open(DOM, "{'domain'} = ); close(DOM); if ($nis->{'domain'}) { - if (open(SRV, "$binding_dir/$nis->{'domain'}/ypservers")) { + if (open(SRV, "<$binding_dir/$nis->{'domain'}/ypservers")) { while() { s/\r|\n//g; push(@{$nis->{'servers'}}, $_); @@ -238,7 +238,7 @@ sub parse_yp_makefile # First parse joined lines local $lnum = 0; local (@lines, $llast); -open(MAKE, $yp_makefile); +open(MAKE, "<".$yp_makefile); while() { s/\r|\n//g; local $slash = (s/\\$//); diff --git a/nis/suse-linux-lib.pl b/nis/suse-linux-lib.pl index 43d0b6d85..94dbed093 100755 --- a/nis/suse-linux-lib.pl +++ b/nis/suse-linux-lib.pl @@ -171,7 +171,7 @@ printf " \n", $var->{'MINGID'}->{'value'}; print " $text{'server_slaves'}\n"; -open(SLAVES, "/var/yp/ypservers"); +open(SLAVES, ") { s/\s//g; push(@slaves, $_) if ($_); @@ -363,7 +363,7 @@ sub parse_rc_config local $rc; local $lnum = 0; local $f = $_[0] ? $_[0] : $rc_config; -open(CONF, $f); +open(CONF, "<".$f); while() { s/\r|\n//g; s/#.*$//g; diff --git a/nis/united-linux-lib.pl b/nis/united-linux-lib.pl index 98991ac02..d00308fdc 100755 --- a/nis/united-linux-lib.pl +++ b/nis/united-linux-lib.pl @@ -20,7 +20,7 @@ return $rv; sub get_client_config { local $nis; -open(CONF, $config{'client_conf'}); +open(CONF, "<".$config{'client_conf'}); while() { s/\r|\n//g; s/#.*$//g; @@ -35,7 +35,7 @@ while() { } } close(CONF); -open(DOMAIN, "/etc/defaultdomain"); +open(DOMAIN, "{'domain'} = ); close(DOMAIN); return $nis; @@ -167,7 +167,7 @@ printf " \n", $var->{'MINGID'}->{'value'}; print " $text{'server_slaves'}\n"; -open(SLAVES, "/var/yp/ypservers"); +open(SLAVES, ") { s/\s//g; push(@slaves, $_) if ($_); diff --git a/openslp/slp-lib.pl b/openslp/slp-lib.pl index a4e6f3467..2d6f74fa0 100755 --- a/openslp/slp-lib.pl +++ b/openslp/slp-lib.pl @@ -23,7 +23,7 @@ sub get_snda_config { local $snda; flock SLP, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n"); -open(SLP, $config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n"); +open(SLP, "<".$config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n"); while() { s/\r|\n//g; if (/^(\s|#|;)*net.slp.useScopes\s*=\s*(.*)/) { @@ -45,7 +45,7 @@ sub get_netcfg_config { local $netcfg; flock SLP, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n"); -open(SLP, $config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n"); +open(SLP, "<".$config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n"); while() { s/\r|\n//g; if (/^(\s|#|;)*net.slp.isBroadcastOnly\s*=\s*(\S+)/) { @@ -115,7 +115,7 @@ sub get_dacfg_config { local $dacfg; flock SLP, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n"); -open(SLP, $config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n"); +open(SLP, "<".$config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n"); while() { s/\r|\n//g; if (/^(\s|#|;)*net.slp.isDA\s*=\s*(\S+)/) { @@ -133,7 +133,7 @@ sub get_log_config { local $log; flock SLP, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n"); -open(SLP, $config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n"); +open(SLP, "<".$config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n"); while() { s/\r|\n//g; if (/^(\s|#|;)*net.slp.traceDATraffic\s*=\s*(\S+)/) { @@ -163,7 +163,7 @@ return $dacfg; sub enable_list_line { flock SLP, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n"); -open(SLP, $config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n"); +open(SLP, "<".$config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n"); local @slp = ; close(SLP); flock SLP, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_conf'}: $!\n"); @@ -186,7 +186,7 @@ flock SLP, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_conf'}: $!\n" # enable_single_val_line(&val, &line) sub enable_single_val_line { -open(SLP, $config->{slpd_conf}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n"); +open(SLP, "<".$config->{slpd_conf}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n"); flock SLP, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n"); local @slp = ; close(SLP); @@ -210,7 +210,7 @@ flock SLP, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_conf'}: $!\n" sub disable_line { flock SLP, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_conf'}: $!\n"); -open(SLP, $config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n"); +open(SLP, "<".$config->{'slpd_conf'}) || &error("$text->{'error_open'} $config->{'slpd_conf'}: $!\n"); local @slp = ; close(SLP); flock SLP, 8 || &error("$text->{'error_flock_off'} $config->{'slpd_conf'}: $!\n"); @@ -233,7 +233,7 @@ sub parse_config_file { local %dummy; flock FH, 1 || &error("$text->{'error_flock_on'} $config_file: $!\n"); -open(FH, $config_file) || &error("$text->{'error_open'} $config_file: $!\n"); +open(FH, "<".$config_file) || &error("$text->{'error_open'} $config_file: $!\n"); while () { $dummy{$1} = $2 if (/(\S+)=(.+)/) } @@ -247,7 +247,7 @@ sub restart { local $pid; flock PID, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_pid'}: $!\n"); -open(PID, $config->{'slpd_pid'}) || &start_slpd; +open(PID, "<".$config->{'slpd_pid'}) || &start_slpd; while () { $pid=$1, last if (/(\d+)/) } @@ -265,7 +265,7 @@ sub slpd_is_running { local $pid; flock PID, 1 || &error("$text->{'error_flock_on'} $config->{'slpd_pid'}: $!\n"); -open(PID, $config->{'slpd_pid'}) || return 0; +open(PID, "<".$config->{'slpd_pid'}) || return 0; while () { $pid=$1, last if (/(\d+)/) } diff --git a/oschooser.pl b/oschooser.pl index ed48382c6..d10fb0c7f 100755 --- a/oschooser.pl +++ b/oschooser.pl @@ -10,7 +10,7 @@ $| = 1; ($oslist, $out, $auto) = @ARGV; -open(OS, $oslist) || die "failed to open $oslist : $!"; +open(OS, "<".$oslist) || die "failed to open $oslist : $!"; while() { chop; if (/^([^\t]+)\t+([^\t]+)\t+([^\t]+)\t+([^\t]+)\t*(.*)$/) { diff --git a/pam/pam_env.so.pl b/pam/pam_env.so.pl index 025bbc631..fa8eb44ac 100755 --- a/pam/pam_env.so.pl +++ b/pam/pam_env.so.pl @@ -5,7 +5,7 @@ sub display_module_args { local $file = $_[2]->{'conffile'} ? $_[2]->{'conffile'} : "/etc/security/pam_env.conf"; -open(FILE, $file); +open(FILE, "<".$file); while() { s/#.*$//; s/\r|\n//g; diff --git a/pam/pam_group.so.pl b/pam/pam_group.so.pl index 75e6cec38..8ff4067eb 100755 --- a/pam/pam_group.so.pl +++ b/pam/pam_group.so.pl @@ -5,7 +5,7 @@ sub display_module_args { local $file = "/etc/security/group.conf"; local @group; -open(FILE, $file); +open(FILE, "<".$file); while() { s/#.*$//; s/\r|\n//g; diff --git a/pam/pam_time.so.pl b/pam/pam_time.so.pl index 01602c65c..443054586 100755 --- a/pam/pam_time.so.pl +++ b/pam/pam_time.so.pl @@ -5,7 +5,7 @@ sub display_module_args { local $file = "/etc/security/time.conf"; local @time; -open(FILE, $file); +open(FILE, "<".$file); while() { s/#.*$//; s/\r|\n//g; diff --git a/pap/pap-lib.pl b/pap/pap-lib.pl index f1545bd53..639f2bbd9 100755 --- a/pap/pap-lib.pl +++ b/pap/pap-lib.pl @@ -59,7 +59,7 @@ sub parse_ppp_options { local @rv; local $lnum = 0; -open(OPTS, $_[0]); +open(OPTS, "<".$_[0]); while() { s/\r|\n//g; s/#.*$//g; @@ -127,7 +127,7 @@ sub parse_login_config { local @rv; local $lnum = 0; -open(LOGIN, $config{'login_config'}); +open(LOGIN, "<".$config{'login_config'}); while() { s/\r|\n//g; s/#.*$//g; @@ -172,7 +172,7 @@ sub parse_dialin_config { local @rv; local $lnum = 0; -open(DIALIN, $config{'dialin_config'}); +open(DIALIN, "<".$config{'dialin_config'}); while() { s/\r|\n//g; s/#.*$//g; diff --git a/pap/secrets-lib.pl b/pap/secrets-lib.pl index 409d0cb12..d0f4ab9fb 100755 --- a/pap/secrets-lib.pl +++ b/pap/secrets-lib.pl @@ -5,7 +5,7 @@ sub list_secrets { local(@rv, $line, $_); -open(SEC, $config{'pap_file'}); +open(SEC, "<".$config{'pap_file'}); $line = 0; while() { chop; diff --git a/perlpath.pl b/perlpath.pl index 1cdb58b8b..70ad9668c 100755 --- a/perlpath.pl +++ b/perlpath.pl @@ -14,11 +14,11 @@ else { } foreach $f (@files) { - open(IN, $f); + open(IN, "<".$f); @lines = ; close(IN); if ($lines[0] =~ /^#!\/\S*perl\S*(.*)/) { - open(OUT, "> $f"); + open(OUT, ">".$f); print OUT "#!$ppath$1\n"; for($i=1; $i<@lines; $i++) { print OUT $lines[$i]; diff --git a/phpini/phpini-lib.pl b/phpini/phpini-lib.pl index 93725d0dc..4e4f80110 100755 --- a/phpini/phpini-lib.pl +++ b/phpini/phpini-lib.pl @@ -24,7 +24,7 @@ if (!defined($get_config_cache{$file})) { local @rv = ( ); local $lnum = 0; local $section; - open(CONFIG, $file) || return undef; + open(CONFIG, "<".$file) || return undef; if ($fmt eq "ini") { # Classic php.ini format while() { diff --git a/postfix/postfix-lib.pl b/postfix/postfix-lib.pl index a909a4df0..d60499eac 100755 --- a/postfix/postfix-lib.pl +++ b/postfix/postfix-lib.pl @@ -1612,7 +1612,7 @@ if (!scalar(@master_config_cache)) { @master_config_cache = ( ); local $lnum = 0; local $prog; - open(MASTER, $config{'postfix_master'}); + open(MASTER, "<".$config{'postfix_master'}); while() { s/\r|\n//g; if (/^(#?)\s*(\S+)\s+(inet|unix|fifo)\s+(y|n|\-)\s+(y|n|\-)\s+(y|n|\-)\s+(\S+)\s+(\S+)\s+(.*)$/) { diff --git a/postgresql/exec.cgi b/postgresql/exec.cgi index 60adef9c4..6d2c1574e 100755 --- a/postgresql/exec.cgi +++ b/postgresql/exec.cgi @@ -35,7 +35,7 @@ else { } # Add to the old commands file - open(OLD, "$commands_file.$in{'db'}"); + open(OLD, "<$commands_file.$in{'db'}"); while() { s/\r|\n//g; $already++ if ($_ eq $in{'cmd'}); diff --git a/postgresql/exec_form.cgi b/postgresql/exec_form.cgi index b67f99b05..abff7b3d9 100755 --- a/postgresql/exec_form.cgi +++ b/postgresql/exec_form.cgi @@ -15,7 +15,7 @@ $prog = "exec_form.cgi?db=".&urlize($in{'db'})."&mode="; print &ui_tabs_start(\@tabs, "mode", $in{'mode'} || "exec", 1); # Get recently run commands -open(OLD, "$commands_file.$in{'db'}"); +open(OLD, "<$commands_file.$in{'db'}"); while() { s/\r|\n//g; push(@old, $_); diff --git a/postgresql/import.cgi b/postgresql/import.cgi index 9527c97ca..b51351d08 100755 --- a/postgresql/import.cgi +++ b/postgresql/import.cgi @@ -38,7 +38,7 @@ if (!$in{'delete'}) { # Read the file $skip = 0; -open(FILE, $file); +open(FILE, "<$file"); while() { s/\r|\n//g; next if (!/\S/); diff --git a/postgresql/postgresql-lib.pl b/postgresql/postgresql-lib.pl index e23e0eb38..d2b02a195 100755 --- a/postgresql/postgresql-lib.pl +++ b/postgresql/postgresql-lib.pl @@ -545,7 +545,7 @@ else { sub get_hba_config { local $lnum = 0; -open(HBA, $hba_conf_file); +open(HBA, "<".$hba_conf_file); while() { s/\r|\n//g; s/^\s*#.*$//g; diff --git a/ppp-client/ppp-client-lib.pl b/ppp-client/ppp-client-lib.pl index 6bc8563c0..fb46eef6b 100755 --- a/ppp-client/ppp-client-lib.pl +++ b/ppp-client/ppp-client-lib.pl @@ -17,7 +17,7 @@ sub get_config { local (@rv, $sect); local $lnum = 0; -open(FILE, $config{'file'}); +open(FILE, "<".$config{'file'}); while() { s/^\s*;.*//; s/\r|\n//g; @@ -108,7 +108,7 @@ sub save_connect_details sub get_connect_details { local ($ip, $pid, $sect); -open(DETAILS, $details_file) || return (); +open(DETAILS, "<".$details_file) || return (); chop($ip =
); chop($pid =
); chop($sect =
); @@ -172,7 +172,7 @@ if (!($pid = fork())) { exec($config{'wvdial'}, $sect); exit(1); } -while (!open(TEMP, $temp)) { } +while (!open(TEMP, "<".$temp)) { } &additional_log("exec", undef, "$config{'wvdial'} $sect"); unlink($temp); diff --git a/pptp-client/pptp-client-lib.pl b/pptp-client/pptp-client-lib.pl index eac286971..a15c4db75 100755 --- a/pptp-client/pptp-client-lib.pl +++ b/pptp-client/pptp-client-lib.pl @@ -33,7 +33,7 @@ sub parse_ppp_options { local @rv; local $lnum = 0; -open(OPTS, $_[0]); +open(OPTS, "<".$_[0]); while() { s/\r|\n//g; if (/^#\s*(.*)/) { diff --git a/pptp-server/pptp-server-lib.pl b/pptp-server/pptp-server-lib.pl index 0e8ef2091..cbf9c74fe 100755 --- a/pptp-server/pptp-server-lib.pl +++ b/pptp-server/pptp-server-lib.pl @@ -16,7 +16,7 @@ sub get_config { local @rv; local $lnum = 0; -open(FILE, $config{'file'}); +open(FILE, "<".$config{'file'}); while() { s/\r|\n//g; if (/^\s*(#?)\s*(\S+)\s*(\S*)\s*$/) { @@ -69,7 +69,7 @@ elsif (defined($_[2])) { # Returns the PID of the running PPTP server process sub get_pptpd_pid { -open(PID, $config{'pid_file'}) || return undef; +open(PID, "<".$config{'pid_file'}) || return undef; local $pid = ; $pid = int($pid); close(PID); @@ -93,7 +93,7 @@ sub parse_ppp_options { local @rv; local $lnum = 0; -open(OPTS, $_[0]); +open(OPTS, "<".$_[0]); while() { s/\r|\n//g; s/#.*$//g; diff --git a/proc/freebsd-lib.pl b/proc/freebsd-lib.pl index dd85c7b95..1e3e9e0a8 100755 --- a/proc/freebsd-lib.pl +++ b/proc/freebsd-lib.pl @@ -77,7 +77,7 @@ return (); # Disconnects this process from it's controlling PTY, if connected sub close_controlling_pty { -if (open(DEVTTY, "/dev/tty")) { +if (open(DEVTTY, "); close(INDEX); if (!$idx) { diff --git a/proc/killtail.cgi b/proc/killtail.cgi index 640d9b95e..4c903e236 100755 --- a/proc/killtail.cgi +++ b/proc/killtail.cgi @@ -3,7 +3,7 @@ require './proc-lib.pl'; &ReadParse(); $idfile = "$module_config_directory/$in{'id'}.tail"; -open(IDFILE, $idfile) || exit; +open(IDFILE, "<$idfile") || exit; chop($pid = ); close(IDFILE); $pid || exit; diff --git a/proc/linux-lib.pl b/proc/linux-lib.pl index 72dc50c06..f52337401 100755 --- a/proc/linux-lib.pl +++ b/proc/linux-lib.pl @@ -224,7 +224,7 @@ else { # Disconnects this process from it's controlling PTY, if connected sub close_controlling_pty { -if (open(DEVTTY, "/dev/tty")) { +if (open(DEVTTY, ") { if (/^(\S+):\s+(\d+)/) { $m{lc($1)} = $2; @@ -307,11 +307,11 @@ return ( $memtotal, # CPU mhz, model, vendor, cache and count sub os_get_cpu_info { -open(LOAD, "/proc/loadavg") || return (); +open(LOAD, "); close(LOAD); local %c; -open(CPUINFO, "/proc/cpuinfo"); +open(CPUINFO, ") { if (/^(\S[^:]*\S)\s*:\s*(.*)/) { $c{lc($1)} = $2; diff --git a/procmail/procmail-lib.pl b/procmail/procmail-lib.pl index af5288488..ee300d357 100755 --- a/procmail/procmail-lib.pl +++ b/procmail/procmail-lib.pl @@ -29,7 +29,7 @@ sub parse_procmail_file local (@rv, $rec, $_); local $lnum = 0; local $fh = $_[0]; -open($fh, $_[0]); +open($fh, "<".$_[0]); while(<$fh>) { local $slnum = $lnum; s/\s+$//; diff --git a/proftpd/allmanual_form.cgi b/proftpd/allmanual_form.cgi index 06a3fbdf9..c87c8d16a 100755 --- a/proftpd/allmanual_form.cgi +++ b/proftpd/allmanual_form.cgi @@ -25,9 +25,7 @@ print "\n"; print "\n"; print "
\n"; print "\n"; diff --git a/proftpd/find_ftpaccess.cgi b/proftpd/find_ftpaccess.cgi index 0e0821a4e..06e949d5b 100755 --- a/proftpd/find_ftpaccess.cgi +++ b/proftpd/find_ftpaccess.cgi @@ -29,7 +29,7 @@ foreach $d (@dirs) { $d = $u[7]; next if (!$u[7]); } - open(FIND, "find '$d' -name .ftpaccess -print |"); + open(FIND, "find ".quotemeta($d)." -name .ftpaccess -print |"); while() { s/\r|\n//g; push(@rv, $_); diff --git a/proftpd/proftpd-lib.pl b/proftpd/proftpd-lib.pl index 89fd84d0c..c28686f29 100755 --- a/proftpd/proftpd-lib.pl +++ b/proftpd/proftpd-lib.pl @@ -49,7 +49,7 @@ if (opendir(DIR, $fn)) { else { # Just a normal config file local $lnum = 0; - if (open(CONF, $fn)) { + if (open(CONF, "<".$fn)) { @rv = &parse_config_file(CONF, $lnum, $fn); close(CONF); foreach $inc (&find_directive("Include", \@rv)) { @@ -616,7 +616,7 @@ return wantarray ? ($c, $v) : $c; sub get_ftpaccess_config { local($lnum, @conf); -open(FTPACCESS, $_[0]); +open(FTPACCESS, "<".$_[0]); @conf = &parse_config_file(FTPACCESS, $lnum, $_[0]); close(FTPACCESS); return \@conf; @@ -679,7 +679,7 @@ if ($config{'test_always'}) { local @files = &unique(map { $_->{'file'} } @$conf); local $/ = undef; foreach $f (@files) { - if (open(BEFORE, $f)) { + if (open(BEFORE, "<".$f)) { $before_changing{$f} = ; close(BEFORE); } diff --git a/qmailadmin/filter.pl b/qmailadmin/filter.pl index 5f4c78d64..b23b66a50 100755 --- a/qmailadmin/filter.pl +++ b/qmailadmin/filter.pl @@ -4,7 +4,7 @@ # read qmail module config $p = -l $0 ? readlink($0) : $0; $p =~ /^(.*)\/[^\/]+$/; -open(CONF, "$1/config"); +open(CONF, "<$1/config"); while() { if (/^(\S+)=(.*)/) { $config{$1} = $2; @@ -27,7 +27,7 @@ while() { } # read the filter file -if (open(FILTER, $ARGV[0])) { +if (open(FILTER, "<".$ARGV[0])) { while() { s/\r|\n//g; if (/^(\S+)\s+(\S+)\s+(\S+)\s+(.*)$/) { diff --git a/qmailadmin/old_edit_ffile.cgi b/qmailadmin/old_edit_ffile.cgi index f90eaa498..1335a9875 100755 --- a/qmailadmin/old_edit_ffile.cgi +++ b/qmailadmin/old_edit_ffile.cgi @@ -6,7 +6,7 @@ require './qmail-lib.pl'; &ReadParse(); &ui_print_header(undef, $text{'ffile_title'}, ""); -open(FILE, $in{'file'}); +open(FILE, "<$in{'file'}"); while() { s/\r|\n//g; if (/^(\S+)\s+(\S+)\s+(\S+)\s+(.*)$/) { diff --git a/qmailadmin/old_edit_rfile.cgi b/qmailadmin/old_edit_rfile.cgi index 90e37afbc..5469ef88e 100755 --- a/qmailadmin/old_edit_rfile.cgi +++ b/qmailadmin/old_edit_rfile.cgi @@ -6,7 +6,7 @@ require './qmail-lib.pl'; &ReadParse(); &ui_print_header(undef, $text{'rfile_title'}, ""); -open(FILE, $in{'file'}); +open(FILE, "<$in{'file'}"); while() { if (/^Reply-Tracking:\s*(.*)/) { $replies = $1; diff --git a/qmailadmin/qmail-lib.pl b/qmailadmin/qmail-lib.pl index c4c42ced7..99253ead5 100755 --- a/qmailadmin/qmail-lib.pl +++ b/qmailadmin/qmail-lib.pl @@ -41,7 +41,7 @@ sub get_alias local $alias = { 'name' => $_[0], 'file' => "$qmail_alias_dir/.qmail-$_[0]", 'values' => [ ] }; -open(ALIAS, $alias->{'file'}); +open(ALIAS, "<".$alias->{'file'}); while() { s/\r|\n//g; s/#.*$//g; @@ -200,7 +200,7 @@ unlink("$_[0]->{'file'}"); # Returns the value from a qmail single-line control file sub get_control_file { -open(FILE, "$qmail_control_dir/$_[0]") || return undef; +open(FILE, "<$qmail_control_dir/$_[0]") || return undef; local $line = ; close(FILE); $line =~ s/\r|\n//g; @@ -228,7 +228,7 @@ else { sub list_control_file { local @lines; -open(FILE, "$qmail_control_dir/$_[0]") || return undef; +open(FILE, "<$qmail_control_dir/$_[0]") || return undef; while() { s/\r|\n//g; s/#.*$//g; @@ -264,7 +264,7 @@ sub list_routes if (!scalar(@list_routes_cache)) { local $lnum = 0; local @rv; - open(ROUTES, $qmail_routes_file); + open(ROUTES, "<".$qmail_routes_file); while() { s/\r|\n//g; s/#.*$//; @@ -390,7 +390,7 @@ sub list_virts if (!scalar(@list_virts_cache)) { local $lnum = 0; local @rv; - open(VIRTS, $qmail_virts_file); + open(VIRTS, "<".$qmail_virts_file); while() { s/\r|\n//g; s/#.*$//; @@ -595,7 +595,7 @@ sub list_assigns if (!scalar(@list_assigns_cache)) { local @rv; local $lnum = 0; - open(ASSIGNS, $qmail_assigns_file); + open(ASSIGNS, "<".$qmail_assigns_file); while() { s/\r|\n//g; last if ($_ eq '.'); diff --git a/quota/edgrace.pl b/quota/edgrace.pl index 0cc943e1e..0b9bf9de8 100755 --- a/quota/edgrace.pl +++ b/quota/edgrace.pl @@ -13,10 +13,10 @@ $ft = $ENV{'QUOTA_FTIME'}; $fu = $ENV{'QUOTA_FUNITS'}; $f = $ARGV[0]; -open(FILE, $f); +open(FILE, "<".$f); while() { $qdata .= $_; } close(FILE); $nqdata = &edit_grace_file($qdata, $fs, $bt, $bu, $ft, $fu); -open(FILE, "> $f"); +open(FILE, ">$f"); print FILE $nqdata; close(FILE); diff --git a/quota/edquota.pl b/quota/edquota.pl index d3b8c8396..c816ac496 100755 --- a/quota/edquota.pl +++ b/quota/edquota.pl @@ -14,10 +14,10 @@ $sf = $ENV{'QUOTA_SFILES'}; $hf = $ENV{'QUOTA_HFILES'}; $f = $ARGV[0]; -open(FILE, $f); +open(FILE, "<".$f); while() { $qdata .= $_; } close(FILE); $nqdata = &edit_quota_file($qdata, $fs, $sb, $hb, $sf, $hf); -open(FILE, "> $f"); +open(FILE, ">".$f); print FILE $nqdata; close(FILE); diff --git a/raid/raid-lib.pl b/raid/raid-lib.pl index 51926ec33..230eb76c8 100755 --- a/raid/raid-lib.pl +++ b/raid/raid-lib.pl @@ -6,7 +6,7 @@ use WebminCore; &init_config(); &foreign_require("fdisk"); -open(MODE, "$module_config_directory/mode"); +open(MODE, "<$module_config_directory/mode"); chop($raid_mode = ); close(MODE); $raid_mode ||= "mdadm"; @@ -35,7 +35,7 @@ sub get_mdstat # Read the mdstat file local %mdstat; local $lastdev; -open(MDSTAT, $config{'mdstat'}); +open(MDSTAT, "<".$config{'mdstat'}); while() { if (/^(md\d+)\s*:\s+(\S+)\s+(\S+)\s+(.*)\s+(\d+)\s+blocks\s*(.*)resync=([0-9\.]+|delayed)/) { $mdstat{$lastdev = "/dev/$1"} = [ $2, $3, $4, $5, $7, $6 ]; @@ -78,7 +78,7 @@ return \@get_raidtab_cache if (scalar(@get_raidtab_cache)); if ($raid_mode eq "raidtools") { # Read the raidtab file local $lnum = 0; - open(RAID, $config{'raidtab'}); + open(RAID, "<".$config{'raidtab'}); while() { s/\r|\n//g; s/#.*$//; @@ -186,7 +186,7 @@ else { } close(MDSTAT); local $lastdev; - open(MDSTAT, $config{'mdstat'}); + open(MDSTAT, "<".$config{'mdstat'}); while(){ if (/^(md\d+)/) { $lastdev = "/dev/$1"; @@ -227,12 +227,12 @@ return \@get_raidtab_cache; sub get_uuid { open(MDSTAT, "mdadm --detail $_[0]->{'value'} |"); - while() { - if (/^\s+UUID\s+:\s*(.*)/) { - return $1; - } - } - close(MDSTAT); + while() { + if (/^\s+UUID\s+:\s*(.*)/) { + return $1; + } + } + close(MDSTAT); } # disk_errors(string) diff --git a/rbac/rbac-lib.pl b/rbac/rbac-lib.pl index 96edb218d..1fd069daf 100755 --- a/rbac/rbac-lib.pl +++ b/rbac/rbac-lib.pl @@ -14,7 +14,7 @@ sub list_user_attrs if (!scalar(@list_user_attrs_cache)) { @list_user_attrs_cache = ( ); local $lnum = 0; - open(ATTR, $config{'user_attr'}); + open(ATTR, "<".$config{'user_attr'}); while() { s/\r|\n//g; s/#.*$//; @@ -145,7 +145,7 @@ sub list_prof_attrs if (!scalar(@list_prof_attrs_cache)) { @list_prof_attrs_cache = ( ); local $lnum = 0; - open(ATTR, $config{'prof_attr'}); + open(ATTR, "<".$config{'prof_attr'}); while() { s/\r|\n//g; s/#.*$//; @@ -288,7 +288,7 @@ sub list_auth_attrs if (!scalar(@list_auth_attrs_cache)) { @list_auth_attrs_cache = ( ); local $lnum = 0; - open(ATTR, $config{'auth_attr'}); + open(ATTR, "<".$config{'auth_attr'}); while() { s/\r|\n//g; s/#.*$//; @@ -409,7 +409,7 @@ sub list_exec_attrs if (!scalar(@list_exec_attrs_cache)) { @list_exec_attrs_cache = ( ); local $lnum = 0; - open(ATTR, $config{'exec_attr'}); + open(ATTR, "<".$config{'exec_attr'}); while() { s/\r|\n//g; s/#.*$//; @@ -499,7 +499,7 @@ sub get_policy_config if (!scalar(@policy_conf_cache)) { @policy_conf_cache = ( ); local $lnum = 0; - open(ATTR, $config{'policy_conf'}); + open(ATTR, "<".$config{'policy_conf'}); while() { s/\r|\n//g; s/\s+$//; @@ -574,7 +574,7 @@ sub list_projects if (!scalar(@list_projects_cache)) { @list_projects_cache = ( ); local $lnum = 0; - open(ATTR, $config{'project'}); + open(ATTR, "<".$config{'project'}); while() { s/\r|\n//g; s/#.*$//; @@ -811,7 +811,7 @@ sub list_crypt_algorithms if (!scalar(@list_crypt_algorithms_cache)) { push(@list_crypt_algorithms_cache, { 'name' => '__unix__' } ); local $lnum = 0; - open(CRYPT, $config{'crypt_conf'}); + open(CRYPT, "<".$config{'crypt_conf'}); while() { s/\r|\n//g; s/#.*$//; diff --git a/rbac/rbac_help.cgi b/rbac/rbac_help.cgi index db787c9d8..c9b5ff428 100755 --- a/rbac/rbac_help.cgi +++ b/rbac/rbac_help.cgi @@ -10,7 +10,7 @@ $hf = $in{'help'}; &error($text{'help_epath'}); &PrintHeader(); -open(HELP, $hf); +open(HELP, "<$hf"); while() { print $_; } diff --git a/samba/conf_pass.cgi b/samba/conf_pass.cgi index a155bb5d9..c9d920cb1 100755 --- a/samba/conf_pass.cgi +++ b/samba/conf_pass.cgi @@ -55,7 +55,7 @@ $map = &ui_radio("username_map_def", &getval("username map") eq "" ? 1 : 0, [ 0, $text{'passwd_below'} ] ])."
\n"; $map .= &ui_columns_start([ $text{'passwd_unixuser'}, $text{'passwd_winuser'} ]); -open(UMAP, &getval("username map")); +open(UMAP, "<".&getval("username map")); while() { s/\r|\n//g; s/[#;].*$//g; diff --git a/samba/samba-lib.pl b/samba/samba-lib.pl index 4f713bc7b..466ff5e36 100755 --- a/samba/samba-lib.pl +++ b/samba/samba-lib.pl @@ -9,7 +9,7 @@ use WebminCore; $has_iconv = &has_command("iconv"); # Get the samba version -if (open(VERSION, "$module_config_directory/version")) { +if (open(VERSION, "<$module_config_directory/version")) { chop($samba_version = ); close(VERSION); } diff --git a/sarg/sarg-lib.pl b/sarg/sarg-lib.pl index a7ea3950d..e05d55aa9 100755 --- a/sarg/sarg-lib.pl +++ b/sarg/sarg-lib.pl @@ -15,7 +15,7 @@ sub get_config { if (!scalar(@get_config_cache)) { local $lnum = 0; - open(CONF, $config{'sarg_conf'}); + open(CONF, "<".$config{'sarg_conf'}); while() { s/\r|\n//g; if (/^\s*(#*)\s*(\S+)\s+"([^"]*)"/ || @@ -281,7 +281,7 @@ local $default = &find($name, $conf, 2); local $defstr = $default ? " ($default->{'value'})" : ""; local $found; local @langs = ( [ "", $text{'default'}.$defstr ] ); -open(LANGS, $file); +open(LANGS, "<".$file); while() { chop; if (/^(\S+)\t+(\S.*)/) { diff --git a/sarg/view.cgi b/sarg/view.cgi index 06c26ccf2..7cfd64844 100755 --- a/sarg/view.cgi +++ b/sarg/view.cgi @@ -22,7 +22,7 @@ if (-d $full && -r "$full/index.html") { # Display file contents if ($full =~ /\.(html|htm)$/i && !$config{'naked'}) { - open(FILE, $full) || &error($text{'view_eopen'}." : $full"); + open(FILE, "<$full") || &error($text{'view_eopen'}." : $full"); while(read(FILE, $buf, 1024)) { $data .= $buf; } @@ -54,7 +54,7 @@ elsif (-d $full) { } else { # Show RAW file contents - open(FILE, $full) || &error($text{'view_eopen'}." : $full"); + open(FILE, "<$full") || &error($text{'view_eopen'}." : $full"); print "Content-type: ",&guess_mime_type($full, "text/plain"),"\n"; print "\n"; while(read(FILE, $buf, 1024)) { diff --git a/sendmail/access-lib.pl b/sendmail/access-lib.pl index 648fca07f..31104d200 100755 --- a/sendmail/access-lib.pl +++ b/sendmail/access-lib.pl @@ -26,7 +26,7 @@ sub list_access if (!scalar(@list_access_cache)) { @list_access_cache = ( ); local $lnum = 0; - open(ACC, $_[0]); + open(ACC, "<".$_[0]); while() { s/\r|\n//g; # remove newlines if (/^\s*#+\s*(.*)/) { diff --git a/sendmail/autoreply.pl b/sendmail/autoreply.pl index 6ca279591..5c7cec3cf 100755 --- a/sendmail/autoreply.pl +++ b/sendmail/autoreply.pl @@ -106,8 +106,8 @@ chop($host = `hostname`); $rheader{'Message-Id'} = "<".time().".".$$."\@".$host.">"; # read the autoreply file (or alternate) -if (open(AUTO, $ARGV[0]) || - $ARGV[2] && open(AUTO, $ARGV[2])) { +if (open(AUTO, "<".$ARGV[0]) || + $ARGV[2] && open(AUTO, "<".$ARGV[2])) { while() { s/\$SUBJECT/$header{'subject'}/g; s/\$FROM/$header{'from'}/g; @@ -244,7 +244,7 @@ if ($spam) { print SPAM $body; close(SPAM); $isspam = undef; - open(SPAMOUT, $temp); + open(SPAMOUT, "<".$temp); while() { if (/^X-Spam-Status:\s+Yes/i) { $isspam = 1; @@ -263,7 +263,7 @@ if ($spam) { # Read attached files foreach $f (@files) { local $/ = undef; - if (!open(FILE, $f)) { + if (!open(FILE, "<".$f)) { print STDERR "Failed to open $f : $!\n"; exit(1); } @@ -441,7 +441,7 @@ return $file =~ /\.gif/i ? "image/gif" : sub read_config_file { local %config; -if (open(CONF, $_[0])) { +if (open(CONF, "<".$_[0])) { while() { if (/^(\S+)=(.*)/) { $config{$1} = $2; diff --git a/sendmail/domain-lib.pl b/sendmail/domain-lib.pl index 54c133152..cd46f11f5 100755 --- a/sendmail/domain-lib.pl +++ b/sendmail/domain-lib.pl @@ -27,7 +27,7 @@ if (!scalar(@list_domains_cache)) { @list_domains_cache = ( ); local $lnum = 0; local $cmt; - open(DOM, $_[0]); + open(DOM, "<".$_[0]); while() { s/\r|\n//g; # remove newlines if (/^\s*#+\s*(.*)/) { diff --git a/sendmail/edit_file.cgi b/sendmail/edit_file.cgi index 260b918c5..de0745424 100755 --- a/sendmail/edit_file.cgi +++ b/sendmail/edit_file.cgi @@ -57,7 +57,7 @@ elsif ($in{'mode'} eq 'access') { else { &error($text{'file_emode'}); } &ui_print_header(undef, $text{'file_title'}, ""); -open(FILE, $file); +open(FILE, "<$file"); @lines = ; close(FILE); diff --git a/sendmail/features-lib.pl b/sendmail/features-lib.pl index e164b4ebc..68ee30586 100755 --- a/sendmail/features-lib.pl +++ b/sendmail/features-lib.pl @@ -6,7 +6,7 @@ sub list_features { local (@rv, $lnum = 0); -open(MC, $config{'sendmail_mc'}); +open(MC, "<".$config{'sendmail_mc'}); while() { s/\r|\n//g; local $f; @@ -84,7 +84,7 @@ return @rv; sub list_define_types { local (@rv, $d); -open(DEFINES, "$module_root_directory/defines"); +open(DEFINES, "<$module_root_directory/defines"); while($d = ) { $d =~ s/\r|\n//g; local $t = $text{'def_'.lc($d)}; diff --git a/sendmail/filter.pl b/sendmail/filter.pl index 6b6296862..7dfcf0318 100755 --- a/sendmail/filter.pl +++ b/sendmail/filter.pl @@ -4,7 +4,7 @@ # read sendmail module config $p = -l $0 ? readlink($0) : $0; $p =~ /^(.*)\/[^\/]+$/; -if (open(CONF, "$1/config")) { +if (open(CONF, "<$1/config")) { while() { if (/^(\S+)=(.*)/) { $config{$1} = $2; @@ -48,7 +48,7 @@ while() { } # read the filter file -if (open(FILTER, $ARGV[0])) { +if (open(FILTER, "<".$ARGV[0])) { while() { s/\r|\n//g; if (/^(\S+)\s+(\S+)\s+(\S+)\s+(.*)$/) { diff --git a/sendmail/generics-lib.pl b/sendmail/generics-lib.pl index 7fcbfcc2e..1358a1a31 100755 --- a/sendmail/generics-lib.pl +++ b/sendmail/generics-lib.pl @@ -27,7 +27,7 @@ if (!scalar(@list_generics_cache)) { @list_generics_cache = ( ); local $lnum = 0; local $cmt; - open(GEN, $_[0]); + open(GEN, "<".$_[0]); while() { s/\r|\n//g; # remove newlines if (/^\s*#+\s*(.*)/) { diff --git a/sendmail/mailers-lib.pl b/sendmail/mailers-lib.pl index 794851a67..3aae8860e 100755 --- a/sendmail/mailers-lib.pl +++ b/sendmail/mailers-lib.pl @@ -27,7 +27,7 @@ if (!scalar(@list_mailers_cache)) { local $lnum = 0; @list_mailers_cache = ( ); local $cmt; - open(MAILER, $_[0]); + open(MAILER, "<".$_[0]); while() { s/\r|\n//g; # remove newlines if (/^\s*#+\s*(.*)/) { diff --git a/sendmail/sendmail-lib.pl b/sendmail/sendmail-lib.pl index 2f25bf936..1fda3a952 100755 --- a/sendmail/sendmail-lib.pl +++ b/sendmail/sendmail-lib.pl @@ -18,7 +18,7 @@ sub get_sendmailcf if (!@sendmailcf_cache) { local($lnum, $i); $lnum = 0; $i = 0; - open(CF, $config{'sendmail_cf'}); + open(CF, "<".$config{'sendmail_cf'}); while() { s/^#.*$//g; # remove comments s/\r|\n//g; # remove newlines @@ -174,7 +174,7 @@ else { # Just HUP the process local ($pid, $any); foreach my $pidfile (split(/\t+/, $config{'sendmail_pid'})) { - if (open(PID, $pidfile)) { + if (open(PID, "<".$pidfile)) { chop($pid = ); close(PID); if ($pid) { &kill_logged('HUP', $pid); } @@ -326,7 +326,7 @@ local @rv; if ($cwfile) { # get entries listed in a separate file $$cwref = $cwfile if ($cwref); - open(CW, $cwfile); + open(CW, "<".$cwfile); while() { s/\r|\n//g; s/#.*$//g; @@ -462,7 +462,7 @@ return @qfiles; sub list_dontblames { local @rv; -open(BLAME, "$module_root_directory/dontblames"); +open(BLAME, "<$module_root_directory/dontblames"); while() { s/\r|\n//g; s/^\s*#.*$//; diff --git a/sendmail/virtusers-lib.pl b/sendmail/virtusers-lib.pl index b59fdb1f3..e56cbc9d0 100755 --- a/sendmail/virtusers-lib.pl +++ b/sendmail/virtusers-lib.pl @@ -27,7 +27,7 @@ if (!scalar(@list_virtusers_cache)) { @list_virtusers_cache = ( ); local $lnum = 0; local $cmt; - open(VIRT, $_[0]); + open(VIRT, "<".$_[0]); while() { s/\r|\n//g; # remove newlines if (/^\s*#+\s*(.*)/) { diff --git a/servers/servers-lib.pl b/servers/servers-lib.pl index bf0d6e771..ef521283b 100755 --- a/servers/servers-lib.pl +++ b/servers/servers-lib.pl @@ -230,7 +230,7 @@ if ($config{'groups_dir'} && opendir(DIR, $config{'groups_dir'})) { $gmap{$f} = $grp = { 'name' => $f, 'type' => 1 }; push(@rv, $grp); } - open(GROUP, "$config{'groups_dir'}/$f"); + open(GROUP, "<$config{'groups_dir'}/$f"); while() { s/\r|\n//g; s/#.*$//; diff --git a/sgiexports/sgiexports-lib.pl b/sgiexports/sgiexports-lib.pl index 72cdf913a..50f0a2d46 100755 --- a/sgiexports/sgiexports-lib.pl +++ b/sgiexports/sgiexports-lib.pl @@ -11,7 +11,7 @@ sub get_exports { local $lnum = 0; local @rv; -open(EXPORTS, $config{'exports_file'}); +open(EXPORTS, "<".$config{'exports_file'}); while() { s/\r|\n//g; s/#.*$//g; diff --git a/shell/index.cgi b/shell/index.cgi index 7c19600ac..6111243a6 100755 --- a/shell/index.cgi +++ b/shell/index.cgi @@ -20,7 +20,7 @@ if ($in{'clearcmds'}) { &webmin_log("clear"); } else { - open(PREVFILE, $prevfile); + open(PREVFILE, "<$prevfile"); chop(@allprevious = ); close(PREVFILE); @previous = &unique(@allprevious); diff --git a/shorewall/shorewall-lib.pl b/shorewall/shorewall-lib.pl index 85ada5296..20d49df92 100755 --- a/shorewall/shorewall-lib.pl +++ b/shorewall/shorewall-lib.pl @@ -46,7 +46,7 @@ return 1; # same! sub read_shorewall_config { local @ret; - open(SHOREWALL_CONF, "$config{'config_dir'}/shorewall.conf"); + open(SHOREWALL_CONF, "<$config{'config_dir'}/shorewall.conf"); while () { chomp; s/\r//; @@ -96,7 +96,7 @@ sub read_table_file { local @rv; local $func = $_[1]; -open(FILE, "$config{'config_dir'}/$_[0]"); +open(FILE, "<$config{'config_dir'}/$_[0]"); while() { s/\r|\n//g; local $l = &$func($_); @@ -112,7 +112,7 @@ sub read_table_struct if (!defined($read_table_cache{$_[0]})) { local @rv; local $func = $_[1]; - open(FILE, "$config{'config_dir'}/$_[0]"); + open(FILE, "<$config{'config_dir'}/$_[0]"); local $lnum = 0; while() { s/\r|\n//g; @@ -640,7 +640,7 @@ else { sub new_interfaces_format { if (&version_atleast(4, 5, 3)) { - open(FILE, "$config{'config_dir'}/interfaces"); + open(FILE, "<$config{'config_dir'}/interfaces"); while() { s/\r|\n//g; if ($_ =~ /\??FORMAT\s+2/) { @@ -1928,7 +1928,7 @@ sub list_standard_actions { local @rv; foreach my $a (split(/\t+/, $config{'actions'})) { - open(ACTIONS, $a); + open(ACTIONS, "<".$a); while() { s/\r|\n//g; s/#.*$//; @@ -1971,7 +1971,7 @@ sub get_shorewall_version { local ($nocache) = @_; local $version; -if (!$nocache && open(VERSION, "$module_config_directory/version")) { +if (!$nocache && open(VERSION, "<$module_config_directory/version")) { chop($version = ); close(VERSION); } @@ -1997,7 +1997,7 @@ sub list_protocols { local @stdprotos = ( 'tcp', 'udp', 'icmp' ); local @otherprotos; -open(PROTOS, "/etc/protocols"); +open(PROTOS, ") { s/\r|\n//g; s/#.*$//; diff --git a/shorewall6/shorewall6-lib.pl b/shorewall6/shorewall6-lib.pl index 5a2c27615..7ee11fa49 100755 --- a/shorewall6/shorewall6-lib.pl +++ b/shorewall6/shorewall6-lib.pl @@ -43,7 +43,7 @@ return 1; # same! sub read_shorewall6_config { local @ret; - open(SHOREWALL_CONF, "$config{'config_dir'}/shorewall6.conf"); + open(SHOREWALL_CONF, "<$config{'config_dir'}/shorewall6.conf"); while () { chomp; s/\r//; @@ -85,7 +85,7 @@ sub read_table_file { local @rv; local $func = $_[1]; -open(FILE, "$config{'config_dir'}/$_[0]"); +open(FILE, "<$config{'config_dir'}/$_[0]"); while() { s/\r|\n//g; local $l = &$func($_); @@ -101,7 +101,7 @@ sub read_table_struct if (!defined($read_table_cache{$_[0]})) { local @rv; local $func = $_[1]; - open(FILE, "$config{'config_dir'}/$_[0]"); + open(FILE, "<$config{'config_dir'}/$_[0]"); local $lnum = 0; while() { s/\r|\n//g; @@ -1557,7 +1557,7 @@ sub list_standard_actions { local @rv; foreach my $a (split(/\t+/, $config{'actions'})) { - open(ACTIONS, $a); + open(ACTIONS, "<".$a); while() { s/\r|\n//g; s/#.*$//; @@ -1600,7 +1600,7 @@ sub get_shorewall6_version { local ($nocache) = @_; local $version; -if (!$nocache && open(VERSION, "$module_config_directory/version")) { +if (!$nocache && open(VERSION, "<$module_config_directory/version")) { chop($version = ); close(VERSION); } @@ -1626,7 +1626,7 @@ sub list_protocols { local @stdprotos = ( 'tcp', 'udp', 'ipv6-icmp' ); local @otherprotos; -open(PROTOS, "/etc/protocols"); +open(PROTOS, ") { s/\r|\n//g; s/#.*$//; diff --git a/smf/smf-lib.pl b/smf/smf-lib.pl index 97d31e972..20486d720 100755 --- a/smf/smf-lib.pl +++ b/smf/smf-lib.pl @@ -700,7 +700,7 @@ local ($template, $target, $find_replace_arrayref, @template_data, $find_replace_expr, @tdata, $find, $replace, $linenum, $line, @replace_data, $i); ($template, $target, $find_replace_arrayref) = @_; -open(TEMPLATE, "$module_root_directory/$template"); +open(TEMPLATE, "<$module_root_directory/$template"); @template_data =