diff options
author | dfr <dfr@FreeBSD.org> | 1997-05-23 17:07:40 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 1997-05-23 17:07:40 +0000 |
commit | 2fc66c2d94f99e157344d3a48c19192a99de5c43 (patch) | |
tree | 627aab032887b4ce5d2a701ff70e31b9eb695b35 /sbin | |
parent | eedff6c44bf07ebb414c85ec464f53dc61127a7e (diff) | |
download | FreeBSD-src-2fc66c2d94f99e157344d3a48c19192a99de5c43.zip FreeBSD-src-2fc66c2d94f99e157344d3a48c19192a99de5c43.tar.gz |
Use realpath on the source as well as the destination.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/mount_null/mount_null.c | 10 | ||||
-rw-r--r-- | sbin/mount_nullfs/mount_nullfs.c | 10 |
2 files changed, 14 insertions, 6 deletions
diff --git a/sbin/mount_null/mount_null.c b/sbin/mount_null/mount_null.c index 6c447ec..4e7f4c3 100644 --- a/sbin/mount_null/mount_null.c +++ b/sbin/mount_null/mount_null.c @@ -45,7 +45,7 @@ char copyright[] = static char sccsid[] = "@(#)mount_null.c 8.6 (Berkeley) 4/26/95"; */ 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 */ #include <sys/param.h> @@ -76,6 +76,7 @@ main(argc, argv) { struct null_args args; int ch, mntflags; + char source[MAXPATHLEN]; char target[MAXPATHLEN]; struct vfsconf vfc; int error; @@ -99,7 +100,10 @@ main(argc, argv) if (realpath(argv[0], target) == 0) 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", argv[0], target, argv[1]); @@ -115,7 +119,7 @@ main(argc, argv) if (error) 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); exit(0); } diff --git a/sbin/mount_nullfs/mount_nullfs.c b/sbin/mount_nullfs/mount_nullfs.c index 6c447ec..4e7f4c3 100644 --- a/sbin/mount_nullfs/mount_nullfs.c +++ b/sbin/mount_nullfs/mount_nullfs.c @@ -45,7 +45,7 @@ char copyright[] = static char sccsid[] = "@(#)mount_null.c 8.6 (Berkeley) 4/26/95"; */ 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 */ #include <sys/param.h> @@ -76,6 +76,7 @@ main(argc, argv) { struct null_args args; int ch, mntflags; + char source[MAXPATHLEN]; char target[MAXPATHLEN]; struct vfsconf vfc; int error; @@ -99,7 +100,10 @@ main(argc, argv) if (realpath(argv[0], target) == 0) 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", argv[0], target, argv[1]); @@ -115,7 +119,7 @@ main(argc, argv) if (error) 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); exit(0); } |