* [pve-devel] [PATCH common 1/1] Fix #7175: remove deprecated timezone file
2025-12-25 8:05 [pve-devel] [PATCH manager/common 0/1] Fix #7175: switch API to timedatectl Stefan Mayr
@ 2025-12-25 8:05 ` Stefan Mayr
2025-12-25 8:05 ` [pve-devel] [PATCH manager 1/1] Fix #7175: use timedatectl for timezone handling Stefan Mayr
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Mayr @ 2025-12-25 8:05 UTC (permalink / raw)
To: pve-devel
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Stefan Mayr <stefan@mayr-stefan.de>
---
src/PVE/INotify.pm | 29 -----------------------------
1 file changed, 29 deletions(-)
diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index 62b3ca8..03c871c 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -651,35 +651,6 @@ register_file(
\&update_etc_resolv_conf,
);
-sub read_etc_timezone {
- my ($filename, $fd) = @_;
-
- my $timezone = <$fd>;
-
- chomp $timezone;
-
- return $timezone;
-}
-
-sub write_etc_timezone {
- my ($filename, $fh, $timezone) = @_;
-
- my $tzinfo = "/usr/share/zoneinfo/$timezone";
-
- raise_param_exc({ 'timezone' => "No such timezone" })
- if (!-f $tzinfo);
-
- ($timezone) = $timezone =~ m/^(.*)$/; # untaint
-
- print $fh "$timezone\n";
-
- unlink("/etc/localtime");
- symlink("/usr/share/zoneinfo/$timezone", "/etc/localtime");
-
-}
-
-register_file('timezone', "/etc/timezone", \&read_etc_timezone, \&write_etc_timezone);
-
sub read_active_workers {
my ($filename, $fh) = @_;
--
2.34.1
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread* [pve-devel] [PATCH manager 1/1] Fix #7175: use timedatectl for timezone handling
2025-12-25 8:05 [pve-devel] [PATCH manager/common 0/1] Fix #7175: switch API to timedatectl Stefan Mayr
2025-12-25 8:05 ` [pve-devel] [PATCH common 1/1] Fix #7175: remove deprecated timezone file Stefan Mayr
@ 2025-12-25 8:05 ` Stefan Mayr
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Mayr @ 2025-12-25 8:05 UTC (permalink / raw)
To: pve-devel
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Stefan Mayr <stefan@mayr-stefan.de>
---
PVE/API2/Nodes.pm | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 6a6465b6..54ed712e 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -1582,10 +1582,15 @@ __PACKAGE__->register_method({
code => sub {
my ($param) = @_;
+ my $timezone;
my $ctime = time();
my $ltime = timegm_nocheck(localtime($ctime));
+ PVE::Tools::run_command(
+ ['timedatectl', 'show', '--property=Timezone', '--value'],
+ outfunc => sub { $timezone //= shift },
+ );
my $res = {
- timezone => PVE::INotify::read_file('timezone'),
+ timezone => $timezone,
time => $ctime,
localtime => $ltime,
};
@@ -1619,7 +1624,7 @@ __PACKAGE__->register_method({
code => sub {
my ($param) = @_;
- PVE::INotify::write_file('timezone', $param->{timezone});
+ PVE::Tools::run_command(['timedatectl', 'set-timezone', $param->{timezone}]);
return;
},
--
2.34.1
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread