1/* Wrapper code for Taylor UUCP on Amiga Unix (SVR4) for cron invoked UUCP */
2/* uucico. */
3
4/* The problem: Cron and rmail (as forked by uuxqt, which may in
5   turn invoke uucico) are not "licensed" processes. Any process
6   that grabs a controlling terminal needs to be licensed.  Taylor
7   UUCP needs controlling terminals.  Taylor UUCP does relinquish
8   the controlling terminal before fork(), so the "UUCP" license is
9   appropriate.  This simple program does the "right" thing, but
10   *MUST* be SETUID ROOT.
11
12   To use this program, you must move 'uucico' to 'uucico.real' (or
13   change the *name = below), compile this program, move it to where
14   uucico was originally, and make it SETUID ROOT.
15
16   This program is intended to be used as a wapper for Taylor UUCP's
17   uucico so that the annoying 'unlicensed user attempted to fork'
18   messages are eliminated.  */
19
20/* Written by: Lawrence E. Rosenman <ler@lerami.lerctr.org>
21   Modified by: Donald Phillips <don@blkhole.resun.com> */
22
23#include <sys/sysm68k.h>
24#include <sys/types.h>
25#include <stdio.h>
26#include <errno.h>
27#include <unistd.h>
28#include <pwd.h>
29
30int main(int argc,char *argv[],char *envp)
31{
32  struct passwd *pw;
33  char   *name = {"/usr/lib/uucp/uucico.real"};
34
35  if (sysm68k(_m68k_LIMUSER,EUA_GET_LIC) == 0 ) { /* are we unlicensed? */
36    if (sysm68k(_m68k_LIMUSER,EUA_UUCP) == -1) { /* yes, get a "uucp"
37                                                    license */
38      fprintf(stderr,"sysm68k failed, errno=%d\n",errno); /* we didn't grab
39                                                             it? */
40      exit(errno);
41    }
42
43    pw = getpwnam("uucp");        /* get the Password Entry for uucp */
44    if (pw == NULL) {
45      fprintf(stderr,"User ID \"uucp\" doesn't exist.\n");
46      exit(1);
47    }
48    setgid(pw->pw_gid);           /* set gid to uucp */
49    setuid(pw->pw_uid);           /* set uid to uucp */
50  }
51
52  argv[0]=name;                 /* have PS not lie... */
53  execv(name, argv);            /* go to the real program */
54  exit(errno);
55}
56