Skip to content

Commit f40f031

Browse files
committed
Use my instead of local
1 parent ea5341b commit f40f031

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

feature-web.pl

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ sub require_apache
1515
# Setup a virtual website for some domain
1616
sub setup_web
1717
{
18-
local ($d) = @_;
19-
local $tmpl = &get_template($d->{'template'});
20-
local $web_port = $d->{'web_port'} || $tmpl->{'web_port'} || 80;
21-
local ($alias, $lockdom);
18+
my ($d) = @_;
19+
my $tmpl = &get_template($d->{'template'});
20+
my $web_port = $d->{'web_port'} || $tmpl->{'web_port'} || 80;
21+
my ($alias, $lockdom);
2222
if ($d->{'alias'} && $tmpl->{'web_alias'} == 1) {
2323
&$first_print($text{'setup_webalias'});
2424
$lockdom = $alias = &get_domain($d->{'alias'});
@@ -29,19 +29,19 @@ sub setup_web
2929
}
3030
&require_apache();
3131
&obtain_lock_web($lockdom);
32-
local $conf = &apache::get_config();
33-
local ($f, $newfile) = &get_website_file($d);
32+
my $conf = &apache::get_config();
33+
my ($f, $newfile) = &get_website_file($d);
3434

3535
# Add NameVirtualHost if needed
36-
local $nvstar = &add_name_virtual($d, $conf, $web_port, 1, $d->{'ip'});
37-
local $nvstar6;
36+
my $nvstar = &add_name_virtual($d, $conf, $web_port, 1, $d->{'ip'});
37+
my $nvstar6;
3838
if ($d->{'ip6'}) {
3939
$nvstar6 = &add_name_virtual($d, $conf, $web_port, 1, $d->{'ip6'});
4040
}
4141

4242
# We use a * for the address for name-based servers under Apache 2,
4343
# if NameVirtualHost * exists.
44-
local $vips = &get_apache_vhost_ips($d, $nvstar, $nvstar6, $web_port);
44+
my $vips = &get_apache_vhost_ips($d, $nvstar, $nvstar6, $web_port);
4545

4646
# Add Listen if needed
4747
&add_listen($d, $conf, $web_port);
@@ -51,22 +51,22 @@ sub setup_web
5151
delete($d->{'php_fpm_port'});
5252
}
5353

54-
local @dirs = &apache_template($tmpl->{'web'}, $d);
54+
my @dirs = &apache_template($tmpl->{'web'}, $d);
5555
if ($apache::httpd_modules{'mod_proxy'}) {
5656
push(@dirs, "ProxyPass /.well-known !");
5757
}
5858
if ($d->{'alias'} && $tmpl->{'web_alias'} == 1) {
5959
# Update the parent virtual host (and the SSL virtual host, if any)
60-
local @ports = ( $alias->{'web_port'} );
60+
my @ports = ( $alias->{'web_port'} );
6161
push(@ports, $alias->{'web_sslport'}) if ($alias->{'ssl'});
6262
foreach my $p (@ports) {
63-
local ($pvirt, $pconf) = &get_apache_virtual(
63+
my ($pvirt, $pconf) = &get_apache_virtual(
6464
$alias->{'dom'}, $p);
6565
if (!$pvirt) {
6666
&$second_print($text{'setup_ewebalias'});
6767
return 0;
6868
}
69-
local @sa = &apache::find_directive("ServerAlias", $pconf);
69+
my @sa = &apache::find_directive("ServerAlias", $pconf);
7070
foreach my $dir (@dirs) {
7171
if ($dir =~ /^\s*Server(Name|Alias)\s+(.*)/) {
7272
push(@sa, $2);
@@ -99,19 +99,19 @@ sub setup_web
9999
# Add the actual <VirtualHost>
100100

101101
# First build up the directives in the <VirtualHost>
102-
local $proxying;
102+
my $proxying;
103103
if ($d->{'alias'}) {
104104
# Because this is just an alias to an existing virtual server,
105105
# create a ProxyPass or Redirect
106106
@dirs = grep { /^\s*Server(Name|Alias)\s/i } @dirs;
107-
local $aliasdom = &get_domain($d->{'alias'});
108-
local $port = $aliasdom->{'web_port'} == 80 ? "" :
107+
my $aliasdom = &get_domain($d->{'alias'});
108+
my $port = $aliasdom->{'web_port'} == 80 ? "" :
109109
":$aliasdom->{'web_port'}";
110-
local $urlhost = "www.".$aliasdom->{'dom'};
110+
my $urlhost = "www.".$aliasdom->{'dom'};
111111
if (!&to_ipaddress($urlhost)) {
112112
$urlhost = $aliasdom->{'dom'};
113113
}
114-
local $url = "http://$urlhost$port/";
114+
my $url = "http://$urlhost$port/";
115115
if ($apache::httpd_modules{'mod_proxy'} &&
116116
$tmpl->{'web_alias'} == 2) {
117117
push(@dirs, "ProxyPass /.well-known !",
@@ -130,14 +130,14 @@ sub setup_web
130130
# Because this is a sub-domain, force the document directory
131131
# to be under the super-domain's public_html. Also, the logs
132132
# must be the same as the parent domain's logs.
133-
local $subdom = &get_domain($d->{'subdom'});
134-
local $subdir = &public_html_dir($d);
135-
local $mydir = &public_html_dir($d, 0, 1);
136-
local $subcgi = &cgi_bin_dir($d);
137-
local $mycgi = &cgi_bin_dir($d, 0, 1);
138-
local $clog = &get_apache_log(
133+
my $subdom = &get_domain($d->{'subdom'});
134+
my $subdir = &public_html_dir($d);
135+
my $mydir = &public_html_dir($d, 0, 1);
136+
my $subcgi = &cgi_bin_dir($d);
137+
my $mycgi = &cgi_bin_dir($d, 0, 1);
138+
my $clog = &get_apache_log(
139139
$subdom->{'dom'}, $subdom->{'web_port'}, 0);
140-
local $elog = &get_apache_log(
140+
my $elog = &get_apache_log(
141141
$subdom->{'dom'}, $subdom->{'web_port'}, 1);
142142
foreach my $dir (@dirs) {
143143
if ($dir =~ /^\s*DocumentRoot/) {
@@ -224,8 +224,8 @@ sub setup_web
224224

225225
# Create empty access and error log files, owned by the domain's user.
226226
# Apache opens them as root, so it will be able to write.
227-
local $log = &get_apache_log($d->{'dom'}, $d->{'web_port'}, 0);
228-
local $elog = &get_apache_log($d->{'dom'}, $d->{'web_port'}, 1);
227+
my $log = &get_apache_log($d->{'dom'}, $d->{'web_port'}, 0);
228+
my $elog = &get_apache_log($d->{'dom'}, $d->{'web_port'}, 1);
229229
&setup_apache_logs($d, $log, $elog);
230230
&link_apache_logs($d, $log, $elog);
231231
$d->{'alias_mode'} = 0;
@@ -256,7 +256,7 @@ sub setup_web
256256

257257
# Add the Apache user to the group for this virtual server, if missing,
258258
# unless the template says not to.
259-
local $web_user = &get_apache_user($d);
259+
my $web_user = &get_apache_user($d);
260260
if ($tmpl->{'web_user'} ne 'none' && $web_user) {
261261
&add_user_to_domain_group($d, $web_user, 'setup_webuser');
262262
}
@@ -280,20 +280,20 @@ sub setup_web
280280

281281
# Make the web directory accessible under SElinux Apache
282282
if (&has_command("chcon")) {
283-
local $hdir = &public_html_dir($d);
283+
my $hdir = &public_html_dir($d);
284284
&execute_command("chcon -R -t httpd_sys_content_t ".
285285
quotemeta($hdir));
286-
local $cgidir = &cgi_bin_dir($d);
286+
my $cgidir = &cgi_bin_dir($d);
287287
&execute_command("chcon -R -t httpd_sys_script_exec_t ".
288288
quotemeta($cgidir));
289-
local $logdir = "$d->{'home'}/logs";
289+
my $logdir = "$d->{'home'}/logs";
290290
&execute_command("chcon -R -t httpd_log_t ".
291291
quotemeta($logdir));
292292
}
293293

294294
# Create a root-owned file in ~/logs to prevent deletion of directory
295-
local $logsdir = "$d->{'home'}/logs";
296-
local $log = &get_apache_log($d->{'dom'}, $d->{'web_port'}, 0);
295+
my $logsdir = "$d->{'home'}/logs";
296+
my $log = &get_apache_log($d->{'dom'}, $d->{'web_port'}, 0);
297297
if (-d $logsdir && !-e "$logsdir/.nodelete" &&
298298
&is_under_directory($logsdir, $log)) {
299299
open(NODELETE, ">$logsdir/.nodelete");
@@ -309,11 +309,11 @@ sub setup_web
309309

310310
# Re-apply limits, so that Apache directives are updated
311311
if (defined(&supports_resource_limits)) {
312-
local ($ok) = &supports_resource_limits();
312+
my ($ok) = &supports_resource_limits();
313313
if ($ok) {
314-
local $pd = $d->{'parent'} ?
314+
my $pd = $d->{'parent'} ?
315315
&get_domain($d->{'parent'}) : $d;
316-
local $rv = &get_domain_resource_limits($pd);
316+
my $rv = &get_domain_resource_limits($pd);
317317
&save_domain_resource_limits($d, $rv, 1) if (%{$rv});
318318
}
319319
}
@@ -343,7 +343,7 @@ sub setup_web
343343
}
344344

345345
# If any alias domains with web already exist, re-set them up
346-
local @adoms = &get_domain_by("alias", $d->{'id'},
346+
my @adoms = &get_domain_by("alias", $d->{'id'},
347347
"web", 1,
348348
"alias_mode", 1);
349349
foreach my $ad (@adoms) {
@@ -358,25 +358,25 @@ sub setup_web
358358
# Delete the virtual server from the Apache config
359359
sub delete_web
360360
{
361-
local ($d) = @_;
361+
my ($d) = @_;
362362
&require_apache();
363363
if ($d->{'alias_mode'}) {
364364
# Just delete ServerAlias directives from parent
365365
&$first_print($text{'delete_apachealias'});
366-
local $alias = &get_domain($d->{'alias'});
366+
my $alias = &get_domain($d->{'alias'});
367367
&obtain_lock_web($alias);
368368
&remove_webmail_redirect_directives($d);
369-
local @ports = ( $alias->{'web_port'} );
369+
my @ports = ( $alias->{'web_port'} );
370370
push(@ports, $alias->{'web_sslport'}) if ($alias->{'ssl'});
371371
foreach my $p (@ports) {
372-
local ($pvirt, $pconf, $conf) = &get_apache_virtual(
372+
my ($pvirt, $pconf, $conf) = &get_apache_virtual(
373373
$alias->{'dom'}, $p);
374374
if (!$pvirt) {
375375
&release_lock_web($alias);
376376
&$second_print($text{'setup_ewebalias'});
377377
return 0;
378378
}
379-
local @sa = &apache::find_directive("ServerAlias", $pconf);
379+
my @sa = &apache::find_directive("ServerAlias", $pconf);
380380
@sa = grep { !/(^|\.)\Q$d->{'dom'}\E$/ } @sa;
381381
&apache::save_directive("ServerAlias", \@sa, $pconf, $conf);
382382
&flush_file_lines($pvirt->{'file'});
@@ -399,17 +399,17 @@ sub delete_web
399399
# Just delete one virtual server
400400
&$first_print($text{'delete_apache'});
401401
&obtain_lock_web($d);
402-
local $conf = &apache::get_config();
402+
my $conf = &apache::get_config();
403403
if (!$d->{'alias_mode'}) {
404404
# Remove the custom Listen directive added for the domain
405405
&remove_listen($d, $conf, $d->{'web_port'});
406406
}
407-
local ($virt, $vconf) = &get_apache_virtual($d->{'dom'},
407+
my ($virt, $vconf) = &get_apache_virtual($d->{'dom'},
408408
$d->{'web_port'});
409409
if ($virt) {
410-
local $alog = &get_apache_log($d->{'dom'},
410+
my $alog = &get_apache_log($d->{'dom'},
411411
$d->{'web_port'}, 0);
412-
local $elog = &get_apache_log($d->{'dom'},
412+
my $elog = &get_apache_log($d->{'dom'},
413413
$d->{'web_port'}, 1);
414414
&delete_web_virtual_server($virt, $conf);
415415
&$second_print($text{'setup_done'});
@@ -418,7 +418,7 @@ sub delete_web
418418
if ($alog && !&is_under_directory($d->{'home'}, $alog) &&
419419
!$d->{'subdom'} && !$d->{'web_nodeletelogs'}) {
420420
&$first_print($text{'delete_apachelog'});
421-
local @dlogs = ($alog, glob("${alog}.*"),
421+
my @dlogs = ($alog, glob("${alog}.*"),
422422
glob("${alog}_*"), glob("${alog}-*"));
423423
if ($elog) {
424424
push(@dlogs, $elog, glob("${elog}.*"),

0 commit comments

Comments
 (0)