Am 12.05.2014 18:08, schrieb Lennart Poettering:
> On Sat, 10.05.14 06:56, Michael Biebl ([email protected]) wrote:
> 
>> Am 07.05.2014 21:19, schrieb Gero Treuner:
>>> On Wed, May 07, 2014 at 02:32:40PM +0200, Michael Biebl wrote:
>>>> Please try the attached net.agent (copy it to /lib/udev/net.agent and
>>>> make it executable).
>>>> It escapes the interface name before starting an instance of the
>>>> service. If you want to run systemctl status, make sure to quote the
>>>> name like this:
>>>>
>>>> systemctl status "ifup@veth\x2ddevmachine.service"
>>>>
>>>> Please report if that works for you.
>>>
>>> The patch works fine. Thanks for all.
>>
>> Thanks for testing.
>>
>> Thinking more about it, a nicer solution would be, if systemd would
>> offer another specifier [0], basically the inverse of %I.
>> I.e. you pass a (unescaped) string as instance name and systemd does the
>> escaping which then can be used in the unit file.
>>
>> Let's call that specifier %Y for now.
> 
> Not following here?
> 
> 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 [email protected] 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 [email protected], the resulting BindsTo= is
not set properly, my-eth is not escaped.

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 [email protected] 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?

Michael

[0] https://bugs.freedesktop.org/show_bug.cgi?id=78388


-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to