]> git.pld-linux.org Git - packages/autolog.git/blame - autolog-0.34.debian.diff
- release 5,
[packages/autolog.git] / autolog-0.34.debian.diff
CommitLineData
b15a8e40 1diff -urN autolog-0.34.orig/Makefile autolog-0.34/Makefile
2--- autolog-0.34.orig/Makefile Fri Oct 16 20:38:44 1998
3+++ autolog-0.34/Makefile Fri Oct 16 20:39:16 1998
4@@ -3,9 +3,9 @@
5 # The -g flag is to include debugging information. It gets
6 # stripped back out in the install command anyway.
7 CC = gcc
8-CFLAGS = -g
9-MANDIR = /usr/man
10-BINDIR = /usr/sbin
11+CFLAGS = -O2 -g -Wall
12+MANDIR = $(DESTDIR)/usr/man
13+BINDIR = $(DESTDIR)/usr/sbin
14 # *********************************************************
15
16 autolog: autolog.c
17@@ -13,8 +13,9 @@
18
19 install: autolog
20 install -s autolog $(BINDIR)
21- install -m644 autolog.conf.5 $(MANDIR)/man5
22- install -m644 autolog.8 $(MANDIR)/man8
23+ install -p -m644 autolog.conf.5 $(MANDIR)/man5
24+ install -p -m644 autolog.8 $(MANDIR)/man8
25+ install -p -m644 crontab $(DESTDIR)/etc/cron.d/autolog
26
27 clean:
28- rm autolog
29+ rm -f autolog
30diff -urN autolog-0.34.orig/autolog.8 autolog-0.34/autolog.8
31--- autolog-0.34.orig/autolog.8 Fri Oct 16 20:38:44 1998
32+++ autolog-0.34/autolog.8 Fri Oct 16 20:39:16 1998
33@@ -1,4 +1,4 @@
34-.TH AUTOLOG 1L "Administrative Utilities" "Linux" \" -*- nroff -*-
35+.TH AUTOLOG 8 "Administrative Utilities" "Linux" \" -*- nroff -*-
36 .SH NAME
37 autolog \- Log out idle users
38 .SH SYNOPSIS
39@@ -6,55 +6,59 @@
40 .br
41 .SH DESCRIPTION
42 The program reads the utmp file, entry by entry. The
43-username for each 'user process' is compared to the entries in the
44-configuration file (see
45-.B autoconf(5)
46-). The first entry to match both the name, the group,
47+username for each `user process' is compared to the entries in the
48+configuration file
49+.IR autolog.conf .
50+The first entry to match both the name, the group,
51 and the tty line of the process will be used to conduct the automatic
52 logout.
53
54 .SH OPTIONS
55 .TP
56-.B -a
57+.I -a
58 (all processes) Print information on ALL utmp entries--not just user processes.
59 .TP
60-.B -d
61+.I -d
62 (debug mode) This is helpful in setting up your configuration file.
63 The program runs in foreground rather than forking and it prints
64 out verbose messages about what it is doing.
65 .TP
66-.B -n
67+.I -n
68 (nokill) Use this to prevent autolog from actually "killing"
69 anyone. Use -d and -n together when setting up a new
70 configuration file.
71 .TP
72-.B -f config_file_name
73-Use this to override the default: "/etc/autolog.conf"
74-.TP
75-.B -l log_file_name
76-Use this to override the default: "/var/log/autolog.log".
77+.I -f config_file_name
78+Use this to override the default:
79+.I /etc/autolog.conf
80+.TP
81+.I -l log_file_name
82+Use this to override the default:
83+.IR /var/log/autolog.log .
84 Note that if this file doesn't exist, no logging will happen.
85 Create the file (with touch) to enable logging.
86 .TP
87-.B -t idle_time
88+.I -t idle_time
89 Use this to override the internal default idle time (minutes)
90 .TP
91-.B -g grace_period
92+.I -g grace_period
93 Use this to override the internal default grace period (seconds)
94 .TP
95-.B -m yes/no
96+.I -m yes/no
97 Use this to override the internal mailing switch. If "yes"
98 the program will send mail to the users right after killing them.
99 .TP
100-.B -c yes/no
101+.I -c yes/no
102 Use this to override the internal "pre-clear" switch. If "yes"
103 the program will clear the terminal screen before warning the user.
104 .TP
105-.B -w yes/no
106+.I -w yes/no
107 Do timeouts based on total session time--not idle time. (hard)
108 .TP
109-.B -L yes/no
110+.I -L yes/no
111 If set to "yes" activities will be written to the logfile if
112 present.
113+.SH "SEE ALSO"
114+.BR autolog.conf (5)
115 .SH AUTHOR
116 Kyle Bateman <kyle@actarg.com>
117diff -urN autolog-0.34.orig/autolog.c autolog-0.34/autolog.c
118--- autolog-0.34.orig/autolog.c Fri Oct 16 20:38:44 1998
119+++ autolog-0.34/autolog.c Fri Oct 16 20:39:16 1998
120@@ -18,11 +18,13 @@
121 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
122 */
123
124+#include <stdlib.h>
125 #include <stdio.h>
126 #include <signal.h>
127 #include <string.h>
128 #include <sys/types.h>
129 #include <sys/stat.h>
130+#include <unistd.h>
131 #include <utmp.h>
132 #include <time.h>
133 #include <pwd.h>
134@@ -80,7 +82,13 @@
135 conf_el c_arr[MAXCONF];
136 int c_idx = 0;
137
138-main(int argc, char *argv[])
139+void eat_confile(void);
140+int check_idle(void);
141+void bailout(const char *message, int status) __attribute__ ((noreturn));
142+void mesg(int flag, char *name, char *dev, int stime, int idle, conf_el *ce);
143+int killit(pid_t pid);
144+
145+int main(int argc, char *argv[])
146 {
147 int i;
148 for (i = 1; i < argc; i++)
149@@ -132,15 +140,15 @@
150 eat_confile(); /* read config file */
151 if (!debug) /* if not in debug mode, */
152 if (fork()) /* the parent process */
153- exit(0); /* exits */
154+ return 0; /* exits */
155
156 /* the child processes all utmp file entries: */
157 while ((utmpp = getutent()) != (struct utmp *) NULL)
158 check_idle();
159- exit(0); /* done, so bye */
160+ return 0; /* done, so bye */
161 }
162
163-set_defs(int i)
164+void set_defs(int i)
165 {
166 c_arr[i].name = anystrg;
167 c_arr[i].group = anystrg;
168@@ -154,7 +162,7 @@
169 c_arr[i].log = g_log;
170 }
171
172-eat_confile()
173+void eat_confile(void)
174 {
175 FILE *f;
176 char *s, iline[LINELEN];
177@@ -169,7 +177,7 @@
178 {
179 while (fgets(iline, LINELEN, f))
180 {
181- if (*iline == '#' || strlen(iline) <= 1)
182+ if (*iline == '#' || !iline[0] || !iline[1])
183 continue;
184 set_defs(c_idx);
185 s=strtok(iline,delims);
186@@ -207,7 +215,7 @@
187 printf("Unknown token in file: %s: %s\n",confname,s);
188 }
189 }
190- while(s=strtok(0,delims));
191+ while((s=strtok(NULL,delims)));
192 c_idx++;
193 }
194 fclose(f);
195@@ -226,7 +234,7 @@
196 /* versions of the routine should work for you. */
197 #define AVOID_REGEX_BUG
198 #ifdef AVOID_REGEX_BUG /* some strange bug in re_exec */
199-pat_match(char *patt, char *strg)
200+int pat_match(char *patt, char *strg)
201 {
202 struct re_pattern_buffer rpb;
203 int len, retval = 0;
204@@ -249,16 +257,16 @@
205
206 #else
207 /* return true if strg matches the regex in pattern */
208-pat_match(char *pattern,char *strg)
209+int pat_match(char *pattern,char *strg)
210 {
211 re_comp(pattern);
212 return(re_exec(strg));
213 }
214 #endif
215
216-check_idle() /* select utmp entries needing killing */
217+int check_idle(void) /* select utmp entries needing killing */
218 {
219- char dev[STRLEN], name[STRLEN], prname[STRLEN], *gn = "";
220+ char dev[STRLEN], name[STRLEN], *gn = "";
221 struct stat status;
222 time_t idle, pres_time, start, time(), stime, atime;
223 struct passwd *passwd_entry;
224@@ -272,8 +280,7 @@
225 printf("Non-user process: N:%-8s P:%5d Login:%s",utmpp->ut_user,utmpp->ut_pid,ctime(&utmpp->ut_time));
226 return(0); /* skip the utmp entry */
227 }
228- sprintf(prname,"/proc/%d",utmpp->ut_pid); /* make filename to check in /proc */
229- if (stat(prname, &status)) /* is this a current process */
230+ if (kill(utmpp->ut_pid,0)) /* is this a current process? */
231 {
232 if (listall)
233 printf("Dead process: N:%-8s P:%5d Login:%s",utmpp->ut_user,utmpp->ut_pid,ctime(&utmpp->ut_time));
234@@ -293,7 +300,7 @@
235 name[UT_NAMESIZE] = '\0'; /* null terminate user name string */
236
237 if (debug)
238- printf("\nChecking: %-11s on %-12s I:%-4d T:%d Login: %s",name,dev,idle,utmpp->ut_type,ctime(&utmpp->ut_time));
239+ printf("\nChecking: %-11s on %-12s I:%-4ld T:%d Login: %s",name,dev,idle,utmpp->ut_type,ctime(&utmpp->ut_time));
240
241 /* now try to find the group of this person */
242 /* if usernames in utmp are limited to 8 chars, we will may fail on */
243@@ -303,7 +310,7 @@
244 if (passwd_entry)
245 {
246 strcpy(name,passwd_entry->pw_name);
247- if(group_entry = getgrgid( passwd_entry->pw_gid ))
248+ if((group_entry = getgrgid( passwd_entry->pw_gid )))
249 gn = group_entry->gr_name;
250 else if (debug)
251 printf("Can't find group entry for user: %s\n",name);
252@@ -317,8 +324,8 @@
253 pat_match(c_arr[i].line,utmpp->ut_line))
254 {
255 if (debug)
256- printf("Match #%2d: U:%-12s Grp:%-8s Line:%-9s Pid:%-6d Sess:%3d:%02d\n",
257- i+1,name,gn,utmpp->ut_line,utmpp->ut_pid,stime/60,stime%60);
258+ printf("Match #%2d: U:%-12s Grp:%-8s Line:%-9s Pid:%-6d Sess:%3ld:%02d\n",
259+ i+1,name,gn,utmpp->ut_line,utmpp->ut_pid,stime/60,(int)(stime%60));
260 if (!c_arr[i].idle) /* if user exempt (idle=0) */
261 {
262 if (debug)
263@@ -338,14 +345,14 @@
264 if (!c_arr[i].hard) /* if considering idle time */
265 {
266 if (debug)
267- printf("Subject to logout Idle time: %4d (%2d allowed)\n",idle,ce->idle);
268+ printf("Subject to logout Idle time: %4ld (%2d allowed)\n",idle,ce->idle);
269 if (idle < ce->idle) /* if user was recently active */
270 return(0); /* let it live */
271 }
272 else
273 {
274 if (debug)
275- printf("Subject to logout Total time: %4d (%2d allowed)\n",stime,ce->idle);
276+ printf("Subject to logout Total time: %4ld (%2d allowed)\n",stime,ce->idle);
277 if (stime < ce->idle) /* if user still under limit */
278 return(0); /* let it live */
279 }
280@@ -378,7 +385,7 @@
281 return(0);
282 }
283
284-mesg(int flag, char *name, char *dev, int stime, int idle, conf_el *ce)
285+void mesg(int flag, char *name, char *dev, int stime, int idle, conf_el *ce)
286 {
287 char mbuf[LINELEN]; /* message buffer */
288 time_t tvec;
289@@ -417,10 +424,10 @@
290 fprintf(log, "** LOGOFF ** %s %s idle:%d sess:%d %s",name, dev+5, idle, stime, ctime(&tvec)+3);
291 if (ce->mail)
292 {
293- sprintf(mbuf, "/bin/mail %s", name);
294+ sprintf(mbuf, "/usr/sbin/sendmail %s", name);
295 /* open pipe to mail program for writing */
296 if (!(mprog = popen(mbuf, "w")) )
297- bailout("Can't use /bin/mail program", 6);
298+ bailout("Can't use /usr/sbin/sendmail program", 6);
299 fprintf(mprog, "Subject: Excess Idle Time\nLogged off - excess idle time - %s %s\ntty = %s\n",name, ctime(&tvec), dev+5);
300 fclose(mprog);
301 }
302@@ -431,18 +438,18 @@
303 fprintf(log, "** LOGOFF-FAIL ** %s (pid = %d) %s (%d min idle time) %s",name, utmpp->ut_pid, dev+5, idle, ctime(&tvec)+3);
304 if (ce->mail)
305 {
306- sprintf(mbuf, "/bin/mail root");
307+ sprintf(mbuf, "/usr/sbin/sendmail root");
308 if ((mprog = popen(mbuf, "w")) == (FILE *) NULL)
309- bailout("Can't use /bin/mail program", 7);
310+ bailout("Can't use /usr/sbin/sendmail program", 7);
311 fprintf(mprog, "Subject: Can't logoff %s\nCan't Log off - %s %s\ntty = %s\n", name, name, ctime(&tvec), dev+5);
312 fclose(mprog);
313 }
314 }
315- fclose(log);
316- return(0);
317+ if (log)
318+ fclose(log);
319 }
320
321-killit(int pid) /* terminate process using SIGHUP, then SIGKILL */
322+int killit(pid_t pid) /* terminate process using SIGHUP, then SIGKILL */
323 {
324 kill(pid, SIGHUP); /* first send "hangup" signal */
325 sleep(KWAIT);
326@@ -459,8 +466,8 @@
327 return(1); /* successful kill with SIGHUP */
328 }
329
330-bailout(char *message, int status) /* display error message and exit */
331+void bailout(const char *message, int status) /* display error message and exit */
332 {
333- fprintf(stderr,"autologout: %s\n", message);
334+ fprintf(stderr,"autologout: %s (%m)\n", message);
335 exit(status);
336 }
337diff -urN autolog-0.34.orig/autolog.conf.5 autolog-0.34/autolog.conf.5
338--- autolog-0.34.orig/autolog.conf.5 Fri Oct 16 20:38:44 1998
339+++ autolog-0.34/autolog.conf.5 Fri Oct 16 20:39:16 1998
340@@ -1,4 +1,4 @@
341-.TH autolog.conf 1L "Configuration Files" "Linux" \" -*- nroff -*-
342+.TH autolog.conf 5 "Configuration Files" "Linux" \" -*- nroff -*-
343 .SH NAME
344 autolog.conf \- Configuration file for the autolog command
345 .SH DESCRIPTION
346@@ -32,7 +32,7 @@
347 entry which has all values set from the defaults. This entry will match
348 any process on any port (name=.+ line=.+ group=.+). Therefore, the default
349 action is to kill all processes.
350-.SH ENTRYS
351+.SH ENTRIES
352 .TP
353 .B name=
354 A regular expression specifying which username(s) to match.
355diff -urN autolog-0.34.orig/crontab autolog-0.34/crontab
356--- autolog-0.34.orig/crontab Thu Jan 1 01:00:00 1970
357+++ autolog-0.34/crontab Fri Oct 16 20:39:17 1998
358@@ -0,0 +1 @@
359+*/10 * * * * root test -x /usr/sbin/autolog && /usr/sbin/autolog
This page took 1.309457 seconds and 4 git commands to generate.