]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
* dbus/dbus-message.c:
authorJohn (J5) Palmieri <johnp@redhat.com>
Wed, 15 Jun 2005 15:59:57 +0000 (15:59 +0000)
committerJohn (J5) Palmieri <johnp@redhat.com>
Wed, 15 Jun 2005 15:59:57 +0000 (15:59 +0000)
        (dbus_message_has_path): New method
        (dbus_message_has_interface): New method
        (dbus_message_has_member): New method

        * dbus/dbus/dbus-sysdeps.c (_dbus_check_dir_is_private_to_user):
        New method

        * dbus/dbus-keyring.c (_dbus_keyring_reload): Check to see that
        the keyring directory is private to the user

        * doc/TODO:
         - The convenience functions in dbus-bus.h should perhaps have
         the signatures that they would have if they were autogenerated
         stubs. e.g. the acquire service function. We should also evaluate
         which of these functions to include, in light of the fact that
         GLib/Qt native stubs will probably also exist.: Punted

         - add dbus_message_has_path(), maybe has_member/interface:
         fixed in this patch

         - in dbus-keyring.c, enforce that the keyring dir is not
         world readable/writable: Fixed in this patch

ChangeLog
dbus/dbus-keyring.c
dbus/dbus-message.c
dbus/dbus-message.h
dbus/dbus-sysdeps.c
dbus/dbus-sysdeps.h
doc/TODO

index 6d3087e03c62682bdd56c185f9cef480ac693aa0..9875c600d51c8398ae86ce013c4cb9460d4eefec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2005-06-15  John (J5) Palmieri  <johnp@redhat.com>
+
+       * dbus/dbus-message.c:
+       (dbus_message_has_path): New method
+       (dbus_message_has_interface): New method
+       (dbus_message_has_member): New method
+
+       * dbus/dbus/dbus-sysdeps.c (_dbus_check_dir_is_private_to_user):
+       New method
+
+       * dbus/dbus-keyring.c (_dbus_keyring_reload): Check to see that 
+       the keyring directory is private to the user
+
+       * doc/TODO:
+        - The convenience functions in dbus-bus.h should perhaps have
+        the signatures that they would have if they were autogenerated
+        stubs. e.g. the acquire service function. We should also evaluate
+        which of these functions to include, in light of the fact that
+        GLib/Qt native stubs will probably also exist.: Punted
+
+        - add dbus_message_has_path(), maybe has_member/interface:
+        fixed in this patch
+
+        - in dbus-keyring.c, enforce that the keyring dir is not
+        world readable/writable: Fixed in this patch
+
 2005-06-15  John (J5) Palmieri  <johnp@redhat.com>
 
        * dbus/dbus-marshal-validate.h: Added a new validation
index 8fbfd685ad85c5b67d5787144529256a7b43d8ef..11f4826cc6e90aad1a7919d0772afaed4de6100b 100644 (file)
@@ -415,6 +415,9 @@ _dbus_keyring_reload (DBusKeyring *keyring,
 
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
   
+  if (!_dbus_check_dir_is_private_to_user (&keyring->directory, error))
+    return FALSE;
+    
   if (!_dbus_string_init (&contents))
     {
       dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
@@ -427,7 +430,7 @@ _dbus_keyring_reload (DBusKeyring *keyring,
       _dbus_string_free (&contents);
       return FALSE;
     }
-
+   
   keys = NULL;
   n_keys = 0;
   retval = FALSE;
index cdfdf5f3959a9f5f708a5013f025c182df0527ae..983eea93e133a829de66cb190e727ecfeee28c14 100644 (file)
@@ -2430,6 +2430,36 @@ dbus_message_get_path (DBusMessage   *message)
   return v;
 }
 
+/**
+ * Checks if the message has a path
+ *
+ * @param message the message
+ * @returns #TRUE if there is a path field in the header
+ */
+dbus_bool_t
+dbus_message_has_path (DBusMessage   *message,
+                       const char    *path)
+{
+  const char *msg_path;
+  msg_path = dbus_message_get_path (message);
+  
+  if (msg_path == NULL)
+    {
+      if (path == NULL)
+        return TRUE;
+      else
+        return FALSE;
+    }
+
+  if (path == NULL)
+    return FALSE;
+   
+  if (strcmp (msg_path, path) == 0)
+    return TRUE;
+
+  return FALSE;
+}
+
 /**
  * Gets the object path this message is being sent to
  * (for DBUS_MESSAGE_TYPE_METHOD_CALL) or being emitted
@@ -2520,6 +2550,37 @@ dbus_message_get_interface (DBusMessage *message)
   return v;
 }
 
+/**
+ * Checks if the message has an interface
+ *
+ * @param message the message
+ * @returns #TRUE if there is a interface field in the header
+ */
+dbus_bool_t
+dbus_message_has_interface (DBusMessage   *message,
+                            const char    *interface)
+{
+  const char *msg_interface;
+  msg_interface = dbus_message_get_interface (message);
+   
+  if (msg_interface == NULL)
+    {
+      if (interface == NULL)
+        return TRUE;
+      else
+        return FALSE;
+    }
+
+  if (interface == NULL)
+    return FALSE;
+     
+  if (strcmp (msg_interface, interface) == 0)
+    return TRUE;
+
+  return FALSE;
+
+}
+
 /**
  * Sets the interface member being invoked
  * (DBUS_MESSAGE_TYPE_METHOD_CALL) or emitted
@@ -2569,6 +2630,37 @@ dbus_message_get_member (DBusMessage *message)
   return v;
 }
 
+/**
+ * Checks if the message has an interface member
+ *
+ * @param message the message
+ * @returns #TRUE if there is a member field in the header
+ */
+dbus_bool_t
+dbus_message_has_member (DBusMessage   *message,
+                         const char    *member)
+{
+  const char *msg_member;
+  msg_member = dbus_message_get_member (message);
+  if (msg_member == NULL)
+    {
+      if (member == NULL)
+        return TRUE;
+      else
+        return FALSE;
+    }
+
+  if (member == NULL)
+    return FALSE;
+    
+  if (strcmp (msg_member, member) == 0)
+    return TRUE;
+
+  return FALSE;
+
+}
+
 /**
  * Sets the name of the error (DBUS_MESSAGE_TYPE_ERROR).
  * The name is fully-qualified (namespaced).
index 6124e253396c3465c9f67047316ab4d87c3c574b..f0e80a6775cb53972a524c2e30c500321bb95c53 100644 (file)
@@ -85,12 +85,18 @@ int           dbus_message_get_type         (DBusMessage   *message);
 dbus_bool_t   dbus_message_set_path         (DBusMessage   *message,
                                              const char    *object_path);
 const char*   dbus_message_get_path         (DBusMessage   *message);
+dbus_bool_t   dbus_message_has_path         (DBusMessage   *message, 
+                                             const char    *object_path);  
 dbus_bool_t   dbus_message_set_interface    (DBusMessage   *message,
-                                             const char    *interface);
+                                             const char    *interface);       
 const char*   dbus_message_get_interface    (DBusMessage   *message);
+dbus_bool_t   dbus_message_has_interface    (DBusMessage   *message, 
+                                             const char    *interface);
 dbus_bool_t   dbus_message_set_member       (DBusMessage   *message,
                                              const char    *member);
 const char*   dbus_message_get_member       (DBusMessage   *message);
+dbus_bool_t   dbus_message_has_member       (DBusMessage   *message, 
+                                             const char    *member);
 dbus_bool_t   dbus_message_set_error_name   (DBusMessage   *message,
                                              const char    *name);
 const char*   dbus_message_get_error_name   (DBusMessage   *message);
index 96d51bede44caab1ebd3e7ea40cc80910ff61991..fe747b8d58ae0f946034ce05a329a3f6ce5dfa4a 100644 (file)
@@ -1131,6 +1131,42 @@ _dbus_string_parse_int (const DBusString *str,
   return TRUE;
 }
 
+/**
+* Checks to make sure the given directory is 
+* private to the user 
+*
+* @param error error return
+* @returns #FALSE on failure
+**/
+dbus_bool_t
+_dbus_check_dir_is_private_to_user (DBusString *dir, DBusError *error)
+{
+  const char *directory;
+  struct stat sb;
+       
+  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+    
+  directory = _dbus_string_get_const_data (dir);
+       
+  if (stat (directory, &sb) < 0)
+    {
+      dbus_set_error (error, _dbus_error_from_errno (errno),
+                      "%s", _dbus_strerror (errno));
+   
+      return FALSE;
+    }
+    
+  if ((S_IROTH & sb.st_mode) || (S_IWOTH & sb.st_mode) ||
+      (S_IRGRP & sb.st_mode) || (S_IWGRP & sb.st_mode))
+    {
+      dbus_set_error (error, DBUS_ERROR_FAILED,
+                     "%s directory is not private to the user", directory);
+      return FALSE;
+    }
+    
+  return TRUE;
+}
+
 #ifdef DBUS_BUILD_TESTS
 /* Not currently used, so only built when tests are enabled */
 /**
index 6727630a60666e53f1e613af5ea17f1ca3fa4690..da80c0526be8bcc519db957b2b9c7f3195c76c38 100644 (file)
@@ -255,6 +255,8 @@ dbus_bool_t  _dbus_directory_get_next_file (DBusDirIter      *iter,
                                             DBusError        *error);
 void         _dbus_directory_close         (DBusDirIter      *iter);
 
+dbus_bool_t  _dbus_check_dir_is_private_to_user    (DBusString *dir,
+                                                    DBusError *error);
 
 void        _dbus_generate_random_bytes_buffer (char       *buffer,
                                                 int         n_bytes);
index 773ebf46095900d59b79d65786d20919cdeb3d4e..7eedcd4ac7d7a689d57c5272a0e40ee0a0260e7a 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -5,12 +5,6 @@ Important for 1.0
 
  - Audit @todo and FIXME for security issues
 
- - The convenience functions in dbus-bus.h should perhaps have
-   the signatures that they would have if they were autogenerated
-   stubs. e.g. the acquire service function. We should also evaluate 
-   which of these functions to include, in light of the fact that 
-   GLib/Qt native stubs will probably also exist.
-
  - the "break loader" and valid/invalid message tests are all disabled;
    they need to be fixed and re-enabled with the new message args stuff.
    I think I want to drop the .message files thing and just have code
@@ -48,8 +42,6 @@ Important for 1.0 GLib Bindings
 Might as Well for 1.0
 ===
 
- - add dbus_message_has_path(), maybe has_member/interface
-
  - protocol version in each message is pretty silly
 
 Can Be Post 1.0