summaryrefslogtreecommitdiffstats
path: root/test/udev-test.pl
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2017-09-28 08:53:46 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-09-28 08:53:46 +0200
commit7e760b79ad143b26a5c937afa7666a7c40508f85 (patch)
tree50a8c8572193f84298beeacde87c8399db1cc875 /test/udev-test.pl
parentMerge pull request #6928 from poettering/cgroup-empty-race (diff)
downloadsystemd-7e760b79ad143b26a5c937afa7666a7c40508f85.tar.xz
systemd-7e760b79ad143b26a5c937afa7666a7c40508f85.zip
udev-rules: all values can contain escaped double quotes now (#6890)
This is primarly useful to support escaped double quotes in PROGRAM or IMPORT{program} directives. The only possibilty before this patch was to use an external shell script but this seems too cumbersome for trivial logics such as PROGRAM=="/bin/sh -c 'FOO=\"%s{model}\"; echo ${FOO:0:4}'" or any similar shell constructs that needs to deals with patterns including whitespaces. As it's the case for single quote and for directives running a program, words within escaped double quotes will be considered as a single argument. Fixes: #6835
Diffstat (limited to 'test/udev-test.pl')
-rwxr-xr-xtest/udev-test.pl24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/udev-test.pl b/test/udev-test.pl
index 7e33479004..0d348e5c08 100755
--- a/test/udev-test.pl
+++ b/test/udev-test.pl
@@ -333,6 +333,30 @@ SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n 'foo3 foo4' 'foo5 foo6 foo7 foo
EOF
},
{
+ desc => "program arguments combined with escaped double quotes, part 1",
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
+ exp_name => "foo2" ,
+ rules => <<EOF
+SUBSYSTEMS=="scsi", PROGRAM=="/bin/sh -c 'printf %%s \\\"foo1 foo2\\\" | grep \\\"foo1 foo2\\\"'", KERNEL=="sda5", SYMLINK+="%c{2}"
+EOF
+ },
+ {
+ desc => "program arguments combined with escaped double quotes, part 2",
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
+ exp_name => "foo2" ,
+ rules => <<EOF
+SUBSYSTEMS=="scsi", PROGRAM=="/bin/sh -c \\\"printf %%s 'foo1 foo2' | grep 'foo1 foo2'\\\"", KERNEL=="sda5", SYMLINK+="%c{2}"
+EOF
+ },
+ {
+ desc => "program arguments combined with escaped double quotes, part 3",
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
+ exp_name => "foo2" ,
+ rules => <<EOF
+SUBSYSTEMS=="scsi", PROGRAM=="/bin/sh -c 'printf \\\"%%s %%s\\\" \\\"foo1 foo2\\\" \\\"foo3\\\"| grep \\\"foo1 foo2\\\"'", KERNEL=="sda5", SYMLINK+="%c{2}"
+EOF
+ },
+ {
desc => "characters before the %c{N} substitution",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
exp_name => "my-foo9" ,