[PATCH pve-manager] tree-wide: change /var/run to /run and /var/lock to /run/lock

Jing Luo jing at jing.rocks
Sat Mar 22 16:17:08 CET 2025


"/var/run" and "/var/lock" are deprecated.

This is to comply with Debian Policy 9.1.4 "/run and /run/lock".
(https://www.debian.org/doc/debian-policy/ch-opersys.html#run-and-run-lock)

Signed-off-by: Jing Luo <jing at jing.rocks>
---
 PVE/API2/Nodes.pm             | 4 ++--
 PVE/API2/Replication.pm       | 2 +-
 PVE/CertHelpers.pm            | 2 +-
 PVE/Jobs.pm                   | 2 +-
 PVE/NodeConfig.pm             | 2 +-
 PVE/Service/pvedaemon.pm      | 2 +-
 PVE/Service/pveproxy.pm       | 4 ++--
 PVE/Service/spiceproxy.pm     | 4 ++--
 PVE/VZDump.pm                 | 6 +++---
 bin/pvedaemon                 | 2 +-
 bin/pveproxy                  | 2 +-
 bin/spiceproxy                | 2 +-
 services/pvescheduler.service | 2 +-
 13 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 9cdf19db..3708eb26 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -1978,7 +1978,7 @@ __PACKAGE__->register_method ({
 	    }
 
 	    eval { # remove backup locks, but avoid running into a scheduled backup job
-		PVE::Tools::lock_file('/var/run/vzdump.lock', 10, $remove_locks_on_startup, $nodename);
+		PVE::Tools::lock_file('/run/vzdump.lock', 10, $remove_locks_on_startup, $nodename);
 	    };
 	    warn $@ if $@;
 
@@ -2540,7 +2540,7 @@ __PACKAGE__->register_method ({
     code => sub {
 	my ($param) = @_;
 
-	PVE::Tools::lock_file('/var/lock/pve-etchosts.lck', undef, sub {
+	PVE::Tools::lock_file('/run/lock/pve-etchosts.lck', undef, sub {
 	    if ($param->{digest}) {
 		my $hosts = PVE::INotify::read_file('etchosts');
 		PVE::Tools::assert_if_modified($hosts->{digest}, $param->{digest});
diff --git a/PVE/API2/Replication.pm b/PVE/API2/Replication.pm
index e4a7180f..9d2aff5b 100644
--- a/PVE/API2/Replication.pm
+++ b/PVE/API2/Replication.pm
@@ -21,7 +21,7 @@ use PVE::RESTHandler;
 
 use base qw(PVE::RESTHandler);
 
-our $pvesr_lock_path = "/var/lock/pvesr.lck";
+our $pvesr_lock_path = "/run/lock/pvesr.lck";
 
 our $lookup_guest_class = sub {
     my ($vmtype) = @_;
diff --git a/PVE/CertHelpers.pm b/PVE/CertHelpers.pm
index 7e088cb9..38e8d9ca 100644
--- a/PVE/CertHelpers.pm
+++ b/PVE/CertHelpers.pm
@@ -30,7 +30,7 @@ PVE::JSONSchema::register_standard_option('pve-acme-directory-url', {
     pattern => '^https?://.*',
 });
 
-my $local_cert_lock = '/var/lock/pve-certs.lock';
+my $local_cert_lock = '/run/lock/pve-certs.lock';
 
 sub cert_path_prefix {
     my ($node) = @_;
diff --git a/PVE/Jobs.pm b/PVE/Jobs.pm
index bd323332..6f94eb0e 100644
--- a/PVE/Jobs.pm
+++ b/PVE/Jobs.pm
@@ -21,7 +21,7 @@ cfs_register_file(
 );
 
 my $state_dir = "/var/lib/pve-manager/jobs";
-my $lock_dir = "/var/lock/pve-manager";
+my $lock_dir = "/run/lock/pve-manager";
 
 my $get_state_file = sub {
     my ($jobid, $type) = @_;
diff --git a/PVE/NodeConfig.pm b/PVE/NodeConfig.pm
index 5f58dff5..4235ecea 100644
--- a/PVE/NodeConfig.pm
+++ b/PVE/NodeConfig.pm
@@ -13,7 +13,7 @@ use PVE::API2::ACMEPlugin;
 # register up to 5 domain names per node for now
 my $MAXDOMAINS = 5;
 
-my $node_config_lock = '/var/lock/pvenode.lock';
+my $node_config_lock = '/run/lock/pvenode.lock';
 
 PVE::JSONSchema::register_format('pve-acme-domain', sub {
     my ($domain, $noerr) = @_;
diff --git a/PVE/Service/pvedaemon.pm b/PVE/Service/pvedaemon.pm
index 486d264c..c77683be 100755
--- a/PVE/Service/pvedaemon.pm
+++ b/PVE/Service/pvedaemon.pm
@@ -26,7 +26,7 @@ my $daemon = __PACKAGE__->new('pvedaemon', $cmdline, %daemon_options);
 sub init {
     my ($self) = @_;
 
-    my $accept_lock_fn = "/var/lock/pvedaemon.lck";
+    my $accept_lock_fn = "/run/lock/pvedaemon.lck";
 
     my $lockfh = IO::File->new(">>${accept_lock_fn}") ||
 	die "unable to open lock file '${accept_lock_fn}' - $!\n";
diff --git a/PVE/Service/pveproxy.pm b/PVE/Service/pveproxy.pm
index df3601bd..bc05abe6 100755
--- a/PVE/Service/pveproxy.pm
+++ b/PVE/Service/pveproxy.pm
@@ -35,7 +35,7 @@ my %daemon_options = (
     leave_children_open_on_reload => 1,
     setuid => 'www-data',
     setgid => 'www-data',
-    pidfile => '/var/run/pveproxy/pveproxy.pid',
+    pidfile => '/run/pveproxy/pveproxy.pid',
 );
 
 my $daemon = __PACKAGE__->new('pveproxy', $cmdline, %daemon_options);
@@ -65,7 +65,7 @@ sub init {
     # we use same ALLOW/DENY/POLICY as pveproxy
     my $proxyconf = PVE::APIServer::Utils::read_proxy_config($self->{name});
 
-    my $accept_lock_fn = "/var/lock/pveproxy.lck";
+    my $accept_lock_fn = "/run/lock/pveproxy.lck";
 
     my $lockfh = IO::File->new(">>${accept_lock_fn}") ||
 	die "unable to open lock file '${accept_lock_fn}' - $!\n";
diff --git a/PVE/Service/spiceproxy.pm b/PVE/Service/spiceproxy.pm
index 50b81c18..d06467e3 100755
--- a/PVE/Service/spiceproxy.pm
+++ b/PVE/Service/spiceproxy.pm
@@ -23,7 +23,7 @@ my %daemon_options = (
     leave_children_open_on_reload => 1,
     setuid => 'www-data',
     setgid => 'www-data',
-    pidfile => '/var/run/pveproxy/spiceproxy.pid',
+    pidfile => '/run/pveproxy/spiceproxy.pid',
     );
 
 my $daemon = __PACKAGE__->new('spiceproxy', $cmdline, %daemon_options); 
@@ -34,7 +34,7 @@ sub init {
     # we use same ALLOW/DENY/POLICY as pveproxy
     my $proxyconf = PVE::APIServer::Utils::read_proxy_config('pveproxy');
 
-    my $accept_lock_fn = "/var/lock/spiceproxy.lck";
+    my $accept_lock_fn = "/run/lock/spiceproxy.lck";
 
     my $lockfh = IO::File->new(">>${accept_lock_fn}") ||
 	die "unable to open lock file '${accept_lock_fn}' - $!\n";
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index fd89945e..5178ce9d 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -40,8 +40,8 @@ PVE::JSONSchema::register_standard_option('pve-backup-jobid', {
 
 my @posix_filesystems = qw(ext3 ext4 nfs nfs4 reiserfs xfs);
 
-my $lockfile = '/var/run/vzdump.lock';
-my $pidfile = '/var/run/vzdump.pid';
+my $lockfile = '/run/vzdump.lock';
+my $pidfile = '/run/vzdump.pid';
 my $logdir = '/var/log/vzdump';
 
 my @plugins = qw();
@@ -661,7 +661,7 @@ sub new {
 	push @$findexcl,
 	    '/tmp/?*',
 	    '/var/tmp/?*',
-	    '/var/run/?*.pid',
+	    '/run/?*.pid',
 	    ;
     }
 
diff --git a/bin/pvedaemon b/bin/pvedaemon
index ffccb34f..54b28770 100755
--- a/bin/pvedaemon
+++ b/bin/pvedaemon
@@ -21,7 +21,7 @@ $SIG{'__WARN__'} = sub {
 
 my $prepare = sub {
     # create dir for dtach sockets
-    mkdir "/var/run/dtach";
+    mkdir "/run/dtach";
 };
 
 PVE::Service::pvedaemon->run_cli_handler(prepare => $prepare);
diff --git a/bin/pveproxy b/bin/pveproxy
index 20e8f2ab..4430c37e 100755
--- a/bin/pveproxy
+++ b/bin/pveproxy
@@ -20,7 +20,7 @@ $SIG{'__WARN__'} = sub {
 };
 
 my $prepare = sub {
-    my $rundir="/var/run/pveproxy";
+    my $rundir="/run/pveproxy";
     if (mkdir($rundir, 0700)) { # only works at first start if we are root)
 	my $gid = getgrnam('www-data') || die "getgrnam failed - $!\n";
 	my $uid = getpwnam('www-data') || die "getpwnam failed - $!\n";
diff --git a/bin/spiceproxy b/bin/spiceproxy
index 790c6dff..ea98a3f7 100755
--- a/bin/spiceproxy
+++ b/bin/spiceproxy
@@ -19,7 +19,7 @@ $SIG{'__WARN__'} = sub {
 };
 
 my $prepare  = sub {
-    my $rundir="/var/run/pveproxy";
+    my $rundir="/run/pveproxy";
     if (mkdir($rundir, 0700)) { # only works at first start if we are root)
 	my $gid = getgrnam('www-data') || die "getgrnam failed - $!\n";
 	my $uid = getpwnam('www-data') || die "getpwnam failed - $!\n";
diff --git a/services/pvescheduler.service b/services/pvescheduler.service
index 6d0d0985..8f410101 100644
--- a/services/pvescheduler.service
+++ b/services/pvescheduler.service
@@ -10,7 +10,7 @@ After=pve-storage.target
 ExecStart=/usr/bin/pvescheduler start
 ExecStop=/usr/bin/pvescheduler stop
 ExecReload=/usr/bin/pvescheduler restart
-PIDFile=/var/run/pvescheduler.pid
+PIDFile=/run/pvescheduler.pid
 KillMode=process
 Type=forking
 
-- 
2.49.0





More information about the pve-devel mailing list