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,
1130 const char *send_interface;
1131 const char *send_member;
1132 const char *send_error;
1133 const char *send_destination;
1134 const char *send_path;
1135 const char *send_type;
1136 const char *receive_interface;
1137 const char *receive_member;
1138 const char *receive_error;
1139 const char *receive_sender;
1140 const char *receive_path;
1141 const char *receive_type;
1142 const char *eavesdrop;
1143 const char *send_requested_reply;
1144 const char *receive_requested_reply;
1149 BusPolicyRule *rule;
1151 if (!locate_attributes (parser, element_name,
1155 "send_interface", &send_interface,
1156 "send_member", &send_member,
1157 "send_error", &send_error,
1158 "send_destination", &send_destination,
1159 "send_path", &send_path,
1160 "send_type", &send_type,
1161 "receive_interface", &receive_interface,
1162 "receive_member", &receive_member,
1163 "receive_error", &receive_error,
1164 "receive_sender", &receive_sender,
1165 "receive_path", &receive_path,
1166 "receive_type", &receive_type,
1167 "eavesdrop", &eavesdrop,
1168 "send_requested_reply", &send_requested_reply,
1169 "receive_requested_reply", &receive_requested_reply,
1177 if (!(send_interface || send_member || send_error || send_destination ||
1178 send_type || send_path ||
1179 receive_interface || receive_member || receive_error || receive_sender ||
1180 receive_type || receive_path || eavesdrop ||
1181 send_requested_reply || receive_requested_reply ||
1182 own || user || group))
1184 dbus_set_error (error, DBUS_ERROR_FAILED,
1185 "Element <%s> must have one or more attributes",
1190 if ((send_member && (send_interface == NULL && send_path == NULL)) ||
1191 (receive_member && (receive_interface == NULL && receive_path == NULL)))
1193 dbus_set_error (error, DBUS_ERROR_FAILED,
1194 "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.",
1199 /* Allowed combinations of elements are:
1201 * base, must be all send or all receive:
1204 * interface + member
1207 * base send_ can combine with send_destination, send_path, send_type, send_requested_reply
1208 * base receive_ with receive_sender, receive_path, receive_type, receive_requested_reply, eavesdrop
1210 * user, group, own must occur alone
1212 * Pretty sure the below stuff is broken, FIXME think about it more.
1215 if (((send_interface && send_error) ||
1216 (send_interface && receive_interface) ||
1217 (send_interface && receive_member) ||
1218 (send_interface && receive_error) ||
1219 (send_interface && receive_sender) ||
1220 (send_interface && receive_requested_reply) ||
1221 (send_interface && own) ||
1222 (send_interface && user) ||
1223 (send_interface && group)) ||
1225 ((send_member && send_error) ||
1226 (send_member && receive_interface) ||
1227 (send_member && receive_member) ||
1228 (send_member && receive_error) ||
1229 (send_member && receive_sender) ||
1230 (send_member && receive_requested_reply) ||
1231 (send_member && own) ||
1232 (send_member && user) ||
1233 (send_member && group)) ||
1235 ((send_error && receive_interface) ||
1236 (send_error && receive_member) ||
1237 (send_error && receive_error) ||
1238 (send_error && receive_sender) ||
1239 (send_error && receive_requested_reply) ||
1240 (send_error && own) ||
1241 (send_error && user) ||
1242 (send_error && group)) ||
1244 ((send_destination && receive_interface) ||
1245 (send_destination && receive_member) ||
1246 (send_destination && receive_error) ||
1247 (send_destination && receive_sender) ||
1248 (send_destination && receive_requested_reply) ||
1249 (send_destination && own) ||
1250 (send_destination && user) ||
1251 (send_destination && group)) ||
1253 ((send_type && receive_interface) ||
1254 (send_type && receive_member) ||
1255 (send_type && receive_error) ||
1256 (send_type && receive_sender) ||
1257 (send_type && receive_requested_reply) ||
1258 (send_type && own) ||
1259 (send_type && user) ||
1260 (send_type && group)) ||
1262 ((send_path && receive_interface) ||
1263 (send_path && receive_member) ||
1264 (send_path && receive_error) ||
1265 (send_path && receive_sender) ||
1266 (send_path && receive_requested_reply) ||
1267 (send_path && own) ||
1268 (send_path && user) ||
1269 (send_path && group)) ||
1271 ((send_requested_reply && receive_interface) ||
1272 (send_requested_reply && receive_member) ||
1273 (send_requested_reply && receive_error) ||
1274 (send_requested_reply && receive_sender) ||
1275 (send_requested_reply && receive_requested_reply) ||
1276 (send_requested_reply && own) ||
1277 (send_requested_reply && user) ||
1278 (send_requested_reply && group)) ||
1280 ((receive_interface && receive_error) ||
1281 (receive_interface && own) ||
1282 (receive_interface && user) ||
1283 (receive_interface && group)) ||
1285 ((receive_member && receive_error) ||
1286 (receive_member && own) ||
1287 (receive_member && user) ||
1288 (receive_member && group)) ||
1290 ((receive_error && own) ||
1291 (receive_error && user) ||
1292 (receive_error && group)) ||
1294 ((eavesdrop && own) ||
1295 (eavesdrop && user) ||
1296 (eavesdrop && group)) ||
1298 ((receive_requested_reply && own) ||
1299 (receive_requested_reply && user) ||
1300 (receive_requested_reply && group)) ||
1307 dbus_set_error (error, DBUS_ERROR_FAILED,
1308 "Invalid combination of attributes on element <%s>",
1315 /* In BusPolicyRule, NULL represents wildcard.
1316 * In the config file, '*' represents it.
1318 #define IS_WILDCARD(str) ((str) && ((str)[0]) == '*' && ((str)[1]) == '\0')
1320 if (send_interface || send_member || send_error || send_destination ||
1321 send_path || send_type || send_requested_reply)
1325 if (IS_WILDCARD (send_interface))
1326 send_interface = NULL;
1327 if (IS_WILDCARD (send_member))
1329 if (IS_WILDCARD (send_error))
1331 if (IS_WILDCARD (send_destination))
1332 send_destination = NULL;
1333 if (IS_WILDCARD (send_path))
1335 if (IS_WILDCARD (send_type))
1338 message_type = DBUS_MESSAGE_TYPE_INVALID;
1339 if (send_type != NULL)
1341 message_type = dbus_message_type_from_string (send_type);
1342 if (message_type == DBUS_MESSAGE_TYPE_INVALID)
1344 dbus_set_error (error, DBUS_ERROR_FAILED,
1345 "Bad message type \"%s\"",
1352 !(strcmp (eavesdrop, "true") == 0 ||
1353 strcmp (eavesdrop, "false") == 0))
1355 dbus_set_error (error, DBUS_ERROR_FAILED,
1356 "Bad value \"%s\" for %s attribute, must be true or false",
1357 "eavesdrop", eavesdrop);
1361 if (send_requested_reply &&
1362 !(strcmp (send_requested_reply, "true") == 0 ||
1363 strcmp (send_requested_reply, "false") == 0))
1365 dbus_set_error (error, DBUS_ERROR_FAILED,
1366 "Bad value \"%s\" for %s attribute, must be true or false",
1367 "send_requested_reply", send_requested_reply);
1371 rule = bus_policy_rule_new (BUS_POLICY_RULE_SEND, allow);
1376 rule->d.send.eavesdrop = (strcmp (eavesdrop, "true") == 0);
1379 rule->d.send.log = (strcmp (log, "true") == 0);
1381 if (send_requested_reply)
1382 rule->d.send.requested_reply = (strcmp (send_requested_reply, "true") == 0);
1384 rule->d.send.message_type = message_type;
1385 rule->d.send.path = _dbus_strdup (send_path);
1386 rule->d.send.interface = _dbus_strdup (send_interface);
1387 rule->d.send.member = _dbus_strdup (send_member);
1388 rule->d.send.error = _dbus_strdup (send_error);
1389 rule->d.send.destination = _dbus_strdup (send_destination);
1390 if (send_path && rule->d.send.path == NULL)
1392 if (send_interface && rule->d.send.interface == NULL)
1394 if (send_member && rule->d.send.member == NULL)
1396 if (send_error && rule->d.send.error == NULL)
1398 if (send_destination && rule->d.send.destination == NULL)
1401 else if (receive_interface || receive_member || receive_error || receive_sender ||
1402 receive_path || receive_type || eavesdrop || receive_requested_reply)
1406 if (IS_WILDCARD (receive_interface))
1407 receive_interface = NULL;
1408 if (IS_WILDCARD (receive_member))
1409 receive_member = NULL;
1410 if (IS_WILDCARD (receive_error))
1411 receive_error = NULL;
1412 if (IS_WILDCARD (receive_sender))
1413 receive_sender = NULL;
1414 if (IS_WILDCARD (receive_path))
1415 receive_path = NULL;
1416 if (IS_WILDCARD (receive_type))
1417 receive_type = NULL;
1419 message_type = DBUS_MESSAGE_TYPE_INVALID;
1420 if (receive_type != NULL)
1422 message_type = dbus_message_type_from_string (receive_type);
1423 if (message_type == DBUS_MESSAGE_TYPE_INVALID)
1425 dbus_set_error (error, DBUS_ERROR_FAILED,
1426 "Bad message type \"%s\"",
1434 !(strcmp (eavesdrop, "true") == 0 ||
1435 strcmp (eavesdrop, "false") == 0))
1437 dbus_set_error (error, DBUS_ERROR_FAILED,
1438 "Bad value \"%s\" for %s attribute, must be true or false",
1439 "eavesdrop", eavesdrop);
1443 if (receive_requested_reply &&
1444 !(strcmp (receive_requested_reply, "true") == 0 ||
1445 strcmp (receive_requested_reply, "false") == 0))
1447 dbus_set_error (error, DBUS_ERROR_FAILED,
1448 "Bad value \"%s\" for %s attribute, must be true or false",
1449 "receive_requested_reply", receive_requested_reply);
1453 rule = bus_policy_rule_new (BUS_POLICY_RULE_RECEIVE, allow);
1458 rule->d.receive.eavesdrop = (strcmp (eavesdrop, "true") == 0);
1460 if (receive_requested_reply)
1461 rule->d.receive.requested_reply = (strcmp (receive_requested_reply, "true") == 0);
1463 rule->d.receive.message_type = message_type;
1464 rule->d.receive.path = _dbus_strdup (receive_path);
1465 rule->d.receive.interface = _dbus_strdup (receive_interface);
1466 rule->d.receive.member = _dbus_strdup (receive_member);
1467 rule->d.receive.error = _dbus_strdup (receive_error);
1468 rule->d.receive.origin = _dbus_strdup (receive_sender);
1470 if (receive_path && rule->d.receive.path == NULL)
1472 if (receive_interface && rule->d.receive.interface == NULL)
1474 if (receive_member && rule->d.receive.member == NULL)
1476 if (receive_error && rule->d.receive.error == NULL)
1478 if (receive_sender && rule->d.receive.origin == NULL)
1483 rule = bus_policy_rule_new (BUS_POLICY_RULE_OWN, allow);
1487 if (IS_WILDCARD (own))
1490 rule->d.own.service_name = _dbus_strdup (own);
1491 if (own && rule->d.own.service_name == NULL)
1496 if (IS_WILDCARD (user))
1498 rule = bus_policy_rule_new (BUS_POLICY_RULE_USER, allow);
1502 rule->d.user.uid = DBUS_UID_UNSET;
1506 DBusString username;
1509 _dbus_string_init_const (&username, user);
1511 if (_dbus_parse_unix_user_from_config (&username, &uid))
1513 rule = bus_policy_rule_new (BUS_POLICY_RULE_USER, allow);
1517 rule->d.user.uid = uid;
1521 _dbus_warn ("Unknown username \"%s\" on element <%s>\n",
1522 user, element_name);
1528 if (IS_WILDCARD (group))
1530 rule = bus_policy_rule_new (BUS_POLICY_RULE_GROUP, allow);
1534 rule->d.group.gid = DBUS_GID_UNSET;
1538 DBusString groupname;
1541 _dbus_string_init_const (&groupname, group);
1543 if (_dbus_parse_unix_group_from_config (&groupname, &gid))
1545 rule = bus_policy_rule_new (BUS_POLICY_RULE_GROUP, allow);
1549 rule->d.group.gid = gid;
1553 _dbus_warn ("Unknown group \"%s\" on element <%s>\n",
1554 group, element_name);
1559 _dbus_assert_not_reached ("Did not handle some combination of attributes on <allow> or <deny>");
1565 pe = peek_element (parser);
1566 _dbus_assert (pe != NULL);
1567 _dbus_assert (pe->type == ELEMENT_POLICY);
1569 switch (pe->d.policy.type)
1571 case POLICY_IGNORED:
1572 /* drop the rule on the floor */
1575 case POLICY_DEFAULT:
1576 if (!bus_policy_append_default_rule (parser->policy, rule))
1579 case POLICY_MANDATORY:
1580 if (!bus_policy_append_mandatory_rule (parser->policy, rule))
1584 if (!BUS_POLICY_RULE_IS_PER_CLIENT (rule))
1586 dbus_set_error (error, DBUS_ERROR_FAILED,
1587 "<%s> rule cannot be per-user because it has bus-global semantics",
1592 if (!bus_policy_append_user_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1597 if (!BUS_POLICY_RULE_IS_PER_CLIENT (rule))
1599 dbus_set_error (error, DBUS_ERROR_FAILED,
1600 "<%s> rule cannot be per-group because it has bus-global semantics",
1605 if (!bus_policy_append_group_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1611 case POLICY_CONSOLE:
1612 if (!bus_policy_append_console_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1618 bus_policy_rule_unref (rule);
1625 BUS_SET_OOM (error);
1628 bus_policy_rule_unref (rule);
1633 start_policy_child (BusConfigParser *parser,
1634 const char *element_name,
1635 const char **attribute_names,
1636 const char **attribute_values,
1639 if (strcmp (element_name, "allow") == 0)
1641 if (!append_rule_from_element (parser, element_name,
1642 attribute_names, attribute_values,
1646 if (push_element (parser, ELEMENT_ALLOW) == NULL)
1648 BUS_SET_OOM (error);
1654 else if (strcmp (element_name, "deny") == 0)
1656 if (!append_rule_from_element (parser, element_name,
1657 attribute_names, attribute_values,
1661 if (push_element (parser, ELEMENT_DENY) == NULL)
1663 BUS_SET_OOM (error);
1671 dbus_set_error (error, DBUS_ERROR_FAILED,
1672 "Element <%s> not allowed inside <%s> in configuration file",
1673 element_name, "policy");
1679 start_selinux_child (BusConfigParser *parser,
1680 const char *element_name,
1681 const char **attribute_names,
1682 const char **attribute_values,
1689 context_copy = NULL;
1691 if (strcmp (element_name, "associate") == 0)
1694 const char *context;
1696 if (!locate_attributes (parser, "associate",
1701 "context", &context,
1705 if (push_element (parser, ELEMENT_ASSOCIATE) == NULL)
1707 BUS_SET_OOM (error);
1711 if (own == NULL || context == NULL)
1713 dbus_set_error (error, DBUS_ERROR_FAILED,
1714 "Element <associate> must have attributes own=\"<servicename>\" and context=\"<selinux context>\"");
1718 own_copy = _dbus_strdup (own);
1719 if (own_copy == NULL)
1721 context_copy = _dbus_strdup (context);
1722 if (context_copy == NULL)
1725 if (!_dbus_hash_table_insert_string (parser->service_context_table,
1726 own_copy, context_copy))
1733 dbus_set_error (error, DBUS_ERROR_FAILED,
1734 "Element <%s> not allowed inside <%s> in configuration file",
1735 element_name, "selinux");
1741 dbus_free (own_copy);
1744 dbus_free (context_copy);
1746 BUS_SET_OOM (error);
1751 bus_config_parser_start_element (BusConfigParser *parser,
1752 const char *element_name,
1753 const char **attribute_names,
1754 const char **attribute_values,
1759 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1761 /* printf ("START: %s\n", element_name); */
1763 t = top_element_type (parser);
1765 if (t == ELEMENT_NONE)
1767 if (strcmp (element_name, "busconfig") == 0)
1769 if (!check_no_attributes (parser, "busconfig", attribute_names, attribute_values, error))
1772 if (push_element (parser, ELEMENT_BUSCONFIG) == NULL)
1774 BUS_SET_OOM (error);
1782 dbus_set_error (error, DBUS_ERROR_FAILED,
1783 "Unknown element <%s> at root of configuration file",
1788 else if (t == ELEMENT_BUSCONFIG)
1790 return start_busconfig_child (parser, element_name,
1791 attribute_names, attribute_values,
1794 else if (t == ELEMENT_POLICY)
1796 return start_policy_child (parser, element_name,
1797 attribute_names, attribute_values,
1800 else if (t == ELEMENT_SELINUX)
1802 return start_selinux_child (parser, element_name,
1803 attribute_names, attribute_values,
1808 dbus_set_error (error, DBUS_ERROR_FAILED,
1809 "Element <%s> is not allowed in this context",
1816 set_limit (BusConfigParser *parser,
1821 dbus_bool_t must_be_positive;
1822 dbus_bool_t must_be_int;
1824 must_be_int = FALSE;
1825 must_be_positive = FALSE;
1827 if (strcmp (name, "max_incoming_bytes") == 0)
1829 must_be_positive = TRUE;
1830 parser->limits.max_incoming_bytes = value;
1832 else if (strcmp (name, "max_outgoing_bytes") == 0)
1834 must_be_positive = TRUE;
1835 parser->limits.max_outgoing_bytes = value;
1837 else if (strcmp (name, "max_message_size") == 0)
1839 must_be_positive = TRUE;
1840 parser->limits.max_message_size = value;
1842 else if (strcmp (name, "service_start_timeout") == 0)
1844 must_be_positive = TRUE;
1846 parser->limits.activation_timeout = value;
1848 else if (strcmp (name, "auth_timeout") == 0)
1850 must_be_positive = TRUE;
1852 parser->limits.auth_timeout = value;
1854 else if (strcmp (name, "reply_timeout") == 0)
1856 must_be_positive = TRUE;
1858 parser->limits.reply_timeout = value;
1860 else if (strcmp (name, "max_completed_connections") == 0)
1862 must_be_positive = TRUE;
1864 parser->limits.max_completed_connections = value;
1866 else if (strcmp (name, "max_incomplete_connections") == 0)
1868 must_be_positive = TRUE;
1870 parser->limits.max_incomplete_connections = value;
1872 else if (strcmp (name, "max_connections_per_user") == 0)
1874 must_be_positive = TRUE;
1876 parser->limits.max_connections_per_user = value;
1878 else if (strcmp (name, "max_pending_service_starts") == 0)
1880 must_be_positive = TRUE;
1882 parser->limits.max_pending_activations = value;
1884 else if (strcmp (name, "max_names_per_connection") == 0)
1886 must_be_positive = TRUE;
1888 parser->limits.max_services_per_connection = value;
1890 else if (strcmp (name, "max_match_rules_per_connection") == 0)
1892 must_be_positive = TRUE;
1894 parser->limits.max_match_rules_per_connection = value;
1896 else if (strcmp (name, "max_replies_per_connection") == 0)
1898 must_be_positive = TRUE;
1900 parser->limits.max_replies_per_connection = value;
1904 dbus_set_error (error, DBUS_ERROR_FAILED,
1905 "There is no limit called \"%s\"\n",
1910 if (must_be_positive && value < 0)
1912 dbus_set_error (error, DBUS_ERROR_FAILED,
1913 "<limit name=\"%s\"> must be a positive number\n",
1919 (value < _DBUS_INT_MIN || value > _DBUS_INT_MAX))
1921 dbus_set_error (error, DBUS_ERROR_FAILED,
1922 "<limit name=\"%s\"> value is too large\n",
1931 bus_config_parser_end_element (BusConfigParser *parser,
1932 const char *element_name,
1939 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1941 /* printf ("END: %s\n", element_name); */
1943 t = top_element_type (parser);
1945 if (t == ELEMENT_NONE)
1947 /* should probably be an assertion failure but
1948 * being paranoid about XML parsers
1950 dbus_set_error (error, DBUS_ERROR_FAILED,
1951 "XML parser ended element with no element on the stack");
1955 n = bus_config_parser_element_type_to_name (t);
1956 _dbus_assert (n != NULL);
1957 if (strcmp (n, element_name) != 0)
1959 /* should probably be an assertion failure but
1960 * being paranoid about XML parsers
1962 dbus_set_error (error, DBUS_ERROR_FAILED,
1963 "XML element <%s> ended but topmost element on the stack was <%s>",
1968 e = peek_element (parser);
1969 _dbus_assert (e != NULL);
1974 _dbus_assert_not_reached ("element in stack has no type");
1977 case ELEMENT_INCLUDE:
1980 case ELEMENT_LISTEN:
1981 case ELEMENT_PIDFILE:
1983 case ELEMENT_SERVICEDIR:
1984 case ELEMENT_SERVICEHELPER:
1985 case ELEMENT_INCLUDEDIR:
1987 if (!e->had_content)
1989 dbus_set_error (error, DBUS_ERROR_FAILED,
1990 "XML element <%s> was expected to have content inside it",
1991 bus_config_parser_element_type_to_name (e->type));
1995 if (e->type == ELEMENT_LIMIT)
1997 if (!set_limit (parser, e->d.limit.name, e->d.limit.value,
2003 case ELEMENT_BUSCONFIG:
2004 case ELEMENT_POLICY:
2008 case ELEMENT_KEEP_UMASK:
2009 case ELEMENT_SYSLOG:
2010 case ELEMENT_SELINUX:
2011 case ELEMENT_ASSOCIATE:
2012 case ELEMENT_STANDARD_SESSION_SERVICEDIRS:
2013 case ELEMENT_STANDARD_SYSTEM_SERVICEDIRS:
2014 case ELEMENT_ALLOW_ANONYMOUS:
2018 pop_element (parser);
2024 all_whitespace (const DBusString *str)
2028 _dbus_string_skip_white (str, 0, &i);
2030 return i == _dbus_string_get_length (str);
2034 make_full_path (const DBusString *basedir,
2035 const DBusString *filename,
2036 DBusString *full_path)
2038 if (_dbus_path_is_absolute (filename))
2040 return _dbus_string_copy (filename, 0, full_path, 0);
2044 if (!_dbus_string_copy (basedir, 0, full_path, 0))
2047 if (!_dbus_concat_dir_and_file (full_path, filename))
2055 include_file (BusConfigParser *parser,
2056 const DBusString *filename,
2057 dbus_bool_t ignore_missing,
2060 /* FIXME good test case for this would load each config file in the
2061 * test suite both alone, and as an include, and check
2062 * that the result is the same
2064 BusConfigParser *included;
2065 const char *filename_str;
2066 DBusError tmp_error;
2068 dbus_error_init (&tmp_error);
2070 filename_str = _dbus_string_get_const_data (filename);
2072 /* Check to make sure this file hasn't already been included. */
2073 if (seen_include (parser, filename))
2075 dbus_set_error (error, DBUS_ERROR_FAILED,
2076 "Circular inclusion of file '%s'",
2081 if (! _dbus_list_append (&parser->included_files, (void *) filename_str))
2083 BUS_SET_OOM (error);
2087 /* Since parser is passed in as the parent, included
2088 inherits parser's limits. */
2089 included = bus_config_load (filename, FALSE, parser, &tmp_error);
2091 _dbus_list_pop_last (&parser->included_files);
2093 if (included == NULL)
2095 _DBUS_ASSERT_ERROR_IS_SET (&tmp_error);
2097 if (dbus_error_has_name (&tmp_error, DBUS_ERROR_FILE_NOT_FOUND) &&
2100 dbus_error_free (&tmp_error);
2105 dbus_move_error (&tmp_error, error);
2111 _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
2113 if (!merge_included (parser, included, error))
2115 bus_config_parser_unref (included);
2119 /* Copy included's limits back to parser. */
2120 parser->limits = included->limits;
2122 bus_config_parser_unref (included);
2128 servicehelper_path (BusConfigParser *parser,
2129 const DBusString *filename,
2132 const char *filename_str;
2133 char *servicehelper;
2135 filename_str = _dbus_string_get_const_data (filename);
2137 /* copy to avoid overwriting with NULL on OOM */
2138 servicehelper = _dbus_strdup (filename_str);
2141 if (servicehelper == NULL)
2143 BUS_SET_OOM (error);
2147 /* save the latest servicehelper only if not OOM */
2148 dbus_free (parser->servicehelper);
2149 parser->servicehelper = servicehelper;
2151 /* We don't check whether the helper exists; instead we
2152 * would just fail to ever activate anything if it doesn't.
2153 * This allows an admin to fix the problem if it doesn't exist.
2154 * It also allows the parser test suite to successfully parse
2155 * test cases without installing the helper. ;-)
2162 include_dir (BusConfigParser *parser,
2163 const DBusString *dirname,
2166 DBusString filename;
2168 DBusError tmp_error;
2172 if (!_dbus_string_init (&filename))
2174 BUS_SET_OOM (error);
2180 dir = _dbus_directory_open (dirname, error);
2185 dbus_error_init (&tmp_error);
2186 while (_dbus_directory_get_next_file (dir, &filename, &tmp_error))
2188 DBusString full_path;
2190 if (!_dbus_string_init (&full_path))
2192 BUS_SET_OOM (error);
2196 if (!_dbus_string_copy (dirname, 0, &full_path, 0))
2198 BUS_SET_OOM (error);
2199 _dbus_string_free (&full_path);
2203 if (!_dbus_concat_dir_and_file (&full_path, &filename))
2205 BUS_SET_OOM (error);
2206 _dbus_string_free (&full_path);
2210 if (_dbus_string_ends_with_c_str (&full_path, ".conf"))
2212 if (!include_file (parser, &full_path, TRUE, error))
2214 _dbus_string_free (&full_path);
2219 _dbus_string_free (&full_path);
2222 if (dbus_error_is_set (&tmp_error))
2224 dbus_move_error (&tmp_error, error);
2229 if (!_dbus_string_copy_data (dirname, &s))
2231 BUS_SET_OOM (error);
2235 if (!_dbus_list_append (&parser->conf_dirs, s))
2238 BUS_SET_OOM (error);
2245 _dbus_string_free (&filename);
2248 _dbus_directory_close (dir);
2254 bus_config_parser_content (BusConfigParser *parser,
2255 const DBusString *content,
2260 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2266 _dbus_string_get_const_data (content, &c_str);
2268 printf ("CONTENT %d bytes: %s\n", _dbus_string_get_length (content), c_str);
2272 e = peek_element (parser);
2275 dbus_set_error (error, DBUS_ERROR_FAILED,
2276 "Text content outside of any XML element in configuration file");
2279 else if (e->had_content)
2281 _dbus_assert_not_reached ("Element had multiple content blocks");
2285 switch (top_element_type (parser))
2288 _dbus_assert_not_reached ("element at top of stack has no type");
2291 case ELEMENT_BUSCONFIG:
2292 case ELEMENT_POLICY:
2296 case ELEMENT_KEEP_UMASK:
2297 case ELEMENT_SYSLOG:
2298 case ELEMENT_STANDARD_SESSION_SERVICEDIRS:
2299 case ELEMENT_STANDARD_SYSTEM_SERVICEDIRS:
2300 case ELEMENT_ALLOW_ANONYMOUS:
2301 case ELEMENT_SELINUX:
2302 case ELEMENT_ASSOCIATE:
2303 if (all_whitespace (content))
2307 dbus_set_error (error, DBUS_ERROR_FAILED,
2308 "No text content expected inside XML element %s in configuration file",
2309 bus_config_parser_element_type_to_name (top_element_type (parser)));
2313 case ELEMENT_PIDFILE:
2317 e->had_content = TRUE;
2319 if (!_dbus_string_copy_data (content, &s))
2322 dbus_free (parser->pidfile);
2323 parser->pidfile = s;
2327 case ELEMENT_INCLUDE:
2329 DBusString full_path, selinux_policy_root;
2331 e->had_content = TRUE;
2333 if (e->d.include.if_selinux_enabled
2334 && !bus_selinux_enabled ())
2337 if (!_dbus_string_init (&full_path))
2340 if (e->d.include.selinux_root_relative)
2342 if (!bus_selinux_get_policy_root ())
2344 dbus_set_error (error, DBUS_ERROR_FAILED,
2345 "Could not determine SELinux policy root for relative inclusion");
2346 _dbus_string_free (&full_path);
2349 _dbus_string_init_const (&selinux_policy_root,
2350 bus_selinux_get_policy_root ());
2351 if (!make_full_path (&selinux_policy_root, content, &full_path))
2353 _dbus_string_free (&full_path);
2357 else if (!make_full_path (&parser->basedir, content, &full_path))
2359 _dbus_string_free (&full_path);
2363 if (!include_file (parser, &full_path,
2364 e->d.include.ignore_missing, error))
2366 _dbus_string_free (&full_path);
2370 _dbus_string_free (&full_path);
2374 case ELEMENT_SERVICEHELPER:
2376 DBusString full_path;
2378 e->had_content = TRUE;
2380 if (!_dbus_string_init (&full_path))
2383 if (!make_full_path (&parser->basedir, content, &full_path))
2385 _dbus_string_free (&full_path);
2389 if (!servicehelper_path (parser, &full_path, error))
2391 _dbus_string_free (&full_path);
2395 _dbus_string_free (&full_path);
2399 case ELEMENT_INCLUDEDIR:
2401 DBusString full_path;
2403 e->had_content = TRUE;
2405 if (!_dbus_string_init (&full_path))
2408 if (!make_full_path (&parser->basedir, content, &full_path))
2410 _dbus_string_free (&full_path);
2414 if (!include_dir (parser, &full_path, error))
2416 _dbus_string_free (&full_path);
2420 _dbus_string_free (&full_path);
2428 e->had_content = TRUE;
2430 if (!_dbus_string_copy_data (content, &s))
2433 dbus_free (parser->user);
2442 e->had_content = TRUE;
2444 if (!_dbus_string_copy_data (content, &s))
2447 dbus_free (parser->bus_type);
2448 parser->bus_type = s;
2452 case ELEMENT_LISTEN:
2456 e->had_content = TRUE;
2458 if (!_dbus_string_copy_data (content, &s))
2461 if (!_dbus_list_append (&parser->listen_on,
2474 e->had_content = TRUE;
2476 if (!_dbus_string_copy_data (content, &s))
2479 if (!_dbus_list_append (&parser->mechanisms,
2488 case ELEMENT_SERVICEDIR:
2491 DBusString full_path;
2493 e->had_content = TRUE;
2495 if (!_dbus_string_init (&full_path))
2498 if (!make_full_path (&parser->basedir, content, &full_path))
2500 _dbus_string_free (&full_path);
2504 if (!_dbus_string_copy_data (&full_path, &s))
2506 _dbus_string_free (&full_path);
2510 /* _only_ extra session directories can be specified */
2511 if (!service_dirs_append_unique_or_free (&parser->service_dirs, s))
2513 _dbus_string_free (&full_path);
2518 _dbus_string_free (&full_path);
2526 e->had_content = TRUE;
2529 if (!_dbus_string_parse_int (content, 0, &val, NULL))
2531 dbus_set_error (error, DBUS_ERROR_FAILED,
2532 "<limit name=\"%s\"> element has invalid value (could not parse as integer)",
2537 e->d.limit.value = val;
2539 _dbus_verbose ("Loaded value %ld for limit %s\n",
2546 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2550 BUS_SET_OOM (error);
2555 bus_config_parser_finished (BusConfigParser *parser,
2558 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2560 if (parser->stack != NULL)
2562 dbus_set_error (error, DBUS_ERROR_FAILED,
2563 "Element <%s> was not closed in configuration file",
2564 bus_config_parser_element_type_to_name (top_element_type (parser)));
2569 if (parser->is_toplevel && parser->listen_on == NULL)
2571 dbus_set_error (error, DBUS_ERROR_FAILED,
2572 "Configuration file needs one or more <listen> elements giving addresses");
2580 bus_config_parser_get_user (BusConfigParser *parser)
2582 return parser->user;
2586 bus_config_parser_get_type (BusConfigParser *parser)
2588 return parser->bus_type;
2592 bus_config_parser_get_addresses (BusConfigParser *parser)
2594 return &parser->listen_on;
2598 bus_config_parser_get_mechanisms (BusConfigParser *parser)
2600 return &parser->mechanisms;
2604 bus_config_parser_get_service_dirs (BusConfigParser *parser)
2606 return &parser->service_dirs;
2610 bus_config_parser_get_conf_dirs (BusConfigParser *parser)
2612 return &parser->conf_dirs;
2616 bus_config_parser_get_fork (BusConfigParser *parser)
2618 return parser->fork;
2622 bus_config_parser_get_keep_umask (BusConfigParser *parser)
2624 return parser->keep_umask;
2628 bus_config_parser_get_syslog (BusConfigParser *parser)
2630 return parser->syslog;
2634 bus_config_parser_get_allow_anonymous (BusConfigParser *parser)
2636 return parser->allow_anonymous;
2640 bus_config_parser_get_pidfile (BusConfigParser *parser)
2642 return parser->pidfile;
2646 bus_config_parser_get_servicehelper (BusConfigParser *parser)
2648 return parser->servicehelper;
2652 bus_config_parser_steal_policy (BusConfigParser *parser)
2656 _dbus_assert (parser->policy != NULL); /* can only steal the policy 1 time */
2658 policy = parser->policy;
2660 parser->policy = NULL;
2665 /* Overwrite any limits that were set in the configuration file */
2667 bus_config_parser_get_limits (BusConfigParser *parser,
2670 *limits = parser->limits;
2674 bus_config_parser_steal_service_context_table (BusConfigParser *parser)
2676 DBusHashTable *table;
2678 _dbus_assert (parser->service_context_table != NULL); /* can only steal once */
2680 table = parser->service_context_table;
2682 parser->service_context_table = NULL;
2687 #ifdef DBUS_BUILD_TESTS
2698 do_load (const DBusString *full_path,
2700 dbus_bool_t oom_possible)
2702 BusConfigParser *parser;
2705 dbus_error_init (&error);
2707 parser = bus_config_load (full_path, TRUE, NULL, &error);
2710 _DBUS_ASSERT_ERROR_IS_SET (&error);
2713 dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
2715 _dbus_verbose ("Failed to load valid file due to OOM\n");
2716 dbus_error_free (&error);
2719 else if (validity == VALID)
2721 _dbus_warn ("Failed to load valid file but still had memory: %s\n",
2724 dbus_error_free (&error);
2729 dbus_error_free (&error);
2735 _DBUS_ASSERT_ERROR_IS_CLEAR (&error);
2737 bus_config_parser_unref (parser);
2739 if (validity == INVALID)
2741 _dbus_warn ("Accepted invalid file\n");
2751 const DBusString *full_path;
2756 check_loader_oom_func (void *data)
2758 LoaderOomData *d = data;
2760 return do_load (d->full_path, d->validity, TRUE);
2764 process_test_valid_subdir (const DBusString *test_base_dir,
2768 DBusString test_directory;
2769 DBusString filename;
2777 if (!_dbus_string_init (&test_directory))
2778 _dbus_assert_not_reached ("didn't allocate test_directory\n");
2780 _dbus_string_init_const (&filename, subdir);
2782 if (!_dbus_string_copy (test_base_dir, 0,
2783 &test_directory, 0))
2784 _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory");
2786 if (!_dbus_concat_dir_and_file (&test_directory, &filename))
2787 _dbus_assert_not_reached ("couldn't allocate full path");
2789 _dbus_string_free (&filename);
2790 if (!_dbus_string_init (&filename))
2791 _dbus_assert_not_reached ("didn't allocate filename string\n");
2793 dbus_error_init (&error);
2794 dir = _dbus_directory_open (&test_directory, &error);
2797 _dbus_warn ("Could not open %s: %s\n",
2798 _dbus_string_get_const_data (&test_directory),
2800 dbus_error_free (&error);
2804 if (validity == VALID)
2805 printf ("Testing valid files:\n");
2806 else if (validity == INVALID)
2807 printf ("Testing invalid files:\n");
2809 printf ("Testing unknown files:\n");
2812 while (_dbus_directory_get_next_file (dir, &filename, &error))
2814 DBusString full_path;
2817 if (!_dbus_string_init (&full_path))
2818 _dbus_assert_not_reached ("couldn't init string");
2820 if (!_dbus_string_copy (&test_directory, 0, &full_path, 0))
2821 _dbus_assert_not_reached ("couldn't copy dir to full_path");
2823 if (!_dbus_concat_dir_and_file (&full_path, &filename))
2824 _dbus_assert_not_reached ("couldn't concat file to dir");
2826 if (!_dbus_string_ends_with_c_str (&full_path, ".conf"))
2828 _dbus_verbose ("Skipping non-.conf file %s\n",
2829 _dbus_string_get_const_data (&filename));
2830 _dbus_string_free (&full_path);
2834 printf (" %s\n", _dbus_string_get_const_data (&filename));
2836 _dbus_verbose (" expecting %s\n",
2837 validity == VALID ? "valid" :
2838 (validity == INVALID ? "invalid" :
2839 (validity == UNKNOWN ? "unknown" : "???")));
2841 d.full_path = &full_path;
2842 d.validity = validity;
2844 /* FIXME hackaround for an expat problem, see
2845 * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=124747
2846 * http://freedesktop.org/pipermail/dbus/2004-May/001153.html
2848 /* if (!_dbus_test_oom_handling ("config-loader", check_loader_oom_func, &d)) */
2849 if (!check_loader_oom_func (&d))
2850 _dbus_assert_not_reached ("test failed");
2852 _dbus_string_free (&full_path);
2855 if (dbus_error_is_set (&error))
2857 _dbus_warn ("Could not get next file in %s: %s\n",
2858 _dbus_string_get_const_data (&test_directory),
2860 dbus_error_free (&error);
2869 _dbus_directory_close (dir);
2870 _dbus_string_free (&test_directory);
2871 _dbus_string_free (&filename);
2877 bools_equal (dbus_bool_t a,
2884 strings_equal_or_both_null (const char *a,
2887 if (a == NULL || b == NULL)
2890 return !strcmp (a, b);
2894 elements_equal (const Element *a,
2897 if (a->type != b->type)
2900 if (!bools_equal (a->had_content, b->had_content))
2906 case ELEMENT_INCLUDE:
2907 if (!bools_equal (a->d.include.ignore_missing,
2908 b->d.include.ignore_missing))
2912 case ELEMENT_POLICY:
2913 if (a->d.policy.type != b->d.policy.type)
2915 if (a->d.policy.gid_uid_or_at_console != b->d.policy.gid_uid_or_at_console)
2920 if (strcmp (a->d.limit.name, b->d.limit.name))
2922 if (a->d.limit.value != b->d.limit.value)
2936 lists_of_elements_equal (DBusList *a,
2945 while (ia != NULL && ib != NULL)
2947 if (elements_equal (ia->data, ib->data))
2949 ia = _dbus_list_get_next_link (&a, ia);
2950 ib = _dbus_list_get_next_link (&b, ib);
2953 return ia == NULL && ib == NULL;
2957 lists_of_c_strings_equal (DBusList *a,
2966 while (ia != NULL && ib != NULL)
2968 if (strcmp (ia->data, ib->data))
2970 ia = _dbus_list_get_next_link (&a, ia);
2971 ib = _dbus_list_get_next_link (&b, ib);
2974 return ia == NULL && ib == NULL;
2978 limits_equal (const BusLimits *a,
2982 (a->max_incoming_bytes == b->max_incoming_bytes
2983 || a->max_outgoing_bytes == b->max_outgoing_bytes
2984 || a->max_message_size == b->max_message_size
2985 || a->activation_timeout == b->activation_timeout
2986 || a->auth_timeout == b->auth_timeout
2987 || a->max_completed_connections == b->max_completed_connections
2988 || a->max_incomplete_connections == b->max_incomplete_connections
2989 || a->max_connections_per_user == b->max_connections_per_user
2990 || a->max_pending_activations == b->max_pending_activations
2991 || a->max_services_per_connection == b->max_services_per_connection
2992 || a->max_match_rules_per_connection == b->max_match_rules_per_connection
2993 || a->max_replies_per_connection == b->max_replies_per_connection
2994 || a->reply_timeout == b->reply_timeout);
2998 config_parsers_equal (const BusConfigParser *a,
2999 const BusConfigParser *b)
3001 if (!_dbus_string_equal (&a->basedir, &b->basedir))
3004 if (!lists_of_elements_equal (a->stack, b->stack))
3007 if (!strings_equal_or_both_null (a->user, b->user))
3010 if (!lists_of_c_strings_equal (a->listen_on, b->listen_on))
3013 if (!lists_of_c_strings_equal (a->mechanisms, b->mechanisms))
3016 if (!lists_of_c_strings_equal (a->service_dirs, b->service_dirs))
3019 /* FIXME: compare policy */
3021 /* FIXME: compare service selinux ID table */
3023 if (! limits_equal (&a->limits, &b->limits))
3026 if (!strings_equal_or_both_null (a->pidfile, b->pidfile))
3029 if (! bools_equal (a->fork, b->fork))
3032 if (! bools_equal (a->keep_umask, b->keep_umask))
3035 if (! bools_equal (a->is_toplevel, b->is_toplevel))
3042 all_are_equiv (const DBusString *target_directory)
3044 DBusString filename;
3046 BusConfigParser *first_parser;
3047 BusConfigParser *parser;
3053 first_parser = NULL;
3057 if (!_dbus_string_init (&filename))
3058 _dbus_assert_not_reached ("didn't allocate filename string");
3060 dbus_error_init (&error);
3061 dir = _dbus_directory_open (target_directory, &error);
3064 _dbus_warn ("Could not open %s: %s\n",
3065 _dbus_string_get_const_data (target_directory),
3067 dbus_error_free (&error);
3071 printf ("Comparing equivalent files:\n");
3074 while (_dbus_directory_get_next_file (dir, &filename, &error))
3076 DBusString full_path;
3078 if (!_dbus_string_init (&full_path))
3079 _dbus_assert_not_reached ("couldn't init string");
3081 if (!_dbus_string_copy (target_directory, 0, &full_path, 0))
3082 _dbus_assert_not_reached ("couldn't copy dir to full_path");
3084 if (!_dbus_concat_dir_and_file (&full_path, &filename))
3085 _dbus_assert_not_reached ("couldn't concat file to dir");
3087 if (!_dbus_string_ends_with_c_str (&full_path, ".conf"))
3089 _dbus_verbose ("Skipping non-.conf file %s\n",
3090 _dbus_string_get_const_data (&filename));
3091 _dbus_string_free (&full_path);
3095 printf (" %s\n", _dbus_string_get_const_data (&filename));
3097 parser = bus_config_load (&full_path, TRUE, NULL, &error);
3101 _dbus_warn ("Could not load file %s: %s\n",
3102 _dbus_string_get_const_data (&full_path),
3104 _dbus_string_free (&full_path);
3105 dbus_error_free (&error);
3108 else if (first_parser == NULL)
3110 _dbus_string_free (&full_path);
3111 first_parser = parser;
3115 _dbus_string_free (&full_path);
3116 equal = config_parsers_equal (first_parser, parser);
3117 bus_config_parser_unref (parser);
3126 _dbus_string_free (&filename);
3128 bus_config_parser_unref (first_parser);
3130 _dbus_directory_close (dir);
3137 process_test_equiv_subdir (const DBusString *test_base_dir,
3140 DBusString test_directory;
3141 DBusString filename;
3150 if (!_dbus_string_init (&test_directory))
3151 _dbus_assert_not_reached ("didn't allocate test_directory");
3153 _dbus_string_init_const (&filename, subdir);
3155 if (!_dbus_string_copy (test_base_dir, 0,
3156 &test_directory, 0))
3157 _dbus_assert_not_reached ("couldn't copy test_base_dir to test_directory");
3159 if (!_dbus_concat_dir_and_file (&test_directory, &filename))
3160 _dbus_assert_not_reached ("couldn't allocate full path");
3162 _dbus_string_free (&filename);
3163 if (!_dbus_string_init (&filename))
3164 _dbus_assert_not_reached ("didn't allocate filename string");
3166 dbus_error_init (&error);
3167 dir = _dbus_directory_open (&test_directory, &error);
3170 _dbus_warn ("Could not open %s: %s\n",
3171 _dbus_string_get_const_data (&test_directory),
3173 dbus_error_free (&error);
3177 while (_dbus_directory_get_next_file (dir, &filename, &error))
3179 DBusString full_path;
3181 /* Skip CVS's magic directories! */
3182 if (_dbus_string_equal_c_str (&filename, "CVS"))
3185 if (!_dbus_string_init (&full_path))
3186 _dbus_assert_not_reached ("couldn't init string");
3188 if (!_dbus_string_copy (&test_directory, 0, &full_path, 0))
3189 _dbus_assert_not_reached ("couldn't copy dir to full_path");
3191 if (!_dbus_concat_dir_and_file (&full_path, &filename))
3192 _dbus_assert_not_reached ("couldn't concat file to dir");
3194 equal = all_are_equiv (&full_path);
3195 _dbus_string_free (&full_path);
3204 _dbus_string_free (&test_directory);
3205 _dbus_string_free (&filename);
3207 _dbus_directory_close (dir);
3213 static const char *test_session_service_dir_matches[] =
3216 "/testusr/testlocal/testshare/dbus-1/services",
3217 "/testusr/testshare/dbus-1/services",
3219 DBUS_DATADIR"/dbus-1/services",
3221 "/testhome/foo/.testlocal/testshare/dbus-1/services",
3227 test_default_session_servicedirs (void)
3232 const char *common_progs;
3235 /* On Unix we don't actually use this variable, but it's easier to handle the
3236 * deallocation if we always allocate it, whether needed or not */
3237 if (!_dbus_string_init (&progs))
3238 _dbus_assert_not_reached ("OOM allocating progs");
3240 common_progs = _dbus_getenv ("CommonProgramFiles");
3244 if (!_dbus_string_append (&progs, common_progs))
3246 _dbus_string_free (&progs);
3250 if (!_dbus_string_append (&progs, "/dbus-1/services"))
3252 _dbus_string_free (&progs);
3255 test_session_service_dir_matches[1] = _dbus_string_get_const_data(&progs);
3260 printf ("Testing retrieving the default session service directories\n");
3261 if (!_dbus_get_standard_session_servicedirs (&dirs))
3262 _dbus_assert_not_reached ("couldn't get stardard dirs");
3264 /* make sure our defaults end with share/dbus-1/service */
3265 while ((link = _dbus_list_pop_first_link (&dirs)))
3269 printf (" default service dir: %s\n", (char *)link->data);
3270 _dbus_string_init_const (&path, (char *)link->data);
3271 if (!_dbus_string_ends_with_c_str (&path, "dbus-1/services"))
3273 printf ("error with default session service directories\n");
3274 dbus_free (link->data);
3275 _dbus_list_free_link (link);
3276 _dbus_string_free (&progs);
3280 dbus_free (link->data);
3281 _dbus_list_free_link (link);
3285 if (!_dbus_setenv ("XDG_DATA_HOME", "/testhome/foo/.testlocal/testshare"))
3286 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_HOME");
3288 if (!_dbus_setenv ("XDG_DATA_DIRS", ":/testusr/testlocal/testshare: :/testusr/testshare:"))
3289 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_DIRS");
3291 if (!_dbus_get_standard_session_servicedirs (&dirs))
3292 _dbus_assert_not_reached ("couldn't get stardard dirs");
3294 /* make sure we read and parse the env variable correctly */
3296 while ((link = _dbus_list_pop_first_link (&dirs)))
3298 printf (" test service dir: %s\n", (char *)link->data);
3299 if (test_session_service_dir_matches[i] == NULL)
3301 printf ("more directories parsed than in match set\n");
3302 dbus_free (link->data);
3303 _dbus_list_free_link (link);
3304 _dbus_string_free (&progs);
3308 if (strcmp (test_session_service_dir_matches[i],
3309 (char *)link->data) != 0)
3311 printf ("%s directory does not match %s in the match set\n",
3313 test_session_service_dir_matches[i]);
3314 dbus_free (link->data);
3315 _dbus_list_free_link (link);
3316 _dbus_string_free (&progs);
3322 dbus_free (link->data);
3323 _dbus_list_free_link (link);
3326 if (test_session_service_dir_matches[i] != NULL)
3328 printf ("extra data %s in the match set was not matched\n",
3329 test_session_service_dir_matches[i]);
3331 _dbus_string_free (&progs);
3335 _dbus_string_free (&progs);
3339 static const char *test_system_service_dir_matches[] =
3342 "/testusr/testlocal/testshare/dbus-1/system-services",
3343 "/testusr/testshare/dbus-1/system-services",
3345 DBUS_DATADIR"/dbus-1/system-services",
3350 test_default_system_servicedirs (void)
3355 const char *common_progs;
3358 /* On Unix we don't actually use this variable, but it's easier to handle the
3359 * deallocation if we always allocate it, whether needed or not */
3360 if (!_dbus_string_init (&progs))
3361 _dbus_assert_not_reached ("OOM allocating progs");
3363 common_progs = _dbus_getenv ("CommonProgramFiles");
3367 if (!_dbus_string_append (&progs, common_progs))
3369 _dbus_string_free (&progs);
3373 if (!_dbus_string_append (&progs, "/dbus-1/system-services"))
3375 _dbus_string_free (&progs);
3378 test_system_service_dir_matches[1] = _dbus_string_get_const_data(&progs);
3383 printf ("Testing retrieving the default system service directories\n");
3384 if (!_dbus_get_standard_system_servicedirs (&dirs))
3385 _dbus_assert_not_reached ("couldn't get stardard dirs");
3387 /* make sure our defaults end with share/dbus-1/system-service */
3388 while ((link = _dbus_list_pop_first_link (&dirs)))
3392 printf (" default service dir: %s\n", (char *)link->data);
3393 _dbus_string_init_const (&path, (char *)link->data);
3394 if (!_dbus_string_ends_with_c_str (&path, "dbus-1/system-services"))
3396 printf ("error with default system service directories\n");
3397 dbus_free (link->data);
3398 _dbus_list_free_link (link);
3399 _dbus_string_free (&progs);
3403 dbus_free (link->data);
3404 _dbus_list_free_link (link);
3408 if (!_dbus_setenv ("XDG_DATA_HOME", "/testhome/foo/.testlocal/testshare"))
3409 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_HOME");
3411 if (!_dbus_setenv ("XDG_DATA_DIRS", ":/testusr/testlocal/testshare: :/testusr/testshare:"))
3412 _dbus_assert_not_reached ("couldn't setenv XDG_DATA_DIRS");
3414 if (!_dbus_get_standard_system_servicedirs (&dirs))
3415 _dbus_assert_not_reached ("couldn't get stardard dirs");
3417 /* make sure we read and parse the env variable correctly */
3419 while ((link = _dbus_list_pop_first_link (&dirs)))
3421 printf (" test service dir: %s\n", (char *)link->data);
3422 if (test_system_service_dir_matches[i] == NULL)
3424 printf ("more directories parsed than in match set\n");
3425 dbus_free (link->data);
3426 _dbus_list_free_link (link);
3427 _dbus_string_free (&progs);
3431 if (strcmp (test_system_service_dir_matches[i],
3432 (char *)link->data) != 0)
3434 printf ("%s directory does not match %s in the match set\n",
3436 test_system_service_dir_matches[i]);
3437 dbus_free (link->data);
3438 _dbus_list_free_link (link);
3439 _dbus_string_free (&progs);
3445 dbus_free (link->data);
3446 _dbus_list_free_link (link);
3449 if (test_system_service_dir_matches[i] != NULL)
3451 printf ("extra data %s in the match set was not matched\n",
3452 test_system_service_dir_matches[i]);
3454 _dbus_string_free (&progs);
3458 _dbus_string_free (&progs);
3463 bus_config_parser_test (const DBusString *test_data_dir)
3465 if (test_data_dir == NULL ||
3466 _dbus_string_get_length (test_data_dir) == 0)
3468 printf ("No test data\n");
3472 if (!test_default_session_servicedirs())
3475 if (!test_default_system_servicedirs())
3478 if (!process_test_valid_subdir (test_data_dir, "valid-config-files", VALID))
3481 if (!process_test_valid_subdir (test_data_dir, "invalid-config-files", INVALID))
3484 if (!process_test_equiv_subdir (test_data_dir, "equiv-config-files"))
3490 #endif /* DBUS_BUILD_TESTS */