From 256a97278727f550394475fd6abda89ed1ef3d03 Mon Sep 17 00:00:00 2001 From: Petar Kapris Date: Mon, 28 Dec 2020 23:39:40 +0100 Subject: [PATCH] Remove getdisc function completely The function getdisc doesn't seem to serve any purpose when it comes to checking user idle time, by the time it's called, the part of check_idle which checks access time to the terminal will have already finished, and there is no reason that a check for idle time on a terminal should act any differently based on the line discipline. Since the function serves no purpose, and the call and check of it's result seems like it only introduces a potential bug, and has no reason to be there, the function has been removed, as well as the code in chk_timeout which calls it. NOTE: at this point, the function didn't even check the line discipline, i gutted it so it would only return the constant N_TTY, i was planning on rewriting the function to get the terminal line discipline in a more portable way, since the original way wasn't, but ultimately decided it didn't even need to exist in the first place. --- timeoutd.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/timeoutd.c b/timeoutd.c index 5f94509..f8c6cf8 100644 --- a/timeoutd.c +++ b/timeoutd.c @@ -94,7 +94,6 @@ void bailout(); char chk_timeout(); void logoff_msg(); void killit(); -int getdisc(); int chk_xsession(); /* seppy: is it a X-Session? */ void killit_xsession(); /* seppy: kill the X-Session */ int chk_ssh(pid_t pid); /* seppy: check if user is logged in via ssh (we have to @@ -739,7 +738,6 @@ int session; char usermatch = 0; char groupmatch = 0; char **p; - int disc; configline = 0; @@ -784,15 +782,12 @@ int session; config[configline]->sessmax, daytime, config[configline]->daymax, config[configline]->warntime); #endif - disc = getdisc(dev, host); - limit_type = NOLOGINMSG; if (!config[configline]->login_allowed) return NOLOGIN; limit_type = IDLEMSG; - if (disc == N_TTY && config[configline]->idlemax > 0 - && idle >= config[configline]->idlemax) + if (config[configline]->idlemax > 0 && idle >= config[configline]->idlemax) return IDLEMAX; limit_type = SESSMSG; @@ -1053,17 +1048,6 @@ int signum; signal(SIGCHLD, reapchild); } -int getdisc(d, host) -char *d; -char *host; -{ - int fd; - int disc; - - return N_TTY; - /* TODO: add an actual portable way of getting terminal discipline */ -} - int chk_xsession(dev, host) /* returns TIMEOUTD_XSESSION_{REMOTE,LOCAL,NONE} when dev and host seem to be a xSession. */ char *dev, *host; {