%n open %v 1.3 %c * %l * %b * %d * %f * %t open-1.3.tgz %w Linux %% %setup patch -u -p1 <<'ENDPATCH' diff -ru2N open-1.3/Makefile open-MCC/Makefile --- open-1.3/Makefile Wed May 3 00:11:10 1995 +++ open-MCC/Makefile Sun Aug 18 20:03:57 1996 @@ -1,6 +1,6 @@ CC=gcc -CFLAGS=-O2 -Wall -ansi -LDFLAGS=$(CFLAGS) -s +CFLAGS=-O6 -m386 -Wall -ansi +LDFLAGS= SRC1=open.c @@ -9,7 +9,7 @@ PROG1=open PROG2=switchto -PROGS=$(PROG1) $(PROG2) +PROGS=$(PROG1) $(PROG2) close OPEN=open -MAN=open.1 switchto.1 +MAN=open.1 switchto.1 close.1 BINDIR=/usr/bin MANDIR=/usr/man/man1 @@ -36,6 +36,7 @@ install: $(PROGS) - install -c $(PROGS) $(BINDIR) - install -c $(MAN) $(MANDIR) + install -s -m 555 $(PROGS) $(BINDIR) + install -m 444 $(MAN) $(MANDIR) + gzip -9f /usr/man/man1/open.1 /usr/man/man1/switchto.1 /usr/man/man1/close.1 setuid: diff -ru2N open-1.3/close.1 open-MCC/close.1 --- open-1.3/close.1 Thu Jan 1 01:00:00 1970 +++ open-MCC/close.1 Tue May 2 19:03:24 1995 @@ -0,0 +1,29 @@ +.TH CLOSE 1 "version 1.0" "2 May 1995" "User Commands" +.SH NAME +close \- deallocate unused virtual consoles (VCs). +.SH SYNOPSIS +.B close +[\-v] [vc...] +.SH DESCRIPTION +.B close +can be used to close any or all VC's which are not currently in use. +.BR [vc...] +is an optional space-separated list of VC's to close. If no VC's are +specified, +.B close +will close all unused VC's. +.SS OPTION +.TP +.I "\-v" +Be verbose. +.SH DIAGNOSTICS +In normal operation, +.B close +produces no output, any errors are indications from the kernel that +the requested VC could not be deallocated. +.SH NOTE +Linux kernel version 1.1.54 or above is required. +.SH "SEE ALSO" +.BR open (1). +.SH AUTHOR +todd j. derr diff -ru2N open-1.3/close.c open-MCC/close.c --- open-1.3/close.c Thu Jan 1 01:00:00 1970 +++ open-MCC/close.c Sun Aug 18 20:06:15 1996 @@ -0,0 +1,98 @@ +/* close.c: closes specified or all inactive VC's + * + * todd j. derr + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * v1.0: 2 April 1995 + * + * based on: + * + * open.c: open a vt to run a new command (or shell). + * Copyright (c) 1994 by Jon Tombs + * + */ +#include "open.h" + +const char *CLOSEversion = "close: v1.0: 2 April 1995"; + +#ifndef VTNAME +#error vt device name must be defined in open.h +#endif + +int +main(int argc, char *argv[]) +{ + int fd, opt, i, vtno = -1; + char verbose = FALSE; + struct vt_stat vt; + + while ((opt = getopt(argc, argv, "v")) != -1) { + switch (opt) { + case 'v': + verbose = TRUE; + break; + default: + usage(1); + + } + } + + /* detect if we're running set-id or if we're root. */ + if(geteuid() != getuid() || getegid() != getgid() || !getuid()) + { + if ((fd = open("/dev/console",O_WRONLY,0)) < 0) { + perror("switchto: Can't open /dev/console\n"); + return(3); + } + } + else /* not setuid/setgid */ + { + if ((fd = open("/dev/tty",O_WRONLY,0)) < 0) { + perror("switchto: Can't open /dev/tty\n"); + return(3); + } + + if(ioctl(fd,VT_GETSTATE,&vt) < 0) + { + fprintf(stderr,"This program may only be run on the console.\n"); + close(fd); + exit(1); + } + } + + if(argc==optind) + { + if(verbose) fprintf(stderr,"close: closing all non-active VCs\n"); + if (ioctl(fd, VT_DISALLOCATE, 0) < 0) + perror("VT_DISALLOCATE"); + } + + else for(i=optind; i