shared/specifier: provide proper error messages when specifiers fail to read files
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Mar 2022 11:08:00 +0000 (12:08 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 29 Mar 2022 14:17:56 +0000 (16:17 +0200)
commit6ec4c852c910b1aca649e87ba3143841334f01fa
tree36d36b1728a4a8e2dbf1567eba0c00c0cbf1a8d5
parent7962116fc8a2572c5c89904ac50fe99c8101f28f
shared/specifier: provide proper error messages when specifiers fail to read files

ENOENT is easily confused with the file that we're working on not being
present, e.g. when the file contains %o or something else that requires
os-release to be present. Let's use -EUNATCH instead to reduce that chances of
confusion if the context of the error is lost.

And once we have pinpointed the reason, let's provide a proper error message:

+ build/systemctl --root=/tmp/systemctl-test.TO7Mcb enable some-some-link6@.socket
/tmp/systemctl-test.TO7Mcb/etc/systemd/system/some-some-link6@.socket: Failed to resolve alias "target@A:%A.socket": Protocol driver not attached
Failed to enable unit, cannot resolve specifiers in "target@A:%A.socket".
src/shared/install.c
src/shared/specifier.c
src/test/test-specifier.c
test/test-systemctl-enable.sh