home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sources / 3b1 / 76 < prev    next >
Encoding:
Internet Message Format  |  1992-07-21  |  12.4 KB

  1. Path: sparky!uunet!comp-sources-3b1
  2. From: dave@galaxia.network23.com (David H. Brierley)
  3. Newsgroups: comp.sources.3b1
  4. Subject: v02i023:  pcmgr/smgr e-mail interface program for the 3b1, Part01/01
  5. Date: 21 Jul 1992 22:27:41 -0400
  6. Organization: UUNET Communications
  7. Lines: 393
  8. Sender: dhb@ftp.UU.NET
  9. Approved: dave@galaxia.network23.com
  10. Message-ID: <14ih2tINNd6g@ftp.UU.NET>
  11. NNTP-Posting-Host: ftp.uu.net
  12. X-Checksum-Snefru: 25c053ba f9b71d9c 75348848 07f5fd23
  13.  
  14. Submitted-by: dave@galaxia.network23.com (David H. Brierley)
  15. Posting-number: Volume 2, Issue 23
  16. Archive-name: email/part01
  17.  
  18. This is the README file for the Dave Brierley collection of miscellaneous
  19. source programs.  The collection is posted in seven separate pieces but
  20. all of the source came from the "misc" directory on my machine.  As a result
  21. of this, there is only one README file and only one Makefile, although each
  22. of the seven postings will contain a copy of these two files.  I suggest
  23. that you obtain (or save) as many of these postings as you are interested
  24. in, unpack them all in a single directory, and then compile the sources.
  25. Note that some of the programs are actually shell scripts and therefore do
  26. not need compilation.
  27.  
  28. email.c
  29.  A version of the "email" program.  This program should be installed as
  30.  /usr/bin/email and it will be used by pcmgr (or by smgr) when you click
  31.  on the envelope icon.  It provides a safe interface to the mail program
  32.  by making sure the uid is set correctly and by doing a chdir to the
  33.  users home directory (both of which are already being done by pcmgr).
  34.  This version also provides a unique feature of reading an "rc" file
  35.  from the users home directory (~/.email.rc), which can be used to specify
  36.  what mail program to use.  See the sample provided.
  37.  
  38. email.rc
  39.  Sample .email.rc file.
  40.  
  41. #! /bin/sh
  42. # This is a shell archive.  Remove anything before this line, then unpack
  43. # it by saving it into a file and typing "sh file".  To overwrite existing
  44. # files, type "sh file -c".  You can also feed this as standard input via
  45. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  46. # will see the following message at the end:
  47. #        "End of archive 1 (of 1)."
  48. # Contents:  MANIFEST Makefile README email.c email.rc
  49. # Wrapped by dave@galaxia on Tue Jul 21 10:54:09 1992
  50. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  51. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  52.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  53. else
  54. echo shar: Extracting \"'MANIFEST'\" \(251 characters\)
  55. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  56. X   File Name        Archive #    Description
  57. X-----------------------------------------------------------
  58. X MANIFEST                   1    
  59. X Makefile                   1    
  60. X README                     1    
  61. X email.c                    1    
  62. X email.rc                   1    
  63. END_OF_FILE
  64. if test 251 -ne `wc -c <'MANIFEST'`; then
  65.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  66. fi
  67. # end of 'MANIFEST'
  68. fi
  69. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  70.   echo shar: Will not clobber existing file \"'Makefile'\"
  71. else
  72. echo shar: Extracting \"'Makefile'\" \(374 characters\)
  73. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  74. XCFLAGS    = -O
  75. X
  76. Xall:        bsdln disktest email ndf techo wclipper
  77. X
  78. Xbsdln:        bsdln.o
  79. X        $(CC) bsdln.o
  80. X        mv a.out bsdln
  81. X
  82. Xdisktest:    disktest.o
  83. X        $(CC) disktest.o
  84. X        mv a.out disktest
  85. X
  86. Xemail:        email.o
  87. X        $(CC) email.o
  88. X        mv a.out email
  89. X
  90. Xndf:        ndf.o
  91. X        $(CC) ndf.o
  92. X        mv a.out ndf
  93. X
  94. Xtecho:        techo.o
  95. X        $(CC) techo.o
  96. X        mv a.out techo
  97. X
  98. Xwclipper:    wclipper.o
  99. X        $(CC) wclipper.o
  100. X        mv a.out wclipper
  101. X
  102. END_OF_FILE
  103. if test 374 -ne `wc -c <'Makefile'`; then
  104.     echo shar: \"'Makefile'\" unpacked with wrong size!
  105. fi
  106. # end of 'Makefile'
  107. fi
  108. if test -f 'README' -a "${1}" != "-c" ; then 
  109.   echo shar: Will not clobber existing file \"'README'\"
  110. else
  111. echo shar: Extracting \"'README'\" \(4280 characters\)
  112. sed "s/^X//" >'README' <<'END_OF_FILE'
  113. XThis is the README file for the Dave Brierley collection of miscellaneous
  114. Xsource programs.  The collection is posted in seven separate pieces but
  115. Xall of the source came from the "misc" directory on my machine.  As a result
  116. Xof this, there is only one README file and only one Makefile, although each
  117. Xof the seven postings will contain a copy of these two files.  I suggest
  118. Xthat you obtain (or save) as many of these postings as you are interested
  119. Xin, unpack them all in a single directory, and then compile the sources.
  120. XNote that some of the programs are actually shell scripts and therefore do
  121. Xnot need compilation.
  122. X
  123. XINSTALLATION INSTRUCTIONS:
  124. X1. Compile all the source programs by typing "make all".  Edit the Makefile
  125. X   if you did not unpack all seven of the pieces.  Note that the Makefile
  126. X   does not contain explicit commands for using the shared library.  I always
  127. X   depend on "ccc" to do this for me.
  128. X2. Copy the resultant executables to your favorite bin directory.  I always
  129. X   use "/usr/local/bin".
  130. X3. Copy the various shell scripts to the bin directory and make then executable
  131. X   using the chmod command.  The shell scripts are all distributed with a
  132. X   suffix of ".sh".  I suggest you remove this suffix when you install it, but
  133. X   that is entirely up to you.
  134. X
  135. X
  136. XDescription of programs included in this package.  There is a line of dashes
  137. Xseparating each of the seven pieces.
  138. X
  139. Xbsdln.c
  140. X A version of the ln command that follows the BSD behaviour.  I.e. if the
  141. X target file exists, the command will fail.  The standard 3b1 version will
  142. X remove the target.
  143. X
  144. X--------------------------------------------------------------------------
  145. X
  146. Xinstall.sh
  147. X A shell script version of the BSD install command.
  148. X
  149. Xnull.sh
  150. X Zero out one or more files.
  151. X
  152. Xtolower.sh
  153. X Convert file names to lower case.  Requires ksh.
  154. X
  155. Xtoupper.sh
  156. X Convert file names to upper case.  Requires ksh.
  157. X
  158. X--------------------------------------------------------------------------
  159. X
  160. Xndf.c
  161. X Almost emulates the BSD df command.  I say "almost" because I chose to
  162. X display the numbers in terms of blocks instead of kbytes since everything
  163. X else on the machine displays sizes in blocks.  Supports the "-i" option
  164. X to displays inode information.  Also supports specifying any random
  165. X directory as an argument and it will figure out what file system it is.
  166. X
  167. X--------------------------------------------------------------------------
  168. X
  169. Xdisktest.c
  170. X A program used by the format script to test the floppy disk to be doubly
  171. X sure that it is usable.
  172. X
  173. Xformat.sh
  174. X Format a floppy disk.  Asks questions to determine desired parameters, such
  175. X as number of cylinders and number of sectors.  Will optionally run an
  176. X intensive surface test of the floppy (see disktest.c), build a file system
  177. X structure, and make the floppy bootable.  The main processing is done in a
  178. X loop so you can format multiple floppies easily.
  179. X
  180. Xnewfs.sh
  181. X Reads the VHB from the floppy and then builds a file system structure on it.
  182. X
  183. X--------------------------------------------------------------------------
  184. X
  185. Xtecho.c
  186. X A version of echo that allows direct access to termcap capabilities.  A lot
  187. X easier to use than intermixing calls to echo with calls to tput.
  188. X
  189. Xtecho.1
  190. X Hey, I actually wrote a man page for this one!
  191. X
  192. X--------------------------------------------------------------------------
  193. X
  194. Xwclipper.c
  195. X A program to read in the wtmp file and output the tail end of it.  Useful
  196. X if you want to maintain an N-day history of who has been using your system.
  197. X The output size can be specified in terms of days or kbytes.
  198. X
  199. Xwtmp.fix.sh
  200. X A shell script to control the operation of wclipper.
  201. X
  202. X--------------------------------------------------------------------------
  203. X
  204. Xemail.c
  205. X A version of the "email" program.  This program should be installed as
  206. X /usr/bin/email and it will be used by pcmgr (or by smgr) when you click
  207. X on the envelope icon.  It provides a safe interface to the mail program
  208. X by making sure the uid is set correctly and by doing a chdir to the
  209. X users home directory (both of which are already being done by pcmgr).
  210. X This version also provides a unique feature of reading an "rc" file
  211. X from the users home directory (~/.email.rc), which can be used to specify
  212. X what mail program to use.  See the sample provided.
  213. X
  214. Xemail.rc
  215. X Sample .email.rc file.
  216. END_OF_FILE
  217. if test 4280 -ne `wc -c <'README'`; then
  218.     echo shar: \"'README'\" unpacked with wrong size!
  219. fi
  220. # end of 'README'
  221. fi
  222. if test -f 'email.c' -a "${1}" != "-c" ; then 
  223.   echo shar: Will not clobber existing file \"'email.c'\"
  224. else
  225. echo shar: Extracting \"'email.c'\" \(2781 characters\)
  226. sed "s/^X//" >'email.c' <<'END_OF_FILE'
  227. X#include <stdio.h>
  228. X#include <pwd.h>
  229. X#include <string.h>
  230. X
  231. X#ifndef    MAILER
  232. X# define MAILER    "elm"
  233. X#endif
  234. X
  235. X#define MAXARGS        32
  236. X
  237. Xvoid            check_rc ();
  238. Xvoid            exit ();
  239. Xchar           *malloc ();
  240. Xvoid            perror ();
  241. Xunsigned        sleep ();
  242. X
  243. Xmain (argc, argv)
  244. Xint             argc;
  245. Xchar           *argv[];
  246. X{
  247. X    struct passwd  *getpwnam ();
  248. X    struct passwd  *pwd;
  249. X    int             c;
  250. X    int             errflg;
  251. X    char           *username;
  252. X    char            home[BUFSIZ];
  253. X    char           *mailer[MAXARGS];
  254. X    extern int      optind;
  255. X    extern char    *optarg;
  256. X
  257. X    errflg = 0;
  258. X    username = NULL;
  259. X
  260. X    while ((c = getopt (argc, argv, "iu:")) != EOF)
  261. X    switch (c) {
  262. X    case 'i':
  263. X        break;
  264. X    case 'u':
  265. X        username = optarg;
  266. X        break;
  267. X    case '?':
  268. X        errflg++;
  269. X        break;
  270. X    }
  271. X
  272. X    if (errflg || (username == NULL)) {
  273. X    (void) fprintf (stderr, "usage: email -i -u username\n");
  274. X    (void) sleep (30);
  275. X    exit (2);
  276. X    }
  277. X
  278. X    if ((pwd = getpwnam (username)) == NULL) {
  279. X    (void) fprintf (stderr, "email: unknown username %s\n", username);
  280. X    (void) sleep (30);
  281. X    exit (3);
  282. X    }
  283. X
  284. X    (void) setgid (pwd -> pw_gid);
  285. X    (void) setuid (pwd -> pw_uid);
  286. X    (void) umask (077);        /* better to be overly secure */
  287. X
  288. X    (void) strcpy (home, "HOME=");
  289. X    (void) strcat (home, pwd -> pw_dir);
  290. X    (void) putenv (home);
  291. X
  292. X    (void) chdir (pwd -> pw_dir);
  293. X    mailer[0] = MAILER;
  294. X    mailer[1] = NULL;
  295. X
  296. X    check_rc (mailer);
  297. X
  298. X    (void) execvp (mailer[0], mailer);
  299. X
  300. X    /* NOTREACHED */
  301. X    return (0);
  302. X
  303. X}
  304. X
  305. Xvoid
  306. Xcheck_rc (mailer)
  307. Xchar           *mailer[];
  308. X{
  309. X    FILE           *rc;
  310. X    static char     buffer[BUFSIZ];
  311. X    auto char      *value;
  312. X    auto char      *blank;
  313. X    int             newmask;
  314. X    int             argc;
  315. X
  316. X    if ((rc = fopen (".email.rc", "r")) == NULL) {
  317. X    return;
  318. X    }
  319. X
  320. X    while (fgets (buffer, BUFSIZ, rc) != NULL) {
  321. X    buffer[strlen (buffer) - 1] = '\0';
  322. X    if ((blank = strchr (buffer, ' ')) != NULL) {
  323. X        *blank++ = '\0';
  324. X    }
  325. X    if (strcmp (buffer, "mailer") == 0) {
  326. X        argc = 0;
  327. X        while (blank != NULL) {
  328. X        value = blank;
  329. X        while (*value == ' ') {
  330. X            ++value;
  331. X        }
  332. X        if ((blank = strchr (value, ' ')) != NULL) {
  333. X            *blank++ = '\0';
  334. X        }
  335. X        mailer[argc] = malloc ((unsigned) (strlen (value) + 1));
  336. X        if (mailer[argc] == NULL) {
  337. X            perror ("email");
  338. X            (void) fprintf (stderr, "Unable to allocate memory\n");
  339. X            exit (1);
  340. X        }
  341. X        (void) strcpy (mailer[argc], value);
  342. X        argc++;
  343. X        }
  344. X        mailer[argc] = NULL;
  345. X        continue;
  346. X    }
  347. X    if (strcmp (buffer, "umask") == 0) {
  348. X        if (sscanf (blank, "%o", &newmask) == 1) {
  349. X        (void) umask (newmask);
  350. X        }
  351. X        continue;
  352. X    }
  353. X    if (strcmp (buffer, "stty") == 0) {
  354. X        if (blank != NULL) {
  355. X        *--blank = ' ';
  356. X        }
  357. X        (void) system (buffer);
  358. X        continue;
  359. X    }
  360. X    }
  361. X
  362. X    (void) fclose (rc);
  363. X
  364. X}
  365. END_OF_FILE
  366. if test 2781 -ne `wc -c <'email.c'`; then
  367.     echo shar: \"'email.c'\" unpacked with wrong size!
  368. fi
  369. # end of 'email.c'
  370. fi
  371. if test -f 'email.rc' -a "${1}" != "-c" ; then 
  372.   echo shar: Will not clobber existing file \"'email.rc'\"
  373. else
  374. echo shar: Extracting \"'email.rc'\" \(70 characters\)
  375. sed "s/^X//" >'email.rc' <<'END_OF_FILE'
  376. Xstty erase ^H intr ^? kill ^U
  377. Xmailer /usr/local/bin/mush -C
  378. Xumask 077
  379. END_OF_FILE
  380. if test 70 -ne `wc -c <'email.rc'`; then
  381.     echo shar: \"'email.rc'\" unpacked with wrong size!
  382. fi
  383. # end of 'email.rc'
  384. fi
  385. echo shar: End of archive 1 \(of 1\).
  386. cp /dev/null ark1isdone
  387. MISSING=""
  388. for I in 1 ; do
  389.     if test ! -f ark${I}isdone ; then
  390.     MISSING="${MISSING} ${I}"
  391.     fi
  392. done
  393. if test "${MISSING}" = "" ; then
  394.     echo You have the archive.
  395.     rm -f ark[1-9]isdone
  396. else
  397.     echo You still need to unpack the following archives:
  398.     echo "        " ${MISSING}
  399. fi
  400. ##  End of shell archive.
  401. exit 0
  402. -- 
  403. David H. Brierley
  404. Home: dave@galaxia.network23.com; Work: dhb@quahog.ssd.ray.com
  405. Send comp.sources.3b1 submissions to comp-sources-3b1@galaxia.network23.com
  406. %% Can I be excused, my brain is full. **
  407.