]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mount: add phelper=
authorKarel Zak <kzak@redhat.com>
Wed, 30 Mar 2011 12:56:33 +0000 (14:56 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 30 Mar 2011 12:56:33 +0000 (14:56 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
mount/mount.c
mount/umount.8
mount/umount.c

index d9739897f39c5d452f1766367a804c92bd23aaff..dc357a09859acfe1ab5b65e5fede23fe60af092c 100644 (file)
@@ -209,7 +209,7 @@ static const struct opt_map opt_map[] = {
 static int opt_nofail = 0;
 
 static const char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_sizelimit,
-        *opt_encryption, *opt_speed, *opt_comment, *opt_uhelper;
+        *opt_encryption, *opt_speed, *opt_comment, *opt_uhelper, *opt_phelper;
 
 static int is_readonly(const char *node);
 static int mounted (const char *spec0, const char *node0);
@@ -229,6 +229,7 @@ static struct string_opt_map {
   { "speed=", 0, &opt_speed },
   { "comment=", 1, &opt_comment },
   { "uhelper=", 0, &opt_uhelper },
+  { "phelper=", 0, &opt_phelper },
   { NULL, 0, NULL }
 };
 
index 3606caae904a72563cd93a7aa38e38e2fb0f01e2..69196e539edcf7e948a369b3f97ef1ac85048476 100644 (file)
@@ -151,13 +151,17 @@ The syntax of external umount helpers is:
 .IR type.subtype ]
 .br
 
-where the <suffix> is filesystem type or a value from "uhelper=" mtab option.
-The \-t option is used  for filesystems with subtypes support (for example
-/sbin/mount.fuse -t fuse.sshfs).
+where the <suffix> is filesystem type or a value from "uhelper=" or "phelper="
+mtab option.  The \-t option is used  for filesystems with subtypes support
+(for example /sbin/mount.fuse -t fuse.sshfs).
 
 The uhelper (unprivileged umount helper) is possible to used when non-root user
 wants to umount a mountpoint which is not defined in the /etc/fstab file (e.g
-devices mounted by HAL).
+devices mounted by udisk).
+
+The phelper (privileged umount helper) is possible to used when root user wants
+to umount a mountpoint which should not be directly umounted by umount(8) (e.g.
+devices mounted by pam_mount).
 
 .SH FILES
 .I /etc/mtab
index 347945c82eb6c58a49b92de103af914396fdac5f..f69e5bf33835f6989a518133694d4f390f4350cf 100644 (file)
@@ -572,12 +572,31 @@ is_valid_loop(struct mntentchn *mc, struct mntentchn *fs)
        return 0;
 }
 
+/*
+ * umount helper call based on {u,p}helper= mount option
+ */
+static int check_helper_umountprog(const char *spec, const char *node,
+                                  const char *opts, const char *name,
+                                  int *status)
+{
+       char *helper;
+
+       if (!external_allowed || !opts)
+               return 0;
+
+       helper = get_option_value(opts, name);
+       if (helper)
+               return check_special_umountprog(spec, node, helper, status);
+
+       return 0;
+}
+
 static int
 umount_file (char *arg) {
        struct mntentchn *mc, *fs;
        const char *file, *options;
        int fstab_has_user, fstab_has_users, fstab_has_owner, fstab_has_group;
-       int ok;
+       int ok, status = 0;
        struct stat statbuf;
 
        if (!*arg) {            /* "" would be expanded to `pwd` */
@@ -643,22 +662,11 @@ umount_file (char *arg) {
                            _("umount: %s is not mounted (according to mtab)"),
                            file);
                /*
-                * uhelper - unprivileged umount helper
-                * -- external umount (for example HAL mounts)
+                * uhelper - unprivileged umount helper (e.g. HAL/udisks mounts)
                 */
-               if (external_allowed) {
-                       char *uhelper = NULL;
-
-                       if (mc->m.mnt_opts)
-                               uhelper = get_option_value(mc->m.mnt_opts,
-                                                          "uhelper=");
-                       if (uhelper) {
-                               int status = 0;
-                               if (check_special_umountprog(arg, arg,
-                                                       uhelper, &status))
-                                       return status;
-                       }
-               }
+               if (check_helper_umountprog(arg, arg, mc->m.mnt_opts,
+                                           "uhelper=", &status))
+                       return status;
 
                /* The 2.4 kernel will generally refuse to mount the same
                   filesystem on the same mount point, but will accept NFS.
@@ -729,6 +737,14 @@ umount_file (char *arg) {
                        die (2, _("umount: only %s can unmount %s from %s"),
                             mtab_user ? mtab_user : "root",
                             fs->m.mnt_fsname, fs->m.mnt_dir);
+
+       } else if (mc) {
+               /*
+                * phelper - privileged umount helper (e.g. pam_mount)
+                */
+                if (check_helper_umountprog(arg, arg, mc->m.mnt_opts,
+                                           "phelper=", &status))
+                       return status;
        }
 
        if (mc)