On Mon, 12.05.14 18:40, Michael Biebl (bi...@debian.org) wrote: > > Note that unit names cannot contain unescaped strings. THis is because they > > are stored in the file system. Hence you either have to escape strings > > manually before including them in unit names, or you let "systemctl" do > > this for you automatically, because it detects that you passed an > > incompletely escaped string on the command line. But the latter really > > just is synctactic sugar to make things easy to use for admins. > > Maybe an example makes it clearer. > We do have an ifup@.service in Debian. > This service has > > [Unit] > Description=ifup for %I > After=local-fs.target > BindTo=sys-subsystem-net-devices-%i.device > ... > > And a corresponding udev rule which activates those instance services. > > Now, say we have network interface containing a '-'. e.g. because I > renamed eth0 to "my-eth". > > If I run systemctl start ifup@my-eth.service, the resulting BindsTo= is > not set properly, my-eth is not escaped.
Well, this is the case since "my-eth" is ambiguous, since it can either be an unescaped string, or an escaped version of "my/eth". Now, systemctl will always assume you escape things properly if in doubt and only if you clearly didn't escape things it will do so for you. Which means in this case it will assume it is properly escaped and hence %i is "my-eth", and %I is "my/eth". Which is the right thing to do I would argue. The syntax "systemctl start ifup@my-eth.service" is genuinly problematic, since you actually use three special chars in there: "@", ".", "-". The former two special chars you want systemd to handle as the special chars they are, but the ther former you want to systemd to handle as something it shall not understand as special char, and should hence implicitly escape... But how should systemctl figure out what you are trying to say here? > I want a specifier which does the following: Take the instance name and > escape it. This has several reasons: > 1/ I don't want to re-implement the escaping rules outside of systemd, > especially since I don't know the escaping rules. > 2/ It's hard to escape the interface name from withing a udev rule, > unless I call a shell script, where I do the escaping using sed dances. > This is ugly, to say the least. > 3/ systemctl status ifup@my-eth.service is much more intuitive then > systemctl status ifup@my\x2deth.service. > Auto-completing helps a bit, but it doesn't get the quoting right [0], > so the failure mode is very confusing. > > Has it become clearer with this example? I think the misunderstanding here is abotu what the actual name of the unit is. Unit names must be escaped. And then %I can be used to undo that. Hence you cann include anything unescaped in the unit name, it just doesn't work... Lennart -- Lennart Poettering, Red Hat -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org