Show correct command execution status by checking against update
authorsunil <sunil@openbsd.org>
Mon, 27 Nov 2017 08:35:59 +0000 (08:35 +0000)
committersunil <sunil@openbsd.org>
Mon, 27 Nov 2017 08:35:59 +0000 (08:35 +0000)
operation return value.

Issue reported by 'Zelest' (Jesper Wallin).
Suggestions and ok eric@ gilles@.

usr.sbin/smtpd/control.c
usr.sbin/smtpd/lka.c

index b30d53c..b1123e6 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: control.c,v 1.119 2017/11/23 07:23:36 eric Exp $      */
+/*     $OpenBSD: control.c,v 1.120 2017/11/27 08:35:59 sunil Exp $     */
 
 /*
  * Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
@@ -731,8 +731,8 @@ control_dispatch_ext(struct mproc *p, struct imsg *imsg)
                if (len >= LINE_MAX)
                        goto invalid;
 
+               imsg->hdr.peerid = c->id;
                m_forward(p_lka, imsg);
-               m_compose(p, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
                return;
 
        case IMSG_CTL_DISCOVER_EVPID:
index e09be22..b73bd01 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: lka.c,v 1.200 2017/11/21 12:20:34 eric Exp $  */
+/*     $OpenBSD: lka.c,v 1.201 2017/11/27 08:35:59 sunil Exp $ */
 
 /*
  * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -345,13 +345,17 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
                return;
 
        case IMSG_CTL_UPDATE_TABLE:
+               ret = 0;
                table = table_find(imsg->data, NULL);
                if (table == NULL) {
                        log_warnx("warn: Lookup table not found: "
                            "\"%s\"", (char *)imsg->data);
-                       return;
-               }
-               table_update(table);
+               } else 
+                       ret = table_update(table);
+
+               m_compose(p_control,
+                   (ret == 1) ? IMSG_CTL_OK : IMSG_CTL_FAIL,
+                   imsg->hdr.peerid, 0, -1, NULL, 0);
                return;
        }