mirror of
https://git.proxmox.com/git/pve-common
synced 2025-07-28 22:02:54 +00:00
schema: register 'timezone' format and add verification method
/usr/share/zoneinfo/zone.tab has the valid list of time zones. Signed-off-by: Oguz Bektas <o.bektas@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
0bbe789c6a
commit
e76308e6eb
@ -482,6 +482,25 @@ sub pve_verify_dns_name {
|
|||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
register_format('timezone', \&pve_verify_timezone);
|
||||||
|
sub pve_verify_timezone {
|
||||||
|
my ($timezone, $noerr) = @_;
|
||||||
|
|
||||||
|
my $zonetab = "/usr/share/zoneinfo/zone.tab";
|
||||||
|
return $timezone if $timezone eq 'UTC';
|
||||||
|
open(my $fh, "<", $zonetab);
|
||||||
|
while(my $line = <$fh>) {
|
||||||
|
next if $line =~ /^#/;
|
||||||
|
chomp $line;
|
||||||
|
return $timezone if $timezone eq (split /\t/, $line)[2]; # found
|
||||||
|
}
|
||||||
|
close $fh;
|
||||||
|
|
||||||
|
return undef if $noerr;
|
||||||
|
die "invalid time zone '$timezone'\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# network interface name
|
# network interface name
|
||||||
register_format('pve-iface', \&pve_verify_iface);
|
register_format('pve-iface', \&pve_verify_iface);
|
||||||
sub pve_verify_iface {
|
sub pve_verify_iface {
|
||||||
|
Loading…
Reference in New Issue
Block a user