From abee9c239f74f60a77c0931be23ad1d8670feda6 Mon Sep 17 00:00:00 2001 From: Hrvoje Senjan Date: Tue, 3 Dec 2013 19:31:13 +0100 Subject: [PATCH 1/1] kdesu Add some love From/toUTF8 in practice covers more ground than 8bit. Furthermore, make the kdesu 'command' translatable, it's used in openSUSE with dolphin and konsole 'Start as root' BUG: boo#852256 --- kdesu/kdesu.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) Index: kde-cli-tools-5.17.80git.20220801T014355~e85be44/kdesu/kdesu.cpp =================================================================== --- kde-cli-tools-5.17.80git.20220801T014355~e85be44.orig/kdesu/kdesu.cpp 2022-08-01 03:43:55.000000000 +0200 +++ kde-cli-tools-5.17.80git.20220801T014355~e85be44/kdesu/kdesu.cpp 2022-08-01 05:47:00.996968576 +0200 @@ -165,10 +165,10 @@ int result = startApp(parser); if (result == 127) { - KMessageBox::error(nullptr, i18n("Cannot execute command '%1'.", QString::fromLocal8Bit(command))); + KMessageBox::error(nullptr, i18n("Cannot execute command '%1'.", QString::fromUtf8(command))); } if (result == -2) { - KMessageBox::error(nullptr, i18n("Cannot execute command '%1'. It contains invalid characters.", QString::fromLocal8Bit(command))); + KMessageBox::error(nullptr, i18n("Cannot execute command '%1'. It contains invalid characters.", QString::fromUtf8(command))); } return result; @@ -202,7 +202,7 @@ } // Get target uid - const QByteArray user = p.value(QStringLiteral("u")).toLocal8Bit(); + const QByteArray user = p.value(QStringLiteral("u")).toUtf8(); QByteArray auth_user = user; struct passwd *pw = getpwnam(user.constData()); if (pw == nullptr) { @@ -256,7 +256,7 @@ // Get command if (p.isSet(QStringLiteral("c"))) { - command = p.value(QStringLiteral("c")).toLocal8Bit(); + command = p.value(QStringLiteral("c")).toUtf8(); // Accepting additional arguments here is somewhat weird, // but one can conceive use cases: have a complex command with // redirections and additional file names which need to be quoted @@ -339,7 +339,7 @@ // } KUser u; - env << (QByteArray)("KDESU_USER=" + u.loginName().toLocal8Bit()); + env << (QByteArray)("KDESU_USER=" + u.loginName().toUtf8()); if (keep && !terminal && !just_started) { client.setPriority(priority); @@ -448,7 +448,7 @@ result = WEXITSTATUS(result); return result; } else if (keep && have_daemon) { - client.setPass(password.toLocal8Bit().constData(), timeout); + client.setPass(password.toUtf8().constData(), timeout); client.setPriority(priority); client.setScheduler(scheduler); int result = client.exec(command, user, options, env); @@ -465,7 +465,7 @@ proc.setPriority(priority); proc.setScheduler(scheduler); proc.setCommand(command); - int result = proc.exec(password.toLocal8Bit().constData()); + int result = proc.exec(password.toUtf8().constData()); return result; } return -1;