diff options
author | David Kalnischkies <david@kalnischkies.de> | 2016-06-08 13:44:29 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2016-06-08 17:27:19 +0200 |
commit | 007d8b488787f4c33ced5937f22f99f1b759088a (patch) | |
tree | ee6d42146b4bc01b84c947e7755888a4dd1a1b45 /apt-private | |
parent | 3a487cc03dec3488d0fa3008d04747bb1b4b0baf (diff) |
edsp: drop privileges before executing solvers
Most (if not all) solvers should be able to run perfectly fine without
root privileges as they get the entire state they are supposed to work
on via stdin and do not perform any action directly, but just pass
suggestions on via stdout.
The new default is to run them all as _apt hence, but each solver can
configure another user if it chooses/must. The security benefits are
minimal at best, but it helps preventing silly mistakes (see
35f3ed061f10a25a3fb28bc988fddbb976344c4d) and that is always good.
Note that our 'apt' and 'dump' solver already dropped privileges if they
had them.
Diffstat (limited to 'apt-private')
-rw-r--r-- | apt-private/private-cmndline.cc | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc index 135ee3c4e..ba64c5b46 100644 --- a/apt-private/private-cmndline.cc +++ b/apt-private/private-cmndline.cc @@ -24,6 +24,8 @@ APT_SENTINEL static bool strcmp_match_in_list(char const * const Cmd, ...) /*{{{*/ { + if (Cmd == nullptr) + return false; va_list args; bool found = false; va_start(args, Cmd); @@ -131,8 +133,9 @@ static bool addArgumentsAPTConfig(std::vector<CommandLine::Args> &Args, char con return true; } /*}}}*/ -static bool addArgumentsAPTDumpSolver(std::vector<CommandLine::Args> &, char const * const)/*{{{*/ +static bool addArgumentsAPTDumpSolver(std::vector<CommandLine::Args> &Args, char const * const)/*{{{*/ { + addArg(0,"user","APT::Solver::RunAsUser",CommandLine::HasArg); return true; } /*}}}*/ @@ -337,12 +340,7 @@ std::vector<CommandLine::Args> getCommandArgs(APT_CMD const Program, char const { std::vector<CommandLine::Args> Args; Args.reserve(50); - if (Cmd == nullptr) - { - if (Program == APT_CMD::APT_EXTRACTTEMPLATES) - addArgumentsAPTExtractTemplates(Args, Cmd); - } - else if (strcmp(Cmd, "help") == 0) + if (Cmd != nullptr && strcmp(Cmd, "help") == 0) ; // no options for help so no need to implement it in each else switch (Program) |