* [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
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ 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] 8+ 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
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ 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] 8+ 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
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ 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] 8+ 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
2026-02-18 19:53 ` [pve-devel] [PATCH common, container, manager and pmg-api v2 0/4] " Stefan Mayr
2026-02-20 11:48 ` Stoiko Ivanov
5 siblings, 0 replies; 8+ 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] 8+ messages in thread* Re: [pve-devel] [PATCH common, container, manager and pmg-api v2 0/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
` (3 preceding siblings ...)
2026-01-25 21:01 ` [pve-devel] [PATCH common v2 4/4] " Stefan Mayr
@ 2026-02-18 19:53 ` Stefan Mayr
2026-02-19 8:13 ` Fabian Grünbichler
2026-02-20 11:48 ` Stoiko Ivanov
5 siblings, 1 reply; 8+ messages in thread
From: Stefan Mayr @ 2026-02-18 19:53 UTC (permalink / raw)
To: pve-devel
Am 25.01.2026 um 22:01 schrieb Stefan Mayr:
> Second try to fix #7175. These patches remove direct /etc/timezone
> handling, add timezone functions to the Systemd module and replaces all
> uses of the functions you pointed me to.
>
> This time it is with a verification of valid timezones.
>
> It does not address hardcoded timezones in the javascript for the UI or
> the rust code handling timezones.
>
> Trying to provide patches to Proxmox is the first time I have to use
> an email based patch workflow. I'm pretty sure sending these patches for
> four different repos the way I do it currently is not 100% how it is
> intended to be done. So please forgive me.
>
> 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>
Any feedback on my suggestions to fix the timezone handling?
Thank you,
Stefan Mayr
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [pve-devel] [PATCH common, container, manager and pmg-api v2 0/4] Fix #7175: replace timezone handling with systemd timedatectl
2026-02-18 19:53 ` [pve-devel] [PATCH common, container, manager and pmg-api v2 0/4] " Stefan Mayr
@ 2026-02-19 8:13 ` Fabian Grünbichler
0 siblings, 0 replies; 8+ messages in thread
From: Fabian Grünbichler @ 2026-02-19 8:13 UTC (permalink / raw)
To: pve-devel, Stefan Mayr
On February 18, 2026 8:53 pm, Stefan Mayr wrote:
> Am 25.01.2026 um 22:01 schrieb Stefan Mayr:
>> Second try to fix #7175. These patches remove direct /etc/timezone
>> handling, add timezone functions to the Systemd module and replaces all
>> uses of the functions you pointed me to.
>>
>> This time it is with a verification of valid timezones.
>>
>> It does not address hardcoded timezones in the javascript for the UI or
>> the rust code handling timezones.
>>
>> Trying to provide patches to Proxmox is the first time I have to use
>> an email based patch workflow. I'm pretty sure sending these patches for
>> four different repos the way I do it currently is not 100% how it is
>> intended to be done. So please forgive me.
>>
>> 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>
>
> Any feedback on my suggestions to fix the timezone handling?
Sorry, I haven't gotten around yet to doing another pass over it, I'll
try to fit it in this week or start of the next one!
Fabian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [pve-devel] [PATCH common, container, manager and pmg-api v2 0/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
` (4 preceding siblings ...)
2026-02-18 19:53 ` [pve-devel] [PATCH common, container, manager and pmg-api v2 0/4] " Stefan Mayr
@ 2026-02-20 11:48 ` Stoiko Ivanov
5 siblings, 0 replies; 8+ messages in thread
From: Stoiko Ivanov @ 2026-02-20 11:48 UTC (permalink / raw)
To: Stefan Mayr; +Cc: Proxmox VE development discussion
Thanks for the patches, and your continued effort!
Changes look good to me in principle.
Gave the series a test-run on a PVE 9 and a PMG 9 - it works as advertised.
comments inline:
On Sun, 25 Jan 2026 22:01:47 +0100
Stefan Mayr <stefan@mayr-stefan.de> wrote:
> Second try to fix #7175. These patches remove direct /etc/timezone
> handling, add timezone functions to the Systemd module and replaces all
> uses of the functions you pointed me to.
>
> This time it is with a verification of valid timezones.
>
> It does not address hardcoded timezones in the javascript for the UI or
> the rust code handling timezones.
Replacing the hardcoded list in our frontend-code with a call to an
API-method, which wraps your PVE::Systemd::list_timezones seems like a good
further improvement.
Regarding the rust side of our code and products - from a quick check
those do fall-back to `/etc/localtime` if `/etc/timezone` is not available:
PDM:
https://git.proxmox.com/?p=proxmox-datacenter-manager.git;a=blob;f=server/src/api/nodes/time.rs;h=7f711c95ecd0b810fda360212d1c38a77093c920;hb=d5bfa9b8fa429cfed57dc9a1528e7662ff4c787f
uses proxmox-time-api:
https://git.proxmox.com/?p=proxmox.git;a=blob;f=proxmox-time-api/src/time_impl.rs;h=383bae1168eaab2d503c8da609c532d0974bc0b9;hb=HEAD
(although writing /etc/timezone could also be done only conditionally (on
its existence), and dropped with the next debian-release[0].)
PBS has its own implementation:
https://git.proxmox.com/?p=proxmox-backup.git;a=blob;f=src/api2/node/time.rs;h=d7ca10e31a14332b384518a03b270a7706b1538e;hb=HEAD
(which looks equal to the one in proxmox-time api and could also be
replaced by that from a quick look).
But none of the suggested future improvements are needed for this - so they
can be done independently (by you, if you're interested, else someone here
can take that part).
Splitting the pve-common patch - one introducing the new helpers (and
adding a comment that the ones in PVE::INotify are deprecated), and a
second one actually dropping the old ones, would make this easier to
roll-out (no need to roll out all call-sites (pve-container, pve-manager,
pmg-api) at the same time, to each of our repositories).
apart from the splitting of the patch for pve-common, consider this:
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
>
> Trying to provide patches to Proxmox is the first time I have to use
> an email based patch workflow. I'm pretty sure sending these patches for
> four different repos the way I do it currently is not 100% how it is
> intended to be done. So please forgive me.
>
> 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>
[0] forky will remove /etc/timezone unconditionally, while /etc/localtime
remains:
https://metadata.ftp-master.debian.org/changelogs//main/t/tzdata/tzdata_2025c-3_changelog
^ permalink raw reply [flat|nested] 8+ messages in thread