private-main.cc 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 <signal.h>
  9. #include <apti18n.h>
  10. void InitSignals()
  11. {
  12. // Setup the signals
  13. signal(SIGPIPE,SIG_IGN);
  14. }
  15. void CheckSimulateMode(CommandLine &CmdL)
  16. {
  17. // simulate user-friendly if apt-get has no root privileges
  18. if (getuid() != 0 && _config->FindB("APT::Get::Simulate") == true &&
  19. (CmdL.FileSize() == 0 ||
  20. (strcmp(CmdL.FileList[0], "source") != 0 && strcmp(CmdL.FileList[0], "download") != 0 &&
  21. strcmp(CmdL.FileList[0], "changelog") != 0)))
  22. {
  23. if (_config->FindB("APT::Get::Show-User-Simulation-Note",true) == true)
  24. std::cout << _("NOTE: This is only a simulation!\n"
  25. " apt-get needs root privileges for real execution.\n"
  26. " Keep also in mind that locking is deactivated,\n"
  27. " so don't depend on the relevance to the real current situation!"
  28. ) << std::endl;
  29. _config->Set("Debug::NoLocking",true);
  30. }
  31. }