Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jan 2012 19:40:09 GMT
From:      dfilter@FreeBSD.ORG (dfilter service)
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: conf/163668: commit references a PR
Message-ID:  <201201161940.q0GJe9uW031694@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR conf/163668; it has been noted by GNATS.

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/163668: commit references a PR
Date: Mon, 16 Jan 2012 19:34:35 +0000 (UTC)

 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
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201161940.q0GJe9uW031694>