static char sccsid
[] = "@(#)mailst.c 5.5 (Berkeley) %G%";
* mailst - this routine will fork and execute
* a mail command sending string (str) to user (user).
* If file is non-null, the file is also sent.
* (this is used for mail returned to sender.)
sprintf(buf
, "%s '%s'", MAIL
, user
);
if ((fp
= rpopen(buf
, "w")) != NULL
) {
fprintf(fp
, "From: uucp\nTo: %s\nSubject: %s\n\n", user
, str
);
if (file
&& *file
!= '\0' && (fi
= fopen(subfile(file
), "r")) != NULL
) {
while ((c
= getc(fi
)) != EOF
)
* 'reverting' version of popen
* which runs process with permissions of real gid/uid
* rather than the effective gid/uid.
#define tst(a,b) (*mode == 'r'? (b) : (a))
static int popen_pid
[20];
register myside
, hisside
, pid
;
myside
= tst(p
[WTR
], p
[RDR
]);
hisside
= tst(p
[RDR
], p
[WTR
]);
if((pid
= fork()) == 0) {
/* myside and hisside reverse roles in child */
fcntl(hisside
, F_DUPFD
, tst(0, 1));
dup2(hisside
, tst(0, 1));
execl("/bin/sh", "sh", "-c", cmd
, (char *)0);
return(fdopen(myside
, mode
));
register f
, r
, (*hstat
)(), (*istat
)(), (*qstat
)();
istat
= signal(SIGINT
, SIG_IGN
);
qstat
= signal(SIGQUIT
, SIG_IGN
);
hstat
= signal(SIGHUP
, SIG_IGN
);
while((r
= wait(&status
)) != popen_pid
[f
] && r
!= -1)