Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'jb43771' into 'master'
[lipstick] Don't allow non-privileged processes to raise arbitrary windows. Fixes JB#43771 See merge request mer-core/lipstick!98
- Loading branch information
Showing
11 changed files
with
106 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*************************************************************************** | ||
** | ||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | ||
** Copyright (C) 2012 Jolla Ltd. | ||
** Contact: Robin Burchell <robin.burchell@jollamobile.com> | ||
** | ||
** This file is part of lipstick. | ||
** | ||
** This library is free software; you can redistribute it and/or | ||
** modify it under the terms of the GNU Lesser General Public | ||
** License version 2.1 as published by the Free Software Foundation | ||
** and appearing in the file LICENSE.LGPL included in the packaging | ||
** of this file. | ||
** | ||
****************************************************************************/ | ||
|
||
#include "privilegeddbuscontext.h" | ||
|
||
#include <QCoreApplication> | ||
#include <QDBusConnectionInterface> | ||
#include <QFileInfo> | ||
|
||
uint PrivilegedDBusContext::callerProcessId() const | ||
{ | ||
if (calledFromDBus()) { | ||
return connection().interface()->servicePid(message().service()).value(); | ||
} else { | ||
return QCoreApplication::applicationPid(); | ||
} | ||
} | ||
|
||
bool PrivilegedDBusContext::isPrivileged() | ||
{ | ||
if (!calledFromDBus()) { | ||
// Local function calls are always privileged | ||
return true; | ||
} | ||
|
||
// Get the PID of the calling process | ||
pid_t pid = connection().interface()->servicePid(message().service()); | ||
|
||
// The /proc/<pid> directory is owned by EUID:EGID of the process | ||
QFileInfo info(QStringLiteral("/proc/%1").arg(pid)); | ||
if (info.group() != QLatin1String("privileged") && info.owner() != QLatin1String("root")) { | ||
sendErrorReply(QDBusError::AccessDenied, | ||
QStringLiteral("PID %1 is not in privileged group").arg(pid)); | ||
return false; | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*************************************************************************** | ||
** | ||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | ||
** Copyright (C) 2012 Jolla Ltd. | ||
** Contact: Robin Burchell <robin.burchell@jollamobile.com> | ||
** | ||
** This file is part of lipstick. | ||
** | ||
** This library is free software; you can redistribute it and/or | ||
** modify it under the terms of the GNU Lesser General Public | ||
** License version 2.1 as published by the Free Software Foundation | ||
** and appearing in the file LICENSE.LGPL included in the packaging | ||
** of this file. | ||
** | ||
****************************************************************************/ | ||
#ifndef PRIVILEGEDDBUSCONTEXT_H | ||
#define PRIVILEGEDDBUSCONTEXT_H | ||
|
||
#include <QDBusContext> | ||
#include "lipstickglobal.h" | ||
|
||
class LIPSTICK_EXPORT PrivilegedDBusContext : public QDBusContext | ||
{ | ||
protected: | ||
/*! | ||
* Identifies whether the caller of a dbus function belongs to the privileged group. | ||
* | ||
* \return true if the caller belongs to the privileged group. | ||
*/ | ||
bool isPrivileged(); | ||
|
||
/*! | ||
* Identifies the caller of a dbus function. | ||
* | ||
* \return The PID of the calling process. | ||
*/ | ||
uint callerProcessId() const; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters