Skip to content

Commit

Permalink
launch: align errors when reading service-files with dbus-daemon(1)
Browse files Browse the repository at this point in the history
The reference implementation ignores all error-codes from
bus1_desktop_file_load(), so we should do the same. However, none of
these errors is expected, so lets make sure we print a warning.

Reported-by: Yanko Kaneti <yaneti@declera.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
  • Loading branch information
David Herrmann authored and teg committed Jan 11, 2019
1 parent 2902f7d commit a0869bd
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/launch/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,12 +880,24 @@ static int manager_ini_reader_parse_file(CIniGroup **groupp, const char *path) {

fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0) {
if (errno == ENOENT) {
*groupp = NULL;
return 0;
}
/*
* For compatibility reasons we have to accept any failure
* during open(2). dbus-daemon(1) simply ignores those errors
* and skips the service file in question.
*
* We would very much prefer to whitelist specific error codes
* here, but we would be playing whack-a-mole, so lets just
* treat it as soft-error.
*/
if (errno == ENOENT)
fprintf(stderr, "Original source was unlinked while parsing service file '%s'\n", path);
else if (errno == EACCES)
fprintf(stderr, "Read access denied for service file '%s'\n", path);
else
fprintf(stderr, "Unable to open service file '%s' (%d): %m\n", path, errno);

return error_origin(-errno);
*groupp = NULL;
return 0;
}

r = c_ini_reader_new(&reader);
Expand Down

0 comments on commit a0869bd

Please sign in to comment.