public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager v2] pveproxy: create log directory when starting
@ 2025-04-16  9:18 Maximiliano Sandoval
  0 siblings, 0 replies; only message in thread
From: Maximiliano Sandoval @ 2025-04-16  9:18 UTC (permalink / raw)
  To: pve-devel

We only create this directory while installing or upgrading the package.

If a user deletes /var/log then they will lose access to the web UI
until they either reinstall or upgrade pve-manager.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---

Differences from v1:

- Unconditionally call mkdir+chown if root
- Improve commit message to reflect this can be fixed by a reinstall

 bin/pveproxy | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/bin/pveproxy b/bin/pveproxy
index 20e8f2ab2..914a7c838 100755
--- a/bin/pveproxy
+++ b/bin/pveproxy
@@ -21,10 +21,18 @@ $SIG{'__WARN__'} = sub {
 
 my $prepare = sub {
     my $rundir="/var/run/pveproxy";
-    if (mkdir($rundir, 0700)) { # only works at first start if we are root)
+    my $logdir = '/var/log/pveproxy';
+
+    my $uid = $<;
+    if ($uid == 0) {
 	my $gid = getgrnam('www-data') || die "getgrnam failed - $!\n";
 	my $uid = getpwnam('www-data') || die "getpwnam failed - $!\n";
-	chown($uid, $gid, $rundir);
+
+	mkdir($rundir, 0700);
+	chown($uid, $gid, $rundir) || warn "chown $rundir failed";
+
+	mkdir($logdir, 0700);
+	chown($uid, $gid, $logdir) || warn "chown $logdir failed";
     }
 };
 
-- 
2.39.5



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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-04-16  9:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-16  9:18 [pve-devel] [PATCH manager v2] pveproxy: create log directory when starting Maximiliano Sandoval

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