113667Ssam #ifndef lint
2*13992Sgray static char sccsid[] = "@(#)sdmail.c 5.2 (Berkeley) 07/19/83";
313667Ssam #endif
413667Ssam
513667Ssam #include "uucp.h"
613667Ssam #include <pwd.h>
713667Ssam
813667Ssam /*******
913667Ssam * sdmail(file, uid)
1013667Ssam *
1113667Ssam * sdmail - this routine will determine the owner
1213667Ssam * of the file (file), create a message string and
1313667Ssam * call "mailst" to send the cleanup message.
1413667Ssam * This is only implemented for local system
1513667Ssam * mail at this time.
1613667Ssam */
1713667Ssam
sdmail(file,uid)1813667Ssam sdmail(file, uid)
1913667Ssam char *file;
2013667Ssam register int uid;
2113667Ssam {
2213667Ssam static struct passwd *pwd = NULL;
2313667Ssam struct passwd *getpwuid();
2413667Ssam char mstr[40];
2513667Ssam
2613667Ssam sprintf(mstr, "uuclean deleted file %s\n", file);
2713667Ssam if (pwd != NULL && pwd->pw_uid == uid) {
2813667Ssam mailst(pwd->pw_name, mstr);
2913667Ssam return(0);
3013667Ssam }
3113667Ssam
3213667Ssam if ((pwd = getpwuid(uid)) != NULL) {
3313667Ssam mailst(pwd->pw_name, mstr);
3413667Ssam }
3513667Ssam return(0);
3613667Ssam }
3713667Ssam
3813667Ssam
3913667Ssam /***
4013667Ssam * mailst(user, str)
4113667Ssam * char *user, *str;
4213667Ssam *
4313667Ssam * mailst - this routine will fork and execute
4413667Ssam * a mail command sending string (str) to user (user).
4513667Ssam */
4613667Ssam
mailst(user,str)4713667Ssam mailst(user, str)
4813667Ssam char *user, *str;
4913667Ssam {
5013667Ssam register FILE *fp;
5113667Ssam char cmd[100];
5213667Ssam
5313667Ssam sprintf(cmd, "mail %s", user);
54*13992Sgray if ((fp = rpopen(cmd, "w")) == NULL)
5513667Ssam return;
5613667Ssam /* \n added to mail message. uw-beave!jim (Jim Rees) */
5713667Ssam fprintf(fp, "%s\n", str);
5813667Ssam pclose(fp);
5913667Ssam return;
6013667Ssam }
61