Home | History | Annotate | Download | only in bus

Lines Matching refs:parser

2 /* config-parser.c  XML-library-agnostic configuration file parser
25 #include "config-parser-common.h"
26 #include "config-parser.h"
80 * Parser for bus configuration file.
125 push_element (BusConfigParser *parser,
136 if (!_dbus_list_append (&parser->stack, e))
157 pop_element (BusConfigParser *parser)
161 e = _dbus_list_pop_last (&parser->stack);
167 peek_element (BusConfigParser *parser)
171 e = _dbus_list_get_last (&parser->stack);
177 top_element_type (BusConfigParser *parser)
181 e = _dbus_list_get_last (&parser->stack);
279 merge_included (BusConfigParser *parser,
285 if (!bus_policy_merge (parser->policy,
292 if (!merge_service_context_hash (parser->service_context_table,
301 dbus_free (parser->user);
302 parser->user = included->user;
308 dbus_free (parser->bus_type);
309 parser->bus_type = included->bus_type;
314 parser->fork = TRUE;
317 parser->keep_umask = TRUE;
321 dbus_free (parser->pidfile);
322 parser->pidfile = included->pidfile;
327 _dbus_list_append_link (&parser->listen_on, link);
330 _dbus_list_append_link (&parser->mechanisms, link);
333 service_dirs_append_link_unique_or_free (&parser->service_dirs, link);
336 _dbus_list_append_link (&parser->conf_dirs, link);
342 seen_include (BusConfigParser *parser,
347 iter = parser->included_files;
353 iter = _dbus_list_get_next_link (&parser->included_files, iter);
364 BusConfigParser *parser;
366 parser = dbus_new0 (BusConfigParser, 1);
367 if (parser == NULL)
370 parser->is_toplevel = !!is_toplevel;
372 if (!_dbus_string_init (&parser->basedir))
374 dbus_free (parser);
378 if (((parser->policy = bus_policy_new ()) == NULL) ||
379 !_dbus_string_copy (basedir, 0, &parser->basedir, 0) ||
380 ((parser->service_context_table = _dbus_hash_table_new (DBUS_HASH_STRING,
384 if (parser->policy)
385 bus_policy_unref (parser->policy);
387 _dbus_string_free (&parser->basedir);
389 dbus_free (parser);
395 /* Initialize the parser's limits from the parent. */
396 parser->limits = parent->limits;
400 parser->included_files = parent->included_files;
406 parser->limits.max_incoming_bytes = _DBUS_ONE_MEGABYTE * 127;
407 parser->limits.max_outgoing_bytes = _DBUS_ONE_MEGABYTE * 127;
408 parser->limits.max_message_size = _DBUS_ONE_MEGABYTE * 32;
415 parser->limits.max_incoming_unix_fds = 1024*4;
416 parser->limits.max_outgoing_unix_fds = 1024*4;
417 parser->limits.max_message_unix_fds = 1024;
423 parser->limits.activation_timeout = 25000; /* 25 seconds */
429 parser->limits.auth_timeout = 30000; /* 30 seconds */
431 parser->limits.max_incomplete_connections = 64;
432 parser->limits.max_connections_per_user = 256;
438 parser->limits.max_completed_connections = 2048;
440 parser->limits.max_pending_activations = 512;
441 parser->limits.max_services_per_connection = 512;
451 parser->limits.max_match_rules_per_connection = 512;
453 parser->limits.reply_timeout = -1; /* never */
458 parser->limits.max_replies_per_connection = 1024*8;
461 parser->refcount = 1;
463 return parser;
467 bus_config_parser_ref (BusConfigParser *parser)
469 _dbus_assert (parser->refcount > 0);
471 parser->refcount += 1;
473 return parser;
477 bus_config_parser_unref (BusConfigParser *parser)
479 _dbus_assert (parser->refcount > 0);
481 parser->refcount -= 1;
483 if (parser->refcount == 0)
485 while (parser->stack != NULL)
486 pop_element (parser);
488 dbus_free (parser->user);
489 dbus_free (parser->servicehelper);
490 dbus_free (parser->bus_type);
491 dbus_free (parser->pidfile);
493 _dbus_list_foreach (&parser->listen_on,
497 _dbus_list_clear (&parser->listen_on);
499 _dbus_list_foreach (&parser->service_dirs,
503 _dbus_list_clear (&parser->service_dirs);
505 _dbus_list_foreach (&parser->conf_dirs,
509 _dbus_list_clear (&parser->conf_dirs);
511 _dbus_list_foreach (&parser->mechanisms,
515 _dbus_list_clear (&parser->mechanisms);
517 _dbus_string_free (&parser->basedir);
519 if (parser->policy)
520 bus_policy_unref (parser->policy);
522 if (parser->service_context_table)
523 _dbus_hash_table_unref (parser->service_context_table);
525 dbus_free (parser);
530 bus_config_parser_check_doctype (BusConfigParser *parser,
555 locate_attributes (BusConfigParser *parser,
651 check_no_attributes (BusConfigParser *parser,
669 start_busconfig_child (BusConfigParser *parser,
681 if (!check_no_attributes (parser, "user", attribute_names, attribute_values, error))
684 if (push_element (parser, ELEMENT_USER) == NULL)
694 if (!check_no_attributes (parser, "type", attribute_names, attribute_values, error))
697 if (push_element (parser, ELEMENT_TYPE) == NULL)
707 if (!check_no_attributes (parser, "fork", attribute_names, attribute_values, error))
710 if (push_element (parser, ELEMENT_FORK) == NULL)
716 parser->fork = TRUE;
722 if (!check_no_attributes (parser, "syslog", attribute_names, attribute_values, error))
725 if (push_element (parser, ELEMENT_SYSLOG) == NULL)
731 parser->syslog = TRUE;
737 if (!check_no_attributes (parser, "keep_umask", attribute_names, attribute_values, error))
740 if (push_element (parser, ELEMENT_KEEP_UMASK) == NULL)
746 parser->keep_umask = TRUE;
752 if (!check_no_attributes (parser, "pidfile", attribute_names, attribute_values, error))
755 if (push_element (parser, ELEMENT_PIDFILE) == NULL)
765 if (!check_no_attributes (parser, "listen", attribute_names, attribute_values, error))
768 if (push_element (parser, ELEMENT_LISTEN) == NULL)
778 if (!check_no_attributes (parser, "auth", attribute_names, attribute_values, error))
781 if (push_element (parser, ELEMENT_AUTH) == NULL)
791 if (!check_no_attributes (parser, "servicehelper", attribute_names, attribute_values, error))
794 if (push_element (parser, ELEMENT_SERVICEHELPER) == NULL)
804 if (!check_no_attributes (parser, "includedir", attribute_names, attribute_values, error))
807 if (push_element (parser, ELEMENT_INCLUDEDIR) == NULL)
821 if (!check_no_attributes (parser, "standard_session_servicedirs", attribute_names, attribute_values, error))
824 if (push_element (parser, ELEMENT_STANDARD_SESSION_SERVICEDIRS) == NULL)
837 service_dirs_append_link_unique_or_free (&parser->service_dirs, link);
847 if (!check_no_attributes (parser, "standard_system_servicedirs", attribute_names, attribute_values, error))
850 if (push_element (parser, ELEMENT_STANDARD_SYSTEM_SERVICEDIRS) == NULL)
863 service_dirs_append_link_unique_or_free (&parser->service_dirs, link);
869 if (!check_no_attributes (parser, "allow_anonymous", attribute_names, attribute_values, error))
872 if (push_element (parser, ELEMENT_ALLOW_ANONYMOUS) == NULL)
878 parser->allow_anonymous = TRUE;
883 if (!check_no_attributes (parser, "servicedir", attribute_names, attribute_values, error))
886 if (push_element (parser, ELEMENT_SERVICEDIR) == NULL)
901 if ((e = push_element (parser, ELEMENT_INCLUDE)) == NULL)
911 if (!locate_attributes (parser, "include",
975 if ((e = push_element (parser, ELEMENT_POLICY)) == NULL)
983 if (!locate_attributes (parser, "policy",
1079 if ((e = push_element (parser, ELEMENT_LIMIT)) == NULL)
1085 if (!locate_attributes (parser, "limit",
1111 if (!check_no_attributes (parser, "selinux", attribute_names, attribute_values, error))
1114 if (push_element (parser, ELEMENT_SELINUX) == NULL)
1132 append_rule_from_element (BusConfigParser *parser,
1161 if (!locate_attributes (parser, element_name,
1575 pe = peek_element (parser);
1586 if (!bus_policy_append_default_rule (parser->policy, rule))
1590 if (!bus_policy_append_mandatory_rule (parser->policy, rule))
1602 if (!bus_policy_append_user_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1615 if (!bus_policy_append_group_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1622 if (!bus_policy_append_console_rule (parser->policy, pe->d.policy.gid_uid_or_at_console,
1643 start_policy_child (BusConfigParser *parser,
1651 if (!append_rule_from_element (parser, element_name,
1656 if (push_element (parser, ELEMENT_ALLOW) == NULL)
1666 if (!append_rule_from_element (parser, element_name,
1671 if (push_element (parser, ELEMENT_DENY) == NULL)
1689 start_selinux_child (BusConfigParser *parser,
1706 if (!locate_attributes (parser, "associate",
1715 if (push_element (parser, ELEMENT_ASSOCIATE) == NULL)
1735 if (!_dbus_hash_table_insert_string (parser->service_context_table,
1761 bus_config_parser_start_element (BusConfigParser *parser,
1773 t = top_element_type (parser);
1779 if (!check_no_attributes (parser, "busconfig", attribute_names, attribute_values, error))
1782 if (push_element (parser, ELEMENT_BUSCONFIG) == NULL)
1800 return start_busconfig_child (parser, element_name,
1806 return start_policy_child (parser, element_name,
1812 return start_selinux_child (parser, element_name,
1826 set_limit (BusConfigParser *parser,
1840 parser->limits.max_incoming_bytes = value;
1845 parser->limits.max_incoming_unix_fds = value;
1850 parser->limits.max_outgoing_bytes = value;
1855 parser->limits.max_outgoing_unix_fds = value;
1860 parser->limits.max_message_size = value;
1865 parser->limits.max_message_unix_fds = value;
1871 parser->limits.activation_timeout = value;
1877 parser->limits.auth_timeout = value;
1883 parser->limits.reply_timeout = value;
1889 parser->limits.max_completed_connections = value;
1895 parser->limits.max_incomplete_connections = value;
1901 parser->limits.max_connections_per_user = value;
1907 parser->limits.max_pending_activations = value;
1913 parser->limits.max_services_per_connection = value;
1919 parser->limits.max_match_rules_per_connection = value;
1925 parser->limits.max_replies_per_connection = value;
1956 bus_config_parser_end_element (BusConfigParser *parser,
1968 t = top_element_type (parser);
1976 "XML parser ended element with no element on the stack");
1993 e = peek_element (parser);
2022 if (!set_limit (parser, e->d.limit.name, e->d.limit.value,
2043 pop_element (parser);
2080 include_file (BusConfigParser *parser,
2098 if (seen_include (parser, filename))
2106 if (! _dbus_list_append (&parser->included_files, (void *) filename_str))
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);
2138 if (!merge_included (parser, included, error))
2144 /* Copy included's limits back to parser. */
2145 parser->limits = included->limits;
2153 servicehelper_path (BusConfigParser *parser,
2173 dbus_free (parser->servicehelper);
2174 parser->servicehelper = servicehelper;
2179 * It also allows the parser test suite to successfully parse
2187 include_dir (BusConfigParser *parser,
2237 if (!include_file (parser, &full_path, TRUE, error))
2260 if (!_dbus_list_append (&parser->conf_dirs, s))
2279 bus_config_parser_content (BusConfigParser *parser,
2297 e = peek_element (parser);
2310 switch (top_element_type (parser))
2334 bus_config_parser_element_type_to_name (top_element_type (parser)));
2347 dbus_free (parser->pidfile);
2348 parser->pidfile = s;
2382 else if (!make_full_path (&parser->basedir, content, &full_path))
2388 if (!include_file (parser, &full_path,
2408 if (!make_full_path (&parser->basedir, content, &full_path))
2414 if (!servicehelper_path (parser, &full_path, error))
2433 if (!make_full_path (&parser->basedir, content, &full_path))
2439 if (!include_dir (parser, &full_path, error))
2458 dbus_free (parser->user);
2459 parser->user = s;
2472 dbus_free (parser->bus_type);
2473 parser->bus_type = s;
2486 if (!_dbus_list_append (&parser->listen_on,
2504 if (!_dbus_list_append (&parser->mechanisms,
2523 if (!make_full_path (&parser->basedir, content, &full_path))
2536 if (!service_dirs_append_unique_or_free (&parser->service_dirs, s))
2580 bus_config_parser_finished (BusConfigParser *parser,
2585 if (parser->stack != NULL)
2589 bus_config_parser_element_type_to_name (top_element_type (parser)));
2594 if (parser->is_toplevel && parser->listen_on == NULL)
2605 bus_config_parser_get_user (BusConfigParser *parser)
2607 return parser->user;
2611 bus_config_parser_get_type (BusConfigParser *parser)
2613 return parser->bus_type;
2617 bus_config_parser_get_addresses (BusConfigParser *parser)
2619 return &parser->listen_on;
2623 bus_config_parser_get_mechanisms (BusConfigParser *parser)
2625 return &parser->mechanisms;
2629 bus_config_parser_get_service_dirs (BusConfigParser *parser)
2631 return &parser->service_dirs;
2635 bus_config_parser_get_conf_dirs (BusConfigParser *parser)
2637 return &parser->conf_dirs;
2641 bus_config_parser_get_fork (BusConfigParser *parser)
2643 return parser->fork;
2647 bus_config_parser_get_syslog (BusConfigParser *parser)
2649 return parser->syslog;
2653 bus_config_parser_get_keep_umask (BusConfigParser *parser)
2655 return parser->keep_umask;
2659 bus_config_parser_get_allow_anonymous (BusConfigParser *parser)
2661 return parser->allow_anonymous;
2665 bus_config_parser_get_pidfile (BusConfigParser *parser)
2667 return parser->pidfile;
2671 bus_config_parser_get_servicehelper (BusConfigParser *parser)
2673 return parser->servicehelper;
2677 bus_config_parser_steal_policy (BusConfigParser *parser)
2681 _dbus_assert (parser->policy != NULL); /* can only steal the policy 1 time */
2683 policy = parser->policy;
2685 parser->policy = NULL;
2692 bus_config_parser_get_limits (BusConfigParser *parser,
2695 *limits = parser->limits;
2699 bus_config_parser_steal_service_context_table (BusConfigParser *parser)
2703 _dbus_assert (parser->service_context_table != NULL); /* can only steal once */
2705 table = parser->service_context_table;
2707 parser->service_context_table = NULL;
2727 BusConfigParser *parser;
2732 parser = bus_config_load (full_path, TRUE, NULL, &error);
2733 if (parser == NULL)
2762 bus_config_parser_unref (parser);
3075 BusConfigParser *parser;
3082 parser = NULL;
3125 parser = bus_config_load (&full_path, TRUE, NULL, &error);
3127 if (parser == NULL)
3139 first_parser = parser;
3144 equal = config_parsers_equal (first_parser, parser);
3145 bus_config_parser_unref (parser);