Rip out setting of the log level from udev_new and put it in a new function
This function is internal to systemd code, so external users of libudev will not see those log messages. I think this is better. If we want to allow that, the function could be put in libudev and exported. v2: check that the string is more than one char before stripping quotes
This commit is contained in:
@@ -103,82 +103,6 @@ _public_ struct udev *udev_new(void) {
|
||||
}
|
||||
udev->refcount = 1;
|
||||
|
||||
f = fopen("/etc/udev/udev.conf", "re");
|
||||
if (f != NULL) {
|
||||
char line[UTIL_LINE_SIZE];
|
||||
unsigned line_nr = 0;
|
||||
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
size_t len;
|
||||
char *key;
|
||||
char *val;
|
||||
|
||||
line_nr++;
|
||||
|
||||
/* find key */
|
||||
key = line;
|
||||
while (isspace(key[0]))
|
||||
key++;
|
||||
|
||||
/* comment or empty line */
|
||||
if (key[0] == '#' || key[0] == '\0')
|
||||
continue;
|
||||
|
||||
/* split key/value */
|
||||
val = strchr(key, '=');
|
||||
if (val == NULL) {
|
||||
log_debug("/etc/udev/udev.conf:%u: missing assignment, skipping line.", line_nr);
|
||||
continue;
|
||||
}
|
||||
val[0] = '\0';
|
||||
val++;
|
||||
|
||||
/* find value */
|
||||
while (isspace(val[0]))
|
||||
val++;
|
||||
|
||||
/* terminate key */
|
||||
len = strlen(key);
|
||||
if (len == 0)
|
||||
continue;
|
||||
while (isspace(key[len-1]))
|
||||
len--;
|
||||
key[len] = '\0';
|
||||
|
||||
/* terminate value */
|
||||
len = strlen(val);
|
||||
if (len == 0)
|
||||
continue;
|
||||
while (isspace(val[len-1]))
|
||||
len--;
|
||||
val[len] = '\0';
|
||||
|
||||
if (len == 0)
|
||||
continue;
|
||||
|
||||
/* unquote */
|
||||
if (val[0] == '"' || val[0] == '\'') {
|
||||
if (len == 1 || val[len-1] != val[0]) {
|
||||
log_debug("/etc/udev/udev.conf:%u: inconsistent quoting, skipping line.", line_nr);
|
||||
continue;
|
||||
}
|
||||
val[len-1] = '\0';
|
||||
val++;
|
||||
}
|
||||
|
||||
if (streq(key, "udev_log")) {
|
||||
int prio;
|
||||
|
||||
prio = util_log_priority(val);
|
||||
if (prio < 0)
|
||||
log_debug("/etc/udev/udev.conf:%u: invalid log level '%s', ignoring.", line_nr, val);
|
||||
else
|
||||
log_set_max_level(prio);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return udev;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user