summaryrefslogtreecommitdiffstats
path: root/sbin/mount_unionfs/mount_unionfs.c
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1997-04-29 09:09:09 +0000
committerdfr <dfr@FreeBSD.org>1997-04-29 09:09:09 +0000
commit57051903646d04b2d3a23881594295fbe03ae7a6 (patch)
treea6d489bd94d89151c36f8ac02410df873ba77c88 /sbin/mount_unionfs/mount_unionfs.c
parenta10f222e6900de2bd563ab14e6e2d47d3faac992 (diff)
downloadFreeBSD-src-57051903646d04b2d3a23881594295fbe03ae7a6.zip
FreeBSD-src-57051903646d04b2d3a23881594295fbe03ae7a6.tar.gz
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.
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 e2acac9..03b0f2f 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);
}
OpenPOWER on IntegriCloud