chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
udev: allow final assignments :=
[elogind.git]
/
udev_rules_parse.c
diff --git
a/udev_rules_parse.c
b/udev_rules_parse.c
index 71ca4827288daca318dc9ba81ca5554ea93c0385..3f07521ccb81210994cb93a0117d1cb234317cd5 100644
(file)
--- a/
udev_rules_parse.c
+++ b/
udev_rules_parse.c
@@
-89,6
+89,8
@@
static int get_key(char **line, char **key, enum key_operation *operation, char
break;
if (linepos[0] == '!')
break;
break;
if (linepos[0] == '!')
break;
+ if (linepos[0] == ':')
+ break;
}
/* remember end of key */
}
/* remember end of key */
@@
-115,6
+117,10
@@
static int get_key(char **line, char **key, enum key_operation *operation, char
*operation = KEY_OP_ASSIGN;
linepos++;
dbg("operator=assign");
*operation = KEY_OP_ASSIGN;
linepos++;
dbg("operator=assign");
+ } else if (linepos[0] == ':' && linepos[1] == '=') {
+ *operation = KEY_OP_ASSIGN_FINAL;
+ linepos += 2;
+ dbg("operator=assign_final");
} else
return -1;
} else
return -1;
@@
-236,7
+242,7
@@
static int rules_parse(const char *filename)
while (1) {
char *key;
char *value;
while (1) {
char *key;
char *value;
- enum key_operation operation = KEY_OP_UN
KNOWN
;
+ enum key_operation operation = KEY_OP_UN
SET
;
retval = get_key(&linepos, &key, &operation, &value);
if (retval)
retval = get_key(&linepos, &key, &operation, &value);
if (retval)
@@
-256,6
+262,13
@@
static int rules_parse(const char *filename)
continue;
}
continue;
}
+ if (strcasecmp(key, KEY_ACTION) == 0) {
+ strlcpy(rule.action, value, sizeof(rule.action));
+ rule.action_operation = operation;
+ valid = 1;
+ continue;
+ }
+
if (strcasecmp(key, KEY_BUS) == 0) {
strlcpy(rule.bus, value, sizeof(rule.bus));
rule.bus_operation = operation;
if (strcasecmp(key, KEY_BUS) == 0) {
strlcpy(rule.bus, value, sizeof(rule.bus));
rule.bus_operation = operation;
@@
-357,24
+370,35
@@
static int rules_parse(const char *filename)
if (strcasecmp(key, KEY_SYMLINK) == 0) {
strlcpy(rule.symlink, value, sizeof(rule.symlink));
if (strcasecmp(key, KEY_SYMLINK) == 0) {
strlcpy(rule.symlink, value, sizeof(rule.symlink));
+ rule.symlink_operation = operation;
valid = 1;
continue;
}
if (strcasecmp(key, KEY_OWNER) == 0) {
strlcpy(rule.owner, value, sizeof(rule.owner));
valid = 1;
continue;
}
if (strcasecmp(key, KEY_OWNER) == 0) {
strlcpy(rule.owner, value, sizeof(rule.owner));
+ rule.owner_operation = operation;
valid = 1;
continue;
}
if (strcasecmp(key, KEY_GROUP) == 0) {
strlcpy(rule.group, value, sizeof(rule.group));
valid = 1;
continue;
}
if (strcasecmp(key, KEY_GROUP) == 0) {
strlcpy(rule.group, value, sizeof(rule.group));
+ rule.group_operation = operation;
valid = 1;
continue;
}
if (strcasecmp(key, KEY_MODE) == 0) {
rule.mode = strtol(value, NULL, 8);
valid = 1;
continue;
}
if (strcasecmp(key, KEY_MODE) == 0) {
rule.mode = strtol(value, NULL, 8);
+ rule.mode_operation = operation;
+ valid = 1;
+ continue;
+ }
+
+ if (strcasecmp(key, KEY_RUN) == 0) {
+ strlcpy(rule.run, value, sizeof(rule.run));
+ rule.run_operation = operation;
valid = 1;
continue;
}
valid = 1;
continue;
}
@@
-408,13
+432,6
@@
static int rules_parse(const char *filename)
if (!valid)
goto error;
if (!valid)
goto error;
- /* simple plausibility checks for given keys */
- if ((rule.sysfs_pair[0].name[0] == '\0') ^
- (rule.sysfs_pair[0].value[0] == '\0')) {
- err("inconsistency in " KEY_SYSFS " key");
- goto error;
- }
-
if ((rule.result[0] != '\0') && (program_given == 0)) {
info(KEY_RESULT " is only useful when " KEY_PROGRAM " is called in any rule before");
goto error;
if ((rule.result[0] != '\0') && (program_given == 0)) {
info(KEY_RESULT " is only useful when " KEY_PROGRAM " is called in any rule before");
goto error;