From owner-freebsd-bugs@FreeBSD.ORG Thu Jan 22 05:20:02 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 90283106566C; Thu, 22 Jan 2009 05:20:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 667968FC0A; Thu, 22 Jan 2009 05:20:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n0M5K2DP077237; Thu, 22 Jan 2009 05:20:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n0M5K2Xr077236; Thu, 22 Jan 2009 05:20:02 GMT (envelope-from gnats) Resent-Date: Thu, 22 Jan 2009 05:20:02 GMT Resent-Message-Id: <200901220520.n0M5K2Xr077236@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Cc: keramida@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Giorgos Keramidas Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DBEBF1065674 for ; Thu, 22 Jan 2009 05:18:29 +0000 (UTC) (envelope-from keramida@freebsd.org) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id 64D5C8FC16 for ; Thu, 22 Jan 2009 05:18:28 +0000 (UTC) (envelope-from keramida@freebsd.org) Received: from kobe.laptop (adsl189-242.kln.forthnet.gr [79.103.2.242]) (authenticated bits=128) by igloo.linux.gr (8.14.3/8.14.3/Debian-5) with ESMTP id n0M5ICeK028162 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 22 Jan 2009 07:18:18 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.3/8.14.3) with ESMTP id n0M5IBUH059898 for ; Thu, 22 Jan 2009 07:18:11 +0200 (EET) (envelope-from keramida@freebsd.org) Received: (from keramida@localhost) by kobe.laptop (8.14.3/8.14.3/Submit) id n0M5IBcn059897; Thu, 22 Jan 2009 07:18:11 +0200 (EET) (envelope-from keramida@freebsd.org) Message-Id: <87tz7rdilo.fsf@kobe.laptop> Date: Thu, 22 Jan 2009 07:18:11 +0200 From: Giorgos Keramidas To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 X-GNATS-Notify: keramida Cc: Subject: bin/130855: [PATCH] a chown/chgrp -x option to avoid crossing mount points X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Giorgos Keramidas List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jan 2009 05:20:02 -0000 >Number: 130855 >Category: bin >Synopsis: [PATCH] a chown/chgrp -x option to avoid crossing mount points >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Jan 22 05:20:01 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Giorgos Keramidas >Release: FreeBSD 8.0-CURRENT i386 >Organization: >Environment: System: FreeBSD kobe 8.0-CURRENT FreeBSD 8.0-CURRENT #0: \ Wed Jan 14 02:12:50 EET 2009 build@kobe:/usr/obj/usr/src/sys/KOBE i386 >Description: Some time ago, I hacked a -x option into my local chown/chgrp version, to avoid crossing file system mount points. This is really a trivial patch, but if it is useful to anyone else we can commit it to the src-tree too. >How-To-Repeat: >Fix: --- chown-xdev.patch begins here --- Add a new -x option to chown and chgrp, to inhibit file system mount point traversal. The -x option is documented, like -v, as a non-standard option in the COMPATIBILITY manpage sections. diff -r e8506b2ac7ae -r bc9edfda4335 usr.sbin/chown/chown.c --- a/usr.sbin/chown/chown.c Wed Jan 21 21:31:33 2009 +0200 +++ b/usr.sbin/chown/chown.c Thu Jan 22 07:08:29 2009 +0200 @@ -73,14 +73,14 @@ { FTS *ftsp; FTSENT *p; - int Hflag, Lflag, Rflag, fflag, hflag, vflag; + int Hflag, Lflag, Rflag, fflag, hflag, vflag, xflag; int ch, fts_options, rval; char *cp; ischown = (strcmp(basename(argv[0]), "chown") == 0); - Hflag = Lflag = Rflag = fflag = hflag = vflag = 0; - while ((ch = getopt(argc, argv, "HLPRfhv")) != -1) + Hflag = Lflag = Rflag = fflag = hflag = vflag = xflag = 0; + while ((ch = getopt(argc, argv, "HLPRfhvx")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -105,6 +105,9 @@ case 'v': vflag++; break; + case 'x': + xflag = 1; + break; case '?': default: usage(); @@ -126,8 +129,11 @@ fts_options &= ~FTS_PHYSICAL; fts_options |= FTS_LOGICAL; } - } else + } else { fts_options = hflag ? FTS_PHYSICAL : FTS_LOGICAL; + } + if (xflag) + fts_options |= FTS_XDEV; uid = (uid_t)-1; gid = (gid_t)-1; @@ -297,11 +303,11 @@ if (ischown) (void)fprintf(stderr, "%s\n%s\n", - "usage: chown [-fhv] [-R [-H | -L | -P]] owner[:group]" + "usage: chown [-fhvx] [-R [-H | -L | -P]] owner[:group]" " file ...", - " chown [-fhv] [-R [-H | -L | -P]] :group file ..."); + " chown [-fhvx] [-R [-H | -L | -P]] :group file ..."); else (void)fprintf(stderr, "%s\n", - "usage: chgrp [-fhv] [-R [-H | -L | -P]] group file ..."); + "usage: chgrp [-fhvx] [-R [-H | -L | -P]] group file ..."); exit(1); } diff -r e8506b2ac7ae -r bc9edfda4335 usr.sbin/chown/chgrp.1 --- a/usr.sbin/chown/chgrp.1 Wed Jan 21 21:31:33 2009 +0200 +++ b/usr.sbin/chown/chgrp.1 Thu Jan 22 07:08:29 2009 +0200 @@ -31,7 +31,7 @@ .\" @(#)chgrp.1 8.3 (Berkeley) 3/31/94 .\" $FreeBSD$ .\" -.Dd April 25, 2003 +.Dd January 22, 2009 .Dt CHGRP 1 .Os .Sh NAME @@ -39,7 +39,7 @@ .Nd change group .Sh SYNOPSIS .Nm -.Op Fl fhv +.Op Fl fhvx .Oo .Fl R .Op Fl H | Fl L | Fl P @@ -89,6 +89,8 @@ flag is specified more than once, .Nm will print the filename, followed by the old and new numeric group ID. +.It Fl x +File system mount points are not traversed. .El .Pp The @@ -125,7 +127,9 @@ .Pp The .Fl v -option is non-standard and its use in scripts is not recommended. +and +.Fl x +options are non-standard and their use in scripts is not recommended. .Sh SEE ALSO .Xr chown 2 , .Xr fts 3 , diff -r e8506b2ac7ae -r bc9edfda4335 usr.sbin/chown/chown.8 --- a/usr.sbin/chown/chown.8 Wed Jan 21 21:31:33 2009 +0200 +++ b/usr.sbin/chown/chown.8 Thu Jan 22 07:08:29 2009 +0200 @@ -28,7 +28,7 @@ .\" @(#)chown.8 8.3 (Berkeley) 3/31/94 .\" $FreeBSD$ .\" -.Dd April 25, 2003 +.Dd January 22, 2009 .Dt CHOWN 8 .Os .Sh NAME @@ -36,7 +36,7 @@ .Nd change file owner and group .Sh SYNOPSIS .Nm -.Op Fl fhv +.Op Fl fhvx .Oo .Fl R .Op Fl H | Fl L | Fl P @@ -44,7 +44,7 @@ .Ar owner Ns Op : Ns Ar group .Ar .Nm -.Op Fl fhv +.Op Fl fhvx .Oo .Fl R .Op Fl H | Fl L | Fl P @@ -97,6 +97,8 @@ flag is specified more than once, .Nm will print the filename, followed by the old and new numeric user/group ID. +.It Fl x +File system mount points are not traversed. .El .Pp The @@ -146,7 +148,9 @@ .Pp The .Fl v -option is non-standard and its use in scripts is not recommended. +and +.Fl x +options are non-standard and their use in scripts is not recommended. .Sh SEE ALSO .Xr chgrp 1 , .Xr find 1 , --- chown-xdev.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: