home *** CD-ROM | disk | FTP | other *** search
- Path: comp-sources-3b1
- From: dave@galaxia.network23.com (David H. Brierley)
- Subject: v02i023: pcmgr/smgr e-mail interface program for the 3b1, Part01/01
- Newsgroups: comp.sources.3b1
- Approved: dave@galaxia.network23.com
- X-Checksum-Snefru: 25c053ba f9b71d9c 75348848 07f5fd23
-
- Submitted-by: dave@galaxia.network23.com (David H. Brierley)
- Posting-number: Volume 2, Issue 23
- Archive-name: email/part01
-
- This is the README file for the Dave Brierley collection of miscellaneous
- source programs. The collection is posted in seven separate pieces but
- all of the source came from the "misc" directory on my machine. As a result
- of this, there is only one README file and only one Makefile, although each
- of the seven postings will contain a copy of these two files. I suggest
- that you obtain (or save) as many of these postings as you are interested
- in, unpack them all in a single directory, and then compile the sources.
- Note that some of the programs are actually shell scripts and therefore do
- not need compilation.
-
- email.c
- A version of the "email" program. This program should be installed as
- /usr/bin/email and it will be used by pcmgr (or by smgr) when you click
- on the envelope icon. It provides a safe interface to the mail program
- by making sure the uid is set correctly and by doing a chdir to the
- users home directory (both of which are already being done by pcmgr).
- This version also provides a unique feature of reading an "rc" file
- from the users home directory (~/.email.rc), which can be used to specify
- what mail program to use. See the sample provided.
-
- email.rc
- Sample .email.rc file.
-
- #! /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 1)."
- # Contents: MANIFEST Makefile README email.c email.rc
- # Wrapped by dave@galaxia on Tue Jul 21 10:54:09 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'MANIFEST' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'MANIFEST'\"
- else
- echo shar: Extracting \"'MANIFEST'\" \(251 characters\)
- sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
- X File Name Archive # Description
- X-----------------------------------------------------------
- X MANIFEST 1
- X Makefile 1
- X README 1
- X email.c 1
- X email.rc 1
- END_OF_FILE
- if test 251 -ne `wc -c <'MANIFEST'`; then
- echo shar: \"'MANIFEST'\" unpacked with wrong size!
- fi
- # end of 'MANIFEST'
- fi
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(374 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- XCFLAGS = -O
- X
- Xall: bsdln disktest email ndf techo wclipper
- X
- Xbsdln: bsdln.o
- X $(CC) bsdln.o
- X mv a.out bsdln
- X
- Xdisktest: disktest.o
- X $(CC) disktest.o
- X mv a.out disktest
- X
- Xemail: email.o
- X $(CC) email.o
- X mv a.out email
- X
- Xndf: ndf.o
- X $(CC) ndf.o
- X mv a.out ndf
- X
- Xtecho: techo.o
- X $(CC) techo.o
- X mv a.out techo
- X
- Xwclipper: wclipper.o
- X $(CC) wclipper.o
- X mv a.out wclipper
- X
- END_OF_FILE
- if test 374 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- # end of 'Makefile'
- fi
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(4280 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- XThis is the README file for the Dave Brierley collection of miscellaneous
- Xsource programs. The collection is posted in seven separate pieces but
- Xall of the source came from the "misc" directory on my machine. As a result
- Xof this, there is only one README file and only one Makefile, although each
- Xof the seven postings will contain a copy of these two files. I suggest
- Xthat you obtain (or save) as many of these postings as you are interested
- Xin, unpack them all in a single directory, and then compile the sources.
- XNote that some of the programs are actually shell scripts and therefore do
- Xnot need compilation.
- X
- XINSTALLATION INSTRUCTIONS:
- X1. Compile all the source programs by typing "make all". Edit the Makefile
- X if you did not unpack all seven of the pieces. Note that the Makefile
- X does not contain explicit commands for using the shared library. I always
- X depend on "ccc" to do this for me.
- X2. Copy the resultant executables to your favorite bin directory. I always
- X use "/usr/local/bin".
- X3. Copy the various shell scripts to the bin directory and make then executable
- X using the chmod command. The shell scripts are all distributed with a
- X suffix of ".sh". I suggest you remove this suffix when you install it, but
- X that is entirely up to you.
- X
- X
- XDescription of programs included in this package. There is a line of dashes
- Xseparating each of the seven pieces.
- X
- Xbsdln.c
- X A version of the ln command that follows the BSD behaviour. I.e. if the
- X target file exists, the command will fail. The standard 3b1 version will
- X remove the target.
- X
- X--------------------------------------------------------------------------
- X
- Xinstall.sh
- X A shell script version of the BSD install command.
- X
- Xnull.sh
- X Zero out one or more files.
- X
- Xtolower.sh
- X Convert file names to lower case. Requires ksh.
- X
- Xtoupper.sh
- X Convert file names to upper case. Requires ksh.
- X
- X--------------------------------------------------------------------------
- X
- Xndf.c
- X Almost emulates the BSD df command. I say "almost" because I chose to
- X display the numbers in terms of blocks instead of kbytes since everything
- X else on the machine displays sizes in blocks. Supports the "-i" option
- X to displays inode information. Also supports specifying any random
- X directory as an argument and it will figure out what file system it is.
- X
- X--------------------------------------------------------------------------
- X
- Xdisktest.c
- X A program used by the format script to test the floppy disk to be doubly
- X sure that it is usable.
- X
- Xformat.sh
- X Format a floppy disk. Asks questions to determine desired parameters, such
- X as number of cylinders and number of sectors. Will optionally run an
- X intensive surface test of the floppy (see disktest.c), build a file system
- X structure, and make the floppy bootable. The main processing is done in a
- X loop so you can format multiple floppies easily.
- X
- Xnewfs.sh
- X Reads the VHB from the floppy and then builds a file system structure on it.
- X
- X--------------------------------------------------------------------------
- X
- Xtecho.c
- X A version of echo that allows direct access to termcap capabilities. A lot
- X easier to use than intermixing calls to echo with calls to tput.
- X
- Xtecho.1
- X Hey, I actually wrote a man page for this one!
- X
- X--------------------------------------------------------------------------
- X
- Xwclipper.c
- X A program to read in the wtmp file and output the tail end of it. Useful
- X if you want to maintain an N-day history of who has been using your system.
- X The output size can be specified in terms of days or kbytes.
- X
- Xwtmp.fix.sh
- X A shell script to control the operation of wclipper.
- X
- X--------------------------------------------------------------------------
- X
- Xemail.c
- X A version of the "email" program. This program should be installed as
- X /usr/bin/email and it will be used by pcmgr (or by smgr) when you click
- X on the envelope icon. It provides a safe interface to the mail program
- X by making sure the uid is set correctly and by doing a chdir to the
- X users home directory (both of which are already being done by pcmgr).
- X This version also provides a unique feature of reading an "rc" file
- X from the users home directory (~/.email.rc), which can be used to specify
- X what mail program to use. See the sample provided.
- X
- Xemail.rc
- X Sample .email.rc file.
- END_OF_FILE
- if test 4280 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f 'email.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'email.c'\"
- else
- echo shar: Extracting \"'email.c'\" \(2781 characters\)
- sed "s/^X//" >'email.c' <<'END_OF_FILE'
- X#include <stdio.h>
- X#include <pwd.h>
- X#include <string.h>
- X
- X#ifndef MAILER
- X# define MAILER "elm"
- X#endif
- X
- X#define MAXARGS 32
- X
- Xvoid check_rc ();
- Xvoid exit ();
- Xchar *malloc ();
- Xvoid perror ();
- Xunsigned sleep ();
- X
- Xmain (argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X struct passwd *getpwnam ();
- X struct passwd *pwd;
- X int c;
- X int errflg;
- X char *username;
- X char home[BUFSIZ];
- X char *mailer[MAXARGS];
- X extern int optind;
- X extern char *optarg;
- X
- X errflg = 0;
- X username = NULL;
- X
- X while ((c = getopt (argc, argv, "iu:")) != EOF)
- X switch (c) {
- X case 'i':
- X break;
- X case 'u':
- X username = optarg;
- X break;
- X case '?':
- X errflg++;
- X break;
- X }
- X
- X if (errflg || (username == NULL)) {
- X (void) fprintf (stderr, "usage: email -i -u username\n");
- X (void) sleep (30);
- X exit (2);
- X }
- X
- X if ((pwd = getpwnam (username)) == NULL) {
- X (void) fprintf (stderr, "email: unknown username %s\n", username);
- X (void) sleep (30);
- X exit (3);
- X }
- X
- X (void) setgid (pwd -> pw_gid);
- X (void) setuid (pwd -> pw_uid);
- X (void) umask (077); /* better to be overly secure */
- X
- X (void) strcpy (home, "HOME=");
- X (void) strcat (home, pwd -> pw_dir);
- X (void) putenv (home);
- X
- X (void) chdir (pwd -> pw_dir);
- X mailer[0] = MAILER;
- X mailer[1] = NULL;
- X
- X check_rc (mailer);
- X
- X (void) execvp (mailer[0], mailer);
- X
- X /* NOTREACHED */
- X return (0);
- X
- X}
- X
- Xvoid
- Xcheck_rc (mailer)
- Xchar *mailer[];
- X{
- X FILE *rc;
- X static char buffer[BUFSIZ];
- X auto char *value;
- X auto char *blank;
- X int newmask;
- X int argc;
- X
- X if ((rc = fopen (".email.rc", "r")) == NULL) {
- X return;
- X }
- X
- X while (fgets (buffer, BUFSIZ, rc) != NULL) {
- X buffer[strlen (buffer) - 1] = '\0';
- X if ((blank = strchr (buffer, ' ')) != NULL) {
- X *blank++ = '\0';
- X }
- X if (strcmp (buffer, "mailer") == 0) {
- X argc = 0;
- X while (blank != NULL) {
- X value = blank;
- X while (*value == ' ') {
- X ++value;
- X }
- X if ((blank = strchr (value, ' ')) != NULL) {
- X *blank++ = '\0';
- X }
- X mailer[argc] = malloc ((unsigned) (strlen (value) + 1));
- X if (mailer[argc] == NULL) {
- X perror ("email");
- X (void) fprintf (stderr, "Unable to allocate memory\n");
- X exit (1);
- X }
- X (void) strcpy (mailer[argc], value);
- X argc++;
- X }
- X mailer[argc] = NULL;
- X continue;
- X }
- X if (strcmp (buffer, "umask") == 0) {
- X if (sscanf (blank, "%o", &newmask) == 1) {
- X (void) umask (newmask);
- X }
- X continue;
- X }
- X if (strcmp (buffer, "stty") == 0) {
- X if (blank != NULL) {
- X *--blank = ' ';
- X }
- X (void) system (buffer);
- X continue;
- X }
- X }
- X
- X (void) fclose (rc);
- X
- X}
- END_OF_FILE
- if test 2781 -ne `wc -c <'email.c'`; then
- echo shar: \"'email.c'\" unpacked with wrong size!
- fi
- # end of 'email.c'
- fi
- if test -f 'email.rc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'email.rc'\"
- else
- echo shar: Extracting \"'email.rc'\" \(70 characters\)
- sed "s/^X//" >'email.rc' <<'END_OF_FILE'
- Xstty erase ^H intr ^? kill ^U
- Xmailer /usr/local/bin/mush -C
- Xumask 077
- END_OF_FILE
- if test 70 -ne `wc -c <'email.rc'`; then
- echo shar: \"'email.rc'\" unpacked with wrong size!
- fi
- # end of 'email.rc'
- fi
- echo shar: End of archive 1 \(of 1\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have the archive.
- 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
- --
- David H. Brierley
- Home: dave@galaxia.network23.com; Work: dhb@quahog.ssd.ray.com
- Send comp.sources.3b1 submissions to comp-sources-3b1@galaxia.network23.com
- %% Can I be excused, my brain is full. **
-