diff --git a/timeoutd.c b/timeoutd.c index 95b1572..a670fbc 100644 --- a/timeoutd.c +++ b/timeoutd.c @@ -57,55 +57,6 @@ #define OPENLOG_FLAGS LOG_CONS|LOG_PID #define SYSLOG_DEBUG LOG_DEBUG -/* For those systems (SUNOS) which don't define this: */ -#ifndef WTMP_FILE -#define WTMP_FILE "/usr/adm/wtmp" -#endif - -#ifdef SUNOS -#define ut_pid ut_time -#define ut_user ut_name -#define SEEK_CUR 1 -#define SEEK_END 2 -#define SURE_KILL 1 - -FILE *utfile = NULL; -#define NEED_UTMP_UTILS -#define NEED_STRSEP -#endif - - -#ifdef NEED_UTMP_UTILS -void setutent() -{ - if (utfile == NULL) { - if ((utfile = fopen("/etc/utmp", "r")) == NULL) { - openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); - syslog(LOG_ERR, "Could not open /etc/utmp"); - closelog(); - exit(1); - } - } else - fseek(utfile, 0L, 0); -} - -struct utmp *getutent() -{ /* returns next utmp file entry */ - static struct utmp uent; - - while (fread(&uent, sizeof(struct utmp), 1, utfile) == 1) { - if (uent.ut_line[0] != 0 && uent.ut_name[0] != 0) - return &uent; - } - return (struct utmp *) NULL; -} -#endif - -#ifndef linux -#define N_TTY 1 -#define N_SLIP 2 -#endif - #ifndef CONFIG #define CONFIG "/etc/timeouts" #endif @@ -220,33 +171,6 @@ int strcasecmp(char *s1, char *s2) } #endif -#ifdef NEED_STRSEP -char *strsep(stringp, delim) -char **stringp; -char *delim; -{ - char *retp = *stringp; - char *p; - - if (!**stringp) - return NULL; - - while (**stringp) { - p = delim; - while (*p) { - if (*p == **stringp) { - **stringp = '\0'; - (*stringp)++; - return retp; - } - p++; - } - (*stringp)++; - } - return retp; -} -#endif - int main(argc, argv) int argc; char *argv[]; @@ -1248,23 +1172,6 @@ char *host; return; /* returns */ /* Wait a little while in case the above message gets lost during logout */ -#ifdef SURE_KILL - signal(SIGHUP, SIG_IGN); - if ((pw = getpwnam(user)) == NULL) { - openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); - syslog(LOG_ERR, "Could not log user %s off line %s - unable to determine uid.", user, dev); - closelog(); - } - if (setuid(pw->pw_uid)) { - openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); - syslog(LOG_ERR, "Could not log user %s off line %s - unable to setuid(%d).", user, dev, - pw->pw_uid); - closelog(); - } - kill(-1, SIGHUP); - sleep(KWAIT); - kill(-1, SIGKILL); -#else kill(pid, SIGHUP); /* first send "hangup" signal */ sleep(KWAIT); if (!kill(pid, 0)) { /* SIGHUP might be ignored */ @@ -1276,7 +1183,6 @@ char *host; closelog(); } } -#endif exit(0); } @@ -1329,41 +1235,8 @@ char *host; int fd; int disc; -#ifdef linux - if (chk_xsession(d, host) || chk_xterm(d, host)) - return N_TTY; - - if ((fd = open(d, O_RDONLY | O_NONBLOCK | O_NOCTTY)) < 0) { - openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); - syslog(LOG_WARNING, - "Could not open %s for checking line discipline - idle limits will be enforced.", d); - closelog(); - return N_TTY; - } - - if (ioctl(fd, TIOCGETD, &disc) < 0) { - close(fd); - openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); - syslog(LOG_WARNING, "Could not get line discipline for %s - idle limits will be enforced.", - d); - closelog(); - return N_TTY; - } - - close(fd); - -#ifdef DEBUG - openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); - syslog(SYSLOG_DEBUG, "TTY %s: Discipline=%s.", d, - disc == N_SLIP ? "SLIP" : disc == N_TTY ? "TTY" : disc == - N_PPP ? "PPP" : disc == N_MOUSE ? "MOUSE" : "UNKNOWN"); - closelog(); -#endif - - return disc; -#else return N_TTY; -#endif + /* 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. */