Commit graph

72 commits

Author SHA1 Message Date
Havoc Pennington
29560adcc7 2003-03-12 Havoc Pennington <hp@redhat.com>
Mega-patch that gets the message bus daemon initially handling
	out-of-memory. Work still needed. Also lots of random
	moving stuff to DBusError instead of ResultCode.

	* dbus/dbus-list.c (_dbus_list_length_is_one): new function

	* dbus/dbus-connection.c
	(dbus_connection_send_with_reply_and_block): use DBusError

	* dbus/dbus-bus.c: adapt to API changes, make it use DBusError not
	DBusResultCode

	* dbus/dbus-connection.c (dbus_connection_send): drop the result
	code here, as the only failure possible is OOM.

	* bus/connection.c (bus_connection_disconnect):
	rename bus_connection_disconnected as it's a notification only

	* bus/driver.c (bus_driver_handle_acquire_service): don't free
	"name" on get_args failure, should be done by get_args;
	don't disconnect client for bad args, just return an error.
	(bus_driver_handle_service_exists): ditto

	* bus/services.c (bus_services_list): NULL-terminate returned array

	* bus/driver.c (bus_driver_send_service_lost)
	(bus_driver_send_service_acquired): send messages from driver to a
	specific client to the client's unique name, not to the broadcast
	service.

	* dbus/dbus-message.c (decode_header_data): reject messages that
	contain no name field
	(_dbus_message_get_client_serial): rename to
	dbus_message_get_serial and make public
	(_dbus_message_set_serial): rename from set_client_serial
	(_dbus_message_set_reply_serial): make public
	(_dbus_message_get_reply_serial): make public

	* bus/connection.c (bus_connection_foreach): allow stopping
	iteration by returning FALSE from foreach function.

	* dbus/dbus-connection.c (dbus_connection_send_preallocated)
	(dbus_connection_free_preallocated_send)
	(dbus_connection_preallocate_send): new API for sending a message
	without possibility of malloc failure.
	(dbus_connection_send_message): rename to just
	dbus_connection_send (and same for whole function family)

	* dbus/dbus-errors.c (dbus_error_free): make this reinit the error

	* dbus/dbus-sysdeps.c (_dbus_exit): new function

	* bus/activation.c: handle/return errors

	* dbus/dbus-errors.h: add more DBUS_ERROR #define

	* dbus/dbus-sysdeps.c (_dbus_directory_open) (_dbus_file_get_contents)
	(_dbus_directory_get_next_file): use DBusError instead of DBusResultCode
	(_dbus_result_from_errno): move to this file
2003-03-13 00:56:43 +00:00
Anders Carlsson
799a3ff443 2003-03-10 Anders Carlsson <andersca@codefactory.se>
* dbus/dbus-marshal.c:
	(_dbus_marshal_set_string):
	Take a length argument so we can marshal the correct string
	length.

	(_dbus_marshal_dict), (_dbus_demarshal_dict),
	(_dbus_marshal_get_arg_end_pos), (_dbus_marshal_validate_arg),
	(_dbus_marshal_test):
	* dbus/dbus-marshal.h:
	Add support for marshalling and demarshalling dicts.

	* dbus/dbus-message-builder.c: (_dbus_message_data_load):
	Add support for TYPE DICT.

	* dbus/dbus-message.c: (set_string_field):
	Adjust header padding.

	(dbus_message_append_args_valist), (dbus_message_append_dict),
	(dbus_message_get_args_valist), (dbus_message_iter_get_arg_type),
	(dbus_message_iter_get_dict), (_dbus_message_loader_return_buffer),
	(check_message_handling), (check_have_valid_message):
	* dbus/dbus-message.h:
	Add functions for setting and getting dicts.

	* dbus/dbus-protocol.h:
	Add DBUS_TYPE_DICT.

	* dbus/dbus.h:
	Add dbus-dict.h

	* doc/dbus-specification.sgml:
	Add information about how dicts are marshalled.

	* test/data/invalid-messages/dict-with-nil-value.message:
	* test/data/invalid-messages/too-short-dict.message:
	* test/data/valid-messages/dict-simple.message:
	* test/data/valid-messages/dict.message:
	Add sample messages containing dicts.
2003-03-10 00:13:55 +00:00
Havoc Pennington
7e050c8871 2003-03-04 Havoc Pennington <hp@pobox.com>
* test/data/auth/*: adapt to changes

	* dbus/dbus-auth-script.c (_dbus_auth_script_run): add
	USERID_BASE64 and change USERNAME_BASE64 to put in username not
	userid

	* dbus/dbus-keyring.c (_dbus_keyring_validate_context): prevent
	more stuff from being in a context name, to make the protocol
	simpler to deal with

	* dbus/dbus-errors.c (dbus_error_has_name): new function
	(dbus_error_is_set): new function

	* dbus/dbus-auth.c: replace DBUS_STUPID_TEST_MECH auth
	with DBUS_COOKIE_SHA1, implement DBUS_COOKIE_SHA1

	* dbus/dbus-connection.c (dbus_connection_flush): also read
	messages during a flush operation

	* dbus/Makefile.am: remove dbus-md5 since it isn't currently used.
2003-03-05 02:01:34 +00:00
Havoc Pennington
f7d96bdf80 2003-03-02 Havoc Pennington <hp@pobox.com>
* test/break-loader.c (randomly_set_extreme_ints): add test that
	sets really huge and small integers

	* dbus/dbus-marshal.c (_dbus_marshal_validate_arg): add check
	that length of boolean array fits in the string, and that
	string has room for boolean value in single-bool case.

	* dbus/dbus-message-builder.c (_dbus_message_data_load): add
	optional value to "ALIGN" command which is what to fill the
	alignment with.

	* test/data/valid-messages/no-padding.message: add regression
	test for the message padding problem
2003-03-02 17:34:30 +00:00
Anders Carlsson
3781f063a6 2003-02-24 Anders Carlsson <andersca@codefactory.se>
* dbus/dbus-marshal.c: (_dbus_marshal_validate_arg):
	* dbus/dbus-message-builder.c: (_dbus_message_data_load):
	* dbus/dbus-message.c: (dbus_message_append_boolean),
	(dbus_message_append_boolean_array),
	(dbus_message_get_args_valist), (_dbus_message_test):
	* dbus/dbus-message.h:
	* doc/dbus-specification.sgml:
	Various fixes as pointed out by Havoc.

	* test/data/invalid-messages/bad-boolean-array.message:
	* test/data/invalid-messages/bad-boolean.message:
	Add invalid boolean value test cases.
2003-02-24 20:26:13 +00:00
Anders Carlsson
c8769e0b1d 2003-02-24 Anders Carlsson <andersca@codefactory.se>
* dbus/dbus-internals.c: (_dbus_type_to_string):
	* dbus/dbus-marshal.c: (_dbus_marshal_get_arg_end_pos),
	(_dbus_marshal_validate_arg):
	* dbus/dbus-message-builder.c: (_dbus_message_data_load):
	* dbus/dbus-message.c: (dbus_message_append_args_valist),
	(dbus_message_append_boolean), (dbus_message_append_boolean_array),
	(dbus_message_get_args_valist), (dbus_message_iter_get_boolean),
	(dbus_message_iter_get_int32), (dbus_message_iter_get_uint32),
	(dbus_message_iter_get_double),
	(dbus_message_iter_get_boolean_array), (message_iter_test):
	* dbus/dbus-message.h:
	* dbus/dbus-protocol.h:
	* doc/dbus-specification.sgml:
	* test/data/valid-messages/lots-of-arguments.message:
	Add support for boolean and boolean array types.
2003-02-24 19:04:13 +00:00
Havoc Pennington
6c07098c5e 2003-02-22 Havoc Pennington <hp@pobox.com>
* dbus/dbus-message.c (dbus_message_iter_get_string_array):
	(dbus_message_iter_get_byte_array): Fix up doxygen warnings

	* dbus/dbus-sha.c: add implementation of SHA-1 algorithm

	* dbus/test/data/sha-1: add US government test suite for SHA-1
2003-02-22 17:29:48 +00:00
Anders Carlsson
92f7d50b3b 2003-02-21 Anders Carlsson <andersca@codefactory.se>
* dbus/dbus-marshal.c: (_dbus_demarshal_string_array):
	Make string arrays NULL-terminated.

	* dbus/dbus-memory.c: (dbus_free_string_array):
	* dbus/dbus-memory.h:
	New function for freeing NULL-terminated string arrays.

	* dbus/dbus-message-builder.c: (append_quoted_string),
	(_dbus_message_data_load):
	Add support for array types.

	* dbus/dbus-message.c: (check_message_handling):
	Add more types as test cases.

	* dbus/dbus-sysdeps.c: (_dbus_string_parse_int),
	(_dbus_string_parse_double):
	Add the start offset to the end offset.

	* test/data/valid-messages/lots-of-arguments.message:
	New test message with lots of arguments.
2003-02-21 20:51:34 +00:00
Anders Carlsson
89ee9e6abf 2003-02-19 Anders Carlsson <andersca@codefactory.se>
* configure.in:
	Add check for nonposix getpwnam_r

	* dbus/dbus-mempool.c: (_dbus_mem_pool_new):
	Align the pool element size to a sizeof (void *) boundary.

	* dbus/dbus-sysdeps.c: (_dbus_setenv), (_dbus_connect_unix_socket),
	(_dbus_listen_unix_socket), (_dbus_credentials_from_username):
	General Solaris fixes.

	* test/data/valid-messages/simplest-manual.message:
	Explicitly state that we want little-endian packing.
2003-02-19 16:23:41 +00:00
Joe Shaw
9ada6e2cad 2003-02-18 Joe Shaw <joe@assbarn.com>
* dbus/dbus-auth.c (handle_server_data_stupid_test_mech): Just get
	credentials from our currently running process.
	(get_word): Fix a buglet where we were copying the entire length
	instead of relative to our position.

	* dbus/dbus-hash.c (_dbus_hash_test): Don't try to allocate the
	keys on the stack... it's 640k of data.

	* dbus/dbus-sysdeps.c (_dbus_read_credentials_unix_socket): Always
	read the credentials byte off the socket, even if we don't have
	SO_PEERCRED.
	(_dbus_poll): Implement poll() using select() for systems which
	don't have it.

	* glib/test-dbus-glib.c (main): Print out an error if no
	parameters are given.

	* test/data/auth/fallback.auth-script: Added.  Tests that a client
	can fallback to a secondary auth mechanism if the first fails.
2003-02-18 22:51:35 +00:00
Havoc Pennington
b293770841 add test for header padding not set to all bits 0 2003-02-16 23:10:05 +00:00
Havoc Pennington
e3a4d07d3b test cases with wrong header padding 2003-02-16 23:03:21 +00:00
Havoc Pennington
ac5183eafc add another test 2003-02-16 07:25:30 +00:00
Havoc Pennington
4a8a03aeb7 2003-02-16 Havoc Pennington <hp@pobox.com>
* dbus/dbus-connection.c (dbus_connection_set_change_sigpipe):
	allow people to avoid setting SIGPIPE to SIG_IGN
	(_dbus_connection_new_for_transport): disable SIGPIPE unless
	we've been asked not to
2003-02-16 07:20:54 +00:00
Anders Carlsson
f28c364352 2003-02-13 Anders Carlsson <andersca@codefactory.se>
* test/data/valid-messages/standard-acquire-service.message:
	* test/data/valid-messages/standard-hello.message:
	* test/data/valid-messages/standard-list-services.message:
	* test/data/valid-messages/standard-service-exists.message:
	Add some standard messages.
2003-02-13 15:39:58 +00:00
Havoc Pennington
5970d04af5 2003-02-13 Havoc Pennington <hp@pobox.com>
* dbus/dbus-auth.c (handle_server_data_external_mech): args to
	dbus_credentials_match were backward

	* dbus/dbus-auth-script.c (_dbus_auth_script_run): support
	NO_CREDENTIALS and ROOT_CREDENTIALS

	* dbus/dbus-auth.c (_dbus_auth_do_work): move get_state() routine
	into here. Never process more commands after we've reached an
	end state; store further data as unused bytes.

	* test/data/auth/*: add more auth tests

	* dbus/dbus-auth-script.c (_dbus_auth_script_run): support EXPECT
	command to match exact string and EXPECT_UNUSED to match unused
	bytes

	* test/Makefile.am (dist-hook): fix to dist all the test stuff
2003-02-13 04:11:57 +00:00
Havoc Pennington
c9ea8fac50 2003-02-12 Havoc Pennington <hp@pobox.com>
* dbus/dbus-string.c (_dbus_string_pop_line): fix to also strip
	\r off of popped lines

	* dbus/dbus-auth.c (_dbus_auth_test): write code to run auth
	scripts

	* dbus/dbus-auth-script.c (_dbus_auth_script_run): when doing a
	SEND, append \r\n
2003-02-13 02:33:32 +00:00
Anders Carlsson
8ab042b957 2003-01-31 Anders Carlsson <andersca@codefactory.se>
* dbus/dbus-address.c: (dbus_address_entry_free):
	Free key and value lists.

	* dbus/dbus-internals.c: (_dbus_type_to_string):
	Add the types we didn't have.

	* dbus/dbus-marshal.c: (_dbus_marshal_get_arg_end_pos),
	(_dbus_marshal_validate_arg):
	Add NIL types.

	* dbus/dbus-message.c: (dbus_message_set_sender):
	Remove todo about being able to set sender to NULL.

	(dbus_message_set_is_error_reply),
	(dbus_message_get_is_error_reply):
	* dbus/dbus-message.h:
	New functions.

	* dbus/dbus-protocol.h:
	Add error reply flag.

	* test/data/valid-messages/opposite-endian.message:
	Add NIL type to test.
2003-01-31 13:36:36 +00:00
Havoc Pennington
7ba714ad7f 2003-01-30 Havoc Pennington <hp@pobox.com>
* dbus/dbus-message.c: use message->byte_order instead of
	DBUS_COMPILER_BYTE_ORDER throughout.
	(dbus_message_create_header): pad header to align the
	start of the body of the message to 8-byte boundary

	* dbus/dbus-marshal.h: make all the demarshalers take const
	DBusString arguments.

	* dbus/dbus-message.c (_dbus_message_loader_return_buffer):
	validate message args here, so we don't have to do slow validation
	later, and so we catch bad messages as they are incoming. Also add
	better checks on header_len and body_len. Also fill in
	message->byte_order

	* dbus/dbus-string.c (_dbus_string_validate_utf8): new (not
	implemented properly)
	(_dbus_string_validate_nul): new function to check all-nul

	* dbus/dbus-marshal.c (_dbus_marshal_get_field_end_pos): rename
	get_arg_end_pos and remove all validation
	(_dbus_marshal_validate_arg): actually do validation here.
2003-01-30 04:20:44 +00:00
Havoc Pennington
bec3c093ca 2003-01-28 Havoc Pennington <hp@pobox.com>
* dbus/dbus-message.c (check_message_handling): function to check
	on the loaded message, iterates over it etc.
2003-01-28 04:20:29 +00:00
Havoc Pennington
05a4ad6994 2003-01-27 Havoc Pennington <hp@pobox.com>
* dbus/dbus-mempool.c (time_for_size): replace printf with
	_dbus_verbose

	* dbus/dbus-message-builder.c (_dbus_message_data_load): allow
	empty lines; fix the SAVE_LENGTH stuff to be
	START_LENGTH/END_LENGTH so it actually works; couple other
	bugfixes

	* test/Makefile.am (dist-hook): add dist-hook for .message files

	* dbus/dbus-string.c (DBUS_STRING_COPY_PREAMBLE): source of a copy
	can be constant or locked.
	(_dbus_string_free): allow freeing a const string as
	documented/intended

	* dbus/dbus-sysdeps.c (_dbus_concat_dir_and_file): utility

	* dbus/dbus-test-main.c (main): take an argument which is the
	directory containing test data

	* dbus/dbus-message.c (_dbus_message_test): pass a test_data_dir
	argument to this and load all the messages in test/data/
	checking that they can be loaded or not loaded as appropriate.
2003-01-28 03:53:29 +00:00
Havoc Pennington
2f440457d5 2003-01-26 Havoc Pennington <hp@pobox.com>
* dbus/dbus-message-builder.c: implement, completely untested.

	* test/data/*: add data to be used in testing.
	".message" files are our simple loadable text format.
	".message-raw" will be binary dumps of messages.

	* dbus/dbus-string.c (_dbus_string_starts_with_c_str): new
2003-01-26 21:16:06 +00:00