How to disable break key on console?

Sakari Jalovaara sja at sirius.hut.fi
Mon Feb 11 05:41:55 AEST 1991


This is for demonstration purposes only.  To really turn off the abort
key, binary-patch the kernel.  I don't use this myself; as a sysadmin
I think the abort key is a very useful feature.
									++sja

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# If this archive is complete, you will see the following message at the end:
#		"End of shell archive."
#
# Contents:
#   Makefile disable-abort.c
#
# Wrapped by sja at sirius.hut.fi on Sun Feb 10 19:39:20 1991
#
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"Makefile\"
else
echo shar: Extracting \"Makefile\" \(342 characters\)
sed "s/^X//" >Makefile <<'END_OF_Makefile'
X#
X# Makefile for disable-abort
X#
X
X# -g or -O.  You can also compile with "make DEBUG=-g"
XDEBUG = -O
X
XCFLAGS = $(DEBUG)
XLINTFLAGS =
XLIBS =
XSHELL = /bin/sh
X
XSRC = disable-abort.c
XOBJ = disable-abort.o
X
Xdisable-abort: $(OBJ)
X	$(CC) $(CFLAGS) $(OBJ) $(LIBS) -o disable-abort
X
Xlint:
X	lint $(LINTFLAGS) $(SRC) $(LIBS)
X
Xclean:
X	rm -f *.o a.out core
END_OF_Makefile
if test 342 -ne `wc -c <Makefile`; then
    echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f disable-abort.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"disable-abort.c\"
else
echo shar: Extracting \"disable-abort.c\" \(1982 characters\)
sed "s/^X//" >disable-abort.c <<'END_OF_disable-abort.c'
X
X/*
X *
X * disable-abort.c -- disable the keyboard abort sequence
X *
X * Sakari Jalovaara (sja at sirius.hut.fi)
X *
X * Public domain -- PLEASE do not distribute any part of this software
X * under the GNU license and do not distribute with any other software
X * that is covered by the GNU license.
X */
X
X#include <stdio.h>
X#include <fcntl.h>
X#include <sys/types.h>
X#include <sundev/kbio.h>
X#include <sundev/kbd.h>
X
X
Xchar *errstr ();
X
Xchar *program;
Xint debug = 0;
X
Xint
Xmain (argc, argv)
Xint argc;
Xchar **argv;
X{
X    struct kiockey key;
X    int fd;
X
X    program = argv[0];
X
X    if (argc != 1)
X	debug++;
X
X    if ((fd = open ("/dev/kbd", O_RDWR)) == -1) {
X	fprintf (stderr, "%s: can't open /dev/kbd: %s\n", program, errstr ());
X	exit (1);
X    }
X
X    key.kio_tablemask = KIOCABORT1;
X    key.kio_station = 1;
X    key.kio_entry = 0;
X    key.kio_string[0] = 0;
X
X    doit (fd, &key);
X
X    key.kio_tablemask = KIOCABORT2;
X    key.kio_station = 1;
X    key.kio_entry = 0;
X    key.kio_string[0] = 0;
X
X    doit (fd, &key);
X
X    exit (0);
X}
X
X
Xdoit (fd, key)
Xint fd;
Xstruct kiockey *key;
X{
X    if (debug) {
X
X	if (ioctl (fd, KIOCGETKEY, key) == -1) {
X	    fprintf (stderr, "%s: can't GETKEY: %s\n", program, errstr ());
X	    exit (1);
X	}
X
X	printf ("mask    %d\n", key->kio_tablemask);
X	printf ("station %d\n", key->kio_station);
X	printf ("entry   %d\n", key->kio_entry);
X	printf ("string  \"%s\"\n", key->kio_string);
X
X    } else {
X
X	if (ioctl (fd, KIOCSETKEY, key) == -1) {
X	    fprintf (stderr, "%s: can't SETKEY: %s\n", program, errstr ());
X	    exit (1);
X	}
X    }
X}
X
X
X
X/*
X * char *errstr()
X *
X * Converts errno to an error message.
X *
X * Usage
X *   fprintf (stderr, "%s: can't open %s: %s\n", program, filename, errstr ());
X *
X */
X
Xchar *
Xerrstr ()
X{
X    extern int errno;
X    extern char *sys_errlist[];
X    extern int sys_nerr;
X    static char unknown[40];
X
X    if (errno < sys_nerr && errno >= 0)
X	return sys_errlist[errno];
X
X    sprintf (unknown, "unknown error %d", errno);
X    return unknown;
X}
END_OF_disable-abort.c
if test 1982 -ne `wc -c <disable-abort.c`; then
    echo shar: \"disable-abort.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0



More information about the Alt.sys.sun mailing list