diff -urNr boinc-client_release-7.16-7.16.6-orig/client/hostinfo_unix.cpp boinc-client_release-7.16-7.16.6/client/hostinfo_unix.cpp
--- boinc-client_release-7.16-7.16.6-orig/client/hostinfo_unix.cpp 2020-03-23 06:13:30.000000000 +0100
+++ boinc-client_release-7.16-7.16.6/client/hostinfo_unix.cpp 2020-04-12 01:01:19.675369180 +0200
@@ -41,16 +41,6 @@
#include <cstring>
#endif
-#if HAVE_XSS
-#include <X11/extensions/scrnsaver.h> //X-based idle detection
-// prevents naming collision between X.h define of Always and boinc's
-// lib/prefs.h definition in an enum.
-#undef Always
-#include <dirent.h> //for opening /tmp/.X11-unix/
- // (There is a DirScanner class in BOINC, but it doesn't do what we want)
-#include "log_flags.h" // idle_detection_debug flag for verbose output
-#endif
-
#include <cstdio>
#include <cstdlib>
#include <cstring>
@@ -1800,191 +1790,6 @@
}
#endif // HAVE_UTMP_H
-#if LINUX_LIKE_SYSTEM
-
-#if HAVE_XSS
-
-// Initializer for const vector<string> in xss_idle
-//
-const vector<string> X_display_values_initialize() {
- // According to "man Xserver", each local Xserver will have a socket file
- // at /tmp/.X11-unix/Xn, where "n" is the display number (0, 1, 2, etc).
- // We will parse this directory for currently open Xservers and attempt
- // to ultimately query them for their idle time. If we can't open this
- // directory, or the display_values vector is otherwise empty, then a
- // static list of guesses for open display servers is utilized instead
- // (DISPLAY values ":{0..6}") that will attempt connections to the first
- // seven open Xservers.
- //
- // If we were unable to open _any_ Xserver, then we will log this and
- // xss_idle returns true, effectively leaving idle detection up to other
- // methods.
- //
- static const string dir = "/tmp/.X11-unix/";
- vector<string> display_values;
- vector<string>::iterator it;
-
- DIR *dp;
- struct dirent *dirp;
- if ((dp = opendir(dir.c_str())) == NULL) {
- if (log_flags.idle_detection_debug ) {
- msg_printf(NULL, MSG_INFO,
- "[idle_detection] Error (%d) opening %s.", errno, dir.c_str()
- );
- }
- } else {
- while ((dirp = readdir(dp)) != NULL) {
- display_values.push_back(string(dirp->d_name));
- }
- closedir(dp);
- }
-
- // Get rid of non-matching elements and format the matching ones.
- //
- for (it = display_values.begin(); it != display_values.end(); ) {
- if (it->c_str()[0] != 'X') {
- it = display_values.erase(it);
- } else {
- replace(it->begin(), it->end(), 'X', ':');
- it++;
- }
- }
-
- // if the display_values vector is empty, assume something went wrong
- // (couldn't open directory, no apparent Xn files). Test a static list of
- // DISPLAY values instead that is likely to catch most common use cases.
- // (I don't know of many environments where there will simultaneously be
- // more than seven active, local Xservers. I'm sure they exist... somewhere.
- // But seven was the magic number for me).
- //
- if ( display_values.size() == 0 ) {
- if ( log_flags.idle_detection_debug ) {
- msg_printf(NULL, MSG_INFO,
- "[idle_detection] No DISPLAY values found in /tmp/.X11-unix/."
- );
- msg_printf(NULL, MSG_INFO,
- "[idle_detection] Using static DISPLAY list, :{0..6}."
- );
- }
- display_values.push_back(":0");
- display_values.push_back(":1");
- display_values.push_back(":2");
- display_values.push_back(":3");
- display_values.push_back(":4");
- display_values.push_back(":5");
- display_values.push_back(":6");
- return display_values;
- } else {
- return display_values;
- }
-}
-
-// Ask the X server for user idle time (using XScreenSaver API)
-// Return min of idle times.
-// This function assumes that the boinc user has been
-// granted access to the Xservers a la "xhost +SI:localuser:boinc". If
-// access isn't available for an Xserver, then that Xserver is skipped.
-// One may drop a file in /etc/X11/Xsession.d/ that runs the xhost command
-// for all Xservers on a machine when the Xservers start up.
-//
-long xss_idle() {
- long idle_time = USER_IDLE_TIME_INF;
- const vector<string> display_values = X_display_values_initialize();
- vector<string>::const_iterator it;
-
- // If we can connect to at least one DISPLAY, this is set to false.
- //
- bool no_available_x_display = true;
-
- static XScreenSaverInfo* xssInfo = XScreenSaverAllocInfo();
- // This shouldn't fail. XScreenSaverAllocInfo just returns a small
- // struct (see "man 3 xss"). If we can't allocate this, then we've
- // got bigger problems to worry about.
- //
- if (xssInfo == NULL) {
- if (log_flags.idle_detection_debug) {
- msg_printf(NULL, MSG_INFO,
- "[idle_detection] XScreenSaverAllocInfo failed. Out of memory? Skipping XScreenSaver idle detection."
- );
- }
- return true;
- }
-
- for (it = display_values.begin(); it != display_values.end() ; it++) {
-
- Display* disp = NULL;
- long display_idle_time = 0;
-
- disp = XOpenDisplay(it->c_str());
- // XOpenDisplay may return NULL if there is no running X
- // or DISPLAY points to wrong/invalid display
- //
- if (disp == NULL) {
- if (log_flags.idle_detection_debug) {
- msg_printf(NULL, MSG_INFO,
- "[idle_detection] DISPLAY '%s' not found or insufficient access.",
- it->c_str()
- );
- }
- continue;
- }
-
- // Determine if the DISPLAY we have accessed has the XScreenSaver
- // extension or not.
- //
- int event_base_return, error_base_return;
- if (!XScreenSaverQueryExtension(
- disp, &event_base_return, &error_base_return
- )){
- if (log_flags.idle_detection_debug) {
- msg_printf(NULL, MSG_INFO,
- "[idle_detection] XScreenSaver extension not available for DISPLAY '%s'.",
- it->c_str()
- );
- }
- XCloseDisplay(disp);
- continue;
- }
-
- // All checks passed. Get the idle information.
- //
- no_available_x_display = false;
- XScreenSaverQueryInfo(disp, DefaultRootWindow(disp), xssInfo);
- idle_time = xssInfo->idle;
-
- // Close the connection to the XServer
- //
- XCloseDisplay(disp);
-
- // convert from milliseconds to seconds
- //
- display_idle_time /= 1000;
-
- if (log_flags.idle_detection_debug) {
- msg_printf(NULL, MSG_INFO,
- "[idle_detection] XSS idle detection succeeded on DISPLAY '%s'.", it->c_str()
- );
- msg_printf(NULL, MSG_INFO,
- "[idle_detection] idle_time: %ld", idle_time
- );
- }
-
- idle_time = min(idle_time, display_idle_time);
- }
-
- // If none of the Xservers were queryable, report it
- //
- if (log_flags.idle_detection_debug && no_available_x_display) {
- msg_printf(NULL, MSG_INFO,
- "[idle_detection] Could not connect to any DISPLAYs. XSS idle determination impossible."
- );
- }
- return idle_time;
-
-}
-#endif // HAVE_XSS
-
-#endif // LINUX_LIKE_SYSTEM
long HOST_INFO::user_idle_time(bool check_all_logins) {
long idle_time = USER_IDLE_TIME_INF;
@@ -1998,20 +1803,7 @@
idle_time = min(idle_time, all_tty_idle_time());
#if LINUX_LIKE_SYSTEM
-
-#if HAVE_XSS
- idle_time = min(idle_time, xss_idle());
-#endif // HAVE_XSS
-
-#else
- // We should find out which of the following are actually relevant
- // on which systems (if any)
- //
- idle_time = min(idle_time, (long)device_idle(idle_time, "/dev/mouse"));
- // solaris, linux
- idle_time = min(idle_time, (long)device_idle(idle_time, "/dev/input/mice"));
- idle_time = min(idle_time, (long)device_idle(idle_time, "/dev/kbd"));
- // solaris
+ idle_time = 0;
#endif // LINUX_LIKE_SYSTEM
return idle_time;
}