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.
This commit is contained in:
parent
4b15c06830
commit
64a094f9de
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=25275
@ -73,6 +73,7 @@ main(argc, argv)
|
|||||||
{
|
{
|
||||||
struct union_args args;
|
struct union_args args;
|
||||||
int ch, mntflags;
|
int ch, mntflags;
|
||||||
|
char source[MAXPATHLEN];
|
||||||
char target[MAXPATHLEN];
|
char target[MAXPATHLEN];
|
||||||
struct vfsconf vfc;
|
struct vfsconf vfc;
|
||||||
int error;
|
int error;
|
||||||
@ -106,9 +107,12 @@ main(argc, argv)
|
|||||||
if (realpath(argv[0], target) == 0)
|
if (realpath(argv[0], target) == 0)
|
||||||
err(EX_OSERR, "%s", target);
|
err(EX_OSERR, "%s", target);
|
||||||
|
|
||||||
if (subdir(target, argv[1]) || subdir(argv[1], target))
|
if (realpath(argv[1], source) == 0)
|
||||||
errx(EX_USAGE, "%s (%s) and %s are not distinct paths",
|
err(EX_OSERR, "%s", target);
|
||||||
argv[0], target, argv[1]);
|
|
||||||
|
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;
|
args.target = target;
|
||||||
|
|
||||||
@ -122,7 +126,7 @@ main(argc, argv)
|
|||||||
if (error)
|
if (error)
|
||||||
errx(EX_OSERR, "union filesystem is not available");
|
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);
|
err(EX_OSERR, target);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ main(argc, argv)
|
|||||||
{
|
{
|
||||||
struct union_args args;
|
struct union_args args;
|
||||||
int ch, mntflags;
|
int ch, mntflags;
|
||||||
|
char source[MAXPATHLEN];
|
||||||
char target[MAXPATHLEN];
|
char target[MAXPATHLEN];
|
||||||
struct vfsconf vfc;
|
struct vfsconf vfc;
|
||||||
int error;
|
int error;
|
||||||
@ -106,9 +107,12 @@ main(argc, argv)
|
|||||||
if (realpath(argv[0], target) == 0)
|
if (realpath(argv[0], target) == 0)
|
||||||
err(EX_OSERR, "%s", target);
|
err(EX_OSERR, "%s", target);
|
||||||
|
|
||||||
if (subdir(target, argv[1]) || subdir(argv[1], target))
|
if (realpath(argv[1], source) == 0)
|
||||||
errx(EX_USAGE, "%s (%s) and %s are not distinct paths",
|
err(EX_OSERR, "%s", target);
|
||||||
argv[0], target, argv[1]);
|
|
||||||
|
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;
|
args.target = target;
|
||||||
|
|
||||||
@ -122,7 +126,7 @@ main(argc, argv)
|
|||||||
if (error)
|
if (error)
|
||||||
errx(EX_OSERR, "union filesystem is not available");
|
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);
|
err(EX_OSERR, target);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user