+2020-01-06 Frank Ch. Eigler <fche@redhat.com>
+
+ * Makefile.am: Create a build-time header with lsb/uname info.
+ * debuginfod-client.c: Pass above as additional User-Agent request header.
+ * debuginfod.cxx (conninfo): Print this and X-Forwarded-For, as per
+ apache httpd reverse-proxy chain.
+
2019-12-31 Frank Ch. Eigler <fche@redhat.com>
* debuginfod.cxx: Rework threading model.
noinst_LIBRARIES = libdebuginfod.a
noinst_LIBRARIES += libdebuginfod_pic.a
+debuginfod-client-useragent.h:
+ if type uname 2>/dev/null; then \
+ echo '#define DEBUGINFOD_CLIENT_USERAGENT_1 "'`uname -sm | sed -e 's, ,/,g'`'"' > $@; \
+ else \
+ echo '#define DEBUGINFOD_CLIENT_USERAGENT_1 ""' > $@; \
+ fi
+ if type lsb_release 2>/dev/null; then \
+ echo '#define DEBUGINFOD_CLIENT_USERAGENT_2 "'`lsb_release -sir | sed -e 's, ,/,g'`'"' >> $@; \
+ else \
+ echo '#define DEBUGINFOD_CLIENT_USERAGENT_2 ""' > $@; \
+ fi
+ echo '#define DEBUGINFOD_CLIENT_USERAGENT DEBUGINFOD_CLIENT_USERAGENT_1 "," DEBUGINFOD_CLIENT_USERAGENT_2' >> $@
+
+libdebuginfod: debuginfod-client-useragent.h
libdebuginfod_a_SOURCES = debuginfod-client.c
libdebuginfod_pic_a_SOURCES = debuginfod-client.c
am_libdebuginfod_pic_a_OBJECTS = $(libdebuginfod_a_SOURCES:.c=.os)
EXTRA_DIST = libdebuginfod.map
MOSTLYCLEANFILES = $(am_libdebuginfod_pic_a_OBJECTS) libdebuginfod.so.$(VERSION)
-CLEANFILES += $(am_libdebuginfod_pic_a_OBJECTS) libdebuginfod.so
+CLEANFILES += $(am_libdebuginfod_pic_a_OBJECTS) libdebuginfod.so debuginfod-client-useragent.h
# automake std-options override: arrange to pass LD_LIBRARY_PATH
installcheck-binPROGRAMS: $(bin_PROGRAMS)
#include "config.h"
#include "debuginfod.h"
+#include "debuginfod-client-useragent.h"
#include "system.h"
#include <assert.h>
#include <dirent.h>
curl_easy_setopt(data[i].handle, CURLOPT_NOSIGNAL, (long) 1);
curl_easy_setopt(data[i].handle, CURLOPT_AUTOREFERER, (long) 1);
curl_easy_setopt(data[i].handle, CURLOPT_ACCEPT_ENCODING, "");
- curl_easy_setopt(data[i].handle, CURLOPT_USERAGENT, (void*) PACKAGE_STRING);
+ curl_easy_setopt(data[i].handle, CURLOPT_USERAGENT, (void*) PACKAGE_NAME "/" PACKAGE_VERSION "," DEBUGINFOD_CLIENT_USERAGENT);
curl_multi_add_handle(curlm, data[i].handle);
server_url = strtok_r(NULL, url_delim, &strtok_saveptr);
/* Command-line frontend for retrieving ELF / DWARF / source files
from the debuginfod.
- Copyright (C) 2019 Red Hat, Inc.
+ Copyright (C) 2019-2020 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
/* Debuginfo-over-http server.
- Copyright (C) 2019 Red Hat, Inc.
+ Copyright (C) 2019-2020 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
hostname[0] = servname[0] = '\0';
}
- return string(hostname) + string(":") + string(servname);
+ // extract headers relevant to administration
+ const char* user_agent = MHD_lookup_connection_value (conn, MHD_HEADER_KIND, "User-Agent") ?: "";
+ const char* x_forwarded_for = MHD_lookup_connection_value (conn, MHD_HEADER_KIND, "X-Forwarded-For") ?: "";
+ // NB: these are untrustworthy, beware if machine-processing log files
+
+ return string(hostname) + string(":") + string(servname) + string(" UA:") + string(user_agent) + string(" XFF:") + string(x_forwarded_for);
}