private-main.cc 886 B

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