Bug 19186 - log and ignore invalid config files
Summary: log and ignore invalid config files
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Simon McVittie
QA Contact: John (J5) Palmieri
URL: http://git.collabora.co.uk/?p=user/sm...
Whiteboard:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2008-12-19 10:54 UTC by Colin Walters
Modified: 2011-01-31 11:17 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Quiesce error reports in system.d/*.conf files when loading (1.15 KB, patch)
2011-01-06 09:50 UTC, Simon McVittie
Details | Splinter Review
If a file included via <includedir/> is invalid, syslog and skip it (2.02 KB, patch)
2011-01-31 10:13 UTC, Simon McVittie
Details | Splinter Review

Description Colin Walters 2008-12-19 10:54:26 UTC
We should probably log and ignore config files we fail to parse, instead of aborting entirely.

A lot of different software drops config files there, and it's a rather bad failure condition since your system becomes effectively unbootable.
Comment 1 Simon McVittie 2011-01-06 09:49:08 UTC
This appears to be <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=230231> for which we've had a patch since 2004. At the time it was intended to be temporary; I'm not sure whether it was upstreamed and rejected, or just not upstreamed on the assumption that the need for it would go away.

Anyway, I agree with your rationale and would like to apply the patch. Any objections?
Comment 2 Simon McVittie 2011-01-06 09:50:38 UTC
Created attachment 41714 [details] [review]
Quiesce error reports in system.d/*.conf files when loading

Originally from Daniel Silverstone, dating back to the 0.20-6 Debian package.
Comment 3 Colin Walters 2011-01-06 10:19:10 UTC
Comment on attachment 41714 [details] [review]
Quiesce error reports in system.d/*.conf files when loading


>+                  _dbus_warn("\nEncountered error '%s' while parsing '%s'\n",

Missing space between identifer and paren.

>+                             error->message,
>+                             _dbus_string_get_const_data(&full_path));

Ditto.
Comment 4 Colin Walters 2011-01-06 10:27:04 UTC
Comment on attachment 41714 [details] [review]
Quiesce error reports in system.d/*.conf files when loading


>+                  _dbus_warn("\nEncountered error '%s' while parsing '%s'\n",
>+                             error->message,
>+                             _dbus_string_get_const_data(&full_path));

_dbus_warn isn't quite right for this; in a normal scenario (system bus or session bus) it just gets lost to the void, at least on most general purpose Linux forks I know of.

We should at least attempt to protest in a meaningful way by using e.g.:

bus_context_log (context, DBUS_SYSTEM_LOG_INFO, "Error in config file: %s", error->message);

(This uses syslog)
Comment 5 Simon McVittie 2011-01-06 10:30:48 UTC
Reasonable objections. A revised patch is on my to-do list.
Comment 6 Simon McVittie 2011-01-31 10:13:59 UTC
Created attachment 42762 [details] [review]
If a file included via <includedir/> is invalid, syslog and skip it

This is more graceful than failing entirely (our previous behaviour),
but more visible than ignoring it completely (the previous behaviour
patched in by Debian and derivatives).

Based on a patch from Daniel Silverstone back in 2004, which was meant
to be temporary; I think it makes sense to change this permanently,
since files in *.d are typically supplied by other packages, whose bugs
shouldn't be able to bring down dbus-daemon.

---

Unfortunately, I can't call bus_context_log() here; we haven't written our configuration into the bus context at that point, because we're in the config parser! So, I'm just logging it to syslog unconditionally. Unless you have a better idea?
Comment 7 Colin Walters 2011-01-31 10:50:23 UTC
Review of attachment 42762 [details] [review]:

This looks like a useful improvement.  The only downside I see here is that in our default configuration, the session bus is configured not to syslog, but on the other hand, basically no software puts files in /etc/dbus-1/session.d either.
Comment 8 Simon McVittie 2011-01-31 11:17:22 UTC
Thanks, merged to dbus-1.4 (currently just a copy of master) and master.

Fixed in git for 1.4.4, 1.5.0.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.