Skip to content

Commit a834965

Browse files
committed
Save user session errors to ~/.wayland-errors for Wayland sessions
Issue: #419
1 parent 27dd29e commit a834965

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/helper/UserSession.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,20 @@ namespace SDDM {
9393
QString sessionType = processEnvironment().value("XDG_SESSION_TYPE");
9494

9595
//we cannot use setStandardError file as this code is run in the child process
96-
//we want to redirect after we setuid so that .xsession-errors is owned by the user
96+
//we want to redirect after we setuid so that the log file is owned by the user
9797

98-
//swap the stderr pipe of this subprcess into a file .xsession-errors
99-
int fd = ::open(".xsession-errors", O_WRONLY | O_CREAT | O_TRUNC, 0600);
98+
// determine stderr log file based on session type
99+
QString fileName = sessionType == QStringLiteral("x11")
100+
? QStringLiteral(".xsession-errors") : QStringLiteral(".wayland-errors");
101+
102+
//swap the stderr pipe of this subprcess into a file
103+
int fd = ::open(qPrintable(fileName), O_WRONLY | O_CREAT | O_TRUNC, 0600);
100104
if (fd >= 0)
101105
{
102106
dup2 (fd, STDERR_FILENO);
103107
::close(fd);
104108
} else {
105-
qWarning() << "Could not open stderr to .xsession-errors file";
109+
qWarning() << "Could not open stderr to" << fileName;
106110
}
107111

108112
//redirect any stdout to /dev/null

0 commit comments

Comments
 (0)