From sec@42.org  Thu Aug  6 04:23:01 1998
Received: from matrix.42.org (matrix.42.org [194.246.248.129])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id EAA18299
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 6 Aug 1998 04:22:59 -0700 (PDT)
          (envelope-from sec@42.org)
Received: (from sec@localhost)
	by matrix.42.org (8.8.8/8.8.6) id DAA11134
	(sender <sec>); Wed, 5 Aug 1998 03:21:38 +0200 (CEST)
Message-Id: <199808050121.DAA11134@matrix.42.org>
Date: Wed, 5 Aug 1998 03:21:38 +0200 (CEST)
From: Stefan `Sec` Zehl <sec@42.org>
Reply-To: sec@42.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: test cannot test for sockets
X-Send-Pr-Version: 3.2

>Number:         7507
>Category:       bin
>Synopsis:       test cannot test for sockets
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug  6 04:30:00 PDT 1998
>Closed-Date:    Mon Sep 7 18:59:12 MEST 1998
>Last-Modified:  Mon Sep  7 19:01:57 MEST 1998
>Originator:     Stefan `Sec` Zehl
>Release:        FreeBSD 2.2.6-STABLE i386
>Organization:
>Environment:

2.2-STABLE as of shortly before 2.2.7

>Description:

/bin/test cannot test for unix domain sockets (as used by ssh)

s-w--w--w-  1 root  bin   0 Aug  5 02:51 agent-socket-10654

>How-To-Repeat:

man test

>Fix:
	
Add such operator to /bin/test maybe as '-S' as zsh does ?

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: phk 
State-Changed-When: Thu Aug 6 23:05:12 PDT 1998 
State-Changed-Why:  
good idea, awaiting patch & committer 

From: njs3@doc.ic.ac.uk (Niall Smart)
To: sec@42.org, FreeBSD-gnats-submit@freebsd.org
Cc:  Subject: Re: bin/7507: test cannot test for sockets
Date: Fri, 7 Aug 1998 23:36:29 +0100

 On Aug 5,  3:21am, Stefan `Sec` Zehl wrote:
 } Subject: bin/7507: test cannot test for sockets
 > 
 > >Description:
 > 
 > /bin/test cannot test for unix domain sockets (as used by ssh)
 > 
 > s-w--w--w-  1 root  bin   0 Aug  5 02:51 agent-socket-10654
 > 
 > Add such operator to /bin/test maybe as '-S' as zsh does ?
 
 Suggested fix appended; -S is compatable with *BSD and Solaris.
 
 Note: These patches apply to -current AND -stable cleanly.
       If you apply this manually don't forget to update the
       /bin/[ hard link.
 
 Niall
 
 
 Index: operators.c
 ===================================================================
 RCS file: /cvs/src/bin/test/operators.c,v
 retrieving revision 1.7
 diff -C2 -r1.7 operators.c
 *** operators.c	1998/05/18 06:51:53	1.7
 --- operators.c	1998/08/07 22:26:56
 ***************
 *** 67,70 ****
 --- 67,71 ----
         "-x",
         "-z",
 +       "-S",
         NULL
   };
 ***************
 *** 115,118 ****
 --- 116,120 ----
         12,
         12,
 +       12,
         1,
         1,
 ***************
 *** 148,151 ****
 --- 150,154 ----
         OP_FILE,
         OP_STRING,
 +       OP_FILE,
         0,
         0,
 Index: operators.h
 ===================================================================
 RCS file: /cvs/src/bin/test/operators.h,v
 retrieving revision 1.5
 diff -C2 -r1.5 operators.h
 *** operators.h	1997/02/22 14:06:22	1.5
 --- operators.h	1998/08/07 22:26:56
 ***************
 *** 53,70 ****
   #define	ISEXEC		16
   #define	NULSTR		17
   
 ! #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
   
   
 --- 53,71 ----
   #define	ISEXEC		16
   #define	NULSTR		17
 + #define	ISSOCK		18
   
 ! #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)
   
   
 Index: test.1
 ===================================================================
 RCS file: /cvs/src/bin/test/test.1,v
 retrieving revision 1.6
 diff -C2 -r1.6 test.1
 *** test.1	1998/05/18 06:51:56	1.6
 --- test.1	1998/08/07 22:26:57
 ***************
 *** 100,103 ****
 --- 100,107 ----
   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
 Index: test.c
 ===================================================================
 RCS file: /cvs/src/bin/test/test.c,v
 retrieving revision 1.19
 diff -C2 -r1.19 test.c
 *** test.c	1998/05/18 06:51:59	1.19
 --- test.c	1998/08/07 22:27:00
 ***************
 *** 395,398 ****
 --- 395,401 ----
   		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;
State-Changed-From-To: suspended->closed 
State-Changed-By: cracauer 
State-Changed-When: Mon Sep 7 18:59:12 MEST 1998 
State-Changed-Why:  
Your patch had been committed to -current and will be committed to 
-stable after a short wait period. 

Thanks! 
>Unformatted:
