The server_root function doesn't need the global config as a parameter
This commit is contained in:
+15
-8
@@ -812,9 +812,16 @@ foreach my $d (@$conf) {
|
||||
# Convert a relative path to being under the server root
|
||||
sub server_root
|
||||
{
|
||||
if (!$_[0]) { return undef; }
|
||||
elsif ($_[0] =~ /^\//) { return $_[0]; }
|
||||
else { return "$config{'httpd_dir'}/$_[0]"; }
|
||||
my ($path) = @_;
|
||||
if (!$path) {
|
||||
return undef;
|
||||
}
|
||||
elsif ($path =~ /^\//) {
|
||||
return $path;
|
||||
}
|
||||
else {
|
||||
return "$config{'httpd_dir'}/$path";
|
||||
}
|
||||
}
|
||||
|
||||
sub dump_config
|
||||
@@ -1432,7 +1439,7 @@ sub allowed_auth_file
|
||||
local $_;
|
||||
return 1 if ($access{'dir'} eq '/');
|
||||
return 0 if ($_[0] =~ /\.\./);
|
||||
local $f = &server_root($_[0], &get_config());
|
||||
local $f = &server_root($_[0]);
|
||||
return 0 if (-l $f && !&allowed_auth_file(readlink($f)));
|
||||
local $l = length($access{'dir'});
|
||||
return length($f) >= $l && substr($f, 0, $l) eq $access{'dir'};
|
||||
@@ -1442,7 +1449,7 @@ return length($f) >= $l && substr($f, 0, $l) eq $access{'dir'};
|
||||
# Returns 1 if the directory in some path exists
|
||||
sub directory_exists
|
||||
{
|
||||
local $path = &server_root($_[0], &get_config());
|
||||
local $path = &server_root($_[0]);
|
||||
if ($path =~ /^(\S*\/)([^\/]+)$/) {
|
||||
return -d $1;
|
||||
}
|
||||
@@ -1618,7 +1625,7 @@ local $conf = &get_config();
|
||||
local $pidfilestr = &find_directive_struct("PidFile", $conf);
|
||||
local $pidfile = $pidfilestr ? $pidfilestr->{'words'}->[0]
|
||||
: "logs/httpd.pid";
|
||||
return &server_root($pidfile, $conf);
|
||||
return &server_root($pidfile);
|
||||
}
|
||||
|
||||
# restart_apache()
|
||||
@@ -1803,7 +1810,7 @@ if (!&is_apache_running()) {
|
||||
return $text{'start_eunknown'};
|
||||
}
|
||||
else {
|
||||
$errorlog = &server_root($errorlog, $conf);
|
||||
$errorlog = &server_root($errorlog);
|
||||
$out = &backquote_command("tail -5 ".quotemeta($errorlog));
|
||||
return "$text{'start_eafter'} : <pre>$out</pre>";
|
||||
}
|
||||
@@ -1820,7 +1827,7 @@ local $conf = &get_config();
|
||||
local $errorlogstr = &find_directive_struct("ErrorLog", $conf);
|
||||
local $errorlog = $errorlogstr ? $errorlogstr->{'words'}->[0]
|
||||
: "logs/error_log";
|
||||
$errorlog = &server_root($errorlog, $conf);
|
||||
$errorlog = &server_root($errorlog);
|
||||
return $errorlog;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,23 +14,23 @@ push(@rv, map { $_->{'file'} } @$conf);
|
||||
# Add mime types file
|
||||
local $mfile = &find_directive("TypesConfig", $conf);
|
||||
if (!$mfile) { $mfile = $config{'mime_types'}; }
|
||||
if (!$mfile) { $mfile = &server_root("etc/mime.types", $conf); }
|
||||
if (!-r $mfile) { $mfile = &server_root("conf/mime.types", $conf); }
|
||||
if (!$mfile) { $mfile = &server_root("etc/mime.types"); }
|
||||
if (!-r $mfile) { $mfile = &server_root("conf/mime.types"); }
|
||||
if ($mfile) {
|
||||
push(@rv, &server_root($mfile, $conf));
|
||||
push(@rv, &server_root($mfile));
|
||||
}
|
||||
|
||||
# Add mime magic file
|
||||
local $magic = &find_directive("MimeMagicFile", $conf);
|
||||
if ($magic) {
|
||||
push(@rv, &server_root($magic, $conf));
|
||||
push(@rv, &server_root($magic));
|
||||
}
|
||||
|
||||
# Add all auth files
|
||||
local $auth;
|
||||
foreach $auth (&find_all_directives($conf, "AuthUserFile"),
|
||||
&find_all_directives($conf, "AuthGroupFile")) {
|
||||
push(@rv, &server_root($auth, $conf));
|
||||
push(@rv, &server_root($auth));
|
||||
}
|
||||
|
||||
return &unique(@rv);
|
||||
|
||||
@@ -22,9 +22,9 @@ print &ui_form_end([ [ "", $text{'save'} ] ]);
|
||||
if ($in{'type'} == 6) {
|
||||
$mfile = &find_directive("TypesConfig", $conf);
|
||||
if (!$mfile) { $mfile = $config{'mime_types'}; }
|
||||
if (!$mfile) { $mfile = &server_root("etc/mime.types", $conf); }
|
||||
if (!-r $mfile) { $mfile = &server_root("conf/mime.types", $conf); }
|
||||
$mfile = &server_root($mfile, $conf);
|
||||
if (!$mfile) { $mfile = &server_root("etc/mime.types"); }
|
||||
if (!-r $mfile) { $mfile = &server_root("conf/mime.types"); }
|
||||
$mfile = &server_root($mfile);
|
||||
print &ui_hr();
|
||||
print &ui_subheading($text{'global_mime'});
|
||||
print "$text{'global_mimedesc'}<p>\n";
|
||||
|
||||
@@ -11,7 +11,7 @@ $conf = &get_config();
|
||||
&error(&text('authg_ecannot', $in{'file'}));
|
||||
$desc = &text('authg_header', "<tt>$in{'file'}</tt>");
|
||||
&ui_print_header($desc, $text{'authg_title'}, "");
|
||||
$f = &server_root($in{'file'}, $conf);
|
||||
$f = &server_root($in{'file'});
|
||||
|
||||
@groups = sort { $a->{'name'} cmp $b->{'name'} } &list_authgroups($in{'file'});
|
||||
if (@groups) {
|
||||
|
||||
@@ -11,7 +11,7 @@ $conf = &get_config();
|
||||
&error(&text('authu_ecannot', $in{'file'}));
|
||||
$desc = &text('authu_header', "<tt>$in{'file'}</tt>");
|
||||
&ui_print_header($desc, $text{'authu_title'}, "");
|
||||
$f = &server_root($in{'file'}, $conf);
|
||||
$f = &server_root($in{'file'});
|
||||
|
||||
@users = sort { $a cmp $b } &list_authusers($f);
|
||||
if (@users) {
|
||||
|
||||
@@ -34,8 +34,13 @@ if (!$running) {
|
||||
&error($text{'restart_eunknown'});
|
||||
}
|
||||
else {
|
||||
<<<<<<< HEAD
|
||||
$errorlog = &server_root($errorlog, $conf);
|
||||
$out = &backquote_command("tail -5 ".quotemeta($errorlog));
|
||||
=======
|
||||
$errorlog = &server_root($errorlog);
|
||||
$out = `tail -5 $errorlog`;
|
||||
>>>>>>> The server_root function doesn't need the global config as a parameter
|
||||
&error("<pre>$out</pre>");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user