Fix a possible null pointer dereference.
On some systems getlogin() function might fail to obtain user name. For now just check whether pointer is nullptr. In that case suspending plasma device automounter would not work but at least we will not crash. In future it might make sense to try to use other methods of obtaining login name, such as running "who am i". BUG: 381987
This commit is contained in:
parent
037380228d
commit
13c063a150
|
@ -51,8 +51,14 @@ void OperationRunner::run()
|
||||||
|
|
||||||
// Disable Plasma removable device automounting
|
// Disable Plasma removable device automounting
|
||||||
unsigned int currentUid = getuid(); // 0 if running as root
|
unsigned int currentUid = getuid(); // 0 if running as root
|
||||||
unsigned int userId = getpwnam(getlogin())->pw_uid; // uid of original user before sudo
|
char *login = getlogin();
|
||||||
|
if (login != nullptr){
|
||||||
|
passwd* pwnam = getpwnam(login);
|
||||||
|
if (pwnam != nullptr) {
|
||||||
|
unsigned int userId = pwnam->pw_uid; // uid of original user before sudo
|
||||||
seteuid(userId);
|
seteuid(userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
QStringList modules;
|
QStringList modules;
|
||||||
QDBusConnection bus = QDBusConnection::connectToBus(QDBusConnection::SessionBus, QStringLiteral("sessionBus"));
|
QDBusConnection bus = QDBusConnection::connectToBus(QDBusConnection::SessionBus, QStringLiteral("sessionBus"));
|
||||||
QDBusInterface kdedInterface( QStringLiteral("org.kde.kded5"), QStringLiteral("/kded"), QStringLiteral("org.kde.kded5"), bus );
|
QDBusInterface kdedInterface( QStringLiteral("org.kde.kded5"), QStringLiteral("/kded"), QStringLiteral("org.kde.kded5"), bus );
|
||||||
|
|
Loading…
Reference in New Issue