Skip to contentSkip to conversation

xfs_scrub: don't set WorkingDirectory= in systemd job

PATCH In review Darrick J. Wong 2 participants 2 messages Apr 14, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_scrub: don't set WorkingDirectory= in systemd job

From: Darrick J. Wong <[email protected]>

Somewhere between systemd 237 and 245, they changed the order in which a job has its uid/gid set; capabilities applied; and working directory set. Whereas before they did it in an order such that you could set the working directory to a path inaccessible to 'nobody' (either because they did it before changing the uid or after adding capabilities), now they don't and users instead get a service failure:

[email protected]: Changing to the requested working directory failed: Permission denied [email protected]: Failed at step CHDIR spawning /usr/sbin/xfs_scrub: Permission denied [email protected]: Main process exited, code=exited, status=200/CHDIR

Regardless, xfs_scrub works just fine with PWD set to /, so remove that directive.

---
 scrub/[email protected] |    1 -
 1 file changed, 1 deletion(-)
scrub/[email protected] +0 -1
index 56acea67..6fb3f6ea 100644
@@ -5,7 +5,6 @@ Documentation=man:xfs_scrub(8)
 
 [Service]
 Type=oneshot
-WorkingDirectory=%I
 PrivateNetwork=true
 ProtectSystem=full
 ProtectHome=read-only
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Somewhere between systemd 237 and 245, they changed the order in which a job has its uid/gid set; capabilities applied; and working directory set. Whereas before they did it in an order such that you could set the working directory to a path inaccessible to 'nobody' (either because they did it before changing the uid or after adding capabilities), now they don't and users instead get a service failure:

Quoted 8 lines

[email protected]: Changing to the requested working directory failed: Permission denied [email protected]: Failed at step CHDIR spawning /usr/sbin/xfs_scrub: Permission denied [email protected]: Main process exited, code=exited, status=200/CHDIR

Regardless, xfs_scrub works just fine with PWD set to /, so remove that directive.

systemd is a black box to me but given this change is self contained and scrub is "experimental" let's go for it? ;) I'll pull this in.

Quoted 17 lines
---
 scrub/[email protected] |    1 -
 1 file changed, 1 deletion(-)
scrub/[email protected] +0 -1
index 56acea67..6fb3f6ea 100644
@@ -5,7 +5,6 @@ Documentation=man:xfs_scrub(8)
 
 [Service]
 Type=oneshot
-WorkingDirectory=%I
 PrivateNetwork=true
 ProtectSystem=full
 ProtectHome=read-only