1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-27 08:00:11 +00:00

mount* fixes from Martin Blapp <mb@imp.ch>:

Made mount more userfriendly (bad slashes are now filtered out)
        and we remove in mount_nfs trailing slashes if there are any.

        Fixed mount_xxx binarys to resolve with realpath(3)
        the mountpoint.

        Translate the deprecated nfs-syntax with '@' to ':' .
        The ':' syntax has now precedence, but '@' still works.
        Notify the user that the '@' syntax should not be used.

PR: 7846
PR: 13692
Submitted by:   Martin Blapp <mb@imp.ch>
Reviewed by:    phk
This commit is contained in:
Poul-Henning Kamp 1999-10-09 11:54:14 +00:00
parent 1d64c295bb
commit 73dd316734
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=52055
23 changed files with 231 additions and 126 deletions

View File

@ -87,7 +87,7 @@ main(argc, argv)
struct msdosfs_args args;
struct stat sb;
int c, error, mntflags, set_gid, set_uid, set_mask;
char *dev, *dir, ndir[MAXPATHLEN+1];
char *dev, *dir, mntpath[MAXPATHLEN];
struct vfsconf vfc;
mntflags = set_gid = set_uid = set_mask = 0;
@ -145,15 +145,13 @@ main(argc, argv)
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");
strncat(ndir, "/", sizeof(ndir) - strlen(ndir) - 1);
strncat(ndir, dir, sizeof(ndir) - strlen(ndir) - 1);
dir = ndir;
warnx("using \"%s\" instead", dir);
}
/*
* Resolve the mountpoint with realpath(3) and remove unnecessary
* slashes from the devicename if there are any.
*/
(void)checkpath(dir, mntpath);
(void)rmslashes(dev, dev);
args.fspec = dev;
args.export.ex_root = -2; /* unchecked anyway on DOS fs */
@ -162,8 +160,8 @@ main(argc, argv)
else
args.export.ex_flags = 0;
if (!set_gid || !set_uid || !set_mask) {
if (stat(dir, &sb) == -1)
err(EX_OSERR, "stat %s", dir);
if (stat(mntpath, &sb) == -1)
err(EX_OSERR, "stat %s", mntpath);
if (!set_uid)
args.uid = sb.st_uid;
@ -183,7 +181,7 @@ main(argc, argv)
if (error)
errx(EX_OSERR, "msdos filesystem is not available");
if (mount(vfc.vfc_name, dir, mntflags, &args) < 0)
if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
err(EX_OSERR, "%s", dev);
exit (0);

View File

@ -41,10 +41,13 @@ static const char rcsid[] =
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <err.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include "mntopts.h"
@ -106,3 +109,39 @@ getmntopts(options, m0, flagp, altflagp)
free(optbuf);
}
void
rmslashes(rrpin, rrpout)
char *rrpin;
char *rrpout;
{
char *rrpoutstart;
*rrpout = *rrpin;
for (rrpoutstart = rrpout; *rrpin != '\0'; *rrpout++ = *rrpin++) {
/* skip all double slashes */
while (*rrpin == '/' && *(rrpin + 1) == '/')
rrpin++;
}
/* remove trailing slash if necessary */
if (rrpout - rrpoutstart > 1 && *(rrpout - 1) == '/')
*(rrpout - 1) = '\0';
else
*rrpout = '\0';
}
void
checkpath(path, resolved)
const char *path;
char *resolved;
{
struct stat sb;
if (realpath(path, resolved) != NULL && stat(resolved, &sb) == 0) {
if (!S_ISDIR(sb.st_mode))
errx(EX_USAGE, "%s: not a directory", resolved);
} else
errx(EX_USAGE, "%s: %s", resolved, strerror(errno));
}

View File

@ -88,4 +88,6 @@ struct mntopt {
MOPT_NOCLUSTERW
void getmntopts __P((const char *, const struct mntopt *, int *, int *));
void rmslashes __P((char *, char *));
void checkpath __P((const char *, char resolved_path[]));
extern int getmnt_silent;

View File

@ -61,6 +61,7 @@ static const char rcsid[] =
#include <unistd.h>
#include "extern.h"
#include "mntopts.h"
#include "pathnames.h"
/* `meta' options */
@ -354,7 +355,6 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
NULL
};
const char *argv[100], **edir;
struct stat sb;
struct statfs sf;
pid_t pid;
int argc, i, status;
@ -365,16 +365,8 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
(void)&name;
#endif
if (realpath(name, mntpath) != NULL && stat(mntpath, &sb) == 0) {
if (!S_ISDIR(sb.st_mode)) {
warnx("%s: not a directory", mntpath);
return (1);
}
} else {
warn("%s", mntpath);
return (1);
}
/* resolve the mountpoint with realpath(3) */
(void)checkpath(name, mntpath);
name = mntpath;
if (mntopts == NULL)

View File

@ -85,7 +85,7 @@ main(int argc, char **argv)
{
struct iso_args args;
int ch, mntflags, opts;
char *dev, *dir;
char *dev, *dir, mntpath[MAXPATHLEN];
struct vfsconf vfc;
int error, verbose;
@ -128,6 +128,13 @@ main(int argc, char **argv)
dev = argv[0];
dir = argv[1];
/*
* Resolve the mountpoint with realpath(3) and remove unnecessary
* slashes from the devicename if there are any.
*/
(void)checkpath(dir, mntpath);
(void)rmslashes(dev, dev);
#define DEFAULT_ROOTUID -2
/*
* ISO 9660 filesystems are not writeable.
@ -168,7 +175,7 @@ main(int argc, char **argv)
if (error)
errx(1, "cd9660 filesystem is not available");
if (mount(vfc.vfc_name, dir, mntflags, &args) < 0)
if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
err(1, NULL);
exit(0);
}

View File

@ -76,7 +76,7 @@ main(argc, argv)
{
struct ufs_args args;
int ch, mntflags;
char *fs_name, *options;
char *fs_name, *options, mntpath[MAXPATHLEN];
struct vfsconf vfc;
int error;
@ -100,6 +100,13 @@ main(argc, argv)
args.fspec = argv[0]; /* the name of the device file */
fs_name = argv[1]; /* the mount point */
/*
* Resolve the mountpoint with realpath(3) and remove unnecessary
* slashes from the devicename if there are any.
*/
(void)checkpath(fs_name, mntpath);
(void)rmslashes(args.fspec, args.fspec);
#define DEFAULT_ROOTUID -2
args.export.ex_root = DEFAULT_ROOTUID;
if (mntflags & MNT_RDONLY)
@ -118,7 +125,7 @@ main(argc, argv)
if (error)
errx(EX_OSERR, "ext2fs filesystem is not available");
if (mount(vfc.vfc_name, fs_name, mntflags, &args) < 0)
if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
err(EX_OSERR, "%s", args.fspec);
exit(0);
}

View File

@ -41,10 +41,13 @@ static const char rcsid[] =
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <err.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include "mntopts.h"
@ -106,3 +109,39 @@ getmntopts(options, m0, flagp, altflagp)
free(optbuf);
}
void
rmslashes(rrpin, rrpout)
char *rrpin;
char *rrpout;
{
char *rrpoutstart;
*rrpout = *rrpin;
for (rrpoutstart = rrpout; *rrpin != '\0'; *rrpout++ = *rrpin++) {
/* skip all double slashes */
while (*rrpin == '/' && *(rrpin + 1) == '/')
rrpin++;
}
/* remove trailing slash if necessary */
if (rrpout - rrpoutstart > 1 && *(rrpout - 1) == '/')
*(rrpout - 1) = '\0';
else
*rrpout = '\0';
}
void
checkpath(path, resolved)
const char *path;
char *resolved;
{
struct stat sb;
if (realpath(path, resolved) != NULL && stat(resolved, &sb) == 0) {
if (!S_ISDIR(sb.st_mode))
errx(EX_USAGE, "%s: not a directory", resolved);
} else
errx(EX_USAGE, "%s: %s", resolved, strerror(errno));
}

View File

@ -88,4 +88,6 @@ struct mntopt {
MOPT_NOCLUSTERW
void getmntopts __P((const char *, const struct mntopt *, int *, int *));
void rmslashes __P((char *, char *));
void checkpath __P((const char *, char resolved_path[]));
extern int getmnt_silent;

View File

@ -61,6 +61,7 @@ static const char rcsid[] =
#include <unistd.h>
#include "extern.h"
#include "mntopts.h"
#include "pathnames.h"
/* `meta' options */
@ -354,7 +355,6 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
NULL
};
const char *argv[100], **edir;
struct stat sb;
struct statfs sf;
pid_t pid;
int argc, i, status;
@ -365,16 +365,8 @@ mountfs(vfstype, spec, name, flags, options, mntopts)
(void)&name;
#endif
if (realpath(name, mntpath) != NULL && stat(mntpath, &sb) == 0) {
if (!S_ISDIR(sb.st_mode)) {
warnx("%s: not a directory", mntpath);
return (1);
}
} else {
warn("%s", mntpath);
return (1);
}
/* resolve the mountpoint with realpath(3) */
(void)checkpath(name, mntpath);
name = mntpath;
if (mntopts == NULL)

View File

@ -87,7 +87,7 @@ main(argc, argv)
struct msdosfs_args args;
struct stat sb;
int c, error, mntflags, set_gid, set_uid, set_mask;
char *dev, *dir, ndir[MAXPATHLEN+1];
char *dev, *dir, mntpath[MAXPATHLEN];
struct vfsconf vfc;
mntflags = set_gid = set_uid = set_mask = 0;
@ -145,15 +145,13 @@ main(argc, argv)
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");
strncat(ndir, "/", sizeof(ndir) - strlen(ndir) - 1);
strncat(ndir, dir, sizeof(ndir) - strlen(ndir) - 1);
dir = ndir;
warnx("using \"%s\" instead", dir);
}
/*
* Resolve the mountpoint with realpath(3) and remove unnecessary
* slashes from the devicename if there are any.
*/
(void)checkpath(dir, mntpath);
(void)rmslashes(dev, dev);
args.fspec = dev;
args.export.ex_root = -2; /* unchecked anyway on DOS fs */
@ -162,8 +160,8 @@ main(argc, argv)
else
args.export.ex_flags = 0;
if (!set_gid || !set_uid || !set_mask) {
if (stat(dir, &sb) == -1)
err(EX_OSERR, "stat %s", dir);
if (stat(mntpath, &sb) == -1)
err(EX_OSERR, "stat %s", mntpath);
if (!set_uid)
args.uid = sb.st_uid;
@ -183,7 +181,7 @@ main(argc, argv)
if (error)
errx(EX_OSERR, "msdos filesystem is not available");
if (mount(vfc.vfc_name, dir, mntflags, &args) < 0)
if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
err(EX_OSERR, "%s", dev);
exit (0);

View File

@ -87,7 +87,7 @@ main(argc, argv)
struct msdosfs_args args;
struct stat sb;
int c, error, mntflags, set_gid, set_uid, set_mask;
char *dev, *dir, ndir[MAXPATHLEN+1];
char *dev, *dir, mntpath[MAXPATHLEN];
struct vfsconf vfc;
mntflags = set_gid = set_uid = set_mask = 0;
@ -145,15 +145,13 @@ main(argc, argv)
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");
strncat(ndir, "/", sizeof(ndir) - strlen(ndir) - 1);
strncat(ndir, dir, sizeof(ndir) - strlen(ndir) - 1);
dir = ndir;
warnx("using \"%s\" instead", dir);
}
/*
* Resolve the mountpoint with realpath(3) and remove unnecessary
* slashes from the devicename if there are any.
*/
(void)checkpath(dir, mntpath);
(void)rmslashes(dev, dev);
args.fspec = dev;
args.export.ex_root = -2; /* unchecked anyway on DOS fs */
@ -162,8 +160,8 @@ main(argc, argv)
else
args.export.ex_flags = 0;
if (!set_gid || !set_uid || !set_mask) {
if (stat(dir, &sb) == -1)
err(EX_OSERR, "stat %s", dir);
if (stat(mntpath, &sb) == -1)
err(EX_OSERR, "stat %s", mntpath);
if (!set_uid)
args.uid = sb.st_uid;
@ -183,7 +181,7 @@ main(argc, argv)
if (error)
errx(EX_OSERR, "msdos filesystem is not available");
if (mount(vfc.vfc_name, dir, mntflags, &args) < 0)
if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
err(EX_OSERR, "%s", dev);
exit (0);

View File

@ -256,6 +256,7 @@ main(argc, argv)
struct nfsd_cargs ncd;
int mntflags, altflags, i, nfssvc_flag, num;
char *name, *p, *spec;
char mntpath[MAXPATHLEN];
struct vfsconf vfc;
int error = 0;
#ifdef NFSKERB
@ -470,6 +471,9 @@ main(argc, argv)
if (!getnfsargs(spec, nfsargsp))
exit(1);
/* resolve the mountpoint with realpath(3) */
(void)checkpath(name, mntpath);
#ifdef __FreeBSD__
error = getvfsbyname("nfs", &vfc);
if (error && vfsisloadable("nfs")) {
@ -481,11 +485,11 @@ main(argc, argv)
if (error)
errx(EX_OSERR, "nfs filesystem is not available");
if (mount(vfc.vfc_name, name, mntflags, nfsargsp))
err(1, "%s", name);
if (mount(vfc.vfc_name, mntpath, mntflags, nfsargsp))
err(1, "%s", mntpath);
#else
if (mount("nfs", name, mntflags, nfsargsp))
err(1, "%s", name);
if (mount("nfs", mntpath, mntflags, nfsargsp))
err(1, "%s", mntpath);
#endif
if (nfsargsp->flags & (NFSMNT_NQNFS | NFSMNT_KERB)) {
if ((opflags & ISBGRND) == 0) {
@ -502,7 +506,7 @@ main(argc, argv)
}
openlog("mount_nfs:", LOG_PID, LOG_DAEMON);
nfssvc_flag = NFSSVC_MNTD;
ncd.ncd_dirp = name;
ncd.ncd_dirp = mntpath;
while (nfssvc(nfssvc_flag, (caddr_t)&ncd) < 0) {
if (errno != ENEEDAUTH) {
syslog(LOG_ERR, "nfssvc err %m");
@ -652,27 +656,50 @@ getnfsargs(spec, nfsargsp)
#endif
struct timeval pertry, try;
enum clnt_stat clnt_stat;
int so = RPC_ANYSOCK, i, nfsvers, mntvers, orgcnt;
int so = RPC_ANYSOCK, i, nfsvers, mntvers, orgcnt, speclen;
char *hostp, *delimp;
#ifdef NFSKERB
char *cp;
#endif
u_short tport = 0;
u_short tport;
static struct nfhret nfhret;
static char nam[MNAMELEN + 1];
strncpy(nam, spec, MNAMELEN);
nam[MNAMELEN] = '\0';
if ((delimp = strchr(spec, '@')) != NULL) {
hostp = delimp + 1;
} else if ((delimp = strchr(spec, ':')) != NULL) {
tport = 0;
if ((delimp = strchr(spec, ':')) != NULL) {
hostp = spec;
spec = delimp + 1;
} else if ((delimp = strrchr(spec, '@')) != NULL) {
warnx("path@server syntax is deprecated, use server:path");
hostp = delimp + 1;
} else {
warnx("no <host>:<dirpath> or <dirpath>@<host> spec");
warnx("no <host>:<dirpath> nfs-name");
return (0);
}
*delimp = '\0';
/*
* If there has been a trailing slash at mounttime it seems
* that some mountd implementations fail to remove the mount
* entries from their mountlist while unmounting.
*/
speclen = strlen(spec);
while (speclen > 1 && spec[speclen - 1] == '/') {
spec[speclen - 1] = '\0';
speclen--;
}
if (strlen(hostp) + strlen(spec) + 1 > MNAMELEN) {
warnx("%s:%s: %s", hostp, spec, strerror(ENAMETOOLONG));
return (0);
}
/* Make both '@' and ':' notations equal */
strcat(nam, hostp);
strcat(nam, ":");
strcat(nam, spec);
/*
* DUMB!! Until the mount protocol works on iso transport, we must
* supply both an iso and an inet address for the host.

View File

@ -67,8 +67,8 @@ main(argc, argv)
{
struct ntfs_args args;
struct stat sb;
int c, mntflags, set_gid, set_uid, set_mask,error;
char *dev, *dir, ndir[MAXPATHLEN+1];
int c, mntflags, set_gid, set_uid, set_mask, error;
char *dev, *dir, ndir[MAXPATHLEN+1], mntpath[MAXPATHLEN];
#if __FreeBSD_version >= 300000
struct vfsconf vfc;
#else
@ -113,15 +113,13 @@ main(argc, argv)
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");
strncat(ndir, "/", sizeof(ndir) - strlen(ndir) - 1);
strncat(ndir, dir, sizeof(ndir) - strlen(ndir) - 1);
dir = ndir;
warnx("using \"%s\" instead", dir);
}
/*
* Resolve the mountpoint with realpath(3) and remove unnecessary
* slashes from the devicename if there are any.
*/
(void)checkpath(dir, mntpath);
(void)rmslashes(dev, dev);
args.fspec = dev;
args.export.ex_root = 65534; /* unchecked anyway on DOS fs */
@ -130,8 +128,8 @@ main(argc, argv)
else
args.export.ex_flags = 0;
if (!set_gid || !set_uid || !set_mask) {
if (stat(dir, &sb) == -1)
err(EX_OSERR, "stat %s", dir);
if (stat(mntpath, &sb) == -1)
err(EX_OSERR, "stat %s", mntpath);
if (!set_uid)
args.uid = sb.st_uid;
@ -166,9 +164,9 @@ main(argc, argv)
errx(EX_OSERR, "ntfs filesystem is not available");
#if __FreeBSD_version >= 300000
if (mount(vfc.vfc_name, dir, mntflags, &args) < 0)
if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
#else
if (mount(vfc->vfc_index, dir, mntflags, &args) < 0)
if (mount(vfc->vfc_index, mntpath, mntflags, &args) < 0)
#endif
err(EX_OSERR, "%s", dev);

View File

@ -97,11 +97,9 @@ main(argc, argv)
if (argc != 2)
usage();
if (realpath(argv[0], target) == 0)
err(EX_OSERR, "%s", target);
if (realpath(argv[1], source) == 0)
err(EX_OSERR, "%s", source);
/* resolve target and source with realpath(3) */
(void)checkpath(argv[0], target);
(void)checkpath(argv[1], source);
if (subdir(target, source) || subdir(source, target))
errx(EX_USAGE, "%s (%s) and %s are not distinct paths",

View File

@ -97,11 +97,9 @@ main(argc, argv)
if (argc != 2)
usage();
if (realpath(argv[0], target) == 0)
err(EX_OSERR, "%s", target);
if (realpath(argv[1], source) == 0)
err(EX_OSERR, "%s", source);
/* resolve target and source with realpath(3) */
(void)checkpath(argv[0], target);
(void)checkpath(argv[1], source);
if (subdir(target, source) || subdir(source, target))
errx(EX_USAGE, "%s (%s) and %s are not distinct paths",

View File

@ -105,7 +105,7 @@ main(argc, argv)
struct portal_args args;
struct sockaddr_un un;
char *conf;
char *mountpt;
char mountpt[MAXPATHLEN];
int mntflags = 0;
char tag[32];
struct vfsconf vfc;
@ -142,7 +142,9 @@ main(argc, argv)
* Get config file and mount point
*/
conf = argv[optind];
mountpt = argv[optind+1];
/* resolve the mountpoint with realpath(3) */
(void)checkpath(argv[optind+1], mountpt);
/*
* Construct the listening socket

View File

@ -105,7 +105,7 @@ main(argc, argv)
struct portal_args args;
struct sockaddr_un un;
char *conf;
char *mountpt;
char mountpt[MAXPATHLEN];
int mntflags = 0;
char tag[32];
struct vfsconf vfc;
@ -142,7 +142,9 @@ main(argc, argv)
* Get config file and mount point
*/
conf = argv[optind];
mountpt = argv[optind+1];
/* resolve the mountpoint with realpath(3) */
(void)checkpath(argv[optind+1], mountpt);
/*
* Construct the listening socket

View File

@ -71,6 +71,7 @@ main(argc, argv)
char *argv[];
{
int ch, mntflags;
char mntpath[MAXPATHLEN];
struct vfsconf vfc;
int error;
@ -116,7 +117,10 @@ main(argc, argv)
if (error)
errx(EX_OSERR, "%s filesystem not available", fsname);
if (mount(vfc.vfc_name, argv[1], mntflags, NULL))
/* resolve the mountpoint with realpath(3) */
(void)checkpath(argv[1], mntpath);
if (mount(vfc.vfc_name, mntpath, mntflags, NULL))
err(EX_OSERR, NULL);
exit(0);
}

View File

@ -98,7 +98,8 @@ main(argc, argv)
FILE *fp, *gfp;
u_long gmapdata[GMAPFILEENTRIES][2], mapdata[MAPFILEENTRIES][2];
int ch, count, gnentries, mntflags, nentries;
char *gmapfile, *mapfile, *source, *target, buf[20];
char *gmapfile, *mapfile, buf[20];
char source[MAXPATHLEN], target[MAXPATHLEN];
struct vfsconf vfc;
int error;
@ -125,8 +126,9 @@ main(argc, argv)
if (argc != 2 || mapfile == NULL || gmapfile == NULL)
usage();
source = argv[0];
target = argv[1];
/* resolve both target and source with realpath(3) */
(void)checkpath(argv[0], source);
(void)checkpath(argv[1], target);
/* Read in uid mapping data. */
if ((fp = fopen(mapfile, "r")) == NULL)

View File

@ -98,7 +98,8 @@ main(argc, argv)
FILE *fp, *gfp;
u_long gmapdata[GMAPFILEENTRIES][2], mapdata[MAPFILEENTRIES][2];
int ch, count, gnentries, mntflags, nentries;
char *gmapfile, *mapfile, *source, *target, buf[20];
char *gmapfile, *mapfile, buf[20];
char source[MAXPATHLEN], target[MAXPATHLEN];
struct vfsconf vfc;
int error;
@ -125,8 +126,9 @@ main(argc, argv)
if (argc != 2 || mapfile == NULL || gmapfile == NULL)
usage();
source = argv[0];
target = argv[1];
/* resolve both target and source with realpath(3) */
(void)checkpath(argv[0], source);
(void)checkpath(argv[1], target);
/* Read in uid mapping data. */
if ((fp = fopen(mapfile, "r")) == NULL)

View File

@ -109,11 +109,9 @@ main(argc, argv)
if (argc != 2)
usage();
if (realpath(argv[0], target) == 0)
err(EX_OSERR, "%s", target);
if (realpath(argv[1], source) == 0)
err(EX_OSERR, "%s", source);
/* resolve both target and source with realpath(3) */
(void)checkpath(argv[0], target);
(void)checkpath(argv[1], source);
if (subdir(target, source) || subdir(source, target))
errx(EX_USAGE, "%s (%s) and %s (%s) are not distinct paths",

View File

@ -109,11 +109,9 @@ main(argc, argv)
if (argc != 2)
usage();
if (realpath(argv[0], target) == 0)
err(EX_OSERR, "%s", target);
if (realpath(argv[1], source) == 0)
err(EX_OSERR, "%s", source);
/* resolve both target and source with realpath(3) */
(void)checkpath(argv[0], target);
(void)checkpath(argv[1], source);
if (subdir(target, source) || subdir(source, target))
errx(EX_USAGE, "%s (%s) and %s (%s) are not distinct paths",

View File

@ -105,7 +105,7 @@ main(argc, argv)
struct portal_args args;
struct sockaddr_un un;
char *conf;
char *mountpt;
char mountpt[MAXPATHLEN];
int mntflags = 0;
char tag[32];
struct vfsconf vfc;
@ -142,7 +142,9 @@ main(argc, argv)
* Get config file and mount point
*/
conf = argv[optind];
mountpt = argv[optind+1];
/* resolve the mountpoint with realpath(3) */
(void)checkpath(argv[optind+1], mountpt);
/*
* Construct the listening socket