Add -S flag to test for sockets.
PR: bin/7507 Reviewed by: I tested the patch Submitted by: Stefan `Sec` Zehl sec@42.org
This commit is contained in:
parent
35923ba71d
commit
23f8fb3d1e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=38914
@ -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,
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user