summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago@kde.org>2006-10-24 20:25:01 +0000
committerThiago Macieira <thiago@kde.org>2006-10-24 20:25:01 +0000
commit9bb44a470ffd4eace9307b47be37f9ccab276eec (patch)
tree03a1010e6c18855b2d38b962bd54d994d0d5e52e
parentcb905b58f068ba68ca8f6645b2c4e9b51ec61e3e (diff)
* dbus/dbus-sysdeps.h:
* dbus/dbus-sysdeps-unix.c: Add function _dbus_make_file_world_readable that chmods a file to 0644. * dbus/dbus-sysdeps-unix.c (_dbus_get_autolaunch_address): Avoid writing to the static "argv" array, thereby avoiding a COW on the child process. * dbus/dbus-internals.c (_dbus_create_uuid_file_exclusively): call _dbus_make_file_world_readable on the created file.
-rw-r--r--ChangeLog13
-rw-r--r--dbus/dbus-internals.c2
-rw-r--r--dbus/dbus-sysdeps-unix.c34
-rw-r--r--dbus/dbus-sysdeps.h3
4 files changed, 48 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 17a343c1..9200d1b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-10-24 Thiago Macieira <thiago@kde.org>
+
+ * dbus/dbus-sysdeps.h:
+ * dbus/dbus-sysdeps-unix.c: Add function
+ _dbus_make_file_world_readable that chmods a file to 0644.
+
+ * dbus/dbus-sysdeps-unix.c (_dbus_get_autolaunch_address):
+ Avoid writing to the static "argv" array, thereby avoiding a
+ COW on the child process.
+
+ * dbus/dbus-internals.c (_dbus_create_uuid_file_exclusively):
+ call _dbus_make_file_world_readable on the created file.
+
2006-10-23 David Zeuthen <davidz@redhat.com>
* dbus/dbus-memory.c: Use atomic variable to protect
diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c
index 73e8e086..961e7269 100644
--- a/dbus/dbus-internals.c
+++ b/dbus/dbus-internals.c
@@ -639,6 +639,8 @@ _dbus_create_uuid_file_exclusively (const DBusString *filename,
if (!_dbus_string_save_to_file (&encoded, filename, error))
goto error;
+ if (!_dbus_make_file_world_readable (filename, error))
+ goto error;
_dbus_string_free (&encoded);
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index 01b712b3..45764050 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -1802,6 +1802,33 @@ _dbus_string_save_to_file (const DBusString *str,
return retval;
}
+/** Makes the file readable by every user in the system.
+ *
+ * @param filename the filename
+ * @param error error location
+ * @returns #TRUE if the file's permissions could be changed.
+ */
+dbus_bool_t
+_dbus_make_file_world_readable(const DBusString *filename,
+ DBusError *error)
+{
+ const char *filename_c;
+
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ filename_c = _dbus_string_get_const_data (filename);
+ if (chmod (filename_c, 0644) == -1)
+ {
+ dbus_set_error (error,
+ DBUS_ERROR_FAILED,
+ "Could not change permissions of file %s: %s\n",
+ filename_c,
+ _dbus_strerror (errno));
+ return FALSE;
+ }
+ return TRUE;
+}
+
/** Creates the given file, failing if the file already exists.
*
* @param filename the filename
@@ -2361,11 +2388,11 @@ _dbus_get_autolaunch_address (DBusString *address,
}
i = 0;
- argv[i] = DBUS_BINDIR "/dbus-launch";
+ argv[i] = "dbus-launch";
++i;
argv[i] = "--autolaunch";
++i;
- argv[i] = /* const cast */ (char*) _dbus_string_get_const_data (&uuid);
+ argv[i] = _dbus_string_get_data (&uuid);
++i;
argv[i] = "--binary-syntax";
++i;
@@ -2423,10 +2450,9 @@ _dbus_get_autolaunch_address (DBusString *address,
close (fd);
close (address_pipe[WRITE_END]);
- execv (argv[0], argv);
+ execv (DBUS_BINDIR "/dbus-launch", argv);
/* failed, try searching PATH */
- argv[0] = "dbus-launch";
execvp ("dbus-launch", argv);
/* still nothing, we failed */
diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h
index 77eda965..9e4e6544 100644
--- a/dbus/dbus-sysdeps.h
+++ b/dbus/dbus-sysdeps.h
@@ -273,6 +273,9 @@ dbus_bool_t _dbus_string_save_to_file (const DBusString *str,
const DBusString *filename,
DBusError *error);
+dbus_bool_t _dbus_make_file_world_readable (const DBusString *filename,
+ DBusError *error);
+
dbus_bool_t _dbus_create_file_exclusively (const DBusString *filename,
DBusError *error);
dbus_bool_t _dbus_delete_file (const DBusString *filename,