From owner-svn-src-all@FreeBSD.ORG Mon Jan 16 19:34:21 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AA474106564A; Mon, 16 Jan 2012 19:34:21 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 959AC8FC08; Mon, 16 Jan 2012 19:34:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q0GJYLGp048441; Mon, 16 Jan 2012 19:34:21 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q0GJYL2x048424; Mon, 16 Jan 2012 19:34:21 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201201161934.q0GJYL2x048424@svn.freebsd.org> From: Jaakko Heinonen Date: Mon, 16 Jan 2012 19:34:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r230226 - in head: sbin/mount sbin/mount_cd9660 sbin/mount_ext2fs sbin/mount_msdosfs sbin/mount_nfs sbin/mount_ntfs sbin/mount_nullfs sbin/mount_reiserfs sbin/mount_std sbin/mount_udf s... X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jan 2012 19:34:21 -0000 Author: jh Date: Mon Jan 16 19:34:21 2012 New Revision: 230226 URL: http://svn.freebsd.org/changeset/base/230226 Log: Change checkpath() to not exit on error. This is a prerequisite for fixing the mount(8) "failok" option. PR: 163668 Reviewed by: Garrett Cooper, delphij (previous version) Modified: head/sbin/mount/getmntopts.c head/sbin/mount/mntopts.h head/sbin/mount/mount.c head/sbin/mount/mount_fs.c head/sbin/mount_cd9660/mount_cd9660.c head/sbin/mount_ext2fs/mount_ext2fs.c head/sbin/mount_msdosfs/mount_msdosfs.c head/sbin/mount_nfs/mount_nfs.c head/sbin/mount_ntfs/mount_ntfs.c head/sbin/mount_nullfs/mount_nullfs.c head/sbin/mount_reiserfs/mount_reiserfs.c head/sbin/mount_std/mount_std.c head/sbin/mount_udf/mount_udf.c head/sbin/mount_unionfs/mount_unionfs.c head/usr.sbin/mount_portalfs/mount_portalfs.c Modified: head/sbin/mount/getmntopts.c ============================================================================== --- head/sbin/mount/getmntopts.c Mon Jan 16 18:19:53 2012 (r230225) +++ head/sbin/mount/getmntopts.c Mon Jan 16 19:34:21 2012 (r230226) @@ -124,16 +124,20 @@ rmslashes(char *rrpin, char *rrpout) *rrpout = '\0'; } -void +int checkpath(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); + if (!S_ISDIR(sb.st_mode)) { + errno = ENOTDIR; + return (1); + } } else - errx(EX_USAGE, "%s: %s", resolved, strerror(errno)); + return (1); + + return (0); } void Modified: head/sbin/mount/mntopts.h ============================================================================== --- head/sbin/mount/mntopts.h Mon Jan 16 18:19:53 2012 (r230225) +++ head/sbin/mount/mntopts.h Mon Jan 16 19:34:21 2012 (r230226) @@ -93,7 +93,7 @@ struct mntopt { void getmntopts(const char *, const struct mntopt *, int *, int *); void rmslashes(char *, char *); -void checkpath(const char *, char resolved_path[]); +int checkpath(const char *, char resolved_path[]); extern int getmnt_silent; void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, size_t len); void build_iovec_argf(struct iovec **iov, int *iovlen, const char *name, const char *fmt, ...); Modified: head/sbin/mount/mount.c ============================================================================== --- head/sbin/mount/mount.c Mon Jan 16 18:19:53 2012 (r230225) +++ head/sbin/mount/mount.c Mon Jan 16 19:34:21 2012 (r230226) @@ -539,7 +539,10 @@ mountfs(const char *vfstype, const char static struct cpa mnt_argv; /* resolve the mountpoint with realpath(3) */ - (void)checkpath(name, mntpath); + if (checkpath(name, mntpath) != 0) { + warn("%s", mntpath); + return (1); + } name = mntpath; if (mntopts == NULL) Modified: head/sbin/mount/mount_fs.c ============================================================================== --- head/sbin/mount/mount_fs.c Mon Jan 16 18:19:53 2012 (r230225) +++ head/sbin/mount/mount_fs.c Mon Jan 16 19:34:21 2012 (r230226) @@ -118,7 +118,10 @@ mount_fs(const char *vfstype, int argc, dev = argv[0]; dir = argv[1]; - (void)checkpath(dir, mntpath); + if (checkpath(dir, mntpath) != 0) { + warn("%s", mntpath); + return (1); + } (void)rmslashes(dev, dev); build_iovec(&iov, &iovlen, "fstype", fstype, (size_t)-1); Modified: head/sbin/mount_cd9660/mount_cd9660.c ============================================================================== --- head/sbin/mount_cd9660/mount_cd9660.c Mon Jan 16 18:19:53 2012 (r230225) +++ head/sbin/mount_cd9660/mount_cd9660.c Mon Jan 16 19:34:21 2012 (r230226) @@ -149,7 +149,8 @@ main(int argc, char **argv) * Resolve the mountpoint with realpath(3) and remove unnecessary * slashes from the devicename if there are any. */ - (void)checkpath(dir, mntpath); + if (checkpath(dir, mntpath) != 0) + err(1, "%s", mntpath); (void)rmslashes(dev, dev); if (ssector == -1) { Modified: head/sbin/mount_ext2fs/mount_ext2fs.c ============================================================================== --- head/sbin/mount_ext2fs/mount_ext2fs.c Mon Jan 16 18:19:53 2012 (r230225) +++ head/sbin/mount_ext2fs/mount_ext2fs.c Mon Jan 16 19:34:21 2012 (r230226) @@ -103,7 +103,8 @@ main(int argc, char *argv[]) * Resolve the mountpoint with realpath(3) and remove unnecessary * slashes from the devicename if there are any. */ - (void)checkpath(fs_name, mntpath); + if (checkpath(fs_name, mntpath) != 0) + err(EX_USAGE, "%s", mntpath); (void)rmslashes(fspec, fspec); build_iovec(&iov, &iovlen, "fstype", fstype, strlen(fstype) + 1); Modified: head/sbin/mount_msdosfs/mount_msdosfs.c ============================================================================== --- head/sbin/mount_msdosfs/mount_msdosfs.c Mon Jan 16 18:19:53 2012 (r230225) +++ head/sbin/mount_msdosfs/mount_msdosfs.c Mon Jan 16 19:34:21 2012 (r230226) @@ -193,7 +193,8 @@ main(int argc, char **argv) * Resolve the mountpoint with realpath(3) and remove unnecessary * slashes from the devicename if there are any. */ - (void)checkpath(dir, mntpath); + if (checkpath(dir, mntpath) != 0) + err(EX_USAGE, "%s", mntpath); (void)rmslashes(dev, dev); if (!set_gid || !set_uid || !set_mask) { Modified: head/sbin/mount_nfs/mount_nfs.c ============================================================================== --- head/sbin/mount_nfs/mount_nfs.c Mon Jan 16 18:19:53 2012 (r230225) +++ head/sbin/mount_nfs/mount_nfs.c Mon Jan 16 19:34:21 2012 (r230226) @@ -411,7 +411,8 @@ main(int argc, char *argv[]) exit(1); /* resolve the mountpoint with realpath(3) */ - (void)checkpath(name, mntpath); + if (checkpath(name, mntpath) != 0) + err(1, "%s", mntpath); build_iovec(&iov, &iovlen, "fstype", fstype, (size_t)-1); build_iovec(&iov, &iovlen, "fspath", mntpath, (size_t)-1); Modified: head/sbin/mount_ntfs/mount_ntfs.c ============================================================================== --- head/sbin/mount_ntfs/mount_ntfs.c Mon Jan 16 18:19:53 2012 (r230225) +++ head/sbin/mount_ntfs/mount_ntfs.c Mon Jan 16 19:34:21 2012 (r230226) @@ -163,7 +163,8 @@ main(int argc, char *argv[]) * Resolve the mountpoint with realpath(3) and remove unnecessary * slashes from the devicename if there are any. */ - (void)checkpath(dir, mntpath); + if (checkpath(dir, mntpath) != 0) + err(EX_USAGE, "%s", mntpath); (void)rmslashes(dev, dev); args.fspec = dev; Modified: head/sbin/mount_nullfs/mount_nullfs.c ============================================================================== --- head/sbin/mount_nullfs/mount_nullfs.c Mon Jan 16 18:19:53 2012 (r230225) +++ head/sbin/mount_nullfs/mount_nullfs.c Mon Jan 16 19:34:21 2012 (r230226) @@ -90,8 +90,10 @@ main(int argc, char *argv[]) usage(); /* resolve target and source with realpath(3) */ - (void)checkpath(argv[0], target); - (void)checkpath(argv[1], source); + if (checkpath(argv[0], target) != 0) + err(EX_USAGE, "%s", target); + if (checkpath(argv[1], source) != 0) + err(EX_USAGE, "%s", source); if (subdir(target, source) || subdir(source, target)) errx(EX_USAGE, "%s (%s) and %s are not distinct paths", Modified: head/sbin/mount_reiserfs/mount_reiserfs.c ============================================================================== --- head/sbin/mount_reiserfs/mount_reiserfs.c Mon Jan 16 18:19:53 2012 (r230225) +++ head/sbin/mount_reiserfs/mount_reiserfs.c Mon Jan 16 19:34:21 2012 (r230226) @@ -78,7 +78,8 @@ main(int argc, char *argv[]) * Resolve the mountpoint with realpath(3) and remove unnecessary * slashes from the devicename if there are any. */ - (void)checkpath(dir, mntpath); + if (checkpath(dir, mntpath) != 0) + err(EX_USAGE, "%s", mntpath); (void)rmslashes(dev, dev); /* Read-only support for now */ Modified: head/sbin/mount_std/mount_std.c ============================================================================== --- head/sbin/mount_std/mount_std.c Mon Jan 16 18:19:53 2012 (r230225) +++ head/sbin/mount_std/mount_std.c Mon Jan 16 19:34:21 2012 (r230226) @@ -112,7 +112,8 @@ main(int argc, char *argv[]) usage(); /* resolve the mountpoint with realpath(3) */ - (void)checkpath(argv[1], mntpath); + if (checkpath(argv[1], mntpath) != 0) + err(EX_USAGE, "%s", mntpath); iov[0].iov_base = "fstype"; iov[0].iov_len = sizeof("fstype"); Modified: head/sbin/mount_udf/mount_udf.c ============================================================================== --- head/sbin/mount_udf/mount_udf.c Mon Jan 16 18:19:53 2012 (r230225) +++ head/sbin/mount_udf/mount_udf.c Mon Jan 16 19:34:21 2012 (r230226) @@ -111,7 +111,8 @@ main(int argc, char **argv) * Resolve the mountpoint with realpath(3) and remove unnecessary * slashes from the devicename if there are any. */ - (void)checkpath(dir, mntpath); + if (checkpath(dir, mntpath) != 0) + err(EX_USAGE, "%s", mntpath); (void)rmslashes(dev, dev); /* Modified: head/sbin/mount_unionfs/mount_unionfs.c ============================================================================== --- head/sbin/mount_unionfs/mount_unionfs.c Mon Jan 16 18:19:53 2012 (r230225) +++ head/sbin/mount_unionfs/mount_unionfs.c Mon Jan 16 19:34:21 2012 (r230226) @@ -176,8 +176,10 @@ main(int argc, char *argv[]) usage(); /* resolve both target and source with realpath(3) */ - (void)checkpath(argv[0], target); - (void)checkpath(argv[1], source); + if (checkpath(argv[0], target) != 0) + err(EX_USAGE, "%s", target); + if (checkpath(argv[1], source) != 0) + err(EX_USAGE, "%s", source); if (subdir(target, source) || subdir(source, target)) errx(EX_USAGE, "%s (%s) and %s (%s) are not distinct paths", Modified: head/usr.sbin/mount_portalfs/mount_portalfs.c ============================================================================== --- head/usr.sbin/mount_portalfs/mount_portalfs.c Mon Jan 16 18:19:53 2012 (r230225) +++ head/usr.sbin/mount_portalfs/mount_portalfs.c Mon Jan 16 19:34:21 2012 (r230226) @@ -140,7 +140,8 @@ main(int argc, char *argv[]) } /* resolve the mountpoint with realpath(3) */ - (void)checkpath(argv[optind+1], mountpt); + if (checkpath(argv[optind+1], mountpt) != 0) + err(EX_USAGE, "%s", mountpt); /* * Construct the listening socket