summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-09-01 02:29:27 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-09-01 02:49:53 +0200
commit226c0f64d46019d675840b16bd44ff985b45ad0f (patch)
tree858cb73f6ea1b0dafa5467879994dd416f237cd9 /apt-pkg/contrib/fileutl.cc
parent712ccb8fab59d49533ca2e178aac53f047885f86 (diff)
improve CheckDropPrivsMustBeDisabled further
Various smaller improvements so that the check deals better with already downloaded files, relative paths and other things. Git-Dch: Ignore
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r--apt-pkg/contrib/fileutl.cc10
1 files changed, 6 insertions, 4 deletions
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;
}