Refactor remaining mount_* commands to use the common pathadj()

function for resolving paths.

Make pathadj() no longer warn about symlinks. Symlinks in /dev are
regularly used in several places like LVM . The warning was also
only visible when calling a mount_* command directly as mount(8)
itself would resolve the path witout warning before passing it to
a mount_* command.
This commit is contained in:
mlelstv 2020-07-26 08:20:22 +00:00
parent 1b968d3ccf
commit fd33bfb7f2
23 changed files with 118 additions and 164 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pathadj.c,v 1.2 2011/02/17 16:57:46 pooka Exp $ */ /* $NetBSD: pathadj.c,v 1.3 2020/07/26 08:20:22 mlelstv Exp $ */
/* /*
* Copyright (c) 2008 The NetBSD Foundation. All Rights Reserved. * Copyright (c) 2008 The NetBSD Foundation. All Rights Reserved.
@ -37,10 +37,13 @@ void
pathadj(const char *input, char *adjusted) pathadj(const char *input, char *adjusted)
{ {
if (realpath(input, adjusted) == NULL) if (realpath(input, adjusted) == NULL) {
warn("Warning: realpath %s", input); warn("Warning: realpath %s", input);
if (strncmp(input, adjusted, MAXPATHLEN)) { return;
warnx("\"%s\" is a non-resolved or relative path.", input); }
if (input[0] != '/') {
warnx("\"%s\" is a relative path.", input);
warnx("using \"%s\" instead.", adjusted); warnx("using \"%s\" instead.", adjusted);
} }
} }

View File

@ -1,9 +1,9 @@
# $NetBSD: Makefile,v 1.13 2005/06/27 01:00:05 christos Exp $ # $NetBSD: Makefile,v 1.14 2020/07/26 08:20:22 mlelstv Exp $
.include <bsd.own.mk> .include <bsd.own.mk>
PROG= mount_ados PROG= mount_ados
SRCS= mount_ados.c fattr.c SRCS= mount_ados.c fattr.c pathadj.c
MAN= mount_ados.8 MAN= mount_ados.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount MOUNT= ${NETBSDSRCDIR}/sbin/mount

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_ados.c,v 1.29 2011/08/29 14:35:00 joerg Exp $ */ /* $NetBSD: mount_ados.c,v 1.30 2020/07/26 08:20:22 mlelstv Exp $ */
/* /*
* Copyright (c) 1994 Christopher G. Demetriou * Copyright (c) 1994 Christopher G. Demetriou
@ -36,7 +36,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
__RCSID("$NetBSD: mount_ados.c,v 1.29 2011/08/29 14:35:00 joerg Exp $"); __RCSID("$NetBSD: mount_ados.c,v 1.30 2020/07/26 08:20:22 mlelstv Exp $");
#endif /* not lint */ #endif /* not lint */
#include <sys/param.h> #include <sys/param.h>
@ -120,21 +120,11 @@ mount_ados(int argc, char **argv)
dev = argv[optind]; dev = argv[optind];
dir = argv[optind + 1]; dir = argv[optind + 1];
if (realpath(dev, canon_dev) == NULL) /* Check device path */ pathadj(dev, canon_dev);
err(1, "realpath %s", dev); dev = canon_dev;
if (strncmp(dev, canon_dev, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", dev);
dev = canon_dev;
warnx("using \"%s\" instead.", dev);
}
if (realpath(dir, canon_dir) == NULL) /* Check mounton path */ pathadj(dir, canon_dir);
err(1, "realpath %s", dir); dir = canon_dir;
if (strncmp(dir, canon_dir, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", dir);
dir = canon_dir;
warnx("using \"%s\" instead.", dir);
}
args.fspec = dev; args.fspec = dev;
if (!set_gid || !set_uid || !set_mask) { if (!set_gid || !set_uid || !set_mask) {

View File

@ -1,12 +1,16 @@
# $NetBSD: Makefile,v 1.2 2018/01/22 09:45:32 kamil Exp $ # $NetBSD: Makefile,v 1.3 2020/07/26 08:20:22 mlelstv Exp $
# @(#)Makefile 8.2 (Berkeley) 3/27/94 # @(#)Makefile 8.2 (Berkeley) 3/27/94
.include <bsd.own.mk> .include <bsd.own.mk>
PROG= mount_autofs PROG= mount_autofs
SRCS= mount_autofs.c SRCS= mount_autofs.c pathadj.c
MAN= mount_autofs.8 MAN= mount_autofs.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS+= -I${NETBSDSRCDIR}/sys -I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL} DPADD+=${LIBUTIL}
LDADD+=-lutil LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_autofs.c,v 1.4 2019/11/20 17:18:35 tkusumi Exp $ */ /* $NetBSD: mount_autofs.c,v 1.5 2020/07/26 08:20:22 mlelstv Exp $ */
/*- /*-
* Copyright (c) 2018 The NetBSD Foundation, Inc. * Copyright (c) 2018 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
__RCSID("$NetBSD: mount_autofs.c,v 1.4 2019/11/20 17:18:35 tkusumi Exp $"); __RCSID("$NetBSD: mount_autofs.c,v 1.5 2020/07/26 08:20:22 mlelstv Exp $");
#endif /* not lint */ #endif /* not lint */
#include <sys/param.h> #include <sys/param.h>
@ -46,6 +46,7 @@ __RCSID("$NetBSD: mount_autofs.c,v 1.4 2019/11/20 17:18:35 tkusumi Exp $");
#include <fs/autofs/autofs_mount.h> #include <fs/autofs/autofs_mount.h>
#include "mountprog.h"
#include "mount_autofs.h" #include "mount_autofs.h"
static const struct mntopt mopts[] = { static const struct mntopt mopts[] = {
@ -102,12 +103,7 @@ mount_autofs_parseargs(int argc, char *argv[], void *v, int *mntflags,
usage(); usage();
strlcpy(canon_dev, argv[0], MAXPATHLEN); strlcpy(canon_dev, argv[0], MAXPATHLEN);
if (realpath(argv[1], canon_dir) == NULL) /* Check mounton path */ pathadj(argv[1], canon_dir);
err(EXIT_FAILURE, "realpath %s", canon_dir);
if (strncmp(argv[1], canon_dir, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[1]);
warnx("using \"%s\" instead.", canon_dir);
}
} }
int int

View File

@ -1,12 +1,16 @@
# $NetBSD: Makefile,v 1.13 2005/06/27 01:00:05 christos Exp $ # $NetBSD: Makefile,v 1.14 2020/07/26 08:20:22 mlelstv Exp $
# @(#)Makefile 8.2 (Berkeley) 3/27/94 # @(#)Makefile 8.2 (Berkeley) 3/27/94
.include <bsd.own.mk> .include <bsd.own.mk>
PROG= mount_fdesc PROG= mount_fdesc
SRCS= mount_fdesc.c SRCS= mount_fdesc.c pathadj.c
MAN= mount_fdesc.8 MAN= mount_fdesc.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS+= -I${NETBSDSRCDIR}/sys -I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL} DPADD+=${LIBUTIL}
LDADD+=-lutil LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_fdesc.c,v 1.26 2011/08/29 14:35:00 joerg Exp $ */ /* $NetBSD: mount_fdesc.c,v 1.27 2020/07/26 08:20:22 mlelstv Exp $ */
/* /*
* Copyright (c) 1992, 1993, 1994 * Copyright (c) 1992, 1993, 1994
@ -77,7 +77,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
#if 0 #if 0
static char sccsid[] = "@(#)mount_fdesc.c 8.3 (Berkeley) 4/26/95"; static char sccsid[] = "@(#)mount_fdesc.c 8.3 (Berkeley) 4/26/95";
#else #else
__RCSID("$NetBSD: mount_fdesc.c,v 1.26 2011/08/29 14:35:00 joerg Exp $"); __RCSID("$NetBSD: mount_fdesc.c,v 1.27 2020/07/26 08:20:22 mlelstv Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -92,6 +92,7 @@ __RCSID("$NetBSD: mount_fdesc.c,v 1.26 2011/08/29 14:35:00 joerg Exp $");
#include <mntopts.h> #include <mntopts.h>
#include "mountprog.h"
#include "mount_fdesc.h" #include "mount_fdesc.h"
static const struct mntopt mopts[] = { static const struct mntopt mopts[] = {
@ -142,12 +143,7 @@ mount_fdesc_parseargs(int argc, char *argv[], void *dummy, int *mntflags,
exit(0); exit(0);
strlcpy(canon_dev, argv[0], MAXPATHLEN); strlcpy(canon_dev, argv[0], MAXPATHLEN);
if (realpath(argv[1], canon_dir) == NULL) /* Check mounton path */ pathadj(argv[1], canon_dir);
err(1, "realpath %s", argv[1]);
if (strncmp(argv[1], canon_dir, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[1]);
warnx("using \"%s\" instead.", canon_dir);
}
} }
int int

View File

@ -1,11 +1,11 @@
# $NetBSD: Makefile,v 1.8 2005/06/27 01:00:05 christos Exp $ # $NetBSD: Makefile,v 1.9 2020/07/26 08:20:22 mlelstv Exp $
# #
# Makefile 1.0 1998/6/26 # Makefile 1.0 1998/6/26
.include <bsd.own.mk> .include <bsd.own.mk>
PROG= mount_filecore PROG= mount_filecore
SRCS= mount_filecore.c fattr.c SRCS= mount_filecore.c fattr.c pathadj.c
MAN= mount_filecore.8 MAN= mount_filecore.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount MOUNT= ${NETBSDSRCDIR}/sbin/mount

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_filecore.c,v 1.20 2011/08/29 14:35:01 joerg Exp $ */ /* $NetBSD: mount_filecore.c,v 1.21 2020/07/26 08:20:22 mlelstv Exp $ */
/* /*
* Copyright (c) 1992, 1993, 1994 The Regents of the University of California. * Copyright (c) 1992, 1993, 1994 The Regents of the University of California.
@ -165,24 +165,11 @@ mount_filecore(int argc, char **argv)
if (argc != 2) if (argc != 2)
usage(); usage();
dev = argv[0]; pathadj(argv[0], canon_dev);
dir = argv[1]; dev = canon_dev;
if (realpath(dev, canon_dev) == NULL) /* Check device path */ pathadj(argv[0], canon_dir);
err(1, "realpath %s", dev); dir = canon_dir;
if (strncmp(dev, canon_dev, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", dev);
dev = canon_dev;
warnx("using \"%s\" instead.", dev);
}
if (realpath(dir, canon_dir) == NULL) /* Check mounton path */
err(1, "realpath %s", dir);
if (strncmp(dir, canon_dir, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", dir);
dir = canon_dir;
warnx("using \"%s\" instead.", dir);
}
#define DEFAULT_ROOTUID -2 #define DEFAULT_ROOTUID -2
/* /*

View File

@ -1,12 +1,16 @@
# $NetBSD: Makefile,v 1.13 2005/06/27 01:00:06 christos Exp $ # $NetBSD: Makefile,v 1.14 2020/07/26 08:20:22 mlelstv Exp $
# @(#)Makefile 8.2 (Berkeley) 3/27/94 # @(#)Makefile 8.2 (Berkeley) 3/27/94
.include <bsd.own.mk> .include <bsd.own.mk>
PROG= mount_kernfs PROG= mount_kernfs
SRCS= mount_kernfs.c SRCS= mount_kernfs.c pathadj.c
MAN= mount_kernfs.8 MAN= mount_kernfs.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS+= -I${NETBSDSRCDIR}/sys -I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL} DPADD+=${LIBUTIL}
LDADD+=-lutil LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_kernfs.c,v 1.25 2011/08/29 14:35:01 joerg Exp $ */ /* $NetBSD: mount_kernfs.c,v 1.26 2020/07/26 08:20:22 mlelstv Exp $ */
/* /*
* Copyright (c) 1992, 1993, 1994 * Copyright (c) 1992, 1993, 1994
@ -77,7 +77,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
#if 0 #if 0
static char sccsid[] = "@(#)mount_kernfs.c 8.3 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)mount_kernfs.c 8.3 (Berkeley) 5/4/95";
#else #else
__RCSID("$NetBSD: mount_kernfs.c,v 1.25 2011/08/29 14:35:01 joerg Exp $"); __RCSID("$NetBSD: mount_kernfs.c,v 1.26 2020/07/26 08:20:22 mlelstv Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -92,6 +92,7 @@ __RCSID("$NetBSD: mount_kernfs.c,v 1.25 2011/08/29 14:35:01 joerg Exp $");
#include <mntopts.h> #include <mntopts.h>
#include "mountprog.h"
#include "mount_kernfs.h" #include "mount_kernfs.h"
static const struct mntopt mopts[] = { static const struct mntopt mopts[] = {
@ -142,12 +143,7 @@ mount_kernfs_parseargs(int argc, char *argv[], void *dummy, int *mntflags,
exit(0); exit(0);
strlcpy(canon_dev, argv[0], MAXPATHLEN); strlcpy(canon_dev, argv[0], MAXPATHLEN);
if (realpath(argv[1], canon_dir) == NULL) /* Check mounton path */ pathadj(argv[1], canon_dir);
err(1, "realpath %s", argv[1]);
if (strncmp(argv[1], canon_dir, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[1]);
warnx("using \"%s\" instead.", canon_dir);
}
} }
int int

View File

@ -1,13 +1,15 @@
# $NetBSD: Makefile,v 1.12 2005/06/27 01:00:06 christos Exp $ # $NetBSD: Makefile,v 1.13 2020/07/26 08:20:22 mlelstv Exp $
# @(#)Makefile 8.3 (Berkeley) 3/27/94 # @(#)Makefile 8.3 (Berkeley) 3/27/94
.include <bsd.own.mk> .include <bsd.own.mk>
PROG= mount_null PROG= mount_null
SRCS= mount_null.c SRCS= mount_null.c pathadj.c
MAN= mount_null.8 MAN= mount_null.8
CPPFLAGS+= -I${NETBSDSRCDIR}/sys MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS+= -I${NETBSDSRCDIR}/sys -I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL} DPADD+=${LIBUTIL}
LDADD+=-lutil LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_null.c,v 1.20 2016/07/25 04:40:51 erh Exp $ */ /* $NetBSD: mount_null.c,v 1.21 2020/07/26 08:20:22 mlelstv Exp $ */
/* /*
* Copyright (c) 1992, 1993, 1994 * Copyright (c) 1992, 1993, 1994
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
#if 0 #if 0
static char sccsid[] = "@(#)mount_null.c 8.6 (Berkeley) 4/26/95"; static char sccsid[] = "@(#)mount_null.c 8.6 (Berkeley) 4/26/95";
#else #else
__RCSID("$NetBSD: mount_null.c,v 1.20 2016/07/25 04:40:51 erh Exp $"); __RCSID("$NetBSD: mount_null.c,v 1.21 2020/07/26 08:20:22 mlelstv Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -58,6 +58,8 @@ __RCSID("$NetBSD: mount_null.c,v 1.20 2016/07/25 04:40:51 erh Exp $");
#include <mntopts.h> #include <mntopts.h>
#include "mountprog.h"
static const struct mntopt mopts[] = { static const struct mntopt mopts[] = {
MOPT_STDOPTS, MOPT_STDOPTS,
MOPT_GETARGS, MOPT_GETARGS,
@ -102,19 +104,8 @@ mount_null(int argc, char *argv[])
if (argc != 2) if (argc != 2)
usage(); usage();
if (realpath(argv[0], target) == NULL) /* Check device path */ pathadj(argv[0], target);
err(1, "realpath %s", argv[0]); pathadj(argv[1], canon_dir);
if (strncmp(argv[0], target, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[0]);
warnx("using \"%s\" instead.", target);
}
if (realpath(argv[1], canon_dir) == NULL) /* Check mounton path */
err(1, "realpath %s", argv[1]);
if (strncmp(argv[1], canon_dir, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[1]);
warnx("using \"%s\" instead.", canon_dir);
}
if (strcmp(target, canon_dir) == 0) if (strcmp(target, canon_dir) == 0)
errx(1, "%s (%s) and %s (%s) are identical paths", errx(1, "%s (%s) and %s (%s) are identical paths",

View File

@ -1,13 +1,15 @@
# $NetBSD: Makefile,v 1.5 2005/06/27 01:00:06 christos Exp $ # $NetBSD: Makefile,v 1.6 2020/07/26 08:20:22 mlelstv Exp $
# @(#)Makefile 8.3 (Berkeley) 3/27/94 # @(#)Makefile 8.3 (Berkeley) 3/27/94
.include <bsd.own.mk> .include <bsd.own.mk>
PROG= mount_overlay PROG= mount_overlay
SRCS= mount_overlay.c SRCS= mount_overlay.c pathadj.c
MAN= mount_overlay.8 MAN= mount_overlay.8
CPPFLAGS+= -I${NETBSDSRCDIR}/sys MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS+= -I${NETBSDSRCDIR}/sys -I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL} DPADD+=${LIBUTIL}
LDADD+=-lutil LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_overlay.c,v 1.13 2011/08/29 14:35:02 joerg Exp $ */ /* $NetBSD: mount_overlay.c,v 1.14 2020/07/26 08:20:22 mlelstv Exp $ */
/* /*
* Copyright (c) 1992, 1993, 1994 * Copyright (c) 1992, 1993, 1994
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
#if 0 #if 0
static char sccsid[] = "@(#)mount_null.c 8.6 (Berkeley) 4/26/95"; static char sccsid[] = "@(#)mount_null.c 8.6 (Berkeley) 4/26/95";
#else #else
__RCSID("$NetBSD: mount_overlay.c,v 1.13 2011/08/29 14:35:02 joerg Exp $"); __RCSID("$NetBSD: mount_overlay.c,v 1.14 2020/07/26 08:20:22 mlelstv Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -58,6 +58,8 @@ __RCSID("$NetBSD: mount_overlay.c,v 1.13 2011/08/29 14:35:02 joerg Exp $");
#include <mntopts.h> #include <mntopts.h>
#include "mountprog.h"
static const struct mntopt mopts[] = { static const struct mntopt mopts[] = {
MOPT_STDOPTS, MOPT_STDOPTS,
MOPT_GETARGS, MOPT_GETARGS,
@ -102,19 +104,8 @@ mount_overlay(int argc, char *argv[])
if (argc != 2) if (argc != 2)
usage(); usage();
if (realpath(argv[0], target) == NULL) /* Check device path */ pathadj(argv[0], target);
err(1, "realpath %s", argv[0]); pathadj(argv[1], canon_dir);
if (strncmp(argv[0], target, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[0]);
warnx("using \"%s\" instead.", target);
}
if (realpath(argv[1], canon_dir) == NULL) /* Check mounton path */
err(1, "realpath %s", argv[1]);
if (strncmp(argv[1], canon_dir, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[1]);
warnx("using \"%s\" instead.", canon_dir);
}
args.la.target = target; args.la.target = target;

View File

@ -1,12 +1,16 @@
# $NetBSD: Makefile,v 1.14 2005/06/27 01:00:06 christos Exp $ # $NetBSD: Makefile,v 1.15 2020/07/26 08:20:23 mlelstv Exp $
# @(#)Makefile 8.4 (Berkeley) 3/27/94 # @(#)Makefile 8.4 (Berkeley) 3/27/94
.include <bsd.own.mk> .include <bsd.own.mk>
PROG= mount_procfs PROG= mount_procfs
SRCS= mount_procfs.c SRCS= mount_procfs.c pathadj.c
MAN= mount_procfs.8 MAN= mount_procfs.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS+= -I${NETBSDSRCDIR}/sys -I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL} DPADD+=${LIBUTIL}
LDADD+=-lutil LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_procfs.c,v 1.24 2011/08/29 14:35:02 joerg Exp $ */ /* $NetBSD: mount_procfs.c,v 1.25 2020/07/26 08:20:23 mlelstv Exp $ */
/* /*
* Copyright (c) 1992, 1993, 1994 * Copyright (c) 1992, 1993, 1994
@ -77,7 +77,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
#if 0 #if 0
static char sccsid[] = "@(#)mount_procfs.c 8.4 (Berkeley) 4/26/95"; static char sccsid[] = "@(#)mount_procfs.c 8.4 (Berkeley) 4/26/95";
#else #else
__RCSID("$NetBSD: mount_procfs.c,v 1.24 2011/08/29 14:35:02 joerg Exp $"); __RCSID("$NetBSD: mount_procfs.c,v 1.25 2020/07/26 08:20:23 mlelstv Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -95,6 +95,8 @@ __RCSID("$NetBSD: mount_procfs.c,v 1.24 2011/08/29 14:35:02 joerg Exp $");
#include <mntopts.h> #include <mntopts.h>
#include "mountprog.h"
static const struct mntopt mopts[] = { static const struct mntopt mopts[] = {
MOPT_STDOPTS, MOPT_STDOPTS,
MOPT_GETARGS, MOPT_GETARGS,
@ -141,12 +143,7 @@ mount_procfs(int argc, char *argv[])
if (argc != 2) if (argc != 2)
usage(); usage();
if (realpath(argv[1], canon_dir) == NULL) /* Check mounton path */ pathadj(argv[1], canon_dir);
err(1, "realpath %s", argv[1]);
if (strncmp(argv[1], canon_dir, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[1]);
warnx("using \"%s\" instead.", canon_dir);
}
args.version = PROCFS_ARGSVERSION; args.version = PROCFS_ARGSVERSION;
args.flags = altflags; args.flags = altflags;

View File

@ -1,12 +1,16 @@
# $NetBSD: Makefile,v 1.5 2010/06/14 14:42:49 pooka Exp $ # $NetBSD: Makefile,v 1.6 2020/07/26 08:20:23 mlelstv Exp $
# @(#)Makefile 8.2 (Berkeley) 3/27/94 # @(#)Makefile 8.2 (Berkeley) 3/27/94
.include <bsd.own.mk> .include <bsd.own.mk>
PROG= mount_ptyfs PROG= mount_ptyfs
SRCS= mount_ptyfs.c SRCS= mount_ptyfs.c pathadj.c
MAN= mount_ptyfs.8 MAN= mount_ptyfs.8
MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS+= -I${NETBSDSRCDIR}/sys -I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL} DPADD+=${LIBUTIL}
LDADD+=-lutil LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_ptyfs.c,v 1.17 2016/09/05 01:09:57 sevan Exp $ */ /* $NetBSD: mount_ptyfs.c,v 1.18 2020/07/26 08:20:23 mlelstv Exp $ */
/* /*
* Copyright (c) 1992, 1993, 1994 * Copyright (c) 1992, 1993, 1994
@ -77,7 +77,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
#if 0 #if 0
static char sccsid[] = "@(#)mount_ptyfs.c 8.3 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)mount_ptyfs.c 8.3 (Berkeley) 5/4/95";
#else #else
__RCSID("$NetBSD: mount_ptyfs.c,v 1.17 2016/09/05 01:09:57 sevan Exp $"); __RCSID("$NetBSD: mount_ptyfs.c,v 1.18 2020/07/26 08:20:23 mlelstv Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -98,6 +98,8 @@ __RCSID("$NetBSD: mount_ptyfs.c,v 1.17 2016/09/05 01:09:57 sevan Exp $");
#include <mntopts.h> #include <mntopts.h>
#include "mountprog.h"
#define ALTF_GROUP 0x1 #define ALTF_GROUP 0x1
#define ALTF_MODE 0x2 #define ALTF_MODE 0x2
#define ALTF_CHROOT 0x4 /* compat */ #define ALTF_CHROOT 0x4 /* compat */
@ -202,12 +204,7 @@ mount_ptyfs(int argc, char *argv[])
if (argc != 2) if (argc != 2)
usage(); usage();
if (realpath(argv[1], canon_dir) == NULL) /* Check mounton path */ pathadj(argv[1], canon_dir);
err(1, "realpath %s", argv[1]);
if (strncmp(argv[1], canon_dir, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[1]);
warnx("using \"%s\" instead.", canon_dir);
}
if (mount(MOUNT_PTYFS, canon_dir, mntflags, &args, sizeof args) == -1) if (mount(MOUNT_PTYFS, canon_dir, mntflags, &args, sizeof args) == -1)
err(1, "ptyfs on %s", canon_dir); err(1, "ptyfs on %s", canon_dir);

View File

@ -1,13 +1,15 @@
# $NetBSD: Makefile,v 1.11 2005/06/27 01:00:06 christos Exp $ # $NetBSD: Makefile,v 1.12 2020/07/26 08:20:23 mlelstv Exp $
# @(#)Makefile 8.3 (Berkeley) 3/27/94 # @(#)Makefile 8.3 (Berkeley) 3/27/94
.include <bsd.own.mk> .include <bsd.own.mk>
PROG= mount_umap PROG= mount_umap
SRCS= mount_umap.c SRCS= mount_umap.c pathadj.c
MAN= mount_umap.8 MAN= mount_umap.8
CPPFLAGS+= -I${NETBSDSRCDIR}/sys MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS+= -I${NETBSDSRCDIR}/sys -I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL} DPADD+=${LIBUTIL}
LDADD+=-lutil LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_umap.c,v 1.26 2019/08/20 21:18:10 perseant Exp $ */ /* $NetBSD: mount_umap.c,v 1.27 2020/07/26 08:20:23 mlelstv Exp $ */
/* /*
* Copyright (c) 1992, 1993, 1994 * Copyright (c) 1992, 1993, 1994
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
#if 0 #if 0
static char sccsid[] = "@(#)mount_umap.c 8.5 (Berkeley) 4/26/95"; static char sccsid[] = "@(#)mount_umap.c 8.5 (Berkeley) 4/26/95";
#else #else
__RCSID("$NetBSD: mount_umap.c,v 1.26 2019/08/20 21:18:10 perseant Exp $"); __RCSID("$NetBSD: mount_umap.c,v 1.27 2020/07/26 08:20:23 mlelstv Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -60,6 +60,8 @@ __RCSID("$NetBSD: mount_umap.c,v 1.26 2019/08/20 21:18:10 perseant Exp $");
#include <mntopts.h> #include <mntopts.h>
#include "mountprog.h"
#define ROOTUSER 0 #define ROOTUSER 0
/* /*
* This define controls whether any user but the superuser can own and * This define controls whether any user but the superuser can own and
@ -139,19 +141,8 @@ mount_umap(int argc, char *argv[])
if (argc != 2 || mapfile == NULL || gmapfile == NULL) if (argc != 2 || mapfile == NULL || gmapfile == NULL)
usage(); usage();
if (realpath(argv[0], source) == NULL) /* Check source path */ pathadj(argv[0], source);
err(1, "realpath %s", argv[0]); pathadj(argv[1], target);
if (strncmp(argv[0], source, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[0]);
warnx("using \"%s\" instead.", source);
}
if (realpath(argv[1], target) == NULL) /* Check mounton path */
err(1, "realpath %s", argv[1]);
if (strncmp(argv[1], target, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[1]);
warnx("using \"%s\" instead.", target);
}
/* Read in uid mapping data. */ /* Read in uid mapping data. */
if ((fp = fopen(mapfile, "r")) == NULL) if ((fp = fopen(mapfile, "r")) == NULL)

View File

@ -1,13 +1,15 @@
# $NetBSD: Makefile,v 1.14 2005/06/27 01:00:06 christos Exp $ # $NetBSD: Makefile,v 1.15 2020/07/26 08:20:23 mlelstv Exp $
# @(#)Makefile 8.4 (Berkeley) 7/13/94 # @(#)Makefile 8.4 (Berkeley) 7/13/94
.include <bsd.own.mk> .include <bsd.own.mk>
PROG= mount_union PROG= mount_union
SRCS= mount_union.c SRCS= mount_union.c pathadj.c
MAN= mount_union.8 MAN= mount_union.8
CPPFLAGS+= -I${NETBSDSRCDIR}/sys MOUNT= ${NETBSDSRCDIR}/sbin/mount
CPPFLAGS+= -I${NETBSDSRCDIR}/sys -I${MOUNT}
.PATH: ${MOUNT}
DPADD+=${LIBUTIL} DPADD+=${LIBUTIL}
LDADD+=-lutil LDADD+=-lutil

View File

@ -1,4 +1,4 @@
/* $NetBSD: mount_union.c,v 1.22 2011/08/29 14:35:03 joerg Exp $ */ /* $NetBSD: mount_union.c,v 1.23 2020/07/26 08:20:23 mlelstv Exp $ */
/* /*
* Copyright (c) 1992, 1993, 1994 * Copyright (c) 1992, 1993, 1994
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
#if 0 #if 0
static char sccsid[] = "@(#)mount_union.c 8.6 (Berkeley) 4/26/95"; static char sccsid[] = "@(#)mount_union.c 8.6 (Berkeley) 4/26/95";
#else #else
__RCSID("$NetBSD: mount_union.c,v 1.22 2011/08/29 14:35:03 joerg Exp $"); __RCSID("$NetBSD: mount_union.c,v 1.23 2020/07/26 08:20:23 mlelstv Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -60,6 +60,8 @@ __RCSID("$NetBSD: mount_union.c,v 1.22 2011/08/29 14:35:03 joerg Exp $");
#include <mntopts.h> #include <mntopts.h>
#include "mountprog.h"
static const struct mntopt mopts[] = { static const struct mntopt mopts[] = {
MOPT_STDOPTS, MOPT_STDOPTS,
MOPT_GETARGS, MOPT_GETARGS,
@ -112,19 +114,8 @@ mount_union(int argc, char *argv[])
if (argc != 2) if (argc != 2)
usage(); usage();
if (realpath(argv[0], target) == NULL) /* Check device path */ pathadj(argv[0], target);
err(1, "realpath %s", argv[0]); pathadj(argv[1], canon_dir);
if (strncmp(argv[0], target, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[0]);
warnx("using \"%s\" instead.", target);
}
if (realpath(argv[1], canon_dir) == NULL) /* Check mounton path */
err(1, "realpath %s", argv[1]);
if (strncmp(argv[1], canon_dir, MAXPATHLEN)) {
warnx("\"%s\" is a relative path.", argv[1]);
warnx("using \"%s\" instead.", canon_dir);
}
if (subdir(target, canon_dir) || subdir(canon_dir, target)) if (subdir(target, canon_dir) || subdir(canon_dir, target))
errx(1, "%s (%s) and %s are not distinct paths", errx(1, "%s (%s) and %s are not distinct paths",