]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
fix(cmdpipe): clarify mtr-packet startup failures 601/head
authorDarafei Praliaskouski <me@komzpa.net>
Thu, 7 May 2026 21:37:10 +0000 (01:37 +0400)
committerDarafei Praliaskouski <me@komzpa.net>
Thu, 7 May 2026 21:37:10 +0000 (01:37 +0400)
ui/cmdpipe.c

index bd5606a525dd3f1859b0f2f6f8ee5ccd33cd1641..73b868de5c16e4db07bdb8d3d8b906e662792ec5 100644 (file)
@@ -100,10 +100,15 @@ int send_synchronous_command(
     if (read_length < 0) {
         return -1;
     }
+    if (read_length == 0) {
+        errno = EPIPE;
+        return -1;
+    }
 
     /*  Parse the query reply  */
     reply[read_length] = 0;
     if (parse_command(result, reply)) {
+        errno = EPROTO;
         return -1;
     }
 
@@ -205,6 +210,17 @@ int check_packet_features(
 }
 
 
+static
+void fail_packet_startup(
+    int saved_errno)
+{
+    error(0, saved_errno, "Failure to start mtr-packet");
+    error(EXIT_FAILURE, 0,
+          "mtr-packet did not answer the startup check; "
+          "check that it is installed and allowed to open probe sockets");
+}
+
+
 extern char *myname;
 /*
     Execute mtr-packet, allowing the MTR_PACKET environment to override
@@ -313,7 +329,7 @@ int open_command_pipe(
            execute the mtr-packet binary, we will discover that here.
          */
         if (check_feature(ctl, cmdpipe, "send-probe")) {
-            error(EXIT_FAILURE, errno, "Failure to start mtr-packet");
+            fail_packet_startup(errno);
         }
 
         if (check_packet_features(ctl, cmdpipe)) {