for (p = d; *p != '\0';) *cmdp++ = *p++;\
* uuxqt will execute commands set up by a uux command,
* usually from a remote machine - set by uucp.
#define PATH "PATH=/bin:/usr/bin;"
/* to remove restrictions from uuxqt
* to add allowable commands, add to the list under Cmds[]
char xfile
[MAXFULLNAME
], user
[10], buf
[BUFSIZ
];
char cfile
[NAMESIZE
], dfile
[MAXFULLNAME
];
char fin
[MAXFULLNAME
], sysout
[NAMESIZE
], fout
[MAXFULLNAME
];
char *cmdp
, prm
[MAXFULLNAME
], *ptr
;
while (argc
>1 && argv
[1][0] == '-') {
Debug
= atoi(&argv
[1][2]);
sprintf(stderr
, "unknown flag %s\n", argv
[1]);
DEBUG(4, "\n\n** %s **\n", "START");
DEBUG(4, "User - %s\n", User
);
if (ulockf(X_LOCK
, X_LOCKTIME
) != 0)
DEBUG(4, "process %s\n", "");
while (gtxfile(xfile
) > 0) {
DEBUG(4, "xfile - %s\n", xfile
);
ASSERT(xfp
!= NULL
, "CAN'T OPEN %s", xfile
);
/* initialize to default */
strcpy(fin
, "/dev/null");
strcpy(fout
, "/dev/null");
sprintf(sysout
, "%.7s", Myname
);
while (fgets(buf
, BUFSIZ
, xfp
) != NULL
) {
sscanf(&buf
[1], "%s%s", user
, Rmtname
);
sscanf(&buf
[1], "%s", fin
);
sscanf(&buf
[1], "%s%s", fout
, sysout
);
if (fout
[0] != '~' || prefix(sysout
, Myname
))
if (*(cmd
+ strlen(cmd
) - 1) == '\n')
*(cmd
+ strlen(cmd
) - 1) = '\0';
DEBUG(4, "fin - %s, ", fin
);
DEBUG(4, "fout - %s, ", fout
);
DEBUG(4, "sysout - %s, ", sysout
);
DEBUG(4, "user - %s\n", user
);
DEBUG(4, "cmd - %s\n", cmd
);
if (strcmp(fout
, "/dev/null") == SAME
)
strcpy(dfile
,"/dev/null");
gename(DATAPRE
, sysout
, 'O', dfile
);
/* expand file names where necessary */
cmdp
= buf
+ strlen(buf
);
while ((ptr
= getprm(ptr
, prm
)) != NULL
) {
if (prm
[0] == ';' || prm
[0] == '^'
if ((cmdnok
= cmdok(xcmd
, prm
)) != 0)
sprintf(lbuf
, "%s XQT DENIED", user
);
DEBUG(4, "bad command %s\n", prm
);
notify(user
, Rmtname
, cmd
, "DENIED");
sprintf(lbuf
, "%s XQT", user
);
DEBUG(4, "cmd %s\n", buf
);
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
);
/* exit status not zero */
ASSERT(dfp
!= NULL
, "CAN'T OPEN %s", dfile
);
fprintf(dfp
, "exit status %d", ret
);
if (strcmp(fout
, "/dev/null") != SAME
) {
if (prefix(sysout
, Myname
)) {
gename(CMDPRE
, sysout
, 'O', cfile
);
ASSERT(fp
!= NULL
, "OPEN %s", cfile
);
fprintf(fp
, "S %s %s %s - %s 0666\n",
dfile
, fout
, user
, lastpart(dfile
));
ASSERT(xfp
!= NULL
, "CAN'T OPEN %s", xfile
);
while (fgets(buf
, BUFSIZ
, xfp
) != NULL
) {
sscanf(&buf
[1], "%s", file
);
* gtxfile(file) get a file to execute
* return codes: 0 - no file | 1 - file to execute
pdir
= fopen(Spool
, "r");
ASSERT(pdir
!= NULL
, "GTXFILE CAN'T OPEN %s", Spool
);
while (gnamef(pdir
, file
) != 0) {
DEBUG(4, "file - %s\n", file
);
/* return file to execute */
* gotfiles(file) check for needed files
* return codes: 0 - not ready | 1 - all files ready
char buf
[BUFSIZ
], rqfile
[MAXFULLNAME
];
while (fgets(buf
, BUFSIZ
, fp
) != NULL
) {
sscanf(&buf
[1], "%s", rqfile
);
if (stat(rqfile
, &stbuf
) == -1) {
* rmxfiles(xfile) remove execute files to x-directory
char buf
[BUFSIZ
], file
[NAMESIZE
], tfile
[NAMESIZE
];
if((fp
= fopen(xfile
, "r")) == NULL
)
while (fgets(buf
, BUFSIZ
, fp
) != NULL
) {
if (sscanf(&buf
[1], "%s%s", file
, tfile
) < 2)
sprintf(tfull
, "%s/%s", XQTDIR
, tfile
);
* mvxfiles(xfile) move execute files to x-directory
char buf
[BUFSIZ
], ffile
[MAXFULLNAME
], tfile
[NAMESIZE
];
if((fp
= fopen(xfile
, "r")) == NULL
)
while (fgets(buf
, BUFSIZ
, fp
) != NULL
) {
if (sscanf(&buf
[1], "%s%s", ffile
, tfile
) < 2)
sprintf(tfull
, "%s/%s", XQTDIR
, tfile
);
ret
= link(ffile
, tfull
);
ASSERT(ret
== 0, "LINK RET-%d", ret
);
* cmdok(xc, cmd) check for valid command
* *NOTE - side effect is to set xc to the
* command to be executed.
if (strcmp(cmd
, *ptr
) == SAME
)
* notify send mail to user giving execution results
* This program assumes new mail command - send remote mail
notify(user
, rmt
, cmd
, str
)
char *user
, *rmt
, *cmd
, *str
;
sprintf(text
, "uuxqt cmd (%s) status (%s)", cmd
, str
);
sprintf(ruser
, "%s!%s", rmt
, user
);