]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
2003-02-16 Havoc Pennington <hp@pobox.com>
authorHavoc Pennington <hp@redhat.com>
Sun, 16 Feb 2003 07:20:54 +0000 (07:20 +0000)
committerHavoc Pennington <hp@redhat.com>
Sun, 16 Feb 2003 07:20:54 +0000 (07:20 +0000)
* 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

14 files changed:
.cvsignore
ChangeLog
bus/.cvsignore
dbus/.cvsignore
dbus/dbus-bus.c
dbus/dbus-connection.c
dbus/dbus-connection.h
dbus/dbus-sysdeps.c
dbus/dbus-sysdeps.h
glib/.cvsignore
qt/.cvsignore
test/.cvsignore
test/data/auth/fail-after-n-attempts.auth-script [new file with mode: 0644]
test/data/valid-messages/unknown-header-field.message [new file with mode: 0644]

index d90d2b75432d0bc2ac4b854bbe3fadc31c5c544f..f36c2ddf92c1bd35154e451709bdf20b279837e6 100644 (file)
@@ -16,3 +16,7 @@ autom4te.cache
 config.guess
 config.h
 config.h.in
+*.bb
+*.bbg
+*.da
+*.gcov
index ff9212b1a3abe9a736a94776062b46b0231cef7d..94768963315565eb90cdb110dc01e79e80ed7525 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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-15  Anders Carlsson  <andersca@codefactory.se>
 
        * dbus/dbus-list.c: (_dbus_list_append_link),
index 8b96613021a4c88651763eb493fe9da49bc37de8..2c217808a7248934d6397f67459ffcb82fc15ba8 100644 (file)
@@ -5,3 +5,7 @@ Makefile.in
 *.lo
 *.la
 dbus-daemon-1
+*.bb
+*.bbg
+*.da
+*.gcov
index 4ebd42b84fa589d1e93ebe9f59bec0abdfb6db32..d5539b209a6f30a7b60c00da64ea62199dafd191 100644 (file)
@@ -5,3 +5,7 @@ Makefile.in
 *.lo
 *.la
 dbus-test
+*.bb
+*.bbg
+*.gcov
+*.da
index 776c78ae198599e85154d534dd2f01696fb37708..99ef5ade74aa4a57f96d0257c303e6627c90ca5a 100644 (file)
@@ -1,5 +1,5 @@
 /* -*- mode: C; c-file-style: "gnu" -*- */
-/* dbus-bus.h  Convenience functions for communicating with the bus.
+/* dbus-bus.c  Convenience functions for communicating with the bus.
  *
  * Copyright (C) 2003  CodeFactory AB
  *
index 73b9f18e544d6e312a3bec64a3cb1f569b865e5b..f97a5e134286d923ebbb47cf5ec09207fbcd73bd 100644 (file)
@@ -64,6 +64,8 @@
 /** default timeout value when waiting for a message reply */
 #define DEFAULT_TIMEOUT_VALUE (15 * 1000)
 
+static dbus_bool_t _dbus_modify_sigpipe = TRUE;
+
 /** Opaque typedef for DBusDataSlot */
 typedef struct DBusDataSlot DBusDataSlot;
 /** DBusDataSlot is used to store application data on the connection */
@@ -480,6 +482,9 @@ _dbus_connection_new_for_transport (DBusTransport *transport)
   disconnect_link = _dbus_list_alloc_link (disconnect_message);
   if (disconnect_link == NULL)
     goto error;
+
+  if (_dbus_modify_sigpipe)
+    _dbus_disable_sigpipe ();
   
   connection->refcount = 1;
   connection->mutex = mutex;
@@ -1684,7 +1689,9 @@ _dbus_allocated_slots_init_lock (void)
  * Allocates an integer ID to be used for storing application-specific
  * data on any DBusConnection. The allocated ID may then be used
  * with dbus_connection_set_data() and dbus_connection_get_data().
- * If allocation fails, -1 is returned.
+ * If allocation fails, -1 is returned. Again, the allocated
+ * slot is global, i.e. all DBusConnection objects will
+ * have a slot with the given integer ID reserved.
  *
  * @returns -1 on failure, otherwise the data slot ID
  */
@@ -1865,6 +1872,18 @@ dbus_connection_get_data (DBusConnection   *connection,
   return res;
 }
 
+/**
+ * This function sets a global flag for whether dbus_connection_new()
+ * will set SIGPIPE behavior to SIG_IGN.
+ *
+ * @param will_modify_sigpipe #TRUE to allow sigpipe to be set to SIG_IGN
+ */
+void
+dbus_connection_set_change_sigpipe (dbus_bool_t will_modify_sigpipe)
+{
+  _dbus_modify_sigpipe = will_modify_sigpipe;
+}
+
 /* This must be called with the connection lock not held to avoid
  * holding it over the free_data callbacks, so it can basically
  * only be called at last unref
index 774374e04753872d870f6d4536394eaa179cfec2..5a91ce8298f5ca57e0b36e158f15ffabd025af83 100644 (file)
@@ -155,6 +155,8 @@ dbus_bool_t dbus_connection_set_data           (DBusConnection   *connection,
 void*       dbus_connection_get_data           (DBusConnection   *connection,
                                                 int               slot);
 
+void        dbus_connection_set_change_sigpipe (dbus_bool_t       will_modify_sigpipe); 
+
 void dbus_connection_set_max_message_size       (DBusConnection *connection,
                                                  long            size);
 long dbus_connection_get_max_message_size       (DBusConnection *connection);
index e1ae16c327eb9b61c2bea63e49985b139e07bfd3..676777070b89d52028ae27a465308e675fc5687b 100644 (file)
@@ -1722,4 +1722,13 @@ _dbus_spawn_async (char      **argv,
   return FALSE;
 }
 
+/**
+ * signal (SIGPIPE, SIG_IGN);
+ */
+void
+_dbus_disable_sigpipe (void)
+{
+  signal (SIGPIPE, SIG_IGN);
+}
+
 /** @} end of sysdeps */
index dca12ed32908adda51f0ffdfc33087dd0965fafc..7805f0fd8e6177d2cdd4d90c7d941fb0ac4402ad 100644 (file)
@@ -151,7 +151,9 @@ const char *_dbus_errno_to_string (int         errnum);
 dbus_bool_t _dbus_spawn_async     (char      **argv,
                                   DBusError  *error);
 
-                              
+
+void _dbus_disable_sigpipe (void);
+
 DBUS_END_DECLS;
 
 #endif /* DBUS_SYSDEPS_H */
index 0d7278ef7e65bc05f8e6fc112c28e2bbd1668acb..2ab9efa852f468e396421b7521746ab7b5a3e33d 100644 (file)
@@ -5,3 +5,7 @@ Makefile.in
 *.lo
 *.la
 test-dbus-glib
+*.bb
+*.bbg
+*.da
+*.gcov
index 9626b60089eb0fd438b701c42fb90b4d4e9f7abb..b9485851083e22aceb3becc2a38173751f2bc7b6 100644 (file)
@@ -4,4 +4,7 @@ Makefile
 Makefile.in
 *.lo
 *.la
-
+*.bb
+*.bbg
+*.da
+*.gcov
index 3a3c50d9a34b0db37c54931dde72350e109dd8e2..c3d07582eef0a20105ce5e800f30ddd1e8d5f2a0 100644 (file)
@@ -9,3 +9,9 @@ echo-server
 echo-client
 bus-test
 unbase64
+*.bb
+*.bbg
+*.da
+*.gcov
+break-loader
+spawn-test
diff --git a/test/data/auth/fail-after-n-attempts.auth-script b/test/data/auth/fail-after-n-attempts.auth-script
new file mode 100644 (file)
index 0000000..75bd380
--- /dev/null
@@ -0,0 +1,33 @@
+## this tests that after retrying too often we fail
+
+SERVER
+NO_CREDENTIALS
+
+# 1
+SEND 'AUTH EXTERNAL USERNAME_BASE64'
+EXPECT_COMMAND REJECTED
+EXPECT_STATE WAITING_FOR_INPUT
+
+# 2
+SEND 'AUTH EXTERNAL USERNAME_BASE64'
+EXPECT_COMMAND REJECTED
+EXPECT_STATE WAITING_FOR_INPUT
+
+# 3
+SEND 'AUTH EXTERNAL USERNAME_BASE64'
+EXPECT_COMMAND REJECTED
+EXPECT_STATE WAITING_FOR_INPUT
+
+# 4
+SEND 'AUTH EXTERNAL USERNAME_BASE64'
+EXPECT_COMMAND REJECTED
+EXPECT_STATE WAITING_FOR_INPUT
+
+# 5
+SEND 'AUTH EXTERNAL USERNAME_BASE64'
+EXPECT_COMMAND REJECTED
+EXPECT_STATE WAITING_FOR_INPUT
+
+# 6
+SEND 'AUTH EXTERNAL USERNAME_BASE64'
+EXPECT_STATE NEED_DISCONNECT
diff --git a/test/data/valid-messages/unknown-header-field.message b/test/data/valid-messages/unknown-header-field.message
new file mode 100644 (file)
index 0000000..18ab379
--- /dev/null
@@ -0,0 +1,14 @@
+## message with a 'name' header field and unknown 'unkn' field
+
+## VALID_HEADER includes a LENGTH Header and LENGTH Body
+VALID_HEADER
+FIELD_NAME name
+TYPE STRING
+STRING 'org.freedesktop.Foo'
+FIELD_NAME unkn
+TYPE INT32
+INT32 0xfeeb
+ALIGN 8
+END_LENGTH Header
+START_LENGTH Body
+END_LENGTH Body