home *** CD-ROM | disk | FTP | other *** search
- From: pjc@pcbox.UUCP (Paul J. Condie)
- Newsgroups: alt.sources
- Subject: menu(1) part 11 of 11
- Message-ID: <433@pcbox.UUCP>
- Date: 6 Apr 90 17:58:33 GMT
-
-
- #!/bin/sh
- # this is part 11 of a multipart archive
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file utilities.d/libgeti.d/popmenu.3 continued
- #
- CurArch=11
- if test ! -r s2_seq_.tmp
- then echo "Please unpack part 1 first!"
- exit 1; fi
- ( read Scheck
- if test "$Scheck" != $CurArch
- then echo "Please unpack part $Scheck next!"
- exit 1;
- else exit 0; fi
- ) < s2_seq_.tmp || exit 1
- echo "x - Continuing file utilities.d/libgeti.d/popmenu.3"
- sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/popmenu.3
- Xwill be displayed.
- X.TP 6
- Xhelpfile
- XThe helpfile name that contains help text to be displayed when the uses presses
- Xthe help key. If a helpfile is supplied a "?" is displayed in the lower
- Xright hand corner of the menu. Set to null if no help file is provided.
- X.br
- XThe help file should be in a format corresponding to GetInput(3), see
- XGetInput(3X) for more information. Popmenu is hard-coded to look for
- X\fIhelptag\fP "popmenu" in the helpfile.
- X.TP 6
- Xwin_size
- XThe length of the pop-up window. This may be less than the number of
- Xoptions, so that popmenu() will only display
- X.I win_size
- Xnumber of options on the screen. A window size of 6 or the number of options,
- Xwhichever is less, is used if this field is set to 0. Note that this field
- Xshould not be set to be more than 22, which is the normal screen size (24)
- Xminus 2 for the borders.
- X.TP 6
- Xsizeof( option[0] ) or 0
- XIs an integer telling popmenu() the size of one option array element. It can
- Xalso be set to
- X.I zero(0)
- Xif (char **) array is passed as the next argument,
- X.I popmenu
- Xwill figure out the increment as the size of a char pointer.
- X.TP 6
- Xoption
- XThis is a (char *) to an array which store
- Xthe options you want to appear in the menu. This array can be either a
- Xtwo dimensional char array, or a structure array, or even an array of pointers.
- XThe first char string in each array element up to the first NULL character is
- Xused to be displayed as options. The rest of the field may just be table
- Xlook-up items. Also, The last element must be NULL to signify the end of the
- Xtable.
- X.PP
- XFor menus that has to be built dynamically during run time,
- Xthere are benefit of preparing your option table either way. With a pre-set
- Xchar array storing the menu entries, cpu usage is optimized in the expense of
- Xmemory; while using char *array will optimize memory usage but has to allocate
- Xmemory on the fly. Menus built at compiled time are about equal with either
- Xmethod.
- X
- X.SH CREDITS
- XPaul J. Condie 7/87 (original author)
- X.br
- X{ihnp4,lll-crg,qantel,pyramid}!ptsfa!pbody!pcbox!pjc
- X
- XSam S. Lok enhancements
- X
- X.SH EXAMPLE
- X.nf
- X#include <curses.h>
- X
- X#define NEWMENU 0
- X
- Xint KeyHelp = 23; /* control w */
- Xint KeyCancel = 27; /* ESC */
- Xint KeyDown;
- Xint KeyUp;
- X
- Xmain ()
- X{
- X int option; /* the option the user selected */
- X static char mymenu[][7] = {
- X "QUERY", "ADD", "DELETE", (char *)NULL };
- X static char *yourmenu[] = {
- X "QUERY", "ADD", "DELETE", (char *)NULL };
- X
- X
- X /* define a new menu */
- X popmenu(NEWMENU, 1, 5,10, "Title", "", 3, sizeof( mymenu[0] ), mymenu );
- X popmenu(NEWMENU, 2, 7,15, "Title", "", 0, 0, yourmenu );
- X
- X /* run the menu */
- X option = popmenu (1);
- X option = popmenu (2);
- X
- X /* remove the menu from the screen */
- X touchwin (stdscr);
- X wrefresh (stdscr);
- X}
- X.fi
- X
- X.SH SEE ALSO
- Xcurses(3X), GetInput(3X).
- SHAR_EOF
- echo "File utilities.d/libgeti.d/popmenu.3 is complete"
- chmod 0444 utilities.d/libgeti.d/popmenu.3 || echo "restore of utilities.d/libgeti.d/popmenu.3 fails"
- echo "x - extracting utilities.d/libgeti.d/GetInput.hlp (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetInput.hlp &&
- XGETINPUT
- X.TITLE GETINPUT Help
- XMover Keys:
- X KEY_RETURN (^m) Traverse forwards through the fields.
- X KEY_DOWN (^j) Traverse forwards through the fields.
- X KEY_UP (^k) Traverse backwards through the fields.
- X KEY_TAB (^i) Fast forward through the fields.
- X KEY_BTAB Fast reverse through the fields.
- XField Editing Keys:
- X KEY_BEG (^b) Place cursor at beginning of field.
- X KEY_END (^e) Place cursor at end of input in field.
- X KEY_RIGHT (^l) Forward space within the field.
- X KEY_LEFT (^h) Backspace within the field (non-destructive).
- X KEY_BACKSPACE (^h) Same as KEY_LEFT.
- X KEY_EOL (^d) Delete from cursor to end of field.
- X KEY_DL (^c) Clear field and home cursor.
- X KEY_DC (^x) Delete a character.
- X KEY_IC (^t) Toggle between type-over and insert mode.
- XOther Keys:
- X KEY_HELP (?) Display help screen.
- X KEY_REFRESH (^r) Redraw the screen.
- X KEY_ACCEPT (^a) Accept all input and exit screen.
- X KEY_CANCEL (esc) Cancel all input and exit screen.
- X KEY_SAVE (^f) Save screen to a file.
- X KEY_PRINT (^p) Print screen to lp.
- XGETINPUT
- X
- X
- X
- Xpopmenu
- X.TITLE Pop-Up Menu Help
- XSELECTING OPTIONS:
- X Press the "up arrow key", "^k", "down arrow key", "^j"
- X to place bar on option and press "return".
- X
- X or
- X
- X Enter the first character of the option you
- X wish to select and press "return".
- X
- X KEY_CANCEL (esc) - Cancel selection.
- Xpopmenu
- X
- X
- X
- Xhelp
- X.TITLE Using Help
- XHelp displays consist of a description displayed in a window.
- XIf the description doesn't fit in the window, the Up Arrow and
- XDown Arrow keys can be used to view a few more lines of the
- Xdisplay. Exiting the help system will return the display to
- Xthe state it was in when you asked for help.
- X
- X The following keys are active in help:
- X KEY_CANCEL (esc) Exit help.
- X KEY_DOWN (^j) View a few more lines.
- X KEY_UP (^k) View the previous lines.
- X KEY_BEG (^b) Display first page.
- X KEY_END (^e) Display last page.
- Xhelp
- SHAR_EOF
- chmod 0444 utilities.d/libgeti.d/GetInput.hlp || echo "restore of utilities.d/libgeti.d/GetInput.hlp fails"
- echo "x - extracting utilities.d/checkpass.d/checkpass.1 (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/checkpass.d/checkpass.1 &&
- X. \ %W% DeltaDate %G% ExtrDate %H%
- X.po 6
- X.TH CHECKPASS 1 "" "Menu Utility"
- X
- X.SH \s9NAME\s0
- Xcheckpass \- find matching passwd in /etc/passwd file for a specified login.
- X
- X.SH SYNOPSIS
- Xcheckpass login passwd
- X
- X.SH DESCRIPTION
- X.I Checkpass
- Xfinds the \fIlogin\fP password in the /etc/passwd file, encrypts the
- X\fIpasswd\fP and does a comparison.
- X.SH FILES
- X/etc/passwd
- X
- X.SH AUTHOR
- XVickie C. Chui
- X
- X.SH DIAGNOSTICS
- XCheckpass returns exit code zero if it was successful, otherwise, it
- Xreturns a 4.
- SHAR_EOF
- chmod 0644 utilities.d/checkpass.d/checkpass.1 || echo "restore of utilities.d/checkpass.d/checkpass.1 fails"
- echo "x - extracting utilities.d/checkpass.d/checkpass.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/checkpass.d/checkpass.c &&
- X/*
- X * checkpass.c: encrypt entered passwd and comparing it against
- X * the /etc/passwd.
- X *
- X * Inputs: argv[1] - login
- X * argv[2] - passwd
- X *
- X * Return Values: 4 failure
- X * 0 - matched passwd found
- X */
- X
- X#include <pwd.h>
- X
- Xmain(argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X struct passwd *getpwnam(), *pwentry;
- X char salt[2],
- X *crypt(),
- X *encryptedpw;
- X
- X
- X /* check number of arguments */
- X if(argc != 3) {
- X printf("Usage: checkpass login passwd\n");
- X exit(4);
- X }
- X
- X /* get passwd for login from /etc/passwd file */
- X if((pwentry=getpwnam(argv[1])) == (struct passwd *) 0)
- X exit(4);
- X
- X salt[0] = *(pwentry->pw_passwd);
- X salt[1] = *(pwentry->pw_passwd +1);
- X
- X /* encrypt entered passwd */
- X encryptedpw = crypt(argv[2], salt);
- X
- X /* compare passwd in /etc/passwd with the encrypted passwd */
- X if(strcmp(encryptedpw, pwentry->pw_passwd) )
- X exit(4);
- X exit(0);
- X}
- SHAR_EOF
- chmod 0644 utilities.d/checkpass.d/checkpass.c || echo "restore of utilities.d/checkpass.d/checkpass.c fails"
- echo "x - extracting utilities.d/lock.d/junk (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/junk &&
- X lockfd = open(diallock, O_WRONLY|O_CREAT|O_EXCL,
- X 0444) ;
- X if (lockfd < 0)
- X {
- X if (debug & D_DEVICE)
- X {
- X dialmsg("%s: %s\n", errstring(),
- X diallock) ;
- X }
- X continue ;
- X }
- X else
- X {
- X /* pjc */
- X /* write process id to lock file */
- X sprintf (tmpstr, "%d", getpid());
- X sprintf (spid, "%10.10s", tmpstr);
- X write (lockfd, spid, strlen(spid));
- X }
- X
- X (void) close(lockfd) ;
- SHAR_EOF
- chmod 0644 utilities.d/lock.d/junk || echo "restore of utilities.d/lock.d/junk fails"
- echo "x - extracting utilities.d/lock.d/lock.1 (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/lock.1 &&
- X. \ %W% DeltaDate %G% ExtrDate %H%
- X.po 6
- X.TH LOCK 1 "" "Menu Utility"
- X
- X.SH \s9NAME\s0
- Xlock \- does a lock on a file
- X
- X.SH SYNOPSIS
- X.B lock filename
- X
- X.SH DESCRIPTION
- X.B LOCK
- Xis designed to be a utility program to be used in conjunction with the menu(1)
- Xprogram. Lock does a lock on a file. When used with the menu(1)
- Xprogram the filename should probably be the program name. A "LCK.." is
- Xprepended
- Xto the filename to indicate that this is a lock file. This is in keeping
- Xwith uucp lock file syntax. If the \fILCK..filename\fP
- Xdoes not exist it will be created. The lock file is created/looked for in
- Xgetenv("LOCKDIR").
- X
- X
- X.SH EXAMPLE
- X.nf
- Xlock program_name
- Xif [ $? -eq 0 ]
- X then program_name
- X unlock program_name
- Xfi
- X.fi
- X
- X.SH FILES
- X\fI$LOCKDIR/LCK..filename\fP the lock file
- X
- X.SH AUTHOR
- XPaul J. Condie 10/88
- X.br
- X{att,bellcore,sun,ames,pyramid}!pacbell!pcbox!pjc
- X
- X.SH SEE ALSO
- Xmenu(1), unlock(1).
- X
- X.SH DIAGNOSTICS
- XLock returns a zero if the lock was successfully created,
- X99 no file specified on command line,
- Xotherwise, it returns \fIerrno\fP. See errno description in manual.
- SHAR_EOF
- chmod 0644 utilities.d/lock.d/lock.1 || echo "restore of utilities.d/lock.d/lock.1 fails"
- echo "x - extracting utilities.d/lock.d/lock.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/lock.c &&
- X/*
- X** Returns:
- X** 0 lock successful
- X** 99 no file on command line
- X** otherwise errno
- X*/
- X
- X#include <stdio.h>
- X#include <fcntl.h>
- X#include <errno.h>
- X
- Xmain (argc, argv)
- X int argc;
- X char *argv[];
- X{
- X char *getenv();
- X int fd; /* file descriptor */
- X char file[40];
- X
- X if (argc != 2)
- X exit (1);
- X
- X if (getenv("LOCKDIR") != (char *)NULL)
- X sprintf (file, "%s/LCK..%s", getenv("LOCKDIR"), argv[1]);
- X else
- X sprintf (file, "LCK..%s", argv[1]);
- X
- X if ((fd = open (file, O_WRONLY|O_CREAT|O_EXCL, 0444)) < 0)
- X {
- X /* check to see if process is still running */
- X exit (errno);
- X }
- X
- X /* write process id to lock file */
- X /*
- X sprintf (tmpstr, "%d", getpid());
- X sprintf (spid, "%10.10s", tmpstr);
- X write (lockfd, spid, strlen(spid));
- X */
- X
- X close (fd);
- X exit (0);
- X}
- X/* Paul J. Condie 8-89 */
- SHAR_EOF
- chmod 0644 utilities.d/lock.d/lock.c || echo "restore of utilities.d/lock.d/lock.c fails"
- echo "x - extracting utilities.d/lock.d/unlock.1 (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/unlock.1 &&
- X. \ %W% DeltaDate %G% ExtrDate %H%
- X.po 6
- X.TH UNLOCK 1 "" "Menu Utility"
- X
- X.SH \s9NAME\s0
- Xunlock \- unlocks a semaphore lock on a file
- X
- X.SH SYNOPSIS
- Xlock filename
- X
- X.SH DESCRIPTION
- X.B UNLOCK
- Xis designed to be a utility program to be used in conjunction with the menu(1)
- Xprogram. Unlock does a semaphore unlock on a file then unlinks the filename.
- XThe filename should have been previously locked using lock(1).
- XA "LCK.." is prepended
- Xto the filename to indicate that this is a lock file.
- XThe lock file is looked for in getenv("LOCKDIR").
- X
- X.PP
- XThe important thing for unlock is to make sure it runs regardless of how
- Xthe program exits. Examples of how insure that this happens is illustrated
- Xbelow:
- X.br
- Xtrap 'unlock pgm; trap 2' 2; (pgm; unlock pgm); trap 2
- X.br
- X(nohup pgm; nohup unlock)&
- X
- X.SH FILES
- X\fI$LOCKDIR/LCK..filename\fP the lock file
- X
- X.SH AUTHOR
- XPaul J. Condie 10/88
- X.br
- X{att,bellcore,sun,ames,pyramid}!pacbell!pcbox!pjc
- X
- X.SH SEE ALSO
- Xmenu(1), lock(1).
- X
- X.SH DIAGNOSTICS
- XUnlock returns exit code zero if the unlock was successful, otherwise, it
- Xreturns a non-zero.
- SHAR_EOF
- chmod 0644 utilities.d/lock.d/unlock.1 || echo "restore of utilities.d/lock.d/unlock.1 fails"
- echo "x - extracting utilities.d/lock.d/unlock.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/unlock.c &&
- X/*
- X** Name: unlock(1)
- X** Returns:
- X** 0 unlock successful
- X** 99 no file on command line
- X** otherwise errno
- X*/
- X
- X#include <stdio.h>
- X#include <errno.h>
- X
- Xmain (argc, argv)
- X int argc;
- X char *argv[];
- X{
- X char *getenv();
- X char file[40];
- X
- X if (argc != 2)
- X exit (99);
- X
- X if (getenv("LOCKDIR") != (char *)NULL)
- X sprintf (file, "%s/LCK..%s", getenv("LOCKDIR"), argv[1]);
- X else
- X sprintf (file, "LCK..%s", argv[1]);
- X
- X if (unlink (file) < 0)
- X exit (errno);
- X
- X exit (0);
- X}
- X/* Paul J. Condie 8-89 */
- SHAR_EOF
- chmod 0644 utilities.d/lock.d/unlock.c || echo "restore of utilities.d/lock.d/unlock.c fails"
- echo "x - extracting utilities.d/m.d/adduser (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/adduser &&
- X#! /bin/ksh
- X# %W% DeltaDate %G% ExtrDate %H%
- X
- X### adduser
- X### Add a new user login to the system.
- X### This script is designed to be run from the menu(1) program.
- X### Menu script file is sadmin.m
- X### This script needs to be run with a set uid to root program. You
- X### pick the one you want to use.
- X###
- X### Arguments:
- X### $1 = login ID
- X### $2 = encrypted password
- X### $3 = numerical user ID
- X### $4 = numerical group ID
- X### $5 = Text (Users Read Name)
- X### $6 = directory to create users home directory in
- X### $7 = program to use as Shell
- X### $8 = default .profile for user
- X### $9 = default printer
- X###
- X### Note:
- X### In order to get chgrp to work you need to chown to $LOGNAME first.
- X### The setuid does not work for chgrp ????
- X###
- X
- X### Validate argument count
- Xif [ $# -ne 9 ]
- X then exit 1
- Xfi
- X
- XLOGNAME=$1
- XPASSWD=$2
- XUID=$3
- XGID=$4
- XNAME=$5
- XHOMEDIR=$6/$LOGNAME
- XLOGSHELL=$7
- XDPROFILE=$8
- XPRINTER=$9
- X
- XPWDFILE=/etc/passwd
- XGROUPFILE=/etc/group
- XECHO=/bin/echo
- X
- X#stty sane erase '^h' echoe isig
- X
- Xtrap "$ECHO 'Adduser aborted.\nPress [ Return ] to continue...\c'; read reply; exit" 2 3 15
- X
- X$ECHO "\n"
- X
- Xif grep '^'$LOGNAME: $PWDFILE > /dev/null 2>&1
- X then $ECHO "Logname $LOGNAME is already in use."
- X $ECHO "Please try another."
- X $ECHO "Press [ Return ] to continue...\c"
- X read reply
- X exit 0
- Xfi
- X
- XGROUP=`awk 'BEGIN{FS=":"} {if($3 == g) print $1}' g=$GID $GROUPFILE`
- X
- X
- X
- X$ECHO "Logname: $LOGNAME"
- X$ECHO "Default Passwd: $PASSWD"
- X$ECHO "Real name: $NAME"
- X$ECHO "User id: $UID"
- X$ECHO "Group: $GROUP"
- X$ECHO "Group number: $GID"
- X$ECHO "Home directory: $HOMEDIR"
- X$ECHO "Default Printer: $PRINTER"
- X
- X#$ECHO "\nDatabase Permissions:"
- X#$ECHO "\tService Rep: $rep"
- X
- X$ECHO "\nOkay to add (y/n)? \c"
- Xread reply
- X
- X$ECHO "\n"
- Xif [ "$reply" = "y" ]
- X then trap "$ECHO 'Too late to abort adduser!'" 2 3 15
- X $ECHO "Adding entry to $PWDFILE"
- X ### Next line is for standard SYSV
- X $ECHO "$LOGNAME:$PASSWD:$UID:$GID:$NAME:$HOMEDIR:$LOGSHELL" >> $PWDFILE
- X if [ $? -ne 0 ]
- X then $ECHO "Unable to add entry to $PWDFILE"
- X $ECHO "Aborting add new user."
- X $ECHO "Press [ Return ] to continue...\c"
- X read reply
- X exit 0
- X fi
- X ### Next Line is for the SUN
- X# $ECHO "/^+/i\\" > /tmp/adduser.script
- X# $ECHO "$LOGNAME:$PASSWD:$UID:$GID:$NAME:$HOMEDIR:$LOGSHELL" >> /tmp/adduser.script
- X# sed -f /tmp/adduser.script $PWDFILE > /tmp/newpasswd
- X# cp /tmp/newpasswd $PWDFILE
- X# rm -f /tmp/adduser.script
- X# rm -f /tmp/newpasswd
- X else
- X $ECHO "$LOGNAME not added."
- X exit
- Xfi
- X
- X
- X### Make home directory
- XMAKEDIR=yes
- Xif [ -s $HOMEDIR ]
- X then $ECHO "Warning: $HOMEDIR exists. Okay to use it (y/n)? \c"
- X read reply
- X if [ "$reply" = "y" ]
- X then MAKEDIR=no
- X fi
- Xfi
- Xif [ "$MAKEDIR" = "yes" ]
- X then mkdir $HOMEDIR
- X if [ $? -ne 0 ]
- X then $ECHO "Could not create $HOMEDIR."
- X $ECHO "Aborting adduser."
- X $ECHO "Removing entry in $PWDFILE"
- X sed -e "/^$LOGNAME:/D" $PWDFILE > /tmp/passwd
- X if [ $? -ne 0 ]
- X then $ECHO "Unable to delete entry from password file."
- X exit
- X else chmod 744 $PWDFILE
- X cp /tmp/passwd $PWDFILE
- X rm -f /tmp/passwd
- X fi
- X $ECHO "Press [ Return ] to continue...\c"
- X read reply
- X exit
- X fi
- Xfi
- X# Correct mode of HOMEDIR
- Xchown $LOGNAME $HOMEDIR
- X/bin/chgrp $GROUP $HOMEDIR
- X/bin/chmod 754 $HOMEDIR
- Xchown $LOGNAME $HOMEDIR
- X
- X
- X
- X###
- X### If there is no .profile in HOMEDIR
- X### then Copy default .profile to HOMEDIR
- X###
- X
- Xif [ -f $HOMEDIR/.profile ]
- X then $ECHO "A .profile already exists in $HOMEDIR."
- X else
- X if [ -f $DPROFILE ]
- X then $ECHO "Placing a .profile in $HOMEDIR"
- X ### Next line is used to set default printer LPDEST
- X if [ "$PRINTER" != "NULL" ]
- X # fix this
- X then sed "s/^LPDEST=local/LPDEST=$PRINTER/" $DPROFILE > $HOMEDIR/.profile
- X else cp $DPROFILE $HOMEDIR/.profile
- X fi
- X chown $LOGNAME $HOMEDIR/.profile
- X /bin/chgrp $GROUP $HOMEDIR/.profile
- X /bin/chmod 754 $HOMEDIR/.profile
- X chown $LOGNAME $HOMEDIR/.profile
- X $ECHO "Default .profile added for $LOGNAME."
- X else $ECHO "The default .profile ($DPROFILE) was not found."
- X fi
- Xfi
- X
- X
- X
- X###
- X### Create bin in HOMEDIR
- X###
- X
- Xif [ -d $HOMEDIR/bin ]
- X then $ECHO "A bin directory already exists."
- X else
- X $ECHO "Making directory $HOMEDIR/bin"
- X mkdir $HOMEDIR/bin
- X chown $LOGNAME $HOMEDIR/bin
- X /bin/chgrp $GROUP $HOMEDIR/bin
- X /bin/chmod 755 $HOMEDIR/bin
- X chown $LOGNAME $HOMEDIR/bin
- X $ECHO "Bin directory added for $LOGNAME."
- Xfi
- X
- X
- X
- X###
- X### Grant Database Permissions
- X###
- X
- X#DBPATH=/prod/date.d; export DBPATH
- X#/usr/informix/bin/isql - - <<END
- X#database dateme;
- X#grant select on techs to $LOGNAME;
- X#grant insert on techs to $LOGNAME;
- X#grant update on techs to $LOGNAME;
- X#grant delete on techs to $LOGNAME;
- X#grant connect to $LOGNAME;
- X#END
- X
- X$ECHO "$LOGNAME added."
- X$ECHO "Press [ Return ] to continue...\c"
- Xread reply
- SHAR_EOF
- chmod 6755 utilities.d/m.d/adduser || echo "restore of utilities.d/m.d/adduser fails"
- echo "x - extracting utilities.d/m.d/deluser (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/deluser &&
- X#! /usr/lbin/ksh
- X# @(#)deluser.sh 1.1 DeltaDate 12/31/87 ExtrDate 12/31/87
- X###
- X### You need to chown all files in the home directory you want to delete
- X### to $LOGNAME before you can remove the home directory.
- X###
- X
- XLOGNAME=$1
- XECHO=echo
- XUIDBASE=2000
- X
- Xtrap "$ECHO 'Deluser aborted.'; exit 1" 2 3 15
- X
- Xtput clear
- X#stty sane erase '^h' echoe isig
- X
- X
- X
- Xcase $LOGNAME in
- X dateme|pjc|root|nobody|daemon|sys|bin|uucp|nuucp|news|informix|telic|cadsys)
- X $ECHO "Sorry, You don't have permission to delete that one."
- X continue
- X ;;
- Xesac
- X
- X###
- X### Check for validity - listed in password file.
- X###
- Xif grep '^'$LOGNAME: /etc/passwd > /dev/null 2>&1
- X then
- X ### Extract data for this user and display.
- X setthem=`sed -n "s/^$LOGNAME:\(.*\):\(.*\):\(.*\):\(.*\):\(.*\):\(.*\)/passwd=\1;uid=\2;gid=\3;realname='\4';homedir=\5;shell=\6/p" /etc/passwd`
- X eval $setthem
- X group=`awk 'BEGIN{FS=":"} {if($3 == g) print $1}' g=$gid /etc/group`
- X
- X ###
- X ### uid must be >= UIDBASE
- X ###
- X if [ "$uid" -lt $UIDBASE ]
- X then $ECHO "Sorry, You don't have permission to delete that one."
- X continue
- X fi
- X
- X $ECHO "\nLogname: $LOGNAME"
- X $ECHO "Real name: $realname"
- X $ECHO "User id: $uid"
- X $ECHO "Group: $group"
- X $ECHO "Group number: $gid"
- X $ECHO "Home directory: $homedir"
- X $ECHO "\n\n"
- X break
- X else
- X $ECHO "$LOGNAME is not listed in the password file. Try again."
- X read reply
- Xfi
- X
- X
- X
- Xwhile true
- Xdo
- X $ECHO "Do you wish to delete this user from the system (y/n): \c"
- X read reply
- X
- X case $reply in
- X n|N) break ;;
- X y|Y)
- X if [ "$homedir" != "/prod/date.d/cadsys.d" ]
- X then
- X ### Not a Service Rep
- X ### Service Reps never had permission here
- X DBPATH=/prod/date.d
- X export DBPATH
- X/usr/informix/bin/isql - - <<END
- Xdatabase dateme;
- Xrevoke all on techs from $LOGNAME;
- Xrevoke all on turfs from $LOGNAME;
- Xrevoke all on techtime from $LOGNAME;
- Xrevoke all on factors from $LOGNAME;
- Xrevoke all on turfs from $LOGNAME;
- XEND
- X fi
- X DBPATH=/prod/date.d/cadsys.d
- X export DBPATH
- X/usr/informix/bin/isql - - <<END
- Xdatabase cadsys;
- Xrevoke all on appt from $LOGNAME;
- Xrevoke all on grid from $LOGNAME;
- Xrevoke all on syserror from $LOGNAME;
- Xrevoke all on appt_time from $LOGNAME;
- Xrevoke all on sorder from $LOGNAME;
- Xrevoke all on sysdeflt from $LOGNAME;
- Xrevoke connect from $LOGNAME;
- XEND
- X sed -e "/^$LOGNAME:/D" /etc/passwd > /tmp/passwd
- X if [ $? -ne 0 ]
- X then $ECHO "Unable to delete from password file."
- X exit
- X fi
- X chmod 744 /etc/passwd
- X cp /tmp/passwd /etc/passwd
- X
- X ###
- X ### CUSTOMIZE
- X ### if this is a service rep we don't want to remove homedir
- X ###
- X if [ "$homedir" != "/prod/date.d/cadsys.d" ]
- X then
- X find $homedir -exec /etc/chown $LOGNAME {} \;
- X rm -r $homedir
- X fi
- X $ECHO "\nUser removed from system."
- X break;
- X ;;
- X *) $ECHO "Invalid reply."
- X continue ;;
- X esac
- SHAR_EOF
- chmod 0777 utilities.d/m.d/deluser || echo "restore of utilities.d/m.d/deluser fails"
- echo "x - extracting utilities.d/m.d/junk.m (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/junk.m &&
- X###
- X### .POPMENU
- X### Printer Selection Menu
- X###
- X
- X.TITLE
- XPrinter Menu
- X
- X.TEXT 23 0
- XSelect A Printer.
- X
- X.SETENV BELL LPDEST=srv4e_700ps Printer (srv4e_700ps) selected.
- Xsrv4e_700ps
- X
- X.SETENV BELL LPDEST=srv4e_700dm Printer (srv4e_700dm) selected.
- Xsrv4e_700dm
- X
- X.SETENV BELL LPDEST=srv4e_811a Printer (srv4e_811a) selected.
- Xsrv4e_811a
- X
- X.SETENV BELL LPDEST=srv4e_760c Printer (srv4e_760c) selected.
- Xsrv4e_760c
- SHAR_EOF
- chmod 0644 utilities.d/m.d/junk.m || echo "restore of utilities.d/m.d/junk.m fails"
- echo "x - extracting utilities.d/m.d/passwdsrn.m (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/passwdsrn.m &&
- X.DEFINE_SCREEN passwdsrn
- X window_title = "Password Screen"
- X window_rows = 5
- X window_cols = 26
- X exit_last_field
- X
- X field_name = $PASSWD
- X field_label = Password
- X field_row = 2
- X field_col = 12
- X field_length = 8
- X field_edits = PROTECT
- X field_prompt = "Enter password."
- XENDSCREEN
- SHAR_EOF
- chmod 0644 utilities.d/m.d/passwdsrn.m || echo "restore of utilities.d/m.d/passwdsrn.m fails"
- echo "x - extracting utilities.d/m.d/printer2.sh (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/printer2.sh &&
- XFrom uucp Tue Nov 28 16:07 PST 1989
- X>From uucp Tue Nov 28 15:56 PST 1989 remote from pacbell
- X>From srv.PacBell.COM!pjcondie Tue Nov 28 14:35:31 1989 remote from mother
- XReceived: from pbuddy.srv.PacBell.COM (pbuddy-gw) by srv.PacBell.COM (4.0/SMI-4.0)
- X id AA17298; Tue, 28 Nov 89 14:35:31 PST
- XReceived: from lacm2.srv.PacBell.COM by pbuddy.srv.PacBell.COM (4.0/SMI-4.0)
- X id AA02251; Tue, 28 Nov 89 14:37:38 PST
- XDate: Tue, 28 Nov 89 14:37:38 PST
- XFrom: pjcondie@srv.PacBell.COM (Paul J. Condie)
- XMessage-Id: <8911282237.AA02251@pbuddy.srv.PacBell.COM>
- XTo: pcbox!pjc
- XSubject: Re: printers.sh
- XStatus: R
- X
- X
- X----- Begin Included Message -----
- X
- X>From pbear2!ssl Tue Nov 28 14:31:29 1989
- XSubject: printers.sh
- XTo: pjc (Paul J. Condie(baer))
- XX-Mailer: ELM [version 2.2 PL0]
- X
- X###
- X### Build lpoptions.m from lpoptions.menu
- X### Printer Selection Menu
- X###
- X
- XDUMMY="zzzzzzzz" # end-of-list marker
- X
- Xsetprinters() { # make a function
- Xlpstat -a | grep accept | cut -d' ' -f1 | ( sort ; echo $DUMMY ) |
- Xfor i in `cat`
- Xdo
- X if [ $i = $DUMMY ] # hit last one?
- X then
- X echo $PRINTERS
- X fi
- X PRINTERS=$PRINTERS","$i # concat
- Xdone ; }
- X
- XPRINTERS=$LPDEST`setprinters` # now build it
- Xsed -e s/\$PRINTERS/$PRINTERS/ $BVPS/misc/lpoptions.menu > lpoptions.m
- X
- X
- X----- End Included Message -----
- X
- X
- X
- SHAR_EOF
- chmod 0644 utilities.d/m.d/printer2.sh || echo "restore of utilities.d/m.d/printer2.sh fails"
- echo "x - extracting utilities.d/m.d/printers.m (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/printers.m &&
- X###
- X### .POPMENU
- X### Printer Selection Menu
- X###
- X
- X.TITLE
- XPrinter Menu
- X
- X.TEXT 23 0
- XSelect A Printer.
- X
- X.SETENV BELL LPDEST=srv4e_700ps Printer (srv4e_700ps) selected.
- Xsrv4e_700ps
- X
- X.SETENV BELL LPDEST=srv4e_700dm Printer (srv4e_700dm) selected.
- Xsrv4e_700dm
- X
- X.SETENV BELL LPDEST=srv4e_811a Printer (srv4e_811a) selected.
- Xsrv4e_811a
- X
- X.SETENV BELL LPDEST=srv4e_760c Printer (srv4e_760c) selected.
- Xsrv4e_760c
- X
- X.POPMENU printers.m
- XPOP
- SHAR_EOF
- chmod 0644 utilities.d/m.d/printers.m || echo "restore of utilities.d/m.d/printers.m fails"
- echo "x - extracting utilities.d/m.d/printers.sh (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/printers.sh &&
- X###
- X### Build a .POPMENU
- X### Printer Selection Menu
- X###
- X
- Xecho ".TITLE" > printers.m
- Xecho "Printer Menu" >> printers.m
- X
- Xecho ".TEXT 23 0" >> printers.m
- Xecho "Select A Printer." >> printers.m
- X
- Xlpstat -p | awk '{ print $2 }' |
- Xfor i in `cat`
- Xdo
- X echo ".SETENV BELL LPDEST=$i Printer ($i) selected." >> printers.m
- X echo "$i" >> printers.m
- Xdone
- SHAR_EOF
- chmod 0755 utilities.d/m.d/printers.sh || echo "restore of utilities.d/m.d/printers.sh fails"
- echo "x - extracting utilities.d/m.d/reportsrn.m (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/reportsrn.m &&
- X### Screen to prompt user for report options.
- X### Fields:
- X### $FDATE - From date.
- X### $TDATE - To date.
- X### $PRIORITY - Priority
- X### $LPDEST - Printer Destination
- X### $TARGET - Print to terminal or printer.
- X
- X.DEFINE_SCREEN reportsrn
- X window_title = "REPORT OPTIONS"
- X window_rows = 10
- X window_cols = 28
- X
- X ### $FDATE - From date.
- X
- X field_name = $FDATE
- X field_label = From
- X field_row = 2
- X field_col = 13
- X field_length = 6
- X field_type = DATE
- X field_mask = "MM/DD/YY"
- X field_mustenter
- X field_prompt = "Enter starting date."
- X
- X ### $TDATE - To date.
- X
- X field_name = $TDATE
- X field_label = To
- X field_row = 3
- X field_col = 13
- X field_length = 6
- X field_type = DATE
- X field_mask = "MM/DD/YY"
- X field_mustenter
- X field_prompt = "Enter starting date."
- X
- X field_name = $PRIORITY
- X field_label = Priority
- X field_row = 5
- X field_col = 13
- X field_length = 6
- X field_type = MENU
- X field_range = "LOW,MEDIUM,HIGH"
- X field_prompt = "Select priority level."
- X
- X field_name = $LPDEST
- X field_label = Printer
- X field_row = 6
- X field_col = 13
- X field_length = 11
- X field_type = SET
- X field_range = "srv4e_700ps,srv4e_811a"
- X field_prompt = "Select printer."
- X
- X field_name = $TARGET
- X field_label = "Print To"
- X field_row = 7
- X field_col = 13
- X field_length = 8
- X field_type = SET
- X field_range = "TERMINAL,PRINTER,BOTH"
- X field_prompt = "Print to terminal or printer."
- XENDSCREEN
- SHAR_EOF
- chmod 0644 utilities.d/m.d/reportsrn.m || echo "restore of utilities.d/m.d/reportsrn.m fails"
- echo "x - extracting utilities.d/m.d/sadmin.m (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/sadmin.m &&
- X### Add new user stuff
- X### GROUP - default group for new users
- X### HOMEDIRS - where to make home directories for new users
- X
- XGROUP=users
- XHOMEDIRS=/tmp
- XPRINTER=NULL
- XDPROFILE=/tmp/profile.lacm
- XLOGSHELL=/bin/sh
- XUIDBASE=2000
- XPASSWDAGE=",O/"
- X
- XPWDFILE=/etc/passwd
- XGROUPFILE=/etc/group
- X
- X.TITLE
- X$LOGNAME ...System Administration...$DATE
- X.TITLE
- X...Menu...$TIME
- X.LINE
- X
- X.SYSTEM GETINPUT adduser \
- X suid_exec adduser $logname $PASSWDAGE $UID $GID "$realname" $HOMEDIRS $LOGSHELL $DPROFILE $PRINTER
- XAdd New User To System.
- X
- X.SYSTEM GETINPUT deluser \
- X suid_exec deluser $logname
- XRemove User From System.
- X
- X
- X
- X.DEFINE_SCREEN adduser
- X window_rows = 11
- X window_cols = 47
- X window_title = "Add New User Screen"
- X
- X field_name = $logname
- X field_label = "Login Name"
- X field_row = 2, field_col = 19
- X field_length = 8
- X field_type = ALPHANUM, field_mask = "A "
- X field_mustenter
- X
- X field_name = $realname
- X field_label = "Real Name"
- X field_row = 3, field_col = 19
- X field_length = 25
- X field_type = ALPHANUM
- X field_mustenter
- X
- X field_name = $UID
- X field_label = "User ID"
- X field_row = 4, field_col = 19
- X field_length = 5
- X field_noinput
- X
- X field_name = $GROUP
- X field_label = "Group"
- X field_row = 5, field_col = 19
- X field_length = 10
- X field_noinput
- X
- X field_name = $GID
- X field_label = "Group ID"
- X field_row = 6, field_col = 19
- X field_length = 5
- X field_noinput
- X
- X field_name = $HOMEDIRS
- X field_label = "Home Directory"
- X field_row = 7, field_col = 19
- X field_length = 25
- X field_noinput
- X
- X field_name = $PRINTER
- X field_label = "Default Printer"
- X field_row = 8, field_col = 19
- X field_length = 20
- X field_type = ALPHANUM
- X
- X field_defaults = "UID=`awk 'BEGIN{ FS=\":\" } { x[$3] = 1 } END { i = 2000; while (x[i] == 1) { ++i }; print i }' $PWDFILE`
- X GID=`awk 'BEGIN{FS=\":\"} {if($1 == g) print $3}' g=$GROUP $GROUPFILE`
- X echo NULL NULL $UID $GROUP $GID $HOMEDIRS $PRINTER"
- XENDSCREEN
- X
- X
- X.DEFINE_SCREEN deluser
- X window_rows = 5
- X window_cols = 25
- X window_title = "Delete User Screen"
- X
- X field_name = $logname
- X field_label = "Login Name"
- X field_row = 2, field_col = 14
- X field_length = 8
- X field_type = ALPHANUM, field_mask = "A "
- X field_mustenter
- XENDSCREEN
- SHAR_EOF
- chmod 0644 utilities.d/m.d/sadmin.m || echo "restore of utilities.d/m.d/sadmin.m fails"
- echo "x - extracting utilities.d/m.d/sample.m (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/sample.m &&
- X### Sample.Menu
- X### A sample menu script file.
- X
- X.TITLE
- X$LOGNAME ...SAMPLE...$DATE
- X.TITLE
- X$MAIL...MENU...$TIME
- X.LINE
- X
- X.GNAME sample sample.m
- X
- X.INCLUDE reportsrn.m
- X.INCLUDE passwdsrn.m
- X
- X.TEXT 22 61
- X"?" for help :
- X
- X.SYSTEM echo "Press [ ^d ] to return to menu ..."; ksh
- XUnix System.
- X
- X.SYSTEM who; \
- X echo "Press [ Return ] to continue ..."; \
- X read reply
- XShow Who Is On The System.
- X
- X.SYSTEM more sample.m; echo "Press [ Return ] to continue ...\c"; read reply
- XDisplay sample.m script file.
- X
- X.POPMENU printers.m
- XSelect Printer Menu ($LPDEST).
- X
- X.GETINPUT reportsrn
- XA Sample GETINPUT Screen.
- X
- X.GETINPUT passwdsrn
- XA Sample Password Screen.
- X
- X.SPACE
- X
- X.EXIT
- XExit Menu Program.
- SHAR_EOF
- chmod 0644 utilities.d/m.d/sample.m || echo "restore of utilities.d/m.d/sample.m fails"
- echo "x - extracting utilities.d/m.d/suid_exec.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/suid_exec.c &&
- X#include <stdio.h>
- X#include <fcntl.h>
- X#include <sys/stat.h>
- X
- X#define ROOT 0
- X
- Xmain (argc, argv)
- X int argc;
- X char *argv[];
- X{
- X int fd;
- X struct stat sbuf;
- X char command[200];
- X int i;
- X
- X
- X if (argc < 2)
- X exit (1);
- X
- X if ((fd = open (argv[1], O_RDONLY)) <= 0)
- X exit (1); /* can't open */
- X
- X /* Get file status information */
- X if (fstat (fd, &sbuf) < 0)
- X exit (1);
- X
- X /* Is this a regular file */
- X if ((sbuf.st_mode & S_IFREG) != S_IFREG)
- X exit (1);
- X
- X /* does root own this file */
- X if (sbuf.st_uid != ROOT)
- X exit (1);
- X
- X /* Is file executable by owner(root) */
- X if ((sbuf.st_mode & S_IEXEC) != S_IEXEC)
- X exit (1);
- X
- X /* Is set uid bit on */
- X if ((sbuf.st_mode & S_ISUID) != S_ISUID)
- X exit (1);
- X
- X setuid (ROOT);
- X
- X strcpy (command, argv[1]); /* program name */
- X for (i = 2; i < argc; i++)
- X {
- X strcat (command, " ");
- X strcat (command, "\"");
- X strcat (command, argv[i]); /* program arguments */
- X strcat (command, "\"");
- X }
- X
- X system (command);
- X}
- X/* Paul J. Condie 2-89 */
- SHAR_EOF
- chmod 0644 utilities.d/m.d/suid_exec.c || echo "restore of utilities.d/m.d/suid_exec.c fails"
- rm -f s2_seq_.tmp
- echo "You have unpacked the last part"
- exit 0
-