Added function to detect running in OpenVZ container
authorJamie Cameron <jcameron@webmin.com>
Wed, 2 Sep 2009 21:01:08 +0000 (14:01 -0700)
committerJamie Cameron <jcameron@webmin.com>
Wed, 2 Sep 2009 21:01:08 +0000 (14:01 -0700)
fdisk/module.info
time/module.info
time/time-lib.pl
web-lib-funcs.pl

index 1d82088..4db4547 100644 (file)
@@ -24,6 +24,7 @@ desc_zh_CN.UTF-8=本地磁盘分区
 desc_ja_JP.UTF-8=ローカル ディスクのパーティション
 desc_ko_KR.UTF-8=지역 디스크 파티션 
 novserver=1
+noopenvz=1
 desc_cz=Oddíly na lokálních discích
 desc_nl=Partities op Locale Hard Disken
 desc_ru.UTF-8=Разделы на локальных дисках
index 58f5cf7..fdd57bc 100644 (file)
@@ -28,6 +28,7 @@ desc_zh_CN.UTF-8=系统时间
 desc_ja_JP.UTF-8=システム時間
 desc_ko_KR.UTF-8=시스템 시간
 novserver=1
+noopenvz=1
 desc_it=Ora di sistema
 desc_nl=Systeem Tijd
 desc_ru.UTF-8=Системное время
index 7016285..305b908 100755 (executable)
@@ -220,7 +220,7 @@ elsif ($config{'hwtime'} == 0) {
 else {
        return &has_command("hwclock") &&
               !&running_in_xen() && !&running_in_vserver() &&
-              !&running_in_zone();
+              !&running_in_openvz() && !&running_in_zone();
        }
 }
 
index 9fa6751..43bd0a9 100755 (executable)
@@ -1871,7 +1871,11 @@ if ($_[0]->{'nozone'} && &running_in_zone()) {
        return 0;
        }
 if ($_[0]->{'novserver'} && &running_in_vserver()) {
-       # Not supported in a Linux vserver
+       # Not supported in a Linux Vserver
+       return 0;
+       }
+if ($_[0]->{'noopenvz'} && &running_in_openvz()) {
+       # Not supported in an OpenVZ container
        return 0;
        }
 return 1 if (!$oss || $oss eq '*');
@@ -8146,6 +8150,25 @@ my $cap = &read_file_contents("/proc/xen/capabilities");
 return $cap =~ /control_d/ ? 0 : 1;
 }
 
+=head2 running_in_openvz
+
+Returns 1 if Webmin is running inside an OpenVZ container, by looking
+at /proc/vz/veinfo for a non-zero line.
+
+=cut
+sub running_in_openvz
+{
+return 0 if (!-r "/proc/vz/veinfo");
+my $lref = &read_file_lines("/proc/vz/veinfo", 1);
+return 0 if (!$lref || !@$lref);
+foreach my $l (@$lref) {
+       $l =~ s/^\s+//;
+       my @ll = split(/\s+/, $l);
+       return 0 if ($ll[0] eq '0');
+       }
+return 1;
+}
+
 =head2 list_categories(&modules, [include-empty])
 
 Returns a hash mapping category codes to names, including any custom-defined