+\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 (!Daemon)
+ {
+ errno = 0;
+ p = getlogin();
+ errno = 0;
+ }
+ if (Daemon || 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;
+ }
+ else
+ {
+ extern struct passwd *getpwnam();
+
+ pw = getpwnam(p);
+ if (pw == NULL)
+ syserr("Who are you? (name=%s)", p);
+ }
+ 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 (ArpaMode == ARPA_NONE && from == NULL && nbuf[0] != '\0')
+ FullName = newstr(nbuf);
+ }
+ if (FullName != NULL && FullName[0] != '\0')
+ define('x', FullName);
+
+ setfrom(from, realname);
+}