summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/sendmail/src/util.c')
-rw-r--r--contrib/sendmail/src/util.c146
1 files changed, 141 insertions, 5 deletions
diff --git a/contrib/sendmail/src/util.c b/contrib/sendmail/src/util.c
index 02e8ec2..9775915 100644
--- a/contrib/sendmail/src/util.c
+++ b/contrib/sendmail/src/util.c
@@ -1833,7 +1833,7 @@ dumpfd(fd, printclosed, logit)
}
(void) sm_snprintf(p, SPACELEFT(buf, p), "mode=%o: ",
- (int) st.st_mode);
+ (unsigned int) st.st_mode);
p += strlen(p);
switch (st.st_mode & S_IFMT)
{
@@ -1936,11 +1936,11 @@ dumpfd(fd, printclosed, logit)
default:
defprint:
(void) sm_snprintf(p, SPACELEFT(buf, p),
- "dev=%d/%d, ino=%llu, nlink=%d, u/gid=%d/%d, ",
- major(st.st_dev), minor(st.st_dev),
+ "dev=%ld/%ld, ino=%llu, nlink=%d, u/gid=%ld/%ld, ",
+ (long) major(st.st_dev), (long) minor(st.st_dev),
(ULONGLONG_T) st.st_ino,
- (int) st.st_nlink, (int) st.st_uid,
- (int) st.st_gid);
+ (int) st.st_nlink, (long) st.st_uid,
+ (long) st.st_gid);
p += strlen(p);
(void) sm_snprintf(p, SPACELEFT(buf, p), "size=%llu",
(ULONGLONG_T) st.st_size);
@@ -2866,3 +2866,139 @@ count_open_connections(hostaddr)
return n;
}
+#if _FFR_XCNCT
+/*
+** XCONNECT -- get X-CONNECT info
+**
+** Parameters:
+** inchannel -- FILE to check
+**
+** Returns:
+** -1 on error
+** 0 if X-CONNECT was not given
+** >0 if X-CONNECT was used successfully (D_XCNCT*)
+*/
+
+int
+xconnect(inchannel)
+ SM_FILE_T *inchannel;
+{
+ int r, i;
+ char *p, *b, delim, inp[MAXINPLINE];
+ SOCKADDR addr;
+ char **pvp;
+ char pvpbuf[PSBUFSIZE];
+ char *peerhostname; /* name of SMTP peer or "localhost" */
+ extern ENVELOPE BlankEnvelope;
+
+#define XCONNECT "X-CONNECT "
+#define XCNNCTLEN (sizeof(XCONNECT) - 1)
+
+ /* Ask the ruleset whether to use x-connect */
+ pvp = NULL;
+ peerhostname = RealHostName;
+ if (peerhostname == NULL)
+ peerhostname = "localhost";
+ r = rscap("x_connect", peerhostname,
+ anynet_ntoa(&RealHostAddr), &BlankEnvelope,
+ &pvp, pvpbuf, sizeof(pvpbuf));
+ if (tTd(75, 8))
+ sm_syslog(LOG_INFO, NOQID, "x-connect: rscap=%d", r);
+ if (r == EX_UNAVAILABLE)
+ return 0;
+ if (r != EX_OK)
+ {
+ /* ruleset error */
+ sm_syslog(LOG_INFO, NOQID, "x-connect: rscap=%d", r);
+ return 0;
+ }
+ if (pvp != NULL && pvp[0] != NULL && (pvp[0][0] & 0377) == CANONNET)
+ {
+ /* $#: no x-connect */
+ if (tTd(75, 7))
+ sm_syslog(LOG_INFO, NOQID, "x-connect: nope");
+ return 0;
+ }
+
+ p = sfgets(inp, sizeof(inp), InChannel, TimeOuts.to_nextcommand, "pre");
+ if (tTd(75, 6))
+ sm_syslog(LOG_INFO, NOQID, "x-connect: input=%s", p);
+ if (p == NULL || strncasecmp(p, XCONNECT, XCNNCTLEN) != 0)
+ return -1;
+ p += XCNNCTLEN;
+ while (isascii(*p) && isspace(*p))
+ p++;
+
+ /* parameters: IPAddress [Hostname[ M]] */
+ b = p;
+ while (*p != '\0' && isascii(*p) &&
+ (isalnum(*p) || *p == '.' || *p== ':'))
+ p++;
+ delim = *p;
+ *p = '\0';
+
+ memset(&addr, '\0', sizeof(addr));
+ addr.sin.sin_addr.s_addr = inet_addr(b);
+ if (addr.sin.sin_addr.s_addr != INADDR_NONE)
+ {
+ addr.sa.sa_family = AF_INET;
+ memcpy(&RealHostAddr, &addr, sizeof(addr));
+ if (tTd(75, 2))
+ sm_syslog(LOG_INFO, NOQID, "x-connect: addr=%s",
+ anynet_ntoa(&RealHostAddr));
+ }
+# if NETINET6
+ else if ((r = inet_pton(AF_INET6, b, &addr.sin6.sin6_addr)) == 1)
+ {
+ addr.sa.sa_family = AF_INET6;
+ memcpy(&RealHostAddr, &addr, sizeof(addr));
+ }
+# endif /* NETINET6 */
+ else
+ return -1;
+
+ /* more parameters? */
+ if (delim != ' ')
+ return D_XCNCT;
+ while (*p != '\0' && isascii(*p) && isspace(*p))
+ p++;
+
+ for (b = ++p, i = 0;
+ *p != '\0' && isascii(*p) && (isalnum(*p) || *p == '.' || *p == '-');
+ p++, i++)
+ ;
+ if (i == 0)
+ return D_XCNCT;
+ delim = *p;
+ if (i > MAXNAME)
+ b[MAXNAME] = '\0';
+ else
+ b[i] = '\0';
+ SM_FREE_CLR(RealHostName);
+ RealHostName = newstr(b);
+ if (tTd(75, 2))
+ sm_syslog(LOG_INFO, NOQID, "x-connect: host=%s", b);
+ *p = delim;
+
+ b = p;
+ if (*p != ' ')
+ return D_XCNCT;
+
+ while (*p != '\0' && isascii(*p) && isspace(*p))
+ p++;
+
+ if (tTd(75, 4))
+ {
+ char *e;
+
+ e = strpbrk(p, "\r\n");
+ if (e != NULL)
+ *e = '\0';
+ sm_syslog(LOG_INFO, NOQID, "x-connect: rest=%s", p);
+ }
+ if (*p == 'M')
+ return D_XCNCT_M;
+
+ return D_XCNCT;
+}
+#endif /* _FFR_XCNCT */
OpenPOWER on IntegriCloud