On 28.11.19 г. 16:27 ч., Slavomir Kaslev wrote:
On Thu, Nov 28, 2019 at 1:46 PM Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx> wrote: [...]+ auto lamRootHome = [] () { + QFile fPswd("/etc/passwd"); + QString home("/root"); + QStringList userInfo; + + fPswd.open(QIODevice::ReadOnly); + if (!fPswd.isOpen()) + return home; + + QTextStream s(&fPswd); + while (!s.atEnd()) { + userInfo = s.readLine().split(':'); + + /* Check the User Id. */ + if (userInfo[2].toInt() == 0) { + home = userInfo[5]; + break; + } + } +Another option is to use getpwent(3) [0] instead of parsing /etc/passwd by hand.
Hi Slavi, Thanks for pointing out this! This simplifies the patch a lot. I am sending a new version. cheers, Yordan
Cheers, -- Slavi [0] http://man7.org/linux/man-pages/man3/getpwent.3.html