From: Karel Zak Date: Wed, 30 Mar 2011 12:56:33 +0000 (+0200) Subject: mount: add phelper= X-Git-Tag: v2.20-rc1~411 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=afa2dd42159b3c385aff9f1c3e90194c4fa6e54e;p=thirdparty%2Futil-linux.git mount: add phelper= Signed-off-by: Karel Zak --- diff --git a/mount/mount.c b/mount/mount.c index d9739897f3..dc357a0985 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -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 } }; diff --git a/mount/umount.8 b/mount/umount.8 index 3606caae90..69196e539e 100644 --- a/mount/umount.8 +++ b/mount/umount.8 @@ -151,13 +151,17 @@ The syntax of external umount helpers is: .IR type.subtype ] .br -where the 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 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 diff --git a/mount/umount.c b/mount/umount.c index 347945c82e..f69e5bf338 100644 --- a/mount/umount.c +++ b/mount/umount.c @@ -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)