Skip to content

Commit bf07ed0

Browse files
committed
Only allow changing of document root if virtualmin is not installed
https://forum.virtualmin.com/t/nginx-changing-default-root-directory-breaks-virtualmin/134173
1 parent e1dec61 commit bf07ed0

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

edit_sdocs.cgi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ print &ui_form_start("save_sdocs.cgi", "post");
1616
print &ui_hidden("id", $in{'id'});
1717
print &ui_table_start($text{'docs_header'}, undef, 2);
1818

19-
print &nginx_opt_input("root", $server, 60, undef,
20-
&file_chooser_button("root", 1));
19+
if (!&foreign_check("virtual-server")) {
20+
print &nginx_opt_input("root", $server, 60, undef,
21+
&file_chooser_button("root", 1));
22+
}
2123

2224
print &nginx_opt_input("index", $server, 60, undef, undef, 1);
2325

save_sdocs.cgi

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ my $server = &find_server($in{'id'});
1212
$server || &error($text{'server_egone'});
1313
&can_edit_server($server) || &error($text{'server_ecannot'});
1414

15-
&nginx_opt_parse("root", $server, undef, '^\/.*$');
16-
$in{'root_def'} || &can_directory($in{'root'}) ||
17-
&error(&text('location_ecannot',
18-
"<tt>".&html_escape($in{'root'})."</tt>",
19-
"<tt>".&html_escape($access{'root'})."</tt>"));
15+
if (!&foreign_check("virtual-server")) {
16+
&nginx_opt_parse("root", $server, undef, '^\/.*$');
17+
$in{'root_def'} || &can_directory($in{'root'}) ||
18+
&error(&text('location_ecannot',
19+
"<tt>".&html_escape($in{'root'})."</tt>",
20+
"<tt>".&html_escape($access{'root'})."</tt>"));
21+
}
2022

2123
&nginx_opt_parse("index", $server, undef, undef, undef, 1);
2224

@@ -28,17 +30,19 @@ $in{'root_def'} || &can_directory($in{'root'}) ||
2830
my $name = &find_value("server_name", $server);
2931
&webmin_log("sdocs", "server", $name);
3032

31-
# Redirect with the the new root directory if it was changed
32-
my ($dom, $domroot_curr) = split(/;/, $in{'id'});
33-
my $domroot_new = $in{'root'} ? $in{'root'} : undef;
34-
my ($return_id, $return_query) = ($in{'id'}, "");
35-
if ($domroot_new && $domroot_new ne $domroot_curr) {
36-
&foreign_require("virtual-server");
37-
my $d = &virtual_server::get_domain_by('dom', $dom);
38-
if ($d) {
39-
&virtual_server::clear_links_cache($d);
40-
$return_id = "$dom;$domroot_new";
41-
$return_query = "refresh=1";
33+
if (!&foreign_check("virtual-server")) {
34+
# Redirect with the the new root directory if it was changed
35+
my ($dom, $domroot_curr) = split(/;/, $in{'id'});
36+
my $domroot_new = $in{'root'} ? $in{'root'} : undef;
37+
my ($return_id, $return_query) = ($in{'id'}, "");
38+
if ($domroot_new && $domroot_new ne $domroot_curr) {
39+
&foreign_require("virtual-server");
40+
my $d = &virtual_server::get_domain_by('dom', $dom);
41+
if ($d) {
42+
&virtual_server::clear_links_cache($d);
43+
$return_id = "$dom;$domroot_new";
44+
$return_query = "refresh=1";
45+
}
4246
}
4347
}
4448

0 commit comments

Comments
 (0)