Subject: bin/21568: shutdown gets permission denied error from wall
To: None <gnats-bugs@gnats.netbsd.org>
From: Martin Husemann <martin@duskware.de>
List: netbsd-bugs
Date: 05/14/2003 00:34:02
>Number:         21568
>Category:       bin
>Synopsis:       shutdown gets permission denied error from wall
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 13 22:35:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Martin Husemann
>Release:        NetBSD 1.6T
>Organization:
>Environment:
System: NetBSD night-porter.duskware.de 1.6T NetBSD 1.6T (PORTER) #0: Mon May 12 12:47:55 CEST 2003 martin@night-porter.duskware.de:/usr/src/sys/arch/i386/compile/PORTER i386
Architecture: i386
Machine: i386
>Description:

The test program attached below works when run in an xterm as a normal
user, but fails when run as root:

[/tmp] martin@night-porter > ./blah 
                                                                               
Broadcast Message from martin@night-porter.duskware.de                         
        (/dev/ttyp5) at 0:25 CEST...                                           
                                                                               
test                                                                           

[/tmp] root@night-porter # ./blah 
[/tmp] root@night-porter # wall: /dev/ttyp5: Operation not permitted

The same happens when you run shutdown from within an xterm. (This might be
a kernel problem, I stared a few seconds at a ktrace, and there are some

  1037 wall     CALL  ioctl(0x3,TIOCGETA,0xbfbff6f0)
  1037 wall     RET   ioctl -1 errno 25 Inappropriate ioctl for device
  1037 wall     CALL  close(0x3)

and similar sequences, but that's not realy the expected error message...)

>How-To-Repeat:

Compile and run this as normal user and as root in an xterm:

#include <stdio.h>
#include <unistd.h>

int main()
{
	FILE *f = popen("/usr/bin/wall -n", "w");
	fprintf(f, "test\n");
	fclose(f);
	return 0;
}

>Fix:
n/a
>Release-Note:
>Audit-Trail:
>Unformatted: