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 syslog : 1; /**< TRUE to enable syslog */
118 unsigned int is_toplevel : 1; /**< FALSE if we are a sub-config-file inside another one */
120 unsigned int allow_anonymous : 1; /**< TRUE to allow anonymous connections */
124 push_element (BusConfigParser *parser,
129 _dbus_assert (type != ELEMENT_NONE);
131 e = dbus_new0 (Element, 1);
135 if (!_dbus_list_append (&parser->stack, e))
147 element_free (Element *e)
149 if (e->type == ELEMENT_LIMIT)
150 dbus_free (e->d.limit.name);
156 pop_element (BusConfigParser *parser)
160 e = _dbus_list_pop_last (&parser->stack);
166 peek_element (BusConfigParser *parser)
170 e = _dbus_list_get_last (&parser->stack);
176 top_element_type (BusConfigParser *parser)
180 e = _dbus_list_get_last (&parser->stack);
189 merge_service_context_hash (DBusHashTable *dest,
199 _dbus_hash_iter_init (from, &iter);
200 while (_dbus_hash_iter_next (&iter))
202 const char *service = _dbus_hash_iter_get_string_key (&iter);
203 const char *context = _dbus_hash_iter_get_value (&iter);
205 service_copy = _dbus_strdup (service);
206 if (service_copy == NULL)
208 context_copy = _dbus_strdup (context);
209 if (context_copy == NULL)
212 if (!_dbus_hash_table_insert_string (dest, service_copy, context_copy))
223 dbus_free (service_copy);
226 dbus_free (context_copy);
232 service_dirs_find_dir (DBusList **service_dirs,
237 _dbus_assert (dir != NULL);
239 for (link = *service_dirs; link; link = _dbus_list_get_next_link(service_dirs, link))
241 const char *link_dir;
243 link_dir = (const char *)link->data;
244 if (strcmp (dir, link_dir) == 0)
252 service_dirs_append_unique_or_free (DBusList **service_dirs,
255 if (!service_dirs_find_dir (service_dirs, dir))
256 return _dbus_list_append (service_dirs, dir);
263 service_dirs_append_link_unique_or_free (DBusList **service_dirs,
266 if (!service_dirs_find_dir (service_dirs, dir_link->data))
268 _dbus_list_append_link (service_dirs, dir_link);
272 dbus_free (dir_link->data);
273 _dbus_list_free_link (dir_link);
278 merge_included (BusConfigParser *parser,
279 BusConfigParser *included,
284 if (!bus_policy_merge (parser->policy,
291 if (!merge_service_context_hash (parser->service_context_table,
292 included->service_context_table))
298 if (included->user != NULL)
300 dbus_free (parser->user);
301 parser->user = included->user;
302 included->user = NULL;
305 if (included->bus_type != NULL)
307 dbus_free (parser->bus_type);
308 parser->bus_type = included->bus_type;
309 included->bus_type = NULL;
315 if (included->keep_umask)
316 parser->keep_umask = TRUE;
318 if (included->pidfile != NULL)
320 dbus_free (parser->pidfile);
321 parser->pidfile = included->pidfile;
322 included->pidfile = NULL;
325 while ((link = _dbus_list_pop_first_link (&included->listen_on)))
326 _dbus_list_append_link (&parser->listen_on, link);
328 while ((link = _dbus_list_pop_first_link (&included->mechanisms)))
329 _dbus_list_append_link (&parser->mechanisms, link);
331 while ((link = _dbus_list_pop_first_link (&included->service_dirs)))
332 service_dirs_append_link_unique_or_free (&parser->service_dirs, link);
334 while ((link = _dbus_list_pop_first_link (&included->conf_dirs)))
335 _dbus_list_append_link (&parser->conf_dirs, link);
341 seen_include (BusConfigParser *parser,
342 const DBusString *file)
346 iter = parser->included_files;
349 if (! strcmp (_dbus_string_get_const_data (file), iter->data))
352 iter = _dbus_list_get_next_link (&parser->included_files, iter);
359 bus_config_parser_new (const DBusString *basedir,
360 dbus_bool_t is_toplevel,
361 const BusConfigParser *parent)
363 BusConfigParser *parser;
365 parser = dbus_new0 (BusConfigParser, 1);
369 parser->is_toplevel = !!is_toplevel;
371 if (!_dbus_string_init (&parser->basedir))
377 if (((parser->policy = bus_policy_new ()) == NULL) ||
378 !_dbus_string_copy (basedir, 0, &parser->basedir, 0) ||
379 ((parser->service_context_table = _dbus_hash_table_new (DBUS_HASH_STRING,
381 dbus_free)) == NULL))
384 bus_policy_unref (parser->policy);
386 _dbus_string_free (&parser->basedir);
394 /* Initialize the parser's limits from the parent. */
395 parser->limits = parent->limits;
397 /* Use the parent's list of included_files to avoid
398 circular inclusions. */
399 parser->included_files = parent->included_files;
404 /* Make up some numbers! woot! */
405 parser->limits.max_incoming_bytes = _DBUS_ONE_MEGABYTE * 127;
406 parser->limits.max_outgoing_bytes = _DBUS_ONE_MEGABYTE * 127;
407 parser->limits.max_message_size = _DBUS_ONE_MEGABYTE * 32;
409 /* Making this long means the user has to wait longer for an error
410 * message if something screws up, but making it too short means
411 * they might see a false failure.
413 parser->limits.activation_timeout = 25000; /* 25 seconds */
415 /* Making this long risks making a DOS attack easier, but too short
416 * and legitimate auth will fail. If interactive auth (ask user for
417 * password) is allowed, then potentially it has to be quite long.
419 parser->limits.auth_timeout = 30000; /* 30 seconds */
421 parser->limits.max_incomplete_connections = 64;
422 parser->limits.max_connections_per_user = 256;
424 /* Note that max_completed_connections / max_connections_per_user
425 * is the number of users that would have to work together to
426 * DOS all the other users.
428 parser->limits.max_completed_connections = 2048;
430 parser->limits.max_pending_activations = 512;
431 parser->limits.max_services_per_connection = 512;
433 /* For this one, keep in mind that it isn't only the memory used
434 * by the match rules, but slowdown from linearly walking a big
435 * list of them. A client adding more than this is almost
436 * certainly a bad idea for that reason, and should change to a
437 * smaller number of wider-net match rules - getting every last
438 * message to the bus is probably better than having a thousand
441 parser->limits.max_match_rules_per_connection = 512;
443 parser->limits.reply_timeout = 5 * 60 * 1000; /* 5 minutes */
445 /* this is effectively a limit on message queue size for messages
446 * that require a reply
448 parser->limits.max_replies_per_connection = 1024*8;
451 parser->refcount = 1;
457 bus_config_parser_ref (BusConfigParser *parser)
459 _dbus_assert (parser->refcount > 0);
461 parser->refcount += 1;
467 bus_config_parser_unref (BusConfigParser *parser)
469 _dbus_assert (parser->refcount > 0);
471 parser->refcount -= 1;
473 if (parser->refcount == 0)
475 while (parser->stack != NULL)
476 pop_element (parser);
478 dbus_free (parser->user);
479 dbus_free (parser->servicehelper);
480 dbus_free (parser->bus_type);
481 dbus_free (parser->pidfile);
483 _dbus_list_foreach (&parser->listen_on,
484 (DBusForeachFunction) dbus_free,
487 _dbus_list_clear (&parser->listen_on);
489 _dbus_list_foreach (&parser->service_dirs,
490 (DBusForeachFunction) dbus_free,
493 _dbus_list_clear (&parser->service_dirs);
495 _dbus_list_foreach (&parser->conf_dirs,
496 (DBusForeachFunction) dbus_free,
499 _dbus_list_clear (&parser->conf_dirs);
501 _dbus_list_foreach (&parser->mechanisms,
502 (DBusForeachFunction) dbus_free,
505 _dbus_list_clear (&parser->mechanisms);
507 _dbus_string_free (&parser->basedir);
510 bus_policy_unref (parser->policy);
512 if (parser->service_context_table)
513 _dbus_hash_table_unref (parser->service_context_table);
520 bus_config_parser_check_doctype (BusConfigParser *parser,
524 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
526 if (strcmp (doctype, "busconfig") != 0)
528 dbus_set_error (error,
530 "Configuration file has the wrong document type %s",
545 locate_attributes (BusConfigParser *parser,
546 const char *element_name,
547 const char **attribute_names,
548 const char **attribute_values,
550 const char *first_attribute_name,
551 const char **first_attribute_retloc,
559 LocateAttr attrs[MAX_ATTRS];
563 _dbus_assert (first_attribute_name != NULL);
564 _dbus_assert (first_attribute_retloc != NULL);
569 attrs[0].name = first_attribute_name;
570 attrs[0].retloc = first_attribute_retloc;
571 *first_attribute_retloc = NULL;
573 va_start (args, first_attribute_retloc);
575 name = va_arg (args, const char*);
576 retloc = va_arg (args, const char**);
580 _dbus_assert (retloc != NULL);
581 _dbus_assert (n_attrs < MAX_ATTRS);
583 attrs[n_attrs].name = name;
584 attrs[n_attrs].retloc = retloc;
588 name = va_arg (args, const char*);
589 retloc = va_arg (args, const char**);
595 while (attribute_names[i])
604 if (strcmp (attrs[j].name, attribute_names[i]) == 0)
606 retloc = attrs[j].retloc;
610 dbus_set_error (error, DBUS_ERROR_FAILED,
611 "Attribute \"%s\" repeated twice on the same <%s> element",
612 attrs[j].name, element_name);
617 *retloc = attribute_values[i];
626 dbus_set_error (error, DBUS_ERROR_FAILED,
627 "Attribute \"%s\" is invalid on <%s> element in this context",
628 attribute_names[i], element_name);
641 check_no_attributes (BusConfigParser *parser,
642 const char *element_name,
643 const char **attribute_names,
644 const char **attribute_values,
647 if (attribute_names[0] != NULL)
649 dbus_set_error (error, DBUS_ERROR_FAILED,
650 "Attribute \"%s\" is invalid on <%s> element in this context",
651 attribute_names[0], element_name);
659 start_busconfig_child (BusConfigParser *parser,
660 const char *element_name,
661 const char **attribute_names,
662 const char **attribute_values,
665 ElementType element_type;
667 element_type = bus_config_parser_element_name_to_type (element_name);
669 if (element_type == ELEMENT_USER)
671 if (!check_no_attributes (parser, "user", attribute_names, attribute_values, error))
674 if (push_element (parser, ELEMENT_USER) == NULL)
682 else if (element_type == ELEMENT_TYPE)
684 if (!check_no_attributes (parser, "type", attribute_names, attribute_values, error))
687 if (push_element (parser, ELEMENT_TYPE) == NULL)
695 else if (element_type == ELEMENT_FORK)
697 if (!check_no_attributes (parser, "fork", attribute_names, attribute_values, error))
700 if (push_element (parser, ELEMENT_FORK) == NULL)
710 else if (element_type == ELEMENT_KEEP_UMASK)
712 if (!check_no_attributes (parser, "keep_umask", attribute_names, attribute_values, error))
715 if (push_element (parser, ELEMENT_KEEP_UMASK) == NULL)
721 parser->keep_umask = TRUE;
725 else if (element_type == ELEMENT_SYSLOG)
727 if (!check_no_attributes (parser, "syslog", attribute_names, attribute_values, error))
730 if (push_element (parser, ELEMENT_SYSLOG) == NULL)
736 parser->syslog = TRUE;
740 else if (element_type == ELEMENT_PIDFILE)
742 if (!check_no_attributes (parser, "pidfile", attribute_names, attribute_values, error))
745 if (push_element (parser, ELEMENT_PIDFILE) == NULL)
753 else if (element_type == ELEMENT_LISTEN)
755 if (!check_no_attributes (parser, "listen", attribute_names, attribute_values, error))
758 if (push_element (parser, ELEMENT_LISTEN) == NULL)
766 else if (element_type == ELEMENT_AUTH)
768 if (!check_no_attributes (parser, "auth", attribute_names, attribute_values, error))
771 if (push_element (parser, ELEMENT_AUTH) == NULL)
779 else if (element_type == ELEMENT_SERVICEHELPER)
781 if (!check_no_attributes (parser, "servicehelper", attribute_names, attribute_values, error))
784 if (push_element (parser, ELEMENT_SERVICEHELPER) == NULL)
792 else if (element_type == ELEMENT_INCLUDEDIR)
794 if (!check_no_attributes (parser, "includedir", attribute_names, attribute_values, error))
797 if (push_element (parser, ELEMENT_INCLUDEDIR) == NULL)
805 else if (element_type == ELEMENT_STANDARD_SESSION_SERVICEDIRS)
811 if (!check_no_attributes (parser, "standard_session_servicedirs", attribute_names, attribute_values, error))
814 if (push_element (parser, ELEMENT_STANDARD_SESSION_SERVICEDIRS) == NULL)
820 if (!_dbus_get_standard_session_servicedirs (&dirs))
826 while ((link = _dbus_list_pop_first_link (&dirs)))
827 service_dirs_append_link_unique_or_free (&parser->service_dirs, link);
831 else if (element_type == ELEMENT_STANDARD_SYSTEM_SERVICEDIRS)
837 if (!check_no_attributes (parser, "standard_system_servicedirs", attribute_names, attribute_values, error))
840 if (push_element (parser, ELEMENT_STANDARD_SYSTEM_SERVICEDIRS) == NULL)
846 if (!_dbus_get_standard_system_servicedirs (&dirs))
852 while ((link = _dbus_list_pop_first_link (&dirs)))
853 service_dirs_append_link_unique_or_free (&parser->service_dirs, link);
857 else if (element_type == ELEMENT_ALLOW_ANONYMOUS)
859 if (!check_no_attributes (parser, "allow_anonymous", attribute_names, attribute_values, error))
862 if (push_element (parser, ELEMENT_ALLOW_ANONYMOUS) == NULL)
868 parser->allow_anonymous = TRUE;
871 else if (element_type == ELEMENT_SERVICEDIR)
873 if (!check_no_attributes (parser, "servicedir", attribute_names, attribute_values, error))
876 if (push_element (parser, ELEMENT_SERVICEDIR) == NULL)
884 else if (element_type == ELEMENT_INCLUDE)
887 const char *if_selinux_enabled;
888 const char *ignore_missing;
889 const char *selinux_root_relative;
891 if ((e = push_element (parser, ELEMENT_INCLUDE)) == NULL)
897 e->d.include.ignore_missing = FALSE;
898 e->d.include.if_selinux_enabled = FALSE;
899 e->d.include.selinux_root_relative = FALSE;
901 if (!locate_attributes (parser, "include",
905 "ignore_missing", &ignore_missing,
906 "if_selinux_enabled", &if_selinux_enabled,
907 "selinux_root_relative", &selinux_root_relative,
911 if (ignore_missing != NULL)
913 if (strcmp (ignore_missing, "yes") == 0)
914 e->d.include.ignore_missing = TRUE;
915 else if (strcmp (ignore_missing, "no") == 0)
916 e->d.include.ignore_missing = FALSE;
919 dbus_set_error (error, DBUS_ERROR_FAILED,
920 "ignore_missing attribute must have value \"yes\" or \"no\"");
925 if (if_selinux_enabled != NULL)
927 if (strcmp (if_selinux_enabled, "yes") == 0)
928 e->d.include.if_selinux_enabled = TRUE;
929 else if (strcmp (if_selinux_enabled, "no") == 0)
930 e->d.include.if_selinux_enabled = FALSE;
933 dbus_set_error (error, DBUS_ERROR_FAILED,
934 "if_selinux_enabled attribute must have value"
935 " \"yes\" or \"no\"");
940 if (selinux_root_relative != NULL)
942 if (strcmp (selinux_root_relative, "yes") == 0)
943 e->d.include.selinux_root_relative = TRUE;
944 else if (strcmp (selinux_root_relative, "no") == 0)
945 e->d.include.selinux_root_relative = FALSE;
948 dbus_set_error (error, DBUS_ERROR_FAILED,
949 "selinux_root_relative attribute must have value"
950 " \"yes\" or \"no\"");
957 else if (element_type == ELEMENT_POLICY)
963 const char *at_console;
965 if ((e = push_element (parser, ELEMENT_POLICY)) == NULL)
971 e->d.policy.type = POLICY_IGNORED;
973 if (!locate_attributes (parser, "policy",
980 "at_console", &at_console,
984 if (((context && user) ||
985 (context && group) ||
986 (context && at_console)) ||
988 (user && at_console)) ||
989 (group && at_console) ||
990 !(context || user || group || at_console))
992 dbus_set_error (error, DBUS_ERROR_FAILED,
993 "<policy> element must have exactly one of (context|user|group|at_console) attributes");
999 if (strcmp (context, "default") == 0)
1001 e->d.policy.type = POLICY_DEFAULT;
1003 else if (strcmp (context, "mandatory") == 0)
1005 e->d.policy.type = POLICY_MANDATORY;
1009 dbus_set_error (error, DBUS_ERROR_FAILED,
1010 "context attribute on <policy> must have the value \"default\" or \"mandatory\", not \"%s\"",
1015 else if (user != NULL)
1017 DBusString username;
1018 _dbus_string_init_const (&username, user);
1020 if (_dbus_parse_unix_user_from_config (&username,
1021 &e->d.policy.gid_uid_or_at_console))
1022 e->d.policy.type = POLICY_USER;
1024 _dbus_warn ("Unknown username \"%s\" in message bus configuration file\n",
1027 else if (group != NULL)
1029 DBusString group_name;
1030 _dbus_string_init_const (&group_name, group);
1032 if (_dbus_parse_unix_group_from_config (&group_name,
1033 &e->d.policy.gid_uid_or_at_console))
1034 e->d.policy.type = POLICY_GROUP;
1036 _dbus_warn ("Unknown group \"%s\" in message bus configuration file\n",
1039 else if (at_console != NULL)
1042 t = (strcmp (at_console, "true") == 0);
1043 if (t || strcmp (at_console, "false") == 0)
1045 e->d.policy.gid_uid_or_at_console = t;
1046 e->d.policy.type = POLICY_CONSOLE;
1050 dbus_set_error (error, DBUS_ERROR_FAILED,
1051 "Unknown value \"%s\" for at_console in message bus configuration file",
1059 _dbus_assert_not_reached ("all <policy> attributes null and we didn't set error");
1064 else if (element_type == ELEMENT_LIMIT)
1069 if ((e = push_element (parser, ELEMENT_LIMIT)) == NULL)
1071 BUS_SET_OOM (error);
1075 if (!locate_attributes (parser, "limit",
1085 dbus_set_error (error, DBUS_ERROR_FAILED,
1086 "<limit> element must have a \"name\" attribute");
1090 e->d.limit.name = _dbus_strdup (name);
1091 if (e->d.limit.name == NULL)
1093 BUS_SET_OOM (error);
1099 else if (element_type == ELEMENT_SELINUX)
1101 if (!check_no_attributes (parser, "selinux", attribute_names, attribute_values, error))
1104 if (push_element (parser, ELEMENT_SELINUX) == NULL)
1106 BUS_SET_OOM (error);
1114 dbus_set_error (error, DBUS_ERROR_FAILED,
1115 "Element <%s> not allowed inside <%s> in configuration file",
1116 element_name, "busconfig");
1122 append_rule_from_element (BusConfigParser *parser,
1123 const char *element_name,
1124 const char **attribute_names,
1125 const char **attribute_values,
1129 const char *send_interface;
1130 const char *send_member;
1131 const char *send_error;
1132 const char *send_destination;
1133 const char *send_path;
1134 const char *send_type;
1135 const char *receive_interface;
1136 const char *receive_member;
1137 const char *receive_error;
1138 const char *receive_sender;
1139 const char *receive_path;
1140 const char *receive_type;
1141 const char *eavesdrop;
1142 const char *send_requested_reply;
1143 const char *receive_requested_reply;
1148 BusPolicyRule *rule;
1150 if (!locate_attributes (parser, element_name,
1154 "send_interface", &send_interface,
1155 "send_member", &send_member,
1156 "send_error", &send_error,
1157 "send_destination", &send_destination,
1158 "send_path", &send_path,
1159 "send_type", &send_type,
1160 "receive_interface", &receive_interface,
1161 "receive_member", &receive_member,
1162 "receive_error", &receive_error,
1163 "receive_sender", &receive_sender,
1164 "receive_path", &receive_path,
1165 "receive_type", &receive_type,
1166 "eavesdrop", &eavesdrop,
1167 "send_requested_reply", &send_requested_reply,
1168 "receive_requested_reply", &receive_requested_reply,
1175 if (!(send_interface || send_member || send_error || send_destination ||
1176 send_type || send_path ||
1177 receive_interface || receive_member || receive_error || receive_sender ||
1178 receive_type || receive_path || eavesdrop ||
1179 send_requested_reply || receive_requested_reply ||
1180 own || user || group))
1182 dbus_set_error (error, DBUS_ERROR_FAILED,
1183 "Element <%s> must have one or more attributes",
1188 if ((send_member && (send_interface == NULL && send_path == NULL)) ||
1189 (receive_member && (receive_interface == NULL && receive_path == NULL)))
1191 dbus_set_error (error, DBUS_ERROR_FAILED,
1192 "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.",
1197 /* Allowed combinations of elements are:
1199 * base, must be all send or all receive:
1202 * interface + member
1205 * base send_ can combine with send_destination, send_path, send_type, send_requested_reply
1206 * base receive_ with receive_sender, receive_path, receive_type, receive_requested_reply, eavesdrop
1208 * user, group, own must occur alone
1210 * Pretty sure the below stuff is broken, FIXME think about it more.
1213 if (((send_interface && send_error) ||
1214 (send_interface && receive_interface) ||
1215 (send_interface && receive_member) ||
1216 (send_interface && receive_error) ||
1217 (send_interface && receive_sender) ||
1218 (send_interface && receive_requested_reply) ||
1219 (send_interface && own) ||
1220 (send_interface && user) ||
1221 (send_interface && group)) ||
1223 ((send_member && send_error) ||
1224 (send_member && receive_interface) ||
1225 (send_member && receive_member) ||
1226 (send_member && receive_error) ||
1227 (send_member && receive_sender) ||
1228 (send_member && receive_requested_reply) ||
1229 (send_member && own) ||
1230 (send_member && user) ||
1231 (send_member && group)) ||
1233 ((send_error && receive_interface) ||
1234 (send_error && receive_member) ||
1235 (send_error && receive_error) ||
1236 (send_error && receive_sender) ||
1237 (send_error && receive_requested_reply) ||
1238 (send_error && own) ||
1239 (send_error && user) ||
1240 (send_error && group)) ||
1242 ((send_destination && receive_interface) ||
1243 (send_destination && receive_member) ||
1244 (send_destination && receive_error) ||
1245 (send_destination && receive_sender) ||
1246 (send_destination && receive_requested_reply) ||
1247 (send_destination && own) ||
1248 (send_destination && user) ||
1249 (send_destination && group)) ||
1251 ((send_type && receive_interface) ||
1252 (send_type && receive_member) ||
1253 (send_type && receive_error) ||
1254 (send_type && receive_sender) ||
1255 (send_type && receive_requested_reply) ||
1256 (send_type && own) ||
1257 (send_type && user) ||
1258 (send_type && group)) ||
1260 ((send_path && receive_interface) ||
1261 (send_path && receive_member) ||
1262 (send_path && receive_error) ||
1263 (send_path && receive_sender) ||
1264 (send_path && receive_requested_reply) ||
1265 (send_path && own) ||
1266 (send_path && user) ||
1267 (send_path && group)) ||
1269 ((send_requested_reply && receive_interface) ||
1270 (send_requested_reply && receive_member) ||
1271 (send_requested_reply && receive_error) ||
1272 (send_requested_reply && receive_sender) ||
1273 (send_requested_reply && receive_requested_reply) ||
1274 (send_requested_reply && own) ||
1275 (send_requested_reply && user) ||
1276 (send_requested_reply && group)) ||
1278 ((receive_interface && receive_error) ||
1279 (receive_interface && own) ||
1280 (receive_interface && user) ||
1281 (receive_interface && group)) ||
1283 ((receive_member && receive_error) ||
1284 (receive_member && own) ||
1285 (receive_member && user) ||
1286 (receive_member && group)) ||
1288 ((receive_error && own) ||
1289 (receive_error && user) ||
1290 (receive_error && group)) ||
1292 ((eavesdrop && own) ||
1293 (eavesdrop && user) ||
1294 (eavesdrop && group)) ||
1296 ((receive_requested_reply && own) ||
1297 (receive_requested_reply && user) ||
1298 (receive_requested_reply && group)) ||
1305 dbus_set_error (error, DBUS_ERROR_FAILED,
1306 "Invalid combination of attributes on element <%s>",
1313 /* In BusPolicyRule, NULL represents wildcard.
1314 * In the config file, '*' represents it.
1316 #define IS_WILDCARD(str) ((str) && ((str)[0]) == '*' && ((str)[1]) == '\0')
1318 if (send_interface || send_member || send_error || send_destination ||
1319 send_path || send_type || send_requested_reply)
1323 if (IS_WILDCARD (send_interface))
1324 send_interface = NULL;
1325 if (IS_WILDCARD (send_member))
1327 if (IS_WILDCARD (send_error))
1329 if (IS_WILDCARD (send_destination))
1330 send_destination = NULL;
1331 if (IS_WILDCARD (send_path))
1333 if (IS_WILDCARD (send_type))
1336 message_type = DBUS_MESSAGE_TYPE_INVALID;
1337 if (send_type != NULL)
1339 message_type = dbus_message_type_from_string (send_type);
1340 if (message_type == DBUS_MESSAGE_TYPE_INVALID)
1342 dbus_set_error (error, DBUS_ERROR_FAILED,
1343 "Bad message type \"%s\"",
1350 !(strcmp (eavesdrop, "true") == 0 ||
1351 strcmp (eavesdrop, "false") == 0))
1353 dbus_set_error (error, DBUS_ERROR_FAILED,
1354 "Bad value \"%s\" for %s attribute, must be true or false",
1355 "eavesdrop", eavesdrop);
1359 if (send_requested_reply &&
1360 !(strcmp (send_requested_reply, "true") == 0 ||
1361 strcmp (send_requested_reply, "false") == 0))
1363 dbus_set_error (error, DBUS_ERROR_FAILED,
1364 "Bad value \"%s\" for %s attribute, must be true or false",
1365 "send_requested_reply", send_requested_reply);
1369 rule = bus_policy_rule_new (BUS_POLICY_RULE_SEND, allow);
1374 rule->d.send.eavesdrop = (strcmp (eavesdrop, "true") == 0);
1376 if (send_requested_reply)
1377 rule->d.send.requested_reply = (strcmp (send_requested_reply, "true") == 0);
1379 rule->d.send.message_type = message_type;
1380 rule->d.send.path = _dbus_strdup (send_path);
1381 rule->d.send.interface = _dbus_strdup (send_interface);
1382 rule->d.send.member = _dbus_strdup (send_member);
1383 rule->d.send.error = _dbus_strdup (send_error);
1384 rule->d.send.destination = _dbus_strdup (send_destination);
1385 if (send_path && rule->d.send.path == NULL)
1387 if (send_interface && rule->d.send.interface == NULL)
1389 if (send_member && rule->d.send.member == NULL)
1391 if (send_error && rule->d.send.error == NULL)
1393 if (send_destination && rule->d.send.destination == NULL)
1396 else if (receive_interface || receive_member || receive_error || receive_sender ||
1397 receive_path || receive_type || eavesdrop || receive_requested_reply)
1401 if (IS_WILDCARD (receive_interface))
1402 receive_interface = NULL;
1403 if (IS_WILDCARD (receive_member))
1404 receive_member = NULL;
1405 if (IS_WILDCARD (receive_error))
1406 receive_error = NULL;
1407 if (IS_WILDCARD (receive_sender))
1408 receive_sender = NULL;
1409 if (IS_WILDCARD (receive_path))
1410 receive_path = NULL;
1411 if (IS_WILDCARD (receive_type))
1412 receive_type = NULL;
1414 message_type = DBUS_MESSAGE_TYPE_INVALID;
1415 if (receive_type != NULL)
1417 message_type = dbus_message_type_from_string (receive_type);
1418 if (message_type == DBUS_MESSAGE_TYPE_INVALID)
1420 dbus_set_error (error, DBUS_ERROR_FAILED,
1421 "Bad message type \"%s\"",
1429 !(strcmp (eavesdrop, "true") == 0 ||
1430 strcmp (eavesdrop, "false") == 0))
1432 dbus_set_error (error, DBUS_ERROR_FAILED,
1433 "Bad value \"%s\" for %s attribute, must be true or false",
1434 "eavesdrop", eavesdrop);
1438 if (receive_requested_reply &&
1439 !(strcmp (receive_requested_reply, "true") == 0 ||
1440 strcmp (receive_requested_reply, "false") == 0))
1442 dbus_set_error (error, DBUS_ERROR_FAILED,
1443 "Bad value \"%s\" for %s attribute, must be true or false",
1444 "receive_requested_reply", receive_requested_reply);
1448 rule = bus_policy_rule_new (BUS_POLICY_RULE_RECEIVE, allow);
1453 rule->d.receive.eavesdrop = (strcmp (eavesdrop, "true") == 0);
1455 if (receive_requested_reply)
1456 rule->d.receive.requested_reply = (strcmp (receive_requested_reply, "true") == 0);
1458 rule->d.receive.message_type = message_type;
1459 rule->d.receive.path = _dbus_strdup (receive_path);
1460 rule->d.receive.interface = _dbus_strdup (receive_interface);
1461 rule->d.receive.member = _dbus_strdup (receive_member);
1462 rule->d.receive.error = _dbus_strdup (receive_error);
1463 rule->d.receive.origin = _dbus_strdup (receive_sender);
1465 if (receive_path && rule->d.receive.path == NULL)
1467 if (receive_interface && rule->d.receive.interface == NULL)
1469 if (receive_member && rule->d.receive.member == NULL)
1471 if (receive_error && rule->d.receive.error == NULL)
1473 if (receive_sender && rule->d.receive.origin == NULL)
1478 rule = bus_policy_rule_new (BUS_POLICY_RULE_OWN, allow);
1482 if (IS_WILDCARD (own))
1485 rule->d.own.service_name = _dbus_strdup (own);
1486 if (own && rule->d.own.service_name == NULL)
1491 if (IS_WILDCARD (user))
1493 rule = bus_policy_rule_new (BUS_POLICY_RULE_USER, allow);
1497 rule->d.user.uid = DBUS_UID_UNSET;
1501 DBusString username;
1504 _dbus_string_init_const (&username, user);
1506 if (_dbus_parse_unix_user_from_config (&username, &uid))
1508 rule = bus_policy_rule_new (BUS_POLICY_RULE_USER, allow);
1512 rule->d.user.uid = uid;
1516 _dbus_warn ("Unknown username \"%s\" on element <%s>\n",
1517 user, element_name);
1523 if (IS_WILDCARD (group))
1525 rule = bus_policy_rule_new (BUS_POLICY_RULE_GROUP, allow);
1529 rule->d.group.gid = DBUS_GID_UNSET;
1533 DBusString groupname;
1536 _dbus_string_init_const (&groupname, group);
1538 if (_dbus_parse_unix_group_from_config (&groupname, &gid))
1540 rule = bus_policy_rule_new (BUS_POLICY_RULE_GROUP, allow);
1544 rule->d.group.gid = gid;
1548 _dbus_warn ("Unknown group \"%s\" on element <%s>\n",
1549 group, element_name);
1554 _dbus_assert_not_reached ("Did not handle some combination of attributes on <allow> or <deny>");
1560 pe = peek_element (parser);
1561 _dbus_assert (pe != NULL);
1562 _dbus_assert (pe->type == ELEMENT_POLICY);
1564 switch (pe->d.policy.type)
1566 case POLICY_IGNORED:
1567 /* drop the rule on the floor */
1570 case POLICY_DEFAULT:
1571 if (!bus_policy_append_default_rule (parser->policy, rule))
1574 case POLICY_MANDATORY:
1575 if (!bus_policy_append_mandatory_rule (parser->policy, rule))
1579 if (!BUS_POLICY_RULE_IS_PER_CLIENT (rule))
1581 dbus_set_error (error, DBUS_ERROR_FAILED,
1582 "<%s> rule cannot be per-user because it has bus-global semantics",
1587 if (!bus_policy_append_user_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1592 if (!BUS_POLICY_RULE_IS_PER_CLIENT (rule))
1594 dbus_set_error (error, DBUS_ERROR_FAILED,
1595 "<%s> rule cannot be per-group because it has bus-global semantics",
1600 if (!bus_policy_append_group_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1606 case POLICY_CONSOLE:
1607 if (!bus_policy_append_console_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1613 bus_policy_rule_unref (rule);
1620 BUS_SET_OOM (error);
1623 bus_policy_rule_unref (rule);
1628 start_policy_child (BusConfigParser *parser,
1629 const char *element_name,
1630 const char **attribute_names,
1631 const char **attribute_values,
1634 if (strcmp (element_name, "allow") == 0)
1636 if (!append_rule_from_element (parser, element_name,
1637 attribute_names, attribute_values,
1641 if (push_element (parser, ELEMENT_ALLOW) == NULL)
1643 BUS_SET_OOM (error);
1649 else if (strcmp (element_name, "deny") == 0)
1651 if (!append_rule_from_element (parser, element_name,
1652 attribute_names, attribute_values,
1656 if (push_element (parser, ELEMENT_DENY) == NULL)
1658 BUS_SET_OOM (error);
1666 dbus_set_error (error, DBUS_ERROR_FAILED,
1667 "Element <%s> not allowed inside <%s> in configuration file",
1668 element_name, "policy");
1674 start_selinux_child (BusConfigParser *parser,
1675 const char *element_name,
1676 const char **attribute_names,
1677 const char **attribute_values,
1684 context_copy = NULL;
1686 if (strcmp (element_name, "associate") == 0)
1689 const char *context;
1691 if (!locate_attributes (parser, "associate",
1696 "context", &context,
1700 if (push_element (parser, ELEMENT_ASSOCIATE) == NULL)
1702 BUS_SET_OOM (error);
1706 if (own == NULL || context == NULL)
1708 dbus_set_error (error, DBUS_ERROR_FAILED,
1709 "Element <associate> must have attributes own=\"<servicename>\" and context=\"<selinux context>\"");
1713 own_copy = _dbus_strdup (own);
1714 if (own_copy == NULL)
1716 context_copy = _dbus_strdup (context);
1717 if (context_copy == NULL)
1720 if (!_dbus_hash_table_insert_string (parser->service_context_table,
1721 own_copy, context_copy))
1728 dbus_set_error (error, DBUS_ERROR_FAILED,
1729 "Element <%s> not allowed inside <%s> in configuration file",
1730 element_name, "selinux");
1736 dbus_free (own_copy);
1739 dbus_free (context_copy);
1741 BUS_SET_OOM (error);
1746 bus_config_parser_start_element (BusConfigParser *parser,
1747 const char *element_name,
1748 const char **attribute_names,
1749 const char **attribute_values,
1754 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1756 /* printf ("START: %s\n", element_name); */
1758 t = top_element_type (parser);
1760 if (t == ELEMENT_NONE)
1762 if (strcmp (element_name, "busconfig") == 0)
1764 if (!check_no_attributes (parser, "busconfig", attribute_names, attribute_values, error))
1767 if (push_element (parser, ELEMENT_BUSCONFIG) == NULL)
1769 BUS_SET_OOM (error);
1777 dbus_set_error (error, DBUS_ERROR_FAILED,
1778 "Unknown element <%s> at root of configuration file",
1783 else if (t == ELEMENT_BUSCONFIG)
1785 return start_busconfig_child (parser, element_name,
1786 attribute_names, attribute_values,
1789 else if (t == ELEMENT_POLICY)
1791 return start_policy_child (parser, element_name,
1792 attribute_names, attribute_values,
1795 else if (t == ELEMENT_SELINUX)
1797 return start_selinux_child (parser, element_name,
1798 attribute_names, attribute_values,
1803 dbus_set_error (error, DBUS_ERROR_FAILED,
1804 "Element <%s> is not allowed in this context",
1811 set_limit (BusConfigParser *parser,
1816 dbus_bool_t must_be_positive;
1817 dbus_bool_t must_be_int;
1819 must_be_int = FALSE;
1820 must_be_positive = FALSE;
1822 if (strcmp (name, "max_incoming_bytes") == 0)
1824 must_be_positive = TRUE;
1825 parser->limits.max_incoming_bytes = value;
1827 else if (strcmp (name, "max_outgoing_bytes") == 0)
1829 must_be_positive = TRUE;
1830 parser->limits.max_outgoing_bytes = value;
1832 else if (strcmp (name, "max_message_size") == 0)
1834 must_be_positive = TRUE;
1835 parser->limits.max_message_size = value;
1837 else if (strcmp (name, "service_start_timeout") == 0)
1839 must_be_positive = TRUE;
1841 parser->limits.activation_timeout = value;
1843 else if (strcmp (name, "auth_timeout") == 0)
1845 must_be_positive = TRUE;
1847 parser->limits.auth_timeout = value;
1849 else if (strcmp (name, "reply_timeout") == 0)
1851 must_be_positive = TRUE;
1853 parser->limits.reply_timeout = value;
1855 else if (strcmp (name, "max_completed_connections") == 0)
1857 must_be_positive = TRUE;
1859 parser->limits.max_completed_connections = value;
1861 else if (strcmp (name, "max_incomplete_connections") == 0)
1863 must_be_positive = TRUE;
1865 parser->limits.max_incomplete_connections = value;
1867 else if (strcmp (name, "max_connections_per_user") == 0)
1869 must_be_positive = TRUE;
1871 parser->limits.max_connections_per_user = value;
1873 else if (strcmp (name, "max_pending_service_starts") == 0)
1875 must_be_positive = TRUE;
1877 parser->limits.max_pending_activations = value;
1879 else if (strcmp (name, "max_names_per_connection") == 0)
1881 must_be_positive = TRUE;
1883 parser->limits.max_services_per_connection = value;
1885 else if (strcmp (name, "max_match_rules_per_connection") == 0)
1887 must_be_positive = TRUE;
1889 parser->limits.max_match_rules_per_connection = value;
1891 else if (strcmp (name, "max_replies_per_connection") == 0)
1893 must_be_positive = TRUE;
1895 parser->limits.max_replies_per_connection = value;
1899 dbus_set_error (error, DBUS_ERROR_FAILED,
1900 "There is no limit called \"%s\"\n",
1905 if (must_be_positive && value < 0)
1907 dbus_set_error (error, DBUS_ERROR_FAILED,
1908 "<limit name=\"%s\"> must be a positive number\n",
1914 (value < _DBUS_INT_MIN || value > _DBUS_INT_MAX))
1916 dbus_set_error (error, DBUS_ERROR_FAILED,
1917 "<limit name=\"%s\"> value is too large\n",
1926 bus_config_parser_end_element (BusConfigParser *parser,
1927 const char *element_name,
1934 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1936 /* printf ("END: %s\n", element_name); */
1938 t = top_element_type (parser);
1940 if (t == ELEMENT_NONE)
1942 /* should probably be an assertion failure but
1943 * being paranoid about XML parsers
1945 dbus_set_error (error, DBUS_ERROR_FAILED,
1946 "XML parser ended element with no element on the stack");
1950 n = bus_config_parser_element_type_to_name (t);
1951 _dbus_assert (n != NULL);
1952 if (strcmp (n, element_name) != 0)
1954 /* should probably be an assertion failure but
1955 * being paranoid about XML parsers
1957 dbus_set_error (error, DBUS_ERROR_FAILED,
1958 "XML element <%s> ended but topmost element on the stack was <%s>",
1963 e = peek_element (parser);
1964 _dbus_assert (e != NULL);
1969 _dbus_assert_not_reached ("element in stack has no type");
1972 case ELEMENT_INCLUDE:
1975 case ELEMENT_LISTEN:
1976 case ELEMENT_PIDFILE:
1978 case ELEMENT_SERVICEDIR:
1979 case ELEMENT_SERVICEHELPER:
1980 case ELEMENT_INCLUDEDIR:
1982 if (!e->had_content)
1984 dbus_set_error (error, DBUS_ERROR_FAILED,
1985 "XML element <%s> was expected to have content inside it",
1986 bus_config_parser_element_type_to_name (e->type));
1990 if (e->type == ELEMENT_LIMIT)
1992 if (!set_limit (parser, e->d.limit.name, e->d.limit.value,
1998 case ELEMENT_BUSCONFIG:
1999 case ELEMENT_POLICY:
2003 case ELEMENT_KEEP_UMASK:
2004 case ELEMENT_SYSLOG:
2005 case ELEMENT_SELINUX:
2006 case ELEMENT_ASSOCIATE:
2007 case ELEMENT_STANDARD_SESSION_SERVICEDIRS:
2008 case ELEMENT_STANDARD_SYSTEM_SERVICEDIRS:
2009 case ELEMENT_ALLOW_ANONYMOUS:
2013 pop_element (parser);
2019 all_whitespace (const DBusString *str)
2023 _dbus_string_skip_white (str, 0, &i);
2025 return i == _dbus_string_get_length (str);
2029 make_full_path (const DBusString *basedir,
2030 const DBusString *filename,
2031 DBusString *full_path)
2033 if (_dbus_path_is_absolute (filename))
2035 return _dbus_string_copy (filename, 0, full_path, 0);
2039 if (!_dbus_string_copy (basedir, 0, full_path, 0))
2042 if (!_dbus_concat_dir_and_file (full_path, filename))
2050 include_file (BusConfigParser *parser,
2051 const DBusString *filename,
2052 dbus_bool_t ignore_missing,
2055 /* FIXME good test case for this would load each config file in the
2056 * test suite both alone, and as an include, and check
2057 * that the result is the same
2059 BusConfigParser *included;
2060 const char *filename_str;
2061 DBusError tmp_error;
2063 dbus_error_init (&tmp_error);
2065 filename_str = _dbus_string_get_const_data (filename);
2067 /* Check to make sure this file hasn't already been included. */
2068 if (seen_include (parser, filename))
2070 dbus_set_error (error, DBUS_ERROR_FAILED,
2071 "Circular inclusion of file '%s'",
2076 if (! _dbus_list_append (&parser->included_files, (void *) filename_str))
2078 BUS_SET_OOM (error);
2082 /* Since parser is passed in as the parent, included
2083 inherits parser's limits. */
2084 included = bus_config_load (filename, FALSE, parser, &tmp_error);
2086 _dbus_list_pop_last (&parser->included_files);
2088 if (included == NULL)
2090 _DBUS_ASSERT_ERROR_IS_SET (&tmp_error);
2092 if (dbus_error_has_name (&tmp_error, DBUS_ERROR_FILE_NOT_FOUND) &&
2095 dbus_error_free (&tmp_error);
2100 dbus_move_error (&tmp_error, error);
2106 _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
2108 if (!merge_included (parser, included, error))
2110 bus_config_parser_unref (included);
2114 /* Copy included's limits back to parser. */
2115 parser->limits = included->limits;
2117 bus_config_parser_unref (included);
2123 servicehelper_path (BusConfigParser *parser,
2124 const DBusString *filename,
2127 const char *filename_str;
2128 char *servicehelper;
2130 filename_str = _dbus_string_get_const_data (filename);
2132 /* copy to avoid overwriting with NULL on OOM */
2133 servicehelper = _dbus_strdup (filename_str);
2136 if (servicehelper == NULL)
2138 BUS_SET_OOM (error);
2142 /* save the latest servicehelper only if not OOM */
2143 dbus_free (parser->servicehelper);
2144 parser->servicehelper = servicehelper;
2146 /* We don't check whether the helper exists; instead we
2147 * would just fail to ever activate anything if it doesn't.
2148 * This allows an admin to fix the problem if it doesn't exist.
2149 * It also allows the parser test suite to successfully parse
2150 * test cases without installing the helper. ;-)
2157 include_dir (BusConfigParser *parser,
2158 const DBusString *dirname,
2161 DBusString filename;
2163 DBusError tmp_error;
2167 if (!_dbus_string_init (&filename))
2169 BUS_SET_OOM (error);
2175 dir = _dbus_directory_open (dirname, error);
2180 dbus_error_init (&tmp_error);
2181 while (_dbus_directory_get_next_file (dir, &filename, &tmp_error))
2183 DBusString full_path;
2185 if (!_dbus_string_init (&full_path))
2187 BUS_SET_OOM (error);
2191 if (!_dbus_string_copy (dirname, 0, &full_path, 0))
2193 BUS_SET_OOM (error);
2194 _dbus_string_free (&full_path);
2198 if (!_dbus_concat_dir_and_file (&full_path, &filename))
2200 BUS_SET_OOM (error);
2201 _dbus_string_free (&full_path);
2205 if (_dbus_string_ends_with_c_str (&full_path, ".conf"))
2207 if (!include_file (parser, &full_path, TRUE, error))
2209 _dbus_string_free (&full_path);
2214 _dbus_string_free (&full_path);
2217 if (dbus_error_is_set (&tmp_error))
2219 dbus_move_error (&tmp_error, error);
2224 if (!_dbus_string_copy_data (dirname, &s))
2226 BUS_SET_OOM (error);
2230 if (!_dbus_list_append (&parser->conf_dirs, s))
2233 BUS_SET_OOM (error);
2240 _dbus_string_free (&filename);
2243 _dbus_directory_close (dir);
2249 bus_config_parser_content (BusConfigParser *parser,
2250 const DBusString *content,
2255 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2261 _dbus_string_get_const_data (content, &c_str);
2263 printf ("CONTENT %d bytes: %s\n", _dbus_string_get_length (content), c_str);
2267 e = peek_element (parser);
2270 dbus_set_error (error, DBUS_ERROR_FAILED,
2271 "Text content outside of any XML element in configuration file");
2274 else if (e->had_content)
2276 _dbus_assert_not_reached ("Element had multiple content blocks");
2280 switch (top_element_type (parser))
2283 _dbus_assert_not_reached ("element at top of stack has no type");
2286 case ELEMENT_BUSCONFIG:
2287 case ELEMENT_POLICY:
2291 case ELEMENT_KEEP_UMASK:
2292 case ELEMENT_SYSLOG:
2293 case ELEMENT_STANDARD_SESSION_SERVICEDIRS:
2294 case ELEMENT_STANDARD_SYSTEM_SERVICEDIRS:
2295 case ELEMENT_ALLOW_ANONYMOUS:
2296 case ELEMENT_SELINUX:
2297 case ELEMENT_ASSOCIATE:
2298 if (all_whitespace (content))
2302 dbus_set_error (error, DBUS_ERROR_FAILED,
2303 "No text content expected inside XML element %s in configuration file",
2304 bus_config_parser_element_type_to_name (top_element_type (parser)));
2308 case ELEMENT_PIDFILE:
2312 e->had_content = TRUE;
2314 if (!_dbus_string_copy_data (content, &s))
2317 dbus_free (parser->pidfile);
2318 parser->pidfile = s;
2322 case ELEMENT_INCLUDE:
2324 DBusString full_path, selinux_policy_root;
2326 e->had_content = TRUE;
2328 if (e->d.include.if_selinux_enabled
2329 && !bus_selinux_enabled ())
2332 if (!_dbus_string_init (&full_path))
2335 if (e->d.include.selinux_root_relative)
2337 if (!bus_selinux_get_policy_root ())
2339 dbus_set_error (error, DBUS_ERROR_FAILED,
2340 "Could not determine SELinux policy root for relative inclusion");
2341 _dbus_string_free (&full_path);
2344 _dbus_string_init_const (&selinux_policy_root,
2345 bus_selinux_get_policy_root ());
2346 if (!make_full_path (&selinux_policy_root, content, &full_path))
2348 _dbus_string_free (&full_path);
2352 else if (!make_full_path (&parser->basedir, content, &full_path))
2354 _dbus_string_free (&full_path);
2358 if (!include_file (parser, &full_path,
2359 e->d.include.ignore_missing, error))
2361 _dbus_string_free (&full_path);
2365 _dbus_string_free (&full_path);
2369 case ELEMENT_SERVICEHELPER:
2371 DBusString full_path;
2373 e->had_content = TRUE;
2375 if (!_dbus_string_init (&full_path))
2378 if (!make_full_path (&parser->basedir, content, &full_path))
2380 _dbus_string_free (&full_path);
2384 if (!servicehelper_path (parser, &full_path, error))
2386 _dbus_string_free (&full_path);
2390 _dbus_string_free (&full_path);
2394 case ELEMENT_INCLUDEDIR:
2396 DBusString full_path;
2398 e->had_content = TRUE;
2400 if (!_dbus_string_init (&full_path))
2403 if (!make_full_path (&parser->basedir, content, &full_path))
2405 _dbus_string_free (&full_path);
2409 if (!include_dir (parser, &full_path, error))
2411 _dbus_string_free (&full_path);
2415 _dbus_string_free (&full_path);
2423 e->had_content = TRUE;
2425 if (!_dbus_string_copy_data (content, &s))
2428 dbus_free (parser->user);
2437 e->had_content = TRUE;
2439 if (!_dbus_string_copy_data (content, &s))
2442 dbus_free (parser->bus_type);
2443 parser->bus_type = s;
2447 case ELEMENT_LISTEN:
2451 e->had_content = TRUE;
2453 if (!_dbus_string_copy_data (content, &s))
2456 if (!_dbus_list_append (&parser->listen_on,
2469 e->had_content = TRUE;
2471 if (!_dbus_string_copy_data (content, &s))
2474 if (!_dbus_list_append (&parser->mechanisms,
2483 case ELEMENT_SERVICEDIR:
2486 DBusString full_path;
2488 e->had_content = TRUE;
2490 if (!_dbus_string_init (&full_path))
2493 if (!make_full_path (&parser->basedir, content, &full_path))
2495 _dbus_string_free (&full_path);
2499 if (!_dbus_string_copy_data (&full_path, &s))
2501 _dbus_string_free (&full_path);
2505 /* _only_ extra session directories can be specified */
2506 if (!service_dirs_append_unique_or_free (&parser->service_dirs, s))
2508 _dbus_string_free (&full_path);
2513 _dbus_string_free (&full_path);
2521 e->had_content = TRUE;
2524 if (!_dbus_string_parse_int (content, 0, &val, NULL))
2526 dbus_set_error (error, DBUS_ERROR_FAILED,
2527 "<limit name=\"%s\"> element has invalid value (could not parse as integer)",
2532 e->d.limit.value = val;
2534 _dbus_verbose ("Loaded value %ld for limit %s\n",
2541 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2545 BUS_SET_OOM (error);
2550 bus_config_parser_finished (BusConfigParser *parser,
2553 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2555 if (parser->stack != NULL)
2557 dbus_set_error (error, DBUS_ERROR_FAILED,
2558 "Element <%s> was not closed in configuration file",
2559 bus_config_parser_element_type_to_name (top_element_type (parser)));
2564 if (parser->is_toplevel && parser->listen_on == NULL)
2566 dbus_set_error (error, DBUS_ERROR_FAILED,
2567 "Configuration file needs one or more <listen> elements giving addresses");
2575 bus_config_parser_get_user (BusConfigParser *parser)
2577 return parser->user;
2581 bus_config_parser_get_type (BusConfigParser *parser)
2583 return parser->bus_type;
2587 bus_config_parser_get_addresses (BusConfigParser *parser)
2589 return &parser->listen_on;
2593 bus_config_parser_get_mechanisms (BusConfigParser *parser)
2595 return &parser->mechanisms;
2599 bus_config_parser_get_service_dirs (BusConfigParser *parser)
2601 return &parser->service_dirs;
2605 bus_config_parser_get_conf_dirs (BusConfigParser *parser)
2607 return &parser->conf_dirs;
2611 bus_config_parser_get_fork (BusConfigParser *parser)
2613 return parser->fork;
2617 bus_config_parser_get_keep_umask (BusConfigParser *parser)
2619 return parser->keep_umask;
2623 bus_config_parser_get_syslog (BusConfigParser *parser)
2625 return parser->syslog;
2629 bus_config_parser_get_allow_anonymous (BusConfigParser *parser)
2631 return parser->allow_anonymous;
2635 bus_config_parser_get_pidfile (BusConfigParser *parser)
2637 return parser->pidfile;
2641 bus_config_parser_get_servicehelper (BusConfigParser *parser)
2643 return parser->servicehelper;
2647 bus_config_parser_steal_policy (BusConfigParser *parser)
2651 _dbus_assert (parser->policy != NULL); /* can only steal the policy 1 time */
2653 policy = parser->policy;
2655 parser->policy = NULL;
2660 /* Overwrite any limits that were set in the configuration file */
2662 bus_config_parser_get_limits (BusConfigParser *parser,
2665 *limits = parser->limits;
2669 bus_config_parser_steal_service_context_table (BusConfigParser *parser)
2671 DBusHashTable *table;
2673 _dbus_assert (parser->service_context_table != NULL); /* can only steal once */
2675 table = parser->service_context_table;
2677 parser->service_context_table = NULL;
2682 #ifdef DBUS_BUILD_TESTS
2693 do_load (const DBusString *full_path,
2695 dbus_bool_t oom_possible)
2697 BusConfigParser *parser;
2700 dbus_error_init (&error);
2702 parser = bus_config_load (full_path, TRUE, NULL, &error);
2705 _DBUS_ASSERT_ERROR_IS_SET (&error);
2708 dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
2710 _dbus_verbose ("Failed to load valid file due to OOM\n");
2711 dbus_error_free (&error);
2714 else if (validity == VALID)
2716 _dbus_warn ("Failed to load valid file but still had memory: %s\n",
2719 dbus_error_free (&error);
2724 dbus_error_free (&error);
2730 _DBUS_ASSERT_ERROR_IS_CLEAR (&error);
2732 bus_config_parser_unref (parser);
2734 if (validity == INVALID)
2736 _dbus_warn ("Accepted invalid file\n");
2746 const DBusString *full_path;
2751 check_loader_oom_func (void *data)
2753 LoaderOomData *d = data;
2755 return do_load (d->full_path, d->validity, TRUE);
2759 process_test_valid_subdir (const DBusString *test_base_dir,
2763 DBusString test_directory;
2764 DBusString filename;
2772 if (!_dbus_string_init (&test_directory))
2773 _dbus_assert_not_reached ("didn't allocate test_directory\n");
2775 _dbus_string_init_const (&filename, subdir);
2777 if (!_dbus_string_copy (test_base_dir, 0,
2778 &test_directory, 0))
2779 _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory");
2781 if (!_dbus_concat_dir_and_file (&test_directory, &filename))
2782 _dbus_assert_not_reached ("couldn't allocate full path");
2784 _dbus_string_free (&filename);
2785 if (!_dbus_string_init (&filename))
2786 _dbus_assert_not_reached ("didn't allocate filename string\n");
2788 dbus_error_init (&error);
2789 dir = _dbus_directory_open (&test_directory, &error);
2792 _dbus_warn ("Could not open %s: %s\n",
2793 _dbus_string_get_const_data (&test_directory),
2795 dbus_error_free (&error);
2799 if (validity == VALID)
2800 printf ("Testing valid files:\n");
2801 else if (validity == INVALID)
2802 printf ("Testing invalid files:\n");
2804 printf ("Testing unknown files:\n");
2807 while (_dbus_directory_get_next_file (dir, &filename, &error))
2809 DBusString full_path;
2812 if (!_dbus_string_init (&full_path))
2813 _dbus_assert_not_reached ("couldn't init string");
2815 if (!_dbus_string_copy (&test_directory, 0, &full_path, 0))
2816 _dbus_assert_not_reached ("couldn't copy dir to full_path");
2818 if (!_dbus_concat_dir_and_file (&full_path, &filename))
2819 _dbus_assert_not_reached ("couldn't concat file to dir");
2821 if (!_dbus_string_ends_with_c_str (&full_path, ".conf"))
2823 _dbus_verbose ("Skipping non-.conf file %s\n",
2824 _dbus_string_get_const_data (&filename));
2825 _dbus_string_free (&full_path);
2829 printf (" %s\n", _dbus_string_get_const_data (&filename));
2831 _dbus_verbose (" expecting %s\n",
2832 validity == VALID ? "valid" :
2833 (validity == INVALID ? "invalid" :
2834 (validity == UNKNOWN ? "unknown" : "???")));
2836 d.full_path = &full_path;
2837 d.validity = validity;
2839 /* FIXME hackaround for an expat problem, see
2840 * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=124747
2841 * http://freedesktop.org/pipermail/dbus/2004-May/001153.html
2843 /* if (!_dbus_test_oom_handling ("config-loader", check_loader_oom_func, &d)) */
2844 if (!check_loader_oom_func (&d))
2845 _dbus_assert_not_reached ("test failed");
2847 _dbus_string_free (&full_path);
2850 if (dbus_error_is_set (&error))
2852 _dbus_warn ("Could not get next file in %s: %s\n",
2853 _dbus_string_get_const_data (&test_directory),
2855 dbus_error_free (&error);
2864 _dbus_directory_close (dir);
2865 _dbus_string_free (&test_directory);
2866 _dbus_string_free (&filename);
2872 bools_equal (dbus_bool_t a,
2879 strings_equal_or_both_null (const char *a,
2882 if (a == NULL || b == NULL)
2885 return !strcmp (a, b);
2889 elements_equal (const Element *a,
2892 if (a->type != b->type)
2895 if (!bools_equal (a->had_content, b->had_content))
2901 case ELEMENT_INCLUDE:
2902 if (!bools_equal (a->d.include.ignore_missing,
2903 b->d.include.ignore_missing))
2907 case ELEMENT_POLICY:
2908 if (a->d.policy.type != b->d.policy.type)
2910 if (a->d.policy.gid_uid_or_at_console != b->d.policy.gid_uid_or_at_console)
2915 if (strcmp (a->d.limit.name, b->d.limit.name))
2917 if (a->d.limit.value != b->d.limit.value)
2931 lists_of_elements_equal (DBusList *a,
2940 while (ia != NULL && ib != NULL)
2942 if (elements_equal (ia->data, ib->data))
2944 ia = _dbus_list_get_next_link (&a, ia);
2945 ib = _dbus_list_get_next_link (&b, ib);
2948 return ia == NULL && ib == NULL;
2952 lists_of_c_strings_equal (DBusList *a,
2961 while (ia != NULL && ib != NULL)
2963 if (strcmp (ia->data, ib->data))
2965 ia = _dbus_list_get_next_link (&a, ia);
2966 ib = _dbus_list_get_next_link (&b, ib);
2969 return ia == NULL && ib == NULL;
2973 limits_equal (const BusLimits *a,
2977 (a->max_incoming_bytes == b->max_incoming_bytes
2978 || a->max_outgoing_bytes == b->max_outgoing_bytes
2979 || a->max_message_size == b->max_message_size
2980 || a->activation_timeout == b->activation_timeout
2981 || a->auth_timeout == b->auth_timeout
2982 || a->max_completed_connections == b->max_completed_connections
2983 || a->max_incomplete_connections == b->max_incomplete_connections
2984 || a->max_connections_per_user == b->max_connections_per_user
2985 || a->max_pending_activations == b->max_pending_activations
2986 || a->max_services_per_connection == b->max_services_per_connection
2987 || a->max_match_rules_per_connection == b->max_match_rules_per_connection
2988 || a->max_replies_per_connection == b->max_replies_per_connection
2989 || a->reply_timeout == b->reply_timeout);
2993 config_parsers_equal (const BusConfigParser *a,
2994 const BusConfigParser *b)
2996 if (!_dbus_string_equal (&a->basedir, &b->basedir))
2999 if (!lists_of_elements_equal (a->stack, b->stack))
3002 if (!strings_equal_or_both_null (a->user, b->user))
3005 if (!lists_of_c_strings_equal (a->listen_on, b->listen_on))
3008 if (!lists_of_c_strings_equal (a->mechanisms, b->mechanisms))
3011 if (!lists_of_c_strings_equal (a->service_dirs, b->service_dirs))
3014 /* FIXME: compare policy */
3016 /* FIXME: compare service selinux ID table */
3018 if (! limits_equal (&a->limits, &b->limits))
3021 if (!strings_equal_or_both_null (a->pidfile, b->pidfile))
3024 if (! bools_equal (a->fork, b->fork))
3027 if (! bools_equal (a->keep_umask, b->keep_umask))
3030 if (! bools_equal (a->is_toplevel, b->is_toplevel))
3037 all_are_equiv (const DBusString *target_directory)
3039 DBusString filename;
3041 BusConfigParser *first_parser;
3042 BusConfigParser *parser;
3048 first_parser = NULL;
3052 if (!_dbus_string_init (&filename))
3053 _dbus_assert_not_reached ("didn't allocate filename string");
3055 dbus_error_init (&error);
3056 dir = _dbus_directory_open (target_directory, &error);
3059 _dbus_warn ("Could not open %s: %s\n",
3060 _dbus_string_get_const_data (target_directory),
3062 dbus_error_free (&error);
3066 printf ("Comparing equivalent files:\n");
3069 while (_dbus_directory_get_next_file (dir, &filename, &error))
3071 DBusString full_path;
3073 if (!_dbus_string_init (&full_path))
3074 _dbus_assert_not_reached ("couldn't init string");
3076 if (!_dbus_string_copy (target_directory, 0, &full_path, 0))
3077 _dbus_assert_not_reached ("couldn't copy dir to full_path");
3079 if (!_dbus_concat_dir_and_file (&full_path, &filename))
3080 _dbus_assert_not_reached ("couldn't concat file to dir");
3082 if (!_dbus_string_ends_with_c_str (&full_path, ".conf"))
3084 _dbus_verbose ("Skipping non-.conf file %s\n",
3085 _dbus_string_get_const_data (&filename));
3086 _dbus_string_free (&full_path);
3090 printf (" %s\n", _dbus_string_get_const_data (&filename));
3092 parser = bus_config_load (&full_path, TRUE, NULL, &error);
3096 _dbus_warn ("Could not load file %s: %s\n",
3097 _dbus_string_get_const_data (&full_path),
3099 _dbus_string_free (&full_path);
3100 dbus_error_free (&error);
3103 else if (first_parser == NULL)
3105 _dbus_string_free (&full_path);
3106 first_parser = parser;
3110 _dbus_string_free (&full_path);
3111 equal = config_parsers_equal (first_parser, parser);
3112 bus_config_parser_unref (parser);
3121 _dbus_string_free (&filename);
3123 bus_config_parser_unref (first_parser);
3125 _dbus_directory_close (dir);
3132 process_test_equiv_subdir (const DBusString *test_base_dir,
3135 DBusString test_directory;
3136 DBusString filename;
3145 if (!_dbus_string_init (&test_directory))
3146 _dbus_assert_not_reached ("didn't allocate test_directory");
3148 _dbus_string_init_const (&filename, subdir);
3150 if (!_dbus_string_copy (test_base_dir, 0,
3151 &test_directory, 0))
3152 _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory");
3154 if (!_dbus_concat_dir_and_file (&test_directory, &filename))
3155 _dbus_assert_not_reached ("couldn't allocate full path");
3157 _dbus_string_free (&filename);
3158 if (!_dbus_string_init (&filename))
3159 _dbus_assert_not_reached ("didn't allocate filename string");
3161 dbus_error_init (&error);
3162 dir = _dbus_directory_open (&test_directory, &error);
3165 _dbus_warn ("Could not open %s: %s\n",
3166 _dbus_string_get_const_data (&test_directory),
3168 dbus_error_free (&error);
3172 while (_dbus_directory_get_next_file (dir, &filename, &error))
3174 DBusString full_path;
3176 /* Skip CVS's magic directories! */
3177 if (_dbus_string_equal_c_str (&filename, "CVS"))
3180 if (!_dbus_string_init (&full_path))
3181 _dbus_assert_not_reached ("couldn't init string");
3183 if (!_dbus_string_copy (&test_directory, 0, &full_path, 0))
3184 _dbus_assert_not_reached ("couldn't copy dir to full_path");
3186 if (!_dbus_concat_dir_and_file (&full_path, &filename))
3187 _dbus_assert_not_reached ("couldn't concat file to dir");
3189 equal = all_are_equiv (&full_path);
3190 _dbus_string_free (&full_path);
3199 _dbus_string_free (&test_directory);
3200 _dbus_string_free (&filename);
3202 _dbus_directory_close (dir);
3208 static const char *test_session_service_dir_matches[] =
3211 "/testusr/testlocal/testshare/dbus-1/services",
3212 "/testusr/testshare/dbus-1/services",
3214 DBUS_DATADIR"/dbus-1/services",
3216 "/testhome/foo/.testlocal/testshare/dbus-1/services",
3222 test_default_session_servicedirs (void)
3227 const char *common_progs;
3230 /* On Unix we don't actually use this variable, but it's easier to handle the
3231 * deallocation if we always allocate it, whether needed or not */
3232 if (!_dbus_string_init (&progs))
3233 _dbus_assert_not_reached ("OOM allocating progs");
3235 common_progs = _dbus_getenv ("CommonProgramFiles");
3239 if (!_dbus_string_append (&progs, common_progs))
3241 _dbus_string_free (&progs);
3245 if (!_dbus_string_append (&progs, "/dbus-1/services"))
3247 _dbus_string_free (&progs);
3250 test_session_service_dir_matches[1] = _dbus_string_get_const_data(&progs);
3255 printf ("Testing retrieving the default session service directories\n");
3256 if (!_dbus_get_standard_session_servicedirs (&dirs))
3257 _dbus_assert_not_reached ("couldn't get stardard dirs");
3259 /* make sure our defaults end with share/dbus-1/service */
3260 while ((link = _dbus_list_pop_first_link (&dirs)))
3264 printf (" default service dir: %s\n", (char *)link->data);
3265 _dbus_string_init_const (&path, (char *)link->data);
3266 if (!_dbus_string_ends_with_c_str (&path, "dbus-1/services"))
3268 printf ("error with default session service directories\n");
3269 dbus_free (link->data);
3270 _dbus_list_free_link (link);
3271 _dbus_string_free (&progs);
3275 dbus_free (link->data);
3276 _dbus_list_free_link (link);
3280 if (!_dbus_setenv ("XDG_DATA_HOME", "/testhome/foo/.testlocal/testshare"))
3281 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_HOME");
3283 if (!_dbus_setenv ("XDG_DATA_DIRS", ":/testusr/testlocal/testshare: :/testusr/testshare:"))
3284 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_DIRS");
3286 if (!_dbus_get_standard_session_servicedirs (&dirs))
3287 _dbus_assert_not_reached ("couldn't get stardard dirs");
3289 /* make sure we read and parse the env variable correctly */
3291 while ((link = _dbus_list_pop_first_link (&dirs)))
3293 printf (" test service dir: %s\n", (char *)link->data);
3294 if (test_session_service_dir_matches[i] == NULL)
3296 printf ("more directories parsed than in match set\n");
3297 dbus_free (link->data);
3298 _dbus_list_free_link (link);
3299 _dbus_string_free (&progs);
3303 if (strcmp (test_session_service_dir_matches[i],
3304 (char *)link->data) != 0)
3306 printf ("%s directory does not match %s in the match set\n",
3308 test_session_service_dir_matches[i]);
3309 dbus_free (link->data);
3310 _dbus_list_free_link (link);
3311 _dbus_string_free (&progs);
3317 dbus_free (link->data);
3318 _dbus_list_free_link (link);
3321 if (test_session_service_dir_matches[i] != NULL)
3323 printf ("extra data %s in the match set was not matched\n",
3324 test_session_service_dir_matches[i]);
3326 _dbus_string_free (&progs);
3330 _dbus_string_free (&progs);
3334 static const char *test_system_service_dir_matches[] =
3337 "/testusr/testlocal/testshare/dbus-1/system-services",
3338 "/testusr/testshare/dbus-1/system-services",
3340 DBUS_DATADIR"/dbus-1/system-services",
3345 test_default_system_servicedirs (void)
3350 const char *common_progs;
3353 /* On Unix we don't actually use this variable, but it's easier to handle the
3354 * deallocation if we always allocate it, whether needed or not */
3355 if (!_dbus_string_init (&progs))
3356 _dbus_assert_not_reached ("OOM allocating progs");
3358 common_progs = _dbus_getenv ("CommonProgramFiles");
3362 if (!_dbus_string_append (&progs, common_progs))
3364 _dbus_string_free (&progs);
3368 if (!_dbus_string_append (&progs, "/dbus-1/system-services"))
3370 _dbus_string_free (&progs);
3373 test_system_service_dir_matches[1] = _dbus_string_get_const_data(&progs);
3378 printf ("Testing retrieving the default system service directories\n");
3379 if (!_dbus_get_standard_system_servicedirs (&dirs))
3380 _dbus_assert_not_reached ("couldn't get stardard dirs");
3382 /* make sure our defaults end with share/dbus-1/system-service */
3383 while ((link = _dbus_list_pop_first_link (&dirs)))
3387 printf (" default service dir: %s\n", (char *)link->data);
3388 _dbus_string_init_const (&path, (char *)link->data);
3389 if (!_dbus_string_ends_with_c_str (&path, "dbus-1/system-services"))
3391 printf ("error with default system service directories\n");
3392 dbus_free (link->data);
3393 _dbus_list_free_link (link);
3394 _dbus_string_free (&progs);
3398 dbus_free (link->data);
3399 _dbus_list_free_link (link);
3403 if (!_dbus_setenv ("XDG_DATA_HOME", "/testhome/foo/.testlocal/testshare"))
3404 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_HOME");
3406 if (!_dbus_setenv ("XDG_DATA_DIRS", ":/testusr/testlocal/testshare: :/testusr/testshare:"))
3407 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_DIRS");
3409 if (!_dbus_get_standard_system_servicedirs (&dirs))
3410 _dbus_assert_not_reached ("couldn't get stardard dirs");
3412 /* make sure we read and parse the env variable correctly */
3414 while ((link = _dbus_list_pop_first_link (&dirs)))
3416 printf (" test service dir: %s\n", (char *)link->data);
3417 if (test_system_service_dir_matches[i] == NULL)
3419 printf ("more directories parsed than in match set\n");
3420 dbus_free (link->data);
3421 _dbus_list_free_link (link);
3422 _dbus_string_free (&progs);
3426 if (strcmp (test_system_service_dir_matches[i],
3427 (char *)link->data) != 0)
3429 printf ("%s directory does not match %s in the match set\n",
3431 test_system_service_dir_matches[i]);
3432 dbus_free (link->data);
3433 _dbus_list_free_link (link);
3434 _dbus_string_free (&progs);
3440 dbus_free (link->data);
3441 _dbus_list_free_link (link);
3444 if (test_system_service_dir_matches[i] != NULL)
3446 printf ("extra data %s in the match set was not matched\n",
3447 test_system_service_dir_matches[i]);
3449 _dbus_string_free (&progs);
3453 _dbus_string_free (&progs);
3458 bus_config_parser_test (const DBusString *test_data_dir)
3460 if (test_data_dir == NULL ||
3461 _dbus_string_get_length (test_data_dir) == 0)
3463 printf ("No test data\n");
3467 if (!test_default_session_servicedirs())
3470 if (!test_default_system_servicedirs())
3473 if (!process_test_valid_subdir (test_data_dir, "valid-config-files", VALID))
3476 if (!process_test_valid_subdir (test_data_dir, "invalid-config-files", INVALID))
3479 if (!process_test_equiv_subdir (test_data_dir, "equiv-config-files"))
3485 #endif /* DBUS_BUILD_TESTS */