Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!cadre.dsl.pitt.edu!pitt!unix.cis.pitt.edu!obie.cis.pitt.edu!cmf
From: cmf@obie.cis.pitt.edu (Carl M. Fongheiser)
Newsgroups: comp.unix.ultrix
Subject: Re: su hanging
Message-ID: <19804@unix.cis.pitt.edu>
Date: 2 Oct 89 15:31:15 GMT
References: <2752@decuac.DEC.COM> <772@kl-cs.UUCP>
Sender: news@unix.cis.pitt.edu
Reply-To: cmf@obie.cis.pitt.edu (Carl M. Fongheiser)
Organization: University of Pittsburgh, Computing and Information Services
Lines: 36

In article <772@kl-cs.UUCP> jonathan@cs.keele.ac.uk (Jonathan Knight) writes:
>Su can hang if someone hits ^S on the console.  When su tries to log the
>message 'SU: .....' it hangs waiting for a ^Q on the console.  Very
>irritating, especially if the operators have gone home for the night
>and the machine room is locked up tight....


Well, you could try something like this (WARNING: I haven't tested
this!) :

#include 

main()
{
    int fd;
    char c;

    fd = open("/dev/console", 1);	/* Open the console */
    if (fd < 0) {
	perror("open");
	exit(1);
    }
    c = 'Q' ^ 0100;			/* A ^Q */
    if (ioctl(fd, TIOCSTI, &c) < 0) {
	perror("ioctl");
	exit(1);
    }
}


Note that you'll need to make this setuid root, otherwise the ioctl
will fail.  In fact, if you set up your system correctly, the open
should fail as well!

				Carl Fongheiser
				cmf@unix.cis.pitt.edu