From 6474897750b0604df8943f35b272dd04ba01ddd7 Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Tue, 10 Feb 2015 01:17:09 +0000 Subject: [PATCH 1/2] Add support for ignore_missing attributed in includedir bus config. Organization: Intel Corporation (UK) Ltd. - Co. Reg. #1134945 - Pipers Way, Swindon SN3 1RJ Signed-off-by: Dimitri John Ledkov --- bus/config-parser.c | 56 +++++++++++++++++++++++++++++++++++++++++++++-------- doc/busconfig.dtd | 2 ++ 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/bus/config-parser.c b/bus/config-parser.c index 58048a5..62105f0 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -819,15 +819,39 @@ start_busconfig_child (BusConfigParser *parser, } else if (element_type == ELEMENT_INCLUDEDIR) { - if (!check_no_attributes (parser, "includedir", attribute_names, attribute_values, error)) - return FALSE; + Element *e; + const char *ignore_missing; - if (push_element (parser, ELEMENT_INCLUDEDIR) == NULL) + if ((e = push_element (parser, ELEMENT_INCLUDEDIR)) == NULL) { BUS_SET_OOM (error); return FALSE; } + e->d.include.ignore_missing = FALSE; + + if (!locate_attributes (parser, "includedir", + attribute_names, + attribute_values, + error, + "ignore_missing", &ignore_missing, + NULL)) + return FALSE; + + if (ignore_missing != NULL) + { + if (strcmp (ignore_missing, "yes") == 0) + e->d.include.ignore_missing = TRUE; + else if (strcmp (ignore_missing, "no") == 0) + e->d.include.ignore_missing = FALSE; + else + { + dbus_set_error (error, DBUS_ERROR_FAILED, + "ignore_missing attribute must have value \"yes\" or \"no\""); + return FALSE; + } + } + return TRUE; } else if (element_type == ELEMENT_STANDARD_SESSION_SERVICEDIRS) @@ -2246,6 +2270,7 @@ servicehelper_path (BusConfigParser *parser, static dbus_bool_t include_dir (BusConfigParser *parser, const DBusString *dirname, + dbus_bool_t ignore_missing, DBusError *error) { DBusString filename; @@ -2261,13 +2286,26 @@ include_dir (BusConfigParser *parser, } retval = FALSE; - - dir = _dbus_directory_open (dirname, error); + + dbus_error_init (&tmp_error); + + dir = _dbus_directory_open (dirname, &tmp_error); if (dir == NULL) - goto failed; + { + if (dbus_error_has_name (&tmp_error, DBUS_ERROR_FILE_NOT_FOUND) && + ignore_missing) + { + dbus_error_free (&tmp_error); + goto success; + } + else + { + dbus_move_error (&tmp_error, error); + goto failed; + } + } - dbus_error_init (&tmp_error); while (_dbus_directory_get_next_file (dir, &filename, &tmp_error)) { DBusString full_path; @@ -2335,6 +2373,7 @@ include_dir (BusConfigParser *parser, goto failed; } + success: retval = TRUE; failed: @@ -2508,7 +2547,8 @@ bus_config_parser_content (BusConfigParser *parser, goto nomem; } - if (!include_dir (parser, &full_path, error)) + if (!include_dir (parser, &full_path, + e->d.include.ignore_missing, error)) { _dbus_string_free (&full_path); return FALSE; diff --git a/doc/busconfig.dtd b/doc/busconfig.dtd index 8c5ac33..9e25cc3 100644 --- a/doc/busconfig.dtd +++ b/doc/busconfig.dtd @@ -17,6 +17,8 @@ + -- 2.1.0