all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [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 Stefan Mayr
  2026-01-25 21:01 ` [pve-devel] [PATCH manager v2 1/4] " Stefan Mayr
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Stefan Mayr @ 2026-01-25 21:01 UTC (permalink / raw)
  To: pve-devel

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>
-- 
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] 12+ messages in thread

* [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; 12+ 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] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ 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; 12+ 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] 12+ 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
  2026-02-22 11:02   ` [PATCH common v3 0/2] " Stefan Mayr
                     ` (2 more replies)
  5 siblings, 3 replies; 12+ 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] 12+ messages in thread

* [PATCH common v3 0/2] Fix #7175: replace timezone handling with systemd timedatectl
  2026-02-20 11:48 ` Stoiko Ivanov
@ 2026-02-22 11:02   ` Stefan Mayr
  2026-02-23 10:02     ` Stoiko Ivanov
  2026-02-22 11:02   ` [PATCH common v3 1/2] " Stefan Mayr
  2026-02-22 11:02   ` [PATCH common v3 2/2] " Stefan Mayr
  2 siblings, 1 reply; 12+ messages in thread
From: Stefan Mayr @ 2026-02-22 11:02 UTC (permalink / raw)
  To: pve-devel

This splits the patch to pve-common into two parts:
1. adds functions for systemd timedatectl
2. removes handling deprecated /etc/timezone from INotify module




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH common v3 1/2] Fix #7175: replace timezone handling with systemd timedatectl
  2026-02-20 11:48 ` Stoiko Ivanov
  2026-02-22 11:02   ` [PATCH common v3 0/2] " Stefan Mayr
@ 2026-02-22 11:02   ` Stefan Mayr
  2026-02-22 11:02   ` [PATCH common v3 2/2] " Stefan Mayr
  2 siblings, 0 replies; 12+ messages in thread
From: Stefan Mayr @ 2026-02-22 11:02 UTC (permalink / raw)
  To: pve-devel

Usage of /etc/timezone is deprecated. The tzdata maintainers recommend
switching to timedatectl.

This adds timezone handling to the Systemd module and marks the
functions in the INotify module as deprecated.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Suggested-by: Maximiliano Sandroval <m.sandoval@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Stefan Mayr <stefan@mayr-stefan.de>
---
 src/PVE/INotify.pm |  2 ++
 src/PVE/Systemd.pm | 35 ++++++++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index 62b3ca8..fdec8f1 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -651,6 +651,7 @@ register_file(
     \&update_etc_resolv_conf,
 );
 
+# Deprecated: use PVE::Systemd::get_timezone() instead
 sub read_etc_timezone {
     my ($filename, $fd) = @_;
 
@@ -661,6 +662,7 @@ sub read_etc_timezone {
     return $timezone;
 }
 
+# Deprecated: use PVE::Systemd::set_timezone($timezone) instead
 sub write_etc_timezone {
     my ($filename, $fh, $timezone) = @_;
 
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




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH common v3 2/2] Fix #7175: replace timezone handling with systemd timedatectl
  2026-02-20 11:48 ` Stoiko Ivanov
  2026-02-22 11:02   ` [PATCH common v3 0/2] " Stefan Mayr
  2026-02-22 11:02   ` [PATCH common v3 1/2] " Stefan Mayr
@ 2026-02-22 11:02   ` Stefan Mayr
  2 siblings, 0 replies; 12+ messages in thread
From: Stefan Mayr @ 2026-02-22 11:02 UTC (permalink / raw)
  To: pve-devel

Usage of /etc/timezone is deprecated. The tzdata maintainers recommend
switching to timedatectl.

This removes the deprecated handling of /etc/timezone from the INotify
module.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Suggested-by: Maximiliano Sandroval <m.sandoval@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Stefan Mayr <stefan@mayr-stefan.de>
---
 src/PVE/INotify.pm | 31 -------------------------------
 1 file changed, 31 deletions(-)

diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index fdec8f1..03c871c 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -651,37 +651,6 @@ register_file(
     \&update_etc_resolv_conf,
 );
 
-# Deprecated: use PVE::Systemd::get_timezone() instead
-sub read_etc_timezone {
-    my ($filename, $fd) = @_;
-
-    my $timezone = <$fd>;
-
-    chomp $timezone;
-
-    return $timezone;
-}
-
-# Deprecated: use PVE::Systemd::set_timezone($timezone) instead
-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




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH common v3 0/2] Fix #7175: replace timezone handling with systemd timedatectl
  2026-02-22 11:02   ` [PATCH common v3 0/2] " Stefan Mayr
@ 2026-02-23 10:02     ` Stoiko Ivanov
  0 siblings, 0 replies; 12+ messages in thread
From: Stoiko Ivanov @ 2026-02-23 10:02 UTC (permalink / raw)
  To: Stefan Mayr; +Cc: pve-devel

Thanks for the quick iteration on this!

For reference:
These 2 patches replace PATCH 4/4 from:
https://lore.proxmox.com/pve-devel/20260125210151.1151-5-stefan@mayr-stefan.de/

The idea being that patch 1/2 is applied first - then the patches for
pve-container, pve-manager, pmg-api, with a versioned dependency bump on
libpve-common-perl. Once this is rolled PATCH 2/2 from this series can be
applied as well (breaking pve-container, pve-manager, pmg-api not
containing the patches from the v2).

3 tiny nits, which are mostly for any future patches - the complete series
is fine as is IMO.

nit: I'd use different first line for the commit message of each patch
e.g.:
1/2: fix #7175: add timezonectl helpers to PVE::Systemd
2/2: fix #7175: drop deprecated /etc/timezone file helpers
this can be fixed up on applying.

nit: sending the complete series again (even if patches for the
other repositories did not change at all) helps in having all needed
things in one thread - the duplicate mails are less of a problem.

nit: it seems you set my e-mail as reply-to header for this series (this
should not be an issue, as most people hit "Reply All" in their
mail-clients anyway, but could cause some confusion) - maybe you wanted to
add me in CC (`--cc s.ivanov@proxmox.com` for git send-email)?

As the 2 patches together here amount to the same result as the patch for
pve-common in the v2 - my:
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>

still applies (and I quickly checked applying only patch 1/2 on a test-vm
of mine)

Thanks again for your work on this and making the effort to address the
feedback - much appreciated!
stoiko

On Sun, 22 Feb 2026 12:02:03 +0100
Stefan Mayr <stefan@mayr-stefan.de> wrote:

> This splits the patch to pve-common into two parts:
> 1. adds functions for systemd timedatectl
> 2. removes handling deprecated /etc/timezone from INotify module
> 
> 
> 
> 





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-02-23 10:01 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [pve-devel] [PATCH pmg-api v2 3/4] " Stefan Mayr
2026-01-25 21:01 ` [pve-devel] [PATCH common v2 4/4] " Stefan Mayr
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
2026-02-20 11:48 ` Stoiko Ivanov
2026-02-22 11:02   ` [PATCH common v3 0/2] " Stefan Mayr
2026-02-23 10:02     ` Stoiko Ivanov
2026-02-22 11:02   ` [PATCH common v3 1/2] " Stefan Mayr
2026-02-22 11:02   ` [PATCH common v3 2/2] " Stefan Mayr

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal