public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager/common 0/1] Fix #7175: switch API to timedatectl
@ 2025-12-25  8:05 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 ` [pve-devel] [PATCH manager 1/1] Fix #7175: use timedatectl for timezone handling Stefan Mayr
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Mayr @ 2025-12-25  8:05 UTC (permalink / raw)
  To: pve-devel

Using /etc/timezone is deprecated by the Debian tzdata package. The
Proxmox installer does not use it anymore. This switches the API to use
timedatectl as recommended by the tzdata maintainers.

pve-manager:

Stefan Mayr (1):
  Fix #7175: use timedatectl for timezone handling

 PVE/API2/Nodes.pm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

pve-common:

Stefan Mayr (1):
  Fix #7175: remove deprecated timezone file

 src/PVE/INotify.pm | 29 -----------------------------
 1 file changed, 29 deletions(-)

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

* [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-29 12:03   ` Maximiliano Sandoval
  2025-12-25  8:05 ` [pve-devel] [PATCH manager 1/1] Fix #7175: use timedatectl for timezone handling Stefan Mayr
  1 sibling, 1 reply; 6+ 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] 6+ 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
  2026-01-15 10:25   ` Fabian Grünbichler
  1 sibling, 1 reply; 6+ 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] 6+ messages in thread

* Re: [pve-devel] [PATCH common 1/1] Fix #7175: remove deprecated timezone file
  2025-12-25  8:05 ` [pve-devel] [PATCH common 1/1] Fix #7175: remove deprecated timezone file Stefan Mayr
@ 2025-12-29 12:03   ` Maximiliano Sandoval
  2026-01-15 10:26     ` Fabian Grünbichler
  0 siblings, 1 reply; 6+ messages in thread
From: Maximiliano Sandoval @ 2025-12-29 12:03 UTC (permalink / raw)
  To: Stefan Mayr; +Cc: pve-devel

Stefan Mayr <stefan@mayr-stefan.de> writes:

Thanks for submitting a patch.

A comment below.

> 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);
>

At least pmg-api and pve-container use this. I would recommend to only
add a comment here instead of removing the helper since this is a shared
library. Alternatively, one could port all existing users to, e.g.
timedatectl.

> -
>  sub read_active_workers {
>      my ($filename, $fh) = @_;

-- 
Maximiliano


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

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

* Re: [pve-devel] [PATCH manager 1/1] Fix #7175: use timedatectl for timezone handling
  2025-12-25  8:05 ` [pve-devel] [PATCH manager 1/1] Fix #7175: use timedatectl for timezone handling Stefan Mayr
@ 2026-01-15 10:25   ` Fabian Grünbichler
  0 siblings, 0 replies; 6+ messages in thread
From: Fabian Grünbichler @ 2026-01-15 10:25 UTC (permalink / raw)
  To: pve-devel, Stefan Mayr

On December 25, 2025 9:05 am, Stefan Mayr wrote:
> 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}]);

should we restrict this parameter? AFAICT, only [a-zA-Z][a-zA-Z/_\-]*
are currently valid in timezone values?

alternatively we could query the valid names first (list-timezones) and
then check that the passed value is contained in that set..

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

* Re: [pve-devel] [PATCH common 1/1] Fix #7175: remove deprecated timezone file
  2025-12-29 12:03   ` Maximiliano Sandoval
@ 2026-01-15 10:26     ` Fabian Grünbichler
  0 siblings, 0 replies; 6+ messages in thread
From: Fabian Grünbichler @ 2026-01-15 10:26 UTC (permalink / raw)
  To: Proxmox VE development discussion, Stefan Mayr

On December 29, 2025 1:03 pm, Maximiliano Sandoval wrote:
> Stefan Mayr <stefan@mayr-stefan.de> writes:
> 
> Thanks for submitting a patch.
> 
> A comment below.
> 
>> 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);
>>
> 
> At least pmg-api and pve-container use this. I would recommend to only
> add a comment here instead of removing the helper since this is a shared
> library. Alternatively, one could port all existing users to, e.g.
> timedatectl.

porting all callers and then dropping it would probably make the most
sense, or we could introduce new helpers in pve-common that are usable
for all existing callers..

> 
>> -
>>  sub read_active_workers {
>>      my ($filename, $fh) = @_;
> 
> -- 
> Maximiliano
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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-29 12:03   ` Maximiliano Sandoval
2026-01-15 10:26     ` Fabian Grünbichler
2025-12-25  8:05 ` [pve-devel] [PATCH manager 1/1] Fix #7175: use timedatectl for timezone handling Stefan Mayr
2026-01-15 10:25   ` Fabian Grünbichler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal