+ p = newstr(XcriptFile);
+ (void) mktemp(p);
+ Xscript = fopen(p, "w");
+ if (Xscript == NULL)
+ {
+ Xscript = stdout;
+ syserr("Can't create %s", p);
+ }
+ Transcript = p;
+ (void) chmod(p, 0600);
+}
+\f/*
+** SETSENDER -- set sendmail's idea of the sender.
+**
+** Parameters:
+** from -- the person we would like to believe this
+** is from.
+**
+** Returns:
+** none.
+**
+** Side Effects:
+** Sets the idea of the sender.
+*/
+
+setsender(from)
+ char *from;
+{
+ register char *p;
+ extern char *getlogin();
+ register struct passwd *pw;
+ char *realname;
+ char cfbuf[40];
+
+ /*
+ ** Figure out the real user executing us.
+ ** Getlogin can return errno != 0 on non-errors.
+ */
+
+ if (!Smtp && !QueueRun)
+ {
+ errno = 0;
+ p = getlogin();
+ errno = 0;
+ }
+ else
+ p = from;
+ if (p != NULL)
+ {
+ extern struct passwd *getpwnam();
+
+ pw = getpwnam(p);
+ if (pw == NULL)
+ {
+ if (!Smtp && !QueueRun)
+ syserr("Who are you? (name=%s)", p);
+ p = NULL;
+ }
+ }
+ if (p == NULL)
+ {
+ extern struct passwd *getpwuid();
+ int uid;
+
+ uid = getruid();
+ pw = getpwuid(uid);
+ if (pw == NULL)
+ syserr("Who are you? (uid=%d)", uid);
+ else
+ p = pw->pw_name;
+ }
+ if (p == NULL || p[0] == '\0' || pw == NULL)
+ finis();
+
+ realname = p;
+
+ /*
+ ** Process passwd file entry.
+ */
+
+ /* run user's .mailcf file */
+ define('z', pw->pw_dir);
+ (void) expand("$z/.mailcf", cfbuf, &cfbuf[sizeof cfbuf - 1]);
+ if (safefile(cfbuf, getruid(), S_IREAD))
+ readcf(cfbuf, FALSE);
+
+ /* extract full name from passwd file */
+ if ((FullName == NULL || FullName[0] == '\0') &&
+ pw != NULL && pw->pw_gecos != NULL)
+ {
+ char nbuf[MAXNAME];
+
+ buildfname(pw->pw_gecos, realname, nbuf);
+ if (nbuf[0] != '\0')
+ FullName = newstr(nbuf);
+ }
+ if (FullName != NULL && FullName[0] != '\0')
+ define('x', FullName);
+
+ setfrom(from, realname);
+}
+\f/*
+** INITSYS -- initialize instantiation of system
+**
+** In Daemon mode, this is done in the child.
+**
+** Parameters:
+** none.
+**
+** Returns:
+** none.
+**
+** Side Effects:
+** Initializes the system macros, some global variables,
+** etc. In particular, the current time in various
+** forms is set.
+*/
+
+initsys()
+{
+ static char cbuf[5]; /* holds hop count */
+ static char dbuf[30]; /* holds ctime(tbuf) */
+ static char pbuf[10]; /* holds pid */
+ static char tbuf[10]; /* holds "current" time */
+ static char ybuf[10]; /* holds tty id */
+ register char *p;
+ extern char *ttyname();
+ extern char *arpadate();
+
+ /* convert timeout interval to absolute time */
+ TimeOut -= CurTime;
+ (void) time(&CurTime);
+ TimeOut += CurTime;
+
+ /* process id */
+ (void) sprintf(pbuf, "%d", getpid());
+ define('p', pbuf);
+
+ /* hop count */
+ (void) sprintf(cbuf, "%d", HopCount);
+ define('c', cbuf);
+
+ /* time as integer, unix time, arpa time */
+ (void) sprintf(tbuf, "%ld", &CurTime);
+ define('t', tbuf);
+ (void) strcpy(dbuf, ctime(&CurTime));
+ *index(dbuf, '\n') = '\0';
+ define('d', dbuf);
+ p = newstr(arpadate(dbuf));
+ define('a', p);
+ define('b', p);
+
+ /* version */
+ define('v', Version);
+
+ /* tty name */
+ p = ttyname(2);
+ if (p != NULL)
+ {
+ if (rindex(p, '/') != NULL)
+ p = rindex(p, '/') + 1;
+ strcpy(ybuf, p);
+ define('y', ybuf);
+ }