summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-sysdeps.c
diff options
context:
space:
mode:
authorJohn (J5) Palmieri <johnp@redhat.com>2005-06-15 15:59:57 +0000
committerJohn (J5) Palmieri <johnp@redhat.com>2005-06-15 15:59:57 +0000
commita93f9c04acedc37277ef60dc7225464b8b62f0ee (patch)
treeffa26a5795e85cbf72379239e234785ca1eb2fd3 /dbus/dbus-sysdeps.c
parent5e389fdf499c39926c61b47fcafb5e71291ce1a2 (diff)
* 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
Diffstat (limited to 'dbus/dbus-sysdeps.c')
-rw-r--r--dbus/dbus-sysdeps.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c
index 96d51bed..fe747b8d 100644
--- a/dbus/dbus-sysdeps.c
+++ b/dbus/dbus-sysdeps.c
@@ -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 */
/**