X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fudev%2Fudev-rules.c;h=16348126ee6e88140cec2b48709c8614954cbfa6;hp=769b670b20a1e16b1d44306f517f2709509b0fe4;hb=1291bc895b3dc52fbf7f4c3a04507c14428c4152;hpb=15a722007dc1d8a9a11934b2ab528cf4d25b6c62 diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 769b670b2..16348126e 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -34,6 +34,7 @@ #include "conf-files.h" #include "strbuf.h" #include "strv.h" +#include "util.h" #define PREALLOC_TOKEN 2048 @@ -1066,8 +1067,22 @@ static int add_rule(struct udev_rules *rules, char *line, char *value; enum operation_type op; - if (get_key(rules->udev, &linepos, &key, &op, &value) != 0) + if (get_key(rules->udev, &linepos, &key, &op, &value) != 0) { + /* If we aren't at the end of the line, this is a parsing error. + * Make a best effort to describe where the problem is. */ + if (*linepos != '\n') { + char buf[2] = {linepos[1]}; + _cleanup_free_ char *tmp; + + tmp = cescape(buf); + log_error("invalid key/value pair in file %s on line %u," + "starting at character %lu ('%s')\n", + filename, lineno, linepos - line + 1, tmp); + if (linepos[1] == '#') + log_info("hint: comments can only start at beginning of line"); + } break; + } if (streq(key, "ACTION")) { if (op > OP_MATCH_MAX) {