Skip to content

Commit

Permalink
Fix variable substitution in systemd units
Browse files Browse the repository at this point in the history
Before this change, Autoconf was used to subsitute variables, including
@sysconfdir@, in systemd unit files. This is not how Autoconf should be
used and had an unintended negative consequence: the @sysconfdir@
variable was not fully expanded, so literal `${prefix}/etc` was ending up
in the pcscd.service file, where it was invalid.

Use sed to perform the subsitution from within the makefile where the
variables get expanded fully. This seems to be the standard approach
recommended by Autoconf documentation and used in various projects.

Also, remove the `SCRIPT_IN_FILES` variable from the makefile, which was
not used and seems to be a copy-paste from some other project.
  • Loading branch information
kirelagin authored and LudovicRousseau committed Dec 4, 2021
1 parent e1b1590 commit 88ec131
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 0 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,6 @@ doc/pcscd.8
doc/reader.conf.5
doc/example/Makefile
etc/Makefile
etc/pcscd.service
etc/pcscd.socket
src/Makefile
src/libpcsclite.pc
src/pcscd.h
Expand Down
12 changes: 8 additions & 4 deletions etc/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
if HAVE_SYSTEMD
SCRIPT_IN_FILES = \
pcscd.service.in \
pcscd.socket.in

systemdsystemunit_DATA = \
pcscd.service \
pcscd.socket

edit = sed \
-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
-e 's|@sbindir_exp[@]|$(sbindir_exp)|g' \
-e 's|@ipcdir[@]|$(ipcdir)|g'

$(systemdsystemunit_DATA): % : %.in
$(edit) $< >$@
endif

0 comments on commit 88ec131

Please sign in to comment.