[pdm-devel] [PATCH 1/2] privileged api server: properly handle socket on reload
Fabian Grünbichler
f.gruenbichler at proxmox.com
Mon Dec 23 14:08:51 CET 2024
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 at 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
More information about the pdm-devel
mailing list