local hostname versus entry in mts.conf).
/*
* Local and UUCP Host Name
*/
-char *LocalName(void);
+char *LocalName(int);
char *SystemName(void);
/*
* some prototypes for address parsing system
* (others are in addrsbr.h)
*/
-char *LocalName(void);
+char *LocalName(int);
char *SystemName(void);
char *OfficialName(char *);
*q = '\0';
q = site;
- if (!mh_strcasecmp (LocalName(), site))
- return LocalName();
+ if (!mh_strcasecmp (LocalName(1), site))
+ return LocalName(1);
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
if (clientname) {
client = clientname;
} else {
- client = LocalName(); /* no clientname -> LocalName */
+ client = LocalName(1); /* no clientname -> LocalName */
}
}
if (clientname)
client = clientname;
else
- client = LocalName(); /* no clientname -> LocalName */
+ client = LocalName(1); /* no clientname -> LocalName */
}
/*
}
if (dfhost == NULL) {
- dfhost = LocalName ();
+ dfhost = LocalName (0);
dftype = LOCALHOST;
}
}
if (wanthost == AD_NHST)
- mp->m_type = !mh_strcasecmp (LocalName (), mp->m_host)
+ mp->m_type = !mh_strcasecmp (LocalName (0), mp->m_host)
? LOCALHOST : NETHOST;
else
- mp->m_type = mh_strcasecmp (LocalName(), mp->m_host) ? NETHOST : LOCALHOST;
+ mp->m_type = mh_strcasecmp (LocalName(0), mp->m_host) ? NETHOST : LOCALHOST;
got_host: ;
if (route)
return username;
- domain = LocalName();
+ domain = LocalName(0);
snprintf_return = snprintf (addr, sizeof(addr), "%s@%s", username, domain);
switch (np->m_type) {
case NETHOST:
- len = strlen (cp = LocalName ());
+ len = strlen (cp = LocalName (0));
if (!uprf (np->m_host, cp) || np->m_host[len] != '.')
break;
goto local_test;
* SMTP/POP stuff
*/
char *clientname = NULL;
-char *servers = "localhost \01localnet";
+char *servers = "localhost";
char *pophost = "";
/*
/*
* Get the fully qualified name of the local host.
+ *
+ * If flag is 0, then use anything out of mts.conf (like localname).
+ * If flag is 1, then only use the "proper" local hostname.
*/
char *
-LocalName (void)
+LocalName (int flag)
{
- static char buffer[BUFSIZ] = "";
+ static char buffer0[BUFSIZ] = "";
+ static char buffer1[BUFSIZ] = "";
+ static char *buffer[] = { buffer0, buffer1 };
+ char *buf;
struct addrinfo hints, *res;
+ if (flag < 0 || flag > 1)
+ return NULL;
+
+ buf = buffer[flag];
+
/* check if we have cached the local name */
- if (buffer[0])
- return buffer;
+ if (buf[0])
+ return buf;
mts_init ("mts");
/* check if the mts.conf file specifies a "localname" */
- if (*localname) {
- strncpy (buffer, localname, sizeof(buffer));
+ if (*localname && flag == 0) {
+ strncpy (buf, localname, sizeof(buffer0));
} else {
- memset(buffer, 0, sizeof(buffer));
+ memset(buffer, 0, sizeof(buffer0));
/* first get our local name */
- gethostname (buffer, sizeof(buffer) - 1);
+ gethostname (buf, sizeof(buffer0) - 1);
/* now fully qualify our name */
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = PF_UNSPEC;
- if (getaddrinfo(buffer, NULL, &hints, &res) == 0) {
- strncpy(buffer, res->ai_canonname, sizeof(buffer) - 1);
+ if (getaddrinfo(buf, NULL, &hints, &res) == 0) {
+ strncpy(buf, res->ai_canonname, sizeof(buffer0) - 1);
freeaddrinfo(res);
}
}
* we append that now. This should rarely be needed.
*/
if (*localdomain) {
- strcat (buffer, ".");
- strcat (buffer, localdomain);
+ strcat (buf, ".");
+ strcat (buf, localdomain);
}
- return buffer;
+ return buf;
}
if (clock == 0) {
time (&clock);
snprintf (msgid, sizeof(msgid), "<%d.%ld.%%d@%s>\n",
- (int) getpid(), (long) clock, LocalName());
+ (int) getpid(), (long) clock, LocalName(1));
partno = 0;
msgfmt = getcpy(msgid);
}
if ((c1->c_flags & FACEDFLT) && c2->c_face == NULL) {
char *h, *o;
if ((h = mp->m_host) == NULL)
- h = LocalName ();
+ h = LocalName (0);
if ((o = OfficialName (h)))
h = o;
c2->c_face = concat ("address ", h, " ", mp->m_mbox,
if ((mp = getm (cp, NULL, 0, AD_NAME, NULL))) {
char *h, *o;
if ((h = mp->m_host) == NULL)
- h = LocalName ();
+ h = LocalName (0);
if ((o = OfficialName (h)))
h = o;
c1->c_face = concat ("address ", h, " ", mp->m_mbox, NULL);
if (e->eb_flags) {
user = "anonymous";
- snprintf (buffer, sizeof(buffer), "%s@%s", getusername (), LocalName ());
+ snprintf (buffer, sizeof(buffer), "%s@%s", getusername (),
+ LocalName (1));
pass = buffer;
} else {
ruserpass (e->eb_site, &username, &password);
time (&tclock);
strncpy (from, getlocaladdr(), sizeof(from));
- strncpy (myhost, LocalName (), sizeof(myhost));
+ strncpy (myhost, LocalName (0), sizeof(myhost));
for (cp = myhost; *cp; cp++)
*cp = uptolow (*cp);
fprintf (out, "Date: %s\n", dtime (&tclock, 0));
if (msgid)
fprintf (out, "Message-ID: <%d.%ld@%s>\n",
- (int) getpid (), (long) tclock, LocalName ());
+ (int) getpid (), (long) tclock, LocalName (1));
if (msgflags & MFRM) {
/* There was already a From: in the draft. Don't add one. */
if (!draft_from_masquerading)
fprintf (out, "Resent-Date: %s\n", dtime (&tclock, 0));
if (msgid)
fprintf (out, "Resent-Message-ID: <%d.%ld@%s>\n",
- (int) getpid (), (long) tclock, LocalName ());
+ (int) getpid (), (long) tclock, LocalName (1));
if (msgflags & MRFM) {
/* There was already a Resent-From: in draft. Don't add one. */
if (!draft_from_masquerading)
fprintf (out, "Date: %s\n", dtime (&tclock, 0));
if (msgid)
fprintf (out, "Message-ID: <%d.%ld@%s>\n",
- (int) getpid (), (long) tclock, LocalName ());
+ (int) getpid (), (long) tclock, LocalName (1));
if (msgflags & MFRM) {
/* There was already a From: in the draft. Don't add one. */
if (!draft_from_masquerading)
time (&clock);
snprintf (msgid, sizeof(msgid), "<%d.%ld@%s>",
- (int) getpid(), (long) clock, LocalName());
+ (int) getpid(), (long) clock, LocalName(1));
fseek (in, start, SEEK_SET);
for (partno = 1; partno <= nparts; partno++) {
strncpy (tmpfil, tfile, sizeof(tmpfil));
if (!strchr(mailsw, '@'))
- mailsw = concat (mailsw, "@", LocalName (), NULL);
+ mailsw = concat (mailsw, "@", LocalName (0), NULL);
fprintf (fp, "To: %s\n", mailsw);
if (subjsw)
if (fromsw) {
if (!strchr(fromsw, '@'))
- fromsw = concat (fromsw, "@", LocalName (), NULL);
+ fromsw = concat (fromsw, "@", LocalName (0), NULL);
fprintf (fp, "From: %s\n", fromsw);
}