- parent_device = sysfs_get_device_parent(parent_device);
- if (parent_device == NULL)
- goto exit;
- dbg("look at sysfs_device->path='%s'", parent_device->path);
- dbg("look at sysfs_device->bus_id='%s'", parent_device->bus_id);
+ udev->dev_parent = sysfs_device_get_parent(udev->dev_parent);
+ if (udev->dev_parent == NULL)
+ goto nomatch;
+ dbg("looking at dev_parent->devpath='%s'", udev->dev_parent->devpath);
+ dbg("looking at dev_parent->bus_kernel_name='%s'", udev->dev_parent->kernel_name);
+ }
+
+ /* execute external program */
+ if (rule->program.operation != KEY_OP_UNSET) {
+ char program[PATH_SIZE];
+ char result[PATH_SIZE];
+
+ strlcpy(program, key_val(rule, &rule->program), sizeof(program));
+ udev_rules_apply_format(udev, program, sizeof(program));
+ if (run_program(program, udev->dev->subsystem, result, sizeof(result), NULL, (udev_log_priority >= LOG_INFO)) != 0) {
+ dbg("PROGRAM is false");
+ udev->program_result[0] = '\0';
+ if (rule->program.operation != KEY_OP_NOMATCH)
+ goto nomatch;
+ } else {
+ int count;
+
+ dbg("PROGRAM matches");
+ remove_trailing_chars(result, '\n');
+ count = replace_untrusted_chars(result);
+ if (count)
+ info("%i untrusted character(s) replaced" , count);
+ dbg("result is '%s'", result);
+ strlcpy(udev->program_result, result, sizeof(udev->program_result));
+ dbg("PROGRAM returned successful");
+ if (rule->program.operation == KEY_OP_NOMATCH)
+ goto nomatch;
+ }
+ dbg("PROGRAM key is true");