From 6ac4ffab0627df378e161a9406d27da536ec6cb8 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 4 Mar 2021 13:49:43 +0100 Subject: Prefix usernames that start with a digit with _x_ --- src/namereplace.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/namereplace.cpp b/src/namereplace.cpp index c2c36a8..93f4a21 100644 --- a/src/namereplace.cpp +++ b/src/namereplace.cpp @@ -64,10 +64,23 @@ void NameReplace::loadSubs() void NameReplace::replace(QString& input) { if (!list.isEmpty()) { + // First, apply user defined replacement for (auto &brumm : list) { input = input.replace(brumm.first, brumm.second); } } + // Now, prefix names that start with a digit, since systemd/logind refuses + // to work with those in more recent versions. It was never a good idea to + // do this anyways, but now we don't have a choice, since sessions without + // a proper systemd user instance will become more and more broken in the + // future. + if (*input.constData() >= '0' && *input.constData() <= '9') { + input = QLatin1String("_x_") + input; + } + // Finally, look up the proper casing of the desired username, as some + // servers (AD) are case insensitive, which can lead to problems if what the + // user entered doesn't exactly match what it's actually spelled like + // server-side. QProcess getCaps; getCaps.start(LOOKUP_PROCESS, QStringList(input)); getCaps.waitForFinished(8000); -- cgit v1.2.3-55-g7522