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.
This commit is contained in:
parent
80e7839b97
commit
e680e16ff8
19
timeoutd.c
19
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 */
|
||||
|
|
Loading…
Reference in a new issue