Added detection for vservers
authorJamie Cameron <jcameron@webmin.com>
Sun, 6 May 2007 20:32:02 +0000 (20:32 +0000)
committerJamie Cameron <jcameron@webmin.com>
Sun, 6 May 2007 20:32:02 +0000 (20:32 +0000)
exports/module.info
fdisk/module.info
mount/module.info
net/index.cgi
time/module.info
web-lib-funcs.pl

index 8b2e39a..b104006 100644 (file)
@@ -24,3 +24,4 @@ depends=mount 1.276
 version=1.276
 desc_ru_RU=Êàòàëîãè NFS
 desc_ca=Exportacions NFS
+novserver=1
index d0c4e3f..bdd1e24 100644 (file)
@@ -23,3 +23,4 @@ desc_zh_TW.UTF-8=本機磁碟分割區
 desc_zh_CN.UTF-8=本地磁盘分区
 desc_ja_JP.UTF-8=ローカル ディスクのパーティション
 desc_ko_KR.UTF-8=지역 디스크 파티션 
+novserver=1
index dfc634e..d0c0a78 100644 (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
index 95cee5b..0cc77af 100755 (executable)
@@ -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";
index fbbdb28..3ee18cb 100644 (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
index 5886ef0..8ff7858 100755 (executable)
@@ -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