diff options
author | cracauer <cracauer@FreeBSD.org> | 1998-09-07 16:59:05 +0000 |
---|---|---|
committer | cracauer <cracauer@FreeBSD.org> | 1998-09-07 16:59:05 +0000 |
commit | 3e2891d9937473cab148fc78ec1bbd8e0a99ad2b (patch) | |
tree | 2b52f8f33232af933f7831f84db68719a06967ea /bin | |
parent | 78bcd559ac73145070758db748a52b2c48f6aef4 (diff) | |
download | FreeBSD-src-3e2891d9937473cab148fc78ec1bbd8e0a99ad2b.zip FreeBSD-src-3e2891d9937473cab148fc78ec1bbd8e0a99ad2b.tar.gz |
Add -S flag to test for sockets.
PR: bin/7507
Reviewed by: I tested the patch
Submitted by: Stefan `Sec` Zehl sec@42.org
Diffstat (limited to 'bin')
-rw-r--r-- | bin/test/operators.c | 5 | ||||
-rw-r--r-- | bin/test/operators.h | 29 | ||||
-rw-r--r-- | bin/test/test.1 | 6 | ||||
-rw-r--r-- | bin/test/test.c | 5 |
4 files changed, 28 insertions, 17 deletions
diff --git a/bin/test/operators.c b/bin/test/operators.c index d21ec03..9ebce4a 100644 --- a/bin/test/operators.c +++ b/bin/test/operators.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)operators.c 8.3 (Berkeley) 4/2/94"; #endif static const char rcsid[] = - "$Id$"; + "$Id: operators.c,v 1.7 1998/05/18 06:51:53 charnier Exp $"; #endif /* not lint */ /* @@ -66,6 +66,7 @@ const char *const unary_op[] = { "-w", "-x", "-z", + "-S", NULL }; @@ -114,6 +115,7 @@ const char op_priority[] = { 12, 12, 12, + 12, 1, 1, 2, @@ -147,6 +149,7 @@ const char op_argflag[] = { OP_FILE, OP_FILE, OP_STRING, + OP_FILE, 0, 0, 0, diff --git a/bin/test/operators.h b/bin/test/operators.h index 4bf8563..be8620e 100644 --- a/bin/test/operators.h +++ b/bin/test/operators.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)operators.h 8.3 (Berkeley) 4/2/94 - * $Id$ + * $Id: operators.h,v 1.5 1997/02/22 14:06:22 peter Exp $ */ #define NOT 0 @@ -52,20 +52,21 @@ #define ISWRITE 15 #define ISEXEC 16 #define NULSTR 17 +#define ISSOCK 18 -#define FIRST_BINARY_OP 18 -#define OR1 18 -#define OR2 19 -#define AND1 20 -#define AND2 21 -#define STREQ 22 -#define STRNE 23 -#define EQ 24 -#define NE 25 -#define GT 26 -#define LT 27 -#define LE 28 -#define GE 29 +#define FIRST_BINARY_OP 19 +#define OR1 FIRST_BINARY_OP +#define OR2 (FIRST_BINARY_OP + 1) +#define AND1 (FIRST_BINARY_OP + 2) +#define AND2 (FIRST_BINARY_OP + 3) +#define STREQ (FIRST_BINARY_OP + 4) +#define STRNE (FIRST_BINARY_OP + 5) +#define EQ (FIRST_BINARY_OP + 6) +#define NE (FIRST_BINARY_OP + 7) +#define GT (FIRST_BINARY_OP + 8) +#define LT (FIRST_BINARY_OP + 9) +#define LE (FIRST_BINARY_OP + 10) +#define GE (FIRST_BINARY_OP + 11) #define OP_INT 1 /* arguments to operator are integer */ diff --git a/bin/test/test.1 b/bin/test/test.1 index d6125a4..db51abc 100644 --- a/bin/test/test.1 +++ b/bin/test/test.1 @@ -33,7 +33,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)test.1 8.1 (Berkeley) 5/31/93 -.\" $Id: test.1,v 1.5 1997/06/02 06:33:51 charnier Exp $ +.\" $Id: test.1,v 1.6 1998/05/18 06:51:56 charnier Exp $ .\" .Dd May 31, 1993 .Dt TEST 1 @@ -99,6 +99,10 @@ True if .Ar file is a named pipe .Po Tn FIFO Pc . +.It Fl S Ar file +True if +.Ar file +is a socket. .It Fl r Ar file True if .Ar file diff --git a/bin/test/test.c b/bin/test/test.c index 16f8042..df365e8 100644 --- a/bin/test/test.c +++ b/bin/test/test.c @@ -45,7 +45,7 @@ static char const copyright[] = static char sccsid[] = "@(#)test.c 8.3 (Berkeley) 4/2/94"; #endif static const char rcsid[] = - "$Id$"; + "$Id: test.c,v 1.19 1998/05/18 06:51:59 charnier Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -394,6 +394,9 @@ permission: if (fs->stat.st_uid == geteuid()) case ISFIFO: i = S_IFIFO; goto filetype; + case ISSOCK: + i = S_IFSOCK; + goto filetype; filetype: if ((fs->stat.st_mode & S_IFMT) == i && fs->rcode >= 0) true: sp->u.num = 1; else |