diff options
author | David Kalnischkies <david@kalnischkies.de> | 2020-06-26 23:42:29 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2020-07-02 18:57:11 +0200 |
commit | abba628268308c7c23f168f01966a88fe208885e (patch) | |
tree | 90a1fa8f241e9cba75f249919f443d607634fd63 /methods | |
parent | a976aa30c87d4ea437979257d3065b634323eb98 (diff) |
Reorder config check before checking systemd for non-interactive http
If this option is disabled (which it is by default in Debian), we don't
have to make the call and the checks around it. Not that it really
matters that much as if it would we would be better checking only once.
Diffstat (limited to 'methods')
-rw-r--r-- | methods/http.cc | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/methods/http.cc b/methods/http.cc index 7036b743c..1d2c41337 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -23,6 +23,7 @@ #include <apt-pkg/fileutl.h> #include <apt-pkg/hashes.h> #include <apt-pkg/proxy.h> +#include <apt-pkg/string_view.h> #include <apt-pkg/strutl.h> #include <chrono> @@ -979,15 +980,18 @@ void HttpMethod::SendReq(FetchItem *Itm) "Debian APT-HTTP/1.3 (" PACKAGE_VERSION ")"); #ifdef HAVE_SYSTEMD - char *unit = nullptr; - sd_pid_get_unit(getpid(), &unit); - if (unit != nullptr && *unit != '\0' && not APT::String::Startswith(unit, "user@") // user@ _is_ interactive - && unit != "packagekit.service"s // packagekit likely is interactive - && unit != "dbus.service"s // aptdaemon and qapt don't have systemd services - && ConfigFindB("User-Agent-Non-Interactive", false)) - Req << " non-interactive"; - - free(unit); + if (ConfigFindB("User-Agent-Non-Interactive", false)) + { + using APT::operator""_sv; + char *unit = nullptr; + sd_pid_get_unit(getpid(), &unit); + if (unit != nullptr && *unit != '\0' && not APT::String::Startswith(unit, "user@") // user@ _is_ interactive + && "packagekit.service"_sv != unit // packagekit likely is interactive + && "dbus.service"_sv != unit) // aptdaemon and qapt don't have systemd services + Req << " non-interactive"; + + free(unit); + } #endif Req << "\r\n"; |