Use realpath on the source as well as the destination.
This commit is contained in:
parent
9c63729513
commit
f329f664dd
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=26072
@ -45,7 +45,7 @@ char copyright[] =
|
|||||||
static char sccsid[] = "@(#)mount_null.c 8.6 (Berkeley) 4/26/95";
|
static char sccsid[] = "@(#)mount_null.c 8.6 (Berkeley) 4/26/95";
|
||||||
*/
|
*/
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: mount_null.c,v 1.8 1997/03/11 12:33:36 peter Exp $";
|
"$Id: mount_null.c,v 1.9 1997/03/29 03:32:42 imp Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -76,6 +76,7 @@ main(argc, argv)
|
|||||||
{
|
{
|
||||||
struct null_args args;
|
struct null_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;
|
||||||
@ -99,7 +100,10 @@ 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)
|
||||||
|
err(EX_OSERR, "%s", source);
|
||||||
|
|
||||||
|
if (subdir(target, source) || subdir(source, target))
|
||||||
errx(EX_USAGE, "%s (%s) and %s are not distinct paths",
|
errx(EX_USAGE, "%s (%s) and %s are not distinct paths",
|
||||||
argv[0], target, argv[1]);
|
argv[0], target, argv[1]);
|
||||||
|
|
||||||
@ -115,7 +119,7 @@ main(argc, argv)
|
|||||||
if (error)
|
if (error)
|
||||||
errx(EX_OSERR, "null/loopback filesystem is not available");
|
errx(EX_OSERR, "null/loopback filesystem is not available");
|
||||||
|
|
||||||
if (mount(vfc.vfc_name, argv[1], mntflags, &args))
|
if (mount(vfc.vfc_name, source, mntflags, &args))
|
||||||
err(1, NULL);
|
err(1, NULL);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ char copyright[] =
|
|||||||
static char sccsid[] = "@(#)mount_null.c 8.6 (Berkeley) 4/26/95";
|
static char sccsid[] = "@(#)mount_null.c 8.6 (Berkeley) 4/26/95";
|
||||||
*/
|
*/
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"$Id: mount_null.c,v 1.8 1997/03/11 12:33:36 peter Exp $";
|
"$Id: mount_null.c,v 1.9 1997/03/29 03:32:42 imp Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -76,6 +76,7 @@ main(argc, argv)
|
|||||||
{
|
{
|
||||||
struct null_args args;
|
struct null_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;
|
||||||
@ -99,7 +100,10 @@ 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)
|
||||||
|
err(EX_OSERR, "%s", source);
|
||||||
|
|
||||||
|
if (subdir(target, source) || subdir(source, target))
|
||||||
errx(EX_USAGE, "%s (%s) and %s are not distinct paths",
|
errx(EX_USAGE, "%s (%s) and %s are not distinct paths",
|
||||||
argv[0], target, argv[1]);
|
argv[0], target, argv[1]);
|
||||||
|
|
||||||
@ -115,7 +119,7 @@ main(argc, argv)
|
|||||||
if (error)
|
if (error)
|
||||||
errx(EX_OSERR, "null/loopback filesystem is not available");
|
errx(EX_OSERR, "null/loopback filesystem is not available");
|
||||||
|
|
||||||
if (mount(vfc.vfc_name, argv[1], mntflags, &args))
|
if (mount(vfc.vfc_name, source, mntflags, &args))
|
||||||
err(1, NULL);
|
err(1, NULL);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user