summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Sekletar <msekletar@users.noreply.github.com>2016-10-28 12:09:14 +0200
committerMartin Pitt <martin.pitt@ubuntu.com>2016-10-28 12:09:14 +0200
commit4f985bd80278972912b80df1390f84d7a89f8d51 (patch)
treeff76fe53af0d0bbbcc9580315b1a28f976cbc09e
parente100155dccaf90521f3e4da5af06736685e9e935 (diff)
udev: allow substitutions for SECLABEL key (#4505)
-rw-r--r--man/udev.xml4
-rw-r--r--src/udev/udev-rules.c8
2 files changed, 9 insertions, 3 deletions
diff --git a/man/udev.xml b/man/udev.xml
index dd5563605c..3359fb0865 100644
--- a/man/udev.xml
+++ b/man/udev.xml
@@ -577,8 +577,8 @@
<para>The <varname>NAME</varname>, <varname>SYMLINK</varname>,
<varname>PROGRAM</varname>, <varname>OWNER</varname>,
- <varname>GROUP</varname>, <varname>MODE</varname>, and
- <varname>RUN</varname> fields support simple string substitutions.
+ <varname>GROUP</varname>, <varname>MODE</varname>, <varname>SECLABEL</varname>,
+ and <varname>RUN</varname> fields support simple string substitutions.
The <varname>RUN</varname> substitutions are performed after all rules
have been processed, right before the program is executed, allowing for
the use of device properties set by earlier matching rules. For all other
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 7619c8371b..f6c416bf70 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -2218,10 +2218,16 @@ void udev_rules_apply_to_event(struct udev_rules *rules,
rule->rule.filename_line);
break;
case TK_A_SECLABEL: {
+ char label_str[UTIL_LINE_SIZE] = {};
const char *name, *label;
name = rules_str(rules, cur->key.attr_off);
- label = rules_str(rules, cur->key.value_off);
+ udev_event_apply_format(event, rules_str(rules, cur->key.value_off), label_str, sizeof(label_str));
+ if (label_str[0] != '\0')
+ label = label_str;
+ else
+ label = rules_str(rules, cur->key.value_off);
+
if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL)
udev_list_cleanup(&event->seclabel_list);
udev_list_entry_add(&event->seclabel_list, name, label);