sddm-0.19.0-consolidate-1.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. diff -Naur a/data/scripts/Xsession b/data/scripts/Xsession
  2. --- a/data/scripts/Xsession 2020-11-03 10:55:31.000000000 +0100
  3. +++ b/data/scripts/Xsession 2021-04-03 18:59:31.051127925 +0200
  4. @@ -62,7 +62,10 @@
  5. fi
  6. done
  7. fi
  8. -
  9. +if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS";
  10. +then
  11. + eval "$(dbus-launch --sh-syntax --exit-with-session)"
  12. +fi
  13. # Load Xsession scripts
  14. # OPTIONFILE, USERXSESSION, USERXSESSIONRC and ALTUSERXSESSION are required
  15. # by the scripts to work
  16. diff -Naur a/services/sddm-autologin.pam b/services/sddm-autologin.pam
  17. --- a/services/sddm-autologin.pam 2020-11-03 10:55:31.000000000 +0100
  18. +++ b/services/sddm-autologin.pam 2021-04-03 19:02:11.514619253 +0200
  19. @@ -1,6 +1,6 @@
  20. #%PAM-1.0
  21. auth required pam_env.so
  22. -auth required pam_tally2.so file=/var/log/tallylog onerr=succeed
  23. +auth required pam_faillock.so preauth
  24. auth required pam_shells.so
  25. auth required pam_nologin.so
  26. auth required pam_permit.so
  27. diff -Naur a/src/common/Session.cpp b/src/common/Session.cpp
  28. --- a/src/common/Session.cpp 2020-11-03 10:55:31.000000000 +0100
  29. +++ b/src/common/Session.cpp 2021-04-03 19:00:30.843278097 +0200
  30. @@ -89,7 +89,7 @@
  31. QString Session::desktopSession() const
  32. {
  33. - return fileName().replace(s_entryExtention, QString());
  34. + return QFileInfo(m_fileName).completeBaseName();
  35. }
  36. QString Session::desktopNames() const
  37. diff -Naur a/src/daemon/Seat.cpp b/src/daemon/Seat.cpp
  38. --- a/src/daemon/Seat.cpp 2020-11-03 10:55:31.000000000 +0100
  39. +++ b/src/daemon/Seat.cpp 2021-04-03 19:00:20.073491217 +0200
  40. @@ -28,6 +28,7 @@
  41. #include <QDebug>
  42. #include <QFile>
  43. +#include <QTimer>
  44. #include <functional>
  45. @@ -52,7 +53,7 @@
  46. return m_name;
  47. }
  48. - bool Seat::createDisplay(int terminalId) {
  49. + void Seat::createDisplay(int terminalId) {
  50. //reload config if needed
  51. mainConfig.load();
  52. @@ -84,12 +85,24 @@
  53. m_displays << display;
  54. // start the display
  55. - if (!display->start()) {
  56. - qCritical() << "Could not start Display server on vt" << terminalId;
  57. - return false;
  58. + startDisplay(display);
  59. + }
  60. +
  61. + void Seat::startDisplay(Display *display, int tryNr) {
  62. + if (display->start())
  63. + return;
  64. +
  65. + // It's possible that the system isn't ready yet (driver not loaded,
  66. + // device not enumerated, ...). It's not possible to tell when that changes,
  67. + // so try a few times with a delay in between.
  68. + qWarning() << "Attempt" << tryNr << "starting the Display server on vt" << display->terminalId() << "failed";
  69. +
  70. + if(tryNr >= 3) {
  71. + qCritical() << "Could not start Display server on vt" << display->terminalId();
  72. + return;
  73. }
  74. - return true;
  75. + QTimer::singleShot(2000, display, [=] { startDisplay(display, tryNr + 1); });
  76. }
  77. void Seat::removeDisplay(Display* display) {
  78. diff -Naur a/src/daemon/Seat.h b/src/daemon/Seat.h
  79. --- a/src/daemon/Seat.h 2020-11-03 10:55:31.000000000 +0100
  80. +++ b/src/daemon/Seat.h 2021-04-03 19:00:20.073491217 +0200
  81. @@ -35,13 +35,15 @@
  82. const QString &name() const;
  83. public slots:
  84. - bool createDisplay(int terminalId = -1);
  85. + void createDisplay(int terminalId = -1);
  86. void removeDisplay(SDDM::Display* display);
  87. private slots:
  88. void displayStopped();
  89. private:
  90. + void startDisplay(SDDM::Display *display, int tryNr = 1);
  91. +
  92. QString m_name;
  93. QVector<Display *> m_displays;
  94. diff -Naur a/src/daemon/XorgDisplayServer.cpp b/src/daemon/XorgDisplayServer.cpp
  95. --- a/src/daemon/XorgDisplayServer.cpp 2020-11-03 10:55:31.000000000 +0100
  96. +++ b/src/daemon/XorgDisplayServer.cpp 2021-04-03 19:00:20.076824484 +0200
  97. @@ -118,6 +118,11 @@
  98. if (m_started)
  99. return false;
  100. + if (process) {
  101. + qCritical() << "Tried to start Xorg before previous instance exited";
  102. + return false;
  103. + }
  104. +
  105. // create process
  106. process = new QProcess(this);
  107. @@ -136,106 +141,97 @@
  108. return false;
  109. }
  110. - if (daemonApp->testing()) {
  111. - QStringList args;
  112. - QDir x11socketDir(QStringLiteral("/tmp/.X11-unix"));
  113. - int display = 100;
  114. - while (x11socketDir.exists(QStringLiteral("X%1").arg(display))) {
  115. - ++display;
  116. - }
  117. - m_display = QStringLiteral(":%1").arg(display);
  118. - args << m_display << QStringLiteral("-auth") << m_authPath << QStringLiteral("-br") << QStringLiteral("-noreset") << QStringLiteral("-screen") << QStringLiteral("800x600");
  119. - process->start(mainConfig.X11.XephyrPath.get(), args);
  120. -
  121. -
  122. - // wait for display server to start
  123. - if (!process->waitForStarted()) {
  124. - // log message
  125. - qCritical() << "Failed to start display server process.";
  126. -
  127. - // return fail
  128. - return false;
  129. - }
  130. - emit started();
  131. - } else {
  132. - // set process environment
  133. - QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  134. - env.insert(QStringLiteral("XCURSOR_THEME"), mainConfig.Theme.CursorTheme.get());
  135. - process->setProcessEnvironment(env);
  136. -
  137. - //create pipe for communicating with X server
  138. - //0 == read from X, 1== write to from X
  139. - int pipeFds[2];
  140. - if (pipe(pipeFds) != 0) {
  141. - qCritical("Could not create pipe to start X server");
  142. - }
  143. + // set process environment
  144. + QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
  145. + env.insert(QStringLiteral("XCURSOR_THEME"), mainConfig.Theme.CursorTheme.get());
  146. + process->setProcessEnvironment(env);
  147. +
  148. + //create pipe for communicating with X server
  149. + //0 == read from X, 1== write to from X
  150. + int pipeFds[2];
  151. + if (pipe(pipeFds) != 0) {
  152. + qCritical("Could not create pipe to start X server");
  153. + }
  154. - // start display server
  155. - QStringList args = mainConfig.X11.ServerArguments.get().split(QLatin1Char(' '), QString::SkipEmptyParts);
  156. - args << QStringLiteral("-auth") << m_authPath
  157. + // start display server
  158. + QStringList args;
  159. + if (!daemonApp->testing()) {
  160. + process->setProgram(mainConfig.X11.ServerPath.get());
  161. + args << mainConfig.X11.ServerArguments.get().split(QLatin1Char(' '), QString::SkipEmptyParts)
  162. << QStringLiteral("-background") << QStringLiteral("none")
  163. - << QStringLiteral("-noreset")
  164. - << QStringLiteral("-displayfd") << QString::number(pipeFds[1])
  165. << QStringLiteral("-seat") << displayPtr()->seat()->name();
  166. if (displayPtr()->seat()->name() == QLatin1String("seat0")) {
  167. args << QStringLiteral("vt%1").arg(displayPtr()->terminalId());
  168. }
  169. - qDebug() << "Running:"
  170. - << qPrintable(mainConfig.X11.ServerPath.get())
  171. - << qPrintable(args.join(QLatin1Char(' ')));
  172. - process->start(mainConfig.X11.ServerPath.get(), args);
  173. -
  174. - // wait for display server to start
  175. - if (!process->waitForStarted()) {
  176. - // log message
  177. - qCritical() << "Failed to start display server process.";
  178. -
  179. - // return fail
  180. - close(pipeFds[0]);
  181. - return false;
  182. - }
  183. + } else {
  184. + process->setProgram(mainConfig.X11.XephyrPath.get());
  185. + args << QStringLiteral("-br")
  186. + << QStringLiteral("-screen") << QStringLiteral("800x600");
  187. + }
  188. - // close the other side of pipe in our process, otherwise reading
  189. - // from it may stuck even X server exit.
  190. - close(pipeFds[1]);
  191. + args << QStringLiteral("-auth") << m_authPath
  192. + << QStringLiteral("-noreset")
  193. + << QStringLiteral("-displayfd") << QString::number(pipeFds[1]);
  194. +
  195. + process->setArguments(args);
  196. + qDebug() << "Running:"
  197. + << qPrintable(process->program())
  198. + << qPrintable(process->arguments().join(QLatin1Char(' ')));
  199. + process->start();
  200. +
  201. + // wait for display server to start
  202. + if (!process->waitForStarted()) {
  203. + // log message
  204. + qCritical() << "Failed to start display server process.";
  205. - QFile readPipe;
  206. + // return fail
  207. + close(pipeFds[0]);
  208. + return false;
  209. + }
  210. - if (!readPipe.open(pipeFds[0], QIODevice::ReadOnly)) {
  211. - qCritical("Failed to open pipe to start X Server");
  212. + // close the other side of pipe in our process, otherwise reading
  213. + // from it may stuck even X server exit.
  214. + close(pipeFds[1]);
  215. - close(pipeFds[0]);
  216. - return false;
  217. - }
  218. - QByteArray displayNumber = readPipe.readLine();
  219. - if (displayNumber.size() < 2) {
  220. - // X server gave nothing (or a whitespace).
  221. - qCritical("Failed to read display number from pipe");
  222. + QFile readPipe;
  223. - close(pipeFds[0]);
  224. - return false;
  225. - }
  226. - displayNumber.prepend(QByteArray(":"));
  227. - displayNumber.remove(displayNumber.size() -1, 1); // trim trailing whitespace
  228. - m_display = QString::fromLocal8Bit(displayNumber);
  229. + if (!readPipe.open(pipeFds[0], QIODevice::ReadOnly)) {
  230. + qCritical("Failed to open pipe to start X Server");
  231. - // close our pipe
  232. close(pipeFds[0]);
  233. + stop();
  234. + return false;
  235. + }
  236. + QByteArray displayNumber = readPipe.readLine();
  237. + if (displayNumber.size() < 2) {
  238. + // X server gave nothing (or a whitespace).
  239. + qCritical("Failed to read display number from pipe");
  240. - emit started();
  241. + close(pipeFds[0]);
  242. + stop();
  243. + return false;
  244. }
  245. + displayNumber.prepend(QByteArray(":"));
  246. + displayNumber.remove(displayNumber.size() -1, 1); // trim trailing whitespace
  247. + m_display = QString::fromLocal8Bit(displayNumber);
  248. +
  249. + // close our pipe
  250. + close(pipeFds[0]);
  251. // The file is also used by the greeter, which does care about the
  252. // display number. Write the proper entry, if it's different.
  253. if(m_display != QStringLiteral(":0")) {
  254. if(!addCookie(m_authPath)) {
  255. qCritical() << "Failed to write xauth file";
  256. + stop();
  257. return false;
  258. }
  259. }
  260. changeOwner(m_authPath);
  261. + emit started();
  262. +
  263. // set flag
  264. m_started = true;
  265. @@ -244,8 +240,7 @@
  266. }
  267. void XorgDisplayServer::stop() {
  268. - // check flag
  269. - if (!m_started)
  270. + if (!process)
  271. return;
  272. // log message
  273. @@ -260,6 +255,12 @@
  274. }
  275. void XorgDisplayServer::finished() {
  276. + // clean up
  277. + if (process) {
  278. + process->deleteLater();
  279. + process = nullptr;
  280. + }
  281. +
  282. // check flag
  283. if (!m_started)
  284. return;
  285. @@ -295,10 +296,6 @@
  286. displayStopScript->deleteLater();
  287. displayStopScript = nullptr;
  288. - // clean up
  289. - process->deleteLater();
  290. - process = nullptr;
  291. -
  292. // remove authority file
  293. QFile::remove(m_authPath);