1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* config-parser.c XML-library-agnostic configuration file parser
4 * Copyright (C) 2003, 2004 Red Hat, Inc.
6 * Licensed under the Academic Free License version 2.1
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "config-parser-common.h"
24 #include "config-parser.h"
29 #include <dbus/dbus-list.h>
30 #include <dbus/dbus-internals.h>
35 /* we ignore policies for unknown groups/users */
50 unsigned int had_content : 1;
56 unsigned int ignore_missing : 1;
57 unsigned int if_selinux_enabled : 1;
58 unsigned int selinux_root_relative : 1;
64 unsigned long gid_uid_or_at_console;
78 * Parser for bus configuration file.
80 struct BusConfigParser
82 int refcount; /**< Reference count */
84 DBusString basedir; /**< Directory we resolve paths relative to */
86 DBusList *stack; /**< stack of Element */
88 char *user; /**< user to run as */
90 char *servicehelper; /**< location of the setuid helper */
92 char *bus_type; /**< Message bus type */
94 DBusList *listen_on; /**< List of addresses to listen to */
96 DBusList *mechanisms; /**< Auth mechanisms */
98 DBusList *service_dirs; /**< Directories to look for session services in */
100 DBusList *conf_dirs; /**< Directories to look for policy configuration in */
102 BusPolicy *policy; /**< Security policy */
104 BusLimits limits; /**< Limits */
106 char *pidfile; /**< PID file */
108 DBusList *included_files; /**< Included files stack */
110 DBusHashTable *service_context_table; /**< Map service names to SELinux contexts */
112 unsigned int fork : 1; /**< TRUE to fork into daemon mode */
114 unsigned int keep_umask : 1; /**< TRUE to keep original umask when forking */
116 unsigned int is_toplevel : 1; /**< FALSE if we are a sub-config-file inside another one */
118 unsigned int allow_anonymous : 1; /**< TRUE to allow anonymous connections */
122 push_element (BusConfigParser *parser,
127 _dbus_assert (type != ELEMENT_NONE);
129 e = dbus_new0 (Element, 1);
133 if (!_dbus_list_append (&parser->stack, e))
145 element_free (Element *e)
147 if (e->type == ELEMENT_LIMIT)
148 dbus_free (e->d.limit.name);
154 pop_element (BusConfigParser *parser)
158 e = _dbus_list_pop_last (&parser->stack);
164 peek_element (BusConfigParser *parser)
168 e = _dbus_list_get_last (&parser->stack);
174 top_element_type (BusConfigParser *parser)
178 e = _dbus_list_get_last (&parser->stack);
187 merge_service_context_hash (DBusHashTable *dest,
197 _dbus_hash_iter_init (from, &iter);
198 while (_dbus_hash_iter_next (&iter))
200 const char *service = _dbus_hash_iter_get_string_key (&iter);
201 const char *context = _dbus_hash_iter_get_value (&iter);
203 service_copy = _dbus_strdup (service);
204 if (service_copy == NULL)
206 context_copy = _dbus_strdup (context);
207 if (context_copy == NULL)
210 if (!_dbus_hash_table_insert_string (dest, service_copy, context_copy))
221 dbus_free (service_copy);
224 dbus_free (context_copy);
230 service_dirs_find_dir (DBusList **service_dirs,
235 _dbus_assert (dir != NULL);
237 for (link = *service_dirs; link; link = _dbus_list_get_next_link(service_dirs, link))
239 const char *link_dir;
241 link_dir = (const char *)link->data;
242 if (strcmp (dir, link_dir) == 0)
250 service_dirs_append_unique_or_free (DBusList **service_dirs,
253 if (!service_dirs_find_dir (service_dirs, dir))
254 return _dbus_list_append (service_dirs, dir);
261 service_dirs_append_link_unique_or_free (DBusList **service_dirs,
264 if (!service_dirs_find_dir (service_dirs, dir_link->data))
266 _dbus_list_append_link (service_dirs, dir_link);
270 dbus_free (dir_link->data);
271 _dbus_list_free_link (dir_link);
276 merge_included (BusConfigParser *parser,
277 BusConfigParser *included,
282 if (!bus_policy_merge (parser->policy,
289 if (!merge_service_context_hash (parser->service_context_table,
290 included->service_context_table))
296 if (included->user != NULL)
298 dbus_free (parser->user);
299 parser->user = included->user;
300 included->user = NULL;
303 if (included->bus_type != NULL)
305 dbus_free (parser->bus_type);
306 parser->bus_type = included->bus_type;
307 included->bus_type = NULL;
313 if (included->keep_umask)
314 parser->keep_umask = TRUE;
316 if (included->pidfile != NULL)
318 dbus_free (parser->pidfile);
319 parser->pidfile = included->pidfile;
320 included->pidfile = NULL;
323 while ((link = _dbus_list_pop_first_link (&included->listen_on)))
324 _dbus_list_append_link (&parser->listen_on, link);
326 while ((link = _dbus_list_pop_first_link (&included->mechanisms)))
327 _dbus_list_append_link (&parser->mechanisms, link);
329 while ((link = _dbus_list_pop_first_link (&included->service_dirs)))
330 service_dirs_append_link_unique_or_free (&parser->service_dirs, link);
332 while ((link = _dbus_list_pop_first_link (&included->conf_dirs)))
333 _dbus_list_append_link (&parser->conf_dirs, link);
339 seen_include (BusConfigParser *parser,
340 const DBusString *file)
344 iter = parser->included_files;
347 if (! strcmp (_dbus_string_get_const_data (file), iter->data))
350 iter = _dbus_list_get_next_link (&parser->included_files, iter);
357 bus_config_parser_new (const DBusString *basedir,
358 dbus_bool_t is_toplevel,
359 const BusConfigParser *parent)
361 BusConfigParser *parser;
363 parser = dbus_new0 (BusConfigParser, 1);
367 parser->is_toplevel = !!is_toplevel;
369 if (!_dbus_string_init (&parser->basedir))
375 if (((parser->policy = bus_policy_new ()) == NULL) ||
376 !_dbus_string_copy (basedir, 0, &parser->basedir, 0) ||
377 ((parser->service_context_table = _dbus_hash_table_new (DBUS_HASH_STRING,
379 dbus_free)) == NULL))
382 bus_policy_unref (parser->policy);
384 _dbus_string_free (&parser->basedir);
392 /* Initialize the parser's limits from the parent. */
393 parser->limits = parent->limits;
395 /* Use the parent's list of included_files to avoid
396 circular inclusions. */
397 parser->included_files = parent->included_files;
402 /* Make up some numbers! woot! */
403 parser->limits.max_incoming_bytes = _DBUS_ONE_MEGABYTE * 127;
404 parser->limits.max_outgoing_bytes = _DBUS_ONE_MEGABYTE * 127;
405 parser->limits.max_message_size = _DBUS_ONE_MEGABYTE * 32;
407 /* Making this long means the user has to wait longer for an error
408 * message if something screws up, but making it too short means
409 * they might see a false failure.
411 parser->limits.activation_timeout = 25000; /* 25 seconds */
413 /* Making this long risks making a DOS attack easier, but too short
414 * and legitimate auth will fail. If interactive auth (ask user for
415 * password) is allowed, then potentially it has to be quite long.
417 parser->limits.auth_timeout = 30000; /* 30 seconds */
419 parser->limits.max_incomplete_connections = 64;
420 parser->limits.max_connections_per_user = 256;
422 /* Note that max_completed_connections / max_connections_per_user
423 * is the number of users that would have to work together to
424 * DOS all the other users.
426 parser->limits.max_completed_connections = 2048;
428 parser->limits.max_pending_activations = 512;
429 parser->limits.max_services_per_connection = 512;
431 /* For this one, keep in mind that it isn't only the memory used
432 * by the match rules, but slowdown from linearly walking a big
433 * list of them. A client adding more than this is almost
434 * certainly a bad idea for that reason, and should change to a
435 * smaller number of wider-net match rules - getting every last
436 * message to the bus is probably better than having a thousand
439 parser->limits.max_match_rules_per_connection = 512;
441 parser->limits.reply_timeout = 5 * 60 * 1000; /* 5 minutes */
443 /* this is effectively a limit on message queue size for messages
444 * that require a reply
446 parser->limits.max_replies_per_connection = 1024*8;
449 parser->refcount = 1;
455 bus_config_parser_ref (BusConfigParser *parser)
457 _dbus_assert (parser->refcount > 0);
459 parser->refcount += 1;
465 bus_config_parser_unref (BusConfigParser *parser)
467 _dbus_assert (parser->refcount > 0);
469 parser->refcount -= 1;
471 if (parser->refcount == 0)
473 while (parser->stack != NULL)
474 pop_element (parser);
476 dbus_free (parser->user);
477 dbus_free (parser->servicehelper);
478 dbus_free (parser->bus_type);
479 dbus_free (parser->pidfile);
481 _dbus_list_foreach (&parser->listen_on,
482 (DBusForeachFunction) dbus_free,
485 _dbus_list_clear (&parser->listen_on);
487 _dbus_list_foreach (&parser->service_dirs,
488 (DBusForeachFunction) dbus_free,
491 _dbus_list_clear (&parser->service_dirs);
493 _dbus_list_foreach (&parser->conf_dirs,
494 (DBusForeachFunction) dbus_free,
497 _dbus_list_clear (&parser->conf_dirs);
499 _dbus_list_foreach (&parser->mechanisms,
500 (DBusForeachFunction) dbus_free,
503 _dbus_list_clear (&parser->mechanisms);
505 _dbus_string_free (&parser->basedir);
508 bus_policy_unref (parser->policy);
510 if (parser->service_context_table)
511 _dbus_hash_table_unref (parser->service_context_table);
518 bus_config_parser_check_doctype (BusConfigParser *parser,
522 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
524 if (strcmp (doctype, "busconfig") != 0)
526 dbus_set_error (error,
528 "Configuration file has the wrong document type %s",
543 locate_attributes (BusConfigParser *parser,
544 const char *element_name,
545 const char **attribute_names,
546 const char **attribute_values,
548 const char *first_attribute_name,
549 const char **first_attribute_retloc,
557 LocateAttr attrs[MAX_ATTRS];
561 _dbus_assert (first_attribute_name != NULL);
562 _dbus_assert (first_attribute_retloc != NULL);
567 attrs[0].name = first_attribute_name;
568 attrs[0].retloc = first_attribute_retloc;
569 *first_attribute_retloc = NULL;
571 va_start (args, first_attribute_retloc);
573 name = va_arg (args, const char*);
574 retloc = va_arg (args, const char**);
578 _dbus_assert (retloc != NULL);
579 _dbus_assert (n_attrs < MAX_ATTRS);
581 attrs[n_attrs].name = name;
582 attrs[n_attrs].retloc = retloc;
586 name = va_arg (args, const char*);
587 retloc = va_arg (args, const char**);
593 while (attribute_names[i])
602 if (strcmp (attrs[j].name, attribute_names[i]) == 0)
604 retloc = attrs[j].retloc;
608 dbus_set_error (error, DBUS_ERROR_FAILED,
609 "Attribute \"%s\" repeated twice on the same <%s> element",
610 attrs[j].name, element_name);
615 *retloc = attribute_values[i];
624 dbus_set_error (error, DBUS_ERROR_FAILED,
625 "Attribute \"%s\" is invalid on <%s> element in this context",
626 attribute_names[i], element_name);
639 check_no_attributes (BusConfigParser *parser,
640 const char *element_name,
641 const char **attribute_names,
642 const char **attribute_values,
645 if (attribute_names[0] != NULL)
647 dbus_set_error (error, DBUS_ERROR_FAILED,
648 "Attribute \"%s\" is invalid on <%s> element in this context",
649 attribute_names[0], element_name);
657 start_busconfig_child (BusConfigParser *parser,
658 const char *element_name,
659 const char **attribute_names,
660 const char **attribute_values,
663 ElementType element_type;
665 element_type = bus_config_parser_element_name_to_type (element_name);
667 if (element_type == ELEMENT_USER)
669 if (!check_no_attributes (parser, "user", attribute_names, attribute_values, error))
672 if (push_element (parser, ELEMENT_USER) == NULL)
680 else if (element_type == ELEMENT_TYPE)
682 if (!check_no_attributes (parser, "type", attribute_names, attribute_values, error))
685 if (push_element (parser, ELEMENT_TYPE) == NULL)
693 else if (element_type == ELEMENT_FORK)
695 if (!check_no_attributes (parser, "fork", attribute_names, attribute_values, error))
698 if (push_element (parser, ELEMENT_FORK) == NULL)
708 else if (element_type == ELEMENT_KEEP_UMASK)
710 if (!check_no_attributes (parser, "keep_umask", attribute_names, attribute_values, error))
713 if (push_element (parser, ELEMENT_KEEP_UMASK) == NULL)
719 parser->keep_umask = TRUE;
723 else if (element_type == ELEMENT_PIDFILE)
725 if (!check_no_attributes (parser, "pidfile", attribute_names, attribute_values, error))
728 if (push_element (parser, ELEMENT_PIDFILE) == NULL)
736 else if (element_type == ELEMENT_LISTEN)
738 if (!check_no_attributes (parser, "listen", attribute_names, attribute_values, error))
741 if (push_element (parser, ELEMENT_LISTEN) == NULL)
749 else if (element_type == ELEMENT_AUTH)
751 if (!check_no_attributes (parser, "auth", attribute_names, attribute_values, error))
754 if (push_element (parser, ELEMENT_AUTH) == NULL)
762 else if (element_type == ELEMENT_SERVICEHELPER)
764 if (!check_no_attributes (parser, "servicehelper", attribute_names, attribute_values, error))
767 if (push_element (parser, ELEMENT_SERVICEHELPER) == NULL)
775 else if (element_type == ELEMENT_INCLUDEDIR)
777 if (!check_no_attributes (parser, "includedir", attribute_names, attribute_values, error))
780 if (push_element (parser, ELEMENT_INCLUDEDIR) == NULL)
788 else if (element_type == ELEMENT_STANDARD_SESSION_SERVICEDIRS)
794 if (!check_no_attributes (parser, "standard_session_servicedirs", attribute_names, attribute_values, error))
797 if (push_element (parser, ELEMENT_STANDARD_SESSION_SERVICEDIRS) == NULL)
803 if (!_dbus_get_standard_session_servicedirs (&dirs))
809 while ((link = _dbus_list_pop_first_link (&dirs)))
810 service_dirs_append_link_unique_or_free (&parser->service_dirs, link);
814 else if (element_type == ELEMENT_STANDARD_SYSTEM_SERVICEDIRS)
820 if (!check_no_attributes (parser, "standard_system_servicedirs", attribute_names, attribute_values, error))
823 if (push_element (parser, ELEMENT_STANDARD_SYSTEM_SERVICEDIRS) == NULL)
829 if (!_dbus_get_standard_system_servicedirs (&dirs))
835 while ((link = _dbus_list_pop_first_link (&dirs)))
836 service_dirs_append_link_unique_or_free (&parser->service_dirs, link);
840 else if (element_type == ELEMENT_ALLOW_ANONYMOUS)
842 if (!check_no_attributes (parser, "allow_anonymous", attribute_names, attribute_values, error))
845 if (push_element (parser, ELEMENT_ALLOW_ANONYMOUS) == NULL)
851 parser->allow_anonymous = TRUE;
854 else if (element_type == ELEMENT_SERVICEDIR)
856 if (!check_no_attributes (parser, "servicedir", attribute_names, attribute_values, error))
859 if (push_element (parser, ELEMENT_SERVICEDIR) == NULL)
867 else if (element_type == ELEMENT_INCLUDE)
870 const char *if_selinux_enabled;
871 const char *ignore_missing;
872 const char *selinux_root_relative;
874 if ((e = push_element (parser, ELEMENT_INCLUDE)) == NULL)
880 e->d.include.ignore_missing = FALSE;
881 e->d.include.if_selinux_enabled = FALSE;
882 e->d.include.selinux_root_relative = FALSE;
884 if (!locate_attributes (parser, "include",
888 "ignore_missing", &ignore_missing,
889 "if_selinux_enabled", &if_selinux_enabled,
890 "selinux_root_relative", &selinux_root_relative,
894 if (ignore_missing != NULL)
896 if (strcmp (ignore_missing, "yes") == 0)
897 e->d.include.ignore_missing = TRUE;
898 else if (strcmp (ignore_missing, "no") == 0)
899 e->d.include.ignore_missing = FALSE;
902 dbus_set_error (error, DBUS_ERROR_FAILED,
903 "ignore_missing attribute must have value \"yes\" or \"no\"");
908 if (if_selinux_enabled != NULL)
910 if (strcmp (if_selinux_enabled, "yes") == 0)
911 e->d.include.if_selinux_enabled = TRUE;
912 else if (strcmp (if_selinux_enabled, "no") == 0)
913 e->d.include.if_selinux_enabled = FALSE;
916 dbus_set_error (error, DBUS_ERROR_FAILED,
917 "if_selinux_enabled attribute must have value"
918 " \"yes\" or \"no\"");
923 if (selinux_root_relative != NULL)
925 if (strcmp (selinux_root_relative, "yes") == 0)
926 e->d.include.selinux_root_relative = TRUE;
927 else if (strcmp (selinux_root_relative, "no") == 0)
928 e->d.include.selinux_root_relative = FALSE;
931 dbus_set_error (error, DBUS_ERROR_FAILED,
932 "selinux_root_relative attribute must have value"
933 " \"yes\" or \"no\"");
940 else if (element_type == ELEMENT_POLICY)
946 const char *at_console;
948 if ((e = push_element (parser, ELEMENT_POLICY)) == NULL)
954 e->d.policy.type = POLICY_IGNORED;
956 if (!locate_attributes (parser, "policy",
963 "at_console", &at_console,
967 if (((context && user) ||
968 (context && group) ||
969 (context && at_console)) ||
971 (user && at_console)) ||
972 (group && at_console) ||
973 !(context || user || group || at_console))
975 dbus_set_error (error, DBUS_ERROR_FAILED,
976 "<policy> element must have exactly one of (context|user|group|at_console) attributes");
982 if (strcmp (context, "default") == 0)
984 e->d.policy.type = POLICY_DEFAULT;
986 else if (strcmp (context, "mandatory") == 0)
988 e->d.policy.type = POLICY_MANDATORY;
992 dbus_set_error (error, DBUS_ERROR_FAILED,
993 "context attribute on <policy> must have the value \"default\" or \"mandatory\", not \"%s\"",
998 else if (user != NULL)
1000 DBusString username;
1001 _dbus_string_init_const (&username, user);
1003 if (_dbus_parse_unix_user_from_config (&username,
1004 &e->d.policy.gid_uid_or_at_console))
1005 e->d.policy.type = POLICY_USER;
1007 _dbus_warn ("Unknown username \"%s\" in message bus configuration file\n",
1010 else if (group != NULL)
1012 DBusString group_name;
1013 _dbus_string_init_const (&group_name, group);
1015 if (_dbus_parse_unix_group_from_config (&group_name,
1016 &e->d.policy.gid_uid_or_at_console))
1017 e->d.policy.type = POLICY_GROUP;
1019 _dbus_warn ("Unknown group \"%s\" in message bus configuration file\n",
1022 else if (at_console != NULL)
1025 t = (strcmp (at_console, "true") == 0);
1026 if (t || strcmp (at_console, "false") == 0)
1028 e->d.policy.gid_uid_or_at_console = t;
1029 e->d.policy.type = POLICY_CONSOLE;
1033 dbus_set_error (error, DBUS_ERROR_FAILED,
1034 "Unknown value \"%s\" for at_console in message bus configuration file",
1042 _dbus_assert_not_reached ("all <policy> attributes null and we didn't set error");
1047 else if (element_type == ELEMENT_LIMIT)
1052 if ((e = push_element (parser, ELEMENT_LIMIT)) == NULL)
1054 BUS_SET_OOM (error);
1058 if (!locate_attributes (parser, "limit",
1068 dbus_set_error (error, DBUS_ERROR_FAILED,
1069 "<limit> element must have a \"name\" attribute");
1073 e->d.limit.name = _dbus_strdup (name);
1074 if (e->d.limit.name == NULL)
1076 BUS_SET_OOM (error);
1082 else if (element_type == ELEMENT_SELINUX)
1084 if (!check_no_attributes (parser, "selinux", attribute_names, attribute_values, error))
1087 if (push_element (parser, ELEMENT_SELINUX) == NULL)
1089 BUS_SET_OOM (error);
1097 dbus_set_error (error, DBUS_ERROR_FAILED,
1098 "Element <%s> not allowed inside <%s> in configuration file",
1099 element_name, "busconfig");
1105 append_rule_from_element (BusConfigParser *parser,
1106 const char *element_name,
1107 const char **attribute_names,
1108 const char **attribute_values,
1112 const char *send_interface;
1113 const char *send_member;
1114 const char *send_error;
1115 const char *send_destination;
1116 const char *send_path;
1117 const char *send_type;
1118 const char *receive_interface;
1119 const char *receive_member;
1120 const char *receive_error;
1121 const char *receive_sender;
1122 const char *receive_path;
1123 const char *receive_type;
1124 const char *eavesdrop;
1125 const char *send_requested_reply;
1126 const char *receive_requested_reply;
1131 BusPolicyRule *rule;
1133 if (!locate_attributes (parser, element_name,
1137 "send_interface", &send_interface,
1138 "send_member", &send_member,
1139 "send_error", &send_error,
1140 "send_destination", &send_destination,
1141 "send_path", &send_path,
1142 "send_type", &send_type,
1143 "receive_interface", &receive_interface,
1144 "receive_member", &receive_member,
1145 "receive_error", &receive_error,
1146 "receive_sender", &receive_sender,
1147 "receive_path", &receive_path,
1148 "receive_type", &receive_type,
1149 "eavesdrop", &eavesdrop,
1150 "send_requested_reply", &send_requested_reply,
1151 "receive_requested_reply", &receive_requested_reply,
1158 if (!(send_interface || send_member || send_error || send_destination ||
1159 send_type || send_path ||
1160 receive_interface || receive_member || receive_error || receive_sender ||
1161 receive_type || receive_path || eavesdrop ||
1162 send_requested_reply || receive_requested_reply ||
1163 own || user || group))
1165 dbus_set_error (error, DBUS_ERROR_FAILED,
1166 "Element <%s> must have one or more attributes",
1171 if ((send_member && (send_interface == NULL && send_path == NULL)) ||
1172 (receive_member && (receive_interface == NULL && receive_path == NULL)))
1174 dbus_set_error (error, DBUS_ERROR_FAILED,
1175 "On element <%s>, if you specify a member you must specify an interface or a path. Keep in mind that not all messages have an interface field.",
1180 /* Allowed combinations of elements are:
1182 * base, must be all send or all receive:
1185 * interface + member
1188 * base send_ can combine with send_destination, send_path, send_type, send_requested_reply
1189 * base receive_ with receive_sender, receive_path, receive_type, receive_requested_reply, eavesdrop
1191 * user, group, own must occur alone
1193 * Pretty sure the below stuff is broken, FIXME think about it more.
1196 if (((send_interface && send_error) ||
1197 (send_interface && receive_interface) ||
1198 (send_interface && receive_member) ||
1199 (send_interface && receive_error) ||
1200 (send_interface && receive_sender) ||
1201 (send_interface && receive_requested_reply) ||
1202 (send_interface && own) ||
1203 (send_interface && user) ||
1204 (send_interface && group)) ||
1206 ((send_member && send_error) ||
1207 (send_member && receive_interface) ||
1208 (send_member && receive_member) ||
1209 (send_member && receive_error) ||
1210 (send_member && receive_sender) ||
1211 (send_member && receive_requested_reply) ||
1212 (send_member && own) ||
1213 (send_member && user) ||
1214 (send_member && group)) ||
1216 ((send_error && receive_interface) ||
1217 (send_error && receive_member) ||
1218 (send_error && receive_error) ||
1219 (send_error && receive_sender) ||
1220 (send_error && receive_requested_reply) ||
1221 (send_error && own) ||
1222 (send_error && user) ||
1223 (send_error && group)) ||
1225 ((send_destination && receive_interface) ||
1226 (send_destination && receive_member) ||
1227 (send_destination && receive_error) ||
1228 (send_destination && receive_sender) ||
1229 (send_destination && receive_requested_reply) ||
1230 (send_destination && own) ||
1231 (send_destination && user) ||
1232 (send_destination && group)) ||
1234 ((send_type && receive_interface) ||
1235 (send_type && receive_member) ||
1236 (send_type && receive_error) ||
1237 (send_type && receive_sender) ||
1238 (send_type && receive_requested_reply) ||
1239 (send_type && own) ||
1240 (send_type && user) ||
1241 (send_type && group)) ||
1243 ((send_path && receive_interface) ||
1244 (send_path && receive_member) ||
1245 (send_path && receive_error) ||
1246 (send_path && receive_sender) ||
1247 (send_path && receive_requested_reply) ||
1248 (send_path && own) ||
1249 (send_path && user) ||
1250 (send_path && group)) ||
1252 ((send_requested_reply && receive_interface) ||
1253 (send_requested_reply && receive_member) ||
1254 (send_requested_reply && receive_error) ||
1255 (send_requested_reply && receive_sender) ||
1256 (send_requested_reply && receive_requested_reply) ||
1257 (send_requested_reply && own) ||
1258 (send_requested_reply && user) ||
1259 (send_requested_reply && group)) ||
1261 ((receive_interface && receive_error) ||
1262 (receive_interface && own) ||
1263 (receive_interface && user) ||
1264 (receive_interface && group)) ||
1266 ((receive_member && receive_error) ||
1267 (receive_member && own) ||
1268 (receive_member && user) ||
1269 (receive_member && group)) ||
1271 ((receive_error && own) ||
1272 (receive_error && user) ||
1273 (receive_error && group)) ||
1275 ((eavesdrop && own) ||
1276 (eavesdrop && user) ||
1277 (eavesdrop && group)) ||
1279 ((receive_requested_reply && own) ||
1280 (receive_requested_reply && user) ||
1281 (receive_requested_reply && group)) ||
1288 dbus_set_error (error, DBUS_ERROR_FAILED,
1289 "Invalid combination of attributes on element <%s>",
1296 /* In BusPolicyRule, NULL represents wildcard.
1297 * In the config file, '*' represents it.
1299 #define IS_WILDCARD(str) ((str) && ((str)[0]) == '*' && ((str)[1]) == '\0')
1301 if (send_interface || send_member || send_error || send_destination ||
1302 send_path || send_type || send_requested_reply)
1306 if (IS_WILDCARD (send_interface))
1307 send_interface = NULL;
1308 if (IS_WILDCARD (send_member))
1310 if (IS_WILDCARD (send_error))
1312 if (IS_WILDCARD (send_destination))
1313 send_destination = NULL;
1314 if (IS_WILDCARD (send_path))
1316 if (IS_WILDCARD (send_type))
1319 message_type = DBUS_MESSAGE_TYPE_INVALID;
1320 if (send_type != NULL)
1322 message_type = dbus_message_type_from_string (send_type);
1323 if (message_type == DBUS_MESSAGE_TYPE_INVALID)
1325 dbus_set_error (error, DBUS_ERROR_FAILED,
1326 "Bad message type \"%s\"",
1333 !(strcmp (eavesdrop, "true") == 0 ||
1334 strcmp (eavesdrop, "false") == 0))
1336 dbus_set_error (error, DBUS_ERROR_FAILED,
1337 "Bad value \"%s\" for %s attribute, must be true or false",
1338 "eavesdrop", eavesdrop);
1342 if (send_requested_reply &&
1343 !(strcmp (send_requested_reply, "true") == 0 ||
1344 strcmp (send_requested_reply, "false") == 0))
1346 dbus_set_error (error, DBUS_ERROR_FAILED,
1347 "Bad value \"%s\" for %s attribute, must be true or false",
1348 "send_requested_reply", send_requested_reply);
1352 rule = bus_policy_rule_new (BUS_POLICY_RULE_SEND, allow);
1357 rule->d.send.eavesdrop = (strcmp (eavesdrop, "true") == 0);
1359 if (send_requested_reply)
1360 rule->d.send.requested_reply = (strcmp (send_requested_reply, "true") == 0);
1362 rule->d.send.message_type = message_type;
1363 rule->d.send.path = _dbus_strdup (send_path);
1364 rule->d.send.interface = _dbus_strdup (send_interface);
1365 rule->d.send.member = _dbus_strdup (send_member);
1366 rule->d.send.error = _dbus_strdup (send_error);
1367 rule->d.send.destination = _dbus_strdup (send_destination);
1368 if (send_path && rule->d.send.path == NULL)
1370 if (send_interface && rule->d.send.interface == NULL)
1372 if (send_member && rule->d.send.member == NULL)
1374 if (send_error && rule->d.send.error == NULL)
1376 if (send_destination && rule->d.send.destination == NULL)
1379 else if (receive_interface || receive_member || receive_error || receive_sender ||
1380 receive_path || receive_type || eavesdrop || receive_requested_reply)
1384 if (IS_WILDCARD (receive_interface))
1385 receive_interface = NULL;
1386 if (IS_WILDCARD (receive_member))
1387 receive_member = NULL;
1388 if (IS_WILDCARD (receive_error))
1389 receive_error = NULL;
1390 if (IS_WILDCARD (receive_sender))
1391 receive_sender = NULL;
1392 if (IS_WILDCARD (receive_path))
1393 receive_path = NULL;
1394 if (IS_WILDCARD (receive_type))
1395 receive_type = NULL;
1397 message_type = DBUS_MESSAGE_TYPE_INVALID;
1398 if (receive_type != NULL)
1400 message_type = dbus_message_type_from_string (receive_type);
1401 if (message_type == DBUS_MESSAGE_TYPE_INVALID)
1403 dbus_set_error (error, DBUS_ERROR_FAILED,
1404 "Bad message type \"%s\"",
1412 !(strcmp (eavesdrop, "true") == 0 ||
1413 strcmp (eavesdrop, "false") == 0))
1415 dbus_set_error (error, DBUS_ERROR_FAILED,
1416 "Bad value \"%s\" for %s attribute, must be true or false",
1417 "eavesdrop", eavesdrop);
1421 if (receive_requested_reply &&
1422 !(strcmp (receive_requested_reply, "true") == 0 ||
1423 strcmp (receive_requested_reply, "false") == 0))
1425 dbus_set_error (error, DBUS_ERROR_FAILED,
1426 "Bad value \"%s\" for %s attribute, must be true or false",
1427 "receive_requested_reply", receive_requested_reply);
1431 rule = bus_policy_rule_new (BUS_POLICY_RULE_RECEIVE, allow);
1436 rule->d.receive.eavesdrop = (strcmp (eavesdrop, "true") == 0);
1438 if (receive_requested_reply)
1439 rule->d.receive.requested_reply = (strcmp (receive_requested_reply, "true") == 0);
1441 rule->d.receive.message_type = message_type;
1442 rule->d.receive.path = _dbus_strdup (receive_path);
1443 rule->d.receive.interface = _dbus_strdup (receive_interface);
1444 rule->d.receive.member = _dbus_strdup (receive_member);
1445 rule->d.receive.error = _dbus_strdup (receive_error);
1446 rule->d.receive.origin = _dbus_strdup (receive_sender);
1448 if (receive_path && rule->d.receive.path == NULL)
1450 if (receive_interface && rule->d.receive.interface == NULL)
1452 if (receive_member && rule->d.receive.member == NULL)
1454 if (receive_error && rule->d.receive.error == NULL)
1456 if (receive_sender && rule->d.receive.origin == NULL)
1461 rule = bus_policy_rule_new (BUS_POLICY_RULE_OWN, allow);
1465 if (IS_WILDCARD (own))
1468 rule->d.own.service_name = _dbus_strdup (own);
1469 if (own && rule->d.own.service_name == NULL)
1474 if (IS_WILDCARD (user))
1476 rule = bus_policy_rule_new (BUS_POLICY_RULE_USER, allow);
1480 rule->d.user.uid = DBUS_UID_UNSET;
1484 DBusString username;
1487 _dbus_string_init_const (&username, user);
1489 if (_dbus_parse_unix_user_from_config (&username, &uid))
1491 rule = bus_policy_rule_new (BUS_POLICY_RULE_USER, allow);
1495 rule->d.user.uid = uid;
1499 _dbus_warn ("Unknown username \"%s\" on element <%s>\n",
1500 user, element_name);
1506 if (IS_WILDCARD (group))
1508 rule = bus_policy_rule_new (BUS_POLICY_RULE_GROUP, allow);
1512 rule->d.group.gid = DBUS_GID_UNSET;
1516 DBusString groupname;
1519 _dbus_string_init_const (&groupname, group);
1521 if (_dbus_parse_unix_group_from_config (&groupname, &gid))
1523 rule = bus_policy_rule_new (BUS_POLICY_RULE_GROUP, allow);
1527 rule->d.group.gid = gid;
1531 _dbus_warn ("Unknown group \"%s\" on element <%s>\n",
1532 group, element_name);
1537 _dbus_assert_not_reached ("Did not handle some combination of attributes on <allow> or <deny>");
1543 pe = peek_element (parser);
1544 _dbus_assert (pe != NULL);
1545 _dbus_assert (pe->type == ELEMENT_POLICY);
1547 switch (pe->d.policy.type)
1549 case POLICY_IGNORED:
1550 /* drop the rule on the floor */
1553 case POLICY_DEFAULT:
1554 if (!bus_policy_append_default_rule (parser->policy, rule))
1557 case POLICY_MANDATORY:
1558 if (!bus_policy_append_mandatory_rule (parser->policy, rule))
1562 if (!BUS_POLICY_RULE_IS_PER_CLIENT (rule))
1564 dbus_set_error (error, DBUS_ERROR_FAILED,
1565 "<%s> rule cannot be per-user because it has bus-global semantics",
1570 if (!bus_policy_append_user_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1575 if (!BUS_POLICY_RULE_IS_PER_CLIENT (rule))
1577 dbus_set_error (error, DBUS_ERROR_FAILED,
1578 "<%s> rule cannot be per-group because it has bus-global semantics",
1583 if (!bus_policy_append_group_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1589 case POLICY_CONSOLE:
1590 if (!bus_policy_append_console_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1596 bus_policy_rule_unref (rule);
1603 BUS_SET_OOM (error);
1606 bus_policy_rule_unref (rule);
1611 start_policy_child (BusConfigParser *parser,
1612 const char *element_name,
1613 const char **attribute_names,
1614 const char **attribute_values,
1617 if (strcmp (element_name, "allow") == 0)
1619 if (!append_rule_from_element (parser, element_name,
1620 attribute_names, attribute_values,
1624 if (push_element (parser, ELEMENT_ALLOW) == NULL)
1626 BUS_SET_OOM (error);
1632 else if (strcmp (element_name, "deny") == 0)
1634 if (!append_rule_from_element (parser, element_name,
1635 attribute_names, attribute_values,
1639 if (push_element (parser, ELEMENT_DENY) == NULL)
1641 BUS_SET_OOM (error);
1649 dbus_set_error (error, DBUS_ERROR_FAILED,
1650 "Element <%s> not allowed inside <%s> in configuration file",
1651 element_name, "policy");
1657 start_selinux_child (BusConfigParser *parser,
1658 const char *element_name,
1659 const char **attribute_names,
1660 const char **attribute_values,
1667 context_copy = NULL;
1669 if (strcmp (element_name, "associate") == 0)
1672 const char *context;
1674 if (!locate_attributes (parser, "associate",
1679 "context", &context,
1683 if (push_element (parser, ELEMENT_ASSOCIATE) == NULL)
1685 BUS_SET_OOM (error);
1689 if (own == NULL || context == NULL)
1691 dbus_set_error (error, DBUS_ERROR_FAILED,
1692 "Element <associate> must have attributes own=\"<servicename>\" and context=\"<selinux context>\"");
1696 own_copy = _dbus_strdup (own);
1697 if (own_copy == NULL)
1699 context_copy = _dbus_strdup (context);
1700 if (context_copy == NULL)
1703 if (!_dbus_hash_table_insert_string (parser->service_context_table,
1704 own_copy, context_copy))
1711 dbus_set_error (error, DBUS_ERROR_FAILED,
1712 "Element <%s> not allowed inside <%s> in configuration file",
1713 element_name, "selinux");
1719 dbus_free (own_copy);
1722 dbus_free (context_copy);
1724 BUS_SET_OOM (error);
1729 bus_config_parser_start_element (BusConfigParser *parser,
1730 const char *element_name,
1731 const char **attribute_names,
1732 const char **attribute_values,
1737 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1739 /* printf ("START: %s\n", element_name); */
1741 t = top_element_type (parser);
1743 if (t == ELEMENT_NONE)
1745 if (strcmp (element_name, "busconfig") == 0)
1747 if (!check_no_attributes (parser, "busconfig", attribute_names, attribute_values, error))
1750 if (push_element (parser, ELEMENT_BUSCONFIG) == NULL)
1752 BUS_SET_OOM (error);
1760 dbus_set_error (error, DBUS_ERROR_FAILED,
1761 "Unknown element <%s> at root of configuration file",
1766 else if (t == ELEMENT_BUSCONFIG)
1768 return start_busconfig_child (parser, element_name,
1769 attribute_names, attribute_values,
1772 else if (t == ELEMENT_POLICY)
1774 return start_policy_child (parser, element_name,
1775 attribute_names, attribute_values,
1778 else if (t == ELEMENT_SELINUX)
1780 return start_selinux_child (parser, element_name,
1781 attribute_names, attribute_values,
1786 dbus_set_error (error, DBUS_ERROR_FAILED,
1787 "Element <%s> is not allowed in this context",
1794 set_limit (BusConfigParser *parser,
1799 dbus_bool_t must_be_positive;
1800 dbus_bool_t must_be_int;
1802 must_be_int = FALSE;
1803 must_be_positive = FALSE;
1805 if (strcmp (name, "max_incoming_bytes") == 0)
1807 must_be_positive = TRUE;
1808 parser->limits.max_incoming_bytes = value;
1810 else if (strcmp (name, "max_outgoing_bytes") == 0)
1812 must_be_positive = TRUE;
1813 parser->limits.max_outgoing_bytes = value;
1815 else if (strcmp (name, "max_message_size") == 0)
1817 must_be_positive = TRUE;
1818 parser->limits.max_message_size = value;
1820 else if (strcmp (name, "service_start_timeout") == 0)
1822 must_be_positive = TRUE;
1824 parser->limits.activation_timeout = value;
1826 else if (strcmp (name, "auth_timeout") == 0)
1828 must_be_positive = TRUE;
1830 parser->limits.auth_timeout = value;
1832 else if (strcmp (name, "reply_timeout") == 0)
1834 must_be_positive = TRUE;
1836 parser->limits.reply_timeout = value;
1838 else if (strcmp (name, "max_completed_connections") == 0)
1840 must_be_positive = TRUE;
1842 parser->limits.max_completed_connections = value;
1844 else if (strcmp (name, "max_incomplete_connections") == 0)
1846 must_be_positive = TRUE;
1848 parser->limits.max_incomplete_connections = value;
1850 else if (strcmp (name, "max_connections_per_user") == 0)
1852 must_be_positive = TRUE;
1854 parser->limits.max_connections_per_user = value;
1856 else if (strcmp (name, "max_pending_service_starts") == 0)
1858 must_be_positive = TRUE;
1860 parser->limits.max_pending_activations = value;
1862 else if (strcmp (name, "max_names_per_connection") == 0)
1864 must_be_positive = TRUE;
1866 parser->limits.max_services_per_connection = value;
1868 else if (strcmp (name, "max_match_rules_per_connection") == 0)
1870 must_be_positive = TRUE;
1872 parser->limits.max_match_rules_per_connection = value;
1874 else if (strcmp (name, "max_replies_per_connection") == 0)
1876 must_be_positive = TRUE;
1878 parser->limits.max_replies_per_connection = value;
1882 dbus_set_error (error, DBUS_ERROR_FAILED,
1883 "There is no limit called \"%s\"\n",
1888 if (must_be_positive && value < 0)
1890 dbus_set_error (error, DBUS_ERROR_FAILED,
1891 "<limit name=\"%s\"> must be a positive number\n",
1897 (value < _DBUS_INT_MIN || value > _DBUS_INT_MAX))
1899 dbus_set_error (error, DBUS_ERROR_FAILED,
1900 "<limit name=\"%s\"> value is too large\n",
1909 bus_config_parser_end_element (BusConfigParser *parser,
1910 const char *element_name,
1917 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1919 /* printf ("END: %s\n", element_name); */
1921 t = top_element_type (parser);
1923 if (t == ELEMENT_NONE)
1925 /* should probably be an assertion failure but
1926 * being paranoid about XML parsers
1928 dbus_set_error (error, DBUS_ERROR_FAILED,
1929 "XML parser ended element with no element on the stack");
1933 n = bus_config_parser_element_type_to_name (t);
1934 _dbus_assert (n != NULL);
1935 if (strcmp (n, element_name) != 0)
1937 /* should probably be an assertion failure but
1938 * being paranoid about XML parsers
1940 dbus_set_error (error, DBUS_ERROR_FAILED,
1941 "XML element <%s> ended but topmost element on the stack was <%s>",
1946 e = peek_element (parser);
1947 _dbus_assert (e != NULL);
1952 _dbus_assert_not_reached ("element in stack has no type");
1955 case ELEMENT_INCLUDE:
1958 case ELEMENT_LISTEN:
1959 case ELEMENT_PIDFILE:
1961 case ELEMENT_SERVICEDIR:
1962 case ELEMENT_SERVICEHELPER:
1963 case ELEMENT_INCLUDEDIR:
1965 if (!e->had_content)
1967 dbus_set_error (error, DBUS_ERROR_FAILED,
1968 "XML element <%s> was expected to have content inside it",
1969 bus_config_parser_element_type_to_name (e->type));
1973 if (e->type == ELEMENT_LIMIT)
1975 if (!set_limit (parser, e->d.limit.name, e->d.limit.value,
1981 case ELEMENT_BUSCONFIG:
1982 case ELEMENT_POLICY:
1986 case ELEMENT_KEEP_UMASK:
1987 case ELEMENT_SELINUX:
1988 case ELEMENT_ASSOCIATE:
1989 case ELEMENT_STANDARD_SESSION_SERVICEDIRS:
1990 case ELEMENT_STANDARD_SYSTEM_SERVICEDIRS:
1991 case ELEMENT_ALLOW_ANONYMOUS:
1995 pop_element (parser);
2001 all_whitespace (const DBusString *str)
2005 _dbus_string_skip_white (str, 0, &i);
2007 return i == _dbus_string_get_length (str);
2011 make_full_path (const DBusString *basedir,
2012 const DBusString *filename,
2013 DBusString *full_path)
2015 if (_dbus_path_is_absolute (filename))
2017 return _dbus_string_copy (filename, 0, full_path, 0);
2021 if (!_dbus_string_copy (basedir, 0, full_path, 0))
2024 if (!_dbus_concat_dir_and_file (full_path, filename))
2032 include_file (BusConfigParser *parser,
2033 const DBusString *filename,
2034 dbus_bool_t ignore_missing,
2037 /* FIXME good test case for this would load each config file in the
2038 * test suite both alone, and as an include, and check
2039 * that the result is the same
2041 BusConfigParser *included;
2042 const char *filename_str;
2043 DBusError tmp_error;
2045 dbus_error_init (&tmp_error);
2047 filename_str = _dbus_string_get_const_data (filename);
2049 /* Check to make sure this file hasn't already been included. */
2050 if (seen_include (parser, filename))
2052 dbus_set_error (error, DBUS_ERROR_FAILED,
2053 "Circular inclusion of file '%s'",
2058 if (! _dbus_list_append (&parser->included_files, (void *) filename_str))
2060 BUS_SET_OOM (error);
2064 /* Since parser is passed in as the parent, included
2065 inherits parser's limits. */
2066 included = bus_config_load (filename, FALSE, parser, &tmp_error);
2068 _dbus_list_pop_last (&parser->included_files);
2070 if (included == NULL)
2072 _DBUS_ASSERT_ERROR_IS_SET (&tmp_error);
2074 if (dbus_error_has_name (&tmp_error, DBUS_ERROR_FILE_NOT_FOUND) &&
2077 dbus_error_free (&tmp_error);
2082 dbus_move_error (&tmp_error, error);
2088 _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
2090 if (!merge_included (parser, included, error))
2092 bus_config_parser_unref (included);
2096 /* Copy included's limits back to parser. */
2097 parser->limits = included->limits;
2099 bus_config_parser_unref (included);
2105 servicehelper_path (BusConfigParser *parser,
2106 const DBusString *filename,
2109 const char *filename_str;
2110 char *servicehelper;
2112 filename_str = _dbus_string_get_const_data (filename);
2114 /* copy to avoid overwriting with NULL on OOM */
2115 servicehelper = _dbus_strdup (filename_str);
2118 if (servicehelper == NULL)
2120 BUS_SET_OOM (error);
2124 /* save the latest servicehelper only if not OOM */
2125 dbus_free (parser->servicehelper);
2126 parser->servicehelper = servicehelper;
2128 /* We don't check whether the helper exists; instead we
2129 * would just fail to ever activate anything if it doesn't.
2130 * This allows an admin to fix the problem if it doesn't exist.
2131 * It also allows the parser test suite to successfully parse
2132 * test cases without installing the helper. ;-)
2139 include_dir (BusConfigParser *parser,
2140 const DBusString *dirname,
2143 DBusString filename;
2145 DBusError tmp_error;
2149 if (!_dbus_string_init (&filename))
2151 BUS_SET_OOM (error);
2157 dir = _dbus_directory_open (dirname, error);
2162 dbus_error_init (&tmp_error);
2163 while (_dbus_directory_get_next_file (dir, &filename, &tmp_error))
2165 DBusString full_path;
2167 if (!_dbus_string_init (&full_path))
2169 BUS_SET_OOM (error);
2173 if (!_dbus_string_copy (dirname, 0, &full_path, 0))
2175 BUS_SET_OOM (error);
2176 _dbus_string_free (&full_path);
2180 if (!_dbus_concat_dir_and_file (&full_path, &filename))
2182 BUS_SET_OOM (error);
2183 _dbus_string_free (&full_path);
2187 if (_dbus_string_ends_with_c_str (&full_path, ".conf"))
2189 if (!include_file (parser, &full_path, TRUE, error))
2191 _dbus_string_free (&full_path);
2196 _dbus_string_free (&full_path);
2199 if (dbus_error_is_set (&tmp_error))
2201 dbus_move_error (&tmp_error, error);
2206 if (!_dbus_string_copy_data (dirname, &s))
2208 BUS_SET_OOM (error);
2212 if (!_dbus_list_append (&parser->conf_dirs, s))
2215 BUS_SET_OOM (error);
2222 _dbus_string_free (&filename);
2225 _dbus_directory_close (dir);
2231 bus_config_parser_content (BusConfigParser *parser,
2232 const DBusString *content,
2237 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2243 _dbus_string_get_const_data (content, &c_str);
2245 printf ("CONTENT %d bytes: %s\n", _dbus_string_get_length (content), c_str);
2249 e = peek_element (parser);
2252 dbus_set_error (error, DBUS_ERROR_FAILED,
2253 "Text content outside of any XML element in configuration file");
2256 else if (e->had_content)
2258 _dbus_assert_not_reached ("Element had multiple content blocks");
2262 switch (top_element_type (parser))
2265 _dbus_assert_not_reached ("element at top of stack has no type");
2268 case ELEMENT_BUSCONFIG:
2269 case ELEMENT_POLICY:
2273 case ELEMENT_KEEP_UMASK:
2274 case ELEMENT_STANDARD_SESSION_SERVICEDIRS:
2275 case ELEMENT_STANDARD_SYSTEM_SERVICEDIRS:
2276 case ELEMENT_ALLOW_ANONYMOUS:
2277 case ELEMENT_SELINUX:
2278 case ELEMENT_ASSOCIATE:
2279 if (all_whitespace (content))
2283 dbus_set_error (error, DBUS_ERROR_FAILED,
2284 "No text content expected inside XML element %s in configuration file",
2285 bus_config_parser_element_type_to_name (top_element_type (parser)));
2289 case ELEMENT_PIDFILE:
2293 e->had_content = TRUE;
2295 if (!_dbus_string_copy_data (content, &s))
2298 dbus_free (parser->pidfile);
2299 parser->pidfile = s;
2303 case ELEMENT_INCLUDE:
2305 DBusString full_path, selinux_policy_root;
2307 e->had_content = TRUE;
2309 if (e->d.include.if_selinux_enabled
2310 && !bus_selinux_enabled ())
2313 if (!_dbus_string_init (&full_path))
2316 if (e->d.include.selinux_root_relative)
2318 if (!bus_selinux_get_policy_root ())
2320 dbus_set_error (error, DBUS_ERROR_FAILED,
2321 "Could not determine SELinux policy root for relative inclusion");
2322 _dbus_string_free (&full_path);
2325 _dbus_string_init_const (&selinux_policy_root,
2326 bus_selinux_get_policy_root ());
2327 if (!make_full_path (&selinux_policy_root, content, &full_path))
2329 _dbus_string_free (&full_path);
2333 else if (!make_full_path (&parser->basedir, content, &full_path))
2335 _dbus_string_free (&full_path);
2339 if (!include_file (parser, &full_path,
2340 e->d.include.ignore_missing, error))
2342 _dbus_string_free (&full_path);
2346 _dbus_string_free (&full_path);
2350 case ELEMENT_SERVICEHELPER:
2352 DBusString full_path;
2354 e->had_content = TRUE;
2356 if (!_dbus_string_init (&full_path))
2359 if (!make_full_path (&parser->basedir, content, &full_path))
2361 _dbus_string_free (&full_path);
2365 if (!servicehelper_path (parser, &full_path, error))
2367 _dbus_string_free (&full_path);
2371 _dbus_string_free (&full_path);
2375 case ELEMENT_INCLUDEDIR:
2377 DBusString full_path;
2379 e->had_content = TRUE;
2381 if (!_dbus_string_init (&full_path))
2384 if (!make_full_path (&parser->basedir, content, &full_path))
2386 _dbus_string_free (&full_path);
2390 if (!include_dir (parser, &full_path, error))
2392 _dbus_string_free (&full_path);
2396 _dbus_string_free (&full_path);
2404 e->had_content = TRUE;
2406 if (!_dbus_string_copy_data (content, &s))
2409 dbus_free (parser->user);
2418 e->had_content = TRUE;
2420 if (!_dbus_string_copy_data (content, &s))
2423 dbus_free (parser->bus_type);
2424 parser->bus_type = s;
2428 case ELEMENT_LISTEN:
2432 e->had_content = TRUE;
2434 if (!_dbus_string_copy_data (content, &s))
2437 if (!_dbus_list_append (&parser->listen_on,
2450 e->had_content = TRUE;
2452 if (!_dbus_string_copy_data (content, &s))
2455 if (!_dbus_list_append (&parser->mechanisms,
2464 case ELEMENT_SERVICEDIR:
2467 DBusString full_path;
2469 e->had_content = TRUE;
2471 if (!_dbus_string_init (&full_path))
2474 if (!make_full_path (&parser->basedir, content, &full_path))
2476 _dbus_string_free (&full_path);
2480 if (!_dbus_string_copy_data (&full_path, &s))
2482 _dbus_string_free (&full_path);
2486 /* _only_ extra session directories can be specified */
2487 if (!service_dirs_append_unique_or_free (&parser->service_dirs, s))
2489 _dbus_string_free (&full_path);
2494 _dbus_string_free (&full_path);
2502 e->had_content = TRUE;
2505 if (!_dbus_string_parse_int (content, 0, &val, NULL))
2507 dbus_set_error (error, DBUS_ERROR_FAILED,
2508 "<limit name=\"%s\"> element has invalid value (could not parse as integer)",
2513 e->d.limit.value = val;
2515 _dbus_verbose ("Loaded value %ld for limit %s\n",
2522 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2526 BUS_SET_OOM (error);
2531 bus_config_parser_finished (BusConfigParser *parser,
2534 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2536 if (parser->stack != NULL)
2538 dbus_set_error (error, DBUS_ERROR_FAILED,
2539 "Element <%s> was not closed in configuration file",
2540 bus_config_parser_element_type_to_name (top_element_type (parser)));
2545 if (parser->is_toplevel && parser->listen_on == NULL)
2547 dbus_set_error (error, DBUS_ERROR_FAILED,
2548 "Configuration file needs one or more <listen> elements giving addresses");
2556 bus_config_parser_get_user (BusConfigParser *parser)
2558 return parser->user;
2562 bus_config_parser_get_type (BusConfigParser *parser)
2564 return parser->bus_type;
2568 bus_config_parser_get_addresses (BusConfigParser *parser)
2570 return &parser->listen_on;
2574 bus_config_parser_get_mechanisms (BusConfigParser *parser)
2576 return &parser->mechanisms;
2580 bus_config_parser_get_service_dirs (BusConfigParser *parser)
2582 return &parser->service_dirs;
2586 bus_config_parser_get_conf_dirs (BusConfigParser *parser)
2588 return &parser->conf_dirs;
2592 bus_config_parser_get_fork (BusConfigParser *parser)
2594 return parser->fork;
2598 bus_config_parser_get_keep_umask (BusConfigParser *parser)
2600 return parser->keep_umask;
2604 bus_config_parser_get_allow_anonymous (BusConfigParser *parser)
2606 return parser->allow_anonymous;
2610 bus_config_parser_get_pidfile (BusConfigParser *parser)
2612 return parser->pidfile;
2616 bus_config_parser_get_servicehelper (BusConfigParser *parser)
2618 return parser->servicehelper;
2622 bus_config_parser_steal_policy (BusConfigParser *parser)
2626 _dbus_assert (parser->policy != NULL); /* can only steal the policy 1 time */
2628 policy = parser->policy;
2630 parser->policy = NULL;
2635 /* Overwrite any limits that were set in the configuration file */
2637 bus_config_parser_get_limits (BusConfigParser *parser,
2640 *limits = parser->limits;
2644 bus_config_parser_steal_service_context_table (BusConfigParser *parser)
2646 DBusHashTable *table;
2648 _dbus_assert (parser->service_context_table != NULL); /* can only steal once */
2650 table = parser->service_context_table;
2652 parser->service_context_table = NULL;
2657 #ifdef DBUS_BUILD_TESTS
2668 do_load (const DBusString *full_path,
2670 dbus_bool_t oom_possible)
2672 BusConfigParser *parser;
2675 dbus_error_init (&error);
2677 parser = bus_config_load (full_path, TRUE, NULL, &error);
2680 _DBUS_ASSERT_ERROR_IS_SET (&error);
2683 dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
2685 _dbus_verbose ("Failed to load valid file due to OOM\n");
2686 dbus_error_free (&error);
2689 else if (validity == VALID)
2691 _dbus_warn ("Failed to load valid file but still had memory: %s\n",
2694 dbus_error_free (&error);
2699 dbus_error_free (&error);
2705 _DBUS_ASSERT_ERROR_IS_CLEAR (&error);
2707 bus_config_parser_unref (parser);
2709 if (validity == INVALID)
2711 _dbus_warn ("Accepted invalid file\n");
2721 const DBusString *full_path;
2726 check_loader_oom_func (void *data)
2728 LoaderOomData *d = data;
2730 return do_load (d->full_path, d->validity, TRUE);
2734 process_test_valid_subdir (const DBusString *test_base_dir,
2738 DBusString test_directory;
2739 DBusString filename;
2747 if (!_dbus_string_init (&test_directory))
2748 _dbus_assert_not_reached ("didn't allocate test_directory\n");
2750 _dbus_string_init_const (&filename, subdir);
2752 if (!_dbus_string_copy (test_base_dir, 0,
2753 &test_directory, 0))
2754 _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory");
2756 if (!_dbus_concat_dir_and_file (&test_directory, &filename))
2757 _dbus_assert_not_reached ("couldn't allocate full path");
2759 _dbus_string_free (&filename);
2760 if (!_dbus_string_init (&filename))
2761 _dbus_assert_not_reached ("didn't allocate filename string\n");
2763 dbus_error_init (&error);
2764 dir = _dbus_directory_open (&test_directory, &error);
2767 _dbus_warn ("Could not open %s: %s\n",
2768 _dbus_string_get_const_data (&test_directory),
2770 dbus_error_free (&error);
2774 if (validity == VALID)
2775 printf ("Testing valid files:\n");
2776 else if (validity == INVALID)
2777 printf ("Testing invalid files:\n");
2779 printf ("Testing unknown files:\n");
2782 while (_dbus_directory_get_next_file (dir, &filename, &error))
2784 DBusString full_path;
2787 if (!_dbus_string_init (&full_path))
2788 _dbus_assert_not_reached ("couldn't init string");
2790 if (!_dbus_string_copy (&test_directory, 0, &full_path, 0))
2791 _dbus_assert_not_reached ("couldn't copy dir to full_path");
2793 if (!_dbus_concat_dir_and_file (&full_path, &filename))
2794 _dbus_assert_not_reached ("couldn't concat file to dir");
2796 if (!_dbus_string_ends_with_c_str (&full_path, ".conf"))
2798 _dbus_verbose ("Skipping non-.conf file %s\n",
2799 _dbus_string_get_const_data (&filename));
2800 _dbus_string_free (&full_path);
2804 printf (" %s\n", _dbus_string_get_const_data (&filename));
2806 _dbus_verbose (" expecting %s\n",
2807 validity == VALID ? "valid" :
2808 (validity == INVALID ? "invalid" :
2809 (validity == UNKNOWN ? "unknown" : "???")));
2811 d.full_path = &full_path;
2812 d.validity = validity;
2814 /* FIXME hackaround for an expat problem, see
2815 * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=124747
2816 * http://freedesktop.org/pipermail/dbus/2004-May/001153.html
2818 /* if (!_dbus_test_oom_handling ("config-loader", check_loader_oom_func, &d)) */
2819 if (!check_loader_oom_func (&d))
2820 _dbus_assert_not_reached ("test failed");
2822 _dbus_string_free (&full_path);
2825 if (dbus_error_is_set (&error))
2827 _dbus_warn ("Could not get next file in %s: %s\n",
2828 _dbus_string_get_const_data (&test_directory),
2830 dbus_error_free (&error);
2839 _dbus_directory_close (dir);
2840 _dbus_string_free (&test_directory);
2841 _dbus_string_free (&filename);
2847 bools_equal (dbus_bool_t a,
2854 strings_equal_or_both_null (const char *a,
2857 if (a == NULL || b == NULL)
2860 return !strcmp (a, b);
2864 elements_equal (const Element *a,
2867 if (a->type != b->type)
2870 if (!bools_equal (a->had_content, b->had_content))
2876 case ELEMENT_INCLUDE:
2877 if (!bools_equal (a->d.include.ignore_missing,
2878 b->d.include.ignore_missing))
2882 case ELEMENT_POLICY:
2883 if (a->d.policy.type != b->d.policy.type)
2885 if (a->d.policy.gid_uid_or_at_console != b->d.policy.gid_uid_or_at_console)
2890 if (strcmp (a->d.limit.name, b->d.limit.name))
2892 if (a->d.limit.value != b->d.limit.value)
2906 lists_of_elements_equal (DBusList *a,
2915 while (ia != NULL && ib != NULL)
2917 if (elements_equal (ia->data, ib->data))
2919 ia = _dbus_list_get_next_link (&a, ia);
2920 ib = _dbus_list_get_next_link (&b, ib);
2923 return ia == NULL && ib == NULL;
2927 lists_of_c_strings_equal (DBusList *a,
2936 while (ia != NULL && ib != NULL)
2938 if (strcmp (ia->data, ib->data))
2940 ia = _dbus_list_get_next_link (&a, ia);
2941 ib = _dbus_list_get_next_link (&b, ib);
2944 return ia == NULL && ib == NULL;
2948 limits_equal (const BusLimits *a,
2952 (a->max_incoming_bytes == b->max_incoming_bytes
2953 || a->max_outgoing_bytes == b->max_outgoing_bytes
2954 || a->max_message_size == b->max_message_size
2955 || a->activation_timeout == b->activation_timeout
2956 || a->auth_timeout == b->auth_timeout
2957 || a->max_completed_connections == b->max_completed_connections
2958 || a->max_incomplete_connections == b->max_incomplete_connections
2959 || a->max_connections_per_user == b->max_connections_per_user
2960 || a->max_pending_activations == b->max_pending_activations
2961 || a->max_services_per_connection == b->max_services_per_connection
2962 || a->max_match_rules_per_connection == b->max_match_rules_per_connection
2963 || a->max_replies_per_connection == b->max_replies_per_connection
2964 || a->reply_timeout == b->reply_timeout);
2968 config_parsers_equal (const BusConfigParser *a,
2969 const BusConfigParser *b)
2971 if (!_dbus_string_equal (&a->basedir, &b->basedir))
2974 if (!lists_of_elements_equal (a->stack, b->stack))
2977 if (!strings_equal_or_both_null (a->user, b->user))
2980 if (!lists_of_c_strings_equal (a->listen_on, b->listen_on))
2983 if (!lists_of_c_strings_equal (a->mechanisms, b->mechanisms))
2986 if (!lists_of_c_strings_equal (a->service_dirs, b->service_dirs))
2989 /* FIXME: compare policy */
2991 /* FIXME: compare service selinux ID table */
2993 if (! limits_equal (&a->limits, &b->limits))
2996 if (!strings_equal_or_both_null (a->pidfile, b->pidfile))
2999 if (! bools_equal (a->fork, b->fork))
3002 if (! bools_equal (a->keep_umask, b->keep_umask))
3005 if (! bools_equal (a->is_toplevel, b->is_toplevel))
3012 all_are_equiv (const DBusString *target_directory)
3014 DBusString filename;
3016 BusConfigParser *first_parser;
3017 BusConfigParser *parser;
3023 first_parser = NULL;
3027 if (!_dbus_string_init (&filename))
3028 _dbus_assert_not_reached ("didn't allocate filename string");
3030 dbus_error_init (&error);
3031 dir = _dbus_directory_open (target_directory, &error);
3034 _dbus_warn ("Could not open %s: %s\n",
3035 _dbus_string_get_const_data (target_directory),
3037 dbus_error_free (&error);
3041 printf ("Comparing equivalent files:\n");
3044 while (_dbus_directory_get_next_file (dir, &filename, &error))
3046 DBusString full_path;
3048 if (!_dbus_string_init (&full_path))
3049 _dbus_assert_not_reached ("couldn't init string");
3051 if (!_dbus_string_copy (target_directory, 0, &full_path, 0))
3052 _dbus_assert_not_reached ("couldn't copy dir to full_path");
3054 if (!_dbus_concat_dir_and_file (&full_path, &filename))
3055 _dbus_assert_not_reached ("couldn't concat file to dir");
3057 if (!_dbus_string_ends_with_c_str (&full_path, ".conf"))
3059 _dbus_verbose ("Skipping non-.conf file %s\n",
3060 _dbus_string_get_const_data (&filename));
3061 _dbus_string_free (&full_path);
3065 printf (" %s\n", _dbus_string_get_const_data (&filename));
3067 parser = bus_config_load (&full_path, TRUE, NULL, &error);
3071 _dbus_warn ("Could not load file %s: %s\n",
3072 _dbus_string_get_const_data (&full_path),
3074 _dbus_string_free (&full_path);
3075 dbus_error_free (&error);
3078 else if (first_parser == NULL)
3080 _dbus_string_free (&full_path);
3081 first_parser = parser;
3085 _dbus_string_free (&full_path);
3086 equal = config_parsers_equal (first_parser, parser);
3087 bus_config_parser_unref (parser);
3096 _dbus_string_free (&filename);
3098 bus_config_parser_unref (first_parser);
3100 _dbus_directory_close (dir);
3107 process_test_equiv_subdir (const DBusString *test_base_dir,
3110 DBusString test_directory;
3111 DBusString filename;
3120 if (!_dbus_string_init (&test_directory))
3121 _dbus_assert_not_reached ("didn't allocate test_directory");
3123 _dbus_string_init_const (&filename, subdir);
3125 if (!_dbus_string_copy (test_base_dir, 0,
3126 &test_directory, 0))
3127 _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory");
3129 if (!_dbus_concat_dir_and_file (&test_directory, &filename))
3130 _dbus_assert_not_reached ("couldn't allocate full path");
3132 _dbus_string_free (&filename);
3133 if (!_dbus_string_init (&filename))
3134 _dbus_assert_not_reached ("didn't allocate filename string");
3136 dbus_error_init (&error);
3137 dir = _dbus_directory_open (&test_directory, &error);
3140 _dbus_warn ("Could not open %s: %s\n",
3141 _dbus_string_get_const_data (&test_directory),
3143 dbus_error_free (&error);
3147 while (_dbus_directory_get_next_file (dir, &filename, &error))
3149 DBusString full_path;
3151 /* Skip CVS's magic directories! */
3152 if (_dbus_string_equal_c_str (&filename, "CVS"))
3155 if (!_dbus_string_init (&full_path))
3156 _dbus_assert_not_reached ("couldn't init string");
3158 if (!_dbus_string_copy (&test_directory, 0, &full_path, 0))
3159 _dbus_assert_not_reached ("couldn't copy dir to full_path");
3161 if (!_dbus_concat_dir_and_file (&full_path, &filename))
3162 _dbus_assert_not_reached ("couldn't concat file to dir");
3164 equal = all_are_equiv (&full_path);
3165 _dbus_string_free (&full_path);
3174 _dbus_string_free (&test_directory);
3175 _dbus_string_free (&filename);
3177 _dbus_directory_close (dir);
3183 static const char *test_session_service_dir_matches[] =
3186 "/testusr/testlocal/testshare/dbus-1/services",
3187 "/testusr/testshare/dbus-1/services",
3189 DBUS_DATADIR"/dbus-1/services",
3191 "/testhome/foo/.testlocal/testshare/dbus-1/services",
3197 test_default_session_servicedirs (void)
3202 const char *common_progs;
3205 /* On Unix we don't actually use this variable, but it's easier to handle the
3206 * deallocation if we always allocate it, whether needed or not */
3207 if (!_dbus_string_init (&progs))
3208 _dbus_assert_not_reached ("OOM allocating progs");
3210 common_progs = _dbus_getenv ("CommonProgramFiles");
3214 if (!_dbus_string_append (&progs, common_progs))
3216 _dbus_string_free (&progs);
3220 if (!_dbus_string_append (&progs, "/dbus-1/services"))
3222 _dbus_string_free (&progs);
3225 test_session_service_dir_matches[1] = _dbus_string_get_const_data(&progs);
3230 printf ("Testing retrieving the default session service directories\n");
3231 if (!_dbus_get_standard_session_servicedirs (&dirs))
3232 _dbus_assert_not_reached ("couldn't get stardard dirs");
3234 /* make sure our defaults end with share/dbus-1/service */
3235 while ((link = _dbus_list_pop_first_link (&dirs)))
3239 printf (" default service dir: %s\n", (char *)link->data);
3240 _dbus_string_init_const (&path, (char *)link->data);
3241 if (!_dbus_string_ends_with_c_str (&path, "dbus-1/services"))
3243 printf ("error with default session service directories\n");
3244 dbus_free (link->data);
3245 _dbus_list_free_link (link);
3246 _dbus_string_free (&progs);
3250 dbus_free (link->data);
3251 _dbus_list_free_link (link);
3255 if (!_dbus_setenv ("XDG_DATA_HOME", "/testhome/foo/.testlocal/testshare"))
3256 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_HOME");
3258 if (!_dbus_setenv ("XDG_DATA_DIRS", ":/testusr/testlocal/testshare: :/testusr/testshare:"))
3259 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_DIRS");
3261 if (!_dbus_get_standard_session_servicedirs (&dirs))
3262 _dbus_assert_not_reached ("couldn't get stardard dirs");
3264 /* make sure we read and parse the env variable correctly */
3266 while ((link = _dbus_list_pop_first_link (&dirs)))
3268 printf (" test service dir: %s\n", (char *)link->data);
3269 if (test_session_service_dir_matches[i] == NULL)
3271 printf ("more directories parsed than in match set\n");
3272 dbus_free (link->data);
3273 _dbus_list_free_link (link);
3274 _dbus_string_free (&progs);
3278 if (strcmp (test_session_service_dir_matches[i],
3279 (char *)link->data) != 0)
3281 printf ("%s directory does not match %s in the match set\n",
3283 test_session_service_dir_matches[i]);
3284 dbus_free (link->data);
3285 _dbus_list_free_link (link);
3286 _dbus_string_free (&progs);
3292 dbus_free (link->data);
3293 _dbus_list_free_link (link);
3296 if (test_session_service_dir_matches[i] != NULL)
3298 printf ("extra data %s in the match set was not matched\n",
3299 test_session_service_dir_matches[i]);
3301 _dbus_string_free (&progs);
3305 _dbus_string_free (&progs);
3309 static const char *test_system_service_dir_matches[] =
3312 "/testusr/testlocal/testshare/dbus-1/system-services",
3313 "/testusr/testshare/dbus-1/system-services",
3315 DBUS_DATADIR"/dbus-1/system-services",
3320 test_default_system_servicedirs (void)
3325 const char *common_progs;
3328 /* On Unix we don't actually use this variable, but it's easier to handle the
3329 * deallocation if we always allocate it, whether needed or not */
3330 if (!_dbus_string_init (&progs))
3331 _dbus_assert_not_reached ("OOM allocating progs");
3333 common_progs = _dbus_getenv ("CommonProgramFiles");
3337 if (!_dbus_string_append (&progs, common_progs))
3339 _dbus_string_free (&progs);
3343 if (!_dbus_string_append (&progs, "/dbus-1/system-services"))
3345 _dbus_string_free (&progs);
3348 test_system_service_dir_matches[1] = _dbus_string_get_const_data(&progs);
3353 printf ("Testing retrieving the default system service directories\n");
3354 if (!_dbus_get_standard_system_servicedirs (&dirs))
3355 _dbus_assert_not_reached ("couldn't get stardard dirs");
3357 /* make sure our defaults end with share/dbus-1/system-service */
3358 while ((link = _dbus_list_pop_first_link (&dirs)))
3362 printf (" default service dir: %s\n", (char *)link->data);
3363 _dbus_string_init_const (&path, (char *)link->data);
3364 if (!_dbus_string_ends_with_c_str (&path, "dbus-1/system-services"))
3366 printf ("error with default system service directories\n");
3367 dbus_free (link->data);
3368 _dbus_list_free_link (link);
3369 _dbus_string_free (&progs);
3373 dbus_free (link->data);
3374 _dbus_list_free_link (link);
3378 if (!_dbus_setenv ("XDG_DATA_HOME", "/testhome/foo/.testlocal/testshare"))
3379 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_HOME");
3381 if (!_dbus_setenv ("XDG_DATA_DIRS", ":/testusr/testlocal/testshare: :/testusr/testshare:"))
3382 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_DIRS");
3384 if (!_dbus_get_standard_system_servicedirs (&dirs))
3385 _dbus_assert_not_reached ("couldn't get stardard dirs");
3387 /* make sure we read and parse the env variable correctly */
3389 while ((link = _dbus_list_pop_first_link (&dirs)))
3391 printf (" test service dir: %s\n", (char *)link->data);
3392 if (test_system_service_dir_matches[i] == NULL)
3394 printf ("more directories parsed than in match set\n");
3395 dbus_free (link->data);
3396 _dbus_list_free_link (link);
3397 _dbus_string_free (&progs);
3401 if (strcmp (test_system_service_dir_matches[i],
3402 (char *)link->data) != 0)
3404 printf ("%s directory does not match %s in the match set\n",
3406 test_system_service_dir_matches[i]);
3407 dbus_free (link->data);
3408 _dbus_list_free_link (link);
3409 _dbus_string_free (&progs);
3415 dbus_free (link->data);
3416 _dbus_list_free_link (link);
3419 if (test_system_service_dir_matches[i] != NULL)
3421 printf ("extra data %s in the match set was not matched\n",
3422 test_system_service_dir_matches[i]);
3424 _dbus_string_free (&progs);
3428 _dbus_string_free (&progs);
3433 bus_config_parser_test (const DBusString *test_data_dir)
3435 if (test_data_dir == NULL ||
3436 _dbus_string_get_length (test_data_dir) == 0)
3438 printf ("No test data\n");
3442 if (!test_default_session_servicedirs())
3445 if (!test_default_system_servicedirs())
3448 if (!process_test_valid_subdir (test_data_dir, "valid-config-files", VALID))
3451 if (!process_test_valid_subdir (test_data_dir, "invalid-config-files", INVALID))
3454 if (!process_test_equiv_subdir (test_data_dir, "equiv-config-files"))
3460 #endif /* DBUS_BUILD_TESTS */