aptdropprivs.cc 687 B

12345678910111213141516171819202122232425262728
  1. #include <config.h>
  2. #include <apt-pkg/cmndline.h>
  3. #include <apt-pkg/configuration.h>
  4. #include <apt-pkg/error.h>
  5. #include <apt-pkg/fileutl.h>
  6. #include <unistd.h>
  7. int main(int const argc, const char * argv[])
  8. {
  9. CommandLine::Args Args[] = {
  10. {'c',"config-file",0,CommandLine::ConfigFile},
  11. {'o',"option",0,CommandLine::ArbItem},
  12. {0, "user", "APT::Sandbox::User", CommandLine::HasArg},
  13. {0,0,0,0}
  14. };
  15. CommandLine CmdL(Args, _config);
  16. if(CmdL.Parse(argc,argv) == false || DropPrivileges() == false)
  17. {
  18. _error->DumpErrors(std::cerr, GlobalError::DEBUG);
  19. return 42;
  20. }
  21. return execv(CmdL.FileList[0], const_cast<char**>(CmdL.FileList));
  22. }