Skip to contentSkip to conversation

dtprobed: don't chown systemd service files to root during install

PATCH In review Nick Alcock 1 participant 2 messages Nov 11, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dtprobed: don't chown systemd service files to root during install

I put this in while thinking vaguely that "systemd requires these to be root-owned, we're not using install(1) so we should fix that". If redirecting, the ownership will be the ownership of the running process unless the file already exists (and the thing to do there is to rm -f it first, not to chown it afterwards): and if we're not root, chowning isn't going to work anyway (and will abort the install).

So take the chown out and replace it with an rm -f in the right place.

---
 dtprobed/Build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
dtprobed/Build +1 -1
index c43b62778381..a242afab94fc 100644
@@ -41,8 +41,8 @@ install-dtprobed-autostart::
 ifneq ($(WITH_SYSTEMD),)
 	mkdir -p $(INSTSYSTEMDUNITDIR) $(INSTSYSTEMDPRESETDIR)
 	$(call describe-install-target,$(INSTSYSTEMDUNITDIR),dtprobed.service)
+	rm -f $(INSTSYSTEMDUNITDIR)/dtprobed.service
 	sed 's,@SBINDIR@,$(SBINDIR),' < $(dtprobed_DIR)dtprobed.service.in > $(INSTSYSTEMDUNITDIR)/dtprobed.service
-        chown root:root $(INSTSYSTEMDUNITDIR)/dtprobed.service
 	chmod 0644 $(INSTSYSTEMDUNITDIR)/dtprobed.service
 	$(call describe-install-target,$(INSTSYSTEMDUNITDIR),dtrace-usdt.target)
 	install -m 644 $(dtprobed_DIR)dtrace-usdt.target $(INSTSYSTEMDUNITDIR)

base-commit: ba6e6542c44f22b3707949e859b13209bebefae2

Signature · 1 line
2.46.0.278.g36e3a12567
#1 lore raw
Quoted 9 lines · Nick Alcock

I put this in while thinking vaguely that "systemd requires these to be root-owned, we're not using install(1) so we should fix that". If redirecting, the ownership will be the ownership of the running process unless the file already exists (and the thing to do there is to rm -f it first, not to chown it afterwards): and if we're not root, chowning isn't going to work anyway (and will abort the install).

So take the chown out and replace it with an rm -f in the right place.

Patch withdrawn: Kris's patch is better.