@@ -15,10 +15,10 @@ sub require_apache
15
15
# Setup a virtual website for some domain
16
16
sub setup_web
17
17
{
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 );
22
22
if ($d -> {' alias' } && $tmpl -> {' web_alias' } == 1) {
23
23
&$first_print ($text {' setup_webalias' });
24
24
$lockdom = $alias = &get_domain($d -> {' alias' });
@@ -29,19 +29,19 @@ sub setup_web
29
29
}
30
30
&require_apache();
31
31
&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 );
34
34
35
35
# 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 ;
38
38
if ($d -> {' ip6' }) {
39
39
$nvstar6 = &add_name_virtual($d , $conf , $web_port , 1, $d -> {' ip6' });
40
40
}
41
41
42
42
# We use a * for the address for name-based servers under Apache 2,
43
43
# 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 );
45
45
46
46
# Add Listen if needed
47
47
&add_listen($d , $conf , $web_port );
@@ -51,22 +51,22 @@ sub setup_web
51
51
delete ($d -> {' php_fpm_port' });
52
52
}
53
53
54
- local @dirs = &apache_template($tmpl -> {' web' }, $d );
54
+ my @dirs = &apache_template($tmpl -> {' web' }, $d );
55
55
if ($apache::httpd_modules {' mod_proxy' }) {
56
56
push (@dirs , " ProxyPass /.well-known !" );
57
57
}
58
58
if ($d -> {' alias' } && $tmpl -> {' web_alias' } == 1) {
59
59
# Update the parent virtual host (and the SSL virtual host, if any)
60
- local @ports = ( $alias -> {' web_port' } );
60
+ my @ports = ( $alias -> {' web_port' } );
61
61
push (@ports , $alias -> {' web_sslport' }) if ($alias -> {' ssl' });
62
62
foreach my $p (@ports ) {
63
- local ($pvirt , $pconf ) = &get_apache_virtual(
63
+ my ($pvirt , $pconf ) = &get_apache_virtual(
64
64
$alias -> {' dom' }, $p );
65
65
if (!$pvirt ) {
66
66
&$second_print ($text {' setup_ewebalias' });
67
67
return 0;
68
68
}
69
- local @sa = &apache::find_directive(" ServerAlias" , $pconf );
69
+ my @sa = &apache::find_directive(" ServerAlias" , $pconf );
70
70
foreach my $dir (@dirs ) {
71
71
if ($dir =~ / ^\s *Server(Name|Alias)\s +(.*)/ ) {
72
72
push (@sa , $2 );
@@ -99,19 +99,19 @@ sub setup_web
99
99
# Add the actual <VirtualHost>
100
100
101
101
# First build up the directives in the <VirtualHost>
102
- local $proxying ;
102
+ my $proxying ;
103
103
if ($d -> {' alias' }) {
104
104
# Because this is just an alias to an existing virtual server,
105
105
# create a ProxyPass or Redirect
106
106
@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 ? " " :
109
109
" :$aliasdom ->{'web_port'}" ;
110
- local $urlhost = " www." .$aliasdom -> {' dom' };
110
+ my $urlhost = " www." .$aliasdom -> {' dom' };
111
111
if (!&to_ipaddress($urlhost )) {
112
112
$urlhost = $aliasdom -> {' dom' };
113
113
}
114
- local $url = " http://$urlhost$port /" ;
114
+ my $url = " http://$urlhost$port /" ;
115
115
if ($apache::httpd_modules {' mod_proxy' } &&
116
116
$tmpl -> {' web_alias' } == 2) {
117
117
push (@dirs , " ProxyPass /.well-known !" ,
@@ -130,14 +130,14 @@ sub setup_web
130
130
# Because this is a sub-domain, force the document directory
131
131
# to be under the super-domain's public_html. Also, the logs
132
132
# 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(
139
139
$subdom -> {' dom' }, $subdom -> {' web_port' }, 0);
140
- local $elog = &get_apache_log(
140
+ my $elog = &get_apache_log(
141
141
$subdom -> {' dom' }, $subdom -> {' web_port' }, 1);
142
142
foreach my $dir (@dirs ) {
143
143
if ($dir =~ / ^\s *DocumentRoot/ ) {
@@ -224,8 +224,8 @@ sub setup_web
224
224
225
225
# Create empty access and error log files, owned by the domain's user.
226
226
# 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);
229
229
&setup_apache_logs($d , $log , $elog );
230
230
&link_apache_logs($d , $log , $elog );
231
231
$d -> {' alias_mode' } = 0;
@@ -256,7 +256,7 @@ sub setup_web
256
256
257
257
# Add the Apache user to the group for this virtual server, if missing,
258
258
# unless the template says not to.
259
- local $web_user = &get_apache_user($d );
259
+ my $web_user = &get_apache_user($d );
260
260
if ($tmpl -> {' web_user' } ne ' none' && $web_user ) {
261
261
&add_user_to_domain_group($d , $web_user , ' setup_webuser' );
262
262
}
@@ -280,20 +280,20 @@ sub setup_web
280
280
281
281
# Make the web directory accessible under SElinux Apache
282
282
if (&has_command(" chcon" )) {
283
- local $hdir = &public_html_dir($d );
283
+ my $hdir = &public_html_dir($d );
284
284
&execute_command(" chcon -R -t httpd_sys_content_t " .
285
285
quotemeta ($hdir ));
286
- local $cgidir = &cgi_bin_dir($d );
286
+ my $cgidir = &cgi_bin_dir($d );
287
287
&execute_command(" chcon -R -t httpd_sys_script_exec_t " .
288
288
quotemeta ($cgidir ));
289
- local $logdir = " $d ->{'home'}/logs" ;
289
+ my $logdir = " $d ->{'home'}/logs" ;
290
290
&execute_command(" chcon -R -t httpd_log_t " .
291
291
quotemeta ($logdir ));
292
292
}
293
293
294
294
# 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);
297
297
if (-d $logsdir && !-e " $logsdir /.nodelete" &&
298
298
&is_under_directory($logsdir , $log )) {
299
299
open (NODELETE, " >$logsdir /.nodelete" );
@@ -309,11 +309,11 @@ sub setup_web
309
309
310
310
# Re-apply limits, so that Apache directives are updated
311
311
if (defined (&supports_resource_limits)) {
312
- local ($ok ) = &supports_resource_limits();
312
+ my ($ok ) = &supports_resource_limits();
313
313
if ($ok ) {
314
- local $pd = $d -> {' parent' } ?
314
+ my $pd = $d -> {' parent' } ?
315
315
&get_domain($d -> {' parent' }) : $d ;
316
- local $rv = &get_domain_resource_limits($pd );
316
+ my $rv = &get_domain_resource_limits($pd );
317
317
&save_domain_resource_limits($d , $rv , 1) if (%{$rv });
318
318
}
319
319
}
@@ -343,7 +343,7 @@ sub setup_web
343
343
}
344
344
345
345
# 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' },
347
347
" web" , 1,
348
348
" alias_mode" , 1);
349
349
foreach my $ad (@adoms ) {
@@ -358,25 +358,25 @@ sub setup_web
358
358
# Delete the virtual server from the Apache config
359
359
sub delete_web
360
360
{
361
- local ($d ) = @_ ;
361
+ my ($d ) = @_ ;
362
362
&require_apache();
363
363
if ($d -> {' alias_mode' }) {
364
364
# Just delete ServerAlias directives from parent
365
365
&$first_print ($text {' delete_apachealias' });
366
- local $alias = &get_domain($d -> {' alias' });
366
+ my $alias = &get_domain($d -> {' alias' });
367
367
&obtain_lock_web($alias );
368
368
&remove_webmail_redirect_directives($d );
369
- local @ports = ( $alias -> {' web_port' } );
369
+ my @ports = ( $alias -> {' web_port' } );
370
370
push (@ports , $alias -> {' web_sslport' }) if ($alias -> {' ssl' });
371
371
foreach my $p (@ports ) {
372
- local ($pvirt , $pconf , $conf ) = &get_apache_virtual(
372
+ my ($pvirt , $pconf , $conf ) = &get_apache_virtual(
373
373
$alias -> {' dom' }, $p );
374
374
if (!$pvirt ) {
375
375
&release_lock_web($alias );
376
376
&$second_print ($text {' setup_ewebalias' });
377
377
return 0;
378
378
}
379
- local @sa = &apache::find_directive(" ServerAlias" , $pconf );
379
+ my @sa = &apache::find_directive(" ServerAlias" , $pconf );
380
380
@sa = grep { !/(^|\.)\Q$d -> {' dom' }\E$/ } @sa ;
381
381
&apache::save_directive(" ServerAlias" , \@sa , $pconf , $conf );
382
382
&flush_file_lines($pvirt -> {' file' });
@@ -399,17 +399,17 @@ sub delete_web
399
399
# Just delete one virtual server
400
400
&$first_print ($text {' delete_apache' });
401
401
&obtain_lock_web($d );
402
- local $conf = &apache::get_config();
402
+ my $conf = &apache::get_config();
403
403
if (!$d -> {' alias_mode' }) {
404
404
# Remove the custom Listen directive added for the domain
405
405
&remove_listen($d , $conf , $d -> {' web_port' });
406
406
}
407
- local ($virt , $vconf ) = &get_apache_virtual($d -> {' dom' },
407
+ my ($virt , $vconf ) = &get_apache_virtual($d -> {' dom' },
408
408
$d -> {' web_port' });
409
409
if ($virt ) {
410
- local $alog = &get_apache_log($d -> {' dom' },
410
+ my $alog = &get_apache_log($d -> {' dom' },
411
411
$d -> {' web_port' }, 0);
412
- local $elog = &get_apache_log($d -> {' dom' },
412
+ my $elog = &get_apache_log($d -> {' dom' },
413
413
$d -> {' web_port' }, 1);
414
414
&delete_web_virtual_server($virt , $conf );
415
415
&$second_print ($text {' setup_done' });
@@ -418,7 +418,7 @@ sub delete_web
418
418
if ($alog && !&is_under_directory($d -> {' home' }, $alog ) &&
419
419
!$d -> {' subdom' } && !$d -> {' web_nodeletelogs' }) {
420
420
&$first_print ($text {' delete_apachelog' });
421
- local @dlogs = ($alog , glob (" ${alog} .*" ),
421
+ my @dlogs = ($alog , glob (" ${alog} .*" ),
422
422
glob (" ${alog} _*" ), glob (" ${alog} -*" ));
423
423
if ($elog ) {
424
424
push (@dlogs , $elog , glob (" ${elog} .*" ),
0 commit comments