diff options
Diffstat (limited to 'test/interactive-helper')
-rw-r--r-- | test/interactive-helper/aptdropprivs.cc | 27 | ||||
-rw-r--r-- | test/interactive-helper/makefile | 6 |
2 files changed, 33 insertions, 0 deletions
diff --git a/test/interactive-helper/aptdropprivs.cc b/test/interactive-helper/aptdropprivs.cc new file mode 100644 index 000000000..1cc04f36a --- /dev/null +++ b/test/interactive-helper/aptdropprivs.cc @@ -0,0 +1,27 @@ +#include <config.h> + +#include <apt-pkg/cmndline.h> +#include <apt-pkg/configuration.h> +#include <apt-pkg/error.h> +#include <apt-pkg/fileutl.h> + +#include <unistd.h> + +int main(int const argc, const char * argv[]) +{ + CommandLine::Args Args[] = { + {'c',"config-file",0,CommandLine::ConfigFile}, + {'o',"option",0,CommandLine::ArbItem}, + {0, "user", "APT::Sandbox::User", CommandLine::HasArg}, + {0,0,0,0} + }; + + CommandLine CmdL(Args, _config); + if(CmdL.Parse(argc,argv) == false || DropPrivileges() == false) + { + _error->DumpErrors(std::cerr, GlobalError::DEBUG); + return 42; + } + + return execv(CmdL.FileList[0], const_cast<char**>(CmdL.FileList)); +} diff --git a/test/interactive-helper/makefile b/test/interactive-helper/makefile index 096767c41..450308ca7 100644 --- a/test/interactive-helper/makefile +++ b/test/interactive-helper/makefile @@ -51,3 +51,9 @@ SLIBS = -lapt-pkg -lpthread LIB_MAKES = apt-pkg/makefile SOURCE = aptwebserver.cc include $(PROGRAM_H) + +# Program for testing privileges +PROGRAM=aptdropprivs +SLIBS = -lapt-pkg +SOURCE = aptdropprivs.cc +include $(PROGRAM_H) |