tmpfiles: allow to set file capabilities / binary values in xattr
I wanted to set file capabilities using systemd-tmpfiles, however security.capability extended attribute is a bitset and can't be represented using the current tmpfiles.d syntax because it allows only characters, not arbitrary bytes.
setfattr accepts the base64-encoded values for extended attributes using 0s prefix. I think it could be a good idea to support the same syntax.
Upd: I tried to set capabilities using C escapes
t /usr/lib/maddy/maddy-*-helper - - - - security.capability="\x01\x00\x00\x02\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
but it doesn't seem to work:
⟩ sudo systemd-tmpfiles --create /usr/lib/tmpfiles.d/maddy.conf
Failed to parse extended attribute 'x00\x00\x02\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"', ignoring: Invalid argument
Assertion 'i->xattrs' failed at ../systemd-stable/src/tmpfiles/tmpfiles.c:2422, function specifier_expansion_from_arg(). Aborting.
fish: “sudo systemd-tmpfiles --create…” terminated by signal SIGABRT (Abort)
I'm using systemd 242.19-1 from Arch Linux repos.
(it might also make sense to add an explicit concept for setting fcaps to tmpfiles.d/)
We nowadays support a "~" modifier to deoce the 6th colum as base64. But we do not support it for setting xattrs so far. Would be trivial to add now, though.