| 1 |
Please see CHANGES / git history post 0.42. |
| 2 |
|
| 3 |
Autolog 0.42 |
| 4 |
|
| 5 |
James Dingwall <[email protected]> as maintainer |
| 6 |
|
| 7 |
Autolog 0.41 |
| 8 |
|
| 9 |
The source was investigated after examining issues which occurred when |
| 10 |
accounts with long usernames (nss_winbind DOMAIN\user) would cause |
| 11 |
autolog to segfault. This revealed two key issues: |
| 12 |
|
| 13 |
- userdata string length < UT_NAMESIZE |
| 14 |
- ps output with truncated usernames did not match pids |
| 15 |
|
| 16 |
This revision updates string handling functions to use suitable 'n' |
| 17 |
variants, makes user and terminal variables use UT_NAMESIZE and |
| 18 |
UT_LINESIZE, changes the default ps command to output usernames to |
| 19 |
32 characters to match UT_NAMESIZE; |
| 20 |
|
| 21 |
Autolog 0.40 |
| 22 |
|
| 23 |
Autolog is a new version of autolog by Kyle Bateman ([email protected]), |
| 24 |
modified by me (Carsten Juerges, [email protected]) to |
| 25 |
get the logout-warning on that terminal I worked in, last time. |
| 26 |
Before the warning was written on the login-screen, where I |
| 27 |
started X (startx), so it was difficult to get or to react on |
| 28 |
this warning. |
| 29 |
|
| 30 |
Now it is checked, which is the terminal with the shortest idle-time |
| 31 |
and the message is displayed there. So I can react on it, there. |
| 32 |
|
| 33 |
I put the old readme-text below the (=====)-line and added my changes |
| 34 |
(of details) into that text. They can be found by searching for "##". |
| 35 |
|
| 36 |
Here I just want to report about a few changes, I added to the program. |
| 37 |
|
| 38 |
- first of all: |
| 39 |
This program can run in daemon-mode or as "ordinary program". |
| 40 |
As ordinary program it writes "/tmp/autolog.data" when starting. |
| 41 |
|
| 42 |
So it is not necessary to keep the program in memory to |
| 43 |
chase sleeping users. As this file is read, when the |
| 44 |
program starts. If this file doesn't exist, no problem. |
| 45 |
It will be generated next time. |
| 46 |
|
| 47 |
See the options. |
| 48 |
|
| 49 |
If running as daemon, make sure, you don't start it |
| 50 |
several times e.g. by crontab. |
| 51 |
|
| 52 |
If running as ordinary program, it will stay at least |
| 53 |
as long in memory until all necessary kickouts are done. |
| 54 |
And some more time to make sure, user doesn't return |
| 55 |
2 minutes later. (Until als bans are over.) |
| 56 |
|
| 57 |
- if a user logs out, before his session-limit is reached, his limit |
| 58 |
will be reset. It was also possible to log in again, after being |
| 59 |
kicked out. |
| 60 |
-> fixed this. added a ban-time. (##-1) |
| 61 |
the session-limit will be reset when the banning |
| 62 |
has passed or a bit later, depends on when the |
| 63 |
daemon wakes up from sleeping. |
| 64 |
|
| 65 |
-> added little feature that kills forgotten processes. |
| 66 |
they do appear (e.g. netscape) when a user does not |
| 67 |
terminate netscape correctly. |
| 68 |
|
| 69 |
-> daemon tries to wake up a sleeping user by beeping. |
| 70 |
the user also gets an email, his beeping might not work. |
| 71 |
Email might not work on a network, don't know, could |
| 72 |
only test this on one network, there it worked. |
| 73 |
|
| 74 |
-> being idle for too long is punished with 2 Mins ban. |
| 75 |
Users should not be punished for being idle they |
| 76 |
might be thinking about the current problem. They |
| 77 |
deserve a little break. |
| 78 |
These two minutes should only stop those user who |
| 79 |
log in again and again to block the computer. |
| 80 |
|
| 81 |
-> if the user tries to login before his ban-time ends, |
| 82 |
he will be kicked out without any warning. He will |
| 83 |
be banned for the originial ban-period, again :) |
| 84 |
|
| 85 |
-> changed the "exempt-code" to idle=-1, so idle=0 |
| 86 |
will be useful for demonstration-purpose. |
| 87 |
|
| 88 |
-> the information about crontab (down in the text) |
| 89 |
has expired, if running this program as daemon. |
| 90 |
left it, because i find the hints about crontabs |
| 91 |
quite useful. |
| 92 |
|
| 93 |
Maybe it is useful to restart the program from time |
| 94 |
to time as it might have halted due to any errors. |
| 95 |
(via cron) |
| 96 |
|
| 97 |
The program should only run once on a machine. Otherwise |
| 98 |
the resulting user-information about being kicked out |
| 99 |
it might be confusing. |
| 100 |
|
| 101 |
-> Make sure to reduce the size of the log-file from time |
| 102 |
to time, as it is always growing when adding messages. |
| 103 |
The logile or at least a part of it might be useful |
| 104 |
to find misconfiguration or even bugs in the program. |
| 105 |
|
| 106 |
|
| 107 |
======================================================================= |
| 108 |
|
| 109 |
|
| 110 |
Autolog 0.35 |
| 111 |
|
| 112 |
Autolog is a version of autologout (idleout-mcm) modified by me to allow |
| 113 |
a more detailed configuration file, and to accept command line parameters. |
| 114 |
According to David Dickson, the code originally came from the "Wizard's |
| 115 |
Grabbag" from the May 1990 Unix World. He ported the code essentially |
| 116 |
unchanged. |
| 117 |
|
| 118 |
Mike Mitchell added some code to read a file "/etc/autologout.exempt" |
| 119 |
listing those users which should not be subject to auto logout. |
| 120 |
|
| 121 |
My system required a little more complex approach. I wanted some |
| 122 |
users to be logged off more aggressively than others. I wanted my own |
| 123 |
sessions to remain on line only if they existed on certain ports. |
| 124 |
I also wanted users coming in over the net to be subject to a little |
| 125 |
different idle time than other users. |
| 126 |
|
| 127 |
After doing version 0.20, several people wrote with various additions |
| 128 |
and patches. The problem was that the original syntax of the autolog.conf |
| 129 |
file was a bit limiting and it was hard to work in too many additional |
| 130 |
features without making a big fat mess. With the new, improved format |
| 131 |
of the configuration file, I should be able to accommodate many more |
| 132 |
future features. |
| 133 |
|
| 134 |
The configuration file consists of multiple lines, each of which describes |
| 135 |
a class of processes subject (or not subject) to a certain auto logout |
| 136 |
procedure. A line consists of any number of switches. Value switches are |
| 137 |
of the form: "name=value". Boolean switches are of the form: "name" or |
| 138 |
"noname". Here are some example lines: |
| 139 |
|
| 140 |
name=root line=tty[1-7] idle=0 |
| 141 |
name=guest idle=5 grace=60 nomail hard warn |
| 142 |
group=lynx-.* idle=10 grace=60 clear |
| 143 |
idle=60 grace=30 |
| 144 |
|
| 145 |
Using these switches, you can define a username, a group, and a tty line. |
| 146 |
These descriptions can contain wildcard characters (regular expressions). |
| 147 |
You can also define an idle time, a grace period and a few other options. |
| 148 |
When reading the configuration file, the program creates a record for each |
| 149 |
configuration line. A value is assigned to each variable in the record |
| 150 |
regardless of whether or not you specify one explicitly. Values for |
| 151 |
missing variables are provided by defaults which are compiled in and can |
| 152 |
be modified from the command line. |
| 153 |
|
| 154 |
If no configuration file is found, the program will create a single |
| 155 |
entry which has all values set from the defaults. This entry will match |
| 156 |
any process on any port (name=.+ line=.+ group=.+). Therefore, the default |
| 157 |
action is to kill all processes. |
| 158 |
|
| 159 |
The values which can be set for each entry are as follows: |
| 160 |
|
| 161 |
name= |
| 162 |
A regular expression specifying which username(s) to match. |
| 163 |
group= |
| 164 |
A regular expression specifying which group(s) to match. |
| 165 |
line= |
| 166 |
A regular expression specifying which tty line(s) to match. |
| 167 |
Omit the "/dev/" part of the special name. |
| 168 |
idle= |
| 169 |
An integer specifying the number of --minutes-- of idle |
| 170 |
(or connect) time to allow before beginning automatic logoff. |
| 171 |
An idle time of 0 exempts the process from automatic logoff. |
| 172 |
(##) changed this to "-1" => exempts idle-time. |
| 173 |
this allows short idle-time "0" for demonstrating. |
| 174 |
grace= |
| 175 |
An integer specifying the number of --seconds-- from the initial |
| 176 |
warning to killing the process. |
| 177 |
ban= |
| 178 |
An integer specifying the number of --minutes--, the user |
| 179 |
should stay away after exceeding his session-limit. (##-1) |
| 180 |
hard |
| 181 |
A boolean value indicating total connect time will be |
| 182 |
considered rather than idle time. |
| 183 |
mail |
| 184 |
A boolean value indicating that mail will be sent to the |
| 185 |
user explaining that he was killed. |
| 186 |
clear |
| 187 |
A boolean value indicating that the screen will be cleared |
| 188 |
before a warning message is sent. (##) |
| 189 |
-> will only be cleared, if user is still on that screen. |
| 190 |
warn |
| 191 |
A boolean value indicating that a warning message will be |
| 192 |
sent at the beginning of the "grace" period. |
| 193 |
log |
| 194 |
A boolean value indicating that activities will be logged |
| 195 |
to the logfile (if it exists). |
| 196 |
|
| 197 |
Additionally I added a feature for exotic ps-versions: |
| 198 |
|
| 199 |
ps=ps -ef |
| 200 |
a ps-command, which results in one heading line |
| 201 |
and lines starting with username and pid |
| 202 |
e.g. "ps=ps aux" on SuSE Linux. |
| 203 |
|
| 204 |
lostkill |
| 205 |
A boolean value indicatin whether this program should |
| 206 |
kill lost processes or not. So place "nolostkill" in |
| 207 |
the config-file doesn't touch them. |
| 208 |
If enabled(default), this program will only kill lost |
| 209 |
processes with uid between 500 and 60000. Other uids |
| 210 |
(at least in some Linux dialects) belong to system |
| 211 |
processes which should not be killed. |
| 212 |
|
| 213 |
Once configured, the program reads the utmp file, entry by entry. The |
| 214 |
username for each 'user process' is compared to the entries in the |
| 215 |
configuration file. The first entry to match both the name, the group, |
| 216 |
and the tty line of the process will be used to conduct the automatic |
| 217 |
logout. |
| 218 |
|
| 219 |
If no entries are found matching a given process, that process will be |
| 220 |
spared from an untimely demise. Therefore, it is a good idea to always |
| 221 |
have a "cleanup" line at the end of the configuration file to catch |
| 222 |
anything that might have been missed by the more explicit definitions. |
| 223 |
Since the default name, group, and line are all ".+", a simple line like: |
| 224 |
|
| 225 |
idle=30 |
| 226 |
|
| 227 |
will do. Actually, any one switch can be specified on the line and all the |
| 228 |
others will get the default values. |
| 229 |
|
| 230 |
See the sample file autolog.conf for an example configuration. |
| 231 |
|
| 232 |
Installation Instructions: |
| 233 |
|
| 234 |
1. If desired, edit the defaults in autolog.c such as |
| 235 |
D_IDLE, D_GRACE, D_MAIL, etc. (This is generally not |
| 236 |
necessary). |
| 237 |
|
| 238 |
If you want the binary to land somewhere besides |
| 239 |
/usr/sbin, edit the Makefile accordingly. |
| 240 |
|
| 241 |
2. Type 'make install'. |
| 242 |
|
| 243 |
3. Copy autolog.conf to /etc and then edit it to make the |
| 244 |
changes needed by your system. (See the instructions |
| 245 |
above.) |
| 246 |
|
| 247 |
4. Wait until the system has a bunch of idle processes. |
| 248 |
Run "autolog -d -n |less" and examine the output to see |
| 249 |
that the desired processes are going to "get the axe." |
| 250 |
If it looks good, try running "autolog -d" to make sure. |
| 251 |
When you're happy with your configuration file, setup cron. |
| 252 |
|
| 253 |
5. In your Crontab file place a line that invokes |
| 254 |
autolog about every few minutes, such as: |
| 255 |
|
| 256 |
0,10,20,30,40,50 * * * * /usr/sbin/autolog |
| 257 |
|
| 258 |
On my system cron only runs the process at night. |
| 259 |
This way, users sessions stay on uninterrupted during the |
| 260 |
workday. I use the lines: |
| 261 |
|
| 262 |
0 20 * * * /usr/sbin/autolog |
| 263 |
0 22 * * * /usr/sbin/autolog |
| 264 |
0 1 * * * /usr/sbin/autolog |
| 265 |
|
| 266 |
|
| 267 |
COMMAND LINE PARAMETERS: |
| 268 |
|
| 269 |
-a (all processes) Print information on ALL utmp entries--not just |
| 270 |
user processes. |
| 271 |
|
| 272 |
-d (debug mode) This is helpful in setting up your configuration file. |
| 273 |
The program runs in foreground rather than forking and it prints |
| 274 |
out verbose messages about what it is doing. |
| 275 |
|
| 276 |
-n (nokill) Use this to prevent autolog from actually "killing" |
| 277 |
anyone. Use -d and -n together when setting up a new |
| 278 |
configuration file. |
| 279 |
|
| 280 |
-o (ordinary) Use this to start the program as ordinary |
| 281 |
program. Otherwise it will stay as daemon in memory. |
| 282 |
Good idea if you are low on memory. |
| 283 |
|
| 284 |
-f config_file_name |
| 285 |
Use this to override the default: "/etc/autolog.conf" |
| 286 |
|
| 287 |
-l log_file_name |
| 288 |
Use this to override the default: "/var/log/autolog.log" |
| 289 |
|
| 290 |
Note that if this file doesn't exist, no logging will happen. |
| 291 |
Create the file (with touch) to enable logging. |
| 292 |
|
| 293 |
-t idle_time |
| 294 |
Use this to override the internal default idle time (minutes) |
| 295 |
|
| 296 |
-g grace_period |
| 297 |
Use this to override the internal default grace period (seconds) |
| 298 |
|
| 299 |
-m yes/no |
| 300 |
Use this to override the internal mailing switch. If "yes" |
| 301 |
the program will send mail to the users right after killing them. |
| 302 |
|
| 303 |
-c yes/no |
| 304 |
Use this to override the internal "pre-clear" switch. If "yes" |
| 305 |
the program will clear the terminal screen before warning the user. |
| 306 |
|
| 307 |
-w yes/no |
| 308 |
If set to "no" no warning message will be printed to processes |
| 309 |
about to be killed. |
| 310 |
|
| 311 |
-h yes/no |
| 312 |
Do timeouts based on total session time--not idle time. (hard) |
| 313 |
|
| 314 |
-L yes/no |
| 315 |
If set to "yes" activities will be written to the logfile if |
| 316 |
present. |
| 317 |
|
| 318 |
|
| 319 |
Bugs/Caveats: |
| 320 |
- The utmp file seems to only hold 8 characters worth of login name. |
| 321 |
If your login name is shorter than this, note that autolog may only |
| 322 |
see the first 8 characters. This is screwing up the group search |
| 323 |
function too. This shouldn't be too hard to fix. I'll |
| 324 |
just have to derive the real login name from the pid or something... |
| 325 |
|
| 326 |
- There is a feature that would be very helpful that autolog doesn't have |
| 327 |
yet. The ppp program generally creates a login process which is seen |
| 328 |
by autolog. The problem is that network activity does not change the |
| 329 |
idle time on the tty controlled by ppp. So there is no way (with the |
| 330 |
existing code) for autolog to know if the network link has gone idle for |
| 331 |
a period of time (it appears idle all the time--no matter what happens. |
| 332 |
|
| 333 |
So your choices are this: You can leave ppp out of your |
| 334 |
"autolog strategy" in which case it will look like an idle shell and will |
| 335 |
get killed. Or, you can put it in the configuration file with an |
| 336 |
exemption (idle=0) in which case it will never get killed no matter what. |
| 337 |
|
| 338 |
If someone knows where I can snoop in the OS (in a portable way) to find |
| 339 |
out how long its been since a ppp login passed any network traffic, I |
| 340 |
would add a ppp switch to be used for this purpose. |
| 341 |
|
| 342 |
- When this program get to another system, it sometime needs |
| 343 |
to be recompiled. I compiled it in SuSE 6.3 and running under |
| 344 |
SuSE 6.0 it gave a "segmentation fault" without recompiling. |
| 345 |
|
| 346 |
|
| 347 |
Ideas: |
| 348 |
- One might find out, how the "you have new mail"-message gets |
| 349 |
to the user and try to use this way for letting the user know |
| 350 |
about his coming end. |
| 351 |
- One might think about a pop-up box when running a session |
| 352 |
without any terminals. At the moment this program tries to |
| 353 |
send an email to the user. If one selects enough idle-time, |
| 354 |
this should be ok. |
| 355 |
- Maybe it is possible when this deamon starts sleeping, it |
| 356 |
actually terminates and gets started again after some time. |
| 357 |
This might save some memory when sleeping or sleeping for more |
| 358 |
than 5 Minutes. I assume, other deamons behave like this, too, |
| 359 |
but I don't know how... |
| 360 |
|
| 361 |
|
| 362 |
Have fun knocking off those 'delinquent' users! And don't let the power |
| 363 |
go to your head... |
| 364 |
|
| 365 |
Kyle Bateman |
| 366 |
[email protected] |
| 367 |
|
| 368 |
Be careful when playing with a daemon. Devils like |
| 369 |
playing, but only they know all rules of their games! |
| 370 |
A game, plaid with a devil becomes the devil's game. |
| 371 |
|
| 372 |
Users should be informed about such a program running. |
| 373 |
Especially users, which are kicked off without warning |
| 374 |
might get very angry when losing several hours of work. |
| 375 |
Keep in mind, some are running jobs over several hours. |
| 376 |
|
| 377 |
Carsten Juerges |
| 378 |
[email protected] |
| 379 |
|
| 380 |
|
| 381 |
p.s. quoting a part of "man strtok" |
| 382 |
> BUGS Never use this function. This function modifies ... |