From e680e16ff847d59be00b0648d4144a9a535c0e86 Mon Sep 17 00:00:00 2001 From: Petar Kapris Date: Fri, 18 Dec 2020 19:09:35 +0100 Subject: [PATCH] Remove config check for user in check_idle At the beginning of the check_idle function, the username in the utmp entry currently being checked is used to loop through the config file and check if the user is mentioned in the config line at all. This is completely unnecessary, as the needed check is done later anyways when chk_timeout is called, it might give a slight performance boost to prevent some of the xsession checks that happen before the chk_timeout call, but slow code is probably better than repeating code. --- timeoutd.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/timeoutd.c b/timeoutd.c index 2521be5..3b67bb4 100644 --- a/timeoutd.c +++ b/timeoutd.c @@ -834,7 +834,6 @@ void check_idle() char host[sizeof(utmpp->ut_host) + 1]; struct stat status, *pstat; time_t idle, sesstime; - short aktconfigline = -1; /* -1 if user is in config; >0 if he's not in config, * is handled in an other way */ pstat = &status; /* point to status structure */ sprintf(path, "/proc/%d", utmpp->ut_pid); @@ -843,24 +842,6 @@ void check_idle() strncpy(user, utmpp->ut_user, sizeof(user) - 1); /* get user name */ user[sizeof(user) - 1] = '\0'; /* null terminate user name string */ - - /* Only check user if he is mentioned in the config */ - - while (config[++aktconfigline] && aktconfigline >= 0) - if (chkmatch(user, config[aktconfigline]->users)) { - aktconfigline = -2; /* we found user in config, so he/they has/have restrictions */ - break; - } - - if (aktconfigline > 0) { /* > 0 if user is not in config */ -#ifdef DEBUG - syslog(LOG_DEBUG, "User %s or * not in config -> No restrictions. Not checking %s on %s", - user, user, dev); -#endif - return; /* now, we return because the user beeing checked is not in config, so he has no restrictions */ - } - - strncpy(host, utmpp->ut_host, sizeof(host) - 1); /* get host name */ host[sizeof(host) - 1] = '\0'; strncpy(dev, utmpp->ut_line, sizeof(dev) - 1); /* get device name */