all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH 1/2] privileged api server: properly handle socket on reload
Date: Mon, 23 Dec 2024 14:08:51 +0100	[thread overview]
Message-ID: <20241223130852.388217-2-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20241223130852.388217-1-f.gruenbichler@proxmox.com>

the permission/ownership change fails during reload because the socket doesn't
exist on-disk anymore, it is only passed along as previously opened FD in that
case..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
as the referenced comment indicates, this should probably all move to the rest
server itself.. this is rather a stop-gap measure.

 .../bin/proxmox-datacenter-privileged-api.rs  | 48 ++++++++++---------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/server/src/bin/proxmox-datacenter-privileged-api.rs b/server/src/bin/proxmox-datacenter-privileged-api.rs
index d4e8817..2276a78 100644
--- a/server/src/bin/proxmox-datacenter-privileged-api.rs
+++ b/server/src/bin/proxmox-datacenter-privileged-api.rs
@@ -147,28 +147,32 @@ async fn run() -> Result<(), Error> {
             .expect("bad api socket path"),
         move |listener: tokio::net::UnixListener| {
             let sockpath = pdm_buildcfg::PDM_PRIVILEGED_API_SOCKET_FN;
-
-            // NOTE: NoFollowSymlink is apparently not implemented in fchmodat()...
-            fchmodat(
-                Some(libc::AT_FDCWD),
-                sockpath,
-                Mode::from_bits_truncate(0o660),
-                FchmodatFlags::FollowSymlink,
-            )
-            .map_err(|err| {
-                format_err!("unable to set mode for api socket '{sockpath:?}' - {err}")
-            })?;
-
-            fchownat(
-                None,
-                sockpath,
-                None,
-                Some(api_user.gid),
-                FchownatFlags::FollowSymlink,
-            )
-            .map_err(|err| {
-                format_err!("unable to set ownership for api socket '{sockpath}' - {err}")
-            })?;
+            // FIXME: needs to be adapted if socket is no longer removed above
+            // the socket only exists on the first start/restart, it's passed along as open FD for
+            // reloads..
+            if Path::new(sockpath).exists() {
+                // NOTE: NoFollowSymlink is apparently not implemented in fchmodat()...
+                fchmodat(
+                    Some(libc::AT_FDCWD),
+                    sockpath,
+                    Mode::from_bits_truncate(0o660),
+                    FchmodatFlags::FollowSymlink,
+                )
+                .map_err(|err| {
+                    format_err!("unable to set mode for api socket '{sockpath:?}' - {err}")
+                })?;
+
+                fchownat(
+                    None,
+                    sockpath,
+                    None,
+                    Some(api_user.gid),
+                    FchownatFlags::FollowSymlink,
+                )
+                .map_err(|err| {
+                    format_err!("unable to set ownership for api socket '{sockpath}' - {err}")
+                })?;
+            }
 
             let incoming = UnixAcceptor::from(listener);
 
-- 
2.39.5



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

  reply	other threads:[~2024-12-23 13:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-23 13:08 [pdm-devel] [PATCH 0/2] fix reload behaviour Fabian Grünbichler
2024-12-23 13:08 ` Fabian Grünbichler [this message]
2024-12-23 16:16   ` [pdm-devel] [PATCH 1/2] privileged api server: properly handle socket on reload Thomas Lamprecht
2024-12-30 15:00     ` Thomas Lamprecht
2024-12-23 13:08 ` [pdm-devel] [PATCH 2/2] build: properly reload services after upgrade Fabian Grünbichler
2024-12-23 15:39 ` [pdm-devel] applied: [PATCH 0/2] fix reload behaviour Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241223130852.388217-2-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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