Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 +2.11; site dcl-cs.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!mcvax!ukc!icdoc!dcl-cs!stephen From: stephen@dcl-cs.UUCP (Stephen J. Muir) Newsgroups: net.sources Subject: Program for maintaining mailing lists (sendmail). Message-ID: <355@dcl-cs.UUCP> Date: Tue, 6-Aug-85 20:45:34 EDT Article-I.D.: dcl-cs.355 Posted: Tue Aug 6 20:45:34 1985 Date-Received: Sat, 10-Aug-85 22:33:08 EDT Reply-To: stephen@dcl-cs.UUCP (Stephen J. Muir) Organization: Department of Computing at Lancaster University. Lines: 107 Xpath: icdoc ivax I wanted to maintain large mailing lists using "sendmail". I only knew of two ways of doing this: - set up a login name with a ".forward" file OR - set up aliases in "/usr/lib/aliases" I didn't want to set up login names and "/usr/lib/aliases" would have become too unwieldy, so I wrote another program to do it and this follows. If there is another way to do it, or there is a better program about, please mail me. Installation: Compile the following program and put in "/usr/bin/maillistfile". Create a file containing all the mailboxes in the list, one per line. Put an entry of the following form in "/usr/lib/aliases": fire-lovers:"|maillistfile /usr/gurus/elton/fire-lovers". ----------------------------------- cut here ---------------------------------- #!/bin/sh echo 'Start of pack.out, part 01 of 01:' echo 'x - maillistfile.c' sed 's/^X//' > maillistfile.c << '/' X/* Written by Stephen J. Muir, Computing Dept., Lancaster University */ X X# includeX# include X# include X# include X Xextern char *malloc (); X Xchar *mailer = "/usr/lib/sendmail", **newargv, **nargvp; X Xint fd, count; X Xstruct stat stat; X Xmain (argc, argv, envp) X char *argv [], *envp []; X { register char *cp, *recipients; X if (argc != 2) X { fprintf (stderr, "usage: maillistfile file\n"); X exit (1); X } X if ((fd = open (argv [1], O_RDONLY, 0)) == -1) X { perror (argv [1]); X exit (1); X } X setuid (getuid ()); X (void)fstat (fd, &stat); X if ((stat.st_mode & S_IFMT) != S_IFREG) X { fprintf (stderr, "%s: not a regular file", argv [1]); X exit (1); X } X if ((recipients = malloc (stat.st_size)) == 0) X { fprintf (stderr, "Out of memory.\n"); X exit (1); X } X if (read (fd, recipients, stat.st_size) != stat.st_size) X { perror ("read()"); X exit (1); X } X for (cp = recipients; cp < recipients + stat.st_size; ++cp) X if (*cp == '\0') X { fprintf (stderr, "%s: null byte in file\n", argv [1]); X exit (1); X } X else if (*cp == '\n') X { *cp = '\0'; X ++count; X } X if (*--cp != '\0') X { fprintf (stderr, "%s: incomplete last line\n", argv [1]); X exit (1); X } X if (count == 0) X { fprintf (stderr, "%s: empty list\n", argv [1]); X exit (1); X } X if ((nargvp = X newargv = X (char **)malloc ((sizeof (char **)) * (count + 3)) X ) == 0 X ) X { fprintf (stderr, "Out of memory.\n"); X exit (1); X } X *nargvp++ = "maillist"; X *nargvp++ = "-oMslist-channel"; X cp = recipients; X while (count--) X { *nargvp++ = cp; X while (*cp++ != '\0'); X } X *nargvp++ = 0; X execve (mailer, newargv, envp); X perror (mailer); X exit (1); X } / echo 'Part 01 of pack.out complete.' exit -- UUCP: ...!seismo!mcvax!ukc!dcl-cs!stephen DARPA: stephen%lancs.comp@ucl-cs | Post: University of Lancaster, JANET: stephen@uk.ac.lancs.comp | Department of Computing, Phone: +44 524 65201 Ext. 4599 | Bailrigg, Lancaster, UK. Project:Alvey ECLIPSE Distribution | LA1 4YR