private-main.cc 972 B

12345678910111213141516171819202122232425262728293031
  1. #include <config.h>
  2. #include <apt-pkg/cmndline.h>
  3. #include <apt-pkg/configuration.h>
  4. #include <apt-private/private-main.h>
  5. #include <iostream>
  6. #include <string.h>
  7. #include <unistd.h>
  8. #include <apti18n.h>
  9. void CheckSimulateMode(CommandLine &CmdL)
  10. {
  11. // simulate user-friendly if apt-get has no root privileges
  12. if (getuid() != 0 && _config->FindB("APT::Get::Simulate") == true &&
  13. (CmdL.FileSize() == 0 ||
  14. (strcmp(CmdL.FileList[0], "source") != 0 && strcmp(CmdL.FileList[0], "download") != 0 &&
  15. strcmp(CmdL.FileList[0], "changelog") != 0)))
  16. {
  17. if (_config->FindB("APT::Get::Show-User-Simulation-Note",true) == true)
  18. std::cout << _("NOTE: This is only a simulation!\n"
  19. " apt-get needs root privileges for real execution.\n"
  20. " Keep also in mind that locking is deactivated,\n"
  21. " so don't depend on the relevance to the real current situation!"
  22. ) << std::endl;
  23. _config->Set("Debug::NoLocking",true);
  24. }
  25. }