diff options
author | Michael Vogt <mvo@debian.org> | 2016-01-25 14:44:42 +0100 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2016-01-25 14:44:42 +0100 |
commit | a6fd0c5cc412afd5dac7a9952cab741e48342488 (patch) | |
tree | 623c31965289c3af6dd50710e23b18bddb13d527 /apt-pkg | |
parent | 8ee09b58e9f061cf5296c54680e2b3386f83ff04 (diff) |
Log calling SUDO_USER or PKEXEC_UID in history.log
Thanks: Thomas Reusch
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index ce9224791..e94a8cfdc 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -48,12 +48,28 @@ #include <string> #include <utility> #include <vector> +#include <sstream> #include <apti18n.h> /*}}}*/ using namespace std; +APT_PURE static string +AptHistoryUser() +{ + stringstream out; + const char* env[]{"SUDO_USER", "PKEXEC_UID", nullptr}; + for (int i=0; env[i] != nullptr; i++) + { + if (getenv(env[i]) != nullptr) + { + out << env[i] << "=" << getenv(env[i]) << " "; + } + } + return out.str(); +} + APT_PURE static unsigned int EnvironmentSize() { @@ -876,6 +892,8 @@ bool pkgDPkgPM::OpenLog() } if (_config->Exists("Commandline::AsString") == true) WriteHistoryTag("Commandline", _config->Find("Commandline::AsString")); + if (AptHistoryUser() != "") + WriteHistoryTag("Requested-By", AptHistoryUser()); WriteHistoryTag("Install", install); WriteHistoryTag("Reinstall", reinstall); WriteHistoryTag("Upgrade", upgrade); |