Hi Gilles,

While looking over smtp_enqueue(), I have noticed that setting of
hostname is a noop. It looks like a leftover code from a bugfix in here
(http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/smtpd/smtp.c.diff?r2=1.141&r1=1.140&f=u)

I am including a diff to smtp.c below that includes the removal of that code
(it also includes the changes to smtp.c in my first patch).

Thanks!
--peter


Index: smtp.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/smtp.c,v
retrieving revision 1.152
diff -u -p -r1.152 smtp.c
--- smtp.c      8 Jan 2016 21:31:06 -0000       1.152
+++ smtp.c      12 Feb 2016 20:47:54 -0000
@@ -46,7 +46,7 @@ static void smtp_setup_events(void);
 static void smtp_pause(void);
 static void smtp_resume(void);
 static void smtp_accept(int, short, void *);
-static int smtp_enqueue(uid_t *);
+static int smtp_enqueue(void);
 static int smtp_can_accept(void);
 static void smtp_setup_listeners(void);
 static int smtp_sni_callback(SSL *, int *, void *);
@@ -84,7 +84,7 @@ smtp_imsg(struct mproc *p, struct imsg *
 
                case IMSG_QUEUE_SMTP_SESSION:
                        m_compose(p, IMSG_QUEUE_SMTP_SESSION, 0, 0,
-                           smtp_enqueue(NULL), imsg->data,
+                           smtp_enqueue(), imsg->data,
                            imsg->hdr.len - sizeof imsg->hdr);
                        return;
                }
@@ -94,7 +94,7 @@ smtp_imsg(struct mproc *p, struct imsg *
                switch (imsg->hdr.type) {
                case IMSG_CTL_SMTP_SESSION:
                        m_compose(p, IMSG_CTL_SMTP_SESSION, imsg->hdr.peerid, 0,
-                           smtp_enqueue(imsg->data), NULL, 0);
+                           smtp_enqueue(), NULL, 0);
                        return;
 
                case IMSG_CTL_PAUSE_SMTP:
@@ -217,22 +217,10 @@ smtp_resume(void)
 }
 
 static int
-smtp_enqueue(uid_t *euid)
+smtp_enqueue(void)
 {
-       static struct listener   local, *listener = NULL;
-       char                     buf[HOST_NAME_MAX+1], *hostname;
-       int                      fd[2];
-
-       if (listener == NULL) {
-               listener = &local;
-               (void)strlcpy(listener->tag, "local", sizeof(listener->tag));
-               listener->ss.ss_family = AF_LOCAL;
-               listener->ss.ss_len = sizeof(struct sockaddr *);
-               (void)strlcpy(listener->hostname, env->sc_hostname,
-                   sizeof(listener->hostname));
-               (void)strlcpy(listener->filter, env->sc_enqueue_filter,
-                   sizeof listener->filter);
-       }
+       struct listener  *listener = env->sc_sock_listener;
+       int              fd[2];
 
        /*
         * Some enqueue requests buffered in IMSG may still arrive even after
@@ -245,13 +233,7 @@ smtp_enqueue(uid_t *euid)
        if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, fd))
                return (-1);
 
-       hostname = env->sc_hostname;
-       if (euid) {
-               (void)snprintf(buf, sizeof(buf), "%s", hostname);
-               hostname = buf;
-       }
-
-       if ((smtp_session(listener, fd[0], &listener->ss, hostname)) == -1) {
+       if ((smtp_session(listener, fd[0], &listener->ss, env->sc_hostname)) == 
-1) {
                close(fd[0]);
                close(fd[1]);
                return (-1);

Reply via email to