Delete trailing whitespaces

Several lines in the code either have whitespace where tabs are
expected, the converse, or trailing whitespace before a newline. All
of these have been removed or replaced.
This commit is contained in:
kappa 2020-10-30 21:56:33 +01:00
parent 2bd4a73b56
commit 848c784e7f

View file

@ -1,7 +1,7 @@
/*
"@(#) timeoutd.c 1.6 by Shane Alderton"
based on:
"@(#) autologout.c by David Dickson"
"@(#) autologout.c by David Dickson"
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -96,7 +96,7 @@ struct utmp *getutent() /* returns next utmp file entry */
while (fread(&uent, sizeof(struct utmp), 1, utfile) == 1)
{
if (uent.ut_line[0] != 0 && uent.ut_name[0] != 0)
if (uent.ut_line[0] != 0 && uent.ut_name[0] != 0)
return &uent;
}
return (struct utmp *) NULL;
@ -467,7 +467,7 @@ void free_wtmp()
#ifdef DEBUG_WTMP
struct tm *tm;
tm = localtime(&(wtmplist->elem.ut_time));
printf("%d:%d %s %s %s\n",
printf("%d:%d %s %s %s\n",
tm->tm_hour,tm->tm_min, wtmplist->elem.ut_line,
wtmplist->elem.ut_user,
#ifndef SUNOS
@ -719,7 +719,7 @@ struct time_ent *te;
{
if (daynums[now.tm_wday] & te->days && /* Date within range */
((te->starttime <= te->endtime && /* Time within range */
now_hhmm >= te->starttime &&
now_hhmm >= te->starttime &&
now_hhmm <= te->endtime)
||
(te->starttime > te->endtime &&
@ -791,7 +791,7 @@ char *user;
#ifdef DEBUG_WTMP
struct tm *tm;
tm = localtime(&(login_p->elem.ut_time));
fprintf(stderr, "%d:%d %s %s %s\n",
fprintf(stderr, "%d:%d %s %s %s\n",
tm->tm_hour,tm->tm_min, login_p->elem.ut_line,
login_p->elem.ut_user,
"login");
@ -825,7 +825,7 @@ char *user;
if (logout_p)
{
tm = localtime(&(logout_p->elem.ut_time));
fprintf(stderr, "%d:%d %s %s %s\n",
fprintf(stderr, "%d:%d %s %s %s\n",
tm->tm_hour,tm->tm_min, logout_p->elem.ut_line,
logout_p->elem.ut_user, "logout");
fprintf(stderr, "%s %d minutes\n", user, ((logout_p?logout_p->elem.ut_time:time_now) - login_p->elem.ut_time)/60);
@ -876,7 +876,7 @@ char *host;
sleep(KWAIT); /* and give the user some time to read the message ;) */
return;
}
if ((fd = open(tty, O_WRONLY|O_NOCTTY|O_NONBLOCK)) < 0 ||
(ttyf = fdopen(fd, "w")) == NULL)
{
@ -1029,7 +1029,7 @@ void check_idle() /* Check for exceeded time limits & logoff exceeders */
/* Only check user if he is mentioned in the config */
if(!config[0])
return; /* no entries in config */
while(config[++aktconfigline] && aktconfigline >= 0)
@ -1037,7 +1037,7 @@ void check_idle() /* Check for exceeded time limits & logoff exceeders */
aktconfigline = -2; /* we found user or * in config, so he/they has/have restrictions */
break;
}
if(aktconfigline > 0) { /* > 0 if user is not in config */
#ifdef DEBUG
openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON);
@ -1059,13 +1059,13 @@ void check_idle() /* Check for exceeded time limits & logoff exceeders */
sprintf(errmsg, "Can't get status of user %s's terminal (%s)\n",
user, dev);
/* bailout(errmsg, 1); MOH: is there a reason to exit here? */
return;
return;
}
/* idle time is the lesser of:
* current time less last access time OR
* current time less last modified time
*/
#ifdef TIMEOUTDX11
#ifdef TIMEOUTDX11
if(chk_xsession(dev, host) && !chk_xterm(dev, host)) { /* check idle for Xsession, but not for xterm */
idle = get_xidle(user, host) / 1000 / 60; /* get_xidle returns millisecs, we need mins */
openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON);
@ -1207,8 +1207,8 @@ char *host;
closelog();
return;
}
/* check if the pid is sshd. If so, get PID of the child process (another ssh, owned by the user).
Test reverse if this child process is also ssh and owned by the user we want to log out.
(because we don't want to slay another user ;) */
@ -1218,7 +1218,7 @@ char *host;
syslog(LOG_NOTICE, "I am at killit() pid=%d user=%s child=%d line %d", pid, user, cpid, __LINE__);
closelog();
#endif
if(chk_ssh(pid) && chk_ssh(cpid) && !strcmp(getusr(cpid), user)) {
#ifdef DEBUG
openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON);
@ -1327,7 +1327,7 @@ char *host;
#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);
@ -1365,17 +1365,17 @@ char *dev,*host;
if( strncmp(host, ":0", 1) == 0 ) {
/* Look here, how we check if it's a Xsession but no telnet or whatever.
* The problem is that a xterm running on :0 has the device pts/?. But if we ignore
* all pts/?, ssh users won't be restricted.
* all pts/?, ssh users won't be restricted.
* So, if (tty="pts/?" OR tty=":*") AND host = ":*", we have a Xsession:
*
*
* seppy@schleptop:~$ w
* 20:06:33 up 18 min, 6 users, load average: 0.14, 0.16, 0.12
* USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
* dennis :0 - 19:48 ?xdm? 0.00s ? -
* dennis pts/1 :0.0 20:00 4:12 0.03s 0.03s bash
* dennis pts/2 :0.0 20:01 0.00s 0.18s 0.16s ssh localhost
* dennis pts/1 :0.0 20:00 4:12 0.03s 0.03s bash
* dennis pts/2 :0.0 20:01 0.00s 0.18s 0.16s ssh localhost
* dennis pts/3 localhost 20:01 0.00s 0.01s 0.00s w
*/
*/
#ifdef DEBUG
openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON);
syslog(LOG_DEBUG, "LOCAL Xsession detected. device=%s host=%s", dev, host);
@ -1451,9 +1451,9 @@ char *host, *user;
closelog();
#endif
sleep(KWAIT); /* and give the user some time to read the message ;) */
#ifndef DEBUG
#ifndef DEBUG
/* kill pid here */
kill(pid, SIGTERM); /* otherwise, X crashes */
sleep(KWAIT);
@ -1490,12 +1490,12 @@ pid_t pid;
fscanf (proc_file, "%*d (%[^)]", comm);
fclose(proc_file);
if(!strcmp(comm, "sshd"))
return 1;
else
return 0;
}
}
char *getusr(pid) /*seppy; returns the name of the user owning process with the Process ID pid */
pid_t pid;
@ -1521,7 +1521,7 @@ char *user;
char *display;
{
Display* dpy;
static XScreenSaverInfo* mitInfo = 0;
static XScreenSaverInfo* mitInfo = 0;
struct passwd *pwEntry;
char homedir[50]; /*50 should be enough*/
char oldhomedir[50];
@ -1558,13 +1558,13 @@ char *display;
sprintf(homedir, "HOME=%s", pwEntry->pw_dir);
putenv(homedir);
/* First, check if there is a xserver.. */
/* First, check if there is a xserver.. */
if ((dpy = XOpenDisplay (display)) == NULL) { /* = intended */
openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON);
syslog(LOG_NOTICE, "Could not connect to %s to query idle-time for %s. Ignoring.", display, user);
closelog();
} else {
if (!mitInfo)
if (!mitInfo)
mitInfo = XScreenSaverAllocInfo ();
XScreenSaverQueryInfo (dpy, DefaultRootWindow (dpy), mitInfo);
retval = mitInfo->idle;
@ -1580,14 +1580,14 @@ char *display;
/* seppy; getchild()
returns the pid of the first child-process found.
- 1 if a error occured,
returns the pid of the first child-process found.
- 1 if a error occured,
- 0 if none found
We need this because utmp returns a process owned by
We need this because utmp returns a process owned by
root when a user is connected via ssh. If we kill its
child (owned by the user) he/she gets logged off */
pid_t getcpid(ppid)
pid_t getcpid(ppid)
pid_t ppid;
{
DIR *proc;
@ -1595,27 +1595,27 @@ pid_t ppid;
struct dirent *cont;
char akt_pid[99];
char path[512];
proc = opendir("/proc/");
if(proc == NULL) {
printf("error opening directory\n");
return -1; /* error */
}
while((cont = readdir(proc)) != NULL) {
if(cont->d_type == DT_DIR && isdigit(cont->d_name[0])) { /* check only PIDs */
sprintf(path, "/proc/%s/status", cont->d_name);
proc_file = fopen(path, "r");
if(!proc_file)
printf("error opening proc status file %s\n", path);
while(!fscanf(proc_file, "PPid: %s", akt_pid))
fgets(akt_pid, 10, proc_file);
if(atoi(akt_pid) == ppid)
return (pid_t)atoi(cont->d_name); /* return pid of child */
}
}
return 0; /* no child found */
return 0; /* no child found */
} /* getchild(ppid) */