Date: Thu, 31 Oct 1996 09:50:27 -0700 (MST) From: Marc Slemko <marcs@znep.com> To: Nathan Lawson <nlawson@kdat.csc.calpoly.edu> Cc: freebsd-security@freebsd.org Subject: Re: /etc/security Message-ID: <Pine.BSF.3.95.961031093503.12929A-100000@alive.ampr.ab.ca> In-Reply-To: <199610311610.IAA20880@kdat.calpoly.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 31 Oct 1996, Nathan Lawson wrote:
> > <<On Thu, 31 Oct 1996 08:18:58 +0100, sthaug@nethelp.no said:
> >
> > >> checking setuid files and devices:
> > >> find: /doscopy/sb16/pro_org/i'vebeen.org: illegal path
> > >> find: /doscopy/sb16/pro_org/she'llbe.org: illegal path
> >
> > The best way to deal with this is probably using the `-print0' primary
> > to `find' and using a `perl -n0' script to process the results, like:
> >
> > find ..... -print0 | perl -n0e 'exec "/bin/ls", "-lFgod", <>;'
>
> Yes, the -print0 option is useful, but to avoid executing another interpreter
> just for the task of filtering out the NULLs, I prefer to use xargs -0
>
> >From the man page:
> -0 Changes xargs to expect NUL (``\0'') characters as seperators,
> instead of spaces and newlines. This is expected to be used in
> concert with the -print0 function in find.
>
> This avoids execing a costly interpreter and keeps the scripts using xargs,
> which is useful with very long path lists.
Except for the minor problem that xargs does not have a -0 option
on FreeBSD. GNU xargs does and OpenBSD xargs does. Below is the
diff from OpenBSD to implement the change. I think it is a worthwhile
change, although I haven't really looked too much at the OpenBSD
way of doing it to see if it is a good implementation.
Index: xargs.c
===================================================================
RCS file: /cvs/src/usr.bin/xargs/xargs.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -c -r1.1 -r1.2
*** xargs.c 1995/10/18 08:47:00 1.1
--- xargs.c 1996/06/11 06:48:06 1.2
***************
*** 62,67 ****
--- 62,68 ----
#include "pathnames.h"
int tflag, rval;
+ int zflag;
void run __P((char **));
void usage __P((void));
***************
*** 94,100 ****
nargs = 5000;
nline = ARG_MAX - 4 * 1024;
nflag = xflag = 0;
! while ((ch = getopt(argc, argv, "n:s:tx")) != EOF)
switch(ch) {
case 'n':
nflag = 1;
--- 95,101 ----
nargs = 5000;
nline = ARG_MAX - 4 * 1024;
nflag = xflag = 0;
! while ((ch = getopt(argc, argv, "0n:s:tx")) != EOF)
switch(ch) {
case 'n':
nflag = 1;
***************
*** 110,115 ****
--- 111,119 ----
case 'x':
xflag = 1;
break;
+ case '0':
+ zflag = 1;
+ break;
case '?':
default:
usage();
***************
*** 183,192 ****
case ' ':
case '\t':
/* Quotes escape tabs and spaces. */
! if (insingle || indouble)
goto addch;
goto arg2;
case '\n':
/* Empty lines are skipped. */
if (argp == p)
continue;
--- 187,203 ----
case ' ':
case '\t':
/* Quotes escape tabs and spaces. */
! if (insingle || indouble || zflag)
goto addch;
goto arg2;
+ case '\0':
+ if (zflag)
+ goto arg2;
+ goto addch;
case '\n':
+ if (zflag)
+ goto addch;
+
/* Empty lines are skipped. */
if (argp == p)
continue;
***************
*** 217,232 ****
argp = p;
break;
case '\'':
! if (indouble)
goto addch;
insingle = !insingle;
break;
case '"':
! if (insingle)
goto addch;
indouble = !indouble;
break;
case '\\':
/* Backslash escapes anything, is escaped by quotes. */
if (!insingle && !indouble && (ch = getchar()) == EOF)
errx(1, "backslash at EOF");
--- 228,245 ----
argp = p;
break;
case '\'':
! if (indouble || zflag)
goto addch;
insingle = !insingle;
break;
case '"':
! if (insingle || zflag)
goto addch;
indouble = !indouble;
break;
case '\\':
+ if (zflag)
+ goto addch;
/* Backslash escapes anything, is escaped by quotes. */
if (!insingle && !indouble && (ch = getchar()) == EOF)
errx(1, "backslash at EOF");
***************
*** 316,321 ****
usage()
{
(void)fprintf(stderr,
! "usage: xargs [-t] [-n number [-x]] [-s size] [utility [argument ...]]\n");
exit(1);
}
--- 329,334 ----
usage()
{
(void)fprintf(stderr,
! "usage: xargs [-0] [-t] [-n number [-x]] [-s size] [utility [argument ...]]\n");
exit(1);
}
Index: xargs.1
===================================================================
RCS file: /cvs/src/usr.bin/xargs/xargs.1,v
retrieving revision 1.1
retrieving revision 1.3
diff -c -r1.1 -r1.3
*** xargs.1 1995/10/18 08:47:00 1.1
--- xargs.1 1996/06/11 06:56:57 1.3
***************
*** 45,50 ****
--- 45,51 ----
.Nd "construct argument list(s) and execute utility"
.Sh SYNOPSIS
.Nm xargs
+ .Op Fl 0
.Op Fl t
.Oo Op Fl x
.Fl n Ar number
***************
*** 81,86 ****
--- 82,97 ----
.Pp
The options are as follows:
.Bl -tag -width indent
+ .It Fl 0
+ Changes
+ .Nm xargs
+ to expect NUL
+ (``\\0'')
+ characters as seperators, instead of spaces and newlines.
+ This is expected to be used in concert with the
+ .Fl print0
+ function in
+ .Nm find .
.It Fl n Ar number
Set the maximum number of arguments taken from standard input for each
invocation of the utility.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95.961031093503.12929A-100000>
