summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Pfeiffer <markus.pfeiffer@morphism.de>2017-10-30 11:09:24 +0000
committerMarkus Pfeiffer <markus.pfeiffer@morphism.de>2017-10-31 00:37:20 +0000
commitbc4641c0be094d7297cce5746de3569aa3ae1442 (patch)
treecd2ee667bca1d0397db0c405fc1464261080b536
parent6d4d6c980ce68f9b22b96cbcb229893f80f14243 (diff)
downloadConsoleKit2-bc4641c0be094d7297cce5746de3569aa3ae1442.tar.gz
Fix make_tmpfs for DragonFly
The previous version of the code assumed that DragonFly supports passing a string of options to mount(2). This is not the case and so this lead to a bug where a user's tmpfs was created with invalid ownership and mode. We now correctly pass a struct of type tmpfs_mount_info. The struct is only exported as of DragonFly 5.1 and newer, so this code will only build on a recent version of DragonFly.
-rw-r--r--src/ck-sysdeps-dragonfly.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/ck-sysdeps-dragonfly.c b/src/ck-sysdeps-dragonfly.c
index b43de38..dc28c5d 100644
--- a/src/ck-sysdeps-dragonfly.c
+++ b/src/ck-sysdeps-dragonfly.c
@@ -48,6 +48,7 @@
#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
+#include <vfs/tmpfs/tmpfs_mount.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
@@ -546,16 +547,19 @@ gboolean
ck_make_tmpfs (guint uid, guint gid, const gchar *dest)
{
#ifdef HAVE_SYS_MOUNT_H
- gchar *opts;
- int result;
-
+ int result;
+ struct tmpfs_mount_info opts;
TRACE ();
- opts = g_strdup_printf ("mode=0700,uid=%d", uid);
-
- result = mount("tmpfs", dest, 0, opts);
+ opts.ta_version = TMPFS_ARGS_VERSION;
+ opts.ta_size_max = 0;
+ opts.ta_nodes_max = 0;
+ opts.ta_maxfsize_max = 0;
+ opts.ta_root_uid = uid;
+ opts.ta_root_gid = gid;
+ opts.ta_root_mode = 0x1c0; /* 0700 */
- g_free (opts);
+ result = mount("tmpfs", dest, 0, &opts);
if (result == 0) {
return TRUE;