BSD 4_4 release
[unix-history] / usr / src / usr.bin / xsend / xsend / xsend.c
index c702472..ad14aa4 100644 (file)
@@ -1,18 +1,26 @@
+/*-
+ * This module is believed to contain source code proprietary to AT&T.
+ * Use and redistribution is subject to the Berkeley Software License
+ * Agreement and your Software Agreement with AT&T (Western Electric).
+ */
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)xsend.c    4.2 %G%";
-#endif
+static char sccsid[] = "@(#)xsend.c    8.1 (Berkeley) 6/6/93";
+#endif /* not lint */
 
 
-#include "xmail.h"
-#include <sys/types.h>
-#include <pwd.h>
+#include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/stat.h>
-#include <dir.h>
+#include <sys/dir.h>
+#include <pwd.h>
+#include "xmail.h"
+#include "pathnames.h"
+
 extern int errno;
 struct stat stbuf;
 int uid, destuid;
 extern int errno;
 struct stat stbuf;
 int uid, destuid;
-char *myname, *dest, *keyfile[128], line[128];
+char *myname, *dest, keyfile[128], line[128];
 struct direct *dbuf;
 struct direct *dbuf;
-char *maildir = "/usr/spool/secretmail/";
+char *maildir = _PATH_SECRETMAIL;
 FILE *kf, *mf;
 DIR *df;
 MINT *a[42], *cd[6][128];
 FILE *kf, *mf;
 DIR *df;
 MINT *a[42], *cd[6][128];
@@ -73,8 +81,27 @@ main(argc, argv) char **argv;
        dbg = 1;
 #endif
        run();
        dbg = 1;
 #endif
        run();
-       sprintf(buf, "mail %s <%snotice", dest, maildir);
-       system(buf);
+       {
+               char    hostname[MAXHOSTNAMELEN];
+               FILE    *nf, *popen();
+               struct  passwd  *passp;
+
+               sprintf(buf, "%s %s", _PATH_MAIL, dest);
+               if ((nf = popen(buf, "w")) == NULL)
+                       xfatal("cannot pipe to %s", _PATH_MAIL);
+               passp = getpwuid(getuid());
+               if (passp == 0){
+                       pclose(nf);
+                       xfatal("Who are you?");
+               }
+               gethostname(hostname, sizeof(hostname));
+               fprintf(nf, "Subject: %s@%s sent you secret mail\n",
+                       passp->pw_name, hostname);
+               fprintf(nf,
+                "Your secret mail can be read on host %s using ``xget''.\n",
+                       hostname);
+               pclose(nf);
+       }
        exit(0);
 }
 mkcd()
        exit(0);
 }
 mkcd()