Bug 758427

Summary: systemd unit templates don't resolve %-specifiers properly
Product: [openSUSE] openSUSE 12.1 Reporter: Forgotten User 7XRNh5WElB <forgotten_7XRNh5WElB>
Component: BasesystemAssignee: Frederic Crozat <fcrozat>
Status: RESOLVED INVALID QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None    
Version: Final   
Target Milestone: ---   
Hardware: All   
OS: openSUSE 12.1   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Forgotten User 7XRNh5WElB 2012-04-21 23:09:14 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0

In a systemd unit template file (a file like /etc/systemd/system/blah@.service) at least the fields "ConditionPathExists" and "Requires" have trouble handling %I.

Reproducible: Always

Steps to Reproduce:
Here are two service files which I created in order to autostart an iaxmodem whenever a corresponding faxgetty gets started:

================= iaxmodem@.service ================
[Unit]
Description = IAXmodem for /dev/%I
ConditionPathExists = /etc/iaxmodem/%I
Requires = asterisk.service
After = asterisk.service

[Service]
Type = simple
ExecStart = /usr/sbin/iaxmodem %I
====================================================

============= faxgetty4ttyiax@.service =============
[Unit]
Description = HylaFAX faxgetty at /dev/%I
ConditionPathExists = /var/spool/fax/etc/config.%I
ConditionPathExists = /etc/iaxmodem/%I
Requires = iaxmodem@%I.service

[Service]
Type = simple
Restart = on-success
ExecStart = /usr/lib/fax/faxgetty /dev/%I
====================================================

The files /etc/iaxmodem/ttyiax1 and /var/spool/fax/etc/config.ttyiax1 exist.
Actual Results:  
$ systemctl start faxgetty4ttyiax@ttyiax1.service
produces
> systemd[1]: Failed to add dependency on iaxmodem@%I.service, ignoring: Invalid argument
in /var/log/messages and
> start condition failed at ...
in the status output of
$ systemctl status faxgetty4ttyiax@ttyiax1.service

Expected Results:  
$ systemctl start faxgetty4ttyiax@ttyiax1.service
should start a faxgetty instance and pull in the corresponding iaxmodem service.

If my understanding of the templating mechanism (on the man page of systemd.unit) is correct, such a construction is supposed to work.
If it is intentional that the %-specifiers don't get resolved, please consider this bug report a feature request.
Comment 1 Frederic Crozat 2012-04-23 13:45:48 UTC
for Requires (and other dependencies ), the only accepted format strings are: %n %N %p %i

for ConditionPathExists, it doesn't look supported, from a quick look at the code but I don't know if it is wanted or a bug.
Comment 2 Frederic Crozat 2013-03-11 17:30:04 UTC
closing as invalid. Please open a bug upstream on https://bugs.freedesktop.org/ if you want more % specifier to be supported