sysusers: convert to conf_file_read()

I was annoyed that systemd-sysusers doesn't print any info when it opens a
config file. Its read_config_file() started out the same as the one in tmpfiles,
and then they diverged. The one in tmpfiles has that logging, hence the rework
to use it here too and get better logging. The two programs should provide
similar functionality, so using a common helper will make it easier to extend
them in tandem later.

No functional change apart from the log info.

The userdata argument (Context) is moved to the last position as requested in
the review.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2024-02-09 17:57:41 +01:00
parent f6a1346e4e
commit 15d660fb41
2 changed files with 18 additions and 60 deletions
+4 -5
View File
@@ -439,12 +439,11 @@ int conf_file_read(
if (IN_SET(line[0], 0, '#'))
continue;
k = parse_line(fn, v, line, &invalid_line, userdata);
if (k < 0 && invalid_line) {
k = parse_line(fn, v, line, invalid_config ? &invalid_line : NULL, userdata);
if (k < 0 && invalid_line)
/* Allow reporting with a special code if the caller requested this. */
if (invalid_config)
*invalid_config = true;
} else
*invalid_config = true;
else
/* The first error, if any, becomes our return value. */
RET_GATHER(r, k);
}