File 0003-Leave-duplicate-symlinks-out-of-the-SessionModel.patch of Package sddm
From a86829ae62b4338be716b3d75642321e631dcdec Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Sat, 4 Feb 2023 22:14:16 +0100
Subject: [PATCH] Leave duplicate symlinks out of the SessionModel
Used for autologin (default.desktop) and backwards-compat.
---
src/greeter/SessionModel.cpp | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
Index: sddm-0.21.0/src/greeter/SessionModel.cpp
===================================================================
--- sddm-0.21.0.orig/src/greeter/SessionModel.cpp
+++ sddm-0.21.0/src/greeter/SessionModel.cpp
@@ -137,6 +137,15 @@ namespace SDDM {
sessions.removeDuplicates();
for (auto& session : qAsConst(sessions)) {
Session *si = new Session(type, session);
+
+ // Skip symlinks that point to the same directory,
+ // they will be visited under the real name
+ QFileInfo fi_link(si->fileName());
+ if (fi_link.isSymLink() && fi_link.canonicalPath() == si->directory().path()) {
+ delete si;
+ continue;
+ }
+
bool execAllowed = true;
QFileInfo fi(si->tryExec());
if (fi.isAbsolute()) {
@@ -168,9 +177,11 @@ namespace SDDM {
if (lastSession.isEmpty())
lastSession = mainConfig.DefaultSession.get();
+ lastSession = QFileInfo(lastSession).canonicalFilePath();
+
// find out index of the last session
for (int i = 0; i < d->sessions.size(); ++i) {
- if (d->sessions.at(i)->fileName() == lastSession) {
+ if (QFileInfo(d->sessions.at(i)->fileName()).canonicalFilePath() == lastSession) {
d->lastIndex = i;
break;
}