summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2003-07-03 22:41:41 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2003-07-03 22:41:41 +0000
commit68c4ff61328d01e604a97f41a255784b3ba007b2 (patch)
tree7424873456d7982920c124a4f0a56cb7140ca8c8 /sbin
parentf231113e2426ef83d1f4662298c597f2d2719ed5 (diff)
use realpath() in helpers instead of doing it ourselves every time.
also fixes pr1662. from otto moerbeek
Diffstat (limited to 'sbin')
-rw-r--r--sbin/mount_ados/mount_ados.c18
-rw-r--r--sbin/mount_cd9660/mount_cd9660.c9
-rw-r--r--sbin/mount_ext2fs/mount_ext2fs.c9
-rw-r--r--sbin/mount_fdesc/mount_fdesc.c10
-rw-r--r--sbin/mount_ffs/mount_ffs.c9
-rw-r--r--sbin/mount_kernfs/mount_kernfs.c10
-rw-r--r--sbin/mount_lfs/mount_lfs.c9
-rw-r--r--sbin/mount_msdos/mount_msdos.c18
-rw-r--r--sbin/mount_nfs/mount_nfs.c7
-rw-r--r--sbin/mount_ntfs/mount_ntfs.c16
-rw-r--r--sbin/mount_null/mount_null.c6
-rw-r--r--sbin/mount_portal/mount_portal.c9
-rw-r--r--sbin/mount_procfs/mount_procfs.c10
-rw-r--r--sbin/mount_umap/mount_umap.c11
-rw-r--r--sbin/mount_union/mount_union.c6
-rw-r--r--sbin/mount_xfs/mount_xfs.c8
16 files changed, 82 insertions, 83 deletions
diff --git a/sbin/mount_ados/mount_ados.c b/sbin/mount_ados/mount_ados.c
index be8da3859e8..188fd57a55e 100644
--- a/sbin/mount_ados/mount_ados.c
+++ b/sbin/mount_ados/mount_ados.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_ados.c,v 1.11 2003/07/02 22:38:53 avsm Exp $ */
+/* $OpenBSD: mount_ados.c,v 1.12 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_ados.c,v 1.5 1996/04/13 01:30:59 jtc Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: mount_ados.c,v 1.11 2003/07/02 22:38:53 avsm Exp $";
+static char rcsid[] = "$OpenBSD: mount_ados.c,v 1.12 2003/07/03 22:41:40 tedu Exp $";
#endif /* not lint */
#include <sys/cdefs.h>
@@ -67,7 +67,7 @@ main(int argc, char *argv[])
struct adosfs_args args;
struct stat sb;
int c, mntflags, set_gid, set_uid, set_mask;
- char *dev, *dir, ndir[MAXPATHLEN+1];
+ char *dev, dir[MAXPATHLEN];
mntflags = set_gid = set_uid = set_mask = 0;
(void)memset(&args, '\0', sizeof(args));
@@ -100,16 +100,8 @@ main(int argc, char *argv[])
usage();
dev = argv[optind];
- dir = argv[optind + 1];
- if (dir[0] != '/') {
- warnx("\"%s\" is a relative path.", dir);
- if (getcwd(ndir, sizeof(ndir)) == NULL)
- err(1, "getcwd");
- strlcat(ndir, "/", sizeof(ndir));
- strlcat(ndir, dir, sizeof(ndir));
- dir = ndir;
- warnx("using \"%s\" instead.", dir);
- }
+ if (realpath(argv[optind + 1], dir) == NULL)
+ err(1, "realpath %s", dir);
args.fspec = dev;
args.export_info.ex_root = -2; /* unchecked anyway on DOS fs */
diff --git a/sbin/mount_cd9660/mount_cd9660.c b/sbin/mount_cd9660/mount_cd9660.c
index ffc0778bca5..e2ee9a086d2 100644
--- a/sbin/mount_cd9660/mount_cd9660.c
+++ b/sbin/mount_cd9660/mount_cd9660.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_cd9660.c,v 1.15 2003/06/11 06:22:13 deraadt Exp $ */
+/* $OpenBSD: mount_cd9660.c,v 1.16 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_cd9660.c,v 1.3 1996/04/13 01:31:08 jtc Exp $ */
/*
@@ -45,7 +45,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_cd9660.c 8.4 (Berkeley) 3/27/94";
#else
-static char rcsid[] = "$OpenBSD: mount_cd9660.c,v 1.15 2003/06/11 06:22:13 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mount_cd9660.c,v 1.16 2003/07/03 22:41:40 tedu Exp $";
#endif
#endif /* not lint */
@@ -75,7 +75,7 @@ main(int argc, char *argv[])
{
struct iso_args args;
int ch, mntflags, opts;
- char *dev, *dir;
+ char *dev, dir[MAXPATHLEN];
mntflags = opts = 0;
while ((ch = getopt(argc, argv, "egjo:R")) != -1)
@@ -106,7 +106,8 @@ main(int argc, char *argv[])
usage();
dev = argv[0];
- dir = argv[1];
+ if (realpath(argv[1], dir) == NULL)
+ err(1, "realpath %s", dir);
#define DEFAULT_ROOTUID -2
args.fspec = dev;
diff --git a/sbin/mount_ext2fs/mount_ext2fs.c b/sbin/mount_ext2fs/mount_ext2fs.c
index d0d981c95f8..e4e179ecaf1 100644
--- a/sbin/mount_ext2fs/mount_ext2fs.c
+++ b/sbin/mount_ext2fs/mount_ext2fs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_ext2fs.c,v 1.11 2003/06/11 06:22:13 deraadt Exp $ */
+/* $OpenBSD: mount_ext2fs.c,v 1.12 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_ffs.c,v 1.3 1996/04/13 01:31:19 jtc Exp $ */
/*-
@@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_ufs.c 8.2 (Berkeley) 3/27/94";
#else
-static char rcsid[] = "$OpenBSD: mount_ext2fs.c,v 1.11 2003/06/11 06:22:13 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mount_ext2fs.c,v 1.12 2003/07/03 22:41:40 tedu Exp $";
#endif
#endif /* not lint */
@@ -69,7 +69,7 @@ main(int argc, char *argv[])
{
struct ufs_args args; /* XXX ffs_args */
int ch, mntflags;
- char *fs_name, *errcause;
+ char fs_name[MAXPATHLEN], *errcause;
mntflags = 0;
optind = optreset = 1; /* Reset for parse of new argv. */
@@ -89,7 +89,8 @@ main(int argc, char *argv[])
ext2fs_usage();
args.fspec = argv[0]; /* The name of the device file. */
- fs_name = argv[1]; /* The mount point. */
+ if (realpath(argv[1], fs_name) == NULL) /* The mount point. */
+ err(1, "realpath %s", fs_name);
#define DEFAULT_ROOTUID -2
args.export_info.ex_root = DEFAULT_ROOTUID;
diff --git a/sbin/mount_fdesc/mount_fdesc.c b/sbin/mount_fdesc/mount_fdesc.c
index ad9173d8a9d..364ff938bdd 100644
--- a/sbin/mount_fdesc/mount_fdesc.c
+++ b/sbin/mount_fdesc/mount_fdesc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_fdesc.c,v 1.9 2003/06/11 06:22:13 deraadt Exp $ */
+/* $OpenBSD: mount_fdesc.c,v 1.10 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_fdesc.c,v 1.7 1996/04/13 01:31:15 jtc Exp $ */
/*
@@ -44,7 +44,7 @@ char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_fdesc.c 8.2 (Berkeley) 3/27/94";
#else
-static char rcsid[] = "$OpenBSD: mount_fdesc.c,v 1.9 2003/06/11 06:22:13 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mount_fdesc.c,v 1.10 2003/07/03 22:41:40 tedu Exp $";
#endif
#endif /* not lint */
@@ -71,6 +71,7 @@ int
main(int argc, char *argv[])
{
int ch, mntflags;
+ char path[MAXPATHLEN];
mntflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1)
@@ -88,7 +89,10 @@ main(int argc, char *argv[])
if (argc != 2)
usage();
- if (mount(MOUNT_FDESC, argv[1], mntflags, NULL)) {
+ if (realpath(argv[1], path) == NULL)
+ err(1, "realpath %s", path);
+
+ if (mount(MOUNT_FDESC, path, mntflags, NULL)) {
if (errno == EOPNOTSUPP)
errx(1, "%s: Filesystem not supported by kernel",
argv[1]);
diff --git a/sbin/mount_ffs/mount_ffs.c b/sbin/mount_ffs/mount_ffs.c
index 4e390cb4853..a40fb43ad47 100644
--- a/sbin/mount_ffs/mount_ffs.c
+++ b/sbin/mount_ffs/mount_ffs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_ffs.c,v 1.16 2003/06/11 06:22:13 deraadt Exp $ */
+/* $OpenBSD: mount_ffs.c,v 1.17 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_ffs.c,v 1.3 1996/04/13 01:31:19 jtc Exp $ */
/*-
@@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_ufs.c 8.2 (Berkeley) 3/27/94";
#else
-static char rcsid[] = "$OpenBSD: mount_ffs.c,v 1.16 2003/06/11 06:22:13 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mount_ffs.c,v 1.17 2003/07/03 22:41:40 tedu Exp $";
#endif
#endif /* not lint */
@@ -74,7 +74,7 @@ main(int argc, char *argv[])
{
struct ufs_args args; /* XXX ffs_args */
int ch, mntflags;
- char *fs_name, *errcause;
+ char fs_name[MAXPATHLEN], *errcause;
mntflags = 0;
optind = optreset = 1; /* Reset for parse of new argv. */
@@ -94,7 +94,8 @@ main(int argc, char *argv[])
ffs_usage();
args.fspec = argv[0]; /* The name of the device file. */
- fs_name = argv[1]; /* The mount point. */
+ if (realpath(argv[1], fs_name) == NULL) /* The mount point. */
+ err(1, "realpath %s", fs_name);
#define DEFAULT_ROOTUID -2
args.export_info.ex_root = DEFAULT_ROOTUID;
diff --git a/sbin/mount_kernfs/mount_kernfs.c b/sbin/mount_kernfs/mount_kernfs.c
index 8b01c86e8a8..723349c461c 100644
--- a/sbin/mount_kernfs/mount_kernfs.c
+++ b/sbin/mount_kernfs/mount_kernfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_kernfs.c,v 1.10 2003/06/11 06:22:13 deraadt Exp $ */
+/* $OpenBSD: mount_kernfs.c,v 1.11 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_kernfs.c,v 1.8 1996/04/13 05:35:39 cgd Exp $ */
/*
@@ -44,7 +44,7 @@ char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_kernfs.c 8.2 (Berkeley) 3/27/94";
#else
-static char rcsid[] = "$OpenBSD: mount_kernfs.c,v 1.10 2003/06/11 06:22:13 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mount_kernfs.c,v 1.11 2003/07/03 22:41:40 tedu Exp $";
#endif
#endif /* not lint */
@@ -71,6 +71,7 @@ int
main(int argc, char *argv[])
{
int ch, mntflags;
+ char path[MAXPATHLEN];
mntflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1)
@@ -88,7 +89,10 @@ main(int argc, char *argv[])
if (argc != 2)
usage();
- if (mount(MOUNT_KERNFS, argv[1], mntflags, NULL)) {
+ if (realpath(argv[1], path) == NULL)
+ err(1, "realpath %s", path);
+
+ if (mount(MOUNT_KERNFS, path, mntflags, NULL)) {
if (errno == EOPNOTSUPP)
errx(1, "Filesystem not supported by kernel");
else
diff --git a/sbin/mount_lfs/mount_lfs.c b/sbin/mount_lfs/mount_lfs.c
index 61941de59c1..f41bcf43f72 100644
--- a/sbin/mount_lfs/mount_lfs.c
+++ b/sbin/mount_lfs/mount_lfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_lfs.c,v 1.10 2003/06/11 06:22:13 deraadt Exp $ */
+/* $OpenBSD: mount_lfs.c,v 1.11 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_lfs.c,v 1.4 1996/04/13 05:35:44 cgd Exp $ */
/*-
@@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_lfs.c 8.3 (Berkeley) 3/27/94";
#else
-static char rcsid[] = "$OpenBSD: mount_lfs.c,v 1.10 2003/06/11 06:22:13 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mount_lfs.c,v 1.11 2003/07/03 22:41:40 tedu Exp $";
#endif
#endif /* not lint */
@@ -74,7 +74,7 @@ main(int argc, char *argv[])
{
struct ufs_args args;
int ch, mntflags, noclean;
- char *fs_name, *options;
+ char fs_name[MAXPATHLEN], *options;
char *errcause;
options = NULL;
@@ -104,7 +104,8 @@ main(int argc, char *argv[])
usage();
args.fspec = argv[0]; /* the name of the device file */
- fs_name = argv[1]; /* the mount point */
+ if (realpath(argv[1], fs_name) == NULL) /* the mount point */
+ err(1, "realpath %s", fs_name);
#define DEFAULT_ROOTUID -2
args.export_info.ex_root = DEFAULT_ROOTUID;
diff --git a/sbin/mount_msdos/mount_msdos.c b/sbin/mount_msdos/mount_msdos.c
index 13969e8e1c6..29e18c26232 100644
--- a/sbin/mount_msdos/mount_msdos.c
+++ b/sbin/mount_msdos/mount_msdos.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_msdos.c,v 1.17 2003/07/02 22:38:53 avsm Exp $ */
+/* $OpenBSD: mount_msdos.c,v 1.18 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_msdos.c,v 1.16 1996/10/24 00:12:50 cgd Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: mount_msdos.c,v 1.17 2003/07/02 22:38:53 avsm Exp $";
+static char rcsid[] = "$OpenBSD: mount_msdos.c,v 1.18 2003/07/03 22:41:40 tedu Exp $";
#endif /* not lint */
#include <sys/cdefs.h>
@@ -68,7 +68,7 @@ main(int argc, char **argv)
struct msdosfs_args args;
struct stat sb;
int c, mntflags, set_gid, set_uid, set_mask;
- char *dev, *dir, ndir[MAXPATHLEN];
+ char *dev, dir[MAXPATHLEN];
char *errcause;
mntflags = set_gid = set_uid = set_mask = 0;
@@ -117,16 +117,8 @@ main(int argc, char **argv)
usage();
dev = argv[optind];
- dir = argv[optind + 1];
- if (dir[0] != '/') {
- warnx("\"%s\" is a relative path.", dir);
- if (getcwd(ndir, sizeof(ndir)) == NULL)
- err(1, "getcwd");
- strlcat(ndir, "/", sizeof(ndir));
- strlcat(ndir, dir, sizeof(ndir));
- dir = ndir;
- warnx("using \"%s\" instead.", dir);
- }
+ if (realpath(argv[optind + 1], dir) == NULL)
+ err(1, "realpath %s", dir);
args.fspec = dev;
args.export_info.ex_root = -2; /* unchecked anyway on DOS fs */
diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c
index 89b87b2ccdb..4ae18bb626a 100644
--- a/sbin/mount_nfs/mount_nfs.c
+++ b/sbin/mount_nfs/mount_nfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_nfs.c,v 1.32 2003/06/11 06:22:14 deraadt Exp $ */
+/* $OpenBSD: mount_nfs.c,v 1.33 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_nfs.c,v 1.12.4.1 1996/05/25 22:48:05 fvdl Exp $ */
/*
@@ -180,7 +180,7 @@ main(int argc, char *argv[])
struct nfs_args *nfsargsp;
struct nfs_args nfsargs;
int mntflags, altflags, num;
- char *name, *p, *spec;
+ char name[MAXPATHLEN], *p, *spec;
retrycnt = DEF_RETRY;
@@ -368,7 +368,8 @@ main(int argc, char *argv[])
usage();
spec = *argv++;
- name = *argv;
+ if (realpath(*argv, name) == NULL)
+ err(1, "realpath %s", name);
if (!getnfsargs(spec, nfsargsp))
exit(1);
diff --git a/sbin/mount_ntfs/mount_ntfs.c b/sbin/mount_ntfs/mount_ntfs.c
index fa602047ede..d0957ec8caa 100644
--- a/sbin/mount_ntfs/mount_ntfs.c
+++ b/sbin/mount_ntfs/mount_ntfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_ntfs.c,v 1.7 2003/07/02 22:38:54 avsm Exp $ */
+/* $OpenBSD: mount_ntfs.c,v 1.8 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_ntfs.c,v 1.9 2003/05/03 15:37:08 christos Exp $ */
/*
@@ -73,7 +73,7 @@ main(int argc, char *argv[])
struct ntfs_args args;
struct stat sb;
int c, mntflags, set_gid, set_uid, set_mask;
- char *dev, *dir, ndir[MAXPATHLEN];
+ char *dev, dir[MAXPATHLEN];
mntflags = set_gid = set_uid = set_mask = 0;
(void)memset(&args, '\0', sizeof(args));
@@ -112,16 +112,8 @@ main(int argc, char *argv[])
usage();
dev = argv[optind];
- dir = argv[optind + 1];
- if (dir[0] != '/') {
- warnx("\"%s\" is a relative path", dir);
- if (getcwd(ndir, sizeof(ndir)) == NULL)
- err(EX_OSERR, "getcwd");
- strlcat(ndir, "/", sizeof(ndir));
- strlcat(ndir, dir, sizeof(ndir));
- dir = ndir;
- warnx("using \"%s\" instead", dir);
- }
+ if (realpath(argv[optind + 1], dir) == NULL)
+ err(1, "realpath %s", dir);
args.fspec = dev;
args.export_info.ex_root = 65534; /* unchecked anyway on DOS fs */
diff --git a/sbin/mount_null/mount_null.c b/sbin/mount_null/mount_null.c
index 31767a90e74..83668b9060b 100644
--- a/sbin/mount_null/mount_null.c
+++ b/sbin/mount_null/mount_null.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_null.c,v 1.10 2003/06/11 06:22:14 deraadt Exp $ */
+/* $OpenBSD: mount_null.c,v 1.11 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_null.c,v 1.3 1996/04/13 01:31:49 jtc Exp $ */
/*
@@ -43,7 +43,7 @@ char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_null.c 8.5 (Berkeley) 3/27/94";
#else
-static char rcsid[] = "$OpenBSD: mount_null.c,v 1.10 2003/06/11 06:22:14 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mount_null.c,v 1.11 2003/07/03 22:41:40 tedu Exp $";
#endif
#endif /* not lint */
@@ -92,7 +92,7 @@ main(int argc, char *argv[])
usage();
if (realpath(argv[0], target) == 0)
- err(1, "%s", target);
+ err(1, "realpath %s", target);
if (subdir(target, argv[1]) || subdir(argv[1], target))
errx(1, "%s (%s) and %s are not distinct paths",
diff --git a/sbin/mount_portal/mount_portal.c b/sbin/mount_portal/mount_portal.c
index 572b2359f6b..f86cef6095c 100644
--- a/sbin/mount_portal/mount_portal.c
+++ b/sbin/mount_portal/mount_portal.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_portal.c,v 1.24 2003/06/11 06:22:14 deraadt Exp $ */
+/* $OpenBSD: mount_portal.c,v 1.25 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_portal.c,v 1.8 1996/04/13 01:31:54 jtc Exp $ */
/*
@@ -43,7 +43,7 @@ char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_portal.c 8.6 (Berkeley) 4/26/95";
#else
-static char rcsid[] = "$OpenBSD: mount_portal.c,v 1.24 2003/06/11 06:22:14 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mount_portal.c,v 1.25 2003/07/03 22:41:40 tedu Exp $";
#endif
#endif /* not lint */
@@ -73,7 +73,7 @@ const struct mntopt mopts[] = {
extern char *__progname; /* from crt0.o */
-static char *mountpt; /* made available to signal handler */
+static char mountpt[MAXPATHLEN]; /* made available to signal handler */
static void usage(void);
@@ -152,7 +152,8 @@ main(int argc, char *argv[])
* Get config file and mount point
*/
conf = argv[optind];
- mountpt = argv[optind+1];
+ if (realpath(argv[optind+1], mountpt) == NULL)
+ err(1, "realpath %s", mountpt);
/*
* Construct the listening socket
diff --git a/sbin/mount_procfs/mount_procfs.c b/sbin/mount_procfs/mount_procfs.c
index 77f4791aa2d..e36debd92f9 100644
--- a/sbin/mount_procfs/mount_procfs.c
+++ b/sbin/mount_procfs/mount_procfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_procfs.c,v 1.10 2003/06/11 06:22:14 deraadt Exp $ */
+/* $OpenBSD: mount_procfs.c,v 1.11 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_procfs.c,v 1.7 1996/04/13 01:31:59 jtc Exp $ */
/*
@@ -44,7 +44,7 @@ char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_procfs.c 8.3 (Berkeley) 3/27/94";
#else
-static char rcsid[] = "$OpenBSD: mount_procfs.c,v 1.10 2003/06/11 06:22:14 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mount_procfs.c,v 1.11 2003/07/03 22:41:40 tedu Exp $";
#endif
#endif /* not lint */
@@ -75,6 +75,7 @@ main(int argc, char *argv[])
{
int ch, mntflags, altflags;
struct procfs_args args;
+ char path[MAXPATHLEN];
mntflags = altflags = 0;
while ((ch = getopt(argc, argv, "o:")) != -1)
@@ -92,10 +93,13 @@ main(int argc, char *argv[])
if (argc != 2)
usage();
+ if (realpath(argv[1], path) == NULL)
+ err(1, "realpath %s", path);
+
args.version = PROCFS_ARGSVERSION;
args.flags = altflags;
- if (mount(MOUNT_PROCFS, argv[1], mntflags, &args)) {
+ if (mount(MOUNT_PROCFS, path, mntflags, &args)) {
if (errno == EOPNOTSUPP)
errx(1, "%s: Filesystem not supported by kernel",
argv[1]);
diff --git a/sbin/mount_umap/mount_umap.c b/sbin/mount_umap/mount_umap.c
index 9f1020d7181..a14a2cc6de2 100644
--- a/sbin/mount_umap/mount_umap.c
+++ b/sbin/mount_umap/mount_umap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_umap.c,v 1.13 2003/06/11 06:22:14 deraadt Exp $ */
+/* $OpenBSD: mount_umap.c,v 1.14 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_umap.c,v 1.5 1996/04/13 01:32:05 jtc Exp $ */
/*
@@ -43,7 +43,7 @@ char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_umap.c 8.3 (Berkeley) 3/27/94";
#else
-static char rcsid[] = "$OpenBSD: mount_umap.c,v 1.13 2003/06/11 06:22:14 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mount_umap.c,v 1.14 2003/07/03 22:41:40 tedu Exp $";
#endif
#endif /* not lint */
@@ -98,7 +98,7 @@ main(int argc, char *argv[])
u_long umapdata[UMAPFILEENTRIES][2];
u_long gmapdata[GMAPFILEENTRIES][2];
int ch, count, gnentries, mntflags, unentries;
- char *gmapfile, *umapfile, *source, *target, buf[20];
+ char *gmapfile, *umapfile, *source, target[MAXPATHLEN], buf[20];
mntflags = 0;
umapfile = gmapfile = NULL;
@@ -124,7 +124,8 @@ main(int argc, char *argv[])
usage();
source = argv[0];
- target = argv[1];
+ if (realpath(argv[1], target) == NULL)
+ err(1, "realpath %s", target);
/* Read in uid mapping data. */
if ((fp = fopen(umapfile, "r")) == NULL)
@@ -225,7 +226,7 @@ main(int argc, char *argv[])
args.gnentries = gnentries;
args.gmapdata = gmapdata;
- if (mount(MOUNT_UMAP, argv[1], mntflags, &args)) {
+ if (mount(MOUNT_UMAP, target, mntflags, &args)) {
if (errno == EOPNOTSUPP)
errx(1, "%s: Filesystem not supported by kernel",
argv[1]);
diff --git a/sbin/mount_union/mount_union.c b/sbin/mount_union/mount_union.c
index f8a0bd9dfe9..61de03e584c 100644
--- a/sbin/mount_union/mount_union.c
+++ b/sbin/mount_union/mount_union.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_union.c,v 1.9 2003/06/11 06:22:14 deraadt Exp $ */
+/* $OpenBSD: mount_union.c,v 1.10 2003/07/03 22:41:40 tedu Exp $ */
/* $NetBSD: mount_union.c,v 1.3 1996/04/13 01:32:11 jtc Exp $ */
/*
@@ -43,7 +43,7 @@ char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_union.c 8.5 (Berkeley) 3/27/94";
#else
-static char rcsid[] = "$OpenBSD: mount_union.c,v 1.9 2003/06/11 06:22:14 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mount_union.c,v 1.10 2003/07/03 22:41:40 tedu Exp $";
#endif
#endif /* not lint */
@@ -103,7 +103,7 @@ main(int argc, char *argv[])
usage();
if (realpath(argv[0], target) == 0)
- err(1, "%s", target);
+ err(1, "realpath %s", target);
if (subdir(target, argv[1]) || subdir(argv[1], target))
errx(1, "%s (%s) and %s are not distinct paths",
diff --git a/sbin/mount_xfs/mount_xfs.c b/sbin/mount_xfs/mount_xfs.c
index b789f90a65d..f1c17a6a1e0 100644
--- a/sbin/mount_xfs/mount_xfs.c
+++ b/sbin/mount_xfs/mount_xfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_xfs.c,v 1.6 2000/01/22 20:25:02 deraadt Exp $ */
+/* $OpenBSD: mount_xfs.c,v 1.7 2003/07/03 22:41:40 tedu Exp $ */
/*
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
@@ -72,6 +72,7 @@ main(int argc, char **argv)
{
int ch;
int mntflags = 0;
+ char path[MAXPATHLEN];
optind = optreset = 1;
while ((ch = getopt(argc, argv, "o:")) != -1)
@@ -90,7 +91,10 @@ main(int argc, char **argv)
if (argc != 2)
usage();
- if (mount(MOUNT_XFS, argv[1], mntflags, argv[0])) {
+ if (realpath(argv[1], path) == NULL)
+ err(1, "realpath %s", path);
+
+ if (mount(MOUNT_XFS, path, mntflags, argv[0])) {
if (errno == EOPNOTSUPP)
errx(1, "Filesystem not supported by kernel");
else