From josb@cncdsl.com  Sat Nov  3 17:07:50 2001
Return-Path: <josb@cncdsl.com>
Received: from w250.z064001178.sjc-ca.dsl.cnc.net (w250.z064001178.sjc-ca.dsl.cnc.net [64.1.178.250])
	by hub.freebsd.org (Postfix) with SMTP id B780F37B405
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  3 Nov 2001 17:07:49 -0800 (PST)
Received: (qmail 34036 invoked by uid 1000); 4 Nov 2001 01:08:10 -0000
Message-Id: <20011104010810.34035.qmail@lizzy.bugworks.com>
Date: 4 Nov 2001 01:08:10 -0000
From: Jos Backus <josb@cncdsl.com>
Reply-To: Jos@lizzy.bugworks.com,
	Backus <@lizzy.bugworks.com Jos Backus <josb@cncdsl.com>>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: open("/dev/null", O_TRUNC) broken on -current
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         31742
>Category:       kern
>Synopsis:       open("/dev/null", O_TRUNC) broken on -current
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Nov 03 17:10:01 PST 2001
>Closed-Date:    Mon Nov 5 17:00:16 PST 2001
>Last-Modified:  Mon Nov 05 17:00:26 PST 2001
>Originator:     Jos Backus
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
none
>Environment:
System: FreeBSD lizzy.bugworks.com 5.0-CURRENT FreeBSD 5.0-CURRENT #17: Sat Nov 3 15:04:31 PST 2001 jos@lizzy.bugworks.com:/disk0/usr/obj/usr/src/sys/LIZZY i386

lizzy:/tmp% ls -ld /dev
dr-xr-xr-x  4 root  wheel  0 Nov  3 07:15 /dev
lizzy:/tmp% ls -l /dev/null 
crw-rw-rw-  1 root  wheel    2,   2 Nov  3 17:04 /dev/null
lizzy:/tmp% 

>Description:

    open("/dev/null", O_TRUNC) fails with EPERM.

>How-To-Repeat:

lizzy:/tmp% cat c.c
#include <stdio.h>
#include <fcntl.h>

int
main(int argc, char *argv[])
{
    char *s = "string";
    int fd;
    int flag = 0;

    if (argc > 1) flag = O_TRUNC;
    if ((fd = open("/dev/null", O_CREAT|O_WRONLY|flag)) == -1)
        err(1, "open");
    write(fd, s, strlen(s));
    close(fd);
    exit(0);
}
lizzy:/tmp% make c
cc -O -pipe -march=pentiumpro     c.c  -o c
lizzy:/tmp% ./c
lizzy:/tmp% ./c 1
c: open: Operation not permitted
lizzy:/tmp% 

>Fix:
>Release-Note:
>Audit-Trail:

From: "Andrew R. Reiter" <arr@FreeBSD.org>
To: Jos@lizzy.bugworks.com,
	"Backus <@lizzy.bugworks.com Jos Backus" <josb@cncdsl.com>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: kern/31742: open("/dev/null", O_TRUNC) broken on -current
Date: Sat, 3 Nov 2001 23:20:48 -0500 (EST)

 On 4 Nov 2001, Jos Backus wrote:
 :>Quarter:        
 :>Keywords:       
 :>Date-Required:
 :>Class:          sw-bug
 :>Submitter-Id:   current-users
 :>Arrival-Date:   Sat Nov 03 17:10:01 PST 2001
 :>Closed-Date:
 :>Last-Modified:
 :>Originator:     Jos Backus
 :>Release:        FreeBSD 5.0-CURRENT i386
 :>Organization:
 :none
 :>Environment:
 :System: FreeBSD lizzy.bugworks.com 5.0-CURRENT FreeBSD 5.0-CURRENT #17: Sat Nov 3 15:04:31 PST 2001 jos@lizzy.bugworks.com:/disk0/usr/obj/usr/src/sys/LIZZY i386
 :
 :lizzy:/tmp% ls -ld /dev
 :dr-xr-xr-x  4 root  wheel  0 Nov  3 07:15 /dev
 :lizzy:/tmp% ls -l /dev/null 
 :crw-rw-rw-  1 root  wheel    2,   2 Nov  3 17:04 /dev/null
 :lizzy:/tmp% 
 :
 :>Description:
 :
 :    open("/dev/null", O_TRUNC) fails with EPERM.
 :
 :>How-To-Repeat:
 :
 :lizzy:/tmp% cat c.c
 :#include <stdio.h>
 :#include <fcntl.h>
 :
 :int
 :main(int argc, char *argv[])
 :{
 :    char *s = "string";
 :    int fd;
 :    int flag = 0;
 :
 :    if (argc > 1) flag = O_TRUNC;
 :    if ((fd = open("/dev/null", O_CREAT|O_WRONLY|flag)) == -1)
 :        err(1, "open");
 :    write(fd, s, strlen(s));
 :    close(fd);
 :    exit(0);
 :}
 :lizzy:/tmp% make c
 :cc -O -pipe -march=pentiumpro     c.c  -o c
 :lizzy:/tmp% ./c
 :lizzy:/tmp% ./c 1
 :c: open: Operation not permitted
 :lizzy:/tmp% 
 :
 :>Fix:
 :>Release-Note:
 :>Audit-Trail:
 :>Unformatted:
 :
 :To Unsubscribe: send mail to majordomo@FreeBSD.org
 :with "unsubscribe freebsd-bugs" in the body of the message
 :
 
 --------------------------------------------------------------
 Andrew R. Reiter	"Nothing shocks me.  I'm a scientist."
 arr@watson.org			- Indiana Jones
 arr@FreeBSD.org
 --------------------------------------------------------------
 
 

From: "Andrew R. Reiter" <arr@FreeBSD.org>
To: Jos@lizzy.bugworks.com,
	"Backus <@lizzy.bugworks.com Jos Backus" <josb@cncdsl.com>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: kern/31742: open("/dev/null", O_TRUNC) broken on -current
Date: Sat, 3 Nov 2001 23:31:17 -0500 (EST)

 I was unable to reproduce this.  Used the same code and:
 
 root@rakahanga:(test)$ ls -dl /dev
 drwxr-xr-x  4 root  wheel  0 Nov  3 18:00 /dev
 root@rakahanga:(test)$ ls -al /dev/null
 crw-rw-rw-  1 root  wheel    2,   2 Nov  3 21:29 /dev/null
 root@rakahanga:(test)$
 root@rakahanga:(test)$ ./devnull-perm 1
 root@rakahanga:(test)$
 uid=1000
 andrewr@rakahanga:(test)$ ./devnull-perm 1
 andrewr@rakahanga:(test)$
 
 any thoughts?
 
 Andrew
 
 On 4 Nov 2001, Jos Backus wrote:
 :
 :>Number:         31742
 :>Category:       kern
 :>Synopsis:       open("/dev/null", O_TRUNC) broken on -current
 :>Confidential:   no
 :>Severity:       serious
 :>Priority:       high
 :>Responsible:    freebsd-bugs
 :>State:          open
 :>Quarter:        
 :>Keywords:       
 :>Date-Required:
 :>Class:          sw-bug
 :>Submitter-Id:   current-users
 :>Arrival-Date:   Sat Nov 03 17:10:01 PST 2001
 :>Closed-Date:
 :>Last-Modified:
 :>Originator:     Jos Backus
 :>Release:        FreeBSD 5.0-CURRENT i386
 :>Organization:
 :none
 :>Environment:
 :System: FreeBSD lizzy.bugworks.com 5.0-CURRENT FreeBSD 5.0-CURRENT #17: Sat Nov 3 15:04:31 PST 2001 jos@lizzy.bugworks.com:/disk0/usr/obj/usr/src/sys/LIZZY i386
 :
 :lizzy:/tmp% ls -ld /dev
 :dr-xr-xr-x  4 root  wheel  0 Nov  3 07:15 /dev
 :lizzy:/tmp% ls -l /dev/null 
 :crw-rw-rw-  1 root  wheel    2,   2 Nov  3 17:04 /dev/null
 :lizzy:/tmp% 
 :
 :>Description:
 :
 :    open("/dev/null", O_TRUNC) fails with EPERM.
 :
 :>How-To-Repeat:
 :
 :lizzy:/tmp% cat c.c
 :#include <stdio.h>
 :#include <fcntl.h>
 :
 :int
 :main(int argc, char *argv[])
 :{
 :    char *s = "string";
 :    int fd;
 :    int flag = 0;
 :
 :    if (argc > 1) flag = O_TRUNC;
 :    if ((fd = open("/dev/null", O_CREAT|O_WRONLY|flag)) == -1)
 :        err(1, "open");
 :    write(fd, s, strlen(s));
 :    close(fd);
 :    exit(0);
 :}
 :lizzy:/tmp% make c
 :cc -O -pipe -march=pentiumpro     c.c  -o c
 :lizzy:/tmp% ./c
 :lizzy:/tmp% ./c 1
 :c: open: Operation not permitted
 :lizzy:/tmp% 
 :
 :>Fix:
 :>Release-Note:
 :>Audit-Trail:
 :>Unformatted:
 :
 :To Unsubscribe: send mail to majordomo@FreeBSD.org
 :with "unsubscribe freebsd-bugs" in the body of the message
 :
 
 --
 Andrew R. Reiter
 arr@watson.org
 arr@FreeBSD.org
 

From: Poul-Henning Kamp <phk@critter.freebsd.dk>
To: Jos@lizzy.bugworks.com,
	"Backus <@lizzy.bugworks.com Jos Backus" <josb@cncdsl.com>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: kern/31742: open("/dev/null", O_TRUNC) broken on -current 
Date: Sun, 04 Nov 2001 09:31:04 +0100

 I saw something like that a couple of days ago, but it works
 on my current box now.  Is this on an up-to-date -current box ?
 
 Poul-Henning
 
 -- 
 Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
 phk@FreeBSD.ORG         | TCP/IP since RFC 956
 FreeBSD committer       | BSD since 4.3-tahoe    
 Never attribute to malice what can adequately be explained by incompetence.

From: Jos Backus <josb@cncdsl.com>
To: Poul-Henning Kamp <phk@critter.freebsd.dk>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: kern/31742: open("/dev/null", O_TRUNC) broken on -current
Date: Sun, 4 Nov 2001 13:01:42 -0801

 On Sun, Nov 04, 2001 at 09:31:04AM +0100, Poul-Henning Kamp wrote:
 > I saw something like that a couple of days ago, but it works
 > on my current box now.  Is this on an up-to-date -current box ?
 
 Yes. And updating to devfs_vnops.c 1.32 fixed the problem. Thanks again!
 
 -- 
 Jos Backus                 _/  _/_/_/        Santa Clara, CA
                           _/  _/   _/
                          _/  _/_/_/             
                     _/  _/  _/    _/
 josb@cncdsl.com     _/_/   _/_/_/            use Std::Disclaimer;
State-Changed-From-To: open->closed 
State-Changed-By: arr 
State-Changed-When: Mon Nov 5 17:00:16 PST 2001 
State-Changed-Why:  
Already fixed. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31742 
>Unformatted:
