From 226c0f64d46019d675840b16bd44ff985b45ad0f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 1 Sep 2015 02:29:27 +0200 Subject: improve CheckDropPrivsMustBeDisabled further Various smaller improvements so that the check deals better with already downloaded files, relative paths and other things. Git-Dch: Ignore --- apt-pkg/contrib/fileutl.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 1d20c9c35..837edef4b 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -2141,6 +2141,8 @@ std::string GetTempDir(std::string const &User) if (pw == NULL) return GetTempDir(); + gid_t const old_euid = geteuid(); + gid_t const old_egid = getegid(); if (setegid(pw->pw_gid) != 0) _error->Errno("setegid", "setegid %u failed", pw->pw_gid); if (seteuid(pw->pw_uid) != 0) @@ -2148,10 +2150,10 @@ std::string GetTempDir(std::string const &User) std::string const tmp = GetTempDir(); - if (seteuid(0) != 0) - _error->Errno("seteuid", "seteuid %u failed", 0); - if (setegid(0) != 0) - _error->Errno("setegid", "setegid %u failed", 0); + if (seteuid(old_euid) != 0) + _error->Errno("seteuid", "seteuid %u failed", old_euid); + if (setegid(old_egid) != 0) + _error->Errno("setegid", "setegid %u failed", old_egid); return tmp; } -- cgit v1.2.3