chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util: consider both fuse.glusterfs and glusterfs network file systems
[elogind.git]
/
src
/
udev
/
udev-rules.c
diff --git
a/src/udev/udev-rules.c
b/src/udev/udev-rules.c
index 8d2b057e2f6c4ab0d3726eb51c92c3ed5430e9e1..26302640a6405c157c7a6c39ba5688cefc9abe7b 100644
(file)
--- a/
src/udev/udev-rules.c
+++ b/
src/udev/udev-rules.c
@@
-440,8
+440,6
@@
static void dump_rules(struct udev_rules *rules)
dump_token(rules, &rules->tokens[i]);
}
#else
dump_token(rules, &rules->tokens[i]);
}
#else
-static inline const char *operation_str(enum operation_type type) { return NULL; }
-static inline const char *token_str(enum token_type type) { return NULL; }
static inline void dump_token(struct udev_rules *rules, struct token *token) {}
static inline void dump_rules(struct udev_rules *rules) {}
#endif /* DEBUG */
static inline void dump_token(struct udev_rules *rules, struct token *token) {}
static inline void dump_rules(struct udev_rules *rules) {}
#endif /* DEBUG */
@@
-870,7
+868,7
@@
static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
struct token *token = &rule_tmp->token[rule_tmp->token_cur];
const char *attr = NULL;
struct token *token = &rule_tmp->token[rule_tmp->token_cur];
const char *attr = NULL;
- mem
set(token, 0x00
, sizeof(struct token));
+ mem
zero(token
, sizeof(struct token));
switch (type) {
case TK_M_ACTION:
switch (type) {
case TK_M_ACTION:
@@
-900,6
+898,7
@@
static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
case TK_A_GOTO:
case TK_M_TAG:
case TK_A_TAG:
case TK_A_GOTO:
case TK_M_TAG:
case TK_A_TAG:
+ case TK_A_STATIC_NODE:
token->key.value_off = rules_add_string(rule_tmp->rules, value);
break;
case TK_M_IMPORT_BUILTIN:
token->key.value_off = rules_add_string(rule_tmp->rules, value);
break;
case TK_M_IMPORT_BUILTIN:
@@
-943,9
+942,6
@@
static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
case TK_A_MODE_ID:
token->key.mode = *(mode_t *)data;
break;
case TK_A_MODE_ID:
token->key.mode = *(mode_t *)data;
break;
- case TK_A_STATIC_NODE:
- token->key.value_off = rules_add_string(rule_tmp->rules, value);
- break;
case TK_M_EVENT_TIMEOUT:
token->key.event_timeout = *(int *)data;
break;
case TK_M_EVENT_TIMEOUT:
token->key.event_timeout = *(int *)data;
break;
@@
-993,7
+989,7
@@
static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
}
if (attr != NULL) {
}
if (attr != NULL) {
- /* check if property/attribut name has substitution chars */
+ /* check if property/attribut
e
name has substitution chars */
if (attr[0] == '[')
token->key.attrsubst = SB_SUBSYS;
else if (strchr(attr, '%') != NULL || strchr(attr, '$') != NULL)
if (attr[0] == '[')
token->key.attrsubst = SB_SUBSYS;
else if (strchr(attr, '%') != NULL || strchr(attr, '$') != NULL)
@@
-1054,7
+1050,7
@@
static int add_rule(struct udev_rules *rules, char *line,
const char *attr;
struct rule_tmp rule_tmp;
const char *attr;
struct rule_tmp rule_tmp;
- mem
set(&rule_tmp, 0x00
, sizeof(struct rule_tmp));
+ mem
zero(&rule_tmp
, sizeof(struct rule_tmp));
rule_tmp.rules = rules;
rule_tmp.rule.type = TK_RULE;
/* the offset in the rule is limited to unsigned short */
rule_tmp.rules = rules;
rule_tmp.rule.type = TK_RULE;
/* the offset in the rule is limited to unsigned short */
@@
-1146,7
+1142,7
@@
static int add_rule(struct udev_rules *rules, char *line,
}
if (startswith(key, "ATTR{")) {
}
if (startswith(key, "ATTR{")) {
- attr = get_key_attribute(rules->udev, key + s
izeof("ATTR")-1
);
+ attr = get_key_attribute(rules->udev, key + s
trlen("ATTR")
);
if (attr == NULL) {
log_error("error parsing ATTR attribute");
goto invalid;
if (attr == NULL) {
log_error("error parsing ATTR attribute");
goto invalid;
@@
-1160,7
+1156,7
@@
static int add_rule(struct udev_rules *rules, char *line,
}
if (startswith(key, "SECLABEL{")) {
}
if (startswith(key, "SECLABEL{")) {
- attr = get_key_attribute(rules->udev, key + s
izeof("SECLABEL")-1
);
+ attr = get_key_attribute(rules->udev, key + s
trlen("SECLABEL")
);
if (!attr) {
log_error("error parsing SECLABEL attribute");
goto invalid;
if (!attr) {
log_error("error parsing SECLABEL attribute");
goto invalid;
@@
-1202,7
+1198,7
@@
static int add_rule(struct udev_rules *rules, char *line,
log_error("invalid ATTRS operation");
goto invalid;
}
log_error("invalid ATTRS operation");
goto invalid;
}
- attr = get_key_attribute(rules->udev, key + s
izeof("ATTRS")-1
);
+ attr = get_key_attribute(rules->udev, key + s
trlen("ATTRS")
);
if (attr == NULL) {
log_error("error parsing ATTRS attribute");
goto invalid;
if (attr == NULL) {
log_error("error parsing ATTRS attribute");
goto invalid;
@@
-1227,7
+1223,7
@@
static int add_rule(struct udev_rules *rules, char *line,
}
if (startswith(key, "ENV{")) {
}
if (startswith(key, "ENV{")) {
- attr = get_key_attribute(rules->udev, key + s
izeof("ENV")-1
);
+ attr = get_key_attribute(rules->udev, key + s
trlen("ENV")
);
if (attr == NULL) {
log_error("error parsing ENV attribute");
goto invalid;
if (attr == NULL) {
log_error("error parsing ENV attribute");
goto invalid;
@@
-1286,7
+1282,7
@@
static int add_rule(struct udev_rules *rules, char *line,
}
if (startswith(key, "IMPORT")) {
}
if (startswith(key, "IMPORT")) {
- attr = get_key_attribute(rules->udev, key + s
izeof("IMPORT")-1
);
+ attr = get_key_attribute(rules->udev, key + s
trlen("IMPORT")
);
if (attr == NULL) {
log_error("IMPORT{} type missing, ignoring IMPORT %s:%u", filename, lineno);
continue;
if (attr == NULL) {
log_error("IMPORT{} type missing, ignoring IMPORT %s:%u", filename, lineno);
continue;
@@
-1332,7
+1328,7
@@
static int add_rule(struct udev_rules *rules, char *line,
log_error("invalid TEST operation");
goto invalid;
}
log_error("invalid TEST operation");
goto invalid;
}
- attr = get_key_attribute(rules->udev, key + s
izeof("TEST")-1
);
+ attr = get_key_attribute(rules->udev, key + s
trlen("TEST")
);
if (attr != NULL) {
mode = strtol(attr, NULL, 8);
rule_add_key(&rule_tmp, TK_M_TEST, op, value, &mode);
if (attr != NULL) {
mode = strtol(attr, NULL, 8);
rule_add_key(&rule_tmp, TK_M_TEST, op, value, &mode);
@@
-1343,7
+1339,7
@@
static int add_rule(struct udev_rules *rules, char *line,
}
if (startswith(key, "RUN")) {
}
if (startswith(key, "RUN")) {
- attr = get_key_attribute(rules->udev, key + s
izeof("RUN")-1
);
+ attr = get_key_attribute(rules->udev, key + s
trlen("RUN")
);
if (attr == NULL)
attr = "program";
if (attr == NULL)
attr = "program";
@@
-1617,7
+1613,7
@@
struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
char **files, **f;
int r;
char **files, **f;
int r;
- rules =
calloc(1, sizeof(struct udev_rules)
);
+ rules =
new0(struct udev_rules, 1
);
if (rules == NULL)
return NULL;
rules->udev = udev;
if (rules == NULL)
return NULL;
rules->udev = udev;
@@
-1654,7
+1650,7
@@
struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
strv_free(files);
strv_free(files);
- mem
set(&end_token, 0x00
, sizeof(struct token));
+ mem
zero(&end_token
, sizeof(struct token));
end_token.type = TK_END;
add_token(rules, &end_token);
log_debug("rules contain %zu bytes tokens (%u * %zu bytes), %zu bytes strings",
end_token.type = TK_END;
add_token(rules, &end_token);
log_debug("rules contain %zu bytes tokens (%u * %zu bytes), %zu bytes strings",
@@
-2561,15
+2557,11
@@
int udev_rules_apply_static_dev_perms(struct udev_rules *rules)
/* we assure, that the permissions tokens are sorted before the static token */
if (mode == 0 && uid == 0 && gid == 0 && tags == NULL)
goto next;
/* we assure, that the permissions tokens are sorted before the static token */
if (mode == 0 && uid == 0 && gid == 0 && tags == NULL)
goto next;
+
strscpyl(device_node, sizeof(device_node), "/dev/", rules_str(rules, cur->key.value_off), NULL);
strscpyl(device_node, sizeof(device_node), "/dev/", rules_str(rules, cur->key.value_off), NULL);
- if (stat(device_node, &stats) != 0)
- goto next;
- if (!S_ISBLK(stats.st_mode) && !S_ISCHR(stats.st_mode))
- goto next;
+ /* export the tags to a directory as symlinks, allowing otherwise dead nodes to be tagged */
if (tags) {
if (tags) {
- /* Export the tags to a directory as symlinks, allowing otherwise dead nodes to be tagged */
-
STRV_FOREACH(t, tags) {
_cleanup_free_ char *unescaped_filename = NULL;
STRV_FOREACH(t, tags) {
_cleanup_free_ char *unescaped_filename = NULL;
@@
-2594,7
+2586,12
@@
int udev_rules_apply_static_dev_perms(struct udev_rules *rules)
/* don't touch the permissions if only the tags were set */
if (mode == 0 && uid == 0 && gid == 0)
/* don't touch the permissions if only the tags were set */
if (mode == 0 && uid == 0 && gid == 0)
- goto next;
+ break;
+
+ if (stat(device_node, &stats) != 0)
+ break;
+ if (!S_ISBLK(stats.st_mode) && !S_ISCHR(stats.st_mode))
+ break;
if (mode == 0) {
if (gid > 0)
if (mode == 0) {
if (gid > 0)