Commit graph

83 commits

Author SHA1 Message Date
Alban Crequy
5670dc6cf7 config parser: add own_prefix
https://bugs.freedesktop.org/show_bug.cgi?id=46882
2012-03-04 14:36:56 +00:00
Simon McVittie
fccb5a0fe1 Explicitly don't search XDG_DATA_DIRS for system services, and document it
In practice, it never works, because the activation helper doesn't
respect environment variables for security reasons.
If you want to vary the search path, alter system.conf instead, to
replace or augment <standard_system_servicedirs/> with your preferred
search path.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=21620
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2012-02-08 16:11:35 +00:00
Simon McVittie
222b7d9f97 config-parser: don't try to get CommonProgramFiles from the environment on Unix
It's unused on Unix, and gcc warns.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39231
Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
2011-08-05 12:27:04 +01:00
Lennart Poettering
d837d937c5 activation: add /lib/dbus-1/system-services to the search path for services
In order to allow D-Bus usage during early boot (where /usr is not
accessible) also search for bus activation files in
/lib/dbus-1/system-services/. This is only a first step in the right
direction, before we really can boot without /usr we'd need to move all
current activation files (or possibly replace
/usr/dbus-1/system-services to a symlink to
/lib/dbus-1/system-services).
2011-07-28 21:22:07 +02:00
Simon McVittie
75cecfc374 Break up the monster conditional in config-parser so gcov can cope
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=10887
Reviewed-by: Colin Walters <walters@verbum.org>
2011-04-07 11:25:54 +01:00
Andre Heinecke
e0fc90bdf2 Do not use the name ELEMENT_TYPE
On Windows Systems ELEMENT_TYPE is already defined
in Winioctl.h this header is included indirectly
in dbus-sysdeps.h. By avoiding the use of the Name
ELEMENT_TYPE it is ensured that config-parser-common.h
can be included together with dbus-sysdeps.h

Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2011-03-07 13:50:38 +00:00
Simon McVittie
7848abe6c2 config-parser regression test: don't require that fd.o #34496 exists
Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
2011-02-24 18:40:11 +00:00
Simon McVittie
7480dfdb2a If a file included via <includedir/> is invalid, syslog and skip it
This is more graceful than failing entirely (our previous behaviour),
but more visible than ignoring it completely (the previous behaviour
patched in by Debian and derivatives).

Based on a patch from Daniel Silverstone back in 2004, which was meant
to be temporary; I think it makes sense to change this permanently,
since files in *.d are typically supplied by other packages, whose bugs
shouldn't be able to bring down dbus-daemon.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=19186
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=230231
Reviewed-by: Colin Walters <walters@verbum.org>
2011-01-31 19:16:00 +00:00
Ralf Habacker
02d973686a Use absolute session service dir path in bus-test on windows. 2010-12-29 14:43:24 +01:00
Marcus Brinkmann
dbecdeabb2 Consistently include <config.h> in all C source files and never in header files. 2010-03-19 20:11:48 +01:00
Ralf Habacker
73b926275f uses tcp based test connections for now 2009-12-01 11:17:40 +01:00
Thiago Macieira
37019e9d27 Merge branch 'fd-passing'
Conflicts:
	dbus/dbus-connection.c
	dbus/dbus-message-util.c
	dbus/dbus-sysdeps-unix.c
2009-07-16 16:05:16 +02:00
Tobias Mueller
5baf2f856a Bug 21161 - Update the FSF address
No comment.

Signed-off-by: Colin Walters <walters@verbum.org>
2009-07-10 19:32:38 -04:00
Scott James Remnant
8f1d2a2fa8 Change default reply timeout.
* bus/config-parser.c (bus_config_parser_new): change the default reply
  timeout to "never"

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-05-28 11:47:36 +02:00
Lennart Poettering
64ad844967 bus: make use of new unix fd limits
Create configuration settings and enforce message unix fd limits the
same way we do for allocated message memory.
2009-05-20 02:10:17 +02:00
Thiago Macieira
63196f69c4 Merge branch 'dbus-1.2'
Conflicts:
	bus/bus.c
	bus/config-parser-common.c
	bus/config-parser-common.h
	bus/config-parser.c
	bus/connection.c
	bus/dbus-daemon.1.in
	dbus/dbus-marshal-validate-util.c
	dbus/dbus-marshal-validate.c
	dbus/dbus-sysdeps-util-unix.c
	test/name-test/tmp-session-like-system.conf
2009-04-28 15:16:36 +02:00
Matt McCutchen
6663d1dd35 Bug 18446: Keep umask for session bus
Signed-off-by: Colin Walters <walters@verbum.org>
2009-01-06 18:20:13 -05:00
Colin Walters
427ff01f9d Add optional logging on allow rules
This lets us have a backwards compatibility allow rule but still easily
see when that rule is being used.
2008-12-16 12:20:43 -05:00
Colin Walters
6053d2208e Add optional logging on allow rules
This lets us have a backwards compatibility allow rule but still easily
see when that rule is being used.
2008-12-16 11:57:27 -05:00
Colin Walters
69ed32cbcc Add syslog of security denials and configuration file reloads
We need to start logging denials so that they become more easily trackable
and debuggable.
2008-12-12 15:18:12 -05:00
Colin Walters
bb2a464067 Add syslog of security denials and configuration file reloads
We need to start logging denials so that they become more easily trackable
and debuggable.
2008-12-12 14:00:16 -05:00
Dennis Kaarsemaker
07a4ad4b04 Bug 15393 - support allow_anonymous config variable
* bus/bus.c: Set allow_anonymous if specified from
	parser.
	* bus/config-parser.c: Parse it.
	* bus/config-parser-common.h: Declare it.

Signed-off-by: Colin Walters <walters@verbum.org>
2008-11-12 08:51:00 -05:00
Matt McCutchen
0314e701c8 Bug 18446: Keep umask for session bus
Signed-off-by: Colin Walters <walters@verbum.org>
2008-11-10 08:55:27 -05:00
John (J5) Palmieri
f72bb380a6 remove dead code
2008-01-15  John (J5) Palmieri  <johnp@redhat.com>

	* patch by Kimmo Hämäläinen <kimmo dot hamalainen at nokia dot com>

	* bus/config-parser.c (locate_attributes): remove dead code which
	always evaluated to TRUE

	* dbus/dbus-shell.c (_dbus_shell_quote): remove unused code
2008-01-15 13:32:47 -05:00
Havoc Pennington
79d3004e26 2007-07-24 Havoc Pennington <hp@redhat.com>
* configure.in: add AM_PROG_CC_C_O to allow per-target CPPFLAGS

	* bus/dispatch.c (bus_dispatch_test_conf): Fix up setting
	TEST_LAUNCH_HELPER_CONFIG to include the full path, and enable
	test shell_fail_service_auto_start when use_launcher==TRUE

	* bus/activation-helper-bin.c (convert_error_to_exit_code): pass
	through the INVALID_ARGS error so the test suite works

	* bus/activation.c (handle_activation_exit_error): return
	DBUS_ERROR_NO_MEMORY if we get BUS_SPAWN_EXIT_CODE_NO_MEMORY

	* dbus/dbus-spawn.c (_dbus_babysitter_get_child_exit_status):
	return only the exit code of the child, not the entire thingy from
	waitpid(), and make the return value indicate whether the child
	exited normally (with a status code)

	* bus/bus.c (process_config_first_time_only): _dbus_strdup works
	on NULL so no need to check
	(process_config_every_time): move servicehelper init here, so we
	reload it on HUP or config file change

	* bus/Makefile.am (install-data-hook): remove comment because
	Emacs make mode seems to be grumpy about it
2007-07-24 22:11:00 +00:00
Richard Hughes
0cb8dd64a9 2007-07-24 Richard Hughes <richard@hughsie.com>
* bus/Makefile.am:
* bus/config-parser.c: (bus_config_parser_unref),
(start_busconfig_child), (bus_config_parser_end_element),
(servicehelper_path), (bus_config_parser_content),
(bus_config_parser_finished),
(bus_config_parser_get_servicehelper),
(test_default_session_servicedirs),
(test_default_system_servicedirs), (bus_config_parser_test):
* bus/config-parser.h:
Make the config-parser code use the common config code.
Also add the session and systemdirs stuff, and make the config parser
aware of the servicehelper field.
2007-07-24 11:58:08 +00:00
Havoc Pennington
d012387afe 2007-07-13 Havoc Pennington <hp@redhat.com>
* Add indent-tabs-mode: nil to all file headers.
2007-07-14 02:44:01 +00:00
Havoc Pennington
ebb99420e5 add a comment about the match rules limit 2007-06-19 17:23:55 +00:00
Havoc Pennington
7be5fd95cd 2007-06-09 Havoc Pennington <hp@redhat.com>
* bus/policy.c (bus_policy_create_client_policy): gracefully
	continue if the connection has no unix user - just don't apply
	any unix user dependent rules.

	* bus/config-parser.c: remove dbus-userdb.h usage

	* bus/bus.c: remove dbus-userdb.h usage

	* dbus/dbus-transport.c (_dbus_transport_get_is_authenticated):
	support Windows user function; also, fix the logic for checking
	auth as root in the default auth code (broken in the previous
	commit)

	* dbus/dbus-connection.c
	(dbus_connection_set_windows_user_function): new function
	(dbus_connection_get_windows_user): new function
2007-06-09 23:41:33 +00:00
Ralf Habacker
5bd59d4a6c * bus/config-parser.c (test_service_dir_matches): fixed ordering for unix.
* bus/config-parser.c (test_default_session_servicedirs): made allocation  of _progs platform independent.
2007-05-24 08:07:28 +00:00
Ralf Habacker
e02f8b1c00 * bus\config-parser.c (test_default_session_servicedirs):win32 fix. 2007-05-17 11:47:48 +00:00
Ralf Habacker
cd57ebe33b * bus/config-parser.c, bus/policy.c, bus/policy.h, bus/dbus-daemon.1.in,bus/session.conf.in: added eavesdrop support for replies - patch by olli.salli at collabora.co.uk approved by Havoc Pennington. 2007-03-15 13:27:01 +00:00
Havoc Pennington
9362aac398 2007-03-11 Havoc Pennington <hp@redhat.com>
* tools/dbus-launch.c (do_close_stderr): fix C89 problem and
	formatting problem

	* Mostly fix the DBusPipe mess.
	- put line break after function return types
	- put space before parens
	- do not pass structs around by value
	- don't use dbus_strerror after calling supposedly cross-platform
	api
	- don't name pipe variables "fd"
	- abstract special fd numbers like -1 and 1
2007-03-12 22:52:40 +00:00
Havoc Pennington
8d3d8ff557 2007-01-26 Havoc Pennington <hp@redhat.com>
* bus/session.conf.in: override all the default limits with much
	higher limits on the session bus, there is no reason the session
	bus should have low limits

	* bus/config-parser.c (bus_config_parser_new): increase default
	limits so they are less likely to be hit; in particular the max
	replies per connection was way too low
2007-01-26 16:10:26 +00:00
John (J5) Palmieri
a157ec7f72 * bus/config-parser.c (service_dirs_find_dir): use
_dbus_list_get_next_link so we don't get stuck in an infinite loop
  (start_busconfig_child): move processing of standard_session_servicedirs
  tags here because they have no content
  (bus_config_parser_content): check we don't have content in
  standard_session_servicedirs tag

* tools/Makefile.am: Make sure the /var/lib/dbus directory is created
  Packagers need to own this directory
2006-11-02 23:56:48 +00:00
John (J5) Palmieri
5640f7a57b * configure.in: expose DBUS_DATADIR
* bus/config-parser.c: add the standard_session_servicedirs element
  to the parser
  (bus_config_parser_content): process the standard_session_servicedirs
  element by getting the standard directories from sysdeps and merging
  them into the service directory list
  (test_default_session_servicedirs): make sure we get what we expect

* bus/session.conf.in: replace the servicedir tag with the
  standard_session_servicedirs tag

* dbus/dbus-list.h: remove the typedef of DBusList and place it in
  dbus-sysdeps.h to avoid circular header dependencies

* dbus/dbus-sysdeps.h: add the typedef of DBusList

* dbus/dbus-sysdeps-unix.c (split_paths_and_append): utility function
  which takes a string of directories delimited by colons, parses them
  out, appends a suffix and puts them in a list ignoring empty elements
  (_dbus_get_standard_session_servicedirs): returns the standard
  directories for a session bus to look for service activation files
  on Unix which includes the XDG_DATA_HOME, XDG_DATA_DIRS and
  DBUS_DATADIR directories

* test/data/valid-config-files/many-rules.conf: add the
  standard_session_servicedirs tag to the valid config file tests
2006-11-01 23:30:46 +00:00
John (J5) Palmieri
feb7d3a0f0 * bus/config-parser.c (service_dirs_find_dir,
service_dirs_append_unique_or_free,
  service_dirs_append_link_unique_or_free): New static methods
  for only appending unique service directory names into
  the service directory list
  (merge_included, bus_config_parser_content): Only add unique
  service directory names into the list
2006-10-27 18:30:22 +00:00
John (J5) Palmieri
9a3145b9f3 These are all patches from Kjartan Maraas <kmaraas at gnome dot org>
with cleanups of bugs found from Coverity reports:

* dbus/dbus-sysdeps-util.c (_dbus_write_pid_file):
  close the file on error to avoid a leak

* bus/expirelist.c (bus_expire_list_test):
  Check for NULL on dbus_new0

* bus/activation.c (update_directory):
  remove dead code

* bus/config-parser.c (merge_service_context_hash, start_selinux_child):
  Fix some leaks

* bus/bus.c (process_config_every_time):
  Fixed a leak

* bus/desktop-file.c (parse_key_value):
  Fixed leak

* bus/selinux.c (bus_selinux_id_table_insert):
  Fixed leak
2006-08-08 23:29:03 +00:00
David Zeuthen
1d19fc62e9 2005-06-14 David Zeuthen <davidz@redhat.com>
* bus/bus.c (process_config_every_time): Drop existing conf-dir
        watches (if applicable) and add new watches

        * bus/main.c (signal_handler): Handle SIGIO if using D_NOTIFY
        (main): Setup SIGIO signal handler if using D_NOTIFY

        * bus/config-parser.h: Add prototype bus_config_parser_get_conf_dirs

        * bus/config-parser.c (struct BusConfigParser): Add conf_dirs list
        (merge_included): Also merge conf_dirs list
        (bus_config_parser_unref): Clear conf_dirs list
        (include_dir): Add directory to conf_dirs list
        (bus_config_parser_get_conf_dirs): New function

        * bus/dir-watch.[ch]: New files

        * bus/Makefile.am (BUS_SOURCES): Add dir-watch.[ch]

        * configure.in: Add checks for D_NOTIFY on Linux
2005-06-15 02:31:38 +00:00
David Zeuthen
ded3a8efb1 2005-04-13 David Zeuthen <davidz@redhat.com>
* bus/config-parser.c (bus_config_parser_new): Bump this to a
        more reasonable, yet still totally arbitrary, value :-).
2005-04-14 15:10:22 +00:00
Havoc Pennington
8873c90f99 2005-01-18 Havoc Pennington <hp@redhat.com>
* Throughout, grand renaming to strip out the use of "service",
	just say "name" instead (or "bus name" when ambiguous).  Did not
	change the internal code of the message bus itself, only the
	programmer-facing API and messages.

	* doc/dbus-specification.xml: further update the message bus section

	* bus/config-parser.c (all_are_equiv): fix bug using freed string
	in error case
2005-01-18 20:42:15 +00:00
Colin Walters
cdac3e058b 2004-11-07 Colin Walters <walters@verbum.org>
* bus/bus.c (load_config): Break into three
	separate functions: process_config_first_time_only,
	process_config_every_time, and process_config_postinit.
	(process_config_every_time): Move call of
	bus_registry_set_service_context_table into
	process_config_postinit.
	(process_config_postinit): New function, does
	any processing that needs to happen late
	in initialization (and also on reload).
	(bus_context_new): Instead of calling load_config,
	open config parser here and call process_config_first_time_only
	and process_config_every_time directly.  Later, after
	we have forked but before changing UID,
	invoke bus_selinux_full_init, and then call
	process_config_postinit.
	(bus_context_reload_config): As in bus_context_new,
	load parse file inside here, and call process_config_every_time
	and process_config_postinit.

	* bus/services.h, bus/services.c
	(bus_registry_set_service_context_table): Rename
	from bus_registry_set_sid_table.  Take string hash from config
	parser, and convert them here into SIDs.

	* bus/config-parser.c (struct BusConfigParser): Have
	config parser only store a mapping of service->context
	string.
	(merge_service_context_hash): New function.
	(merge_included): Merge context string hashes instead
	of using bus_selinux_id_table_union.
	(bus_config_parser_new): Don't use bus_selinux_id_table_new;
	simply create a new string hash.
	(bus_config_parser_unref): Unref it.
	(start_selinux_child): Simply insert strings into hash,
	don't call bus_selinux_id_table_copy_over.

	* bus/selinux.h, bus/selinux.c (bus_selinux_id_table_union)
	(bus_selinux_id_table_copy_over): Delete.
2004-11-07 17:05:19 +00:00
Colin Walters
736fa825e1 2004-10-18 Colin Walters <walters@verbum.org>
* bus/selinux.h: Add bus_selinux_enabled.

	* bus/selinux.c (bus_selinux_enabled): Implement it.

	* bus/config-parser.c (struct include): Add
	if_selinux_enabled member.
	(start_busconfig_child): Parse if_selinux_enabled
	attribute for include.
	(bus_config_parser_content): Handle it.

	* bus/session.conf.in, bus/system.conf.in: Add
	inclusion of context mapping to default config files;
	conditional on SELinux being enabled.

	* doc/busconfig.dtd: Add to if_selinux_enabled to default DTD.

	* test/data/invalid-config-files/badselinux-1.conf,
	test/data/invalid-config-files/badselinux-2.conf:
	Test files for bad syntax.
2004-10-18 04:04:12 +00:00
John (J5) Palmieri
b78d222083 Console user security policy
* bus/config-parser.c:
(struct PolicyType): Add POLICY_CONSOLE
(struct Element.d.policy): s/gid_or_uid/gid_uid_or_at_console
(start_busconfig_child): Sets up console element when
<policy at_console=""> is encountered in a policy file
(append_rule_from_element): Convert console elements to console
rules.

* bus/policy.c:
(bus_policy_create_client_policy): Add console rules to the client
policy based on if the client is at the console
(bus_policy_append_console_rule): New function for adding a
console rule to a policy
(bus_policy_merge): Handle console rule merging

* dbus/dbus-sysdeps.h: Added the DBUS_CONSOLE_DIR constant
where we check for console user files

* dbus/dbus-sysdeps.c:
(_dbus_file_exists): New function which checks if the given
file exists
(_dbus_user_at_console): New function which does the system
specific process of checking if the user is at the console

* dbus/dbus-userdb.c:
(_dbus_is_console_user): New function converts a UID to user name
and then calls the system specific _dbus_user_at_console to
see if the user is at the console and therefor a console user
2004-08-25 22:11:49 +00:00
Olivier Andrieu
8a2c91b8a5 * bus/config-parser.c (set_limit):
* bus/dbus-daemon-1.1.in:
* test/data/valid-config-files/many-rules.conf: set the
max_match_rules_per_connection limt from the config file.

* doc/busconfig.dtd: update the DTD.

* bus/driver.c: remove some unused variables.
2004-08-25 08:03:12 +00:00
Colin Walters
ee78f2800f 2004-08-23 Colin Walters <walters@redhat.com>
* bus/selinux.h: Prototype bus_selinux_get_policy_root.

	* bus/selinux.c: Create a thread for policy reload notification.
	(bus_selinux_get_policy_root): Implement.

	Updated SELinux support from Matthew Rickard <mjricka@epoch.ncsc.mil>

	* bus/config-parser.c (start_busconfig_child)
	(bus_config_parser_content): Support SELinux-root relative
	inclusion.

	* configure.in <HAVE_SELINUX>: Add -lpthread.

	* bus/test-main.c (test_pre_hook, test_post_hook): New.
	(test_post_hook): Move memory checking into here.
	(test_pre_hook, test_post_hook): Move SELinux checks in
	here, but conditional on a DBUS_TEST_SELINUX environment
	variable.  Unfortunately we can't run the SELinux checks
	as a normal user, since they won't have any permissions
	for /selinux.  So this will have to be tested manually
	for now, until we have virtualization for most of
	libselinux.
2004-08-23 16:09:54 +00:00
Colin Walters
c7c4d95d0e 2004-08-20 Colin Walters <walters@redhat.com>
* bus/config-parser.c (start_busconfig_child): Remove some unused
	variables.

	* bus/selinux.c (bus_selinux_id_table_insert): Avoid compiler
	warning.
2004-08-20 15:28:50 +00:00
Havoc Pennington
43605a6f4e 2004-08-09 Havoc Pennington <hp@redhat.com>
* COPYING: switch to Academic Free License version 2.1 instead of
	2.0, to resolve complaints about patent termination clause.
2004-08-10 03:07:01 +00:00
Olivier Andrieu
3abcc7d28d * bus/config-parser.c (bus_config_parser_new): fix an invalid _unref
in the SELinux support.

* doc/busconfig.dtd: update DTD for SELinux support.

* bus/config-loader-libxml.c: fix error handler and parser
initialisation/cleanup. OOM test now works with libxml2 HEAD.

* configure.in: remove the warning about libxml2

* dbus/dbus-bus.c: silence doxygen warning.
2004-07-31 18:28:10 +00:00
Havoc Pennington
1e9b185b0c 2004-07-24 Havoc Pennington <hp@redhat.com>
SELinux support from Matthew Rickard <mjricka@epoch.ncsc.mil>

	* bus/selinux.c, bus/selinux.h: new file encapsulating selinux
	functionality

	* configure.in: add --enable-selinux

	* bus/policy.c (bus_policy_merge): add FIXME to a comment

	* bus/main.c (main): initialize and shut down selinux

	* bus/connection.c: store SELinux ID on each connection, to avoid
	repeated getting of the string context and converting it into
	an ID

	* bus/bus.c (bus_context_get_policy): new accessor, though it
	isn't used
	(bus_context_check_security_policy): check whether the security
	context of sender connection can send to the security context of
	recipient connection

	* bus/config-parser.c: add parsing for <selinux> and <associate>

	* dbus/dbus-transport.c (_dbus_transport_get_unix_fd): to
	implement dbus_connection_get_unix_fd()

	* dbus/dbus-connection.c (dbus_connection_get_unix_fd): new
	function, used by the selinux stuff
2004-07-30 05:59:34 +00:00