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 d90d2b7..f36c2dd 100644 (file)
@@ -16,3 +16,7 @@ autom4te.cache
 config.guess
 config.h
 config.h.in
+*.bb
+*.bbg
+*.da
+*.gcov
index ff9212b..9476896 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 8b96613..2c21780 100644 (file)
@@ -5,3 +5,7 @@ Makefile.in
 *.lo
 *.la
 dbus-daemon-1
+*.bb
+*.bbg
+*.da
+*.gcov
index 4ebd42b..d5539b2 100644 (file)
@@ -5,3 +5,7 @@ Makefile.in
 *.lo
 *.la
 dbus-test
+*.bb
+*.bbg
+*.gcov
+*.da
index 776c78a..99ef5ad 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 73b9f18..f97a5e1 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 774374e..5a91ce8 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 e1ae16c..6767770 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 dca12ed..7805f0f 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 0d7278e..2ab9efa 100644 (file)
@@ -5,3 +5,7 @@ Makefile.in
 *.lo
 *.la
 test-dbus-glib
+*.bb
+*.bbg
+*.da
+*.gcov
index 9626b60..b948585 100644 (file)
@@ -4,4 +4,7 @@ Makefile
 Makefile.in
 *.lo
 *.la
-
+*.bb
+*.bbg
+*.da
+*.gcov
index 3a3c50d..c3d0758 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