Advertisement
Guest User

Untitled

a guest
May 13th, 2022
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. while (1) {
  2. line = readLine();
  3. if (line.isNull()) {
  4. return -1;
  5. }
  6.  
  7. if (line == "display") {
  8. writeLine(display());
  9. } else if (line == "display_auth") {
  10. #if HAVE_X11
  11. writeLine(displayAuth());
  12. #else
  13. writeLine("");
  14. #endif
  15. } else if (line == "command") {
  16. writeString(m_command);
  17. } else if (line == "path") {
  18. QByteArray path = qgetenv("PATH");
  19. if (!path.isEmpty() && path[0] == ':') {
  20. path = path.mid(1);
  21. }
  22. if (m_user == "root") {
  23. if (!path.isEmpty()) {
  24. path = "/sbin:/bin:/usr/sbin:/usr/bin:" + path;
  25. } else {
  26. path = "/sbin:/bin:/usr/sbin:/usr/bin";
  27. }
  28. }
  29. writeLine(path);
  30. } else if (line == "user") {
  31. writeLine(m_user);
  32. } else if (line == "priority") {
  33. tmp.setNum(m_priority);
  34. writeLine(tmp);
  35. } else if (line == "scheduler") {
  36. if (m_scheduler == SchedRealtime) {
  37. writeLine("realtime");
  38. } else {
  39. writeLine("normal");
  40. }
  41. } else if (line == "xwindows_only") {
  42. if (m_XOnly) {
  43. writeLine("no");
  44. } else {
  45. writeLine("yes");
  46. }
  47. } else if (line == "app_startup_id") {
  48. QList<QByteArray> env = environment();
  49. QByteArray tmp;
  50. for (int i = 0; i < env.count(); ++i) {
  51. const char startup_env[] = "DESKTOP_STARTUP_ID=";
  52. if (env.at(i).startsWith(startup_env)) {
  53. tmp = env.at(i).mid(sizeof(startup_env) - 1);
  54. }
  55. }
  56. if (tmp.isEmpty()) {
  57. tmp = "0"; // krazy:exclude=doublequote_chars
  58. }
  59. writeLine(tmp);
  60. } else if (line == "app_start_pid") { // obsolete
  61. // Force the pid_t returned from getpid() into
  62. // something QByteArray understands; avoids ambiguity
  63. // between short and unsigned short in particular.
  64. tmp.setNum((PIDType<sizeof(pid_t)>::PID_t)(getpid()));
  65. writeLine(tmp);
  66. } else if (line == "environment") { // additional env vars
  67. QList<QByteArray> env = environment();
  68. for (int i = 0; i < env.count(); ++i) {
  69. writeString(env.at(i));
  70. }
  71. writeLine("");
  72. } else if (line == "end") {
  73. return 0;
  74. } else {
  75. qWarning() << "[" << __FILE__ << ":" << __LINE__ << "] " << "Unknown request:" << line;
  76. return 1;
  77. }
  78. }
  79. /*
  80. * !!! ADDED BY ARRAYBOLT3
  81. * !!! Notice that there's no match for "stop" anywhere in this long list of "else if" statements. I think that's what
  82. * !!! kdesu is complaining about.
  83. *
  84. */
  85. return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement