Willy,

because we ask for the `uname -a` output on the bug tracker, users sometimes
forget to give all the requested information and I'm tired of always having
to redact my machine names I thought I'd combine the `haproxy -vv + uname -a`
into just `uname -a` by adding the results of uname(2) to the version
information within `haproxy -vv`. My understanding is that the uname(2)
behavior is defined in POSIX, thus I expect this to be portable.

Best regards
Tim Düsterhus

Apply with `git am --scissors` to automatically cut the commit message.

-- >8 --
This patch adds the sysname, release, version and machine fields from
the uname results to the version output. It intentionally leaves out the
machine name, because it is usually not useful and users might not want to
expose their machine names for privacy reasons.

May be backported if it is considered useful for debugging.
---
 src/haproxy.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/haproxy.c b/src/haproxy.c
index d01ddfdab..60db73502 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -46,6 +46,7 @@
 #include <signal.h>
 #include <stdarg.h>
 #include <sys/resource.h>
+#include <sys/utsname.h>
 #include <sys/wait.h>
 #include <time.h>
 #include <syslog.h>
@@ -541,6 +542,8 @@ void hap_register_per_thread_free(int (*fct)())
 
 static void display_version()
 {
+       struct utsname utsname;
+
        printf("HA-Proxy version %s %s - https://haproxy.org/\n";
               PRODUCT_STATUS "\n", haproxy_version, haproxy_date);
 
@@ -563,6 +566,10 @@ static void display_version()
                else
                        printf("Known bugs: " PRODUCT_URL_BUGS "\n", 
base_version);
        }
+       
+       if (uname(&utsname) == 0) {
+               printf("Running on: %s %s %s %s\n", utsname.sysname, 
utsname.release, utsname.version, utsname.machine);
+       }
 }
 
 static void display_build_opts()
-- 
2.26.1


Reply via email to