- if (rule->result_operation != KEY_OP_UNSET) {
- dbg("check for " KEY_RESULT " rule->result='%s', udev->program_result='%s'",
- rule->result, udev->program_result);
- if (strcmp_pattern(rule->result, udev->program_result) != 0) {
- dbg(KEY_RESULT " is not matching");
- if (rule->result_operation != KEY_OP_NOMATCH)
- goto exit;
- } else {
- dbg(KEY_RESULT " matches");
- if (rule->result_operation == KEY_OP_NOMATCH)
- goto exit;
+ if (match_key("RESULT", rule, &rule->result, udev->program_result))
+ goto nomatch;
+
+ /* import variables returned from program or or file into environment */
+ if (rule->import.operation != KEY_OP_UNSET) {
+ char import[PATH_SIZE];
+ int rc = -1;
+
+ strlcpy(import, key_val(rule, &rule->import), sizeof(import));
+ udev_rules_apply_format(udev, import, sizeof(import));
+ dbg("check for IMPORT import='%s'", import);
+ if (rule->import_type == IMPORT_PROGRAM) {
+ rc = import_program_into_env(udev, import);
+ } else if (rule->import_type == IMPORT_FILE) {
+ dbg("import file import='%s'", import);
+ rc = import_file_into_env(udev, import);
+ } else if (rule->import_type == IMPORT_PARENT) {
+ dbg("import parent import='%s'", import);
+ rc = import_parent_into_env(udev, import);
+ }
+ if (rc != 0) {
+ dbg("IMPORT failed");
+ if (rule->import.operation != KEY_OP_NOMATCH)
+ goto nomatch;
+ } else
+ dbg("IMPORT '%s' imported", key_val(rule, &rule->import));
+ dbg("IMPORT key is true");
+ }
+
+ /* rule matches, if we have ENV assignments export it */
+ for (i = 0; i < rule->env.count; i++) {
+ struct key_pair *pair = &rule->env.keys[i];
+
+ if (pair->key.operation == KEY_OP_ASSIGN) {
+ const char *key_name = key_pair_name(rule, pair);
+ const char *value = key_val(rule, &pair->key);
+
+ name_list_key_add(&udev->env_list, key_name, value);
+ setenv(key_name, value, 1);
+ dbg("export ENV '%s=%s'", key_name, value);