Bug 25728 - Starting debubinfod with --port=0 is not documented
Summary: Starting debubinfod with --port=0 is not documented
Status: RESOLVED FIXED
Alias: None
Product: elfutils
Classification: Unclassified
Component: debuginfod (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-26 10:55 UTC by Konrad Kleine
Modified: 2020-03-28 20:45 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konrad Kleine 2020-03-26 10:55:26 UTC
In order bind the debuginfod server on any port (e.g. for testing) you might want to start it using

    debuginfod --port=0

When you do that, the logs say: 

    started http server on IPv4 IPv6 port=0

IMHO debuginfod should print the port that was actually assigned by the operating system.
Comment 1 Mark Wielaard 2020-03-26 11:57:31 UTC
Is this behavior actually useful or does --port=0 work by accident?
I don't see this (http_port == 0) documented for MHD_start_daemon.
So I would actually just reject it:

diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
index 7c7e85eb..39736351 100644
--- a/debuginfod/debuginfod.cxx
+++ b/debuginfod/debuginfod.cxx
@@ -422,7 +422,8 @@ parse_opt (int key, char *arg,
     case 'v': verbose ++; break;
     case 'd': db_path = string(arg); break;
     case 'p': http_port = (unsigned) atoi(arg);
-      if (http_port > 65535) argp_failure(state, 1, EINVAL, "port number");
+      if (http_port == 0 || http_port > 65535)
+        argp_failure(state, 1, EINVAL, "port number");
       break;
     case 'F': scan_files = true; break;
     case 'R':
Comment 2 Mark Wielaard 2020-03-27 14:53:26 UTC
Proposed to just disable this undocumented "feature" because it doesn't seem very useful:
https://sourceware.org/pipermail/elfutils-devel/2020q1/002568.html
Comment 3 Frank Ch. Eigler 2020-03-28 20:45:30 UTC
pushed this to master, along with a tiny man page blurb.