home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / unix / volume07 / idleusrs < prev    next >
SHell self-extracting ARchive  |  1988-09-11  |  7.6 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: SHell self-extracting ARchive (archive/shar).

You can browse this item here: idleusrs

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file C source, ASCII text default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/rfc822 default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 53 75 62 6a 65 63 74 3a | 20 20 76 30 37 69 30 38 |Subject:| v07i08|
|00000010| 39 3a 20 20 41 20 73 69 | 6d 70 6c 65 20 42 53 44 |9: A si|mple BSD|
|00000020| 20 69 64 6c 65 2d 75 73 | 65 72 73 20 64 61 65 6d | idle-us|ers daem|
|00000030| 6f 6e 0a 4e 65 77 73 67 | 72 6f 75 70 73 3a 20 6d |on.Newsg|roups: m|
|00000040| 6f 64 2e 73 6f 75 72 63 | 65 73 0a 41 70 70 72 6f |od.sourc|es.Appro|
|00000050| 76 65 64 3a 20 6d 69 72 | 72 6f 72 21 72 73 0a 0a |ved: mir|ror!rs..|
|00000060| 53 75 62 6d 69 74 74 65 | 64 20 62 79 3a 20 73 65 |Submitte|d by: se|
|00000070| 69 73 6d 6f 21 65 72 69 | 78 21 6d 69 6b 65 20 28 |ismo!eri|x!mike (|
|00000080| 4d 69 6b 65 20 57 69 6c | 6c 69 61 6d 73 29 0a 4d |Mike Wil|liams).M|
|00000090| 6f 64 2e 73 6f 75 72 63 | 65 73 3a 20 56 6f 6c 75 |od.sourc|es: Volu|
|000000a0| 6d 65 20 37 2c 20 49 73 | 73 75 65 20 38 39 0a 41 |me 7, Is|sue 89.A|
|000000b0| 72 63 68 69 76 65 2d 6e | 61 6d 65 3a 20 69 64 6c |rchive-n|ame: idl|
|000000c0| 65 2e 75 73 65 72 73 0a | 0a 44 65 61 72 20 4d 6f |e.users.|.Dear Mo|
|000000d0| 64 65 72 61 74 6f 72 2c | 0a 0a 50 6c 65 61 73 65 |derator,|..Please|
|000000e0| 20 66 69 6e 64 20 77 69 | 74 68 69 6e 20 74 68 65 | find wi|thin the|
|000000f0| 20 73 6f 75 72 63 65 20 | 63 6f 64 65 20 66 6f 72 | source |code for|
|00000100| 20 61 20 64 61 65 6d 6f | 6e 20 49 20 68 61 76 65 | a daemo|n I have|
|00000110| 20 62 65 65 6e 20 72 75 | 6e 6e 69 6e 67 20 66 6f | been ru|nning fo|
|00000120| 72 0a 6d 6f 72 65 20 74 | 68 61 6e 20 36 20 6d 6f |r.more t|han 6 mo|
|00000130| 6e 74 68 73 20 77 69 74 | 68 6f 75 74 20 70 72 6f |nths wit|hout pro|
|00000140| 62 6c 65 6d 73 20 6f 6e | 20 6f 75 72 20 34 2e 32 |blems on| our 4.2|
|00000150| 42 53 44 20 73 79 73 74 | 65 6d 2e 20 49 74 20 73 |BSD syst|em. It s|
|00000160| 69 6d 70 6c 79 0a 6c 6f | 67 73 20 6f 66 66 20 69 |imply.lo|gs off i|
|00000170| 64 6c 65 20 75 73 65 72 | 73 20 61 66 65 72 20 67 |dle user|s afer g|
|00000180| 69 76 69 6e 67 20 74 68 | 65 6d 20 66 61 69 72 20 |iving th|em fair |
|00000190| 77 61 72 6e 69 6e 67 2e | 20 53 65 65 20 63 6f 6d |warning.| See com|
|000001a0| 6d 65 6e 74 73 20 61 74 | 20 74 68 65 0a 73 74 61 |ments at| the.sta|
|000001b0| 72 74 20 6f 66 20 74 68 | 65 20 63 6f 64 65 20 66 |rt of th|e code f|
|000001c0| 6f 72 20 6d 6f 72 65 20 | 64 65 74 61 69 6c 73 2e |or more |details.|
|000001d0| 0a 0a 49 20 77 72 6f 74 | 65 20 74 68 69 73 20 74 |..I wrot|e this t|
|000001e0| 68 69 6e 67 20 61 66 74 | 65 72 20 49 20 6e 6f 74 |hing aft|er I not|
|000001f0| 69 63 65 64 20 74 68 65 | 20 73 6f 6d 65 20 75 73 |iced the| some us|
|00000200| 65 72 73 20 6e 65 76 65 | 72 20 6c 6f 67 67 65 64 |ers neve|r logged|
|00000210| 20 6f 66 66 2e 20 20 49 | 0a 68 61 76 65 20 73 65 | off. I|.have se|
|00000220| 65 6e 20 73 69 6d 69 6c | 61 72 20 74 68 69 6e 67 |en simil|ar thing|
|00000230| 73 20 6f 6e 20 74 68 65 | 20 6e 65 74 20 62 65 66 |s on the| net bef|
|00000240| 6f 72 65 2c 20 62 75 74 | 20 74 68 65 79 20 61 6c |ore, but| they al|
|00000250| 6c 20 73 65 65 6d 65 64 | 20 72 61 74 68 65 72 0a |l seemed| rather.|
|00000260| 63 6f 6d 70 6c 69 63 61 | 74 65 64 2c 20 77 68 65 |complica|ted, whe|
|00000270| 72 65 61 73 20 74 68 69 | 73 20 74 68 69 6e 67 20 |reas thi|s thing |
|00000280| 69 73 20 76 65 72 79 20 | 73 69 6d 70 6c 65 20 61 |is very |simple a|
|00000290| 6e 64 20 65 61 73 79 20 | 74 6f 20 75 73 65 20 61 |nd easy |to use a|
|000002a0| 6e 64 0a 63 6f 6e 66 69 | 67 75 72 65 2e 20 20 4d |nd.confi|gure. M|
|000002b0| 61 79 62 65 20 74 68 65 | 20 63 6f 6e 66 69 67 20 |aybe the| config |
|000002c0| 64 61 74 61 20 73 68 6f | 75 6c 64 20 62 65 20 72 |data sho|uld be r|
|000002d0| 65 61 64 20 66 72 6f 6d | 20 61 20 66 69 6c 65 2c |ead from| a file,|
|000002e0| 20 49 20 74 68 6f 75 67 | 68 74 0a 6f 66 20 74 68 | I thoug|ht.of th|
|000002f0| 69 73 20 62 75 74 20 66 | 65 6c 74 20 74 68 61 74 |is but f|elt that|
|00000300| 20 74 68 65 20 74 68 69 | 6e 67 20 69 73 20 73 6f | the thi|ng is so|
|00000310| 20 73 65 6c 64 6f 6d 20 | 72 65 63 6f 6e 66 69 67 | seldom |reconfig|
|00000320| 75 72 65 64 20 74 68 61 | 74 20 74 68 69 73 0a 73 |ured tha|t this.s|
|00000330| 65 65 6d 65 64 20 75 6e | 65 63 65 73 73 61 72 79 |eemed un|ecessary|
|00000340| 2e 20 48 61 76 65 20 6e | 6f 74 20 70 75 74 20 69 |. Have n|ot put i|
|00000350| 6e 20 61 6e 79 20 63 6f | 6d 6d 65 6e 74 73 20 61 |n any co|mments a|
|00000360| 62 6f 75 74 20 74 68 69 | 73 20 62 65 69 6e 67 20 |bout thi|s being |
|00000370| 70 75 62 6c 69 63 0a 64 | 6f 6d 61 69 6e 20 65 74 |public.d|omain et|
|00000380| 63 2c 20 62 75 74 20 6f | 66 20 63 6f 75 72 73 65 |c, but o|f course|
|00000390| 20 61 6e 79 6f 6e 65 20 | 63 61 6e 20 75 73 65 20 | anyone |can use |
|000003a0| 74 68 69 73 20 65 78 61 | 63 74 6c 79 20 61 73 20 |this exa|ctly as |
|000003b0| 74 68 65 79 20 77 61 6e | 74 20 61 73 0a 66 61 72 |they wan|t as.far|
|000003c0| 20 61 73 20 49 20 61 6d | 20 63 6f 6e 63 65 72 6e | as I am| concern|
|000003d0| 65 64 2e 0a 0a 4d 69 6b | 65 20 57 69 6c 6c 69 61 |ed...Mik|e Willia|
|000003e0| 6d 73 20 28 6d 69 6b 65 | 40 65 72 69 78 2e 55 55 |ms (mike|@erix.UU|
|000003f0| 43 50 20 6f 72 20 2e 2e | 2e 6d 63 76 61 78 21 65 |CP or ..|.mcvax!e|
|00000400| 6e 65 61 21 65 72 69 78 | 21 6d 69 6b 65 29 0a 0a |nea!erix|!mike)..|
|00000410| 23 21 20 2f 62 69 6e 2f | 73 68 0a 23 20 54 68 69 |#! /bin/|sh.# Thi|
|00000420| 73 20 69 73 20 61 20 73 | 68 65 6c 6c 20 61 72 63 |s is a s|hell arc|
|00000430| 68 69 76 65 2e 20 20 52 | 65 6d 6f 76 65 20 61 6e |hive. R|emove an|
|00000440| 79 74 68 69 6e 67 20 62 | 65 66 6f 72 65 20 74 68 |ything b|efore th|
|00000450| 69 73 20 6c 69 6e 65 2c | 0a 23 20 74 68 65 6e 20 |is line,|.# then |
|00000460| 75 6e 70 61 63 6b 20 69 | 74 20 62 79 20 73 61 76 |unpack i|t by sav|
|00000470| 69 6e 67 20 69 74 20 69 | 6e 20 61 20 66 69 6c 65 |ing it i|n a file|
|00000480| 20 61 6e 64 20 74 79 70 | 69 6e 67 20 22 73 68 20 | and typ|ing "sh |
|00000490| 66 69 6c 65 22 2e 0a 23 | 20 49 66 20 61 6c 6c 20 |file"..#| If all |
|000004a0| 67 6f 65 73 20 77 65 6c | 6c 2c 20 79 6f 75 20 77 |goes wel|l, you w|
|000004b0| 69 6c 6c 20 73 65 65 20 | 74 68 65 20 6d 65 73 73 |ill see |the mess|
|000004c0| 61 67 65 20 22 45 6e 64 | 20 6f 66 20 73 68 65 6c |age "End| of shel|
|000004d0| 6c 20 61 72 63 68 69 76 | 65 2e 22 0a 23 20 43 6f |l archiv|e.".# Co|
|000004e0| 6e 74 65 6e 74 73 3a 20 | 20 4d 61 6b 65 66 69 6c |ntents: | Makefil|
|000004f0| 65 20 69 64 65 6c 2e 63 | 0a 50 41 54 48 3d 2f 62 |e idel.c|.PATH=/b|
|00000500| 69 6e 3a 2f 75 73 72 2f | 62 69 6e 3a 2f 75 73 72 |in:/usr/|bin:/usr|
|00000510| 2f 75 63 62 3b 20 65 78 | 70 6f 72 74 20 50 41 54 |/ucb; ex|port PAT|
|00000520| 48 0a 65 63 68 6f 20 73 | 68 61 72 3a 20 65 78 74 |H.echo s|har: ext|
|00000530| 72 61 63 74 69 6e 67 20 | 22 27 4d 61 6b 65 66 69 |racting |"'Makefi|
|00000540| 6c 65 27 22 20 27 28 34 | 36 20 63 68 61 72 61 63 |le'" '(4|6 charac|
|00000550| 74 65 72 73 29 27 0a 69 | 66 20 74 65 73 74 20 2d |ters)'.i|f test -|
|00000560| 66 20 27 4d 61 6b 65 66 | 69 6c 65 27 20 3b 20 74 |f 'Makef|ile' ; t|
|00000570| 68 65 6e 20 0a 20 20 65 | 63 68 6f 20 73 68 61 72 |hen . e|cho shar|
|00000580| 3a 20 77 69 6c 6c 20 6e | 6f 74 20 6f 76 65 72 2d |: will n|ot over-|
|00000590| 77 72 69 74 65 20 65 78 | 69 73 74 69 6e 67 20 66 |write ex|isting f|
|000005a0| 69 6c 65 20 22 27 4d 61 | 6b 65 66 69 6c 65 27 22 |ile "'Ma|kefile'"|
|000005b0| 0a 65 6c 73 65 0a 73 65 | 64 20 27 73 2f 5e 58 2f |.else.se|d 's/^X/|
|000005c0| 2f 27 20 3e 4d 61 6b 65 | 66 69 6c 65 20 3c 3c 27 |/' >Make|file <<'|
|000005d0| 40 2f 2f 45 2a 4f 2a 46 | 20 4d 61 6b 65 66 69 6c |@//E*O*F| Makefil|
|000005e0| 65 2f 2f 27 0a 58 0a 58 | 69 64 65 6c 3a 09 69 64 |e//'.X.X|idel:.id|
|000005f0| 65 6c 2e 63 0a 58 09 24 | 28 43 43 29 20 24 28 43 |el.c.X.$|(CC) $(C|
|00000600| 46 4c 41 47 53 29 20 2d | 6f 20 69 64 65 6c 20 69 |FLAGS) -|o idel i|
|00000610| 64 65 6c 2e 63 0a 40 2f | 2f 45 2a 4f 2a 46 20 4d |del.c.@/|/E*O*F M|
|00000620| 61 6b 65 66 69 6c 65 2f | 2f 0a 69 66 20 74 65 73 |akefile/|/.if tes|
|00000630| 74 20 34 36 20 2d 6e 65 | 20 22 60 77 63 20 2d 63 |t 46 -ne| "`wc -c|
|00000640| 20 3c 27 4d 61 6b 65 66 | 69 6c 65 27 60 22 3b 20 | <'Makef|ile'`"; |
|00000650| 74 68 65 6e 0a 20 20 20 | 20 65 63 68 6f 20 73 68 |then. | echo sh|
|00000660| 61 72 3a 20 65 72 72 6f | 72 20 74 72 61 6e 73 6d |ar: erro|r transm|
|00000670| 69 74 74 69 6e 67 20 22 | 27 4d 61 6b 65 66 69 6c |itting "|'Makefil|
|00000680| 65 27 22 20 27 28 73 68 | 6f 75 6c 64 20 68 61 76 |e'" '(sh|ould hav|
|00000690| 65 20 62 65 65 6e 20 34 | 36 20 63 68 61 72 61 63 |e been 4|6 charac|
|000006a0| 74 65 72 73 29 27 0a 66 | 69 0a 66 69 20 23 20 65 |ters)'.f|i.fi # e|
|000006b0| 6e 64 20 6f 66 20 6f 76 | 65 72 77 72 69 74 69 6e |nd of ov|erwritin|
|000006c0| 67 20 63 68 65 63 6b 0a | 65 63 68 6f 20 73 68 61 |g check.|echo sha|
|000006d0| 72 3a 20 65 78 74 72 61 | 63 74 69 6e 67 20 22 27 |r: extra|cting "'|
|000006e0| 69 64 65 6c 2e 63 27 22 | 20 27 28 35 34 34 38 20 |idel.c'"| '(5448 |
|000006f0| 63 68 61 72 61 63 74 65 | 72 73 29 27 0a 69 66 20 |characte|rs)'.if |
|00000700| 74 65 73 74 20 2d 66 20 | 27 69 64 65 6c 2e 63 27 |test -f |'idel.c'|
|00000710| 20 3b 20 74 68 65 6e 20 | 0a 20 20 65 63 68 6f 20 | ; then |. echo |
|00000720| 73 68 61 72 3a 20 77 69 | 6c 6c 20 6e 6f 74 20 6f |shar: wi|ll not o|
|00000730| 76 65 72 2d 77 72 69 74 | 65 20 65 78 69 73 74 69 |ver-writ|e existi|
|00000740| 6e 67 20 66 69 6c 65 20 | 22 27 69 64 65 6c 2e 63 |ng file |"'idel.c|
|00000750| 27 22 0a 65 6c 73 65 0a | 73 65 64 20 27 73 2f 5e |'".else.|sed 's/^|
|00000760| 58 2f 2f 27 20 3e 69 64 | 65 6c 2e 63 20 3c 3c 27 |X//' >id|el.c <<'|
|00000770| 40 2f 2f 45 2a 4f 2a 46 | 20 69 64 65 6c 2e 63 2f |@//E*O*F| idel.c/|
|00000780| 2f 27 0a 58 2f 2a 20 69 | 64 6c 65 73 20 64 65 61 |/'.X/* i|dles dea|
|00000790| 6d 6f 6e 20 2d 20 6b 69 | 6c 6c 73 20 6f 66 66 20 |mon - ki|lls off |
|000007a0| 75 73 65 72 73 20 77 68 | 6f 20 68 61 76 65 20 6e |users wh|o have n|
|000007b0| 6f 74 20 75 73 65 64 20 | 74 68 65 69 72 20 74 65 |ot used |their te|
|000007c0| 72 6d 69 6e 61 6c 73 20 | 66 6f 72 0a 58 20 2a 20 |rminals |for.X * |
|000007d0| 61 20 73 70 65 63 69 66 | 69 65 64 20 74 69 6d 65 |a specif|ied time|
|000007e0| 2e 0a 58 20 2a 20 54 65 | 73 74 65 64 20 61 6e 64 |..X * Te|sted and|
|000007f0| 20 72 75 6e 20 66 6f 72 | 20 36 20 6d 6f 6e 74 68 | run for| 6 month|
|00000800| 20 6f 6e 20 34 2e 32 20 | 42 53 44 20 61 74 20 73 | on 4.2 |BSD at s|
|00000810| 69 74 65 20 45 72 69 78 | 2e 0a 58 20 2a 20 43 68 |ite Erix|..X * Ch|
|00000820| 61 6e 67 65 20 4c 4d 45 | 53 53 41 47 45 2c 20 57 |ange LME|SSAGE, W|
|00000830| 4d 45 53 53 41 47 45 2c | 20 44 41 59 4f 55 59 2c |MESSAGE,| DAYOUY,|
|00000840| 20 4e 49 47 48 54 4f 2c | 20 45 56 45 4e 49 4e 47 | NIGHTO,| EVENING|
|00000850| 2c 20 4d 4f 52 4e 49 4e | 47 20 61 6e 64 20 53 4c |, MORNIN|G and SL|
|00000860| 45 45 50 0a 58 20 2a 20 | 74 6f 20 77 68 61 74 20 |EEP.X * |to what |
|00000870| 79 6f 75 20 77 61 6e 74 | 20 6c 6f 63 61 6c 6c 79 |you want| locally|
|00000880| 20 28 73 65 65 20 63 6f | 6d 6d 65 6e 74 73 20 69 | (see co|mments i|
|00000890| 6e 20 63 6f 64 65 29 20 | 63 6f 6d 70 69 6c 65 20 |n code) |compile |
|000008a0| 61 6e 64 20 72 75 6e 20 | 28 61 73 20 72 6f 6f 74 |and run |(as root|
|000008b0| 29 2e 0a 58 20 2a 20 70 | 72 65 66 65 72 61 62 6c |)..X * p|referabl|
|000008c0| 79 20 73 74 61 72 74 65 | 64 20 69 6e 20 2f 65 74 |y starte|d in /et|
|000008d0| 63 2f 72 63 2e 6c 6f 63 | 61 6c 20 62 79 20 6c 69 |c/rc.loc|al by li|
|000008e0| 6e 65 73 20 73 6f 6d 65 | 74 68 69 6e 67 20 6c 69 |nes some|thing li|
|000008f0| 6b 65 20 74 68 69 73 3a | 0a 58 20 2a 09 69 66 20 |ke this:|.X *.if |
|00000900| 5b 20 2d 66 20 2f 75 73 | 72 2f 6c 6f 63 61 6c 2f |[ -f /us|r/local/|
|00000910| 6c 69 62 2f 69 64 20 5d | 3b 20 74 68 65 6e 0a 58 |lib/id ]|; then.X|
|00000920| 20 2a 09 09 2f 75 73 72 | 2f 6c 6f 63 61 6c 2f 6c | *../usr|/local/l|
|00000930| 69 62 2f 69 64 20 26 20 | 65 63 68 6f 20 2d 6e 20 |ib/id & |echo -n |
|00000940| 27 20 69 64 6c 65 27 09 | 3e 2f 64 65 76 2f 63 6f |' idle'.|>/dev/co|
|00000950| 6e 73 6f 6c 65 0a 58 20 | 2a 09 66 69 0a 58 20 2a |nsole.X |*.fi.X *|
|00000960| 20 77 68 65 6e 20 73 74 | 61 72 74 69 6e 67 20 6c | when st|arting l|
|00000970| 6f 63 61 6c 20 64 61 65 | 6d 6f 6e 73 2e 0a 58 20 |ocal dae|mons..X |
|00000980| 2a 20 54 68 65 20 64 61 | 65 6d 6f 6e 20 77 61 6b |* The da|emon wak|
|00000990| 65 73 20 75 70 20 65 76 | 65 72 79 20 53 4c 45 45 |es up ev|ery SLEE|
|000009a0| 50 20 6d 69 6e 75 74 65 | 73 2c 20 72 65 61 64 73 |P minute|s, reads|
|000009b0| 20 55 54 4d 50 20 61 6e | 64 20 73 74 61 74 73 20 | UTMP an|d stats |
|000009c0| 74 68 65 20 74 65 72 6d | 69 6e 61 6c 73 0a 58 20 |the term|inals.X |
|000009d0| 2a 20 74 6f 20 73 65 65 | 20 69 66 20 77 68 65 6e |* to see| if when|
|000009e0| 20 74 68 65 79 20 77 65 | 72 65 20 6c 61 73 74 20 | they we|re last |
|000009f0| 75 73 65 64 2e 20 41 20 | 77 61 72 6e 69 6e 67 20 |used. A |warning |
|00000a00| 28 57 4d 45 53 53 41 47 | 45 29 20 69 73 20 73 65 |(WMESSAG|E) is se|
|00000a10| 6e 74 20 69 66 20 74 68 | 65 20 0a 58 20 2a 20 74 |nt if th|e .X * t|
|00000a20| 69 6d 65 20 65 6c 61 70 | 73 65 64 20 65 78 63 65 |ime elap|sed exce|
|00000a30| 64 65 73 20 74 69 6d 65 | 20 57 41 52 4e 20 6d 69 |des time| WARN mi|
|00000a40| 6e 75 74 65 73 2e 20 54 | 68 65 20 75 73 65 72 20 |nutes. T|he user |
|00000a50| 69 73 20 6c 6f 67 67 65 | 64 20 6f 75 74 20 61 6e |is logge|d out an|
|00000a60| 64 20 61 20 6d 65 73 73 | 61 67 65 0a 58 20 2a 20 |d a mess|age.X * |
|00000a70| 28 4c 4d 45 53 53 41 47 | 45 29 20 69 73 20 73 65 |(LMESSAG|E) is se|
|00000a80| 6e 74 20 69 66 20 74 68 | 65 20 75 73 65 72 20 68 |nt if th|e user h|
|00000a90| 61 73 20 62 65 65 6e 20 | 69 64 6c 65 20 66 6f 72 |as been |idle for|
|00000aa0| 20 6d 6f 72 65 20 74 68 | 61 6e 20 44 41 59 4f 55 | more th|an DAYOU|
|00000ab0| 54 20 6d 69 6e 75 74 65 | 73 0a 58 20 2a 20 62 65 |T minute|s.X * be|
|00000ac0| 74 77 65 65 6e 20 74 68 | 65 20 68 6f 75 72 73 20 |tween th|e hours |
|00000ad0| 4d 4f 52 4e 49 4e 47 20 | 74 6f 20 45 56 45 4e 49 |MORNING |to EVENI|
|00000ae0| 4e 47 20 6f 72 20 65 6c | 73 65 20 4e 49 47 48 54 |NG or el|se NIGHT|
|00000af0| 4f 20 6d 69 6e 75 74 65 | 73 2e 20 45 72 72 6f 72 |O minute|s. Error|
|00000b00| 20 6d 65 73 73 61 67 65 | 73 0a 58 20 2a 20 61 72 | message|s.X * ar|
|00000b10| 65 20 73 65 6e 74 20 74 | 6f 20 73 79 73 6c 6f 67 |e sent t|o syslog|
|00000b20| 20 4c 4f 47 5f 43 52 49 | 54 2e 20 41 20 6c 6f 67 | LOG_CRI|T. A log|
|00000b30| 20 6f 66 20 75 73 65 72 | 73 20 6c 6f 67 67 65 64 | of user|s logged|
|00000b40| 20 6f 75 74 20 69 73 20 | 73 65 6e 74 20 74 6f 20 | out is |sent to |
|00000b50| 73 79 73 6c 6f 67 0a 58 | 20 2a 20 4c 4f 47 5f 49 |syslog.X| * LOG_I|
|00000b60| 4e 46 4f 2e 20 55 73 65 | 66 75 6c 20 66 6f 72 20 |NFO. Use|ful for |
|00000b70| 64 65 66 65 6e 64 69 6e | 67 20 73 79 73 74 65 6d |defendin|g system|
|00000b80| 20 6d 61 6e 61 67 65 72 | 73 20 66 72 6f 6d 20 69 | manager|s from i|
|00000b90| 72 61 74 65 20 75 73 65 | 72 73 20 77 68 6f 20 64 |rate use|rs who d|
|00000ba0| 6f 20 0a 58 20 2a 20 73 | 6f 6d 65 74 68 69 6e 67 |o .X * s|omething|
|00000bb0| 20 73 74 75 70 69 64 20 | 61 6e 64 20 6c 6f 67 20 | stupid |and log |
|00000bc0| 74 68 65 6d 73 65 6c 76 | 65 73 20 6f 75 74 20 61 |themselv|es out a|
|00000bd0| 6e 64 20 74 68 65 6e 20 | 62 6c 61 6d 65 20 74 68 |nd then |blame th|
|00000be0| 65 20 64 61 65 6d 6f 6e | 21 0a 58 20 2a 2f 0a 58 |e daemon|!.X */.X|
|00000bf0| 23 69 6e 63 6c 75 64 65 | 20 3c 75 74 6d 70 2e 68 |#include| <utmp.h|
|00000c00| 3e 0a 58 23 69 6e 63 6c | 75 64 65 20 3c 73 79 73 |>.X#incl|ude <sys|
|00000c10| 2f 74 79 70 65 73 2e 68 | 3e 0a 58 23 69 6e 63 6c |/types.h|>.X#incl|
|00000c20| 75 64 65 20 3c 73 79 73 | 2f 74 69 6d 65 2e 68 3e |ude <sys|/time.h>|
|00000c30| 0a 58 23 69 6e 63 6c 75 | 64 65 20 3c 73 79 73 2f |.X#inclu|de <sys/|
|00000c40| 73 74 61 74 2e 68 3e 0a | 58 23 69 6e 63 6c 75 64 |stat.h>.|X#includ|
|00000c50| 65 20 3c 73 79 73 2f 66 | 69 6c 65 2e 68 3e 0a 58 |e <sys/f|ile.h>.X|
|00000c60| 23 69 6e 63 6c 75 64 65 | 20 3c 73 67 74 74 79 2e |#include| <sgtty.|
|00000c70| 68 3e 0a 58 23 69 6e 63 | 6c 75 64 65 20 3c 73 79 |h>.X#inc|lude <sy|
|00000c80| 73 6c 6f 67 2e 68 3e 0a | 58 23 69 6e 63 6c 75 64 |slog.h>.|X#includ|
|00000c90| 65 20 3c 73 65 74 6a 6d | 70 2e 68 3e 0a 58 23 69 |e <setjm|p.h>.X#i|
|00000ca0| 6e 63 6c 75 64 65 20 3c | 73 69 67 6e 61 6c 2e 68 |nclude <|signal.h|
|00000cb0| 3e 0a 58 23 69 6e 63 6c | 75 64 65 20 3c 73 74 72 |>.X#incl|ude <str|
|00000cc0| 69 6e 67 73 2e 68 3e 0a | 58 23 64 65 66 69 6e 65 |ings.h>.|X#define|
|00000cd0| 20 55 54 4d 50 20 22 2f | 65 74 63 2f 75 74 6d 70 | UTMP "/|etc/utmp|
|00000ce0| 22 0a 58 23 64 65 66 69 | 6e 65 20 4c 4d 45 53 53 |".X#defi|ne LMESS|
|00000cf0| 41 47 45 20 22 5c 30 30 | 37 5c 30 30 37 5c 72 41 |AGE "\00|7\007\rA|
|00000d00| 75 74 6f 20 6c 6f 67 6f | 75 74 20 2d 20 74 6f 6f |uto logo|ut - too|
|00000d10| 20 6c 6f 6e 67 20 69 64 | 6c 65 20 74 69 6d 65 5c | long id|le time\|
|00000d20| 72 5c 6e 22 0a 58 23 64 | 65 66 69 6e 65 20 57 4d |r\n".X#d|efine WM|
|00000d30| 45 53 53 41 47 45 20 22 | 5c 30 30 37 5c 30 30 37 |ESSAGE "|\007\007|
|00000d40| 5c 72 54 68 65 20 69 64 | 6c 65 20 64 65 61 6d 6f |\rThe id|le deamo|
|00000d50| 6e 20 68 61 73 20 73 70 | 6f 74 74 65 64 20 79 6f |n has sp|otted yo|
|00000d60| 75 5c 72 5c 6e 22 0a 58 | 23 64 65 66 69 6e 65 20 |u\r\n".X|#define |
|00000d70| 44 41 59 4f 55 54 20 34 | 38 30 20 2f 2a 20 6c 6f |DAYOUT 4|80 /* lo|
|00000d80| 67 6f 75 74 20 61 66 74 | 65 72 20 74 68 69 73 20 |gout aft|er this |
|00000d90| 6e 75 6d 62 65 72 20 6f | 66 20 69 64 6c 65 20 6d |number o|f idle m|
|00000da0| 69 6e 75 74 65 73 20 2d | 20 64 61 79 74 69 6d 65 |inutes -| daytime|
|00000db0| 2a 2f 0a 58 23 64 65 66 | 69 6e 65 20 4e 49 47 48 |*/.X#def|ine NIGH|
|00000dc0| 54 4f 20 31 32 30 20 2f | 2a 20 6c 6f 67 6f 75 74 |TO 120 /|* logout|
|00000dd0| 20 61 66 74 65 72 20 74 | 68 69 73 20 6e 75 6d 62 | after t|his numb|
|00000de0| 65 72 20 6f 66 20 69 64 | 6c 65 20 6d 69 6e 75 74 |er of id|le minut|
|00000df0| 65 73 20 2d 20 6e 69 67 | 68 74 69 6d 65 20 2a 2f |es - nig|htime */|
|00000e00| 0a 58 23 64 65 66 69 6e | 65 20 4d 4f 52 4e 49 4e |.X#defin|e MORNIN|
|00000e10| 47 20 37 20 2f 2a 20 73 | 74 61 72 74 20 6f 66 20 |G 7 /* s|tart of |
|00000e20| 64 61 79 74 69 6d 65 20 | 2a 2f 0a 58 23 64 65 66 |daytime |*/.X#def|
|00000e30| 69 6e 65 20 45 56 45 4e | 49 4e 47 20 31 38 20 2f |ine EVEN|ING 18 /|
|00000e40| 2a 20 73 74 61 72 74 20 | 6f 66 20 65 76 65 6e 69 |* start |of eveni|
|00000e50| 6e 67 20 74 69 6d 65 20 | 2a 2f 0a 58 23 64 65 66 |ng time |*/.X#def|
|00000e60| 69 6e 65 20 57 41 52 4e | 20 39 30 20 2f 2a 20 73 |ine WARN| 90 /* s|
|00000e70| 74 61 72 74 20 73 65 6e | 64 69 6e 67 20 77 61 72 |tart sen|ding war|
|00000e80| 6e 69 6e 67 73 20 61 66 | 74 65 72 20 74 68 69 73 |nings af|ter this|
|00000e90| 20 74 69 6d 65 20 2a 2f | 0a 58 23 64 65 66 69 6e | time */|.X#defin|
|00000ea0| 65 20 53 4c 45 45 50 20 | 31 30 20 2f 2a 20 74 69 |e SLEEP |10 /* ti|
|00000eb0| 6d 65 20 28 6d 69 6e 75 | 74 65 73 29 20 62 65 74 |me (minu|tes) bet|
|00000ec0| 77 65 65 6e 20 65 61 63 | 68 20 63 68 65 63 6b 20 |ween eac|h check |
|00000ed0| 2a 2f 0a 58 0a 58 6a 6d | 70 5f 62 75 66 20 65 6e |*/.X.Xjm|p_buf en|
|00000ee0| 76 3b 0a 58 73 74 72 75 | 63 74 20 75 74 6d 70 20 |v;.Xstru|ct utmp |
|00000ef0| 75 74 3b 0a 58 73 74 72 | 75 63 74 20 73 74 61 74 |ut;.Xstr|uct stat|
|00000f00| 20 73 62 75 66 3b 0a 58 | 73 74 72 75 63 74 20 74 | sbuf;.X|struct t|
|00000f10| 69 6d 65 76 61 6c 20 74 | 76 3b 0a 58 73 74 72 75 |imeval t|v;.Xstru|
|00000f20| 63 74 20 74 69 6d 65 7a | 6f 6e 65 20 74 7a 3b 0a |ct timez|one tz;.|
|00000f30| 58 73 74 72 75 63 74 20 | 74 6d 20 2a 6c 74 69 6d |Xstruct |tm *ltim|
|00000f40| 65 3b 0a 58 73 74 72 75 | 63 74 20 73 74 61 74 20 |e;.Xstru|ct stat |
|00000f50| 73 62 75 66 3b 0a 58 6d | 61 69 6e 28 29 0a 58 7b |sbuf;.Xm|ain().X{|
|00000f60| 0a 58 09 69 6e 74 20 66 | 64 2c 20 6d 69 6e 75 74 |.X.int f|d, minut|
|00000f70| 65 73 2c 20 6c 6f 67 6f | 75 74 3b 0a 58 09 63 68 |es, logo|ut;.X.ch|
|00000f80| 61 72 20 66 6e 61 6d 65 | 5b 31 32 5d 3b 0a 58 23 |ar fname|[12];.X#|
|00000f90| 69 66 6e 64 65 66 20 44 | 45 42 55 47 0a 58 09 69 |ifndef D|EBUG.X.i|
|00000fa0| 66 20 28 66 6f 72 6b 28 | 29 20 21 3d 20 30 29 20 |f (fork(|) != 0) |
|00000fb0| 65 78 69 74 28 30 29 3b | 20 2f 2a 20 6b 69 6c 6c |exit(0);| /* kill|
|00000fc0| 20 6f 66 66 20 70 61 72 | 65 6e 74 20 2a 2f 0a 58 | off par|ent */.X|
|00000fd0| 09 2f 2a 20 63 6c 6f 73 | 65 20 61 6c 6c 20 66 69 |./* clos|e all fi|
|00000fe0| 6c 65 73 20 2a 2f 0a 58 | 09 66 64 20 3d 20 67 65 |les */.X|.fd = ge|
|00000ff0| 74 64 74 61 62 6c 65 73 | 69 7a 65 28 29 3b 0a 58 |tdtables|ize();.X|
|00001000| 09 66 6f 72 20 28 20 66 | 64 2d 2d 3b 20 66 64 3e |.for ( f|d--; fd>|
|00001010| 3d 30 3b 20 66 64 2d 2d | 29 7b 0a 58 09 09 28 76 |=0; fd--|){.X..(v|
|00001020| 6f 69 64 29 20 63 6c 6f | 73 65 28 66 64 29 3b 0a |oid) clo|se(fd);.|
|00001030| 58 09 7d 0a 58 09 2f 2a | 20 63 72 65 61 74 65 20 |X.}.X./*| create |
|00001040| 66 69 6c 65 73 20 66 6f | 72 20 73 74 64 7b 69 6e |files fo|r std{in|
|00001050| 2c 6f 75 74 2c 65 72 72 | 7d 20 69 66 20 74 68 65 |,out,err|} if the|
|00001060| 79 20 61 72 65 20 75 73 | 65 64 20 62 79 20 73 79 |y are us|ed by sy|
|00001070| 73 6c 6f 67 20 6f 72 20 | 73 6f 6d 65 20 0a 58 09 |slog or |some .X.|
|00001080| 20 20 20 73 75 63 68 20 | 73 74 75 70 69 64 69 74 | such |stupidit|
|00001090| 79 20 2a 2f 0a 58 09 69 | 66 20 28 28 66 64 20 3d |y */.X.i|f ((fd =|
|000010a0| 20 6f 70 65 6e 28 22 2f | 64 65 76 2f 6e 75 6c 6c | open("/|dev/null|
|000010b0| 22 2c 20 4f 5f 52 44 57 | 52 29 29 20 3c 20 30 20 |", O_RDW|R)) < 0 |
|000010c0| 29 20 65 78 69 74 28 31 | 29 3b 0a 58 09 69 66 20 |) exit(1|);.X.if |
|000010d0| 28 28 66 64 20 3d 20 6f | 70 65 6e 28 22 2f 64 65 |((fd = o|pen("/de|
|000010e0| 76 2f 6e 75 6c 6c 22 2c | 20 4f 5f 52 44 57 52 29 |v/null",| O_RDWR)|
|000010f0| 29 20 3c 20 30 20 29 20 | 65 78 69 74 28 31 29 3b |) < 0 ) |exit(1);|
|00001100| 0a 58 09 69 66 20 28 28 | 66 64 20 3d 20 6f 70 65 |.X.if ((|fd = ope|
|00001110| 6e 28 22 2f 64 65 76 2f | 6e 75 6c 6c 22 2c 20 4f |n("/dev/|null", O|
|00001120| 5f 52 44 57 52 29 29 20 | 3c 20 30 20 29 20 65 78 |_RDWR)) |< 0 ) ex|
|00001130| 69 74 28 31 29 3b 0a 58 | 09 2f 2a 20 6e 6f 77 20 |it(1);.X|./* now |
|00001140| 72 65 6d 6f 76 65 20 74 | 68 65 20 63 6f 6e 74 72 |remove t|he contr|
|00001150| 6f 6c 69 6e 67 20 74 74 | 79 20 28 69 66 20 74 68 |oling tt|y (if th|
|00001160| 65 72 65 20 69 73 20 6f | 6e 65 29 20 2a 2f 0a 58 |ere is o|ne) */.X|
|00001170| 09 69 66 20 28 20 28 66 | 64 20 3d 20 6f 70 65 6e |.if ( (f|d = open|
|00001180| 28 22 2f 64 65 76 2f 74 | 74 79 22 2c 20 4f 5f 52 |("/dev/t|ty", O_R|
|00001190| 44 57 52 29 29 20 3e 3d | 20 30 20 29 20 7b 0a 58 |DWR)) >=| 0 ) {.X|
|000011a0| 09 09 28 76 6f 69 64 29 | 20 69 6f 63 74 6c 28 66 |..(void)| ioctl(f|
|000011b0| 64 2c 20 54 49 4f 43 4e | 4f 54 54 59 2c 20 30 29 |d, TIOCN|OTTY, 0)|
|000011c0| 3b 0a 58 09 09 28 76 6f | 69 64 29 20 63 6c 6f 73 |;.X..(vo|id) clos|
|000011d0| 65 28 66 64 29 3b 0a 58 | 09 7d 0a 58 23 65 6e 64 |e(fd);.X|.}.X#end|
|000011e0| 69 66 0a 58 09 0a 58 09 | 77 68 69 6c 65 20 28 31 |if.X..X.|while (1|
|000011f0| 29 20 7b 0a 58 09 09 2f | 2a 20 6f 70 65 6e 20 74 |) {.X../|* open t|
|00001200| 68 65 20 75 74 6d 70 20 | 66 69 6c 65 20 2a 2f 0a |he utmp |file */.|
|00001210| 58 09 09 69 66 20 28 28 | 66 64 20 3d 20 6f 70 65 |X..if ((|fd = ope|
|00001220| 6e 28 55 54 4d 50 2c 20 | 4f 5f 52 44 4f 4e 4c 59 |n(UTMP, |O_RDONLY|
|00001230| 2c 20 30 29 29 20 3c 20 | 30 29 20 7b 0a 58 09 09 |, 0)) < |0) {.X..|
|00001240| 09 73 79 73 6c 6f 67 28 | 4c 4f 47 5f 43 52 49 54 |.syslog(|LOG_CRIT|
|00001250| 2c 20 22 49 64 6c 65 73 | 20 63 61 6e 27 74 20 6f |, "Idles| can't o|
|00001260| 70 65 6e 20 75 74 6d 70 | 22 29 3b 0a 58 09 09 09 |pen utmp|");.X...|
|00001270| 65 78 69 74 28 31 29 3b | 0a 58 09 09 7d 0a 58 09 |exit(1);|.X..}.X.|
|00001280| 09 2f 2a 20 67 65 74 20 | 74 68 65 20 74 69 6d 65 |./* get |the time|
|00001290| 20 2a 2f 0a 58 09 09 69 | 66 20 28 67 65 74 74 69 | */.X..i|f (getti|
|000012a0| 6d 65 6f 66 64 61 79 28 | 26 74 76 2c 20 26 74 7a |meofday(|&tv, &tz|
|000012b0| 29 20 21 3d 20 30 29 20 | 7b 0a 58 09 09 09 73 79 |) != 0) |{.X...sy|
|000012c0| 73 6c 6f 67 28 4c 4f 47 | 5f 43 52 49 54 2c 20 22 |slog(LOG|_CRIT, "|
|000012d0| 49 64 6c 65 73 20 63 61 | 6e 27 74 20 67 65 74 20 |Idles ca|n't get |
|000012e0| 74 69 6d 65 6f 66 64 61 | 79 22 29 3b 0a 58 09 09 |timeofda|y");.X..|
|000012f0| 09 65 78 69 74 28 31 29 | 3b 0a 58 09 09 7d 0a 58 |.exit(1)|;.X..}.X|
|00001300| 09 09 6c 74 69 6d 65 20 | 3d 20 6c 6f 63 61 6c 74 |..ltime |= localt|
|00001310| 69 6d 65 28 26 74 76 2e | 74 76 5f 73 65 63 29 3b |ime(&tv.|tv_sec);|
|00001320| 0a 58 09 09 2f 2a 20 77 | 6f 72 6b 20 6f 75 74 20 |.X../* w|ork out |
|00001330| 74 68 65 20 6c 6f 67 6f | 75 74 20 74 69 6d 65 20 |the logo|ut time |
|00001340| 6c 69 6d 69 74 20 2a 2f | 0a 58 09 09 69 66 20 28 |limit */|.X..if (|
|00001350| 28 6c 74 69 6d 65 2d 3e | 74 6d 5f 68 6f 75 72 20 |(ltime->|tm_hour |
|00001360| 3e 20 4d 4f 52 4e 49 4e | 47 29 20 26 26 20 28 6c |> MORNIN|G) && (l|
|00001370| 74 69 6d 65 2d 3e 74 6d | 5f 68 6f 75 72 20 3c 20 |time->tm|_hour < |
|00001380| 45 56 45 4e 49 4e 47 29 | 29 20 7b 0a 58 09 09 09 |EVENING)|) {.X...|
|00001390| 6c 6f 67 6f 75 74 20 3d | 20 44 41 59 4f 55 54 3b |logout =| DAYOUT;|
|000013a0| 0a 58 09 09 7d 0a 58 09 | 09 65 6c 73 65 20 6c 6f |.X..}.X.|.else lo|
|000013b0| 67 6f 75 74 20 3d 20 4e | 49 47 48 54 4f 3b 0a 58 |gout = N|IGHTO;.X|
|000013c0| 09 09 0a 58 09 09 2f 2a | 20 72 65 61 64 20 74 68 |...X../*| read th|
|000013d0| 65 20 75 74 6d 70 20 66 | 69 6c 65 2c 20 72 65 63 |e utmp f|ile, rec|
|000013e0| 6f 72 64 20 62 79 20 72 | 65 63 6f 72 64 20 75 6e |ord by r|ecord un|
|000013f0| 74 69 6c 20 66 69 6e 69 | 73 68 65 64 20 2a 2f 0a |til fini|shed */.|
|00001400| 58 09 09 77 68 69 6c 65 | 20 28 72 65 61 64 28 66 |X..while| (read(f|
|00001410| 64 2c 20 26 75 74 2c 20 | 73 69 7a 65 6f 66 28 73 |d, &ut, |sizeof(s|
|00001420| 74 72 75 63 74 20 75 74 | 6d 70 29 29 20 3d 3d 20 |truct ut|mp)) == |
|00001430| 73 69 7a 65 6f 66 28 73 | 74 72 75 63 74 20 75 74 |sizeof(s|truct ut|
|00001440| 6d 70 29 29 20 7b 0a 58 | 09 09 09 69 66 20 28 75 |mp)) {.X|...if (u|
|00001450| 74 2e 75 74 5f 6c 69 6e | 65 5b 30 5d 20 21 3d 20 |t.ut_lin|e[0] != |
|00001460| 27 5c 30 27 20 26 26 20 | 75 74 2e 75 74 5f 6e 61 |'\0' && |ut.ut_na|
|00001470| 6d 65 5b 30 5d 20 21 3d | 20 27 5c 30 27 29 20 7b |me[0] !=| '\0') {|
|00001480| 0a 58 09 09 09 09 2f 2a | 20 67 65 74 20 74 68 65 |.X..../*| get the|
|00001490| 20 6c 61 73 74 20 74 69 | 6d 65 20 6f 66 20 75 73 | last ti|me of us|
|000014a0| 65 20 6f 66 20 74 68 65 | 20 74 65 72 6d 69 6e 61 |e of the| termina|
|000014b0| 6c 20 62 79 0a 58 09 09 | 09 09 20 20 20 73 74 61 |l by.X..|.. sta|
|000014c0| 74 2d 69 6e 67 20 74 68 | 65 20 74 65 72 6d 69 6e |t-ing th|e termin|
|000014d0| 61 6c 20 2a 2f 0a 58 09 | 09 09 09 73 74 72 63 70 |al */.X.|...strcp|
|000014e0| 79 28 66 6e 61 6d 65 2c | 20 22 2f 64 65 76 2f 22 |y(fname,| "/dev/"|
|000014f0| 29 3b 0a 58 09 09 09 09 | 73 74 72 63 61 74 28 66 |);.X....|strcat(f|
|00001500| 6e 61 6d 65 2c 20 75 74 | 2e 75 74 5f 6c 69 6e 65 |name, ut|.ut_line|
|00001510| 29 3b 0a 58 09 09 09 09 | 69 66 20 28 73 74 61 74 |);.X....|if (stat|
|00001520| 28 66 6e 61 6d 65 2c 20 | 26 73 62 75 66 29 20 21 |(fname, |&sbuf) !|
|00001530| 3d 20 30 29 20 7b 0a 58 | 09 09 09 09 09 70 65 72 |= 0) {.X|.....per|
|00001540| 72 6f 72 28 22 69 64 6c | 65 73 3a 20 73 74 61 74 |ror("idl|es: stat|
|00001550| 3a 20 22 29 3b 0a 58 09 | 09 09 09 09 63 6f 6e 74 |: ");.X.|....cont|
|00001560| 69 6e 75 65 3b 0a 58 09 | 09 09 09 7d 0a 58 09 09 |inue;.X.|...}.X..|
|00001570| 09 09 2f 2a 20 63 61 6c | 63 75 6c 61 74 65 20 74 |../* cal|culate t|
|00001580| 68 65 20 6e 75 6d 62 65 | 72 20 6f 66 20 6d 69 6e |he numbe|r of min|
|00001590| 75 74 65 73 20 73 69 6e | 63 65 20 74 68 65 20 74 |utes sin|ce the t|
|000015a0| 65 72 6d 69 6e 61 6c 20 | 77 61 73 20 6c 61 73 74 |erminal |was last|
|000015b0| 0a 58 09 09 09 09 20 20 | 20 61 63 65 73 73 65 64 |.X.... | acessed|
|000015c0| 20 2a 2f 0a 58 09 09 09 | 09 6d 69 6e 75 74 65 73 | */.X...|.minutes|
|000015d0| 20 3d 20 28 74 76 2e 74 | 76 5f 73 65 63 20 2d 20 | = (tv.t|v_sec - |
|000015e0| 73 62 75 66 2e 73 74 5f | 61 74 69 6d 65 20 29 20 |sbuf.st_|atime ) |
|000015f0| 2f 20 36 30 3b 0a 58 09 | 09 09 09 2f 2a 20 6b 69 |/ 60;.X.|.../* ki|
|00001600| 6c 6c 20 68 69 6d 20 6f | 66 66 20 6f 72 20 77 61 |ll him o|ff or wa|
|00001610| 72 6e 20 68 69 6d 20 69 | 66 20 68 65 20 68 61 73 |rn him i|f he has|
|00001620| 6e 27 74 20 75 73 65 64 | 20 68 69 73 20 74 65 72 |n't used| his ter|
|00001630| 6d 69 6e 61 6c 20 2a 2f | 0a 58 09 09 09 09 69 66 |minal */|.X....if|
|00001640| 20 28 6d 69 6e 75 74 65 | 73 20 3e 3d 20 6c 6f 67 | (minute|s >= log|
|00001650| 6f 75 74 29 20 7b 0a 58 | 09 09 09 09 09 7a 61 70 |out) {.X|.....zap|
|00001660| 28 66 6e 61 6d 65 2c 20 | 4c 4d 45 53 53 41 47 45 |(fname, |LMESSAGE|
|00001670| 2c 20 30 29 3b 0a 58 09 | 09 09 09 09 73 79 73 6c |, 0);.X.|....sysl|
|00001680| 6f 67 28 4c 4f 47 5f 49 | 4e 46 4f 2c 20 22 41 75 |og(LOG_I|NFO, "Au|
|00001690| 74 6f 20 6c 6f 67 6f 75 | 74 20 25 73 20 25 73 20 |to logou|t %s %s |
|000016a0| 22 2c 0a 58 09 09 09 09 | 09 20 20 75 74 2e 75 74 |",.X....|. ut.ut|
|000016b0| 5f 6e 61 6d 65 2c 20 75 | 74 2e 75 74 5f 6c 69 6e |_name, u|t.ut_lin|
|000016c0| 65 29 3b 0a 58 09 09 09 | 09 7d 0a 58 09 09 09 09 |e);.X...|.}.X....|
|000016d0| 65 6c 73 65 20 69 66 20 | 28 6d 69 6e 75 74 65 73 |else if |(minutes|
|000016e0| 20 3e 3d 20 57 41 52 4e | 29 20 7b 0a 58 09 09 09 | >= WARN|) {.X...|
|000016f0| 09 09 7a 61 70 28 66 6e | 61 6d 65 2c 20 57 4d 45 |..zap(fn|ame, WME|
|00001700| 53 53 41 47 45 2c 20 31 | 29 3b 0a 58 09 09 09 09 |SSAGE, 1|);.X....|
|00001710| 7d 0a 58 09 09 09 7d 0a | 58 09 09 7d 0a 58 09 09 |}.X...}.|X..}.X..|
|00001720| 28 76 6f 69 64 29 20 63 | 6c 6f 73 65 28 66 64 29 |(void) c|lose(fd)|
|00001730| 3b 0a 58 09 09 2f 2a 20 | 73 6c 65 65 70 20 75 6e |;.X../* |sleep un|
|00001740| 74 69 6c 20 69 74 73 20 | 74 69 6d 65 20 74 6f 20 |til its |time to |
|00001750| 73 74 61 72 74 20 61 67 | 61 69 6e 20 2a 2f 0a 58 |start ag|ain */.X|
|00001760| 09 09 73 6c 65 65 70 28 | 53 4c 45 45 50 20 2a 20 |..sleep(|SLEEP * |
|00001770| 36 30 29 3b 0a 58 09 7d | 0a 58 7d 0a 58 2f 2a 20 |60);.X.}|.X}.X/* |
|00001780| 6b 69 6c 6c 20 6f 72 20 | 77 61 72 6e 20 61 20 75 |kill or |warn a u|
|00001790| 73 65 72 20 2a 2f 0a 58 | 7a 61 70 28 66 6e 61 6d |ser */.X|zap(fnam|
|000017a0| 65 2c 20 6d 65 73 73 61 | 67 65 2c 20 77 61 72 6e |e, messa|ge, warn|
|000017b0| 29 0a 58 63 68 61 72 20 | 2a 66 6e 61 6d 65 2c 20 |).Xchar |*fname, |
|000017c0| 2a 6d 65 73 73 61 67 65 | 3b 0a 58 7b 0a 58 09 69 |*message|;.X{.X.i|
|000017d0| 6e 74 20 61 6c 6c 61 72 | 6d 65 64 28 29 3b 0a 58 |nt allar|med();.X|
|000017e0| 09 73 74 72 75 63 74 20 | 73 67 74 74 79 62 20 74 |.struct |sgttyb t|
|000017f0| 74 79 62 3b 0a 58 09 69 | 6e 74 20 74 66 64 3b 0a |tyb;.X.i|nt tfd;.|
|00001800| 58 09 69 66 20 28 66 6f | 72 6b 28 29 20 3d 3d 20 |X.if (fo|rk() == |
|00001810| 30 29 20 7b 0a 58 09 09 | 2f 2a 20 63 68 69 6c 64 |0) {.X..|/* child|
|00001820| 20 6b 69 6c 6c 73 20 74 | 68 65 20 6f 66 66 65 6e | kills t|he offen|
|00001830| 64 65 72 20 2a 2f 0a 58 | 09 09 2f 2a 20 63 6c 6f |der */.X|../* clo|
|00001840| 73 65 20 61 6c 6c 20 66 | 69 6c 65 73 20 2a 2f 0a |se all f|iles */.|
|00001850| 58 09 09 74 66 64 20 3d | 20 67 65 74 64 74 61 62 |X..tfd =| getdtab|
|00001860| 6c 65 73 69 7a 65 28 29 | 3b 0a 58 09 09 66 6f 72 |lesize()|;.X..for|
|00001870| 20 28 20 74 66 64 2d 2d | 3b 20 74 66 64 3e 3d 30 | ( tfd--|; tfd>=0|
|00001880| 3b 20 74 66 64 2d 2d 29 | 7b 0a 58 09 09 09 28 76 |; tfd--)|{.X...(v|
|00001890| 6f 69 64 29 20 63 6c 6f | 73 65 28 74 66 64 29 3b |oid) clo|se(tfd);|
|000018a0| 0a 58 09 09 7d 0a 58 09 | 09 2f 2a 20 6e 6f 77 20 |.X..}.X.|./* now |
|000018b0| 72 65 6d 6f 76 65 20 74 | 68 65 20 63 6f 6e 74 72 |remove t|he contr|
|000018c0| 6f 6c 69 6e 67 20 74 74 | 79 20 28 69 66 20 74 68 |oling tt|y (if th|
|000018d0| 65 72 65 20 69 73 20 6f | 6e 65 29 20 2a 2f 0a 58 |ere is o|ne) */.X|
|000018e0| 09 09 69 66 20 28 20 28 | 74 66 64 20 3d 20 6f 70 |..if ( (|tfd = op|
|000018f0| 65 6e 28 22 2f 64 65 76 | 2f 74 74 79 22 2c 20 4f |en("/dev|/tty", O|
|00001900| 5f 52 44 57 52 29 29 20 | 3e 3d 20 30 20 29 20 7b |_RDWR)) |>= 0 ) {|
|00001910| 0a 58 09 09 09 28 76 6f | 69 64 29 20 69 6f 63 74 |.X...(vo|id) ioct|
|00001920| 6c 28 74 66 64 2c 20 54 | 49 4f 43 4e 4f 54 54 59 |l(tfd, T|IOCNOTTY|
|00001930| 2c 20 30 29 3b 0a 58 09 | 09 09 28 76 6f 69 64 29 |, 0);.X.|..(void)|
|00001940| 20 63 6c 6f 73 65 28 74 | 66 64 29 3b 0a 58 09 09 | close(t|fd);.X..|
|00001950| 7d 0a 58 09 09 2f 2a 20 | 74 68 69 73 20 6f 70 65 |}.X../* |this ope|
|00001960| 6e 20 77 69 6c 6c 20 61 | 6c 73 6f 20 73 65 74 20 |n will a|lso set |
|00001970| 61 20 6e 65 77 20 63 6f | 6e 74 72 6f 6c 69 6e 67 |a new co|ntroling|
|00001980| 20 74 65 72 6d 69 6e 61 | 6c 20 2a 2f 0a 58 09 09 | termina|l */.X..|
|00001990| 74 66 64 20 3d 20 6f 70 | 65 6e 28 66 6e 61 6d 65 |tfd = op|en(fname|
|000019a0| 2c 20 4f 5f 52 44 57 52 | 2c 20 30 36 30 30 29 20 |, O_RDWR|, 0600) |
|000019b0| 3b 0a 58 09 09 69 66 20 | 28 74 66 64 20 3c 20 30 |;.X..if |(tfd < 0|
|000019c0| 29 20 65 78 69 74 28 31 | 29 3b 0a 58 09 09 2f 2a |) exit(1|);.X../*|
|000019d0| 20 73 65 74 75 70 20 61 | 20 74 69 6d 65 6f 75 74 | setup a| timeout|
|000019e0| 20 69 66 20 61 67 61 69 | 6e 73 74 20 61 6c 6c 20 | if agai|nst all |
|000019f0| 6f 64 64 73 20 77 65 20 | 67 65 74 20 68 75 6e 67 |odds we |get hung|
|00001a00| 20 2a 2f 0a 58 09 09 73 | 69 67 6e 61 6c 28 53 49 | */.X..s|ignal(SI|
|00001a10| 47 41 4c 52 4d 2c 61 6c | 6c 61 72 6d 65 64 29 3b |GALRM,al|larmed);|
|00001a20| 0a 58 09 09 61 6c 61 72 | 6d 28 32 29 3b 0a 58 09 |.X..alar|m(2);.X.|
|00001a30| 09 69 66 20 28 73 65 74 | 6a 6d 70 28 65 6e 76 29 |.if (set|jmp(env)|
|00001a40| 20 3d 3d 20 30 29 20 7b | 0a 58 09 09 09 2f 2a 20 | == 0) {|.X.../* |
|00001a50| 64 6f 20 74 68 69 73 20 | 74 6f 20 70 72 65 76 65 |do this |to preve|
|00001a60| 6e 74 20 5e 53 20 66 72 | 6f 6d 20 68 61 6e 67 69 |nt ^S fr|om hangi|
|00001a70| 6e 67 20 74 68 65 20 70 | 72 6f 63 65 73 73 20 2a |ng the p|rocess *|
|00001a80| 2f 0a 58 09 09 09 28 76 | 6f 69 64 29 20 69 6f 63 |/.X...(v|oid) ioc|
|00001a90| 74 6c 28 74 66 64 2c 20 | 54 49 4f 43 53 54 41 52 |tl(tfd, |TIOCSTAR|
|00001aa0| 54 2c 20 28 63 68 61 72 | 20 2a 29 30 29 3b 0a 58 |T, (char| *)0);.X|
|00001ab0| 09 09 09 2f 2a 20 74 6f | 67 67 6c 65 20 63 62 72 |.../* to|ggle cbr|
|00001ac0| 65 61 6b 20 74 6f 20 64 | 69 73 72 75 70 74 20 61 |eak to d|isrupt a|
|00001ad0| 6e 79 20 74 65 72 6d 69 | 6e 61 6c 20 70 61 67 69 |ny termi|nal pagi|
|00001ae0| 6e 67 20 2a 2f 0a 58 09 | 09 09 28 76 6f 69 64 29 |ng */.X.|..(void)|
|00001af0| 20 69 6f 63 74 6c 28 74 | 66 64 2c 20 54 49 4f 43 | ioctl(t|fd, TIOC|
|00001b00| 47 45 54 50 2c 20 26 74 | 74 79 62 29 3b 0a 58 09 |GETP, &t|tyb);.X.|
|00001b10| 09 09 74 74 79 62 2e 73 | 67 5f 66 6c 61 67 73 20 |..ttyb.s|g_flags |
|00001b20| 5e 3d 20 43 42 52 45 41 | 4b 3b 0a 58 09 09 09 28 |^= CBREA|K;.X...(|
|00001b30| 76 6f 69 64 29 20 69 6f | 63 74 6c 28 74 66 64 2c |void) io|ctl(tfd,|
|00001b40| 20 54 49 4f 43 53 45 54 | 50 2c 20 26 74 74 79 62 | TIOCSET|P, &ttyb|
|00001b50| 29 3b 0a 58 09 09 09 74 | 74 79 62 2e 73 67 5f 66 |);.X...t|tyb.sg_f|
|00001b60| 6c 61 67 73 20 5e 3d 20 | 43 42 52 45 41 4b 3b 0a |lags ^= |CBREAK;.|
|00001b70| 58 09 09 09 28 76 6f 69 | 64 29 20 69 6f 63 74 6c |X...(voi|d) ioctl|
|00001b80| 28 74 66 64 2c 20 54 49 | 4f 43 53 45 54 50 2c 20 |(tfd, TI|OCSETP, |
|00001b90| 26 74 74 79 62 29 3b 0a | 58 09 09 09 0a 58 09 09 |&ttyb);.|X....X..|
|00001ba0| 09 2f 2a 20 77 72 69 74 | 65 20 6f 75 74 20 74 68 |./* writ|e out th|
|00001bb0| 65 20 6c 6f 67 6f 75 74 | 20 6d 65 73 73 61 67 65 |e logout| message|
|00001bc0| 20 2a 2f 0a 58 09 09 09 | 77 72 69 74 65 28 74 66 | */.X...|write(tf|
|00001bd0| 64 2c 20 6d 65 73 73 61 | 67 65 2c 20 73 74 72 6c |d, messa|ge, strl|
|00001be0| 65 6e 28 6d 65 73 73 61 | 67 65 29 29 3b 0a 58 09 |en(messa|ge));.X.|
|00001bf0| 09 0a 58 09 09 09 2f 2a | 20 66 6c 75 73 68 20 69 |..X.../*| flush i|
|00001c00| 74 20 6f 75 74 20 66 6f | 72 20 73 61 66 65 74 79 |t out fo|r safety|
|00001c10| 27 73 20 73 61 6b 65 20 | 2a 2f 0a 58 09 09 09 28 |'s sake |*/.X...(|
|00001c20| 76 6f 69 64 29 20 69 6f | 63 74 6c 28 74 66 64 2c |void) io|ctl(tfd,|
|00001c30| 20 54 49 4f 43 46 4c 55 | 53 48 2c 20 28 63 68 61 | TIOCFLU|SH, (cha|
|00001c40| 72 20 2a 29 30 29 3b 0a | 58 09 09 7d 0a 58 09 09 |r *)0);.|X..}.X..|
|00001c50| 61 6c 61 72 6d 28 30 29 | 3b 0a 58 09 09 28 76 6f |alarm(0)|;.X..(vo|
|00001c60| 69 64 29 20 63 6c 6f 73 | 65 28 74 66 64 29 3b 0a |id) clos|e(tfd);.|
|00001c70| 58 09 09 2f 2a 20 6b 69 | 6c 6c 20 6f 66 66 20 74 |X../* ki|ll off t|
|00001c80| 68 65 20 6f 66 66 65 6e | 64 65 72 27 73 20 6c 6f |he offen|der's lo|
|00001c90| 67 69 6e 20 61 6e 64 20 | 65 78 69 74 20 2a 2f 0a |gin and |exit */.|
|00001ca0| 58 09 09 69 66 20 28 21 | 77 61 72 6e 29 20 76 68 |X..if (!|warn) vh|
|00001cb0| 61 6e 67 75 70 28 29 3b | 0a 58 09 09 65 78 69 74 |angup();|.X..exit|
|00001cc0| 28 30 29 3b 0a 58 09 7d | 0a 58 09 2f 2a 70 61 72 |(0);.X.}|.X./*par|
|00001cd0| 65 6e 74 3a 20 77 61 69 | 74 20 66 6f 72 20 74 68 |ent: wai|t for th|
|00001ce0| 65 20 66 6f 72 6b 65 64 | 20 70 72 6f 63 65 73 73 |e forked| process|
|00001cf0| 2a 2f 0a 58 09 77 68 69 | 6c 65 20 28 77 61 69 74 |*/.X.whi|le (wait|
|00001d00| 28 30 29 20 3d 3d 20 30 | 29 3b 0a 58 7d 0a 58 0a |(0) == 0|);.X}.X.|
|00001d10| 58 2f 2a 20 6a 75 73 74 | 20 6c 6f 6e 67 6a 6d 70 |X/* just| longjmp|
|00001d20| 20 6f 75 74 20 69 66 20 | 74 69 6d 65 64 20 6f 75 | out if |timed ou|
|00001d30| 74 20 28 53 49 47 41 4c | 52 4d 20 72 65 63 65 69 |t (SIGAL|RM recei|
|00001d40| 76 65 64 29 20 2a 2f 0a | 58 61 6c 6c 61 72 6d 65 |ved) */.|Xallarme|
|00001d50| 64 28 73 69 67 29 0a 58 | 69 6e 74 20 73 69 67 3b |d(sig).X|int sig;|
|00001d60| 0a 58 7b 0a 58 6c 6f 6e | 67 6a 6d 70 28 65 6e 76 |.X{.Xlon|gjmp(env|
|00001d70| 2c 31 29 3b 0a 58 7d 0a | 58 0a 40 2f 2f 45 2a 4f |,1);.X}.|X.@//E*O|
|00001d80| 2a 46 20 69 64 65 6c 2e | 63 2f 2f 0a 69 66 20 74 |*F idel.|c//.if t|
|00001d90| 65 73 74 20 35 34 34 38 | 20 2d 6e 65 20 22 60 77 |est 5448| -ne "`w|
|00001da0| 63 20 2d 63 20 3c 27 69 | 64 65 6c 2e 63 27 60 22 |c -c <'i|del.c'`"|
|00001db0| 3b 20 74 68 65 6e 0a 20 | 20 20 20 65 63 68 6f 20 |; then. | echo |
|00001dc0| 73 68 61 72 3a 20 65 72 | 72 6f 72 20 74 72 61 6e |shar: er|ror tran|
|00001dd0| 73 6d 69 74 74 69 6e 67 | 20 22 27 69 64 65 6c 2e |smitting| "'idel.|
|00001de0| 63 27 22 20 27 28 73 68 | 6f 75 6c 64 20 68 61 76 |c'" '(sh|ould hav|
|00001df0| 65 20 62 65 65 6e 20 35 | 34 34 38 20 63 68 61 72 |e been 5|448 char|
|00001e00| 61 63 74 65 72 73 29 27 | 0a 66 69 0a 66 69 20 23 |acters)'|.fi.fi #|
|00001e10| 20 65 6e 64 20 6f 66 20 | 6f 76 65 72 77 72 69 74 | end of |overwrit|
|00001e20| 69 6e 67 20 63 68 65 63 | 6b 0a 65 63 68 6f 20 73 |ing chec|k.echo s|
|00001e30| 68 61 72 3a 20 22 45 6e | 64 20 6f 66 20 73 68 65 |har: "En|d of she|
|00001e40| 6c 6c 20 61 72 63 68 69 | 76 65 2e 22 0a 65 78 69 |ll archi|ve.".exi|
|00001e50| 74 20 30 0a | |t 0. | |
+--------+-------------------------+-------------------------+--------+--------+