BSD 3 development
[unix-history] / usr / src / cmd / uucp / uuxqt.c
index 4d5f3b4..fa0f72a 100644 (file)
@@ -16,7 +16,6 @@ for (p = d; *p != '\0';) *cmdp++ = *p++;\
  */
 
 char *Cmds[] = {
  */
 
 char *Cmds[] = {
-       "mail",
        "rmail",
        "lpr",
        "opr",
        "rmail",
        "lpr",
        "opr",
@@ -24,10 +23,9 @@ char *Cmds[] = {
        "fget",
        NULL
        };
        "fget",
        NULL
        };
-#define CMDOK(a, b)    cmdok(a,b)
 #define PATH   "PATH=/bin:/usr/bin;"
 /*  to remove restrictions from uuxqt
 #define PATH   "PATH=/bin:/usr/bin;"
 /*  to remove restrictions from uuxqt
- *  redefine CMDOK 0
+ *  define ALLOK 1
  *
  *  to add allowable commands, add to the list under Cmds[]
  */
  *
  *  to add allowable commands, add to the list under Cmds[]
  */
@@ -49,7 +47,9 @@ char *argv[];
        char *getprm();
        int uid, ret;
        int stcico = 0;
        char *getprm();
        int uid, ret;
        int stcico = 0;
-       Debug = 0;
+       char rnum[5];
+
+       uucpname(Myname);
        Ofn = 1;
        Ifn = 0;
        while (argc>1 && argv[1][0] == '-') {
        Ofn = 1;
        Ifn = 0;
        while (argc>1 && argv[1][0] == '-') {
@@ -139,7 +139,7 @@ char *argv[];
                                APPCMD(prm);
                                continue;
                        }
                                APPCMD(prm);
                                continue;
                        }
-                       if ((cmdnok = CMDOK(xcmd, prm)) != 0) 
+                       if ((cmdnok = cmdok(xcmd, prm)) != 0) 
                                /*  command not valid  */
                                break;
 
                                /*  command not valid  */
                                break;
 
@@ -151,6 +151,7 @@ char *argv[];
                        sprintf(lbuf, "%s XQT DENIED", user);
                        logent(cmd, lbuf);
                        DEBUG(4, "bad command %s\n", prm);
                        sprintf(lbuf, "%s XQT DENIED", user);
                        logent(cmd, lbuf);
                        DEBUG(4, "bad command %s\n", prm);
+                       notify(user, Rmtname, cmd, "DENIED");
                        goto rmfiles;
                }
                sprintf(lbuf, "%s XQT", user);
                        goto rmfiles;
                }
                sprintf(lbuf, "%s XQT", user);
@@ -160,6 +161,10 @@ char *argv[];
                mvxfiles(xfile);
                chdir(XQTDIR);
                ret = shio(buf, fin, dfile, user);
                mvxfiles(xfile);
                chdir(XQTDIR);
                ret = shio(buf, fin, dfile, user);
+               sprintf(rnum, "%d", ret);
+               if (strcmp(xcmd, "rmail") != SAME
+                 && strcmp(xcmd, "mail") != SAME)
+                       notify(user, Rmtname, cmd, rnum);
                DEBUG(4, "exit cmd - %d\n", ret);
                chdir(Spool);
                rmxfiles(xfile);
                DEBUG(4, "exit cmd - %d\n", ret);
                chdir(Spool);
                rmxfiles(xfile);
@@ -347,6 +352,8 @@ char *xfile;
 
 /***
  *     cmdok(xc, cmd)          check for valid command
 
 /***
  *     cmdok(xc, cmd)          check for valid command
+ *                     *NOTE - side effect is to set xc to the
+ *                             command to be executed.
  *     char *xc, *cmd;
  *
  *     return 0 - ok | 1 nok
  *     char *xc, *cmd;
  *
  *     return 0 - ok | 1 nok
@@ -359,16 +366,38 @@ char *xc, *cmd;
 
        if (xc[0] != '\0')
                return(0);
 
        if (xc[0] != '\0')
                return(0);
+#ifndef ALLOK
        ptr = Cmds;
        while(*ptr != NULL) {
        ptr = Cmds;
        while(*ptr != NULL) {
-DEBUG(4, "cmd %s, ", cmd);
-DEBUG(4, "ptr %s\n", *ptr);
                if (strcmp(cmd, *ptr) == SAME)
                        break;
        ptr++;
        }
        if (*ptr == NULL)
                return(1);
                if (strcmp(cmd, *ptr) == SAME)
                        break;
        ptr++;
        }
        if (*ptr == NULL)
                return(1);
+#endif
        strcpy(xc, cmd);
        return(0);
 }
        strcpy(xc, cmd);
        return(0);
 }
+
+
+/***
+ *     notify  send mail to user giving execution results
+ *     return code - none
+ *     This program assumes new mail command - send remote mail
+ */
+
+notify(user, rmt, cmd, str)
+char *user, *rmt, *cmd, *str;
+{
+       char text[100];
+       char ruser[100];
+
+       sprintf(text, "uuxqt cmd (%s) status (%s)", cmd, str);
+       if (prefix(rmt, Myname))
+               strcpy(ruser, user);
+       else
+               sprintf(ruser, "%s!%s", rmt, user);
+       mailst(ruser, text);
+       return;
+}