aboutsummaryrefslogtreecommitdiff
path: root/sbin/mount_unionfs/mount_unionfs.c
diff options
context:
space:
mode:
authorDoug Rabson <dfr@FreeBSD.org>1997-04-29 09:09:09 +0000
committerDoug Rabson <dfr@FreeBSD.org>1997-04-29 09:09:09 +0000
commit64a094f9de0a7c8aab63b7081f83827bfc1aa17a (patch)
tree6923b941b684a22c67fed8277de3be8b716d7ce1 /sbin/mount_unionfs/mount_unionfs.c
parent4b15c06830f04102a6a85165531240d34b1b944a (diff)
downloadsrc-64a094f9de0a7c8aab63b7081f83827bfc1aa17a.tar.gz
src-64a094f9de0a7c8aab63b7081f83827bfc1aa17a.zip
Use realpath() on the source as well as the target otherwise it can be
impossible to unmount a union which was mounted with a relative pathname.
Notes
Notes: svn path=/head/; revision=25275
Diffstat (limited to 'sbin/mount_unionfs/mount_unionfs.c')
-rw-r--r--sbin/mount_unionfs/mount_unionfs.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sbin/mount_unionfs/mount_unionfs.c b/sbin/mount_unionfs/mount_unionfs.c
index e2acac97df4f..03b0f2f805c6 100644
--- a/sbin/mount_unionfs/mount_unionfs.c
+++ b/sbin/mount_unionfs/mount_unionfs.c
@@ -73,6 +73,7 @@ main(argc, argv)
{
struct union_args args;
int ch, mntflags;
+ char source[MAXPATHLEN];
char target[MAXPATHLEN];
struct vfsconf vfc;
int error;
@@ -106,9 +107,12 @@ main(argc, argv)
if (realpath(argv[0], target) == 0)
err(EX_OSERR, "%s", target);
- if (subdir(target, argv[1]) || subdir(argv[1], target))
- errx(EX_USAGE, "%s (%s) and %s are not distinct paths",
- argv[0], target, argv[1]);
+ if (realpath(argv[1], source) == 0)
+ err(EX_OSERR, "%s", target);
+
+ if (subdir(target, source) || subdir(source, target))
+ errx(EX_USAGE, "%s (%s) and %s (%s) are not distinct paths",
+ argv[0], target, argv[1], source);
args.target = target;
@@ -122,7 +126,7 @@ main(argc, argv)
if (error)
errx(EX_OSERR, "union filesystem is not available");
- if (mount(vfc.vfc_name, argv[1], mntflags, &args))
+ if (mount(vfc.vfc_name, source, mntflags, &args))
err(EX_OSERR, target);
exit(0);
}