summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSebastien Braun2010-10-06 15:13:31 +0200
committerSebastien Braun2010-10-06 15:13:31 +0200
commitc8579de3b79b64bcb72adfd97d2ebf424e8df4b7 (patch)
tree7a17024762217daec3c1f04384324091f40abaf5 /src
parentFix deletion order bug (diff)
downloadpvs-c8579de3b79b64bcb72adfd97d2ebf424e8df4b7.tar.gz
pvs-c8579de3b79b64bcb72adfd97d2ebf424e8df4b7.tar.xz
pvs-c8579de3b79b64bcb72adfd97d2ebf424e8df4b7.zip
Detect the presence of PolKit on configuration
When no PolKit is installed, the program gets built without support for it. This can be overriden by specifying -DENABLE_POLKIT=ON on the cmake command line.
Diffstat (limited to 'src')
-rw-r--r--src/input/CMakeLists.txt21
-rw-r--r--src/input/pvsCheckPrivileges.cpp4
2 files changed, 25 insertions, 0 deletions
diff --git a/src/input/CMakeLists.txt b/src/input/CMakeLists.txt
index fcb5ff5..44cf6b6 100644
--- a/src/input/CMakeLists.txt
+++ b/src/input/CMakeLists.txt
@@ -57,6 +57,27 @@ if(UNIX)
x11FakeMouseHandler.cpp
privilegedHandlerForwarder.cpp
)
+
+ # we need pkg-config to find out where to install the action file:
+ find_package(PkgConfig)
+ if(NOT PKG_CONFIG_FOUND)
+ # we will try to make a best effort and put our policy file into
+ # ${PREFIX}/share/polkit-1, but only if we can find
+ # the pkexec executable.
+ find_program(PKEXEC_LOCATION pkexec)
+ if(PKEXEC_LOCATION OR ENABLE_POLKIT)
+ set(POLKIT_FOUND ON)
+ endif()
+ else()
+ pkg_check_modules(POLKIT "polkit-gobject-1")
+ endif()
+
+ # now, arrange for policykit integration:
+ if(POLKIT_FOUND OR ENABLE_POLKIT)
+ set_property(SOURCE ${pvsprivinputd_SRCS}
+ APPEND
+ PROPERTY COMPILE_DEFINITIONS HAVE_POLKIT)
+ endif()
endif()
add_library(
diff --git a/src/input/pvsCheckPrivileges.cpp b/src/input/pvsCheckPrivileges.cpp
index 57b5d8b..f9a8851 100644
--- a/src/input/pvsCheckPrivileges.cpp
+++ b/src/input/pvsCheckPrivileges.cpp
@@ -211,6 +211,7 @@ PVSCheckPrivileges::UserPrivilege PVSCheckPrivileges::getUserPrivilege(CachedInp
}
// User is not trivially privileged, so try to check with PolicyKit.
+#ifdef HAVE_POLKIT // but only if it is present
// For PolKit, we need the start-time of the process.
// On Linux, we can get it from /proc:
QString procStat = QString("/proc/%1/stat").arg(sender.pid);
@@ -257,6 +258,9 @@ PVSCheckPrivileges::UserPrivilege PVSCheckPrivileges::getUserPrivilege(CachedInp
return USER_LOOKUP_FAILURE;
}
return reply.value().isAuthorized ? USER_PRIVILEGED : USER_UNPRIVILEGED;
+#else
+ return USER_UNPRIVILEGED;
+#endif
}
QString PVSCheckPrivileges::getX11SessionName(CachedInputContext const& sender)