Skip site navigation (1)Skip section navigation (2)
Date:      20 Feb 1999 08:54:16 -0000
From:      monte@gonefishing.org
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/10169: find -perm <mode> doesn't allow a bitwise-:  on <mode>
Message-ID:  <19990220085416.28210.qmail@sturgeon.gonefishing.org>

index | next in thread | raw e-mail


>Number:         10169
>Category:       bin
>Synopsis:       find -perm <mode> doesn't allow a bitwise-& on <mode>
>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:   Sat Feb 20 01:00:01 PST 1999
>Closed-Date:
>Last-Modified:
>Originator:     Monte Mitzelfelt
>Release:        FreeBSD 2.2.6-RELEASE i386
>Organization:
New Mexico Technet, Inc.
>Environment:

	irrelevant

>Description:

	The find -perm option currently supports an exact match,
	or if the mode is preceded by a '-', it checks for a match
	in at least the bits specified on the command line.  It is
	often desirable to find things with any execute or setuid or
	setgid bits set.

>How-To-Repeat:

	irrelevant

>Fix:

	I've included the context diff of a patch that would add in GNU
	find style, a +mode.  Basically, it does a bitwise & of the mask
	against each files mode.  If any bits are set in mask and mode,
	the & sniffs them out and returns a true value.  The man page
	is patched as well.
	
*** old/function.c	Sun Feb  2 11:57:22 1997
--- function.c	Fri Feb 19 10:40:28 1999
***************
*** 741,746 ****
--- 741,748 ----
  	    (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO);
  	if (plan->flags == F_ATLEAST)
  		return ((plan->m_data | mode) == mode);
+ 	else if (plan->flags == F_ANY )
+ 		return (plan->m_data & mode);
  	else
  		return (mode == plan->m_data);
  	/* NOTREACHED */
***************
*** 759,764 ****
--- 761,771 ----
  
  	if (*perm == '-') {
  		new->flags = F_ATLEAST;
+ 		++perm;
+ 	}
+ 
+ 	if (*perm == '+') {
+ 		new->flags = F_ANY;
  		++perm;
  	}
  
*** old/find.h	Fri Oct  4 06:54:05 1996
--- find.h	Thu Feb 18 00:15:17 1999
***************
*** 58,63 ****
--- 58,64 ----
  #define	F_MTFLAG	1			/* fstype */
  #define	F_MTTYPE	2
  #define	F_ATLEAST	1			/* perm */
+ #define	F_ANY		2			/* perm */
  	int flags;				/* private flags */
  	enum ntype type;			/* plan node type */
  	union {
*** old/find.1	Fri May 22 16:52:16 1998
--- find.1	Thu Feb 18 00:18:39 1999
***************
*** 268,274 ****
  in the comparison.
  If the mode is preceded by a dash (``\-''), this primary evaluates to true
  if at least all of the bits in the mode are set in the file's mode bits.
! If the mode is not preceded by a dash, this primary evaluates to true if
  the bits in the mode exactly match the file's mode bits.
  Note, the first character of a symbolic mode may not be a dash (``\-'').
  .It Ic -print
--- 268,276 ----
  in the comparison.
  If the mode is preceded by a dash (``\-''), this primary evaluates to true
  if at least all of the bits in the mode are set in the file's mode bits.
! If the mode is preceded by a plus (``\+''), this primary evaluates to true
! if any of the bits in the mode are set in the file's mode bits.
! Otherwise, this primary evaluates to true if
  the bits in the mode exactly match the file's mode bits.
  Note, the first character of a symbolic mode may not be a dash (``\-'').
  .It Ic -print

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



home | help

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