private-main.cc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // disable locking in simulation, but show the message only for users
  18. // as root hasn't the same problems like unreadable files which can heavily
  19. // distort the simulation.
  20. if (_config->FindB("APT::Get::Simulate") == true &&
  21. (CmdL.FileSize() == 0 ||
  22. (strcmp(CmdL.FileList[0], "source") != 0 && strcmp(CmdL.FileList[0], "download") != 0 &&
  23. strcmp(CmdL.FileList[0], "changelog") != 0)))
  24. {
  25. if (getuid() != 0 && _config->FindB("APT::Get::Show-User-Simulation-Note",true) == true)
  26. std::cout << _("NOTE: This is only a simulation!\n"
  27. " apt-get needs root privileges for real execution.\n"
  28. " Keep also in mind that locking is deactivated,\n"
  29. " so don't depend on the relevance to the real current situation!"
  30. ) << std::endl;
  31. _config->Set("Debug::NoLocking",true);
  32. }
  33. }