* [pve-devel] [PATCH manager v2 1/4] Fix #7175: replace timezone handling with systemd timedatectl
2026-01-25 21:01 [pve-devel] [PATCH common, container, manager and pmg-api v2 0/4] Fix #7175: replace timezone handling with systemd timedatectl Stefan Mayr
@ 2026-01-25 21:01 ` Stefan Mayr
2026-01-25 21:01 ` [pve-devel] [PATCH container v2 2/4] " Stefan Mayr
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Mayr @ 2026-01-25 21:01 UTC (permalink / raw)
To: pve-devel
Usage of /etc/timezone is deprecated. The tzdata maintainers recommend
switching to timedatectl.
This changes the use of INotify to the Systemd module for timezone
settings.
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Suggested-by: Maximiliano Sandroval <m.sandoval@proxmox.com>
Signed-off-by: Stefan Mayr <stefan@mayr-stefan.de>
---
PVE/API2/Nodes.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 5bd6fe49..3de2b8c7 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -1585,7 +1585,7 @@ __PACKAGE__->register_method({
my $ctime = time();
my $ltime = timegm_nocheck(localtime($ctime));
my $res = {
- timezone => PVE::INotify::read_file('timezone'),
+ timezone => PVE::Systemd::get_timezone(),
time => $ctime,
localtime => $ltime,
};
@@ -1619,7 +1619,7 @@ __PACKAGE__->register_method({
code => sub {
my ($param) = @_;
- PVE::INotify::write_file('timezone', $param->{timezone});
+ PVE::Systemd::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] 5+ messages in thread* [pve-devel] [PATCH container v2 2/4] Fix #7175: replace timezone handling with systemd timedatectl
2026-01-25 21:01 [pve-devel] [PATCH common, container, manager and pmg-api v2 0/4] Fix #7175: replace timezone handling with systemd timedatectl Stefan Mayr
2026-01-25 21:01 ` [pve-devel] [PATCH manager v2 1/4] " Stefan Mayr
@ 2026-01-25 21:01 ` Stefan Mayr
2026-01-25 21:01 ` [pve-devel] [PATCH pmg-api v2 3/4] " Stefan Mayr
2026-01-25 21:01 ` [pve-devel] [PATCH common v2 4/4] " Stefan Mayr
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Mayr @ 2026-01-25 21:01 UTC (permalink / raw)
To: pve-devel
Usage of /etc/timezone is deprecated. The tzdata maintainers recommend
switching to timedatectl.
This changes the use of INotify to the Systemd module for timezone
settings.
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Suggested-by: Maximiliano Sandroval <m.sandoval@proxmox.com>
Signed-off-by: Stefan Mayr <stefan@mayr-stefan.de>
---
src/PVE/LXC/Setup.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
index 113093d..9dfe766 100644
--- a/src/PVE/LXC/Setup.pm
+++ b/src/PVE/LXC/Setup.pm
@@ -130,7 +130,7 @@ sub new {
# Cache some host files we need access to:
$plugin->{host_resolv_conf} = PVE::INotify::read_file('resolvconf');
- $plugin->{host_timezone} = PVE::INotify::read_file('timezone');
+ $plugin->{host_timezone} = PVE::Systemd::get_timezone();
abs_path('/etc/localtime') =~ m|^(/.+)| or die "invalid /etc/localtime\n"; # untaint
$plugin->{host_localtime} = $1;
--
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] 5+ messages in thread* [pve-devel] [PATCH pmg-api v2 3/4] Fix #7175: replace timezone handling with systemd timedatectl
2026-01-25 21:01 [pve-devel] [PATCH common, container, manager and pmg-api v2 0/4] Fix #7175: replace timezone handling with systemd timedatectl Stefan Mayr
2026-01-25 21:01 ` [pve-devel] [PATCH manager v2 1/4] " Stefan Mayr
2026-01-25 21:01 ` [pve-devel] [PATCH container v2 2/4] " Stefan Mayr
@ 2026-01-25 21:01 ` Stefan Mayr
2026-01-25 21:01 ` [pve-devel] [PATCH common v2 4/4] " Stefan Mayr
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Mayr @ 2026-01-25 21:01 UTC (permalink / raw)
To: pve-devel
Usage of /etc/timezone is deprecated. The tzdata maintainers recommend
switching to timedatectl.
This changes the use of INotify to the Systemd module for timezone
settings.
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Suggested-by: Maximiliano Sandroval <m.sandoval@proxmox.com>
Signed-off-by: Stefan Mayr <stefan@mayr-stefan.de>
---
src/PMG/API2/Nodes.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/PMG/API2/Nodes.pm b/src/PMG/API2/Nodes.pm
index 3479d64..66c4c3b 100644
--- a/src/PMG/API2/Nodes.pm
+++ b/src/PMG/API2/Nodes.pm
@@ -662,7 +662,7 @@ __PACKAGE__->register_method({
my $ctime = time();
my $ltime = timegm_nocheck(localtime($ctime));
my $res = {
- timezone => PVE::INotify::read_file('timezone'),
+ timezone => PVE::Systemd::get_timezone(),
time => time(),
localtime => $ltime,
};
@@ -693,7 +693,7 @@ __PACKAGE__->register_method({
code => sub {
my ($param) = @_;
- PVE::INotify::write_file('timezone', $param->{timezone});
+ PVE::Systemd::set_timezone($param->{timezone});
return undef;
},
--
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] 5+ messages in thread* [pve-devel] [PATCH common v2 4/4] Fix #7175: replace timezone handling with systemd timedatectl
2026-01-25 21:01 [pve-devel] [PATCH common, container, manager and pmg-api v2 0/4] Fix #7175: replace timezone handling with systemd timedatectl Stefan Mayr
` (2 preceding siblings ...)
2026-01-25 21:01 ` [pve-devel] [PATCH pmg-api v2 3/4] " Stefan Mayr
@ 2026-01-25 21:01 ` Stefan Mayr
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Mayr @ 2026-01-25 21:01 UTC (permalink / raw)
To: pve-devel
Usage of /etc/timezone is deprecated. The tzdata maintainers recommend
switching to timedatectl.
This removes handling the timezone file from the INotify module and adds
functions to the Systemd module as a replacement
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Suggested-by: Maximiliano Sandroval <m.sandoval@proxmox.com>
Signed-off-by: Stefan Mayr <stefan@mayr-stefan.de>
---
src/PVE/INotify.pm | 29 -----------------------------
src/PVE/Systemd.pm | 35 ++++++++++++++++++++++++++++++++++-
2 files changed, 34 insertions(+), 30 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) = @_;
diff --git a/src/PVE/Systemd.pm b/src/PVE/Systemd.pm
index 6ff0dc8..aabb774 100644
--- a/src/PVE/Systemd.pm
+++ b/src/PVE/Systemd.pm
@@ -10,7 +10,8 @@ use Net::DBus::Reactor;
use POSIX qw(EINTR);
use Socket qw(SOCK_DGRAM);
-use PVE::Tools qw(file_set_contents file_get_contents trim);
+use PVE::Exception qw(raise_param_exc);
+use PVE::Tools qw(file_set_contents file_get_contents run_command trim);
sub escape_unit {
my ($val, $is_path) = @_;
@@ -285,6 +286,38 @@ sub write_ini {
file_set_contents($filename, $content);
}
+# Use systemds timedatectl for managing timezone settings
+sub get_timezone {
+ my $timezone;
+
+ PVE::Tools::run_command(
+ ['timedatectl', 'show', '--property=Timezone', '--value'],
+ outfunc => sub { $timezone //= shift },
+ );
+
+ return $timezone;
+}
+
+sub set_timezone {
+ my ($timezone) = @_;
+
+ raise_param_exc({ 'timezone' => "No such timezone" })
+ if (!grep { $_ eq $timezone } list_timezones());
+
+ PVE::Tools::run_command(['timedatectl', 'set-timezone', $timezone]);
+}
+
+sub list_timezones {
+ my @timezones = ();
+
+ PVE::Tools::run_command(
+ ['timedatectl', 'list-timezones'],
+ outfunc => sub { push(@timezones, shift); },
+ );
+
+ return @timezones;
+}
+
=head3 notify()
This is a pure Perl reimplementation of systemd's C<sd_notify()> mechanism as defined in
--
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] 5+ messages in thread