udisks2 and ACLs
Allin Cottrell <[email protected]>
| Newsgroups | gmane.linux.hotplug.devel |
|---|---|
| Message-ID | <[email protected]> |
I notice that udisks-1.99.0 depends unconditionally on ACLs (for handling permissions under /run/media). Since ACLs are kinda redundant on personal laptop and desktop systems it would be nice if this dependency were optional. I'm attaching a patch to udisks' udiskslinuxfilesystem.c which calls chown() if ACLs are not available. Since I'm not an automake guy I'm not sure how to revise the configure script, but the idea is that you should be able to do --disable-acl with the effect that ENABLE_ACL is not defined (otherwise it is defined). And config.h.in should have added: /* Enable ACLs */ #undef ENABLE_ACL -- Allin Cottrell Department of Economics Wake Forest University, NC
udisks-acl.diff
(text/plain, 2 KB)
--- udiskslinuxfilesystem.c.orig 2012-08-30 13:22:17.975670390 -0400
+++ udiskslinuxfilesystem.c 2012-09-05 09:15:01.755412910 -0400
@@ -29,7 +29,9 @@
#include <stdio.h>
#include <mntent.h>
#include <sys/types.h>
+#ifdef ENABLE_ACL
#include <sys/acl.h>
+#endif
#include <errno.h>
#include <glib/gstdio.h>
@@ -781,10 +783,13 @@
/* ---------------------------------------------------------------------------------------------------- */
+#ifdef ENABLE_ACL
+
static gboolean
-add_acl (const gchar *path,
- uid_t uid,
- GError **error)
+add_user_permission (const gchar *path,
+ uid_t uid,
+ gid_t gid,
+ GError **error)
{
gboolean ret = FALSE;
acl_t acl = NULL;
@@ -817,6 +822,34 @@
return ret;
}
+#else
+
+static gboolean
+add_user_permission (const gchar *path,
+ uid_t uid,
+ gid_t gid,
+ GError **error)
+{
+ gboolean ret = FALSE;
+
+ if (chown(path, uid, gid) != 0)
+ {
+ g_set_error (error,
+ G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "Giving ownership to uid %d for `%s' failed: %m",
+ (gint) uid, path);
+ }
+ else
+ {
+ ret = TRUE;
+ }
+
+ return ret;
+}
+
+#endif /* ENABLE_ACL or not */
+
/*
* calculate_mount_point: <internal>
* @dameon: A #UDisksDaemon.
@@ -888,8 +921,8 @@
mount_dir);
goto out;
}
- /* Finally, add the read+execute ACL for $USER */
- if (!add_acl (mount_dir, uid, error))
+ /* Finally, add the read+execute ACL for $USER (or chown) */
+ if (!add_user_permission (mount_dir, uid, gid, error))
{
if (rmdir (mount_dir) != 0)
udisks_warning ("Error calling rmdir() on %s: %m", mount_dir);