`/run/sr-mount` parent directory created 0700 on some hosts, 0755 on others
-
I'm trying to work out why the mode on
/run/sr-mountitself (the parent, not the per-SR subdirectories) is inconsistent across hosts in our estate.We monitor SR capacity with Zabbix, which runs as an unprivileged user. Where the parent is 0700 the agent can't traverse it, so the SR checks fail with:
Cannot obtain filesystem information: [13] Permission deniedTwo hosts, both on the same XCP-ng version (8.3 LTS). The first works, the second does not.
Host A, working:
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)Host B, broken:
Access: (0700/drwx------) Uid: ( 0/ root) Gid: ( 0/ root)Nobody has changed it by hand, and
/runis tmpfs, so the directory gets recreated on every boot.FileSR.pycreates each SR's own mount directory at 0700, which looks like the source of it:grep -n "makedirs\|mkdir\|chmod\|0o7\|0700\|0755" /opt/xensource/sm/FileSR.py 127: util.ioretry(lambda: os.mkdir(self.remotepath)) 178: util.ioretry(lambda: util.makedirs(self.path, mode=0o700)) 188: os.chmod(self.path, mode=0o0700)self.pathis/run/sr-mount/<sr-uuid>, so 0700 on the SR's own directory is intentional. Bututil.makedirsis recursive and defaults tomode=0o777:grep -n "def makedirs\|chmod" /opt/xensource/sm/util.py 623:def makedirs(name, mode=0o777): 636: os.chmod(name, mode)My reading: if a local EXT SR attaches before
/run/sr-mountexists,makedirs(self.path, mode=0o700)creates the parent in the same call and the parent inherits 0700. On hosts where something else creates the parent first at the default mode, whatever attaches later finds it already there and leaves it alone.What we have tried, none of it ideal. A plain
chmod 755 /run/sr-mountworks but doesn't survive a reboot. AnExecStartPostdrop-in onxs-sm.servicepersists but can lose the race if an SR attaches after the service reports started. We're now testing a systemd.pathunit watching/run/sr-mountthat re-applies 0755 whenever it changes, which sidesteps the ordering question, but it's a workaround rather than a fix and won't survive a major version upgrade.I'm sure someone else must have come across this issue so I'm hoping there's a better fix.
Sudo doesn't help.
vfs.fs.sizestats the path in-process, anddfwith no path argument still stats each filesystem, so the SR rows drop with no error for a non-root user.Questions:
- Is 0755 the intended mode for the parent
/run/sr-mount, with the 0700 an unintended side effect of the recursivemakedirs? Or is 0700 on the parent deliberate too, making the 0755 hosts the anomaly? - Does anything create the parent or set its mode explicitly, or does it only ever appear as a by-product of the first SR attach?
- Has anyone else hit this while monitoring SR capacity with a non-root agent, and how did you handle it?
Is there a supported way to have the parent set at 0755 consistently, or should this be raised as a bug against
sm? - Is 0755 the intended mode for the parent
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login