From ea79392ce726186e6a2107a00977ae9d5ce8598d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 4 Dec 2018 14:51:27 +0100 Subject: Namereplace: Try to call external tool to translate username Mainly used to achieve case insentive login --- src/namereplace.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/namereplace.cpp b/src/namereplace.cpp index cc93025..0e203f3 100644 --- a/src/namereplace.cpp +++ b/src/namereplace.cpp @@ -4,8 +4,10 @@ #include #include #include +#include #define SOURCE_FILE "/opt/openslx/lightdm/login-regexp" +#define LOOKUP_PROCESS "/opt/openslx/pam/get_username" static QList< QPair< QRegularExpression, QString > > list; @@ -61,9 +63,22 @@ void NameReplace::loadSubs() void NameReplace::replace(QString& input) { - if (list.isEmpty()) - return; - for (auto &brumm : list) { - input = input.replace(brumm.first, brumm.second); + if (!list.isEmpty()) { + for (auto &brumm : list) { + input = input.replace(brumm.first, brumm.second); + } + } + QProcess getCaps; + getCaps.start(LOOKUP_PROCESS, QStringList(input)); + getCaps.waitForFinished(100); + QString output = QString::fromLocal8Bit(getCaps.readAllStandardOutput()); + int idx = output.indexOf('\n'); + if (idx != -1) { + output = output.left(idx); + } + if (output.length() == input.length()) { + input = output; + } else { + qDebug() << "Not replacing" << input << "by" << output; } } -- cgit v1.2.3-55-g7522