opermenu sources (1/2)

Steven Freed CIRT sfreed at triton.unm.edu
Mon Jun 17 09:45:22 AEST 1991


This is the first of two shar  files containing the sources to opermenu.

Opermenu is a simple menu based system for unix system operators which
helps to simplify the day to day opertions of local and remote hosts.
It includes facilities for backup, motd, shutdown, reboot, talking to
users, process monitoring, and printer and print queue manipulation.
(the printer stuff has a few bugs at the moment.)

Please consider this a alpha test. It works (mostly) here at UNM, it should
work elsewhere.  Please send me comments, bug reports, bug fixes, questions,
etc. so we can incorperate them into the sources here and make them 
available for all.

The sources are also available via anon ftp from ariel.unm.edu (129.24.8.1)
in pub/opermenu/*.Z

#! /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
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 2)."
# Contents:  COPYING MANIFEST README mdi mdi/Makefile mdi/add.c
#   mdi/externs.c mdi/getinfo.c mdi/mdi.h mdi/readinfo.c mdi/search.c
#   mdi/test.c src src/accounting.c src/atoo.c src/attend_dump.c
#   src/cmds.h src/defs.h src/dequeue.c src/do_dump.c src/fclear.c
#   src/free_space.c src/games.c src/get_level.c src/get_printername.c
#   src/get_tdrive.c src/getans.c src/hasp_log.c src/ibm_log.c
#   src/in.c src/is_a_tty.c src/kill_end_spaces.c src/known_printer.c
#   src/last_backup.c src/list_printers.c src/list_ps.c src/log_dump.c
#   src/lpc.c src/lpc_cmd.c src/machine_info src/main.c
#   src/main_menu.c src/match.c src/motd.c src/naughty.c
#   src/oper_kill.c src/passwd.c src/plot.c src/printer_down.c
#   src/printer_menu.c src/printer_up.c src/printers.c src/read_mail.c
#   src/rje.c src/run.c src/send_mail.c src/set_ids.c src/set_sigs.c
#   src/show_queue.c src/shutdown.c src/talk.c src/wall.c src/who.c
# Wrapped by sfreed at triton.unm.edu on Fri Jun 14 18:00:57 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'COPYING' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'COPYING'\"
else
echo shar: Extracting \"'COPYING'\" \(566 characters\)
sed "s/^X//" >'COPYING' <<'END_OF_FILE'
The University of New Mexico holds the copyright on opermenu.  
X
opermenu may be freely copied, as long as the following conditions are
met:
X
X	+ opermenu is not sold for a profit.
X
X	+ the source code for opermenu is made available along with the
X	  executable
X	
X	+ The copyright and author notices remain intact
X
Note that this follows the basic ideas of the GNU general public license
X
Opermenu was originally written by Kenneth Ingham, and later hacked on by
various persons including, but not limited to: Don Glascock, Van Rauch,
Robert Hare, and Mike Collier.
X
X
END_OF_FILE
if test 566 -ne `wc -c <'COPYING'`; then
    echo shar: \"'COPYING'\" unpacked with wrong size!
fi
# end of 'COPYING'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(2532 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X COPYING                    1	
X MANIFEST                   1	This shipping list
X README                     1	
X mdi                        1	
X mdi/Makefile               1	
X mdi/add.c                  1	
X mdi/externs.c              1	
X mdi/getinfo.c              1	
X mdi/getnamevalue.c         2	
X mdi/mdi.h                  1	
X mdi/readinfo.c             1	
X mdi/search.c               1	
X mdi/test.c                 1	
X src                        1	
X src/Makefile               2	
X src/accounting.c           1	
X src/atoo.c                 1	
X src/attend_dump.c          1	
X src/backup.c               2	
X src/cmds.h                 1	
X src/defs.h                 1	
X src/dequeue.c              1	
X src/do_dump.c              1	
X src/dump_io.c              2	
X src/execute.c              2	
X src/externs.c              2	
X src/failed_dump.c          2	
X src/fclear.c               1	
X src/free_space.c           1	
X src/games.c                1	
X src/get_fsystem.c          2	
X src/get_level.c            1	
X src/get_printername.c      1	
X src/get_tdrive.c           1	
X src/getans.c               1	
X src/hasp_log.c             1	
X src/ibm_log.c              1	
X src/in.c                   1	
X src/init.c                 2	
X src/is_a_tty.c             1	
X src/kill_end_spaces.c      1	
X src/known_printer.c        1	
X src/last_backup.c          1	
X src/line_to_vec.c          2	
X src/list_printers.c        1	
X src/list_ps.c              1	
X src/log_dump.c             1	
X src/lpc.c                  1	
X src/lpc_cmd.c              1	
X src/machine_info           1	
X src/main.c                 1	
X src/main_menu.c            1	
X src/match.c                1	
X src/motd.c                 1	
X src/mtaccess.c             2	
X src/naughty.c              1	
X src/oper_kill.c            1	
X src/passwd.c               1	
X src/plot.c                 1	
X src/printer_down.c         1	
X src/printer_menu.c         1	
X src/printer_up.c           1	
X src/printers.c             1	
X src/ps_open.c              2	
X src/read_mail.c            1	
X src/reroute_printer.c      2	
X src/rje.c                  1	
X src/run.c                  1	
X src/send_mail.c            1	
X src/set_date.c             2	
X src/set_ids.c              1	
X src/set_sigs.c             1	
X src/setdate.c              2	
X src/show_queue.c           1	
X src/shutdown.c             1	
X src/talk.c                 1	
X src/wall.c                 1	
X src/who.c                  1	
END_OF_FILE
if test 2532 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1674 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X Opermenu source consists of two parts, the core opermenu source which 
is generic and *should* run on any Unix platform, and a machine dependant
interface (mdi) library. The mdi specifies a file which is read at 
runtime which tells where everything (that is important to the task at hand)
is on that particular machine. This can be changed at runtime with the 
environment variable MACHINFO which specifies an alternate info file to use.
A sample machine_info file is in src/machine_info. 
X
XFiles you might (probably) want to change:
X
X		mdi/mdi.h
X		   /Makefile
X
X		src/Makefile
X		   /machine_info
X		   /defs.h
X		   /cmds.h
X		   /externs.c
X		   /log_dump.c    (#define LOGFILE)
X
XFor non-root person to use opermenu, it needs to be setuid root in most
cases. Here at UNM we keep it setuid root and executable by owner (root)
and group "oper". 
X
TODO list:
X
X   * All the defines need to be moved to one include file so that changes are
X     easier. This will be done when we do an official release.
X
X   * A general cleaning up of the sources.
X
X   * Fix the printer stuff. It's ugly, it's nasty, it don't work too well.
X     (or not at all...)
X
X   * An X interface
X
X   * Add your's here.....
X
If you do any changes, additions, fixes, etc. etc. to opermenu no matter
how small, please let me know so I can integrate them into the package
here so they are there for everyone in the general releases and
upgrades.
X
Any and all suggestions and comments are welcome. We already know there
is some really ugly code in opermenu, so you don't need to tell us that. ;-)
X
Steve Freed
X2701 Campus Blvd. NE               sfreed at ariel.unm.edu
Albuquerque, NM  87131-6046
X
X(505) 277-3074
X
X
END_OF_FILE
if test 1674 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test ! -d 'mdi' ; then
    echo shar: Creating directory \"'mdi'\"
    mkdir 'mdi'
fi
if test -f 'mdi/Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mdi/Makefile'\"
else
echo shar: Extracting \"'mdi/Makefile'\" \(367 characters\)
sed "s/^X//" >'mdi/Makefile' <<'END_OF_FILE'
OBJS = add.o externs.o getinfo.o getnamevalue.o readinfo.o search.o
CFLAGS =  -O
X
default: libmdi.a
X
libmdi.a: $(OBJS)
X	ar ru libmdi.a $(OBJS)
X	ranlib libmdi.a
X
X$(OBJS): mdi.h
X
lint:
X	lint *.c > Lint.out
X
shar:
X	shar *.c *.h Makefile Config > /tmp/Mdi.shar
X
test: libmdi.a test.c
X	cc -o test test.c libmdi.a
X	./test
X
clean:
X	rm -f *.o libmdi.a test Lint.out Mdi.shar
END_OF_FILE
if test 367 -ne `wc -c <'mdi/Makefile'`; then
    echo shar: \"'mdi/Makefile'\" unpacked with wrong size!
fi
# end of 'mdi/Makefile'
fi
if test -f 'mdi/add.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mdi/add.c'\"
else
echo shar: Extracting \"'mdi/add.c'\" \(923 characters\)
sed "s/^X//" >'mdi/add.c' <<'END_OF_FILE'
X#include "mdi.h"
X
X#define allocate(s)	(s *) malloc(sizeof(s))
X#define reallocate(p, s, t)	(t *)realloc((char *)p, s)
X
X_mdi_add(name, value)
char *name, *value;
X{
X	extern struct entry *_mdi_entries;
X	extern int _mdi_nentries;
X	unsigned size;
X	char *malloc(), *realloc();
X
X	if (_mdi_nentries == 0) {
X		_mdi_entries = allocate(struct entry);
X		_mdi_entries[0].name = name;
X		_mdi_entries[0].value = value;
X		_mdi_nentries++;
X	}
X	else {
X		size = (_mdi_nentries + 1) * sizeof(struct entry);
X		_mdi_entries = reallocate(_mdi_entries, size, struct entry);
X		_mdi_entries[_mdi_nentries].name = name;
X		_mdi_entries[_mdi_nentries].value = value;
X		_mdi_nentries++;
X	}
X}
X
X/*
X * free the array of structures.  Useful in using 'getinfo' on
X * several different files.
X */
X_mdi_zap()
X{
X    if ( _mdi_nentries == 0 ) 
X	return( True );
X
X    free( (char *)_mdi_entries );
X    _mdi_entries = (struct entry *) NULL;
X    _mdi_nentries = 0;
X}
END_OF_FILE
if test 923 -ne `wc -c <'mdi/add.c'`; then
    echo shar: \"'mdi/add.c'\" unpacked with wrong size!
fi
# end of 'mdi/add.c'
fi
if test -f 'mdi/externs.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mdi/externs.c'\"
else
echo shar: Extracting \"'mdi/externs.c'\" \(116 characters\)
sed "s/^X//" >'mdi/externs.c' <<'END_OF_FILE'
X#include "mdi.h"
X
struct entry *_mdi_entries;
int _mdi_haveinfo = False;
int _mdi_nentries = 0;
X
int debug = False;
END_OF_FILE
if test 116 -ne `wc -c <'mdi/externs.c'`; then
    echo shar: \"'mdi/externs.c'\" unpacked with wrong size!
fi
# end of 'mdi/externs.c'
fi
if test -f 'mdi/getinfo.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mdi/getinfo.c'\"
else
echo shar: Extracting \"'mdi/getinfo.c'\" \(803 characters\)
sed "s/^X//" >'mdi/getinfo.c' <<'END_OF_FILE'
X#include "mdi.h"
X
char *setinfo( fname )
char *fname;		/* file name to use */
X{
X	extern int _mdi_haveinfo;
X	extern int debug;
X
X	if ( _mdi_haveinfo ) {
X		if ( debug )
X			printf( "another call to setinfo before endinfo...\n" );
X		endinfo();
X	}
X	_mdi_readinfo( fname );
X	_mdi_haveinfo = True;
X}
X
X
char *getinfo(name)
char *name;		/* string to look for */
X{
X	extern int _mdi_haveinfo;
X	extern int debug;
X
X	char *_mdi_search();
X
X	if (! _mdi_haveinfo) {
X		if (debug) {
X			printf("This is the first call to getinfo.\n");
X			printf("'setinfo' hasn't been called by anyone.\n");
X		}
X		setinfo( NO_USER_SUPPLIED );
X	}
X	else
X		if (debug)
X			printf("'setinfo' has been called by somebody.\n");
X	
X	return _mdi_search(name);
X}
X
X
endinfo()
X{
X    extern int _mdi_haveinfo;
X
X    _mdi_zap();
X    _mdi_haveinfo = False;
X}
END_OF_FILE
if test 803 -ne `wc -c <'mdi/getinfo.c'`; then
    echo shar: \"'mdi/getinfo.c'\" unpacked with wrong size!
fi
# end of 'mdi/getinfo.c'
fi
if test -f 'mdi/mdi.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mdi/mdi.h'\"
else
echo shar: Extracting \"'mdi/mdi.h'\" \(540 characters\)
sed "s/^X//" >'mdi/mdi.h' <<'END_OF_FILE'
X#include <stdio.h>
X
X#define MAX_STR		256
X#define ENV_FILE	"MACHINFO"
X#define DEF_FILE	"/machine_info"
X
X/*
X * if 'getinfo' is called directly, it will tell 'setinfo' to find the
X * file to use.  If 'setinfo' is passed a NULL pointer, then it goes
X * through the regular rigamaroll(sp!) of initializing.  If it is passed
X * a pointer to a string, then it will try to use that string in place
X * of the normal, default files.
X */
X#define NO_USER_SUPPLIED	(char *) NULL
X
X#define True		1
X#define False		0
X
struct entry {
X	char *name, *value;
X};
END_OF_FILE
if test 540 -ne `wc -c <'mdi/mdi.h'`; then
    echo shar: \"'mdi/mdi.h'\" unpacked with wrong size!
fi
# end of 'mdi/mdi.h'
fi
if test -f 'mdi/readinfo.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mdi/readinfo.c'\"
else
echo shar: Extracting \"'mdi/readinfo.c'\" \(1045 characters\)
sed "s/^X//" >'mdi/readinfo.c' <<'END_OF_FILE'
X#include "mdi.h"
X#include <string.h>
X
X_mdi_readinfo( user_supplied )
char *user_supplied;		/* usser-supplied file name (may be NULL) */
X{
X	char *name, *value;
X	char *fname;
X	char *getenv();
X	FILE *in;
X	extern char *sys_errlist[];
X	extern int errno;
X	extern int debug;
X	extern int _mdi_nentries;
X	extern struct entry *_mdi_entries;
X
X	if ( user_supplied != (char *) NULL )
X		fname = user_supplied;		/* use this instead */
X	else
X		fname = getenv(ENV_FILE);	/* look for one */
X
X	if (fname == NULL)
X		fname = DEF_FILE;
X	
X	if (debug)
X		printf("file name is '%s'\n", fname);
X
X	if ((in = fopen(fname, "r")) == NULL) {
X		fprintf(stderr, "Warning: Unable to open '%s'\n", fname);
X		fprintf(stderr, "%s\n\n", sys_errlist[errno]);
X		_mdi_nentries = 0;
X		return;
X	}
X
X	while (_mdi_getnamevalue(&name, &value, in) != EOF) {
X		if (debug)
X			printf("name '%s'\tvalue '%s'\n", name, value);
X		_mdi_add(name, value);
X	}
X
X	if (debug)
X		printf("read in %d entries.\n", _mdi_nentries);
X
X	qsort((char *)_mdi_entries, _mdi_nentries, sizeof(struct entry), 
X		strcmp);
X}
END_OF_FILE
if test 1045 -ne `wc -c <'mdi/readinfo.c'`; then
    echo shar: \"'mdi/readinfo.c'\" unpacked with wrong size!
fi
# end of 'mdi/readinfo.c'
fi
if test -f 'mdi/search.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mdi/search.c'\"
else
echo shar: Extracting \"'mdi/search.c'\" \(545 characters\)
sed "s/^X//" >'mdi/search.c' <<'END_OF_FILE'
X#include "mdi.h"
X
char *
X_mdi_search(name)
char *name;
X{
X	extern int _mdi_nentries, debug;
X	extern struct entry *_mdi_entries;
X	register int i;
X
X	if (debug)
X		printf("looking for '%s'\n", name);
X	/* should use binary search. */
X	for (i=0; i<_mdi_nentries; i++) {
X		if (debug)
X			printf("looking at '%s'\n", _mdi_entries[i].name);
X		if (strcmp(name, _mdi_entries[i].name) == 0) {
X			if (debug)
X				printf("found '%s'\n", _mdi_entries[i].value);
X			return _mdi_entries[i].value;
X		}
X	}
X	
X	if (debug)
X		printf("Found nothing!\n");
X
X	return NULL;
X}
END_OF_FILE
if test 545 -ne `wc -c <'mdi/search.c'`; then
    echo shar: \"'mdi/search.c'\" unpacked with wrong size!
fi
# end of 'mdi/search.c'
fi
if test -f 'mdi/test.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mdi/test.c'\"
else
echo shar: Extracting \"'mdi/test.c'\" \(376 characters\)
sed "s/^X//" >'mdi/test.c' <<'END_OF_FILE'
char *f[] = {
X	"machine",
X	"operating system",
X	"tape drive",
X	"password hashing",
X	0
X};
X
main()
X{
X	int i;
X	char *getinfo();
X
X	setinfo( "Config1" );
X	for (i=0; f[i]; i++)
X		printf("%s: %s (%o)\n", f[i], getinfo(f[i]), getinfo(f[i]));
X	
X	putchar( '\n' );
X
X	setinfo( "Config2" );
X	for (i=0; f[i]; i++)
X		printf("%s: %s (%o)\n", f[i], getinfo(f[i]), getinfo(f[i]));
X
X	exit(0);
X}
END_OF_FILE
if test 376 -ne `wc -c <'mdi/test.c'`; then
    echo shar: \"'mdi/test.c'\" unpacked with wrong size!
fi
# end of 'mdi/test.c'
fi
if test ! -d 'src' ; then
    echo shar: Creating directory \"'src'\"
    mkdir 'src'
fi
if test -f 'src/accounting.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/accounting.c'\"
else
echo shar: Extracting \"'src/accounting.c'\" \(240 characters\)
sed "s/^X//" >'src/accounting.c' <<'END_OF_FILE'
X/* 
X   run accounting.
X*/
X
X#include "defs.h"
X
extern int remote_managed;
X
accounting()
X{
X    if ( remote_managed ) {
X	printf("Since this host is remotely managed, please do not do this.\n");
X	return( 0 );
X    }
X    system( ACCOUNT_PGM );
X}
END_OF_FILE
if test 240 -ne `wc -c <'src/accounting.c'`; then
    echo shar: \"'src/accounting.c'\" unpacked with wrong size!
fi
# end of 'src/accounting.c'
fi
if test -f 'src/atoo.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/atoo.c'\"
else
echo shar: Extracting \"'src/atoo.c'\" \(793 characters\)
sed "s/^X//" >'src/atoo.c' <<'END_OF_FILE'
X/*LINTLIBRARY*/
X/* 
X   atoo: alpha to octal conversion.
X
X   Assumptions:
X
X   Arguments:
X	str: pointer to a string of octal digits.
X
X   Returns:
X	the value of str interpreted as a string of octal digits. 
X
X   Global data used:
X	none.
X
X   Notes:
X	atoo recognizes an optional string of spaces, an optional sign,
X	then a string of octal digits.  it stops on first non octal
X	digit or end of string.
X
X   Author:
X	Kenneth Ingham
X
X   Date:
X	Thu Sep  5 13:26:24 MDT 1985
X*/
X
atoo(str)
char *str;
X{
X	int value = 0, sign;
X
X	/* skip white space */
X	for ( ; *str && (*str == ' ' || *str == '\t'); str++)
X		;
X
X	/* check for sign */
X	sign = (*str == '-' ? -1 : 1);
X
X	/* convert the value */
X	for ( ; *str && (*str >= '0' && *str <= '7'); str++) 
X		value = value * 8 + (*str - '0');
X	
X	return(sign*value);
X}
END_OF_FILE
if test 793 -ne `wc -c <'src/atoo.c'`; then
    echo shar: \"'src/atoo.c'\" unpacked with wrong size!
fi
# end of 'src/atoo.c'
fi
if test -f 'src/attend_dump.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/attend_dump.c'\"
else
echo shar: Extracting \"'src/attend_dump.c'\" \(1365 characters\)
sed "s/^X//" >'src/attend_dump.c' <<'END_OF_FILE'
X/*
X   attend_dump: dump needs attention.  Determine why and send the
X   appropriate information to it (possibly obtained from the user).
X
X   Kenneth Ingham
X*/
X
X#include "defs.h"
X
X#define NEW_TAPE	"Is the new tape mounted"
X#define ABORT		"Do you want to abort?"
X
attend_dump(line, to_dump, cmd, fsystem, host, tapenum, tmach, tdrive)
char *line, *cmd, *fsystem, *host, *tmach, *tdrive;
int to_dump, *tapenum;
X{
X	char volser[MAX_STR], volser2[MAX_STR];
X	char ans[MAX_STR];
X	int len;
X	int tape_slen;
X	int first_time;
X
X	tape_slen = strlen(NEW_TAPE);
X
X	if (strncmp(&line[25], NEW_TAPE, tape_slen) == 0) {
X		printf("  DUMP: NEEDS ATTENTION:  Its time for a new tape.\n");
X		first_time = 1;
X		do {
X			if (!first_time) {
X				printf("There was a mismatch between ");
X				printf("the volsers you entered.  Please\n");
X				printf("try again.\n\n");
X			}
X			printf("What is the volser of the next reel? ");
X			gets(volser);
X			printf("Please re-check the volser and re-enter: ");
X			gets(volser2);
X			first_time = 0;
X		} while (strcmp(volser, volser2) != 0);
X
X		getans("Is the tape mounted & online?", "yes/no", ans);
X		len = strlen(ans);
X		ans[len] = '\n';
X		ans[len+1] = '\0';
X		write(to_dump, ans, strlen(ans));
X
X		(*tapenum)++;
X
X		log_dump(volser, cmd, fsystem, host, *tapenum, tmach, tdrive);
X	}
X	else {
X		puts(line);
X		gets(ans);
X		write(to_dump, ans, strlen(ans));
X	}
X}
END_OF_FILE
if test 1365 -ne `wc -c <'src/attend_dump.c'`; then
    echo shar: \"'src/attend_dump.c'\" unpacked with wrong size!
fi
# end of 'src/attend_dump.c'
fi
if test -f 'src/cmds.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/cmds.h'\"
else
echo shar: Extracting \"'src/cmds.h'\" \(381 characters\)
sed "s/^X//" >'src/cmds.h' <<'END_OF_FILE'
X/* 
X   numbers here correspond to 1+index into array "choices" defined in
X   externs.c
X*/
X
void exit(), shutdown(), list_ps(), oper_kill(), show_queue(), dequeue();
void talk(), wall(), send_mail(), last_backup(), backup(), plot(), rje();
void games(), ibm_log(), hasp_log(), mtaccess(), set_date(), main_menu();
void printers(), lpc_cmd(), printer_down(), printer_up(),reroute();
END_OF_FILE
if test 381 -ne `wc -c <'src/cmds.h'`; then
    echo shar: \"'src/cmds.h'\" unpacked with wrong size!
fi
# end of 'src/cmds.h'
fi
if test -f 'src/defs.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/defs.h'\"
else
echo shar: Extracting \"'src/defs.h'\" \(1422 characters\)
sed "s/^X//" >'src/defs.h' <<'END_OF_FILE'
X/*
X * defs.h: global definitions for the oper program
X */
X
X#include <stdio.h>
X#include <pwd.h>
X#include <fstab.h>
X#include <sys/types.h>
X#include <signal.h>
X#include <sys/stat.h>
X#include <errno.h>
X#include <ctype.h>
X#include <strings.h>
X#include <sys/wait.h>       
X#include <sys/time.h>      
X#include <sys/resource.h> 
X
X#define MAX_STR		256
X#define MAX_ARGS	256
X#define MAX_PRINTER	30
X#define True 1
X#define False 0
X
X/* structure for main menu commands */
struct cmd_st {
X	char *desc;	/* what the oper sees as the meaning of the cmd */
X	void (*func)();	/* func to do the work (if any; NULL otherwise) */
X	int type;	/* done directly with run or system.  Which? */
X	char *cstr;	/* command string to pass to run or system */
X};
X
X/* structure for printer commands */
struct pcmd_st {
X	char *desc;	/* what the oper sees as the meaning of the cmd */
X	void (*func)();	/* func to do the work */
X	char *cmd_arg;	/* argument to routine which does the work */
X};
X
X#define PROC		0
X#define RUN		1
X#define SYSTEM		2
X
X#define PRINTER_PIPE	"grep '|' /etc/printcap | grep -v '#' | sed -e 's/|/, /g' -e 's/:/ /' -e 's/\\\\//'"
X
X#define UID		0
X#define GID		1
X
X#define OPER	"oper"
X#define MTACCT	"/usr/adm/mtacct"
X
char *getwd(), *getinfo();
X
X#define DOMAIN_NAME	".unm.edu"
X
X# define TAPELIST "DUMP_TO"
struct tapedrive {
X    char td_dumpprog[50];
X    char td_host[50];
X    char td_drive[50];
X    char td_flags[50];
X    int td_density;
X};
END_OF_FILE
if test 1422 -ne `wc -c <'src/defs.h'`; then
    echo shar: \"'src/defs.h'\" unpacked with wrong size!
fi
# end of 'src/defs.h'
fi
if test -f 'src/dequeue.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/dequeue.c'\"
else
echo shar: Extracting \"'src/dequeue.c'\" \(730 characters\)
sed "s/^X//" >'src/dequeue.c' <<'END_OF_FILE'
X/*
X   dequeue: remove an entry from the lpr queue.  First find out which
X   printers we know about by means of a complex pipeline, then allow
X   only those printers to be specified.
X
X
X*/
X
X#include "defs.h"
X
void
dequeue()
X{
X	char ans[MAX_STR];
X	char pname[MAX_STR];
X	char cmd[MAX_STR];
X	char *lprm_pgm, *lpq_pgm;
X
X	if ((lprm_pgm = getinfo("LPRM_PGM")) == NULL ||
X	    (lpq_pgm  = getinfo("LPQ_PGM"))  == NULL)  {
X		printf("Sorry, can't dequeue print jobs on this machine.\n");
X		return;
X	}
X	
X	get_printername(pname);
X
X	sprintf(cmd,"%s -P%s", lpq_pgm, pname);
X	run(cmd);
X
X	printf("\nWhich job to remove [press return for none]? ");
X	gets(ans);
X
X	if (ans[0]) {
X		sprintf(cmd,"%s -P%s %s", lprm_pgm, pname, ans);
X		system(cmd);
X	}
X}
END_OF_FILE
if test 730 -ne `wc -c <'src/dequeue.c'`; then
    echo shar: \"'src/dequeue.c'\" unpacked with wrong size!
fi
# end of 'src/dequeue.c'
fi
if test -f 'src/do_dump.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/do_dump.c'\"
else
echo shar: Extracting \"'src/do_dump.c'\" \(905 characters\)
sed "s/^X//" >'src/do_dump.c' <<'END_OF_FILE'
X/*
X   do_dump: run the dump, reading the output and looking for special
X   magic cookies.  When we notice that dump wants a new tape, we also
X   collect info about the ibm volser from the oper in addition to
X   finding out if it is mounted yet.
X
X   Kenneth Ingham
X*/
X
X#include "defs.h"
X
X#define DUMP_ATTN	"  DUMP: NEEDS ATTENTION:"
X
do_dump(cmd, fsystem, host, tmach, tdrive)
char *cmd, *fsystem, *host, *tmach, *tdrive;
X{
X	int to_dump, from_dump, nl;
X	int dump_attn_len, i, tapenum;
X	char buf[MAX_STR];
X	char *lines[MAX_ARGS];
X
X	tapenum = 0;
X	dump_attn_len = strlen(DUMP_ATTN);
X	dump_io(cmd, &to_dump, &from_dump);
X
X	while (read(from_dump, buf, MAX_STR) != 0) {
X		nl = line_to_vec(buf, lines, "\n");
X		for (i=0; i<nl; i++) {
X			if (strncmp(lines[i], DUMP_ATTN, dump_attn_len) == 0)
X				attend_dump(lines[i], to_dump, cmd, fsystem,
X				host, &tapenum, tmach, tdrive);
X			else
X				puts(lines[i]);
X		}
X	}
X}
END_OF_FILE
if test 905 -ne `wc -c <'src/do_dump.c'`; then
    echo shar: \"'src/do_dump.c'\" unpacked with wrong size!
fi
# end of 'src/do_dump.c'
fi
if test -f 'src/fclear.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/fclear.c'\"
else
echo shar: Extracting \"'src/fclear.c'\" \(1027 characters\)
sed "s/^X//" >'src/fclear.c' <<'END_OF_FILE'
X/* 
X   fclear: clear a lockfile from the large code filter system.
X
X   Kenneth Ingham
X
X   Wed Jul 24 12:56:33 MDT 1985
X*/
X
X#include "defs.h"
X
extern int machine;		/* the number of the machine i'm currently on */
extern int machflags[];		/* list of flags for all machines */
X
fclear()
X{
X	char line[MAX_STR], ans[MAX_STR], programs[50][MAX_STR];
X	FILE *fopen(), *limfile;
X	int i, n;
X
X    if ( (machflags[machine] & MF_RMANAGED) != 0 ) {
X	printf("Since this host is remotely managed, please do not do this.\n");
X	return( 0 );
X    }
X
X	if ((limfile = fopen(LIMIT_FILE, "r")) == NULL) {
X		printf("Unable to open '%s'\n", LIMIT_FILE);
X		return;
X	}
X
X	for (i=0; fscanf(limfile, "%s\t%d", programs[i], &n) == 2; i++)
X		printf("%d - %s\n", i, programs[i]);
X
X	do {
X		printf("Which lockfile needs to be removed (0-%d)? ", i-1);
X		if (gets(ans) == NULL) {
X			printf("fclear: aborting.\n");
X			return;
X		}
X		n = atoi(ans);
X	} while (n < 0 || n >= i);
X
X	sprintf(line, "%s %s", FCLEAR_PGM, programs[n]);
X	printf("%s\n", line);
X	system(line);
X}
END_OF_FILE
if test 1027 -ne `wc -c <'src/fclear.c'`; then
    echo shar: \"'src/fclear.c'\" unpacked with wrong size!
fi
# end of 'src/fclear.c'
fi
if test -f 'src/free_space.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/free_space.c'\"
else
echo shar: Extracting \"'src/free_space.c'\" \(129 characters\)
sed "s/^X//" >'src/free_space.c' <<'END_OF_FILE'
X/* 
X    free_space: show how much free space there is left on the disks.
X*/
X
X#include "defs.h"
X
free_space()
X{
X	run(FREE_PGM);
X}
END_OF_FILE
if test 129 -ne `wc -c <'src/free_space.c'`; then
    echo shar: \"'src/free_space.c'\" unpacked with wrong size!
fi
# end of 'src/free_space.c'
fi
if test -f 'src/games.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/games.c'\"
else
echo shar: Extracting \"'src/games.c'\" \(962 characters\)
sed "s/^X//" >'src/games.c' <<'END_OF_FILE'
X/*
X   games: change the status of the games.
X*/
X
X#include "defs.h"
X
void
games()
X{
X	struct stat st_buf;
X	char ans[MAX_STR], *gets();
X	int rc;
X	char *play_pgm, *play_mode;
X
X	if ((play_pgm = getinfo("PLAY_PGM")) == NULL || 
X	    (play_mode= getinfo("PLAY_MODE")) == NULL) {
X		printf("Can't change status of games on this machine.\n");
X		return;
X	}
X
X	/*
X	   check to see what the protection bits on the play program
X	   are.  Problems occur if 'stat' blows up.
X	*/
X	rc = stat(play_pgm, &st_buf);
X	if (rc < 0) {
X		perror("games: stat");
X		printf("Please write an IR about this.\n");
X		return;
X	}
X
X	printf("The games are currently %s.\n", 
X		((st_buf.st_mode & 0777) == 0 ? "down" : "up"));
X
X	getans("Change? [y/n] ", "y/n", ans);
X
X	if (ans[0] == 'y') {
X		if ((st_buf.st_mode & 0777) == 0 )
X			rc = chmod(play_pgm, atoo(play_mode));
X		else
X			rc = chmod(play_pgm, 0);
X		if (rc != 0) {
X			perror("games: chmod");
X			printf("Please write an IR about this\n");
X		}
X	}
X}
END_OF_FILE
if test 962 -ne `wc -c <'src/games.c'`; then
    echo shar: \"'src/games.c'\" unpacked with wrong size!
fi
# end of 'src/games.c'
fi
if test -f 'src/get_level.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/get_level.c'\"
else
echo shar: Extracting \"'src/get_level.c'\" \(453 characters\)
sed "s/^X//" >'src/get_level.c' <<'END_OF_FILE'
X/*
X   get_level: get the dump level that we are to use.
X*/
X
X#include "defs.h"
X
extern char *getinfo();
X
get_level()
X{
X	char *str_level;
X	int level;
X	char ans[MAX_STR];
X
X	if ( (str_level=getinfo("ALLBACKUPSARE")) != (char *) NULL )
X		printf( "\nWe'll be doing a level-%d backup.\n",
X							level=atoi(str_level) );
X	else 
X		do {
X			printf("\nDump level: [0-9] ");
X			gets(ans);
X			level = atoi(ans);
X		} while (level < 0 || level > 9);
X
X	return level;
X}
END_OF_FILE
if test 453 -ne `wc -c <'src/get_level.c'`; then
    echo shar: \"'src/get_level.c'\" unpacked with wrong size!
fi
# end of 'src/get_level.c'
fi
if test -f 'src/get_printername.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/get_printername.c'\"
else
echo shar: Extracting \"'src/get_printername.c'\" \(966 characters\)
sed "s/^X//" >'src/get_printername.c' <<'END_OF_FILE'
X/*
X   get_printername: go through /etc/printcap, gathering printer names.
X   Get user to select one.
X*/
X
X#include "defs.h"
X
extern FILE *popen();
X
get_printername(pname)
char *pname;
X{
X	FILE *pr;
X	int i, nprinters, printer, ok;
X	char printers[MAX_PRINTER][MAX_STR], ans[MAX_STR];
X	char *tonull;
X
X	if (!list_printers(printers, &nprinters))
X		return; /* couldn't get a list of printers */
X
X	ans[0] = '\0';
X	do {
X		printf("Printer name? [? for list] ");
X		fgets(ans, MAX_STR, stdin);
X		kill_end_spaces(ans);
X		if (ans[0] == '?') {
X			printf("The printers are:\n\n");
X			for (i=0; i<nprinters; i++) {
X				puts(printers[i]);
X				if (i != 0 && i % 22 == 0) {
X					printf("Press return for more:");
X					(void) gets(ans);
X				}
X			}
X			printf("\n");
X		}
X		else if (!(ok = known_printer(ans, printers, nprinters))) {
X			printf("Unknown printer name '%s'.\n", ans);
X			printf("Use ? to get a list.\n");
X		}
X	} while (!ans[0] || ans[0] == '?' || !ok);
X
X	strcpy(pname, ans);
X}
END_OF_FILE
if test 966 -ne `wc -c <'src/get_printername.c'`; then
    echo shar: \"'src/get_printername.c'\" unpacked with wrong size!
fi
# end of 'src/get_printername.c'
fi
if test -f 'src/get_tdrive.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/get_tdrive.c'\"
else
echo shar: Extracting \"'src/get_tdrive.c'\" \(634 characters\)
sed "s/^X//" >'src/get_tdrive.c' <<'END_OF_FILE'
X/*
X   get_tdrive: select a tape drive & density.
X*/
X
X#include "defs.h"
X
struct tapedrive *get_tdrive()
X{
X	extern struct tapedrive tapelist[];
X	extern int ntapedrives;
X	char ans[MAX_STR];
X	int i;
X	int dchoice;
X
X	/*
X	 * ok, now find out what (legal) density they wanna use:
X	 */
X	do {
X		putchar( '\n' );
X		for ( i=0; i < ntapedrives; i++ )
X			printf( "  %d) %s's %s at %d bpi\n", i+1,
X				tapelist[i].td_host, tapelist[i].td_drive,
X				tapelist[i].td_density );
X
X		printf( "\nEnter number for desired density: " );
X		gets(ans);
X		dchoice = atoi(ans);
X	} while ( dchoice <= 0 || dchoice > ntapedrives );
X
X	return &tapelist[dchoice-1];
X}
END_OF_FILE
if test 634 -ne `wc -c <'src/get_tdrive.c'`; then
    echo shar: \"'src/get_tdrive.c'\" unpacked with wrong size!
fi
# end of 'src/get_tdrive.c'
fi
if test -f 'src/getans.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/getans.c'\"
else
echo shar: Extracting \"'src/getans.c'\" \(1011 characters\)
sed "s/^X//" >'src/getans.c' <<'END_OF_FILE'
X/* 
X   getans: get an answer after printing out a question.  accept only an
X   answer from selection, a "SEP" separated list of choices.  Return
X   result.
X*/
X
X#include "defs.h"
X
X#define SEP '/'	/* the character used to separate the selections */
X
getans(question, selection, result)
char *question, *selection, *result;
X{
X	char selects[MAX_STR], *strcpy(), *gets();
X	int strings[MAX_STR];
X	register int i, j;
X
X	/* 
X	   copy selection so that when we change it we don't change the
X	   copy passed to us.  Then go through, changing slashes to
X	   nulls and setting up pointers to the beginnings of each
X	   string.
X	*/
X	j = 0;
X	strcpy(selects, selection);
X	strings[j++] = 0;
X	for (i=0; selects[i]; i++)
X		if (selects[i] == SEP) {
X			selects[i] = '\0';
X			strings[j++] = i+1;
X		}
X	strings[j] = -1;
X
X	printf("%s", question);
X	gets(result);
X	
X	while (!in(result, strings, selects)) {
X		printf("'%s' is not a valid response.  Choose from: %s\n",
X			result, selection);
X		printf("%s", question);
X		gets(result);
X	}
X}
END_OF_FILE
if test 1011 -ne `wc -c <'src/getans.c'`; then
    echo shar: \"'src/getans.c'\" unpacked with wrong size!
fi
# end of 'src/getans.c'
fi
if test -f 'src/hasp_log.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/hasp_log.c'\"
else
echo shar: Extracting \"'src/hasp_log.c'\" \(239 characters\)
sed "s/^X//" >'src/hasp_log.c' <<'END_OF_FILE'
X/* 
X    hasp_log: show the hasplog.
X*/
X
X#include "defs.h"
X
void
hasp_log()
X{
X	extern int machine, machflags[];
X
X	if ( machflags[machine] & MF_HASRJE )
X		run(HASP_LOG_PGM);
X	else
X		printf("\n\nThere is no rje link on this machine.\n\n");
X}
END_OF_FILE
if test 239 -ne `wc -c <'src/hasp_log.c'`; then
    echo shar: \"'src/hasp_log.c'\" unpacked with wrong size!
fi
# end of 'src/hasp_log.c'
fi
if test -f 'src/ibm_log.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/ibm_log.c'\"
else
echo shar: Extracting \"'src/ibm_log.c'\" \(235 characters\)
sed "s/^X//" >'src/ibm_log.c' <<'END_OF_FILE'
X/* 
X    ibm_log: show the ibmlog.
X*/
X
X#include "defs.h"
X
void
ibm_log()
X{
X	extern int machine, machflags[];
X
X	if ( machflags[machine] & MF_HASRJE )
X		run(IBM_LOG_PGM);
X	else
X		printf("\n\nThere is no rje link on this machine.\n\n");
X}
END_OF_FILE
if test 235 -ne `wc -c <'src/ibm_log.c'`; then
    echo shar: \"'src/ibm_log.c'\" unpacked with wrong size!
fi
# end of 'src/ibm_log.c'
fi
if test -f 'src/in.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/in.c'\"
else
echo shar: Extracting \"'src/in.c'\" \(348 characters\)
sed "s/^X//" >'src/in.c' <<'END_OF_FILE'
X/* 
X   in: utility routine called by getans to find if the answer is in the
X   list of choices.  return True or False.
X*/
X
X#include "defs.h"
X
in(result, strings, selects)
char *result, *selects;
int strings[];
X{
X	register int i;
X
X	for (i=0; strings[i] != -1; i++)
X		if (strcmp(&selects[strings[i]], result) == 0)
X			return True;
X	
X	return False;
X}
END_OF_FILE
if test 348 -ne `wc -c <'src/in.c'`; then
    echo shar: \"'src/in.c'\" unpacked with wrong size!
fi
# end of 'src/in.c'
fi
if test -f 'src/is_a_tty.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/is_a_tty.c'\"
else
echo shar: Extracting \"'src/is_a_tty.c'\" \(1014 characters\)
sed "s/^X//" >'src/is_a_tty.c' <<'END_OF_FILE'
X/* 
X   is_a_tty: is the string passed a valid ttyname?
X
X   accept strings of the form:
X	15
X	tty15
X	/dev/tty15
X   
X   After making sure that the name is one of the forms above, make sure
X   that it really exists by doing a 'stat' on it.  
X   
X   When an invalid ttyname is given, show possible selections.
X*/
X
X#include "defs.h"
X
X#define LS_TTYS_CMD	"ls tty?*"
X
is_a_tty(str)
char *str;
X{
X	char name[MAX_STR], *strcpy(), cwd[MAX_STR];
X	struct stat stat_buf;
X	int rc;
X
X	if (strlen(str) == 2) /* just last two chars of ttyname */
X		sprintf(name,"/dev/tty%s",str);
X	else if ((strncmp(str,"/dev/tty",8) == 0) && (strlen(str) > 8))
X		strcpy(name,str);
X	else if ((strncmp(str,"tty",3) == 0) && (strlen(str) > 3))
X		sprintf(name,"/dev/%s",str);
X	else
X		strcpy(name,"Bad tty name");
X
X	rc = stat(name, &stat_buf);
X
X	if (rc != 0) {
X		if(str[0] != '?')
X		    printf("That is not a valid ttyname.  Valid names are:\n");
X		(void) getwd(cwd);
X		chdir("/dev");
X		run(LS_TTYS_CMD);
X		chdir(cwd);
X		return False;
X	}
X
X	return True;
X}
END_OF_FILE
if test 1014 -ne `wc -c <'src/is_a_tty.c'`; then
    echo shar: \"'src/is_a_tty.c'\" unpacked with wrong size!
fi
# end of 'src/is_a_tty.c'
fi
if test -f 'src/kill_end_spaces.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/kill_end_spaces.c'\"
else
echo shar: Extracting \"'src/kill_end_spaces.c'\" \(253 characters\)
sed "s/^X//" >'src/kill_end_spaces.c' <<'END_OF_FILE'
X/*
X   kill_end_spaces: remove any white space at the end of the given
X   string.
X
X   Kenneth Ingham
X*/
X
X#include "defs.h"
X
kill_end_spaces(str)
char str[];
X{
X	int len;
X
X	len = strlen(str)-1;
X	while (isspace(str[len])) {
X		str[len] = '\0';
X		len--;
X	}
X}
END_OF_FILE
if test 253 -ne `wc -c <'src/kill_end_spaces.c'`; then
    echo shar: \"'src/kill_end_spaces.c'\" unpacked with wrong size!
fi
# end of 'src/kill_end_spaces.c'
fi
if test -f 'src/known_printer.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/known_printer.c'\"
else
echo shar: Extracting \"'src/known_printer.c'\" \(857 characters\)
sed "s/^X//" >'src/known_printer.c' <<'END_OF_FILE'
X/*
X   known_printer: return whether or not the printer entered is in the
X   list of printers.  We assume that the printer names are separated by
X   commas.
X
X   Kenneth Ingham
X*/
X
X#include "defs.h"
X
X/* this macro evaluates its arguments twice */
X#define min(a,b)	( (a) < (b) ? (a) : (b) )
X
known_printer(ans, printers, nprinters)
char ans[], printers[MAX_PRINTER][MAX_STR];
int nprinters;
X{
X	int i, alen, plen, len;
X	char *begin, *next;
X
X	alen = strlen(ans);
X
X	/* printer names are several per line, separated by commas */
X	for (i=0; i<nprinters; i++) {
X		begin = printers[i];
X		do {
X			next = index(begin, ',');
X			if (next != NULL)
X				plen = next - begin;
X			else
X				plen = strlen(begin);
X			len = min(alen, plen);
X			if (strncmp(begin, ans, len) == 0 && alen == plen)
X				return True;
X			begin = next + 2;
X		} while (next != NULL);
X	}
X
X	return False;
X}
END_OF_FILE
if test 857 -ne `wc -c <'src/known_printer.c'`; then
    echo shar: \"'src/known_printer.c'\" unpacked with wrong size!
fi
# end of 'src/known_printer.c'
fi
if test -f 'src/last_backup.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/last_backup.c'\"
else
echo shar: Extracting \"'src/last_backup.c'\" \(328 characters\)
sed "s/^X//" >'src/last_backup.c' <<'END_OF_FILE'
X/* 
X   last backup: show the last dump dates 
X*/
X
X#include "defs.h"
X
void
last_backup()
X{
X	char cmd[MAX_STR], *dump_pgm;
X
X	if ((dump_pgm = getinfo("DUMPDATES_PGM")) == NULL) {
X		printf("Sorry, can't do this here.\n");
X		return;
X	}
X
X	printf( "(This may take a minute or two...\n\n" );
X	sprintf(cmd,"%s W",dump_pgm);
X	run(cmd);
X}
END_OF_FILE
if test 328 -ne `wc -c <'src/last_backup.c'`; then
    echo shar: \"'src/last_backup.c'\" unpacked with wrong size!
fi
# end of 'src/last_backup.c'
fi
if test -f 'src/list_printers.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/list_printers.c'\"
else
echo shar: Extracting \"'src/list_printers.c'\" \(586 characters\)
sed "s/^X//" >'src/list_printers.c' <<'END_OF_FILE'
X/* 
X   list_printers: get a list of the printers known by this system by
X   looking through printcap.
X
X   Kenneth Ingham
X*/
X
X#include "defs.h"
X
list_printers(printers, nprinters)
char printers[MAX_PRINTER][MAX_STR];
int *nprinters;
X{
X	FILE *pr, *popen();
X	int i;
X
X	if ((pr = popen(PRINTER_PIPE, "r")) == NULL) {
X		printf("Unable to execute printer finding pipeline.\n");
X		printf("Please inform the person who maintains this\n");
X		printf("program.");
X		return False;
X	}
X
X	for (i=0; fgets(printers[i], MAX_STR, pr); i++)
X		kill_end_spaces(printers[i]);
X	*nprinters = i;
X	return True;
X}
END_OF_FILE
if test 586 -ne `wc -c <'src/list_printers.c'`; then
    echo shar: \"'src/list_printers.c'\" unpacked with wrong size!
fi
# end of 'src/list_printers.c'
fi
if test -f 'src/list_ps.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/list_ps.c'\"
else
echo shar: Extracting \"'src/list_ps.c'\" \(865 characters\)
sed "s/^X//" >'src/list_ps.c' <<'END_OF_FILE'
X/*
X   list_ps: perform a ps command.
X*/
X
X#include "defs.h"
X
void
list_ps()
X{
X	char cmd[MAX_STR], ans[MAX_STR], *gets();
X	int len;
X	char *pager, *ps_pgm;
X
X	if ((ps_pgm = getinfo("PS_PGM")) == NULL) {
X		printf("Sorry, I am unable to do that on this machine.\n");
X		return;
X	}
X
X	if ((pager = getinfo("PAGER")) == NULL)
X		printf("Warning, I am unable to find a pager to use.\n");
X
X	getans("List all processes or just one terminal's? [a/t] ", "a/t", ans);
X
X	if (ans[0] == 'a') {
X		if (pager)
X			sprintf(cmd,"%s -aug | %s",ps_pgm,pager);
X		else
X			sprintf(cmd,"%s -aug",ps_pgm);
X		run(cmd);
X	}
X	else if (ans[0] == 't') {
X		do {
X			printf("Which terminal ('?' for list)? ");
X			gets(ans);
X		} while (! is_a_tty(ans) );
X		len = strlen(ans);
X		/* what ps wants is the last two chars of tty name */
X		sprintf(cmd,"%s ut%c%c\n",ps_pgm,ans[len-2],ans[len-1]);
X		run(cmd);
X	}
X}
END_OF_FILE
if test 865 -ne `wc -c <'src/list_ps.c'`; then
    echo shar: \"'src/list_ps.c'\" unpacked with wrong size!
fi
# end of 'src/list_ps.c'
fi
if test -f 'src/log_dump.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/log_dump.c'\"
else
echo shar: Extracting \"'src/log_dump.c'\" \(716 characters\)
sed "s/^X//" >'src/log_dump.c' <<'END_OF_FILE'
X/*
X  log_dump: record the info about this tape in the log file (later we
X  will actually pass info to the IBM).
X
X  Knneth Ingham
X*/
X
X#include "defs.h"
X
X#define LOGFILE		"/usr/local/adm/dump.log"
X
log_dump(volser, cmd, fsystem, host, tapenum, tmach, tdrive)
char *volser, *cmd, *fsystem, *host, *tmach, *tdrive;
int tapenum;
X{
X	FILE *log;
X	long ltime, time();
X
X	if ((log=fopen(LOGFILE,"a")) == NULL) {
X		printf("Warning: unable to open dump log file ('%s').\n",
X			LOGFILE);
X		printf("Continuing with dump.\n");
X		return;
X	}
X
X	ltime = time((long *)0);
X	fprintf(log, "(%s) %s was tape %d of the dump of %s on %s to %s:%s",
X		cmd, volser, tapenum, fsystem, host, tmach, tdrive);
X	fprintf(log, "at %s",ctime(&ltime));
X}
END_OF_FILE
if test 716 -ne `wc -c <'src/log_dump.c'`; then
    echo shar: \"'src/log_dump.c'\" unpacked with wrong size!
fi
# end of 'src/log_dump.c'
fi
if test -f 'src/lpc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/lpc.c'\"
else
echo shar: Extracting \"'src/lpc.c'\" \(240 characters\)
sed "s/^X//" >'src/lpc.c' <<'END_OF_FILE'
X/* 
X   lpc: modify printer status
X*/
X
X#include "defs.h"
X
lpc()
X{
X    extern int remote_managed;
X
X    if ( remote_managed ) {
X	printf("Since this host is remotely managed, please do not do this.\n");
X	return( 0 );
X    }
X
X	system(LPC_PGM);
X}
END_OF_FILE
if test 240 -ne `wc -c <'src/lpc.c'`; then
    echo shar: \"'src/lpc.c'\" unpacked with wrong size!
fi
# end of 'src/lpc.c'
fi
if test -f 'src/lpc_cmd.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/lpc_cmd.c'\"
else
echo shar: Extracting \"'src/lpc_cmd.c'\" \(423 characters\)
sed "s/^X//" >'src/lpc_cmd.c' <<'END_OF_FILE'
X/*
X   lpc_cmd: allow the opers to do an lpc command.  Our argument tells us
X   which command to do.  We just grab printer name and place it after
X   the command and the execute it.
X
X   Kenneth Ingham
X*/
X
X#include "defs.h"
X
void
lpc_cmd(cmd)
char *cmd;
X{
X	char pname[MAX_STR];
X	char to_run[MAX_STR];
X	extern char *lpc_pgm;
X
X	get_printername(pname);
X
X	sprintf(to_run, "%s %s \"%s\"", lpc_pgm, cmd, pname);
X	system(to_run);
X}
END_OF_FILE
if test 423 -ne `wc -c <'src/lpc_cmd.c'`; then
    echo shar: \"'src/lpc_cmd.c'\" unpacked with wrong size!
fi
# end of 'src/lpc_cmd.c'
fi
if test -f 'src/machine_info' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/machine_info'\"
else
echo shar: Extracting \"'src/machine_info'\" \(1063 characters\)
sed "s/^X//" >'src/machine_info' <<'END_OF_FILE'
X#
X# This is the machine configuration file used by the 'oper' program.
X# Note that #'s are comments, and comments are terminated by new lines.
X#
X# 'oper' looks for the name of a corresponding program to execute.  So,
X# to turn off an option, comment out (BUT DO NOT REMOVE!!!!) the line that
X# defines the corresponding program.
X#
X# For a remote site, uncomment & correctly fill in the string:
X#REMOTE_MGR=root at vaxpopuli
X#
DOC=doc at hydra
X#
X#LDUMP_PGM=/etc/dump
X#RDUMP_PGM=/etc/rdump
X#
X# Where you can dump to:
DUMP_TO=carina,/dev/rmt0h,6250,/etc/rdump,o:oberon,/dev/rmt8,6250,/etc/rdump,o
X#DUMP_TO=triton,/dev/rmt0h,6250,/etc/dump,
DUMPDATES_PGM=/etc/dump
X#
DUMP_OPT=o
X#
LPC_PGM=/etc/lpc
LPQ_PGM=/usr/ucb/lpq
LPRM_PGM=/usr/ucb/lprm
X#4.2_LPC=yes, on hydra
X#
MAIL_PGM=/usr/ucb/mail
X#
PAGER= /usr/ucb/more
X#
PLAY_MODE=2755
PLAY_PGM=/usr/local/bin/play
X#
PS_PGM=/bin/ps
X#
SHUTDOWN=/etc/shutdown
X#
TALK_PGM=/bin/write
X#
WALL_PGM=/bin/wall
X#
WHO_PGM=/bin/who
X#
X# status/motd's home directory:
X#
statd_dir=/usr/local/lib/stat
statd_files=/usr/local/lib/stat/files_direct
END_OF_FILE
if test 1063 -ne `wc -c <'src/machine_info'`; then
    echo shar: \"'src/machine_info'\" unpacked with wrong size!
fi
# end of 'src/machine_info'
fi
if test -f 'src/main.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/main.c'\"
else
echo shar: Extracting \"'src/main.c'\" \(1118 characters\)
sed "s/^X//" >'src/main.c' <<'END_OF_FILE'
X/*
X   oper main program
X*/
X
X#include "defs.h"
X
main()
X{
X	extern int ncmds;
X	extern struct cmd_st cmds[];
X	int cmd;
X	char ans[MAX_STR], *gets(), *gets_rc;
X	void main_menu();
X
X	init();
X
X	printf("\n\nWelcome to the oper menu.\n\n");
X
X#ifdef DEBUG
X	printf("Debugging turned on.\n");
X	printf("This better not be a production version\n");
X#endif DEBUG
X
X	main_menu();
X	do {
X		printf("\nEnter command ==> ");
X		if ((gets_rc = gets(ans)) == NULL)
X			continue;  /* Drop to end of loop */
X		cmd = atoi(gets_rc) - 1;
X		if (cmd >= 0 && cmd < ncmds)
X			switch(cmds[cmd].type) {
X				case PROC:
X					(*cmds[cmd].func)();
X					break;
X				case RUN:
X					run(cmds[cmd].cstr);
X					break;
X				case SYSTEM:
X					system(cmds[cmd].cstr);
X					break;
X				default:
X					printf("Unknown command type!!!\n");
X					printf("Report this to the ");
X					printf("person who maintains this ");
X					printf("program.\n");
X					exit(1);
X			}
X		else if (cmd == -1) /* cr was hit */
X			main_menu();
X		else {
X			printf("Invalid command (%d).  Valid commands ",cmd+1);
X			printf("are integers between 1 and %d\n", ncmds); 
X		}
X	} while (gets_rc != NULL);
X}
END_OF_FILE
if test 1118 -ne `wc -c <'src/main.c'`; then
    echo shar: \"'src/main.c'\" unpacked with wrong size!
fi
# end of 'src/main.c'
fi
if test -f 'src/main_menu.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/main_menu.c'\"
else
echo shar: Extracting \"'src/main_menu.c'\" \(676 characters\)
sed "s/^X//" >'src/main_menu.c' <<'END_OF_FILE'
X/*
X   main_menu: print the main menu for the oper program.
X*/
X
X#include "defs.h"
X
void
main_menu()
X{
X	extern int remote_managed;
X	extern struct cmd_st cmds[];
X	extern int ncmds;
X	int n_over_2, i;
X
X	if (ncmds < 0)
X		for (ncmds=0; cmds[ncmds].desc; ncmds++);
X
X	printf("\n\n           ****** Operator Command Menu ******\n");
X
X	if ( remote_managed )
X		printf("                            <* Remotely Managed *>\n" );
X
X	putchar( '\n' );
X
X	n_over_2 = ncmds / 2;
X	for (i=0; i<n_over_2; i++)
X		printf("%2d - %-33s  %2d - %-33s\n", i+1, cmds[i].desc,
X			i+n_over_2+1, cmds[i+n_over_2].desc);
X	if (ncmds != n_over_2 * 2)
X		printf("%-39s %2d - %-33s"," ", ncmds, cmds[ncmds-1].desc);
X}
END_OF_FILE
if test 676 -ne `wc -c <'src/main_menu.c'`; then
    echo shar: \"'src/main_menu.c'\" unpacked with wrong size!
fi
# end of 'src/main_menu.c'
fi
if test -f 'src/match.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/match.c'\"
else
echo shar: Extracting \"'src/match.c'\" \(751 characters\)
sed "s/^X//" >'src/match.c' <<'END_OF_FILE'
X/* 
X   match returns the index into where that what occurs.  Smatch is for
X	strings, cmatch for chars.
X
X   Assumptions:
X
X   Arguments:
X	what: what we are looking for.
X	where: where we are looking for it.
X	num: number of entries in where.
X
X   Returns:
X	the index in 'where' where 'what' occurs, or -1 if not found.
X
X   Global data used:
X	none.
X   
X   Local variables:
X	i: loop index.
X
X   Author:
X	Kenneth Ingham
X
X   Date:
X	Thu Sep  5 14:05:01 MDT 1985
X
X*/
X
smatch(what, where, num)
char *what, *where[];
int num;
X{
X	int i;
X
X	for (i=0; i<num; i++)
X		if (strcmp(what,where[i]) == 0)
X			return(i);
X	return(-1);
X}
X
cmatch(what, where, num)
char what, where[];
int num;
X{
X	int i;
X
X	for (i=0; i<num; i++)
X		if (what == where[i])
X			return(i);
X	return(-1);
X}
END_OF_FILE
if test 751 -ne `wc -c <'src/match.c'`; then
    echo shar: \"'src/match.c'\" unpacked with wrong size!
fi
# end of 'src/match.c'
fi
if test -f 'src/motd.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/motd.c'\"
else
echo shar: Extracting \"'src/motd.c'\" \(263 characters\)
sed "s/^X//" >'src/motd.c' <<'END_OF_FILE'
X/*
X   motd: start up an editing session on /etc/motd (or maybe something
X   similar).
X*/
X
X#include "defs.h"
X
motd()
X{
X
X    if ( remote_managed ) {
X	printf("Since this host is remotely managed, please do not do this.\n");
X	return( 0 );
X    }
X
X	system(MOTD_PGM);
X}
END_OF_FILE
if test 263 -ne `wc -c <'src/motd.c'`; then
    echo shar: \"'src/motd.c'\" unpacked with wrong size!
fi
# end of 'src/motd.c'
fi
if test -f 'src/naughty.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/naughty.c'\"
else
echo shar: Extracting \"'src/naughty.c'\" \(148 characters\)
sed "s/^X//" >'src/naughty.c' <<'END_OF_FILE'
X#include <stdio.h>
X
int naughty()
X{
X    printf( "\n\n  Please!!  %s  %s\n\n",
X			"Don't hurt me like that!!",
X			"Use the main menu to exit!!" );
X}
END_OF_FILE
if test 148 -ne `wc -c <'src/naughty.c'`; then
    echo shar: \"'src/naughty.c'\" unpacked with wrong size!
fi
# end of 'src/naughty.c'
fi
if test -f 'src/oper_kill.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/oper_kill.c'\"
else
echo shar: Extracting \"'src/oper_kill.c'\" \(953 characters\)
sed "s/^X//" >'src/oper_kill.c' <<'END_OF_FILE'
X/*
X   oper_kill: allow the operators to kill a process.
X
X   note that a '?' as a ps number will go to routine to list processes.
X*/
X
X#include "defs.h"
X
void
oper_kill()
X{
X	char ans[MAX_STR], *gets();
X	extern int errno, remote_managed;
X	int rc, pid;
X	void list_ps();
X
X    if ( remote_managed ) {
X	printf("Since this host is remotely managed, please do not do this.\n");
X	return;
X    }
X
X	do {
X		printf("Enter process number to kill [? for list; return to abort]: ");
X		gets(ans);
X		pid = atoi(ans);
X		if (ans[0] == '?' && ans[1] == '\0')
X			list_ps();
X	} while (ans[0] && pid == 0 );
X	if (!ans[0]) /* cr */
X		return;
X
X	rc = kill(pid, SIGKILL);
X	if (rc != 0) {
X		switch(errno) {
X			case EINVAL:
X				printf("Bad arguments to kill.  Call systems programmer.");
X				break;
X			case ESRCH:
X				printf("No such process exists.");
X				break;
X			case EPERM:
X				printf("Sorry.");
X				break;
X			default:
X				printf("Kill: error code %d",errno);
X				break;
X		}
X	}
X}
END_OF_FILE
if test 953 -ne `wc -c <'src/oper_kill.c'`; then
    echo shar: \"'src/oper_kill.c'\" unpacked with wrong size!
fi
# end of 'src/oper_kill.c'
fi
if test -f 'src/passwd.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/passwd.c'\"
else
echo shar: Extracting \"'src/passwd.c'\" \(136 characters\)
sed "s/^X//" >'src/passwd.c' <<'END_OF_FILE'
X/*
X   passwd: allow the operators to change the password for the oper
X   account.
X*/
X
X#include "defs.h"
X
passwd()
X{
X	run(PASSWD_PGM);
X}
END_OF_FILE
if test 136 -ne `wc -c <'src/passwd.c'`; then
    echo shar: \"'src/passwd.c'\" unpacked with wrong size!
fi
# end of 'src/passwd.c'
fi
if test -f 'src/plot.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/plot.c'\"
else
echo shar: Extracting \"'src/plot.c'\" \(683 characters\)
sed "s/^X//" >'src/plot.c' <<'END_OF_FILE'
X/*
X   plot: start up a vplot or cplot.
X*/
X
X#include "defs.h"
X
extern int machine;		/* the number of the machine i'm currently on */
extern int machflags[];		/* list of flags for all machines */
X
void
plot()
X{
X	char type[MAX_STR], *gets();
X
X    if ( (machflags[machine] & MF_RMANAGED) != 0 ) {
X	printf("Since this host is remotely managed, please do not do this.\n");
X	return;
X    }
X
X	printf("Plot.\n\n");
X	getans("Versatec, Calcomp, or Abort? [v/c/a] ", "v/a/c", type);
X
X	switch (type[0]) {
X		case 'a':
X			break;
X		case 'v': 
X			run(VER_PLOT_PGM);
X			break;
X		case 'c':
X			run(CAL_PLOT_PGM);
X			break;
X		default:
X			fprintf(stderr,"Impossible condition occurred.\n");
X			break;
X	}
X}
END_OF_FILE
if test 683 -ne `wc -c <'src/plot.c'`; then
    echo shar: \"'src/plot.c'\" unpacked with wrong size!
fi
# end of 'src/plot.c'
fi
if test -f 'src/printer_down.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/printer_down.c'\"
else
echo shar: Extracting \"'src/printer_down.c'\" \(546 characters\)
sed "s/^X//" >'src/printer_down.c' <<'END_OF_FILE'
X/*
X   printer_down: take a printer down with lpc.  Basically we call lpc
X   with the printer name and reason (sounds easy enough).
X
X   Kenneth Ingham
X*/
X
X#include "defs.h"
X
void
printer_down()
X{
X	char reason[MAX_STR];
X	char pname[MAX_STR];
X	char cmd[MAX_STR];
X	extern char *lpc_pgm;
X
X	get_printername(pname);
X
X	if ( getinfo("4.2_LPC") != NULL )
X		sprintf(cmd, "%s abort %s", lpc_pgm, pname);
X	else {
X		printf("\nWhy is the printer being taken down? ");
X		gets(reason);
X		sprintf(cmd, "%s down %s %s", lpc_pgm, pname, reason);
X	}
X
X	system(cmd);
X}
END_OF_FILE
if test 546 -ne `wc -c <'src/printer_down.c'`; then
    echo shar: \"'src/printer_down.c'\" unpacked with wrong size!
fi
# end of 'src/printer_down.c'
fi
if test -f 'src/printer_menu.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/printer_menu.c'\"
else
echo shar: Extracting \"'src/printer_menu.c'\" \(435 characters\)
sed "s/^X//" >'src/printer_menu.c' <<'END_OF_FILE'
X/*
X   printer_menu: display the printer command menu.
X
X   Kenneth Ingham
X*/
X
X#include "defs.h"
X
printer_menu()
X{
X	extern struct pcmd_st pcmds[];
X	extern int npcmds;
X	int i;
X
X	if (npcmds < 0)
X		for (npcmds=0; pcmds[npcmds].desc; npcmds++);
X
X	printf("\n\n                ****** Printer Menu ******\n\n");
X
X	printf("%2d - Return to main menu.\n",1);
X	for (i=0; i<npcmds; i++)
X		printf("%2d - %-s\n", i+2, pcmds[i].desc);
X	printf("\n");
X}
END_OF_FILE
if test 435 -ne `wc -c <'src/printer_menu.c'`; then
    echo shar: \"'src/printer_menu.c'\" unpacked with wrong size!
fi
# end of 'src/printer_menu.c'
fi
if test -f 'src/printer_up.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/printer_up.c'\"
else
echo shar: Extracting \"'src/printer_up.c'\" \(789 characters\)
sed "s/^X//" >'src/printer_up.c' <<'END_OF_FILE'
X/*
X   printer_up: bring a printer up with lpc.  Basically we call lpc
X   with the printer name, and tell it to work its magic.
X
X   Kenneth Ingham (&dsg)
X*/
X
X#include "defs.h"
X
void
printer_up()
X{
X	char pname[MAX_STR];
X	char cmd[MAX_STR];
X	extern char *lpc_pgm;
X
X	get_printername(pname);
X
X	if ( getinfo("4.2_LPC") != NULL ) {
X		printf( "First, we make sure the queue is turned on:\n" );
X		sprintf(cmd, "%s enable %s", lpc_pgm, pname);
X		system(cmd);
X		printf( "Then, we start 'er up:\n" );
X		sprintf(cmd, "%s start %s", lpc_pgm, pname);
X		system(cmd);
X	} else {
X		printf( "Enabling the queue & starting the printer:\n" );
X		sprintf(cmd, "%s up %s", lpc_pgm, pname);
X		printf( "uid = %d; gid = %d; euid = %d; egid = %d.\n",
X			getuid(), getgid(), geteuid(), getegid() );
X		system(cmd);
X	}
X}
END_OF_FILE
if test 789 -ne `wc -c <'src/printer_up.c'`; then
    echo shar: \"'src/printer_up.c'\" unpacked with wrong size!
fi
# end of 'src/printer_up.c'
fi
if test -f 'src/printers.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/printers.c'\"
else
echo shar: Extracting \"'src/printers.c'\" \(925 characters\)
sed "s/^X//" >'src/printers.c' <<'END_OF_FILE'
X/*
X   printers: play with the printers.  Access to lprm, lpq and lpc.
X
X   Kenneth Ingham
X*/
X
X#include "defs.h"
X
void
printers()
X{
X	extern struct pcmd_st pcmds[];
X	extern int npcmds;
X	int cmd;
X	char *gets_rc;
X	extern char *gets();		/* make madmax happy */
X	char ans[MAX_STR];
X	extern char *lpc_pgm;
X
X	if ( (lpc_pgm = getinfo("LPC_PGM")) == NULL ) {
X		printf("Since this host is remotely managed, ");
X		printf("please do not do this.\n");
X		return;
X	}
X
X	printer_menu();
X	do {
X		printf("\nEnter printer command ==> ");
X		cmd = atoi(gets_rc = gets(ans)) - 2;
X		if (cmd == -1) /* that's all for now */
X			return;
X		else if (cmd >= 0 && cmd < npcmds) /* valid command */
X			(*pcmds[cmd].func)(pcmds[cmd].cmd_arg);
X		else if (cmd == -2) /* cr was hit */
X			printer_menu();
X		else {
X			printf("Invalid command (%d).  Valid commands ",cmd+1);
X			printf("are integers between 1 and %d\n", npcmds+1); 
X		}
X	} while (gets_rc != NULL);
X}
END_OF_FILE
if test 925 -ne `wc -c <'src/printers.c'`; then
    echo shar: \"'src/printers.c'\" unpacked with wrong size!
fi
# end of 'src/printers.c'
fi
if test -f 'src/read_mail.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/read_mail.c'\"
else
echo shar: Extracting \"'src/read_mail.c'\" \(109 characters\)
sed "s/^X//" >'src/read_mail.c' <<'END_OF_FILE'
X/*
X   read_mail: start up a mail program to read mail
X*/
X
X#include "defs.h"
X
read_mail()
X{
X	run(MAIL_PGM);
X}
END_OF_FILE
if test 109 -ne `wc -c <'src/read_mail.c'`; then
    echo shar: \"'src/read_mail.c'\" unpacked with wrong size!
fi
# end of 'src/read_mail.c'
fi
if test -f 'src/rje.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/rje.c'\"
else
echo shar: Extracting \"'src/rje.c'\" \(387 characters\)
sed "s/^X//" >'src/rje.c' <<'END_OF_FILE'
X/*
X   rje: change the status of rje.
X*/
X
X#include "defs.h"
X
void
rje()
X{
X	extern int machine, machflags[];
X	char ans[MAX_STR], *gets();
X
X	if ( machflags[machine] & MF_HASRJE ) {
X		getans("Start or Restart the rje? [rs] ","r/s", ans);
X
X		if (ans[0] == 'r')
X			system(RJE_RESTART_PGM);
X		else
X			system(RJE_START_PGM);
X	}
X	else
X		printf("\n\nThere is no rje link on this machine.\n\n");
X}
END_OF_FILE
if test 387 -ne `wc -c <'src/rje.c'`; then
    echo shar: \"'src/rje.c'\" unpacked with wrong size!
fi
# end of 'src/rje.c'
fi
if test -f 'src/run.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/run.c'\"
else
echo shar: Extracting \"'src/run.c'\" \(502 characters\)
sed "s/^X//" >'src/run.c' <<'END_OF_FILE'
X/* 
X   run: execute a program as the user, not as root.  
X
X   Kenneth Ingham
X*/
X
X#include "defs.h"
X
run(s)
char *s;
X{
X	extern uid_t uid, gid;
X	extern int remote_managed;
X	int pid;
X
X	pid = fork();
X
X	if (pid == 0) {
X		if ( (!remote_managed) && (setgid(gid) != 0) ) {
X			printf("setgid failed.\n");
X			printf("Call person responible for this program\n");
X			exit(1);
X		}
X
X		system(s);
X
X		_exit(0);
X	}
X	else {
X		signal(SIGINT, SIG_IGN);
X		while (wait((int *)0) != pid)
X			;
X		signal(SIGINT, SIG_DFL);
X	}
X}
END_OF_FILE
if test 502 -ne `wc -c <'src/run.c'`; then
    echo shar: \"'src/run.c'\" unpacked with wrong size!
fi
# end of 'src/run.c'
fi
if test -f 'src/send_mail.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/send_mail.c'\"
else
echo shar: Extracting \"'src/send_mail.c'\" \(393 characters\)
sed "s/^X//" >'src/send_mail.c' <<'END_OF_FILE'
X/*
X   send_mail: start up a mail program to send mail
X*/
X
X#include "defs.h"
X
void
send_mail()
X{
X	char who[MAX_STR], cmd[MAX_STR], *gets();
X	char *mail_pgm;
X
X	if ((mail_pgm = getinfo("MAIL_PGM")) == NULL) {
X		printf("Sorry, unable to send mail from this machine.\n");
X		return;
X	}
X
X	printf("Send mail to: ");
X	gets(who);
X
X	if (!who[0]) return;
X
X	sprintf(cmd,"%s %s",mail_pgm,who);
X	run(cmd);
X}
END_OF_FILE
if test 393 -ne `wc -c <'src/send_mail.c'`; then
    echo shar: \"'src/send_mail.c'\" unpacked with wrong size!
fi
# end of 'src/send_mail.c'
fi
if test -f 'src/set_ids.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/set_ids.c'\"
else
echo shar: Extracting \"'src/set_ids.c'\" \(1076 characters\)
sed "s/^X//" >'src/set_ids.c' <<'END_OF_FILE'
X/*
X   set_ids: set the uid and gid to be able to do all of the oper
X   functions.
X
X   Kenneth Ingham
X*/
X
X#include "defs.h"
X
set_ids()
X{
X	extern uid_t uid, gid, oper_uid;
X	extern char *remote_mgr;
X	int uid_rc, gid_rc;
X	struct passwd *pw, *getpwnam();
X
X	uid = geteuid();
X	gid = getegid();
X/*
X * It would be better to do a getpwnam for testing purposes, although
X * it might be slower.  But this is only done once, so...
X *
X *	pw = getpwuid(getuid());
X */
X	if ((pw = getpwnam( "oper" )) == NULL) { /* no oper? */
X		fprintf(stderr, "Warning: No oper account on this machine.\n");
X		oper_uid = getuid(); /* what else to do? */
X	}
X	else
X		oper_uid = pw->pw_uid;
X/*
X * if we are remotely managed, than we are NOT running setuid.  This
X * means that we don't have to worry about the modes under which we run.
X */
X	if ( remote_mgr != (char *) NULL )
X		return( 0 );
X
X	if ((uid_rc = setuid(UID)) < 0 || (gid_rc = setgid(GID)) < 0) {
X		fprintf(stderr,"Unable to set uid or gid.\n");
X		fprintf(stderr,"uid rc: %d      gid rc: %d\n", uid_rc, gid_rc);
X		perror("oper menu");
X		exit(1);
X	}
X}
END_OF_FILE
if test 1076 -ne `wc -c <'src/set_ids.c'`; then
    echo shar: \"'src/set_ids.c'\" unpacked with wrong size!
fi
# end of 'src/set_ids.c'
fi
if test -f 'src/set_sigs.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/set_sigs.c'\"
else
echo shar: Extracting \"'src/set_sigs.c'\" \(535 characters\)
sed "s/^X//" >'src/set_sigs.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <signal.h>
X
int set_sigs()
X{
X    extern int naughty();
X
X/*
X *	Let them interrupt their way outa stuff, after all:
X *
X *  signal( SIGINT,  naughty );
X */
X    signal( SIGQUIT, naughty );
X    /*
X       by ignoring sigtstp, we force an interrupt to leave.  This way no
X       beeps for "there are stopped jobs".  The ignore passes on to any
X       child processes.  That we don't catch sigint is a way to
X       interrupt out of things.  Sorta like running on system V.
X    */
X    signal( SIGTSTP, SIG_IGN );
X}
END_OF_FILE
if test 535 -ne `wc -c <'src/set_sigs.c'`; then
    echo shar: \"'src/set_sigs.c'\" unpacked with wrong size!
fi
# end of 'src/set_sigs.c'
fi
if test -f 'src/show_queue.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/show_queue.c'\"
else
echo shar: Extracting \"'src/show_queue.c'\" \(372 characters\)
sed "s/^X//" >'src/show_queue.c' <<'END_OF_FILE'
X/*
X   show_queue: show the print queue for a specified printer.
X*/
X
X#include "defs.h"
X
void
show_queue()
X{
X	char cmd[MAX_STR];
X	char pname[MAX_STR];
X	char *lpq_pgm;
X
X	if ((lpq_pgm  = getinfo("LPQ_PGM"))  == NULL)  {
X		printf("Sorry, can't show print jobs on this machine.\n");
X		return;
X	}
X
X	get_printername(pname);
X	
X	sprintf(cmd,"%s -P%s", lpq_pgm, pname);
X	run(cmd);
X}
END_OF_FILE
if test 372 -ne `wc -c <'src/show_queue.c'`; then
    echo shar: \"'src/show_queue.c'\" unpacked with wrong size!
fi
# end of 'src/show_queue.c'
fi
if test -f 'src/shutdown.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/shutdown.c'\"
else
echo shar: Extracting \"'src/shutdown.c'\" \(1236 characters\)
sed "s/^X//" >'src/shutdown.c' <<'END_OF_FILE'
X/*
X   shutdown: procedure to begin shutting down the system.
X*/
X
X#include "defs.h"
X
void
shutdown()
X{
X	char ans[MAX_STR], cmd[MAX_STR], *gets(), flag[3];
X	char reason[MAX_STR], *shutdown_pgm;
X	int time;
X
X	if ((shutdown_pgm = getinfo("SHUTDOWN")) == NULL) {
X		printf("Since this host is remotely managed, ");
X		printf("please do not do this.\n");
X		return;
X	}
X
X	getans("Are you SURE you want to shutdown the system? [y/n] ",
X		"y/n", ans);
X
X	if (ans[0] == 'n')
X		return;
X
X	printf("Select type of shutdown: \n\n");
X	printf("1. Immediately reboot.\n");
X	printf("2. Halt (for power down, hardware maintence, etc).\n");
X	printf("3. Go to single user mode.\n");
X	printf("4. Standalone for Development.\n");
X	printf("\n");
X	getans("Enter type of shutdown: ", "1/2/3/4", ans);
X
X	switch(atoi(ans)) {
X		case 1:
X			strcpy(flag, "-r");
X			break;
X		case 2:
X			strcpy(flag, "-h");
X			break;
X		case 3:
X			flag[0] = '\0';
X			break;
X		case 4:
X			strcpy(flag, "-k");
X			break;
X	}
X
X	do {
X		printf("Time till shutdown? [minutes] ");
X		time = atoi(gets(ans));
X	} while (time <= 0);
X
X	printf("Reason for shutdown:\n");
X	gets(reason);
X
X	sprintf(cmd,"%s %s +%d '%s'", shutdown_pgm, flag, time, reason);
X
X	puts(cmd);
X#ifndef DEBUG
X	system(cmd);
X#endif  DEBUG
X}
END_OF_FILE
if test 1236 -ne `wc -c <'src/shutdown.c'`; then
    echo shar: \"'src/shutdown.c'\" unpacked with wrong size!
fi
# end of 'src/shutdown.c'
fi
if test -f 'src/talk.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/talk.c'\"
else
echo shar: Extracting \"'src/talk.c'\" \(727 characters\)
sed "s/^X//" >'src/talk.c' <<'END_OF_FILE'
X/*
X   talk: allow the operators to talk to a user.
X
X   note that a ? given as a response to 'talk to which user' will list
X   the users on the system.
X*/
X
X#include "defs.h"
X
void
talk()
X{
X	char user[MAX_STR], cmd[MAX_STR], *gets(), *talk_pgm;
X	char *who_pgm;
X	int question;
X
X	if ((talk_pgm = getinfo("TALK_PGM")) == NULL) {
X		printf("Sorry, Can't talk on this machine.\n");
X		return;
X	}
X
X	who_pgm = getinfo("WHO_PGM");
X
X	do {
X		question = False;
X		printf("Talk to which user [? for list]? ");
X		gets(user);
X		if (user[0] == '?' && user[1] == '\0') {
X			question = True;
X			if (who_pgm)
X				run(who_pgm);
X			else
X				printf("I can't get a list!\n");
X		}
X	} while ( question );
X
X	sprintf(cmd,"%s %s",talk_pgm,user);
X	run(cmd);
X}
END_OF_FILE
if test 727 -ne `wc -c <'src/talk.c'`; then
    echo shar: \"'src/talk.c'\" unpacked with wrong size!
fi
# end of 'src/talk.c'
fi
if test -f 'src/wall.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/wall.c'\"
else
echo shar: Extracting \"'src/wall.c'\" \(351 characters\)
sed "s/^X//" >'src/wall.c' <<'END_OF_FILE'
X/*
X   wall: allow the operators to write to all users.
X*/
X
X#include "defs.h"
X
void
wall()
X{
X	char *wall_pgm;
X
X	if ((wall_pgm = getinfo("WALL_PGM")) == NULL) {
X		printf("Sorry, can't do it on this machine.\n");
X		return;
X	}
X
X	printf("Enter message to send to all of the currently\n");
X	printf("logged in users, end with ^D.\n\n");
X	system(wall_pgm);
X}
END_OF_FILE
if test 351 -ne `wc -c <'src/wall.c'`; then
    echo shar: \"'src/wall.c'\" unpacked with wrong size!
fi
# end of 'src/wall.c'
fi
if test -f 'src/who.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/who.c'\"
else
echo shar: Extracting \"'src/who.c'\" \(89 characters\)
sed "s/^X//" >'src/who.c' <<'END_OF_FILE'
X/*
X   who: list the users on the system.
X*/
X
X#include "defs.h"
X
who()
X{
X	run(WHO_PGM);
X}
END_OF_FILE
if test 89 -ne `wc -c <'src/who.c'`; then
    echo shar: \"'src/who.c'\" unpacked with wrong size!
fi
# end of 'src/who.c'
fi
echo shar: End of archive 1 \(of 2\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 

Steve.                    sfreed at ariel.unm.edu



More information about the Comp.unix.admin mailing list