Added detection for vservers

This commit is contained in:
Jamie Cameron
2007-05-06 20:32:02 +00:00
parent 7ce51b0d11
commit 64f741f7d7
6 changed files with 30 additions and 2 deletions

View File

@@ -24,3 +24,4 @@ depends=mount 1.276
version=1.276
desc_ru_RU=Êàòàëîãè NFS
desc_ca=Exportacions NFS
novserver=1

View File

@@ -23,3 +23,4 @@ desc_zh_TW.UTF-8=本機磁碟分割區
desc_zh_CN.UTF-8=本地ç£<C3A7>ç˜åˆ†åŒº
desc_ja_JP.UTF-8=ローカル デã£ã¹ã¯ã<C2AF>®ãƒãƒ¼ãƒ†ã£ã·ãƒ§ãƒ³
desc_ko_KR.UTF-8=지역 디스í<C2A4>¬ 파티션
novserver=1

View File

@@ -27,3 +27,4 @@ desc_zh_TW.UTF-8=磁碟與網路檔案系統
desc_zh_CN.UTF-8=ç£<C3A7>ç˜åŒç½ç»œæ‡ä»¶ç³»ç»Ÿ
desc_ja_JP.UTF-8=デã£ã¹ã¯ã<C2AF>Šãˆã<CB86>³ãƒ<C3A3>ットワーã¯ï½¥ãƒ•ã¡ã¤ãƒ«ã·ã¹ãƒ†ãƒ 
desc_ko_KR.UTF-8=디스í<C2A4>¬ ë°<C3AB> 네트ìŒí<C592>¬ 파ì<C592>¼ìœìŠ¤í…œ
novserver=1

View File

@@ -6,10 +6,11 @@ require './net-lib.pl';
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
&help_search_link("ifconfig hosts resolve.conf nsswitch.conf", "man"));
$zone = &running_in_zone() || &running_in_vserver();
foreach $i ('ifcs', 'routes', 'dns', 'hosts',
($config{'ipnodes_file'} ? ('ipnodes') : ( ))) {
next if (!$access{$i});
next if ($i eq "ifcs" && &running_in_zone());
next if ($i eq "ifcs" && $zone);
push(@links, "list_${i}.cgi");
push(@titles, $text{"${i}_title"});
@@ -17,7 +18,7 @@ foreach $i ('ifcs', 'routes', 'dns', 'hosts',
}
&icons_table(\@links, \@titles, \@icons, @icons > 4 ? scalar(@icons) : 4);
if (defined(&apply_network) && $access{'apply'} && !&running_in_zone()) {
if (defined(&apply_network) && $access{'apply'} && !$zone) {
# Allow the user to apply the network config
print "<hr>\n";
print "<form action=apply.cgi>\n";

View File

@@ -27,3 +27,4 @@ desc_zh_TW.UTF-8=系統時間
desc_zh_CN.UTF-8=系统时间
desc_ja_JP.UTF-8=システム時間
desc_ko_KR.UTF-8=시스템 시간
novserver=1

View File

@@ -1319,6 +1319,10 @@ if ($_[0]->{'nozone'} && &running_in_zone()) {
# Not supported in a Solaris Zone
return 0;
}
if ($_[0]->{'novserver'} && &running_in_vserver()) {
# Not supported in a Linux vserver
return 0;
}
return 1 if (!$oss || $oss eq '*');
local $osver = $_[2] || $gconfig{'os_version'};
local $ostype = $_[1] || $gconfig{'os_type'};
@@ -5937,6 +5941,25 @@ chop($zn);
return $zn && $zn ne "global";
}
# running_in_vserver()
# Returns 1 if the current Webmin instance is running in a Linux VServer.
# Used to disable modules and features that are not appropriate
sub running_in_vserver
{
return 0 if ($gconfig{'os_type'} !~ /^\*-linux$/);
local $vserver;
open(MTAB, "/etc/mtab");
while(<MTAB>) {
local ($dev, $mp) = split(/\s+/, $_);
if ($mp eq "/" && $dev =~ /^\/dev\/hdv/) {
$vserver = 1;
last;
}
}
close(MTAB);
return $vserver;
}
# list_categories(&modules)
# Returns a hash mapping category codes to names
sub list_categories