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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "config-parser-common.h"
26 #include "config-parser.h"
31 #include <dbus/dbus-list.h>
32 #include <dbus/dbus-internals.h>
33 #include <dbus/dbus-sysdeps.h>
38 /* we ignore policies for unknown groups/users */
53 unsigned int had_content : 1;
59 unsigned int ignore_missing : 1;
60 unsigned int if_selinux_enabled : 1;
61 unsigned int selinux_root_relative : 1;
67 unsigned long gid_uid_or_at_console;
81 * Parser for bus configuration file.
83 struct BusConfigParser
85 int refcount; /**< Reference count */
87 DBusString basedir; /**< Directory we resolve paths relative to */
89 DBusList *stack; /**< stack of Element */
91 char *user; /**< user to run as */
93 char *servicehelper; /**< location of the setuid helper */
95 char *bus_type; /**< Message bus type */
97 DBusList *listen_on; /**< List of addresses to listen to */
99 DBusList *mechanisms; /**< Auth mechanisms */
101 DBusList *service_dirs; /**< Directories to look for session services in */
103 DBusList *conf_dirs; /**< Directories to look for policy configuration in */
105 BusPolicy *policy; /**< Security policy */
107 BusLimits limits; /**< Limits */
109 char *pidfile; /**< PID file */
111 DBusList *included_files; /**< Included files stack */
113 DBusHashTable *service_context_table; /**< Map service names to SELinux contexts */
115 unsigned int fork : 1; /**< TRUE to fork into daemon mode */
117 unsigned int syslog : 1; /**< TRUE to enable syslog */
118 unsigned int keep_umask : 1; /**< TRUE to keep original umask when forking */
120 unsigned int is_toplevel : 1; /**< FALSE if we are a sub-config-file inside another one */
122 unsigned int allow_anonymous : 1; /**< TRUE to allow anonymous connections */
126 push_element (BusConfigParser *parser,
131 _dbus_assert (type != ELEMENT_NONE);
133 e = dbus_new0 (Element, 1);
137 if (!_dbus_list_append (&parser->stack, e))
149 element_free (Element *e)
151 if (e->type == ELEMENT_LIMIT)
152 dbus_free (e->d.limit.name);
158 pop_element (BusConfigParser *parser)
162 e = _dbus_list_pop_last (&parser->stack);
168 peek_element (BusConfigParser *parser)
172 e = _dbus_list_get_last (&parser->stack);
178 top_element_type (BusConfigParser *parser)
182 e = _dbus_list_get_last (&parser->stack);
191 merge_service_context_hash (DBusHashTable *dest,
201 _dbus_hash_iter_init (from, &iter);
202 while (_dbus_hash_iter_next (&iter))
204 const char *service = _dbus_hash_iter_get_string_key (&iter);
205 const char *context = _dbus_hash_iter_get_value (&iter);
207 service_copy = _dbus_strdup (service);
208 if (service_copy == NULL)
210 context_copy = _dbus_strdup (context);
211 if (context_copy == NULL)
214 if (!_dbus_hash_table_insert_string (dest, service_copy, context_copy))
225 dbus_free (service_copy);
228 dbus_free (context_copy);
234 service_dirs_find_dir (DBusList **service_dirs,
239 _dbus_assert (dir != NULL);
241 for (link = *service_dirs; link; link = _dbus_list_get_next_link(service_dirs, link))
243 const char *link_dir;
245 link_dir = (const char *)link->data;
246 if (strcmp (dir, link_dir) == 0)
254 service_dirs_append_unique_or_free (DBusList **service_dirs,
257 if (!service_dirs_find_dir (service_dirs, dir))
258 return _dbus_list_append (service_dirs, dir);
265 service_dirs_append_link_unique_or_free (DBusList **service_dirs,
268 if (!service_dirs_find_dir (service_dirs, dir_link->data))
270 _dbus_list_append_link (service_dirs, dir_link);
274 dbus_free (dir_link->data);
275 _dbus_list_free_link (dir_link);
280 merge_included (BusConfigParser *parser,
281 BusConfigParser *included,
286 if (!bus_policy_merge (parser->policy,
293 if (!merge_service_context_hash (parser->service_context_table,
294 included->service_context_table))
300 if (included->user != NULL)
302 dbus_free (parser->user);
303 parser->user = included->user;
304 included->user = NULL;
307 if (included->bus_type != NULL)
309 dbus_free (parser->bus_type);
310 parser->bus_type = included->bus_type;
311 included->bus_type = NULL;
317 if (included->keep_umask)
318 parser->keep_umask = TRUE;
320 if (included->pidfile != NULL)
322 dbus_free (parser->pidfile);
323 parser->pidfile = included->pidfile;
324 included->pidfile = NULL;
327 while ((link = _dbus_list_pop_first_link (&included->listen_on)))
328 _dbus_list_append_link (&parser->listen_on, link);
330 while ((link = _dbus_list_pop_first_link (&included->mechanisms)))
331 _dbus_list_append_link (&parser->mechanisms, link);
333 while ((link = _dbus_list_pop_first_link (&included->service_dirs)))
334 service_dirs_append_link_unique_or_free (&parser->service_dirs, link);
336 while ((link = _dbus_list_pop_first_link (&included->conf_dirs)))
337 _dbus_list_append_link (&parser->conf_dirs, link);
343 seen_include (BusConfigParser *parser,
344 const DBusString *file)
348 iter = parser->included_files;
351 if (! strcmp (_dbus_string_get_const_data (file), iter->data))
354 iter = _dbus_list_get_next_link (&parser->included_files, iter);
361 bus_config_parser_new (const DBusString *basedir,
362 dbus_bool_t is_toplevel,
363 const BusConfigParser *parent)
365 BusConfigParser *parser;
367 parser = dbus_new0 (BusConfigParser, 1);
371 parser->is_toplevel = !!is_toplevel;
373 if (!_dbus_string_init (&parser->basedir))
379 if (((parser->policy = bus_policy_new ()) == NULL) ||
380 !_dbus_string_copy (basedir, 0, &parser->basedir, 0) ||
381 ((parser->service_context_table = _dbus_hash_table_new (DBUS_HASH_STRING,
383 dbus_free)) == NULL))
386 bus_policy_unref (parser->policy);
388 _dbus_string_free (&parser->basedir);
396 /* Initialize the parser's limits from the parent. */
397 parser->limits = parent->limits;
399 /* Use the parent's list of included_files to avoid
400 circular inclusions. */
401 parser->included_files = parent->included_files;
406 /* Make up some numbers! woot! */
407 parser->limits.max_incoming_bytes = _DBUS_ONE_MEGABYTE * 127;
408 parser->limits.max_outgoing_bytes = _DBUS_ONE_MEGABYTE * 127;
409 parser->limits.max_message_size = _DBUS_ONE_MEGABYTE * 32;
411 /* We set relatively conservative values here since due to the
412 way SCM_RIGHTS works we need to preallocate an array for the
413 maximum number of file descriptors we can receive. Picking a
414 high value here thus translates directly to more memory
416 parser->limits.max_incoming_unix_fds = 1024*4;
417 parser->limits.max_outgoing_unix_fds = 1024*4;
418 parser->limits.max_message_unix_fds = 1024;
420 /* Making this long means the user has to wait longer for an error
421 * message if something screws up, but making it too short means
422 * they might see a false failure.
424 parser->limits.activation_timeout = 25000; /* 25 seconds */
426 /* Making this long risks making a DOS attack easier, but too short
427 * and legitimate auth will fail. If interactive auth (ask user for
428 * password) is allowed, then potentially it has to be quite long.
430 parser->limits.auth_timeout = 30000; /* 30 seconds */
432 parser->limits.max_incomplete_connections = 64;
433 parser->limits.max_connections_per_user = 256;
435 /* Note that max_completed_connections / max_connections_per_user
436 * is the number of users that would have to work together to
437 * DOS all the other users.
439 parser->limits.max_completed_connections = 2048;
441 parser->limits.max_pending_activations = 512;
442 parser->limits.max_services_per_connection = 512;
444 /* For this one, keep in mind that it isn't only the memory used
445 * by the match rules, but slowdown from linearly walking a big
446 * list of them. A client adding more than this is almost
447 * certainly a bad idea for that reason, and should change to a
448 * smaller number of wider-net match rules - getting every last
449 * message to the bus is probably better than having a thousand
452 parser->limits.max_match_rules_per_connection = 512;
454 parser->limits.reply_timeout = -1; /* never */
456 /* this is effectively a limit on message queue size for messages
457 * that require a reply
459 parser->limits.max_replies_per_connection = 1024*8;
462 parser->refcount = 1;
468 bus_config_parser_ref (BusConfigParser *parser)
470 _dbus_assert (parser->refcount > 0);
472 parser->refcount += 1;
478 bus_config_parser_unref (BusConfigParser *parser)
480 _dbus_assert (parser->refcount > 0);
482 parser->refcount -= 1;
484 if (parser->refcount == 0)
486 while (parser->stack != NULL)
487 pop_element (parser);
489 dbus_free (parser->user);
490 dbus_free (parser->servicehelper);
491 dbus_free (parser->bus_type);
492 dbus_free (parser->pidfile);
494 _dbus_list_foreach (&parser->listen_on,
495 (DBusForeachFunction) dbus_free,
498 _dbus_list_clear (&parser->listen_on);
500 _dbus_list_foreach (&parser->service_dirs,
501 (DBusForeachFunction) dbus_free,
504 _dbus_list_clear (&parser->service_dirs);
506 _dbus_list_foreach (&parser->conf_dirs,
507 (DBusForeachFunction) dbus_free,
510 _dbus_list_clear (&parser->conf_dirs);
512 _dbus_list_foreach (&parser->mechanisms,
513 (DBusForeachFunction) dbus_free,
516 _dbus_list_clear (&parser->mechanisms);
518 _dbus_string_free (&parser->basedir);
521 bus_policy_unref (parser->policy);
523 if (parser->service_context_table)
524 _dbus_hash_table_unref (parser->service_context_table);
531 bus_config_parser_check_doctype (BusConfigParser *parser,
535 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
537 if (strcmp (doctype, "busconfig") != 0)
539 dbus_set_error (error,
541 "Configuration file has the wrong document type %s",
556 locate_attributes (BusConfigParser *parser,
557 const char *element_name,
558 const char **attribute_names,
559 const char **attribute_values,
561 const char *first_attribute_name,
562 const char **first_attribute_retloc,
570 LocateAttr attrs[MAX_ATTRS];
574 _dbus_assert (first_attribute_name != NULL);
575 _dbus_assert (first_attribute_retloc != NULL);
580 attrs[0].name = first_attribute_name;
581 attrs[0].retloc = first_attribute_retloc;
582 *first_attribute_retloc = NULL;
584 va_start (args, first_attribute_retloc);
586 name = va_arg (args, const char*);
587 retloc = va_arg (args, const char**);
591 _dbus_assert (retloc != NULL);
592 _dbus_assert (n_attrs < MAX_ATTRS);
594 attrs[n_attrs].name = name;
595 attrs[n_attrs].retloc = retloc;
599 name = va_arg (args, const char*);
600 retloc = va_arg (args, const char**);
606 while (attribute_names[i])
615 if (strcmp (attrs[j].name, attribute_names[i]) == 0)
617 retloc = attrs[j].retloc;
621 dbus_set_error (error, DBUS_ERROR_FAILED,
622 "Attribute \"%s\" repeated twice on the same <%s> element",
623 attrs[j].name, element_name);
628 *retloc = attribute_values[i];
637 dbus_set_error (error, DBUS_ERROR_FAILED,
638 "Attribute \"%s\" is invalid on <%s> element in this context",
639 attribute_names[i], element_name);
652 check_no_attributes (BusConfigParser *parser,
653 const char *element_name,
654 const char **attribute_names,
655 const char **attribute_values,
658 if (attribute_names[0] != NULL)
660 dbus_set_error (error, DBUS_ERROR_FAILED,
661 "Attribute \"%s\" is invalid on <%s> element in this context",
662 attribute_names[0], element_name);
670 start_busconfig_child (BusConfigParser *parser,
671 const char *element_name,
672 const char **attribute_names,
673 const char **attribute_values,
676 ElementType element_type;
678 element_type = bus_config_parser_element_name_to_type (element_name);
680 if (element_type == ELEMENT_USER)
682 if (!check_no_attributes (parser, "user", attribute_names, attribute_values, error))
685 if (push_element (parser, ELEMENT_USER) == NULL)
693 else if (element_type == ELEMENT_CONFIGTYPE)
695 if (!check_no_attributes (parser, "type", attribute_names, attribute_values, error))
698 if (push_element (parser, ELEMENT_CONFIGTYPE) == NULL)
706 else if (element_type == ELEMENT_FORK)
708 if (!check_no_attributes (parser, "fork", attribute_names, attribute_values, error))
711 if (push_element (parser, ELEMENT_FORK) == NULL)
721 else if (element_type == ELEMENT_SYSLOG)
723 if (!check_no_attributes (parser, "syslog", attribute_names, attribute_values, error))
726 if (push_element (parser, ELEMENT_SYSLOG) == NULL)
732 parser->syslog = TRUE;
736 else if (element_type == ELEMENT_KEEP_UMASK)
738 if (!check_no_attributes (parser, "keep_umask", attribute_names, attribute_values, error))
741 if (push_element (parser, ELEMENT_KEEP_UMASK) == NULL)
747 parser->keep_umask = TRUE;
751 else if (element_type == ELEMENT_PIDFILE)
753 if (!check_no_attributes (parser, "pidfile", attribute_names, attribute_values, error))
756 if (push_element (parser, ELEMENT_PIDFILE) == NULL)
764 else if (element_type == ELEMENT_LISTEN)
766 if (!check_no_attributes (parser, "listen", attribute_names, attribute_values, error))
769 if (push_element (parser, ELEMENT_LISTEN) == NULL)
777 else if (element_type == ELEMENT_AUTH)
779 if (!check_no_attributes (parser, "auth", attribute_names, attribute_values, error))
782 if (push_element (parser, ELEMENT_AUTH) == NULL)
790 else if (element_type == ELEMENT_SERVICEHELPER)
792 if (!check_no_attributes (parser, "servicehelper", attribute_names, attribute_values, error))
795 if (push_element (parser, ELEMENT_SERVICEHELPER) == NULL)
803 else if (element_type == ELEMENT_INCLUDEDIR)
805 if (!check_no_attributes (parser, "includedir", attribute_names, attribute_values, error))
808 if (push_element (parser, ELEMENT_INCLUDEDIR) == NULL)
816 else if (element_type == ELEMENT_STANDARD_SESSION_SERVICEDIRS)
822 if (!check_no_attributes (parser, "standard_session_servicedirs", attribute_names, attribute_values, error))
825 if (push_element (parser, ELEMENT_STANDARD_SESSION_SERVICEDIRS) == NULL)
831 if (!_dbus_get_standard_session_servicedirs (&dirs))
837 while ((link = _dbus_list_pop_first_link (&dirs)))
838 service_dirs_append_link_unique_or_free (&parser->service_dirs, link);
842 else if (element_type == ELEMENT_STANDARD_SYSTEM_SERVICEDIRS)
848 if (!check_no_attributes (parser, "standard_system_servicedirs", attribute_names, attribute_values, error))
851 if (push_element (parser, ELEMENT_STANDARD_SYSTEM_SERVICEDIRS) == NULL)
857 if (!_dbus_get_standard_system_servicedirs (&dirs))
863 while ((link = _dbus_list_pop_first_link (&dirs)))
864 service_dirs_append_link_unique_or_free (&parser->service_dirs, link);
868 else if (element_type == ELEMENT_ALLOW_ANONYMOUS)
870 if (!check_no_attributes (parser, "allow_anonymous", attribute_names, attribute_values, error))
873 if (push_element (parser, ELEMENT_ALLOW_ANONYMOUS) == NULL)
879 parser->allow_anonymous = TRUE;
882 else if (element_type == ELEMENT_SERVICEDIR)
884 if (!check_no_attributes (parser, "servicedir", attribute_names, attribute_values, error))
887 if (push_element (parser, ELEMENT_SERVICEDIR) == NULL)
895 else if (element_type == ELEMENT_INCLUDE)
898 const char *if_selinux_enabled;
899 const char *ignore_missing;
900 const char *selinux_root_relative;
902 if ((e = push_element (parser, ELEMENT_INCLUDE)) == NULL)
908 e->d.include.ignore_missing = FALSE;
909 e->d.include.if_selinux_enabled = FALSE;
910 e->d.include.selinux_root_relative = FALSE;
912 if (!locate_attributes (parser, "include",
916 "ignore_missing", &ignore_missing,
917 "if_selinux_enabled", &if_selinux_enabled,
918 "selinux_root_relative", &selinux_root_relative,
922 if (ignore_missing != NULL)
924 if (strcmp (ignore_missing, "yes") == 0)
925 e->d.include.ignore_missing = TRUE;
926 else if (strcmp (ignore_missing, "no") == 0)
927 e->d.include.ignore_missing = FALSE;
930 dbus_set_error (error, DBUS_ERROR_FAILED,
931 "ignore_missing attribute must have value \"yes\" or \"no\"");
936 if (if_selinux_enabled != NULL)
938 if (strcmp (if_selinux_enabled, "yes") == 0)
939 e->d.include.if_selinux_enabled = TRUE;
940 else if (strcmp (if_selinux_enabled, "no") == 0)
941 e->d.include.if_selinux_enabled = FALSE;
944 dbus_set_error (error, DBUS_ERROR_FAILED,
945 "if_selinux_enabled attribute must have value"
946 " \"yes\" or \"no\"");
951 if (selinux_root_relative != NULL)
953 if (strcmp (selinux_root_relative, "yes") == 0)
954 e->d.include.selinux_root_relative = TRUE;
955 else if (strcmp (selinux_root_relative, "no") == 0)
956 e->d.include.selinux_root_relative = FALSE;
959 dbus_set_error (error, DBUS_ERROR_FAILED,
960 "selinux_root_relative attribute must have value"
961 " \"yes\" or \"no\"");
968 else if (element_type == ELEMENT_POLICY)
974 const char *at_console;
976 if ((e = push_element (parser, ELEMENT_POLICY)) == NULL)
982 e->d.policy.type = POLICY_IGNORED;
984 if (!locate_attributes (parser, "policy",
991 "at_console", &at_console,
995 if (((context && user) ||
996 (context && group) ||
997 (context && at_console)) ||
999 (user && at_console)) ||
1000 (group && at_console) ||
1001 !(context || user || group || at_console))
1003 dbus_set_error (error, DBUS_ERROR_FAILED,
1004 "<policy> element must have exactly one of (context|user|group|at_console) attributes");
1008 if (context != NULL)
1010 if (strcmp (context, "default") == 0)
1012 e->d.policy.type = POLICY_DEFAULT;
1014 else if (strcmp (context, "mandatory") == 0)
1016 e->d.policy.type = POLICY_MANDATORY;
1020 dbus_set_error (error, DBUS_ERROR_FAILED,
1021 "context attribute on <policy> must have the value \"default\" or \"mandatory\", not \"%s\"",
1026 else if (user != NULL)
1028 DBusString username;
1029 _dbus_string_init_const (&username, user);
1031 if (_dbus_parse_unix_user_from_config (&username,
1032 &e->d.policy.gid_uid_or_at_console))
1033 e->d.policy.type = POLICY_USER;
1035 _dbus_warn ("Unknown username \"%s\" in message bus configuration file\n",
1038 else if (group != NULL)
1040 DBusString group_name;
1041 _dbus_string_init_const (&group_name, group);
1043 if (_dbus_parse_unix_group_from_config (&group_name,
1044 &e->d.policy.gid_uid_or_at_console))
1045 e->d.policy.type = POLICY_GROUP;
1047 _dbus_warn ("Unknown group \"%s\" in message bus configuration file\n",
1050 else if (at_console != NULL)
1053 t = (strcmp (at_console, "true") == 0);
1054 if (t || strcmp (at_console, "false") == 0)
1056 e->d.policy.gid_uid_or_at_console = t;
1057 e->d.policy.type = POLICY_CONSOLE;
1061 dbus_set_error (error, DBUS_ERROR_FAILED,
1062 "Unknown value \"%s\" for at_console in message bus configuration file",
1070 _dbus_assert_not_reached ("all <policy> attributes null and we didn't set error");
1075 else if (element_type == ELEMENT_LIMIT)
1080 if ((e = push_element (parser, ELEMENT_LIMIT)) == NULL)
1082 BUS_SET_OOM (error);
1086 if (!locate_attributes (parser, "limit",
1096 dbus_set_error (error, DBUS_ERROR_FAILED,
1097 "<limit> element must have a \"name\" attribute");
1101 e->d.limit.name = _dbus_strdup (name);
1102 if (e->d.limit.name == NULL)
1104 BUS_SET_OOM (error);
1110 else if (element_type == ELEMENT_SELINUX)
1112 if (!check_no_attributes (parser, "selinux", attribute_names, attribute_values, error))
1115 if (push_element (parser, ELEMENT_SELINUX) == NULL)
1117 BUS_SET_OOM (error);
1125 dbus_set_error (error, DBUS_ERROR_FAILED,
1126 "Element <%s> not allowed inside <%s> in configuration file",
1127 element_name, "busconfig");
1133 append_rule_from_element (BusConfigParser *parser,
1134 const char *element_name,
1135 const char **attribute_names,
1136 const char **attribute_values,
1141 const char *send_interface;
1142 const char *send_member;
1143 const char *send_error;
1144 const char *send_destination;
1145 const char *send_path;
1146 const char *send_type;
1147 const char *receive_interface;
1148 const char *receive_member;
1149 const char *receive_error;
1150 const char *receive_sender;
1151 const char *receive_path;
1152 const char *receive_type;
1153 const char *eavesdrop;
1154 const char *send_requested_reply;
1155 const char *receive_requested_reply;
1160 BusPolicyRule *rule;
1162 if (!locate_attributes (parser, element_name,
1166 "send_interface", &send_interface,
1167 "send_member", &send_member,
1168 "send_error", &send_error,
1169 "send_destination", &send_destination,
1170 "send_path", &send_path,
1171 "send_type", &send_type,
1172 "receive_interface", &receive_interface,
1173 "receive_member", &receive_member,
1174 "receive_error", &receive_error,
1175 "receive_sender", &receive_sender,
1176 "receive_path", &receive_path,
1177 "receive_type", &receive_type,
1178 "eavesdrop", &eavesdrop,
1179 "send_requested_reply", &send_requested_reply,
1180 "receive_requested_reply", &receive_requested_reply,
1188 if (!(send_interface || send_member || send_error || send_destination ||
1189 send_type || send_path ||
1190 receive_interface || receive_member || receive_error || receive_sender ||
1191 receive_type || receive_path || eavesdrop ||
1192 send_requested_reply || receive_requested_reply ||
1193 own || user || group))
1195 dbus_set_error (error, DBUS_ERROR_FAILED,
1196 "Element <%s> must have one or more attributes",
1201 if ((send_member && (send_interface == NULL && send_path == NULL)) ||
1202 (receive_member && (receive_interface == NULL && receive_path == NULL)))
1204 dbus_set_error (error, DBUS_ERROR_FAILED,
1205 "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.",
1210 /* Allowed combinations of elements are:
1212 * base, must be all send or all receive:
1215 * interface + member
1218 * base send_ can combine with send_destination, send_path, send_type, send_requested_reply
1219 * base receive_ with receive_sender, receive_path, receive_type, receive_requested_reply, eavesdrop
1221 * user, group, own must occur alone
1223 * Pretty sure the below stuff is broken, FIXME think about it more.
1226 if ((send_interface && (send_error ||
1227 receive_interface ||
1231 receive_requested_reply ||
1236 (send_member && (send_error ||
1237 receive_interface ||
1241 receive_requested_reply ||
1246 (send_error && (receive_interface ||
1250 receive_requested_reply ||
1255 (send_destination && (receive_interface ||
1259 receive_requested_reply ||
1264 (send_type && (receive_interface ||
1268 receive_requested_reply ||
1273 (send_path && (receive_interface ||
1277 receive_requested_reply ||
1282 (send_requested_reply && (receive_interface ||
1286 receive_requested_reply ||
1291 (receive_interface && (receive_error ||
1296 (receive_member && (receive_error ||
1301 (receive_error && (own ||
1305 (eavesdrop && (own ||
1309 (receive_requested_reply && (own ||
1313 (own && (user || group)) ||
1317 dbus_set_error (error, DBUS_ERROR_FAILED,
1318 "Invalid combination of attributes on element <%s>",
1325 /* In BusPolicyRule, NULL represents wildcard.
1326 * In the config file, '*' represents it.
1328 #define IS_WILDCARD(str) ((str) && ((str)[0]) == '*' && ((str)[1]) == '\0')
1330 if (send_interface || send_member || send_error || send_destination ||
1331 send_path || send_type || send_requested_reply)
1335 if (IS_WILDCARD (send_interface))
1336 send_interface = NULL;
1337 if (IS_WILDCARD (send_member))
1339 if (IS_WILDCARD (send_error))
1341 if (IS_WILDCARD (send_destination))
1342 send_destination = NULL;
1343 if (IS_WILDCARD (send_path))
1345 if (IS_WILDCARD (send_type))
1348 message_type = DBUS_MESSAGE_TYPE_INVALID;
1349 if (send_type != NULL)
1351 message_type = dbus_message_type_from_string (send_type);
1352 if (message_type == DBUS_MESSAGE_TYPE_INVALID)
1354 dbus_set_error (error, DBUS_ERROR_FAILED,
1355 "Bad message type \"%s\"",
1362 !(strcmp (eavesdrop, "true") == 0 ||
1363 strcmp (eavesdrop, "false") == 0))
1365 dbus_set_error (error, DBUS_ERROR_FAILED,
1366 "Bad value \"%s\" for %s attribute, must be true or false",
1367 "eavesdrop", eavesdrop);
1371 if (send_requested_reply &&
1372 !(strcmp (send_requested_reply, "true") == 0 ||
1373 strcmp (send_requested_reply, "false") == 0))
1375 dbus_set_error (error, DBUS_ERROR_FAILED,
1376 "Bad value \"%s\" for %s attribute, must be true or false",
1377 "send_requested_reply", send_requested_reply);
1381 rule = bus_policy_rule_new (BUS_POLICY_RULE_SEND, allow);
1386 rule->d.send.eavesdrop = (strcmp (eavesdrop, "true") == 0);
1389 rule->d.send.log = (strcmp (log, "true") == 0);
1391 if (send_requested_reply)
1392 rule->d.send.requested_reply = (strcmp (send_requested_reply, "true") == 0);
1394 rule->d.send.message_type = message_type;
1395 rule->d.send.path = _dbus_strdup (send_path);
1396 rule->d.send.interface = _dbus_strdup (send_interface);
1397 rule->d.send.member = _dbus_strdup (send_member);
1398 rule->d.send.error = _dbus_strdup (send_error);
1399 rule->d.send.destination = _dbus_strdup (send_destination);
1400 if (send_path && rule->d.send.path == NULL)
1402 if (send_interface && rule->d.send.interface == NULL)
1404 if (send_member && rule->d.send.member == NULL)
1406 if (send_error && rule->d.send.error == NULL)
1408 if (send_destination && rule->d.send.destination == NULL)
1411 else if (receive_interface || receive_member || receive_error || receive_sender ||
1412 receive_path || receive_type || eavesdrop || receive_requested_reply)
1416 if (IS_WILDCARD (receive_interface))
1417 receive_interface = NULL;
1418 if (IS_WILDCARD (receive_member))
1419 receive_member = NULL;
1420 if (IS_WILDCARD (receive_error))
1421 receive_error = NULL;
1422 if (IS_WILDCARD (receive_sender))
1423 receive_sender = NULL;
1424 if (IS_WILDCARD (receive_path))
1425 receive_path = NULL;
1426 if (IS_WILDCARD (receive_type))
1427 receive_type = NULL;
1429 message_type = DBUS_MESSAGE_TYPE_INVALID;
1430 if (receive_type != NULL)
1432 message_type = dbus_message_type_from_string (receive_type);
1433 if (message_type == DBUS_MESSAGE_TYPE_INVALID)
1435 dbus_set_error (error, DBUS_ERROR_FAILED,
1436 "Bad message type \"%s\"",
1444 !(strcmp (eavesdrop, "true") == 0 ||
1445 strcmp (eavesdrop, "false") == 0))
1447 dbus_set_error (error, DBUS_ERROR_FAILED,
1448 "Bad value \"%s\" for %s attribute, must be true or false",
1449 "eavesdrop", eavesdrop);
1453 if (receive_requested_reply &&
1454 !(strcmp (receive_requested_reply, "true") == 0 ||
1455 strcmp (receive_requested_reply, "false") == 0))
1457 dbus_set_error (error, DBUS_ERROR_FAILED,
1458 "Bad value \"%s\" for %s attribute, must be true or false",
1459 "receive_requested_reply", receive_requested_reply);
1463 rule = bus_policy_rule_new (BUS_POLICY_RULE_RECEIVE, allow);
1468 rule->d.receive.eavesdrop = (strcmp (eavesdrop, "true") == 0);
1470 if (receive_requested_reply)
1471 rule->d.receive.requested_reply = (strcmp (receive_requested_reply, "true") == 0);
1473 rule->d.receive.message_type = message_type;
1474 rule->d.receive.path = _dbus_strdup (receive_path);
1475 rule->d.receive.interface = _dbus_strdup (receive_interface);
1476 rule->d.receive.member = _dbus_strdup (receive_member);
1477 rule->d.receive.error = _dbus_strdup (receive_error);
1478 rule->d.receive.origin = _dbus_strdup (receive_sender);
1480 if (receive_path && rule->d.receive.path == NULL)
1482 if (receive_interface && rule->d.receive.interface == NULL)
1484 if (receive_member && rule->d.receive.member == NULL)
1486 if (receive_error && rule->d.receive.error == NULL)
1488 if (receive_sender && rule->d.receive.origin == NULL)
1493 rule = bus_policy_rule_new (BUS_POLICY_RULE_OWN, allow);
1497 if (IS_WILDCARD (own))
1500 rule->d.own.service_name = _dbus_strdup (own);
1501 if (own && rule->d.own.service_name == NULL)
1506 if (IS_WILDCARD (user))
1508 rule = bus_policy_rule_new (BUS_POLICY_RULE_USER, allow);
1512 rule->d.user.uid = DBUS_UID_UNSET;
1516 DBusString username;
1519 _dbus_string_init_const (&username, user);
1521 if (_dbus_parse_unix_user_from_config (&username, &uid))
1523 rule = bus_policy_rule_new (BUS_POLICY_RULE_USER, allow);
1527 rule->d.user.uid = uid;
1531 _dbus_warn ("Unknown username \"%s\" on element <%s>\n",
1532 user, element_name);
1538 if (IS_WILDCARD (group))
1540 rule = bus_policy_rule_new (BUS_POLICY_RULE_GROUP, allow);
1544 rule->d.group.gid = DBUS_GID_UNSET;
1548 DBusString groupname;
1551 _dbus_string_init_const (&groupname, group);
1553 if (_dbus_parse_unix_group_from_config (&groupname, &gid))
1555 rule = bus_policy_rule_new (BUS_POLICY_RULE_GROUP, allow);
1559 rule->d.group.gid = gid;
1563 _dbus_warn ("Unknown group \"%s\" on element <%s>\n",
1564 group, element_name);
1569 _dbus_assert_not_reached ("Did not handle some combination of attributes on <allow> or <deny>");
1575 pe = peek_element (parser);
1576 _dbus_assert (pe != NULL);
1577 _dbus_assert (pe->type == ELEMENT_POLICY);
1579 switch (pe->d.policy.type)
1581 case POLICY_IGNORED:
1582 /* drop the rule on the floor */
1585 case POLICY_DEFAULT:
1586 if (!bus_policy_append_default_rule (parser->policy, rule))
1589 case POLICY_MANDATORY:
1590 if (!bus_policy_append_mandatory_rule (parser->policy, rule))
1594 if (!BUS_POLICY_RULE_IS_PER_CLIENT (rule))
1596 dbus_set_error (error, DBUS_ERROR_FAILED,
1597 "<%s> rule cannot be per-user because it has bus-global semantics",
1602 if (!bus_policy_append_user_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1607 if (!BUS_POLICY_RULE_IS_PER_CLIENT (rule))
1609 dbus_set_error (error, DBUS_ERROR_FAILED,
1610 "<%s> rule cannot be per-group because it has bus-global semantics",
1615 if (!bus_policy_append_group_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1621 case POLICY_CONSOLE:
1622 if (!bus_policy_append_console_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1628 bus_policy_rule_unref (rule);
1635 BUS_SET_OOM (error);
1638 bus_policy_rule_unref (rule);
1643 start_policy_child (BusConfigParser *parser,
1644 const char *element_name,
1645 const char **attribute_names,
1646 const char **attribute_values,
1649 if (strcmp (element_name, "allow") == 0)
1651 if (!append_rule_from_element (parser, element_name,
1652 attribute_names, attribute_values,
1656 if (push_element (parser, ELEMENT_ALLOW) == NULL)
1658 BUS_SET_OOM (error);
1664 else if (strcmp (element_name, "deny") == 0)
1666 if (!append_rule_from_element (parser, element_name,
1667 attribute_names, attribute_values,
1671 if (push_element (parser, ELEMENT_DENY) == NULL)
1673 BUS_SET_OOM (error);
1681 dbus_set_error (error, DBUS_ERROR_FAILED,
1682 "Element <%s> not allowed inside <%s> in configuration file",
1683 element_name, "policy");
1689 start_selinux_child (BusConfigParser *parser,
1690 const char *element_name,
1691 const char **attribute_names,
1692 const char **attribute_values,
1699 context_copy = NULL;
1701 if (strcmp (element_name, "associate") == 0)
1704 const char *context;
1706 if (!locate_attributes (parser, "associate",
1711 "context", &context,
1715 if (push_element (parser, ELEMENT_ASSOCIATE) == NULL)
1717 BUS_SET_OOM (error);
1721 if (own == NULL || context == NULL)
1723 dbus_set_error (error, DBUS_ERROR_FAILED,
1724 "Element <associate> must have attributes own=\"<servicename>\" and context=\"<selinux context>\"");
1728 own_copy = _dbus_strdup (own);
1729 if (own_copy == NULL)
1731 context_copy = _dbus_strdup (context);
1732 if (context_copy == NULL)
1735 if (!_dbus_hash_table_insert_string (parser->service_context_table,
1736 own_copy, context_copy))
1743 dbus_set_error (error, DBUS_ERROR_FAILED,
1744 "Element <%s> not allowed inside <%s> in configuration file",
1745 element_name, "selinux");
1751 dbus_free (own_copy);
1754 dbus_free (context_copy);
1756 BUS_SET_OOM (error);
1761 bus_config_parser_start_element (BusConfigParser *parser,
1762 const char *element_name,
1763 const char **attribute_names,
1764 const char **attribute_values,
1769 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1771 /* printf ("START: %s\n", element_name); */
1773 t = top_element_type (parser);
1775 if (t == ELEMENT_NONE)
1777 if (strcmp (element_name, "busconfig") == 0)
1779 if (!check_no_attributes (parser, "busconfig", attribute_names, attribute_values, error))
1782 if (push_element (parser, ELEMENT_BUSCONFIG) == NULL)
1784 BUS_SET_OOM (error);
1792 dbus_set_error (error, DBUS_ERROR_FAILED,
1793 "Unknown element <%s> at root of configuration file",
1798 else if (t == ELEMENT_BUSCONFIG)
1800 return start_busconfig_child (parser, element_name,
1801 attribute_names, attribute_values,
1804 else if (t == ELEMENT_POLICY)
1806 return start_policy_child (parser, element_name,
1807 attribute_names, attribute_values,
1810 else if (t == ELEMENT_SELINUX)
1812 return start_selinux_child (parser, element_name,
1813 attribute_names, attribute_values,
1818 dbus_set_error (error, DBUS_ERROR_FAILED,
1819 "Element <%s> is not allowed in this context",
1826 set_limit (BusConfigParser *parser,
1831 dbus_bool_t must_be_positive;
1832 dbus_bool_t must_be_int;
1834 must_be_int = FALSE;
1835 must_be_positive = FALSE;
1837 if (strcmp (name, "max_incoming_bytes") == 0)
1839 must_be_positive = TRUE;
1840 parser->limits.max_incoming_bytes = value;
1842 else if (strcmp (name, "max_incoming_unix_fds") == 0)
1844 must_be_positive = TRUE;
1845 parser->limits.max_incoming_unix_fds = value;
1847 else if (strcmp (name, "max_outgoing_bytes") == 0)
1849 must_be_positive = TRUE;
1850 parser->limits.max_outgoing_bytes = value;
1852 else if (strcmp (name, "max_outgoing_unix_fds") == 0)
1854 must_be_positive = TRUE;
1855 parser->limits.max_outgoing_unix_fds = value;
1857 else if (strcmp (name, "max_message_size") == 0)
1859 must_be_positive = TRUE;
1860 parser->limits.max_message_size = value;
1862 else if (strcmp (name, "max_message_unix_fds") == 0)
1864 must_be_positive = TRUE;
1865 parser->limits.max_message_unix_fds = value;
1867 else if (strcmp (name, "service_start_timeout") == 0)
1869 must_be_positive = TRUE;
1871 parser->limits.activation_timeout = value;
1873 else if (strcmp (name, "auth_timeout") == 0)
1875 must_be_positive = TRUE;
1877 parser->limits.auth_timeout = value;
1879 else if (strcmp (name, "reply_timeout") == 0)
1881 must_be_positive = TRUE;
1883 parser->limits.reply_timeout = value;
1885 else if (strcmp (name, "max_completed_connections") == 0)
1887 must_be_positive = TRUE;
1889 parser->limits.max_completed_connections = value;
1891 else if (strcmp (name, "max_incomplete_connections") == 0)
1893 must_be_positive = TRUE;
1895 parser->limits.max_incomplete_connections = value;
1897 else if (strcmp (name, "max_connections_per_user") == 0)
1899 must_be_positive = TRUE;
1901 parser->limits.max_connections_per_user = value;
1903 else if (strcmp (name, "max_pending_service_starts") == 0)
1905 must_be_positive = TRUE;
1907 parser->limits.max_pending_activations = value;
1909 else if (strcmp (name, "max_names_per_connection") == 0)
1911 must_be_positive = TRUE;
1913 parser->limits.max_services_per_connection = value;
1915 else if (strcmp (name, "max_match_rules_per_connection") == 0)
1917 must_be_positive = TRUE;
1919 parser->limits.max_match_rules_per_connection = value;
1921 else if (strcmp (name, "max_replies_per_connection") == 0)
1923 must_be_positive = TRUE;
1925 parser->limits.max_replies_per_connection = value;
1929 dbus_set_error (error, DBUS_ERROR_FAILED,
1930 "There is no limit called \"%s\"\n",
1935 if (must_be_positive && value < 0)
1937 dbus_set_error (error, DBUS_ERROR_FAILED,
1938 "<limit name=\"%s\"> must be a positive number\n",
1944 (value < _DBUS_INT_MIN || value > _DBUS_INT_MAX))
1946 dbus_set_error (error, DBUS_ERROR_FAILED,
1947 "<limit name=\"%s\"> value is too large\n",
1956 bus_config_parser_end_element (BusConfigParser *parser,
1957 const char *element_name,
1964 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1966 /* printf ("END: %s\n", element_name); */
1968 t = top_element_type (parser);
1970 if (t == ELEMENT_NONE)
1972 /* should probably be an assertion failure but
1973 * being paranoid about XML parsers
1975 dbus_set_error (error, DBUS_ERROR_FAILED,
1976 "XML parser ended element with no element on the stack");
1980 n = bus_config_parser_element_type_to_name (t);
1981 _dbus_assert (n != NULL);
1982 if (strcmp (n, element_name) != 0)
1984 /* should probably be an assertion failure but
1985 * being paranoid about XML parsers
1987 dbus_set_error (error, DBUS_ERROR_FAILED,
1988 "XML element <%s> ended but topmost element on the stack was <%s>",
1993 e = peek_element (parser);
1994 _dbus_assert (e != NULL);
1999 _dbus_assert_not_reached ("element in stack has no type");
2002 case ELEMENT_INCLUDE:
2004 case ELEMENT_CONFIGTYPE:
2005 case ELEMENT_LISTEN:
2006 case ELEMENT_PIDFILE:
2008 case ELEMENT_SERVICEDIR:
2009 case ELEMENT_SERVICEHELPER:
2010 case ELEMENT_INCLUDEDIR:
2012 if (!e->had_content)
2014 dbus_set_error (error, DBUS_ERROR_FAILED,
2015 "XML element <%s> was expected to have content inside it",
2016 bus_config_parser_element_type_to_name (e->type));
2020 if (e->type == ELEMENT_LIMIT)
2022 if (!set_limit (parser, e->d.limit.name, e->d.limit.value,
2028 case ELEMENT_BUSCONFIG:
2029 case ELEMENT_POLICY:
2033 case ELEMENT_SYSLOG:
2034 case ELEMENT_KEEP_UMASK:
2035 case ELEMENT_SELINUX:
2036 case ELEMENT_ASSOCIATE:
2037 case ELEMENT_STANDARD_SESSION_SERVICEDIRS:
2038 case ELEMENT_STANDARD_SYSTEM_SERVICEDIRS:
2039 case ELEMENT_ALLOW_ANONYMOUS:
2043 pop_element (parser);
2049 all_whitespace (const DBusString *str)
2053 _dbus_string_skip_white (str, 0, &i);
2055 return i == _dbus_string_get_length (str);
2059 make_full_path (const DBusString *basedir,
2060 const DBusString *filename,
2061 DBusString *full_path)
2063 if (_dbus_path_is_absolute (filename))
2065 return _dbus_string_copy (filename, 0, full_path, 0);
2069 if (!_dbus_string_copy (basedir, 0, full_path, 0))
2072 if (!_dbus_concat_dir_and_file (full_path, filename))
2080 include_file (BusConfigParser *parser,
2081 const DBusString *filename,
2082 dbus_bool_t ignore_missing,
2085 /* FIXME good test case for this would load each config file in the
2086 * test suite both alone, and as an include, and check
2087 * that the result is the same
2089 BusConfigParser *included;
2090 const char *filename_str;
2091 DBusError tmp_error;
2093 dbus_error_init (&tmp_error);
2095 filename_str = _dbus_string_get_const_data (filename);
2097 /* Check to make sure this file hasn't already been included. */
2098 if (seen_include (parser, filename))
2100 dbus_set_error (error, DBUS_ERROR_FAILED,
2101 "Circular inclusion of file '%s'",
2106 if (! _dbus_list_append (&parser->included_files, (void *) filename_str))
2108 BUS_SET_OOM (error);
2112 /* Since parser is passed in as the parent, included
2113 inherits parser's limits. */
2114 included = bus_config_load (filename, FALSE, parser, &tmp_error);
2116 _dbus_list_pop_last (&parser->included_files);
2118 if (included == NULL)
2120 _DBUS_ASSERT_ERROR_IS_SET (&tmp_error);
2122 if (dbus_error_has_name (&tmp_error, DBUS_ERROR_FILE_NOT_FOUND) &&
2125 dbus_error_free (&tmp_error);
2130 dbus_move_error (&tmp_error, error);
2136 _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
2138 if (!merge_included (parser, included, error))
2140 bus_config_parser_unref (included);
2144 /* Copy included's limits back to parser. */
2145 parser->limits = included->limits;
2147 bus_config_parser_unref (included);
2153 servicehelper_path (BusConfigParser *parser,
2154 const DBusString *filename,
2157 const char *filename_str;
2158 char *servicehelper;
2160 filename_str = _dbus_string_get_const_data (filename);
2162 /* copy to avoid overwriting with NULL on OOM */
2163 servicehelper = _dbus_strdup (filename_str);
2166 if (servicehelper == NULL)
2168 BUS_SET_OOM (error);
2172 /* save the latest servicehelper only if not OOM */
2173 dbus_free (parser->servicehelper);
2174 parser->servicehelper = servicehelper;
2176 /* We don't check whether the helper exists; instead we
2177 * would just fail to ever activate anything if it doesn't.
2178 * This allows an admin to fix the problem if it doesn't exist.
2179 * It also allows the parser test suite to successfully parse
2180 * test cases without installing the helper. ;-)
2187 include_dir (BusConfigParser *parser,
2188 const DBusString *dirname,
2191 DBusString filename;
2193 DBusError tmp_error;
2197 if (!_dbus_string_init (&filename))
2199 BUS_SET_OOM (error);
2205 dir = _dbus_directory_open (dirname, error);
2210 dbus_error_init (&tmp_error);
2211 while (_dbus_directory_get_next_file (dir, &filename, &tmp_error))
2213 DBusString full_path;
2215 if (!_dbus_string_init (&full_path))
2217 BUS_SET_OOM (error);
2221 if (!_dbus_string_copy (dirname, 0, &full_path, 0))
2223 BUS_SET_OOM (error);
2224 _dbus_string_free (&full_path);
2228 if (!_dbus_concat_dir_and_file (&full_path, &filename))
2230 BUS_SET_OOM (error);
2231 _dbus_string_free (&full_path);
2235 if (_dbus_string_ends_with_c_str (&full_path, ".conf"))
2237 if (!include_file (parser, &full_path, TRUE, error))
2239 if (dbus_error_is_set (error))
2241 /* We log to syslog unconditionally here, because this is
2242 * the configuration parser, so we don't yet know whether
2243 * this bus is going to want to write to syslog! (There's
2244 * also some layer inversion going on, if we want to use
2245 * the bus context.) */
2246 _dbus_system_log (DBUS_SYSTEM_LOG_INFO,
2247 "Encountered error '%s' while parsing '%s'\n",
2249 _dbus_string_get_const_data (&full_path));
2250 dbus_error_free (error);
2255 _dbus_string_free (&full_path);
2258 if (dbus_error_is_set (&tmp_error))
2260 dbus_move_error (&tmp_error, error);
2265 if (!_dbus_string_copy_data (dirname, &s))
2267 BUS_SET_OOM (error);
2271 if (!_dbus_list_append (&parser->conf_dirs, s))
2274 BUS_SET_OOM (error);
2281 _dbus_string_free (&filename);
2284 _dbus_directory_close (dir);
2290 bus_config_parser_content (BusConfigParser *parser,
2291 const DBusString *content,
2296 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2302 _dbus_string_get_const_data (content, &c_str);
2304 printf ("CONTENT %d bytes: %s\n", _dbus_string_get_length (content), c_str);
2308 e = peek_element (parser);
2311 dbus_set_error (error, DBUS_ERROR_FAILED,
2312 "Text content outside of any XML element in configuration file");
2315 else if (e->had_content)
2317 _dbus_assert_not_reached ("Element had multiple content blocks");
2321 switch (top_element_type (parser))
2324 _dbus_assert_not_reached ("element at top of stack has no type");
2327 case ELEMENT_BUSCONFIG:
2328 case ELEMENT_POLICY:
2332 case ELEMENT_SYSLOG:
2333 case ELEMENT_KEEP_UMASK:
2334 case ELEMENT_STANDARD_SESSION_SERVICEDIRS:
2335 case ELEMENT_STANDARD_SYSTEM_SERVICEDIRS:
2336 case ELEMENT_ALLOW_ANONYMOUS:
2337 case ELEMENT_SELINUX:
2338 case ELEMENT_ASSOCIATE:
2339 if (all_whitespace (content))
2343 dbus_set_error (error, DBUS_ERROR_FAILED,
2344 "No text content expected inside XML element %s in configuration file",
2345 bus_config_parser_element_type_to_name (top_element_type (parser)));
2349 case ELEMENT_PIDFILE:
2353 e->had_content = TRUE;
2355 if (!_dbus_string_copy_data (content, &s))
2358 dbus_free (parser->pidfile);
2359 parser->pidfile = s;
2363 case ELEMENT_INCLUDE:
2365 DBusString full_path, selinux_policy_root;
2367 e->had_content = TRUE;
2369 if (e->d.include.if_selinux_enabled
2370 && !bus_selinux_enabled ())
2373 if (!_dbus_string_init (&full_path))
2376 if (e->d.include.selinux_root_relative)
2378 if (!bus_selinux_get_policy_root ())
2380 dbus_set_error (error, DBUS_ERROR_FAILED,
2381 "Could not determine SELinux policy root for relative inclusion");
2382 _dbus_string_free (&full_path);
2385 _dbus_string_init_const (&selinux_policy_root,
2386 bus_selinux_get_policy_root ());
2387 if (!make_full_path (&selinux_policy_root, content, &full_path))
2389 _dbus_string_free (&full_path);
2393 else if (!make_full_path (&parser->basedir, content, &full_path))
2395 _dbus_string_free (&full_path);
2399 if (!include_file (parser, &full_path,
2400 e->d.include.ignore_missing, error))
2402 _dbus_string_free (&full_path);
2406 _dbus_string_free (&full_path);
2410 case ELEMENT_SERVICEHELPER:
2412 DBusString full_path;
2414 e->had_content = TRUE;
2416 if (!_dbus_string_init (&full_path))
2419 if (!make_full_path (&parser->basedir, content, &full_path))
2421 _dbus_string_free (&full_path);
2425 if (!servicehelper_path (parser, &full_path, error))
2427 _dbus_string_free (&full_path);
2431 _dbus_string_free (&full_path);
2435 case ELEMENT_INCLUDEDIR:
2437 DBusString full_path;
2439 e->had_content = TRUE;
2441 if (!_dbus_string_init (&full_path))
2444 if (!make_full_path (&parser->basedir, content, &full_path))
2446 _dbus_string_free (&full_path);
2450 if (!include_dir (parser, &full_path, error))
2452 _dbus_string_free (&full_path);
2456 _dbus_string_free (&full_path);
2464 e->had_content = TRUE;
2466 if (!_dbus_string_copy_data (content, &s))
2469 dbus_free (parser->user);
2474 case ELEMENT_CONFIGTYPE:
2478 e->had_content = TRUE;
2480 if (!_dbus_string_copy_data (content, &s))
2483 dbus_free (parser->bus_type);
2484 parser->bus_type = s;
2488 case ELEMENT_LISTEN:
2492 e->had_content = TRUE;
2494 if (!_dbus_string_copy_data (content, &s))
2497 if (!_dbus_list_append (&parser->listen_on,
2510 e->had_content = TRUE;
2512 if (!_dbus_string_copy_data (content, &s))
2515 if (!_dbus_list_append (&parser->mechanisms,
2524 case ELEMENT_SERVICEDIR:
2527 DBusString full_path;
2529 e->had_content = TRUE;
2531 if (!_dbus_string_init (&full_path))
2534 if (!make_full_path (&parser->basedir, content, &full_path))
2536 _dbus_string_free (&full_path);
2540 if (!_dbus_string_copy_data (&full_path, &s))
2542 _dbus_string_free (&full_path);
2546 /* _only_ extra session directories can be specified */
2547 if (!service_dirs_append_unique_or_free (&parser->service_dirs, s))
2549 _dbus_string_free (&full_path);
2554 _dbus_string_free (&full_path);
2562 e->had_content = TRUE;
2565 if (!_dbus_string_parse_int (content, 0, &val, NULL))
2567 dbus_set_error (error, DBUS_ERROR_FAILED,
2568 "<limit name=\"%s\"> element has invalid value (could not parse as integer)",
2573 e->d.limit.value = val;
2575 _dbus_verbose ("Loaded value %ld for limit %s\n",
2582 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2586 BUS_SET_OOM (error);
2591 bus_config_parser_finished (BusConfigParser *parser,
2594 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2596 if (parser->stack != NULL)
2598 dbus_set_error (error, DBUS_ERROR_FAILED,
2599 "Element <%s> was not closed in configuration file",
2600 bus_config_parser_element_type_to_name (top_element_type (parser)));
2605 if (parser->is_toplevel && parser->listen_on == NULL)
2607 dbus_set_error (error, DBUS_ERROR_FAILED,
2608 "Configuration file needs one or more <listen> elements giving addresses");
2616 bus_config_parser_get_user (BusConfigParser *parser)
2618 return parser->user;
2622 bus_config_parser_get_type (BusConfigParser *parser)
2624 return parser->bus_type;
2628 bus_config_parser_get_addresses (BusConfigParser *parser)
2630 return &parser->listen_on;
2634 bus_config_parser_get_mechanisms (BusConfigParser *parser)
2636 return &parser->mechanisms;
2640 bus_config_parser_get_service_dirs (BusConfigParser *parser)
2642 return &parser->service_dirs;
2646 bus_config_parser_get_conf_dirs (BusConfigParser *parser)
2648 return &parser->conf_dirs;
2652 bus_config_parser_get_fork (BusConfigParser *parser)
2654 return parser->fork;
2658 bus_config_parser_get_syslog (BusConfigParser *parser)
2660 return parser->syslog;
2664 bus_config_parser_get_keep_umask (BusConfigParser *parser)
2666 return parser->keep_umask;
2670 bus_config_parser_get_allow_anonymous (BusConfigParser *parser)
2672 return parser->allow_anonymous;
2676 bus_config_parser_get_pidfile (BusConfigParser *parser)
2678 return parser->pidfile;
2682 bus_config_parser_get_servicehelper (BusConfigParser *parser)
2684 return parser->servicehelper;
2688 bus_config_parser_steal_policy (BusConfigParser *parser)
2692 _dbus_assert (parser->policy != NULL); /* can only steal the policy 1 time */
2694 policy = parser->policy;
2696 parser->policy = NULL;
2701 /* Overwrite any limits that were set in the configuration file */
2703 bus_config_parser_get_limits (BusConfigParser *parser,
2706 *limits = parser->limits;
2710 bus_config_parser_steal_service_context_table (BusConfigParser *parser)
2712 DBusHashTable *table;
2714 _dbus_assert (parser->service_context_table != NULL); /* can only steal once */
2716 table = parser->service_context_table;
2718 parser->service_context_table = NULL;
2723 #ifdef DBUS_BUILD_TESTS
2734 do_load (const DBusString *full_path,
2736 dbus_bool_t oom_possible)
2738 BusConfigParser *parser;
2741 dbus_error_init (&error);
2743 parser = bus_config_load (full_path, TRUE, NULL, &error);
2746 _DBUS_ASSERT_ERROR_IS_SET (&error);
2749 dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
2751 _dbus_verbose ("Failed to load valid file due to OOM\n");
2752 dbus_error_free (&error);
2755 else if (validity == VALID)
2757 _dbus_warn ("Failed to load valid file but still had memory: %s\n",
2760 dbus_error_free (&error);
2765 dbus_error_free (&error);
2771 _DBUS_ASSERT_ERROR_IS_CLEAR (&error);
2773 bus_config_parser_unref (parser);
2775 if (validity == INVALID)
2777 _dbus_warn ("Accepted invalid file\n");
2787 const DBusString *full_path;
2792 check_loader_oom_func (void *data)
2794 LoaderOomData *d = data;
2796 return do_load (d->full_path, d->validity, TRUE);
2800 process_test_valid_subdir (const DBusString *test_base_dir,
2804 DBusString test_directory;
2805 DBusString filename;
2813 if (!_dbus_string_init (&test_directory))
2814 _dbus_assert_not_reached ("didn't allocate test_directory\n");
2816 _dbus_string_init_const (&filename, subdir);
2818 if (!_dbus_string_copy (test_base_dir, 0,
2819 &test_directory, 0))
2820 _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory");
2822 if (!_dbus_concat_dir_and_file (&test_directory, &filename))
2823 _dbus_assert_not_reached ("couldn't allocate full path");
2825 _dbus_string_free (&filename);
2826 if (!_dbus_string_init (&filename))
2827 _dbus_assert_not_reached ("didn't allocate filename string\n");
2829 dbus_error_init (&error);
2830 dir = _dbus_directory_open (&test_directory, &error);
2833 _dbus_warn ("Could not open %s: %s\n",
2834 _dbus_string_get_const_data (&test_directory),
2836 dbus_error_free (&error);
2840 if (validity == VALID)
2841 printf ("Testing valid files:\n");
2842 else if (validity == INVALID)
2843 printf ("Testing invalid files:\n");
2845 printf ("Testing unknown files:\n");
2848 while (_dbus_directory_get_next_file (dir, &filename, &error))
2850 DBusString full_path;
2853 if (!_dbus_string_init (&full_path))
2854 _dbus_assert_not_reached ("couldn't init string");
2856 if (!_dbus_string_copy (&test_directory, 0, &full_path, 0))
2857 _dbus_assert_not_reached ("couldn't copy dir to full_path");
2859 if (!_dbus_concat_dir_and_file (&full_path, &filename))
2860 _dbus_assert_not_reached ("couldn't concat file to dir");
2862 if (!_dbus_string_ends_with_c_str (&full_path, ".conf"))
2864 _dbus_verbose ("Skipping non-.conf file %s\n",
2865 _dbus_string_get_const_data (&filename));
2866 _dbus_string_free (&full_path);
2870 printf (" %s\n", _dbus_string_get_const_data (&filename));
2872 _dbus_verbose (" expecting %s\n",
2873 validity == VALID ? "valid" :
2874 (validity == INVALID ? "invalid" :
2875 (validity == UNKNOWN ? "unknown" : "???")));
2877 d.full_path = &full_path;
2878 d.validity = validity;
2880 /* FIXME hackaround for an expat problem, see
2881 * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=124747
2882 * http://freedesktop.org/pipermail/dbus/2004-May/001153.html
2884 /* if (!_dbus_test_oom_handling ("config-loader", check_loader_oom_func, &d)) */
2885 if (!check_loader_oom_func (&d))
2886 _dbus_assert_not_reached ("test failed");
2888 _dbus_string_free (&full_path);
2891 if (dbus_error_is_set (&error))
2893 _dbus_warn ("Could not get next file in %s: %s\n",
2894 _dbus_string_get_const_data (&test_directory),
2896 dbus_error_free (&error);
2905 _dbus_directory_close (dir);
2906 _dbus_string_free (&test_directory);
2907 _dbus_string_free (&filename);
2913 bools_equal (dbus_bool_t a,
2920 strings_equal_or_both_null (const char *a,
2923 if (a == NULL || b == NULL)
2926 return !strcmp (a, b);
2930 elements_equal (const Element *a,
2933 if (a->type != b->type)
2936 if (!bools_equal (a->had_content, b->had_content))
2942 case ELEMENT_INCLUDE:
2943 if (!bools_equal (a->d.include.ignore_missing,
2944 b->d.include.ignore_missing))
2948 case ELEMENT_POLICY:
2949 if (a->d.policy.type != b->d.policy.type)
2951 if (a->d.policy.gid_uid_or_at_console != b->d.policy.gid_uid_or_at_console)
2956 if (strcmp (a->d.limit.name, b->d.limit.name))
2958 if (a->d.limit.value != b->d.limit.value)
2972 lists_of_elements_equal (DBusList *a,
2981 while (ia != NULL && ib != NULL)
2983 if (elements_equal (ia->data, ib->data))
2985 ia = _dbus_list_get_next_link (&a, ia);
2986 ib = _dbus_list_get_next_link (&b, ib);
2989 return ia == NULL && ib == NULL;
2993 lists_of_c_strings_equal (DBusList *a,
3002 while (ia != NULL && ib != NULL)
3004 if (strcmp (ia->data, ib->data))
3006 ia = _dbus_list_get_next_link (&a, ia);
3007 ib = _dbus_list_get_next_link (&b, ib);
3010 return ia == NULL && ib == NULL;
3014 limits_equal (const BusLimits *a,
3018 (a->max_incoming_bytes == b->max_incoming_bytes
3019 || a->max_incoming_unix_fds == b->max_incoming_unix_fds
3020 || a->max_outgoing_bytes == b->max_outgoing_bytes
3021 || a->max_outgoing_unix_fds == b->max_outgoing_unix_fds
3022 || a->max_message_size == b->max_message_size
3023 || a->max_message_unix_fds == b->max_message_unix_fds
3024 || a->activation_timeout == b->activation_timeout
3025 || a->auth_timeout == b->auth_timeout
3026 || a->max_completed_connections == b->max_completed_connections
3027 || a->max_incomplete_connections == b->max_incomplete_connections
3028 || a->max_connections_per_user == b->max_connections_per_user
3029 || a->max_pending_activations == b->max_pending_activations
3030 || a->max_services_per_connection == b->max_services_per_connection
3031 || a->max_match_rules_per_connection == b->max_match_rules_per_connection
3032 || a->max_replies_per_connection == b->max_replies_per_connection
3033 || a->reply_timeout == b->reply_timeout);
3037 config_parsers_equal (const BusConfigParser *a,
3038 const BusConfigParser *b)
3040 if (!_dbus_string_equal (&a->basedir, &b->basedir))
3043 if (!lists_of_elements_equal (a->stack, b->stack))
3046 if (!strings_equal_or_both_null (a->user, b->user))
3049 if (!lists_of_c_strings_equal (a->listen_on, b->listen_on))
3052 if (!lists_of_c_strings_equal (a->mechanisms, b->mechanisms))
3055 if (!lists_of_c_strings_equal (a->service_dirs, b->service_dirs))
3058 /* FIXME: compare policy */
3060 /* FIXME: compare service selinux ID table */
3062 if (! limits_equal (&a->limits, &b->limits))
3065 if (!strings_equal_or_both_null (a->pidfile, b->pidfile))
3068 if (! bools_equal (a->fork, b->fork))
3071 if (! bools_equal (a->keep_umask, b->keep_umask))
3074 if (! bools_equal (a->is_toplevel, b->is_toplevel))
3081 all_are_equiv (const DBusString *target_directory)
3083 DBusString filename;
3085 BusConfigParser *first_parser;
3086 BusConfigParser *parser;
3092 first_parser = NULL;
3096 if (!_dbus_string_init (&filename))
3097 _dbus_assert_not_reached ("didn't allocate filename string");
3099 dbus_error_init (&error);
3100 dir = _dbus_directory_open (target_directory, &error);
3103 _dbus_warn ("Could not open %s: %s\n",
3104 _dbus_string_get_const_data (target_directory),
3106 dbus_error_free (&error);
3110 printf ("Comparing equivalent files:\n");
3113 while (_dbus_directory_get_next_file (dir, &filename, &error))
3115 DBusString full_path;
3117 if (!_dbus_string_init (&full_path))
3118 _dbus_assert_not_reached ("couldn't init string");
3120 if (!_dbus_string_copy (target_directory, 0, &full_path, 0))
3121 _dbus_assert_not_reached ("couldn't copy dir to full_path");
3123 if (!_dbus_concat_dir_and_file (&full_path, &filename))
3124 _dbus_assert_not_reached ("couldn't concat file to dir");
3126 if (!_dbus_string_ends_with_c_str (&full_path, ".conf"))
3128 _dbus_verbose ("Skipping non-.conf file %s\n",
3129 _dbus_string_get_const_data (&filename));
3130 _dbus_string_free (&full_path);
3134 printf (" %s\n", _dbus_string_get_const_data (&filename));
3136 parser = bus_config_load (&full_path, TRUE, NULL, &error);
3140 _dbus_warn ("Could not load file %s: %s\n",
3141 _dbus_string_get_const_data (&full_path),
3143 _dbus_string_free (&full_path);
3144 dbus_error_free (&error);
3147 else if (first_parser == NULL)
3149 _dbus_string_free (&full_path);
3150 first_parser = parser;
3154 _dbus_string_free (&full_path);
3155 equal = config_parsers_equal (first_parser, parser);
3156 bus_config_parser_unref (parser);
3165 _dbus_string_free (&filename);
3167 bus_config_parser_unref (first_parser);
3169 _dbus_directory_close (dir);
3176 process_test_equiv_subdir (const DBusString *test_base_dir,
3179 DBusString test_directory;
3180 DBusString filename;
3189 if (!_dbus_string_init (&test_directory))
3190 _dbus_assert_not_reached ("didn't allocate test_directory");
3192 _dbus_string_init_const (&filename, subdir);
3194 if (!_dbus_string_copy (test_base_dir, 0,
3195 &test_directory, 0))
3196 _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory");
3198 if (!_dbus_concat_dir_and_file (&test_directory, &filename))
3199 _dbus_assert_not_reached ("couldn't allocate full path");
3201 _dbus_string_free (&filename);
3202 if (!_dbus_string_init (&filename))
3203 _dbus_assert_not_reached ("didn't allocate filename string");
3205 dbus_error_init (&error);
3206 dir = _dbus_directory_open (&test_directory, &error);
3209 _dbus_warn ("Could not open %s: %s\n",
3210 _dbus_string_get_const_data (&test_directory),
3212 dbus_error_free (&error);
3216 while (_dbus_directory_get_next_file (dir, &filename, &error))
3218 DBusString full_path;
3220 /* Skip CVS's magic directories! */
3221 if (_dbus_string_equal_c_str (&filename, "CVS"))
3224 if (!_dbus_string_init (&full_path))
3225 _dbus_assert_not_reached ("couldn't init string");
3227 if (!_dbus_string_copy (&test_directory, 0, &full_path, 0))
3228 _dbus_assert_not_reached ("couldn't copy dir to full_path");
3230 if (!_dbus_concat_dir_and_file (&full_path, &filename))
3231 _dbus_assert_not_reached ("couldn't concat file to dir");
3233 equal = all_are_equiv (&full_path);
3234 _dbus_string_free (&full_path);
3243 _dbus_string_free (&test_directory);
3244 _dbus_string_free (&filename);
3246 _dbus_directory_close (dir);
3252 static const char *test_session_service_dir_matches[] =
3255 "/testhome/foo/.testlocal/testshare/dbus-1/services",
3256 "/testusr/testlocal/testshare/dbus-1/services",
3257 "/testusr/testshare/dbus-1/services",
3258 DBUS_DATADIR"/dbus-1/services",
3260 /* will be filled in test_default_session_servicedirs() */
3269 test_default_session_servicedirs (void)
3277 const char *common_progs;
3280 if (_dbus_get_install_root(buffer, sizeof(buffer)))
3282 strcat(buffer,DBUS_DATADIR);
3283 strcat(buffer,"/dbus-1/services");
3284 test_session_service_dir_matches[0] = buffer;
3288 /* On Unix we don't actually use this variable, but it's easier to handle the
3289 * deallocation if we always allocate it, whether needed or not */
3290 if (!_dbus_string_init (&progs))
3291 _dbus_assert_not_reached ("OOM allocating progs");
3294 common_progs = _dbus_getenv ("CommonProgramFiles");
3298 if (!_dbus_string_append (&progs, common_progs))
3300 _dbus_string_free (&progs);
3304 if (!_dbus_string_append (&progs, "/dbus-1/services"))
3306 _dbus_string_free (&progs);
3309 test_session_service_dir_matches[1] = _dbus_string_get_const_data(&progs);
3314 printf ("Testing retrieving the default session service directories\n");
3315 if (!_dbus_get_standard_session_servicedirs (&dirs))
3316 _dbus_assert_not_reached ("couldn't get stardard dirs");
3318 /* make sure our defaults end with share/dbus-1/service */
3319 while ((link = _dbus_list_pop_first_link (&dirs)))
3323 printf (" default service dir: %s\n", (char *)link->data);
3324 _dbus_string_init_const (&path, (char *)link->data);
3325 if (!_dbus_string_ends_with_c_str (&path, "dbus-1/services"))
3327 printf ("error with default session service directories\n");
3328 dbus_free (link->data);
3329 _dbus_list_free_link (link);
3330 _dbus_string_free (&progs);
3334 dbus_free (link->data);
3335 _dbus_list_free_link (link);
3339 if (!_dbus_setenv ("XDG_DATA_HOME", "/testhome/foo/.testlocal/testshare"))
3340 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_HOME");
3342 if (!_dbus_setenv ("XDG_DATA_DIRS", ":/testusr/testlocal/testshare: :/testusr/testshare:"))
3343 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_DIRS");
3345 if (!_dbus_get_standard_session_servicedirs (&dirs))
3346 _dbus_assert_not_reached ("couldn't get stardard dirs");
3348 /* make sure we read and parse the env variable correctly */
3350 while ((link = _dbus_list_pop_first_link (&dirs)))
3352 printf (" test service dir: %s\n", (char *)link->data);
3353 if (test_session_service_dir_matches[i] == NULL)
3355 printf ("more directories parsed than in match set\n");
3356 dbus_free (link->data);
3357 _dbus_list_free_link (link);
3358 _dbus_string_free (&progs);
3362 if (strcmp (test_session_service_dir_matches[i],
3363 (char *)link->data) != 0)
3365 printf ("%s directory does not match %s in the match set\n",
3367 test_session_service_dir_matches[i]);
3368 dbus_free (link->data);
3369 _dbus_list_free_link (link);
3370 _dbus_string_free (&progs);
3376 dbus_free (link->data);
3377 _dbus_list_free_link (link);
3380 if (test_session_service_dir_matches[i] != NULL)
3382 printf ("extra data %s in the match set was not matched\n",
3383 test_session_service_dir_matches[i]);
3385 _dbus_string_free (&progs);
3389 _dbus_string_free (&progs);
3393 static const char *test_system_service_dir_matches[] =
3396 "/testusr/testlocal/testshare/dbus-1/system-services",
3397 "/testusr/testshare/dbus-1/system-services",
3399 DBUS_DATADIR"/dbus-1/system-services",
3401 "/lib/dbus-1/system-services",
3411 test_default_system_servicedirs (void)
3417 const char *common_progs;
3421 /* On Unix we don't actually use this variable, but it's easier to handle the
3422 * deallocation if we always allocate it, whether needed or not */
3423 if (!_dbus_string_init (&progs))
3424 _dbus_assert_not_reached ("OOM allocating progs");
3427 common_progs = _dbus_getenv ("CommonProgramFiles");
3431 if (!_dbus_string_append (&progs, common_progs))
3433 _dbus_string_free (&progs);
3437 if (!_dbus_string_append (&progs, "/dbus-1/system-services"))
3439 _dbus_string_free (&progs);
3442 test_system_service_dir_matches[1] = _dbus_string_get_const_data(&progs);
3447 printf ("Testing retrieving the default system service directories\n");
3448 if (!_dbus_get_standard_system_servicedirs (&dirs))
3449 _dbus_assert_not_reached ("couldn't get stardard dirs");
3451 /* make sure our defaults end with share/dbus-1/system-service */
3452 while ((link = _dbus_list_pop_first_link (&dirs)))
3456 printf (" default service dir: %s\n", (char *)link->data);
3457 _dbus_string_init_const (&path, (char *)link->data);
3458 if (!_dbus_string_ends_with_c_str (&path, "dbus-1/system-services"))
3460 printf ("error with default system service directories\n");
3461 dbus_free (link->data);
3462 _dbus_list_free_link (link);
3463 _dbus_string_free (&progs);
3467 dbus_free (link->data);
3468 _dbus_list_free_link (link);
3472 if (!_dbus_setenv ("XDG_DATA_HOME", "/testhome/foo/.testlocal/testshare"))
3473 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_HOME");
3475 if (!_dbus_setenv ("XDG_DATA_DIRS", ":/testusr/testlocal/testshare: :/testusr/testshare:"))
3476 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_DIRS");
3478 if (!_dbus_get_standard_system_servicedirs (&dirs))
3479 _dbus_assert_not_reached ("couldn't get stardard dirs");
3481 /* make sure we read and parse the env variable correctly */
3483 while ((link = _dbus_list_pop_first_link (&dirs)))
3485 printf (" test service dir: %s\n", (char *)link->data);
3486 if (test_system_service_dir_matches[i] == NULL)
3488 printf ("more directories parsed than in match set\n");
3489 dbus_free (link->data);
3490 _dbus_list_free_link (link);
3491 _dbus_string_free (&progs);
3495 if (strcmp (test_system_service_dir_matches[i],
3496 (char *)link->data) != 0)
3498 printf ("%s directory does not match %s in the match set\n",
3500 test_system_service_dir_matches[i]);
3501 dbus_free (link->data);
3502 _dbus_list_free_link (link);
3503 _dbus_string_free (&progs);
3509 dbus_free (link->data);
3510 _dbus_list_free_link (link);
3513 if (test_system_service_dir_matches[i] != NULL)
3515 printf ("extra data %s in the match set was not matched\n",
3516 test_system_service_dir_matches[i]);
3518 _dbus_string_free (&progs);
3522 _dbus_string_free (&progs);
3527 bus_config_parser_test (const DBusString *test_data_dir)
3529 if (test_data_dir == NULL ||
3530 _dbus_string_get_length (test_data_dir) == 0)
3532 printf ("No test data\n");
3536 if (!test_default_session_servicedirs())
3540 printf("default system service dir skipped\n");
3542 if (!test_default_system_servicedirs())
3546 if (!process_test_valid_subdir (test_data_dir, "valid-config-files", VALID))
3549 if (!process_test_valid_subdir (test_data_dir, "invalid-config-files", INVALID))
3552 if (!process_test_equiv_subdir (test_data_dir, "equiv-config-files"))
3558 #endif /* DBUS_BUILD_TESTS */