summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Heidelberger <david.heidelberger@ixit.cz>2014-03-13 21:28:42 +0100
committerMartin Pitt <martin.pitt@ubuntu.com>2016-02-29 16:45:21 +0100
commitce392b4e158cbe8051c54203966851ed859412f6 (patch)
tree9f441c520ed8260e97f5d73cc99fd09a64bb7f2a
parent9272e10a1ce8807880240c4911a1f224f52e02c8 (diff)
downloadudisks-ce392b4e158cbe8051c54203966851ed859412f6.tar.gz
allow disabling ACL
This patch provide option to build and run udisks without ACL. v2: as replacement of ACL is used chown call v3: do not change uid, change gid v4: fix indentation & formating issues v5: one missed empty line v6: add g_set_error for chown Thanks Peter Wu for helping me with improving code. https://bugs.freedesktop.org/show_bug.cgi?id=54866
-rw-r--r--configure.ac38
-rw-r--r--src/udiskslinuxfilesystem.c17
2 files changed, 43 insertions, 12 deletions
diff --git a/configure.ac b/configure.ac
index fadba1e..521502b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -183,18 +183,31 @@ if test "x$with_systemdsystemunitdir" != "xno"; then
fi
AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$systemdsystemunitdir"])
-# libacl
-AC_CHECK_HEADERS(
- [sys/acl.h acl/libacl.h],
- [ACL_CFLAGS=""],
- AC_MSG_ERROR([*** ACL headers not found.]))
-AC_CHECK_LIB(
- [acl],
- [acl_get_file],
- [ACL_LIBS="-lacl"],
- AC_MSG_ERROR([*** libacl not found.]))
-AC_SUBST(ACL_CFLAGS)
-AC_SUBST(ACL_LIBS)
+have_acl=no
+AC_ARG_ENABLE(acl, AS_HELP_STRING([--disable-acl], [disable acl support]))
+if test "x$enable_acl" != "xno"; then
+ AC_CHECK_HEADERS(
+ [sys/acl.h acl/libacl.h],
+ [
+ AC_CHECK_LIB(
+ [acl],
+ [acl_get_file],
+ [AC_DEFINE(HAVE_ACL, 1, [Define if libacl is available]) have_acl=yes],
+ have_acl=no)
+ ],
+ have_acl=no)
+ if test "x$have_acl" = "xyes"; then
+ ACL_CFLAGS=""
+ ACL_LIBS="-lacl"
+ fi
+ AC_SUBST(ACL_CFLAGS)
+ AC_SUBST(ACL_LIBS)
+ if test "x$have_acl" = xno -a "x$enable_acl" = xyes; then
+ AC_MSG_ERROR([acl support requested but libraries not found])
+ fi
+fi
+AM_CONDITIONAL(HAVE_ACL, [test "$have_acl" = "yes"])
+
# Internationalization
#
@@ -242,6 +255,7 @@ echo "
systemdsystemunitdir: ${systemdsystemunitdir}
using libsystemd-login: ${have_libsystemd_login}
use /media for mounting: ${fhs_media}
+ acl support: ${have_acl}
compiler: ${CC}
cflags: ${CFLAGS}
diff --git a/src/udiskslinuxfilesystem.c b/src/udiskslinuxfilesystem.c
index 4db3745..68f7c4d 100644
--- a/src/udiskslinuxfilesystem.c
+++ b/src/udiskslinuxfilesystem.c
@@ -30,7 +30,9 @@
#include <stdio.h>
#include <mntent.h>
#include <sys/types.h>
+#ifdef HAVE_ACL
#include <sys/acl.h>
+#endif
#include <errno.h>
#include <glib/gstdio.h>
@@ -803,6 +805,7 @@ ensure_utf8 (const gchar *s)
/* ---------------------------------------------------------------------------------------------------- */
+#ifdef HAVE_ACL
static gboolean
add_acl (const gchar *path,
uid_t uid,
@@ -835,6 +838,7 @@ add_acl (const gchar *path,
acl_free (acl);
return ret;
}
+#endif
/*
* calculate_mount_point: <internal>
@@ -912,7 +916,11 @@ calculate_mount_point (UDisksDaemon *daemon,
goto out;
}
/* Then create the per-user MOUNT_BASE/$USER */
+#ifdef HAVE_ACL
if (g_mkdir (mount_dir, 0700) != 0 && errno != EEXIST)
+#else
+ if (g_mkdir (mount_dir, 0750) != 0 && errno != EEXIST)
+#endif
{
g_set_error (error,
UDISKS_ERROR,
@@ -922,8 +930,17 @@ calculate_mount_point (UDisksDaemon *daemon,
goto out;
}
/* Finally, add the read+execute ACL for $USER */
+#ifdef HAVE_ACL
if (!add_acl (mount_dir, uid, error))
{
+#else
+ if (chown (mount_dir, -1, gid) == -1)
+ {
+ g_set_error (error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ "Failed to change gid to %d for %s: %m",
+ (gint) gid, mount_dir);
+#endif
if (rmdir (mount_dir) != 0)
udisks_warning ("Error calling rmdir() on %s: %m", mount_dir);
goto out;