]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/fileutl.cc
set PR_SET_NO_NEW_PRIVS even if sandbox is disabled
[apt.git] / apt-pkg / contrib / fileutl.cc
index 3e592d94fd349476969cd62b84996c648d19f66b..c51eee737ca660116f750aa3d2b808c2281fb361 100644 (file)
@@ -2179,6 +2179,12 @@ bool DropPrivileges()                                                    /*{{{*/
       _error->Warning("PR_SET_NO_NEW_PRIVS failed with %i", ret);
 #endif
 
+   // empty setting disables privilege dropping - this also ensures
+   // backward compatibility, see bug #764506
+   const std::string toUser = _config->Find("APT::Sandbox::User");
+   if (toUser.empty())
+      return true;
+
    // uid will be 0 in the end, but gid might be different anyway
    uid_t const old_uid = getuid();
    gid_t const old_gid = getgid();
@@ -2186,7 +2192,6 @@ bool DropPrivileges()                                                     /*{{{*/
    if (old_uid != 0)
       return true;
 
-   const std::string toUser = _config->Find("APT::Sandbox::User", "_apt");
    struct passwd *pw = getpwnam(toUser.c_str());
    if (pw == NULL)
       return _error->Error("No user %s, can not drop rights", toUser.c_str());