home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: SHell self-extracting ARchive
(archive/shar).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| SHell self-extracting ARchive (archive/shar)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| 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)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 4e 65 77 73 67 72 6f 75 | 70 73 3a 20 63 6f 6d 70 |Newsgrou|ps: comp|
|00000010| 2e 73 6f 75 72 63 65 73 | 2e 75 6e 69 78 0a 46 72 |.sources|.unix.Fr|
|00000020| 6f 6d 3a 20 62 72 6e 73 | 74 6e 64 40 6e 79 75 2e |om: brns|tnd@nyu.|
|00000030| 65 64 75 20 28 44 61 6e | 20 42 65 72 6e 73 74 65 |edu (Dan| Bernste|
|00000040| 69 6e 29 0a 53 75 62 6a | 65 63 74 3a 20 76 32 35 |in).Subj|ect: v25|
|00000050| 69 31 33 31 3a 20 47 65 | 6e 65 72 61 6c 69 7a 65 |i131: Ge|neralize|
|00000060| 64 20 69 6e 74 65 72 66 | 61 63 65 20 74 6f 20 70 |d interf|ace to p|
|00000070| 73 65 75 64 6f 2d 74 74 | 79 20 64 65 76 69 63 65 |seudo-tt|y device|
|00000080| 73 2c 20 50 61 72 74 30 | 35 2f 30 39 0a 53 65 6e |s, Part0|5/09.Sen|
|00000090| 64 65 72 3a 20 75 6e 69 | 78 2d 73 6f 75 72 63 65 |der: uni|x-source|
|000000a0| 73 2d 6d 6f 64 65 72 61 | 74 6f 72 40 70 61 2e 64 |s-modera|tor@pa.d|
|000000b0| 65 63 2e 63 6f 6d 0a 41 | 70 70 72 6f 76 65 64 3a |ec.com.A|pproved:|
|000000c0| 20 76 69 78 69 65 40 70 | 61 2e 64 65 63 2e 63 6f | vixie@p|a.dec.co|
|000000d0| 6d 0a 0a 53 75 62 6d 69 | 74 74 65 64 2d 42 79 3a |m..Submi|tted-By:|
|000000e0| 20 62 72 6e 73 74 6e 64 | 40 6e 79 75 2e 65 64 75 | brnstnd|@nyu.edu|
|000000f0| 20 28 44 61 6e 20 42 65 | 72 6e 73 74 65 69 6e 29 | (Dan Be|rnstein)|
|00000100| 0a 50 6f 73 74 69 6e 67 | 2d 4e 75 6d 62 65 72 3a |.Posting|-Number:|
|00000110| 20 56 6f 6c 75 6d 65 20 | 32 35 2c 20 49 73 73 75 | Volume |25, Issu|
|00000120| 65 20 31 33 31 0a 41 72 | 63 68 69 76 65 2d 4e 61 |e 131.Ar|chive-Na|
|00000130| 6d 65 3a 20 70 74 79 34 | 2f 70 61 72 74 30 35 0a |me: pty4|/part05.|
|00000140| 0a 23 21 20 2f 62 69 6e | 2f 73 68 0a 23 20 54 68 |.#! /bin|/sh.# Th|
|00000150| 69 73 20 69 73 20 61 20 | 73 68 65 6c 6c 20 61 72 |is is a |shell ar|
|00000160| 63 68 69 76 65 2e 20 20 | 52 65 6d 6f 76 65 20 61 |chive. |Remove a|
|00000170| 6e 79 74 68 69 6e 67 20 | 62 65 66 6f 72 65 20 74 |nything |before t|
|00000180| 68 69 73 20 6c 69 6e 65 | 2c 20 74 68 65 6e 20 75 |his line|, then u|
|00000190| 6e 70 61 63 6b 0a 23 20 | 69 74 20 62 79 20 73 61 |npack.# |it by sa|
|000001a0| 76 69 6e 67 20 69 74 20 | 69 6e 74 6f 20 61 20 66 |ving it |into a f|
|000001b0| 69 6c 65 20 61 6e 64 20 | 74 79 70 69 6e 67 20 22 |ile and |typing "|
|000001c0| 73 68 20 66 69 6c 65 22 | 2e 20 20 54 6f 20 6f 76 |sh file"|. To ov|
|000001d0| 65 72 77 72 69 74 65 20 | 65 78 69 73 74 69 6e 67 |erwrite |existing|
|000001e0| 0a 23 20 66 69 6c 65 73 | 2c 20 74 79 70 65 20 22 |.# files|, type "|
|000001f0| 73 68 20 66 69 6c 65 20 | 2d 63 22 2e 20 20 59 6f |sh file |-c". Yo|
|00000200| 75 20 63 61 6e 20 61 6c | 73 6f 20 66 65 65 64 20 |u can al|so feed |
|00000210| 74 68 69 73 20 61 73 20 | 73 74 61 6e 64 61 72 64 |this as |standard|
|00000220| 20 69 6e 70 75 74 20 76 | 69 61 0a 23 20 75 6e 73 | input v|ia.# uns|
|00000230| 68 61 72 2c 20 6f 72 20 | 62 79 20 74 79 70 69 6e |har, or |by typin|
|00000240| 67 20 22 73 68 20 3c 66 | 69 6c 65 22 2c 20 65 2e |g "sh <f|ile", e.|
|00000250| 67 2e 2e 20 20 49 66 20 | 74 68 69 73 20 61 72 63 |g.. If |this arc|
|00000260| 68 69 76 65 20 69 73 20 | 63 6f 6d 70 6c 65 74 65 |hive is |complete|
|00000270| 2c 20 79 6f 75 0a 23 20 | 77 69 6c 6c 20 73 65 65 |, you.# |will see|
|00000280| 20 74 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 20 6d | the fol|lowing m|
|00000290| 65 73 73 61 67 65 20 61 | 74 20 74 68 65 20 65 6e |essage a|t the en|
|000002a0| 64 3a 0a 23 09 09 22 45 | 6e 64 20 6f 66 20 61 72 |d:.#.."E|nd of ar|
|000002b0| 63 68 69 76 65 20 35 20 | 28 6f 66 20 39 29 2e 22 |chive 5 |(of 9)."|
|000002c0| 0a 23 20 43 6f 6e 74 65 | 6e 74 73 3a 20 20 4e 45 |.# Conte|nts: NE|
|000002d0| 57 20 51 55 45 53 54 49 | 4f 4e 53 20 55 4c 4f 47 |W QUESTI|ONS ULOG|
|000002e0| 53 2e 64 72 61 66 74 31 | 20 70 74 79 2e 31 20 70 |S.draft1| pty.1 p|
|000002f0| 74 79 73 65 63 75 72 65 | 2e 63 20 70 74 79 73 69 |tysecure|.c ptysi|
|00000300| 67 6c 65 72 2e 63 0a 23 | 20 20 20 74 69 6d 65 72 |gler.c.#| timer|
|00000310| 2e 63 0a 23 20 57 72 61 | 70 70 65 64 20 62 79 20 |.c.# Wra|pped by |
|00000320| 76 69 78 69 65 40 63 6f | 67 6e 69 74 69 6f 6e 2e |vixie@co|gnition.|
|00000330| 70 61 2e 64 65 63 2e 63 | 6f 6d 20 6f 6e 20 57 65 |pa.dec.c|om on We|
|00000340| 64 20 46 65 62 20 31 39 | 20 31 33 3a 33 35 3a 30 |d Feb 19| 13:35:0|
|00000350| 34 20 31 39 39 32 0a 50 | 41 54 48 3d 2f 62 69 6e |4 1992.P|ATH=/bin|
|00000360| 3a 2f 75 73 72 2f 62 69 | 6e 3a 2f 75 73 72 2f 75 |:/usr/bi|n:/usr/u|
|00000370| 63 62 20 3b 20 65 78 70 | 6f 72 74 20 50 41 54 48 |cb ; exp|ort PATH|
|00000380| 0a 69 66 20 74 65 73 74 | 20 2d 66 20 27 4e 45 57 |.if test| -f 'NEW|
|00000390| 27 20 2d 61 20 22 24 7b | 31 7d 22 20 21 3d 20 22 |' -a "${|1}" != "|
|000003a0| 2d 63 22 20 3b 20 74 68 | 65 6e 20 0a 20 20 65 63 |-c" ; th|en . ec|
|000003b0| 68 6f 20 73 68 61 72 3a | 20 57 69 6c 6c 20 6e 6f |ho shar:| Will no|
|000003c0| 74 20 63 6c 6f 62 62 65 | 72 20 65 78 69 73 74 69 |t clobbe|r existi|
|000003d0| 6e 67 20 66 69 6c 65 20 | 5c 22 27 4e 45 57 27 5c |ng file |\"'NEW'\|
|000003e0| 22 0a 65 6c 73 65 0a 65 | 63 68 6f 20 73 68 61 72 |".else.e|cho shar|
|000003f0| 3a 20 45 78 74 72 61 63 | 74 69 6e 67 20 5c 22 27 |: Extrac|ting \"'|
|00000400| 4e 45 57 27 5c 22 20 5c | 28 39 31 36 34 20 63 68 |NEW'\" \|(9164 ch|
|00000410| 61 72 61 63 74 65 72 73 | 5c 29 0a 73 65 64 20 22 |aracters|\).sed "|
|00000420| 73 2f 5e 58 2f 2f 22 20 | 3e 27 4e 45 57 27 20 3c |s/^X//" |>'NEW' <|
|00000430| 3c 27 45 4e 44 5f 4f 46 | 5f 46 49 4c 45 27 0a 70 |<'END_OF|_FILE'.p|
|00000440| 74 79 20 34 2e 30 20 28 | 60 60 6e 65 77 70 74 79 |ty 4.0 (|``newpty|
|00000450| 27 27 20 62 65 6c 6f 77 | 29 20 69 73 20 61 6e 20 |'' below|) is an |
|00000460| 61 6c 6d 6f 73 74 20 63 | 6f 6d 70 6c 65 74 65 20 |almost c|omplete |
|00000470| 72 65 77 72 69 74 65 20 | 6f 66 20 70 74 79 20 33 |rewrite |of pty 3|
|00000480| 2e 30 0a 58 28 60 60 6f | 6c 64 70 74 79 27 27 29 |.0.X(``o|ldpty'')|
|00000490| 2e 20 53 6f 6d 65 20 66 | 65 61 74 75 72 65 73 20 |. Some f|eatures |
|000004a0| 61 6e 64 20 6d 69 73 66 | 65 61 74 75 72 65 73 20 |and misf|eatures |
|000004b0| 68 61 76 65 20 62 65 65 | 6e 20 72 65 6d 6f 76 65 |have bee|n remove|
|000004c0| 64 3a 0a 58 0a 58 31 2e | 20 6e 65 77 70 74 79 20 |d:.X.X1.| newpty |
|000004d0| 6e 6f 20 6c 6f 6e 67 65 | 72 20 61 6c 6c 6f 77 73 |no longe|r allows|
|000004e0| 20 66 6f 72 20 73 79 73 | 74 65 6d 73 20 77 69 74 | for sys|tems wit|
|000004f0| 68 6f 75 74 20 66 69 6c | 65 20 64 65 73 63 72 69 |hout fil|e descri|
|00000500| 70 74 6f 72 20 70 61 73 | 73 69 6e 67 2e 0a 58 32 |ptor pas|sing..X2|
|00000510| 2e 20 6e 65 77 70 74 79 | 20 64 6f 65 73 20 6e 6f |. newpty| does no|
|00000520| 74 20 67 6f 20 74 6f 20 | 6f 62 73 63 65 6e 65 20 |t go to |obscene |
|00000530| 6c 65 6e 67 74 68 73 20 | 74 6f 20 65 6e 73 75 72 |lengths |to ensur|
|00000540| 65 20 6e 6f 6e 2d 62 6c | 6f 63 6b 69 6e 67 20 49 |e non-bl|ocking I|
|00000550| 2f 4f 2e 0a 58 33 2e 20 | 6e 65 77 70 74 79 20 64 |/O..X3. |newpty d|
|00000560| 6f 65 73 20 6e 6f 74 20 | 77 6f 72 72 79 20 61 62 |oes not |worry ab|
|00000570| 6f 75 74 20 74 68 65 20 | 62 75 67 67 79 20 4d 41 |out the |buggy MA|
|00000580| 58 55 50 52 43 20 68 61 | 6e 64 6c 69 6e 67 20 69 |XUPRC ha|ndling i|
|00000590| 6e 20 42 53 44 20 34 2e | 7b 32 2c 33 7d 2e 0a 58 |n BSD 4.|{2,3}..X|
|000005a0| 34 2e 20 6e 65 77 70 74 | 79 20 6e 6f 20 6c 6f 6e |4. newpt|y no lon|
|000005b0| 67 65 72 20 6d 61 69 6e | 74 61 69 6e 73 20 61 6e |ger main|tains an|
|000005c0| 20 65 6e 74 69 72 65 20 | 68 69 65 72 61 72 63 68 | entire |hierarch|
|000005d0| 79 20 6f 66 20 73 70 65 | 63 69 61 6c 20 66 69 6c |y of spe|cial fil|
|000005e0| 65 73 2e 0a 58 35 2e 20 | 54 68 65 20 78 2a 20 75 |es..X5. |The x* u|
|000005f0| 74 69 6c 69 74 69 65 73 | 20 61 6e 64 20 2d 78 53 |tilities| and -xS|
|00000600| 20 61 72 65 20 67 6f 6e | 65 2e 0a 58 36 2e 20 46 | are gon|e..X6. F|
|00000610| 6f 72 20 73 65 63 75 72 | 69 74 79 20 72 65 61 73 |or secur|ity reas|
|00000620| 6f 6e 73 2c 20 2d 66 20 | 69 73 20 67 6f 6e 65 2e |ons, -f |is gone.|
|00000630| 0a 58 37 2e 20 73 65 73 | 73 75 73 65 72 20 69 73 |.X7. ses|suser is|
|00000640| 20 67 6f 6e 65 2c 20 61 | 73 20 6e 6f 62 6f 64 79 | gone, a|s nobody|
|00000650| 20 75 73 65 73 20 69 74 | 2e 20 49 6e 20 69 74 73 | uses it|. In its|
|00000660| 20 70 6c 61 63 65 20 69 | 73 20 73 65 73 73 6d 65 | place i|s sessme|
|00000670| 6e 75 20 28 73 65 65 20 | 62 65 6c 6f 77 29 2e 0a |nu (see |below)..|
|00000680| 58 38 2e 20 54 68 65 20 | 73 65 6d 69 2d 61 75 74 |X8. The |semi-aut|
|00000690| 6f 6d 61 74 69 63 20 49 | 4e 53 54 41 4c 4c 20 68 |omatic I|NSTALL h|
|000006a0| 61 73 20 62 65 65 6e 20 | 72 65 70 6c 61 63 65 64 |as been |replaced|
|000006b0| 20 62 79 20 61 20 73 61 | 6e 65 20 63 6f 6e 66 69 | by a sa|ne confi|
|000006c0| 67 75 72 61 74 69 6f 6e | 20 73 79 73 74 65 6d 2e |guration| system.|
|000006d0| 0a 58 0a 53 65 76 65 72 | 61 6c 20 6e 65 77 20 66 |.X.Sever|al new f|
|000006e0| 65 61 74 75 72 65 73 20 | 68 61 76 65 20 62 65 65 |eatures |have bee|
|000006f0| 6e 20 61 64 64 65 64 3a | 0a 58 0a 58 39 2e 20 59 |n added:|.X.X9. Y|
|00000700| 6f 75 20 63 61 6e 20 6e | 6f 77 20 64 69 73 63 6f |ou can n|ow disco|
|00000710| 6e 6e 65 63 74 2c 20 72 | 65 63 6f 6e 6e 65 63 74 |nnect, r|econnect|
|00000720| 2c 20 61 6e 64 20 72 65 | 6e 61 6d 65 20 73 65 73 |, and re|name ses|
|00000730| 73 69 6f 6e 73 20 72 65 | 6d 6f 74 65 6c 79 2e 0a |sions re|motely..|
|00000740| 58 31 30 2e 20 6e 65 77 | 70 74 79 20 70 65 72 66 |X10. new|pty perf|
|00000750| 6f 72 6d 73 20 6d 75 63 | 68 20 62 65 74 74 65 72 |orms muc|h better|
|00000760| 20 74 65 73 74 73 20 74 | 68 61 6e 20 6f 6c 64 70 | tests t|han oldp|
|00000770| 74 79 20 66 6f 72 20 74 | 74 79 20 73 65 63 75 72 |ty for t|ty secur|
|00000780| 69 74 79 2e 0a 58 31 31 | 2e 20 6e 65 77 70 74 79 |ity..X11|. newpty|
|00000790| 20 75 73 65 73 20 6d 79 | 20 73 69 67 73 63 68 65 | uses my| sigsche|
|000007a0| 64 20 6c 69 62 72 61 72 | 79 3b 20 74 68 69 73 20 |d librar|y; this |
|000007b0| 67 72 65 61 74 6c 79 20 | 73 69 6d 70 6c 69 66 69 |greatly |simplifi|
|000007c0| 65 73 20 74 68 65 20 63 | 6f 64 65 2e 0a 58 31 32 |es the c|ode..X12|
|000007d0| 2e 20 6e 65 77 70 74 79 | 27 73 20 72 61 6e 64 6f |. newpty|'s rando|
|000007e0| 6d 20 74 74 79 20 73 65 | 61 72 63 68 69 6e 67 20 |m tty se|arching |
|000007f0| 69 73 20 6e 6f 74 20 76 | 75 6c 6e 65 72 61 62 6c |is not v|ulnerabl|
|00000800| 65 20 74 6f 20 73 65 63 | 6f 6e 64 61 72 79 20 63 |e to sec|ondary c|
|00000810| 6c 75 73 74 65 72 69 6e | 67 2e 0a 58 31 33 2e 20 |lusterin|g..X13. |
|00000820| 6e 65 77 70 74 79 20 73 | 75 70 70 6f 72 74 73 20 |newpty s|upports |
|00000830| 73 65 73 73 69 6f 6e 20 | 61 6e 64 20 73 65 73 73 |session |and sess|
|00000840| 69 6f 6e 2d 63 6f 6e 6e | 65 63 74 69 6f 6e 20 6c |ion-conn|ection l|
|00000850| 6f 67 73 20 61 73 20 77 | 65 6c 6c 20 61 73 20 5b |ogs as w|ell as [|
|00000860| 75 77 5d 74 6d 70 2e 0a | 58 31 34 2e 20 6e 65 77 |uw]tmp..|X14. new|
|00000870| 70 74 79 20 6e 6f 77 20 | 6d 61 69 6e 74 61 69 6e |pty now |maintain|
|00000880| 73 20 61 20 73 69 6e 67 | 6c 65 2c 20 72 65 6c 69 |s a sing|le, reli|
|00000890| 61 62 6c 65 20 63 6f 6d | 6d 75 6e 69 63 61 74 69 |able com|municati|
|000008a0| 6f 6e 73 20 66 69 6c 65 | 20 66 6f 72 20 65 61 63 |ons file| for eac|
|000008b0| 68 20 70 74 79 2e 0a 58 | 31 35 2e 20 49 6e 74 65 |h pty..X|15. Inte|
|000008c0| 72 6e 61 6c 6c 79 2c 20 | 74 68 65 20 6d 61 73 74 |rnally, |the mast|
|000008d0| 65 72 20 61 6e 64 20 73 | 69 67 6e 61 6c 6c 65 72 |er and s|ignaller|
|000008e0| 20 61 72 65 20 6d 75 63 | 68 20 6d 6f 72 65 20 63 | are muc|h more c|
|000008f0| 6c 65 61 6e 6c 79 20 73 | 65 70 61 72 61 74 65 64 |leanly s|eparated|
|00000900| 2e 0a 58 31 36 2e 20 6f | 6c 64 70 74 79 27 73 20 |..X16. o|ldpty's |
|00000910| 2d 64 20 73 65 72 76 65 | 64 20 74 77 6f 20 64 69 |-d serve|d two di|
|00000920| 66 66 65 72 65 6e 74 20 | 66 75 6e 63 74 69 6f 6e |fferent |function|
|00000930| 73 2e 20 6e 65 77 70 74 | 79 27 73 20 2d 64 20 69 |s. newpt|y's -d i|
|00000940| 73 20 73 69 6d 70 6c 65 | 72 2e 0a 58 31 37 2e 20 |s simple|r..X17. |
|00000950| 57 68 65 6e 20 6f 6c 64 | 70 74 79 20 72 65 61 63 |When old|pty reac|
|00000960| 68 65 73 20 45 4f 46 20 | 6f 6e 20 69 6e 70 75 74 |hes EOF |on input|
|00000970| 2c 20 69 74 20 6c 6f 6f | 70 73 20 66 6f 72 65 76 |, it loo|ps forev|
|00000980| 65 72 2e 20 6e 65 77 70 | 74 79 20 64 6f 65 73 6e |er. newp|ty doesn|
|00000990| 27 74 2e 0a 58 31 38 2e | 20 6e 65 77 70 74 79 27 |'t..X18.| newpty'|
|000009a0| 73 20 65 72 72 6f 72 20 | 6d 65 73 73 61 67 65 73 |s error |messages|
|000009b0| 20 61 72 65 2c 20 62 65 | 6c 69 65 76 65 20 69 74 | are, be|lieve it|
|000009c0| 20 6f 72 20 6e 6f 74 2c | 20 63 6f 6d 70 72 65 68 | or not,| compreh|
|000009d0| 65 6e 73 69 62 6c 65 2e | 0a 58 31 39 2e 20 6e 65 |ensible.|.X19. ne|
|000009e0| 77 70 74 79 20 6c 65 74 | 73 20 74 68 65 20 75 73 |wpty let|s the us|
|000009f0| 65 72 20 73 65 74 20 68 | 69 73 20 68 6f 73 74 20 |er set h|is host |
|00000a00| 66 69 65 6c 64 20 69 6e | 20 75 74 6d 70 20 28 74 |field in| utmp (t|
|00000a10| 68 69 73 20 69 73 20 63 | 6f 6e 66 69 67 75 72 61 |his is c|onfigura|
|00000a20| 62 6c 65 29 2e 0a 58 32 | 30 2e 20 6e 65 77 70 74 |ble)..X2|0. newpt|
|00000a30| 79 20 67 69 76 65 73 20 | 74 68 65 20 73 6c 61 76 |y gives |the slav|
|00000a40| 65 20 61 20 50 54 59 20 | 76 61 72 69 61 62 6c 65 |e a PTY |variable|
|00000a50| 20 73 68 6f 77 69 6e 67 | 20 69 74 73 20 65 78 74 | showing| its ext|
|00000a60| 65 6e 73 69 6f 6e 20 28 | 65 2e 67 2e 2c 20 70 37 |ension (|e.g., p7|
|00000a70| 29 2e 0a 58 32 31 2e 20 | 41 20 60 60 73 65 73 73 |)..X21. |A ``sess|
|00000a80| 6d 65 6e 75 27 27 20 75 | 74 69 6c 69 74 79 20 63 |menu'' u|tility c|
|00000a90| 61 6e 20 73 65 72 76 65 | 20 61 73 20 61 20 66 72 |an serve| as a fr|
|00000aa0| 69 65 6e 64 6c 79 20 73 | 65 73 73 69 6f 6e 2d 61 |iendly s|ession-a|
|00000ab0| 77 61 72 65 20 6c 6f 67 | 69 6e 20 77 72 61 70 70 |ware log|in wrapp|
|00000ac0| 65 72 2e 0a 58 32 32 2e | 20 6e 65 77 70 74 79 20 |er..X22.| newpty |
|00000ad0| 69 6e 63 6c 75 64 65 73 | 20 60 60 75 74 6d 70 69 |includes| ``utmpi|
|00000ae0| 6e 69 74 27 27 20 74 6f | 20 70 72 6f 70 65 72 6c |nit'' to| properl|
|00000af0| 79 20 69 6e 69 74 69 61 | 6c 69 7a 65 20 2f 65 74 |y initia|lize /et|
|00000b00| 63 2f 75 74 6d 70 2e 0a | 58 32 33 2e 20 41 20 60 |c/utmp..|X23. A `|
|00000b10| 60 6e 6f 62 75 66 27 27 | 20 75 74 69 6c 69 74 79 |`nobuf''| utility|
|00000b20| 20 6e 6f 77 20 70 72 6f | 76 69 64 65 73 20 61 20 | now pro|vides a |
|00000b30| 63 6f 6d 70 6c 65 74 65 | 6c 79 20 74 72 61 6e 73 |complete|ly trans|
|00000b40| 70 61 72 65 6e 74 20 63 | 68 61 6e 6e 65 6c 2e 0a |parent c|hannel..|
|00000b50| 58 0a 58 0a 58 46 75 72 | 74 68 65 72 20 6e 6f 74 |X.X.XFur|ther not|
|00000b60| 65 73 20 6f 6e 20 74 68 | 65 73 65 3a 0a 58 0a 58 |es on th|ese:.X.X|
|00000b70| 31 2e 20 4c 61 72 67 65 | 20 73 65 63 74 69 6f 6e |1. Large| section|
|00000b80| 73 20 6f 66 20 63 6f 64 | 65 20 69 6e 20 6f 6c 64 |s of cod|e in old|
|00000b90| 70 74 79 20 77 65 72 65 | 20 64 65 64 69 63 61 74 |pty were| dedicat|
|00000ba0| 65 64 20 74 6f 20 68 61 | 6e 64 6c 69 6e 67 20 73 |ed to ha|ndling s|
|00000bb0| 79 73 74 65 6d 73 0a 77 | 69 74 68 6f 75 74 20 72 |ystems.w|ithout r|
|00000bc0| 65 6c 69 61 62 6c 65 20 | 66 69 6c 65 20 64 65 73 |eliable |file des|
|00000bd0| 63 72 69 70 74 6f 72 20 | 70 61 73 73 69 6e 67 20 |criptor |passing |
|00000be0| 28 69 2e 65 2e 2c 20 6d | 61 6e 79 20 42 53 44 20 |(i.e., m|any BSD |
|00000bf0| 34 2e 32 20 76 61 72 69 | 61 6e 74 73 29 2e 0a 49 |4.2 vari|ants)..I|
|00000c00| 6e 20 6e 65 77 70 74 79 | 20 74 68 69 73 20 63 6f |n newpty| this co|
|00000c10| 64 65 20 69 73 20 67 6f | 6e 65 2e 20 49 20 73 74 |de is go|ne. I st|
|00000c20| 69 6c 6c 20 77 6f 72 6b | 20 61 72 6f 75 6e 64 20 |ill work| around |
|00000c30| 74 68 65 20 66 64 20 70 | 61 73 73 69 6e 67 20 62 |the fd p|assing b|
|00000c40| 75 67 73 0a 74 68 61 74 | 20 61 70 70 65 61 72 20 |ugs.that| appear |
|00000c50| 69 6e 20 74 68 65 20 6c | 61 74 65 73 74 20 53 75 |in the l|atest Su|
|00000c60| 6e 4f 53 20 61 6e 64 20 | 55 6c 74 72 69 78 20 72 |nOS and |Ultrix r|
|00000c70| 65 6c 65 61 73 65 73 2e | 0a 58 0a 58 32 2e 20 49 |eleases.|.X.X2. I|
|00000c80| 6e 20 6f 6c 64 70 74 79 | 2c 20 49 20 73 70 65 6e |n oldpty|, I spen|
|00000c90| 74 20 61 20 6c 6f 74 20 | 6f 66 20 74 69 6d 65 20 |t a lot |of time |
|00000ca0| 6f 6e 20 6e 6f 6e 2d 62 | 6c 6f 63 6b 69 6e 67 20 |on non-b|locking |
|00000cb0| 49 2f 4f 2e 20 54 68 65 | 72 65 27 73 20 61 20 6c |I/O. The|re's a l|
|00000cc0| 6f 6e 67 0a 61 6e 64 20 | 73 61 64 20 73 74 6f 72 |ong.and |sad stor|
|00000cd0| 79 20 62 65 68 69 6e 64 | 20 74 68 69 73 3b 20 72 |y behind| this; r|
|00000ce0| 65 61 64 20 6f 6e 2e 0a | 58 0a 58 45 76 65 6e 20 |ead on..|X.XEven |
|00000cf0| 74 68 6f 75 67 68 20 65 | 76 65 72 79 20 62 69 74 |though e|very bit|
|00000d00| 20 6f 66 20 73 65 6d 61 | 6e 74 69 63 73 20 6f 66 | of sema|ntics of|
|00000d10| 20 72 65 61 64 28 29 20 | 61 6e 64 20 77 72 69 74 | read() |and writ|
|00000d20| 65 28 29 20 69 73 20 64 | 72 61 73 74 69 63 61 6c |e() is d|rastical|
|00000d30| 6c 79 0a 61 66 66 65 63 | 74 65 64 20 62 79 20 77 |ly.affec|ted by w|
|00000d40| 68 65 74 68 65 72 20 74 | 68 65 20 64 65 73 63 72 |hether t|he descr|
|00000d50| 69 70 74 6f 72 20 69 73 | 20 6e 6f 6e 2d 62 6c 6f |iptor is| non-blo|
|00000d60| 63 6b 69 6e 67 2c 20 55 | 4e 49 58 20 69 6d 70 6c |cking, U|NIX impl|
|00000d70| 65 6d 65 6e 74 6f 72 73 | 0a 74 68 72 6f 75 67 68 |ementors|.through|
|00000d80| 20 74 68 65 20 79 65 61 | 72 73 20 68 61 76 65 20 | the yea|rs have |
|00000d90| 61 6c 77 61 79 73 2d 2d | 2d 49 20 6d 65 61 6e 20 |always--|-I mean |
|00000da0| 2a 61 6c 77 61 79 73 2a | 2d 2d 2d 70 72 6f 76 69 |*always*|---provi|
|00000db0| 64 65 64 20 66 6f 72 0a | 6e 6f 6e 2d 62 6c 6f 63 |ded for.|non-bloc|
|00000dc0| 6b 69 6e 67 20 49 2f 4f | 20 6f 6e 20 61 20 67 69 |king I/O| on a gi|
|00000dd0| 76 65 6e 20 6f 70 65 6e | 20 66 69 6c 65 2c 20 72 |ven open| file, r|
|00000de0| 61 74 68 65 72 20 74 68 | 61 6e 20 6f 6e 20 61 20 |ather th|an on a |
|00000df0| 70 61 72 74 69 63 75 6c | 61 72 0a 64 65 73 63 72 |particul|ar.descr|
|00000e00| 69 70 74 6f 72 2e 20 54 | 68 69 73 20 69 73 20 66 |iptor. T|his is f|
|00000e10| 69 6e 65 20 66 6f 72 20 | 70 72 6f 67 72 61 6d 73 |ine for |programs|
|00000e20| 20 77 68 69 63 68 20 6f | 70 65 6e 20 74 68 65 69 | which o|pen thei|
|00000e30| 72 20 6f 77 6e 20 64 65 | 73 63 72 69 70 74 6f 72 |r own de|scriptor|
|00000e40| 73 2e 0a 42 75 74 20 70 | 74 79 20 68 61 73 20 74 |s..But p|ty has t|
|00000e50| 6f 20 64 6f 20 49 2f 4f | 20 6f 6e 20 69 6e 70 75 |o do I/O| on inpu|
|00000e60| 74 20 61 6e 64 20 6f 75 | 74 70 75 74 20 64 65 73 |t and ou|tput des|
|00000e70| 63 72 69 70 74 6f 72 73 | 20 77 68 69 63 68 20 73 |criptors| which s|
|00000e80| 6f 6d 65 6f 6e 65 20 65 | 6c 73 65 0a 68 61 73 20 |omeone e|lse.has |
|00000e90| 73 65 74 20 75 70 2e 20 | 49 74 20 63 61 6e 27 74 |set up. |It can't|
|00000ea0| 20 73 65 74 20 4e 44 45 | 4c 41 59 20 6f 6e 20 74 | set NDE|LAY on t|
|00000eb0| 68 6f 73 65 20 64 65 73 | 63 72 69 70 74 6f 72 73 |hose des|criptors|
|00000ec0| 2c 20 62 65 63 61 75 73 | 65 20 61 6e 6f 74 68 65 |, becaus|e anothe|
|00000ed0| 72 0a 69 6e 6e 6f 63 65 | 6e 74 20 70 72 6f 67 72 |r.innoce|nt progr|
|00000ee0| 61 6d 20 6d 69 67 68 74 | 20 62 65 20 72 65 61 64 |am might| be read|
|00000ef0| 69 6e 67 20 6f 72 20 77 | 72 69 74 69 6e 67 20 74 |ing or w|riting t|
|00000f00| 68 65 20 73 61 6d 65 20 | 64 65 73 63 72 69 70 74 |he same |descript|
|00000f10| 6f 72 73 2c 20 61 6e 64 | 0a 4e 44 45 4c 41 59 20 |ors, and|.NDELAY |
|00000f20| 77 69 6c 6c 20 69 6e 20 | 61 6c 6c 20 70 72 6f 62 |will in |all prob|
|00000f30| 61 62 69 6c 69 74 79 20 | 6d 61 6b 65 20 74 68 61 |ability |make tha|
|00000f40| 74 20 70 72 6f 67 72 61 | 6d 20 67 6f 20 69 6e 74 |t progra|m go int|
|00000f50| 6f 20 61 6e 20 69 6e 66 | 69 6e 69 74 65 0a 6c 6f |o an inf|inite.lo|
|00000f60| 6f 70 21 0a 58 0a 4f 66 | 20 63 6f 75 72 73 65 2c |op!.X.Of| course,|
|00000f70| 20 77 68 61 74 20 6d 6f | 73 74 20 70 65 6f 70 6c | what mo|st peopl|
|00000f80| 65 20 64 6f 20 69 73 20 | 6a 75 73 74 20 73 65 6c |e do is |just sel|
|00000f90| 65 63 74 28 29 20 66 6f | 72 20 72 65 61 64 61 62 |ect() fo|r readab|
|00000fa0| 69 6c 69 74 79 20 6f 72 | 0a 77 72 69 74 61 62 69 |ility or|.writabi|
|00000fb0| 6c 69 74 79 2c 20 74 68 | 65 6e 20 61 73 73 75 6d |lity, th|en assum|
|00000fc0| 65 20 74 68 65 20 6f 70 | 65 72 61 74 69 6f 6e 73 |e the op|erations|
|00000fd0| 20 77 6f 6e 27 74 20 62 | 6c 6f 63 6b 2e 20 54 68 | won't b|lock. Th|
|00000fe0| 65 20 70 72 6f 62 6c 65 | 6d 20 69 73 20 74 68 61 |e proble|m is tha|
|00000ff0| 74 0a 74 68 65 79 20 6d | 69 67 68 74 20 62 6c 6f |t.they m|ight blo|
|00001000| 63 6b 2e 20 42 79 20 74 | 68 65 20 74 69 6d 65 20 |ck. By t|he time |
|00001010| 70 74 79 20 67 65 74 73 | 20 61 72 6f 75 6e 64 20 |pty gets| around |
|00001020| 74 6f 20 72 65 61 64 69 | 6e 67 2c 20 73 6f 6d 65 |to readi|ng, some|
|00001030| 6f 6e 65 20 65 6c 73 65 | 0a 63 6f 75 6c 64 20 68 |one else|.could h|
|00001040| 61 76 65 20 72 65 61 64 | 20 74 68 65 20 69 6e 70 |ave read| the inp|
|00001050| 75 74 20 77 68 69 63 68 | 20 63 61 75 73 65 64 20 |ut which| caused |
|00001060| 73 65 6c 65 63 74 28 29 | 20 74 6f 20 72 65 74 75 |select()| to retu|
|00001070| 72 6e 2e 20 53 69 6d 69 | 6c 61 72 6c 79 2c 0a 61 |rn. Simi|larly,.a|
|00001080| 6e 79 20 77 72 69 74 65 | 20 6f 66 20 4e 20 62 79 |ny write| of N by|
|00001090| 74 65 73 20 74 6f 20 61 | 20 70 69 70 65 20 77 69 |tes to a| pipe wi|
|000010a0| 74 68 20 4d 20 62 79 74 | 65 73 20 66 72 65 65 2c |th M byt|es free,|
|000010b0| 20 77 69 74 68 20 4e 20 | 3e 20 4d 20 3e 20 30 2c | with N |> M > 0,|
|000010c0| 20 77 69 6c 6c 0a 62 6c | 6f 63 6b 2c 20 65 76 65 | will.bl|ock, eve|
|000010d0| 6e 20 74 68 6f 75 67 68 | 20 73 65 6c 65 63 74 20 |n though| select |
|000010e0| 77 69 6c 6c 20 72 65 74 | 75 72 6e 20 74 72 75 65 |will ret|urn true|
|000010f0| 2e 20 53 6f 20 49 20 66 | 69 67 75 72 65 64 20 6f |. So I f|igured o|
|00001100| 75 74 20 61 20 77 61 79 | 20 74 6f 0a 61 63 68 69 |ut a way| to.achi|
|00001110| 65 76 65 20 74 72 75 65 | 20 70 65 72 2d 70 72 6f |eve true| per-pro|
|00001120| 63 65 73 73 20 6e 6f 6e | 2d 62 6c 6f 63 6b 69 6e |cess non|-blockin|
|00001130| 67 20 49 2f 4f 3a 20 73 | 69 6d 70 6c 79 20 61 72 |g I/O: s|imply ar|
|00001140| 72 61 6e 67 65 20 66 6f | 72 20 53 49 47 41 4c 52 |range fo|r SIGALR|
|00001150| 4d 20 74 6f 0a 62 65 20 | 73 65 6e 74 20 65 76 65 |M to.be |sent eve|
|00001160| 72 79 20 66 72 61 63 74 | 69 6f 6e 20 6f 66 20 61 |ry fract|ion of a|
|00001170| 20 73 65 63 6f 6e 64 2c | 20 69 6e 74 65 72 72 75 | second,| interru|
|00001180| 70 74 69 6e 67 20 61 6e | 79 20 62 6c 6f 63 6b 69 |pting an|y blocki|
|00001190| 6e 67 20 72 65 61 64 28 | 29 20 6f 72 0a 77 72 69 |ng read(|) or.wri|
|000011a0| 74 65 28 29 2e 20 54 68 | 69 73 20 77 6f 72 6b 73 |te(). Th|is works|
|000011b0| 2d 2d 2d 62 75 74 20 6e | 6f 74 20 75 6e 64 65 72 |---but n|ot under|
|000011c0| 20 42 53 44 20 34 2e 32 | 2c 20 77 68 69 63 68 20 | BSD 4.2|, which |
|000011d0| 72 65 73 74 61 72 74 73 | 20 73 79 73 74 65 6d 0a |restarts| system.|
|000011e0| 63 61 6c 6c 73 2e 20 6f | 6c 64 70 74 79 27 73 20 |calls. o|ldpty's |
|000011f0| 63 6f 6e 66 69 67 75 72 | 61 74 69 6f 6e 20 70 72 |configur|ation pr|
|00001200| 6f 63 65 73 73 20 72 65 | 66 6c 65 63 74 65 64 20 |ocess re|flected |
|00001210| 74 68 69 73 20 65 78 74 | 72 61 20 63 6f 6d 70 6c |this ext|ra compl|
|00001220| 65 78 69 74 79 2e 0a 58 | 0a 4e 6f 77 20 49 27 76 |exity..X|.Now I'v|
|00001230| 65 20 73 65 65 6e 20 74 | 68 65 20 6c 69 67 68 74 |e seen t|he light|
|00001240| 2e 20 54 72 75 65 20 6e | 6f 6e 2d 62 6c 6f 63 6b |. True n|on-block|
|00001250| 69 6e 67 20 49 2f 4f 20 | 62 65 20 64 61 6d 6e 65 |ing I/O |be damne|
|00001260| 64 2e 20 49 27 6d 20 6a | 75 73 74 20 67 6f 69 6e |d. I'm j|ust goin|
|00001270| 67 0a 74 6f 20 73 65 6c | 65 63 74 28 29 20 61 6e |g.to sel|ect() an|
|00001280| 64 20 64 6f 20 6d 79 20 | 6f 70 65 72 61 74 69 6f |d do my |operatio|
|00001290| 6e 73 20 6c 69 6b 65 20 | 65 76 65 72 79 6f 6e 65 |ns like |everyone|
|000012a0| 20 65 6c 73 65 2e 20 49 | 74 27 73 20 6e 6f 74 20 | else. I|t's not |
|000012b0| 6d 79 20 66 61 75 6c 74 | 0a 74 68 61 74 20 73 6f |my fault|.that so|
|000012c0| 20 66 65 77 20 69 6d 70 | 6c 65 6d 65 6e 74 6f 72 | few imp|lementor|
|000012d0| 73 20 75 6e 64 65 72 73 | 74 61 6e 64 20 77 68 79 |s unders|tand why|
|000012e0| 20 6e 6f 6e 2d 62 6c 6f | 63 6b 69 6e 67 20 49 2f | non-blo|cking I/|
|000012f0| 4f 20 6f 6e 20 61 6e 20 | 65 6e 74 69 72 65 0a 6f |O on an |entire.o|
|00001300| 70 65 6e 20 66 69 6c 65 | 2c 20 72 61 74 68 65 72 |pen file|, rather|
|00001310| 20 74 68 61 6e 20 61 20 | 70 61 72 74 69 63 75 6c | than a |particul|
|00001320| 61 72 20 64 65 73 63 72 | 69 70 74 6f 72 2c 20 69 |ar descr|iptor, i|
|00001330| 73 20 73 6f 20 75 73 65 | 6c 65 73 73 2e 20 49 66 |s so use|less. If|
|00001340| 20 65 6d 61 63 73 0a 61 | 6e 64 20 73 63 72 65 65 | emacs.a|nd scree|
|00001350| 6e 20 61 6e 64 20 73 6f | 20 6d 61 6e 79 20 6f 74 |n and so| many ot|
|00001360| 68 65 72 20 70 72 6f 67 | 72 61 6d 73 20 64 6f 6e |her prog|rams don|
|00001370| 27 74 20 63 61 72 65 2c | 20 49 20 77 6f 6e 27 74 |'t care,| I won't|
|00001380| 20 65 69 74 68 65 72 2e | 20 6e 65 77 70 74 79 0a | either.| newpty.|
|00001390| 74 61 6b 65 73 20 6e 6f | 6e 65 20 6f 66 20 6f 6c |takes no|ne of ol|
|000013a0| 64 70 74 79 27 73 20 70 | 72 65 63 61 75 74 69 6f |dpty's p|recautio|
|000013b0| 6e 73 2c 20 61 6e 64 20 | 69 66 20 69 74 20 65 76 |ns, and |if it ev|
|000013c0| 65 72 20 62 6c 6f 63 6b | 73 20 62 65 63 61 75 73 |er block|s becaus|
|000013d0| 65 20 61 20 70 69 70 65 | 0a 69 73 20 74 6f 6f 20 |e a pipe|.is too |
|000013e0| 66 75 6c 6c 20 6f 72 20 | 62 65 63 61 75 73 65 20 |full or |because |
|000013f0| 74 68 65 72 65 20 61 72 | 65 20 6d 75 6c 74 69 70 |there ar|e multip|
|00001400| 6c 65 20 72 65 61 64 65 | 72 73 2c 20 64 6f 6e 27 |le reade|rs, don'|
|00001410| 74 20 62 6c 61 6d 65 20 | 6d 65 2e 20 42 6c 61 6d |t blame |me. Blam|
|00001420| 65 0a 61 20 74 72 75 6c | 79 20 73 65 6e 73 65 6c |e.a trul|y sensel|
|00001430| 65 73 73 20 4f 53 20 64 | 65 73 69 67 6e 20 64 65 |ess OS d|esign de|
|00001440| 63 69 73 69 6f 6e 2e 0a | 58 0a 58 33 2e 20 41 6c |cision..|X.X3. Al|
|00001450| 6c 20 42 53 44 20 76 61 | 72 69 61 6e 74 73 20 68 |l BSD va|riants h|
|00001460| 61 76 65 20 61 20 6d 61 | 78 69 6d 75 6d 20 70 72 |ave a ma|ximum pr|
|00001470| 6f 63 65 73 73 20 6c 69 | 6d 69 74 2c 20 4d 41 58 |ocess li|mit, MAX|
|00001480| 55 50 52 43 20 6f 72 20 | 6d 61 78 75 70 72 63 20 |UPRC or |maxuprc |
|00001490| 69 6e 0a 58 3c 73 79 73 | 2f 70 61 72 61 6d 2e 68 |in.X<sys|/param.h|
|000014a0| 3e 2e 20 57 68 65 6e 20 | 74 68 65 72 65 20 61 72 |>. When |there ar|
|000014b0| 65 20 4d 41 58 55 50 52 | 43 20 70 72 6f 63 65 73 |e MAXUPR|C proces|
|000014c0| 73 65 73 20 77 69 74 68 | 20 73 6f 6d 65 20 75 69 |ses with| some ui|
|000014d0| 64 20 28 6f 74 68 65 72 | 0a 74 68 61 6e 20 30 29 |d (other|.than 0)|
|000014e0| 2c 20 74 68 65 20 6e 65 | 78 74 20 66 6f 72 6b 28 |, the ne|xt fork(|
|000014f0| 29 20 62 79 20 74 68 61 | 74 20 75 69 64 20 77 69 |) by tha|t uid wi|
|00001500| 6c 6c 20 66 61 69 6c 2e | 20 41 20 62 69 74 20 6f |ll fail.| A bit o|
|00001510| 66 20 74 68 6f 75 67 68 | 74 20 77 69 6c 6c 0a 63 |f though|t will.c|
|00001520| 6f 6e 76 69 6e 63 65 20 | 79 6f 75 20 74 68 61 74 |onvince |you that|
|00001530| 20 4d 41 58 55 50 52 43 | 20 73 68 6f 75 6c 64 20 | MAXUPRC| should |
|00001540| 61 70 70 6c 79 20 74 6f | 20 74 68 65 20 72 65 61 |apply to| the rea|
|00001550| 6c 20 75 69 64 2e 20 49 | 66 20 69 74 20 61 70 70 |l uid. I|f it app|
|00001560| 6c 69 65 64 20 74 6f 0a | 74 68 65 20 65 66 66 65 |lied to.|the effe|
|00001570| 63 74 69 76 65 20 75 69 | 64 2c 20 74 68 65 6e 20 |ctive ui|d, then |
|00001580| 69 74 20 77 6f 75 6c 64 | 20 61 66 66 65 63 74 20 |it would| affect |
|00001590| 65 78 65 63 76 65 28 29 | 20 6f 66 20 73 65 74 75 |execve()| of setu|
|000015a0| 69 64 20 70 72 6f 67 72 | 61 6d 73 2e 0a 58 45 76 |id progr|ams..XEv|
|000015b0| 65 6e 20 77 6f 72 73 65 | 2c 20 69 66 20 79 6f 75 |en worse|, if you|
|000015c0| 20 68 61 64 20 61 20 70 | 72 6f 67 72 61 6d 20 73 | had a p|rogram s|
|000015d0| 65 74 75 69 64 20 28 73 | 61 79 29 20 69 6e 67 72 |etuid (s|ay) ingr|
|000015e0| 65 73 2c 20 61 6e 64 20 | 4d 41 58 55 50 52 43 20 |es, and |MAXUPRC |
|000015f0| 75 73 65 72 73 0a 72 61 | 6e 20 74 68 61 74 20 70 |users.ra|n that p|
|00001600| 72 6f 67 72 61 6d 20 61 | 74 20 6f 6e 63 65 2c 20 |rogram a|t once, |
|00001610| 6e 6f 20 6f 74 68 65 72 | 20 75 73 65 72 73 20 77 |no other| users w|
|00001620| 6f 75 6c 64 20 62 65 20 | 61 62 6c 65 20 74 6f 20 |ould be |able to |
|00001630| 72 75 6e 20 69 74 21 20 | 53 6f 0a 61 70 70 6c 79 |run it! |So.apply|
|00001640| 69 6e 67 20 4d 41 58 55 | 50 52 43 20 74 6f 20 74 |ing MAXU|PRC to t|
|00001650| 68 65 20 65 66 66 65 63 | 74 69 76 65 20 75 69 64 |he effec|tive uid|
|00001660| 20 69 73 20 61 20 72 65 | 61 6c 6c 79 20 62 61 64 | is a re|ally bad|
|00001670| 20 69 64 65 61 2e 0a 58 | 0a 47 75 65 73 73 20 77 | idea..X|.Guess w|
|00001680| 68 61 74 3f 20 41 6c 6d | 6f 73 74 20 61 6c 6c 20 |hat? Alm|ost all |
|00001690| 76 65 6e 64 6f 72 73 20 | 68 61 76 65 20 61 70 70 |vendors |have app|
|000016a0| 6c 69 65 64 20 4d 41 58 | 55 50 52 43 20 74 6f 20 |lied MAX|UPRC to |
|000016b0| 74 68 65 20 65 66 66 65 | 63 74 69 76 65 0a 75 69 |the effe|ctive.ui|
|000016c0| 64 2e 20 4f 6e 20 74 68 | 65 20 6f 74 68 65 72 20 |d. On th|e other |
|000016d0| 68 61 6e 64 2c 20 66 65 | 77 20 6f 66 20 74 68 65 |hand, fe|w of the|
|000016e0| 6d 20 68 61 76 65 20 70 | 61 69 64 20 61 6e 79 20 |m have p|aid any |
|000016f0| 61 74 74 65 6e 74 69 6f | 6e 20 74 6f 20 65 78 65 |attentio|n to exe|
|00001700| 63 76 65 28 29 0a 6f 66 | 20 73 65 74 75 69 64 20 |cve().of| setuid |
|00001710| 70 72 6f 67 72 61 6d 73 | 2c 20 73 6f 20 69 6e 20 |programs|, so in |
|00001720| 74 68 65 20 69 6e 67 72 | 65 73 20 63 61 73 65 20 |the ingr|es case |
|00001730| 61 6e 79 20 6e 75 6d 62 | 65 72 20 6f 66 20 75 73 |any numb|er of us|
|00001740| 65 72 73 20 63 61 6e 20 | 72 75 6e 0a 74 68 65 20 |ers can |run.the |
|00001750| 70 72 6f 67 72 61 6d 2c | 20 64 72 61 67 67 69 6e |program,| draggin|
|00001760| 67 20 74 68 65 20 70 72 | 6f 63 65 73 73 20 63 6f |g the pr|ocess co|
|00001770| 75 6e 74 20 77 61 79 20 | 61 62 6f 76 65 20 4d 41 |unt way |above MA|
|00001780| 58 55 50 52 43 2e 20 49 | 66 20 79 6f 75 20 68 61 |XUPRC. I|f you ha|
|00001790| 76 65 0a 61 6e 79 20 65 | 78 70 65 72 69 65 6e 63 |ve.any e|xperienc|
|000017a0| 65 20 69 6e 20 63 72 61 | 73 68 69 6e 67 20 55 4e |e in cra|shing UN|
|000017b0| 49 58 20 73 79 73 74 65 | 6d 73 20 79 6f 75 27 6c |IX syste|ms you'l|
|000017c0| 6c 20 67 75 65 73 73 20 | 77 68 61 74 20 49 27 6d |l guess |what I'm|
|000017d0| 20 61 62 6f 75 74 20 74 | 6f 0a 73 61 79 3a 20 49 | about t|o.say: I|
|000017e0| 66 20 74 68 65 20 70 72 | 6f 63 65 73 73 20 63 6f |f the pr|ocess co|
|000017f0| 75 6e 74 20 66 6f 72 20 | 61 20 75 69 64 20 64 6f |unt for |a uid do|
|00001800| 65 73 20 67 6f 20 61 62 | 6f 76 65 20 4d 41 58 55 |es go ab|ove MAXU|
|00001810| 50 52 43 2c 20 74 68 65 | 6e 20 61 73 20 73 6f 6f |PRC, the|n as soo|
|00001820| 6e 0a 61 73 20 4d 41 58 | 55 50 52 43 20 6f 66 20 |n.as MAX|UPRC of |
|00001830| 74 68 6f 73 65 20 70 72 | 6f 63 65 73 73 65 73 20 |those pr|ocesses |
|00001840| 64 69 65 2c 20 74 68 65 | 20 73 79 73 74 65 6d 20 |die, the| system |
|00001850| 77 69 6c 6c 20 70 61 6e | 69 63 2e 20 28 54 68 69 |will pan|ic. (Thi|
|00001860| 73 20 69 73 20 74 72 75 | 65 0a 75 6e 64 65 72 2c |s is tru|e.under,|
|00001870| 20 65 2e 67 2e 2c 20 55 | 6c 74 72 69 78 2e 29 20 | e.g., U|ltrix.) |
|00001880| 42 72 69 6c 6c 69 61 6e | 74 2e 0a 58 0a 41 73 20 |Brillian|t..X.As |
|00001890| 79 6f 75 20 63 61 6e 20 | 69 6d 61 67 69 6e 65 2c |you can |imagine,|
|000018a0| 20 6e 6f 6e 65 20 6f 66 | 20 74 68 69 73 20 69 73 | none of| this is|
|000018b0| 20 63 6f 6e 64 75 63 69 | 76 65 20 74 6f 20 73 61 | conduci|ve to sa|
|000018c0| 66 65 20 73 65 74 75 69 | 64 0a 70 72 6f 67 72 61 |fe setui|d.progra|
|000018d0| 6d 6d 69 6e 67 2e 20 53 | 79 73 74 65 6d 20 70 61 |mming. S|ystem pa|
|000018e0| 6e 69 63 73 20 61 73 69 | 64 65 2c 20 70 74 79 20 |nics asi|de, pty |
|000018f0| 68 61 73 20 74 6f 20 66 | 6f 72 6b 20 74 77 69 63 |has to f|ork twic|
|00001900| 65 2c 20 61 6e 64 20 49 | 20 64 69 64 6e 27 74 0a |e, and I| didn't.|
|00001910| 77 61 6e 74 20 74 6f 20 | 6c 69 6d 69 74 20 69 74 |want to |limit it|
|00001920| 20 74 6f 20 4d 41 58 55 | 50 52 43 2f 32 20 73 69 | to MAXU|PRC/2 si|
|00001930| 6d 75 6c 74 61 6e 65 6f | 75 73 20 69 6e 76 6f 63 |multaneo|us invoc|
|00001940| 61 74 69 6f 6e 73 2e 20 | 53 6f 20 6f 6c 64 70 74 |ations. |So oldpt|
|00001950| 79 20 73 77 61 70 73 0a | 69 74 73 20 75 69 64 20 |y swaps.|its uid |
|00001960| 61 6e 64 20 65 75 69 64 | 20 61 72 6f 75 6e 64 20 |and euid| around |
|00001970| 65 61 63 68 20 66 6f 72 | 6b 2e 0a 58 0a 54 68 69 |each for|k..X.Thi|
|00001980| 73 20 69 6e 74 72 6f 64 | 75 63 65 73 20 69 74 73 |s introd|uces its|
|00001990| 20 6f 77 6e 20 73 65 74 | 20 6f 66 20 70 72 6f 62 | own set| of prob|
|000019a0| 6c 65 6d 73 2e 20 46 69 | 72 73 74 2c 20 74 68 65 |lems. Fi|rst, the|
|000019b0| 20 6d 6f 6d 65 6e 74 20 | 61 20 73 65 74 75 69 64 | moment |a setuid|
|000019c0| 0a 70 72 6f 67 72 61 6d | 20 64 6f 65 73 20 73 65 |.program| does se|
|000019d0| 74 72 65 75 69 64 28 67 | 65 74 65 75 69 64 28 29 |treuid(g|eteuid()|
|000019e0| 2c 67 65 74 75 69 64 28 | 29 29 2c 20 69 74 20 6f |,getuid(|)), it o|
|000019f0| 70 65 6e 73 20 69 74 73 | 65 6c 66 20 75 70 20 74 |pens its|elf up t|
|00001a00| 6f 20 70 74 72 61 63 65 | 73 0a 62 79 20 74 68 65 |o ptrace|s.by the|
|00001a10| 20 28 6f 72 69 67 69 6e | 61 6c 29 20 72 65 61 6c | (origin|al) real|
|00001a20| 20 75 69 64 2e 20 54 68 | 65 6e 20 61 6c 6c 20 73 | uid. Th|en all s|
|00001a30| 65 63 75 72 69 74 79 20 | 69 73 20 6c 6f 73 74 2e |ecurity |is lost.|
|00001a40| 20 53 65 63 6f 6e 64 2c | 20 74 68 69 73 0a 73 77 | Second,| this.sw|
|00001a50| 61 70 70 69 6e 67 20 69 | 73 20 75 74 74 65 72 6c |apping i|s utterl|
|00001a60| 79 20 70 6f 69 6e 74 6c | 65 73 73 20 6f 6e 20 73 |y pointl|ess on s|
|00001a70| 79 73 74 65 6d 73 20 77 | 69 74 68 20 61 20 73 61 |ystems w|ith a sa|
|00001a80| 6e 65 20 4d 41 58 55 50 | 52 43 20 62 61 73 65 64 |ne MAXUP|RC based|
|00001a90| 20 6f 6e 0a 72 65 61 6c | 20 75 69 64 73 2e 20 46 | on.real| uids. F|
|00001aa0| 69 6e 61 6c 6c 79 2c 20 | 49 20 68 61 76 65 6e 27 |inally, |I haven'|
|00001ab0| 74 20 73 65 65 6e 20 61 | 6e 79 6f 6e 65 20 65 6c |t seen a|nyone el|
|00001ac0| 73 65 20 65 76 65 6e 20 | 63 6f 6e 73 69 64 65 72 |se even |consider|
|00001ad0| 69 6e 67 20 74 68 69 73 | 0a 69 73 73 75 65 2c 20 |ing this|.issue, |
|00001ae0| 6c 65 74 20 61 6c 6f 6e | 65 20 69 6d 70 6c 65 6d |let alon|e implem|
|00001af0| 65 6e 74 69 6e 67 20 77 | 6f 72 6b 61 72 6f 75 6e |enting w|orkaroun|
|00001b00| 64 73 2e 0a 58 0a 53 6f | 20 6f 6e 63 65 20 61 67 |ds..X.So| once ag|
|00001b10| 61 69 6e 20 49 27 76 65 | 20 6a 6f 69 6e 65 64 20 |ain I've| joined |
|00001b20| 74 68 65 20 63 72 6f 77 | 64 2e 20 6e 65 77 70 74 |the crow|d. newpt|
|00001b30| 79 20 70 72 65 74 65 6e | 64 73 20 74 68 61 74 20 |y preten|ds that |
|00001b40| 70 72 6f 63 65 73 73 20 | 6c 69 6d 69 74 73 0a 64 |process |limits.d|
|00001b50| 6f 6e 27 74 20 65 78 69 | 73 74 2e 20 49 66 20 69 |on't exi|st. If i|
|00001b60| 74 20 66 61 69 6c 73 20 | 6d 69 73 65 72 61 62 6c |t fails |miserabl|
|00001b70| 79 2c 20 6f 72 20 79 6f | 75 72 20 73 79 73 74 65 |y, or yo|ur syste|
|00001b80| 6d 20 63 72 61 73 68 65 | 73 2c 20 6a 75 73 74 20 |m crashe|s, just |
|00001b90| 62 65 63 61 75 73 65 0a | 74 6f 6f 20 6d 61 6e 79 |because.|too many|
|00001ba0| 20 75 73 65 72 73 20 72 | 75 6e 20 73 65 74 75 69 | users r|un setui|
|00001bb0| 64 20 70 72 6f 67 72 61 | 6d 73 20 61 74 20 6f 6e |d progra|ms at on|
|00001bc0| 63 65 2c 20 62 6c 61 6d | 65 20 61 6e 20 4f 53 20 |ce, blam|e an OS |
|00001bd0| 64 65 73 69 67 6e 20 64 | 65 63 69 73 69 6f 6e 0a |design d|ecision.|
|00001be0| 61 73 20 73 65 6e 73 65 | 6c 65 73 73 20 61 73 20 |as sense|less as |
|00001bf0| 74 68 65 20 6c 61 63 6b | 20 6f 66 20 70 65 72 2d |the lack| of per-|
|00001c00| 64 65 73 63 72 69 70 74 | 6f 72 20 6e 6f 6e 2d 62 |descript|or non-b|
|00001c10| 6c 6f 63 6b 69 6e 67 20 | 49 2f 4f 2e 0a 58 0a 58 |locking |I/O..X.X|
|00001c20| 35 2e 20 54 68 65 20 78 | 2a 20 75 74 69 6c 69 74 |5. The x|* utilit|
|00001c30| 69 65 73 20 61 6e 64 20 | 2d 78 53 20 61 72 65 20 |ies and |-xS are |
|00001c40| 67 6f 6e 65 20 62 65 63 | 61 75 73 65 20 69 74 20 |gone bec|ause it |
|00001c50| 77 61 73 20 65 61 73 69 | 65 72 20 69 6e 20 70 72 |was easi|er in pr|
|00001c60| 61 63 74 69 63 65 0a 66 | 6f 72 20 75 6e 70 72 69 |actice.f|or unpri|
|00001c70| 76 69 6c 65 67 65 64 20 | 75 73 65 72 73 20 74 6f |vileged |users to|
|00001c80| 20 69 6e 73 74 61 6c 6c | 20 74 68 65 69 72 20 6f | install| their o|
|00001c90| 77 6e 20 63 6f 70 69 65 | 73 20 6f 66 20 70 74 79 |wn copie|s of pty|
|00001ca0| 20 72 61 74 68 65 72 20 | 74 68 61 6e 0a 75 73 65 | rather |than.use|
|00001cb0| 20 74 68 65 20 73 79 73 | 74 65 6d 20 63 6f 70 79 | the sys|tem copy|
|00001cc0| 20 69 6e 20 73 6f 6d 65 | 20 77 65 69 72 64 20 6d | in some| weird m|
|00001cd0| 6f 64 65 2e 0a 58 0a 58 | 31 30 2e 20 57 69 74 68 |ode..X.X|10. With|
|00001ce0| 20 74 68 65 20 64 65 66 | 61 75 6c 74 20 73 65 74 | the def|ault set|
|00001cf0| 74 69 6e 67 73 2c 20 6f | 6c 64 70 74 79 20 77 6f |tings, o|ldpty wo|
|00001d00| 75 6c 64 20 64 65 74 65 | 63 74 20 77 68 65 6e 20 |uld dete|ct when |
|00001d10| 73 6f 6d 65 6f 6e 65 20 | 65 6c 73 65 20 68 61 64 |someone |else had|
|00001d20| 0a 74 68 65 20 74 74 79 | 20 6f 70 65 6e 2e 20 28 |.the tty| open. (|
|00001d30| 45 73 73 65 6e 74 69 61 | 6c 6c 79 20 74 68 65 20 |Essentia|lly the |
|00001d40| 73 61 6d 65 20 74 65 73 | 74 20 61 70 70 65 61 72 |same tes|t appear|
|00001d50| 65 64 20 73 65 76 65 72 | 61 6c 20 6d 6f 6e 74 68 |ed sever|al month|
|00001d60| 73 20 6c 61 74 65 72 0a | 69 6e 20 61 20 60 60 63 |s later.|in a ``c|
|00001d70| 72 69 74 69 63 61 6c 27 | 27 20 74 65 6c 6e 65 74 |ritical'|' telnet|
|00001d80| 64 2f 72 6c 6f 67 69 6e | 64 20 73 65 63 75 72 69 |d/rlogin|d securi|
|00001d90| 74 79 20 70 61 74 63 68 | 20 66 72 6f 6d 20 53 75 |ty patch| from Su|
|00001da0| 6e 2e 29 20 54 68 65 72 | 65 20 77 65 72 65 0a 74 |n.) Ther|e were.t|
|00001db0| 77 6f 20 70 72 6f 62 6c | 65 6d 73 3a 20 66 69 72 |wo probl|ems: fir|
|00001dc0| 73 74 2c 20 69 6e 20 61 | 20 63 6f 6d 6d 6f 6e 20 |st, in a| common |
|00001dd0| 63 61 73 65 2c 20 70 74 | 79 20 77 6f 75 6c 64 20 |case, pt|y would |
|00001de0| 65 6e 64 20 75 70 20 64 | 79 69 6e 67 20 69 6e 73 |end up d|ying ins|
|00001df0| 74 65 61 64 0a 6f 66 20 | 73 69 6d 70 6c 79 20 74 |tead.of |simply t|
|00001e00| 72 79 69 6e 67 20 61 6e | 6f 74 68 65 72 20 74 74 |rying an|other tt|
|00001e10| 79 3b 20 73 65 63 6f 6e | 64 2c 20 74 68 65 20 74 |y; secon|d, the t|
|00001e20| 65 73 74 20 63 61 6e 20 | 62 65 20 64 65 66 65 61 |est can |be defea|
|00001e30| 74 65 64 20 77 69 74 68 | 6f 75 74 0a 74 6f 6f 20 |ted with|out.too |
|00001e40| 6d 75 63 68 20 74 72 6f | 75 62 6c 65 20 28 74 68 |much tro|uble (th|
|00001e50| 6f 75 67 68 20 61 66 74 | 65 72 20 74 68 65 73 65 |ough aft|er these|
|00001e60| 20 79 65 61 72 73 20 49 | 27 6d 20 6e 6f 74 20 73 | years I|'m not s|
|00001e70| 75 72 65 20 74 68 65 72 | 65 20 61 72 65 20 6d 6f |ure ther|e are mo|
|00001e80| 72 65 0a 74 68 61 6e 20 | 61 20 66 65 77 20 64 6f |re.than |a few do|
|00001e90| 7a 65 6e 20 70 65 6f 70 | 6c 65 20 69 6e 20 74 68 |zen peop|le in th|
|00001ea0| 65 20 77 6f 72 6c 64 20 | 77 68 6f 20 6b 6e 6f 77 |e world |who know|
|00001eb0| 20 68 6f 77 20 74 6f 20 | 65 78 70 6c 6f 69 74 20 | how to |exploit |
|00001ec0| 74 68 69 73 29 2e 0a 58 | 0a 70 74 79 20 34 2e 30 |this)..X|.pty 4.0|
|00001ed0| 20 75 73 65 73 20 61 20 | 6d 75 63 68 20 6d 6f 72 | uses a |much mor|
|00001ee0| 65 20 72 65 6c 69 61 62 | 6c 65 20 74 65 73 74 2d |e reliab|le test-|
|00001ef0| 2d 2d 69 74 27 73 20 6e | 6f 77 20 6d 6f 72 65 20 |--it's n|ow more |
|00001f00| 73 65 63 75 72 65 20 74 | 68 61 6e 20 74 68 65 0a |secure t|han the.|
|00001f10| 74 65 73 74 73 20 75 73 | 65 64 20 62 79 20 53 75 |tests us|ed by Su|
|00001f20| 6e 2c 20 43 6f 6e 76 65 | 78 2c 20 44 45 43 2c 20 |n, Conve|x, DEC, |
|00001f30| 61 6e 64 20 73 65 76 65 | 72 61 6c 20 6f 74 68 65 |and seve|ral othe|
|00001f40| 72 20 76 65 6e 64 6f 72 | 73 2e 20 53 65 65 20 74 |r vendor|s. See t|
|00001f50| 68 65 0a 53 45 43 55 52 | 49 54 59 20 66 69 6c 65 |he.SECUR|ITY file|
|00001f60| 20 66 6f 72 20 66 75 72 | 74 68 65 72 20 64 65 74 | for fur|ther det|
|00001f70| 61 69 6c 73 2e 0a 58 0a | 58 31 31 2e 20 49 6e 74 |ails..X.|X11. Int|
|00001f80| 65 72 6e 61 6c 6c 79 2c | 20 70 74 79 20 34 2e 30 |ernally,| pty 4.0|
|00001f90| 20 6e 6f 77 20 75 73 65 | 73 20 6d 79 20 73 69 67 | now use|s my sig|
|00001fa0| 6e 61 6c 2d 73 63 68 65 | 64 75 6c 65 20 28 61 6b |nal-sche|dule (ak|
|00001fb0| 61 20 6e 6f 6e 2d 70 72 | 65 65 6d 70 74 69 76 65 |a non-pr|eemptive|
|00001fc0| 0a 74 68 72 65 61 64 73 | 29 20 6c 69 62 72 61 72 |.threads|) librar|
|00001fd0| 79 20 66 6f 72 20 6d 75 | 6c 74 69 74 61 73 6b 69 |y for mu|ltitaski|
|00001fe0| 6e 67 2e 20 54 68 69 73 | 20 6d 61 6b 65 73 20 74 |ng. This| makes t|
|00001ff0| 68 65 20 6d 61 73 74 65 | 72 20 6d 75 63 68 2c 20 |he maste|r much, |
|00002000| 6d 75 63 68 0a 65 61 73 | 69 65 72 20 74 6f 20 75 |much.eas|ier to u|
|00002010| 6e 64 65 72 73 74 61 6e | 64 2c 20 73 74 6f 70 73 |nderstan|d, stops|
|00002020| 20 63 65 72 74 61 69 6e | 20 72 61 63 65 20 63 6f | certain| race co|
|00002030| 6e 64 69 74 69 6f 6e 73 | 2c 20 61 6e 64 20 72 65 |nditions|, and re|
|00002040| 6d 6f 76 65 73 20 61 6e | 79 0a 6e 65 65 64 20 66 |moves an|y.need f|
|00002050| 6f 72 20 65 78 70 6c 69 | 63 69 74 20 76 61 72 69 |or expli|cit vari|
|00002060| 61 62 6c 65 20 6c 6f 63 | 6b 73 20 28 6c 69 6b 65 |able loc|ks (like|
|00002070| 20 66 6c 61 67 71 77 69 | 6e 63 68 20 69 6e 20 6f | flagqwi|nch in o|
|00002080| 6c 64 70 74 79 29 2e 0a | 58 0a 58 31 32 2e 20 6f |ldpty)..|X.X12. o|
|00002090| 6c 64 70 74 79 27 73 20 | 70 73 65 75 64 6f 2d 72 |ldpty's |pseudo-r|
|000020a0| 61 6e 64 6f 6d 20 74 74 | 79 20 73 65 61 72 63 68 |andom tt|y search|
|000020b0| 69 6e 67 20 73 74 61 72 | 74 65 64 20 66 72 6f 6d |ing star|ted from|
|000020c0| 20 61 20 72 61 6e 64 6f | 6d 20 73 70 6f 74 2c 20 | a rando|m spot, |
|000020d0| 62 75 74 0a 73 65 61 72 | 63 68 65 64 20 69 6e 20 |but.sear|ched in |
|000020e0| 61 20 66 69 78 65 64 20 | 6f 72 64 65 72 20 66 72 |a fixed |order fr|
|000020f0| 6f 6d 20 74 68 61 74 20 | 73 70 6f 74 2e 20 54 68 |om that |spot. Th|
|00002100| 69 73 20 6c 65 66 74 20 | 69 74 20 6f 70 65 6e 20 |is left |it open |
|00002110| 74 6f 20 73 65 63 6f 6e | 64 61 72 79 0a 63 6c 75 |to secon|dary.clu|
|00002120| 73 74 65 72 69 6e 67 2e | 20 49 6e 20 6e 65 77 70 |stering.| In newp|
|00002130| 74 79 20 49 20 61 64 64 | 65 64 20 28 69 6e 20 65 |ty I add|ed (in e|
|00002140| 66 66 65 63 74 29 20 61 | 20 73 65 63 6f 6e 64 61 |ffect) a| seconda|
|00002150| 72 79 20 68 61 73 68 20 | 66 75 6e 63 74 69 6f 6e |ry hash |function|
|00002160| 2c 20 61 6e 64 0a 73 69 | 6e 63 65 20 74 65 72 74 |, and.si|nce tert|
|00002170| 69 61 72 79 20 63 6c 75 | 73 74 65 72 69 6e 67 20 |iary clu|stering |
|00002180| 73 69 6d 70 6c 79 20 64 | 6f 65 73 6e 27 74 20 68 |simply d|oesn't h|
|00002190| 61 70 70 65 6e 20 69 6e | 20 70 72 61 63 74 69 63 |appen in| practic|
|000021a0| 65 2c 20 74 68 69 73 0a | 70 72 6f 62 6c 65 6d 20 |e, this.|problem |
|000021b0| 73 68 6f 75 6c 64 20 62 | 65 20 67 6f 6e 65 2e 0a |should b|e gone..|
|000021c0| 58 0a 58 31 33 2e 20 6e | 65 77 70 74 79 20 73 75 |X.X13. n|ewpty su|
|000021d0| 70 70 6f 72 74 73 20 74 | 68 65 20 73 65 73 73 69 |pports t|he sessi|
|000021e0| 6f 6e 20 61 6e 64 20 73 | 65 73 73 69 6f 6e 2d 63 |on and s|ession-c|
|000021f0| 6f 6e 6e 65 63 74 69 6f | 6e 20 6c 6f 67 73 20 64 |onnectio|n logs d|
|00002200| 65 73 63 72 69 62 65 64 | 20 69 6e 0a 6d 79 20 70 |escribed| in.my p|
|00002210| 74 79 20 70 61 70 65 72 | 2e 20 49 20 66 65 72 76 |ty paper|. I ferv|
|00002220| 65 6e 74 6c 79 20 68 6f | 70 65 20 74 68 61 74 20 |ently ho|pe that |
|00002230| 74 68 65 73 65 20 72 65 | 70 6c 61 63 65 20 75 74 |these re|place ut|
|00002240| 6d 70 20 61 6e 64 20 77 | 74 6d 70 2c 20 69 66 20 |mp and w|tmp, if |
|00002250| 6f 6e 6c 79 0a 62 65 63 | 61 75 73 65 20 74 68 65 |only.bec|ause the|
|00002260| 79 20 68 61 76 65 20 65 | 6e 6f 75 67 68 20 73 70 |y have e|nough sp|
|00002270| 61 63 65 20 74 6f 20 73 | 74 6f 72 65 20 66 75 6c |ace to s|tore ful|
|00002280| 6c 20 68 6f 73 74 20 69 | 6e 66 6f 72 6d 61 74 69 |l host i|nformati|
|00002290| 6f 6e 21 0a 58 0a 58 31 | 34 2e 20 49 6e 20 6f 6c |on!.X.X1|4. In ol|
|000022a0| 64 70 74 79 2c 20 74 68 | 65 20 6d 61 73 74 65 72 |dpty, th|e master|
|000022b0| 20 70 72 6f 63 65 73 73 | 20 77 6f 75 6c 64 20 63 | process| would c|
|000022c0| 72 65 61 74 65 20 61 20 | 63 6f 6d 6d 75 6e 69 63 |reate a |communic|
|000022d0| 61 74 69 6f 6e 73 20 66 | 69 6c 65 0a 6f 6e 6c 79 |ations f|ile.only|
|000022e0| 20 77 68 69 6c 65 20 69 | 74 20 77 61 73 20 64 69 | while i|t was di|
|000022f0| 73 63 6f 6e 6e 65 63 74 | 65 64 2c 20 74 68 65 6e |sconnect|ed, then|
|00002300| 20 72 65 6d 6f 76 65 20 | 74 68 65 20 66 69 6c 65 | remove |the file|
|00002310| 20 77 68 65 6e 20 69 74 | 20 77 61 73 0a 72 65 63 | when it| was.rec|
|00002320| 6f 6e 6e 65 63 74 65 64 | 2e 20 6e 65 77 70 74 79 |onnected|. newpty|
|00002330| 20 6d 61 69 6e 74 61 69 | 6e 73 20 74 68 65 20 63 | maintai|ns the c|
|00002340| 6f 6d 6d 75 6e 69 63 61 | 74 69 6f 6e 73 20 66 69 |ommunica|tions fi|
|00002350| 6c 65 20 61 6c 6c 20 74 | 68 65 20 74 69 6d 65 2e |le all t|he time.|
|00002360| 0a 54 68 69 73 20 65 6c | 69 6d 69 6e 61 74 65 73 |.This el|iminates|
|00002370| 20 73 6f 6d 65 20 64 65 | 65 70 20 72 61 63 65 73 | some de|ep races|
|00002380| 20 61 6e 64 20 6c 65 74 | 73 20 74 68 65 20 6d 61 | and let|s the ma|
|00002390| 73 74 65 72 20 6d 61 69 | 6e 74 61 69 6e 20 63 65 |ster mai|ntain ce|
|000023a0| 72 74 61 69 6e 0a 69 6e | 66 6f 72 6d 61 74 69 6f |rtain.in|formatio|
|000023b0| 6e 20 69 6e 73 74 65 61 | 64 20 6f 66 20 73 74 6f |n instea|d of sto|
|000023c0| 72 69 6e 67 20 69 74 20 | 69 6e 20 61 20 66 69 6c |ring it |in a fil|
|000023d0| 65 20 66 6f 72 20 6f 74 | 68 65 72 20 70 72 6f 63 |e for ot|her proc|
|000023e0| 65 73 73 65 73 20 74 6f | 20 72 65 61 64 2e 0a 58 |esses to| read..X|
|000023f0| 0a 58 31 35 2e 20 54 68 | 65 20 72 6f 6c 65 73 20 |.X15. Th|e roles |
|00002400| 6f 66 20 74 68 65 20 6d | 61 73 74 65 72 20 61 6e |of the m|aster an|
|00002410| 64 20 73 69 67 6e 61 6c | 6c 65 72 20 61 72 65 20 |d signal|ler are |
|00002420| 6e 6f 77 20 6d 75 63 68 | 20 6d 6f 72 65 20 63 6c |now much| more cl|
|00002430| 65 61 72 6c 79 0a 73 65 | 70 61 72 61 74 65 64 2e |early.se|parated.|
|00002440| 20 54 68 65 20 6d 61 73 | 74 65 72 20 64 6f 65 73 | The mas|ter does|
|00002450| 20 6e 6f 74 20 6b 6e 6f | 77 20 77 68 65 74 68 65 | not kno|w whethe|
|00002460| 72 20 74 68 65 20 73 69 | 67 6e 61 6c 6c 65 72 20 |r the si|gnaller |
|00002470| 69 73 20 64 65 74 61 63 | 68 65 64 2c 0a 6f 72 20 |is detac|hed,.or |
|00002480| 69 73 20 6d 61 6e 69 70 | 75 6c 61 74 69 6e 67 20 |is manip|ulating |
|00002490| 61 20 74 74 79 2c 20 6f | 72 20 73 75 70 70 6f 72 |a tty, o|r suppor|
|000024a0| 74 73 20 6a 6f 62 20 63 | 6f 6e 74 72 6f 6c 2e 20 |ts job c|ontrol. |
|000024b0| 54 68 65 20 6d 61 73 74 | 65 72 20 64 6f 65 73 20 |The mast|er does |
|000024c0| 6e 6f 74 0a 61 74 74 65 | 6d 70 74 20 74 6f 20 61 |not.atte|mpt to a|
|000024d0| 73 73 6f 63 69 61 74 65 | 20 69 74 73 65 6c 66 20 |ssociate| itself |
|000024e0| 77 69 74 68 20 74 68 65 | 20 73 69 67 6e 61 6c 6c |with the| signall|
|000024f0| 65 72 27 73 20 74 74 79 | 20 6f 6e 20 72 65 63 6f |er's tty| on reco|
|00002500| 6e 6e 65 63 74 2e 0a 49 | 6e 73 74 65 61 64 20 69 |nnect..I|nstead i|
|00002510| 74 20 61 6c 77 61 79 73 | 20 72 65 6d 61 69 6e 73 |t always| remains|
|00002520| 20 61 73 73 6f 63 69 61 | 74 65 64 20 77 69 74 68 | associa|ted with|
|00002530| 20 74 68 65 20 73 6c 61 | 76 65 27 73 20 74 74 79 | the sla|ve's tty|
|00002540| 2e 0a 58 0a 58 31 36 2e | 20 49 6e 20 6f 6c 64 70 |..X.X16.| In oldp|
|00002550| 74 79 2c 20 70 74 79 20 | 2d 64 20 28 64 65 74 61 |ty, pty |-d (deta|
|00002560| 63 68 65 64 29 20 63 6f | 6d 62 69 6e 65 64 20 74 |ched) co|mbined t|
|00002570| 77 6f 20 66 75 6e 63 74 | 69 6f 6e 73 2e 20 4f 6e |wo funct|ions. On|
|00002580| 65 20 68 61 64 20 74 6f | 20 64 6f 0a 77 69 74 68 |e had to| do.with|
|00002590| 20 74 68 65 20 28 6f 62 | 73 6f 6c 65 74 65 29 20 | the (ob|solete) |
|000025a0| 6b 65 72 6e 65 6c 20 63 | 6f 6e 63 65 70 74 20 6f |kernel c|oncept o|
|000025b0| 66 20 61 20 63 6f 6e 74 | 72 6f 6c 6c 69 6e 67 20 |f a cont|rolling |
|000025c0| 74 74 79 2e 20 54 68 65 | 20 6f 74 68 65 72 20 74 |tty. The| other t|
|000025d0| 6f 6c 64 0a 70 74 79 20 | 74 68 61 74 20 69 74 20 |old.pty |that it |
|000025e0| 77 61 73 20 73 74 61 72 | 74 69 6e 67 20 75 6e 64 |was star|ting und|
|000025f0| 65 72 20 61 20 74 74 79 | 20 61 6e 64 20 73 68 6f |er a tty| and sho|
|00002600| 75 6c 64 20 70 61 79 20 | 61 74 74 65 6e 74 69 6f |uld pay |attentio|
|00002610| 6e 20 74 6f 20 74 68 61 | 74 0a 74 74 79 27 73 20 |n to tha|t.tty's |
|00002620| 6d 6f 64 65 73 20 69 6e | 20 63 6f 6e 73 74 72 75 |modes in| constru|
|00002630| 63 74 69 6e 67 20 6d 6f | 64 65 73 20 66 6f 72 20 |cting mo|des for |
|00002640| 74 68 65 20 70 73 65 75 | 64 6f 2d 74 74 79 2e 20 |the pseu|do-tty. |
|00002650| 49 6e 20 6e 65 77 70 74 | 79 2c 20 2d 64 0a 63 6f |In newpt|y, -d.co|
|00002660| 6e 74 72 6f 6c 73 20 6f | 6e 6c 79 20 74 68 65 20 |ntrols o|nly the |
|00002670| 73 65 63 6f 6e 64 20 66 | 75 6e 63 74 69 6f 6e 2e |second f|unction.|
|00002680| 20 70 74 79 20 77 69 6c | 6c 20 61 75 74 6f 6d 61 | pty wil|l automa|
|00002690| 74 69 63 61 6c 6c 79 20 | 68 61 6e 64 6c 65 20 74 |tically |handle t|
|000026a0| 68 65 0a 6b 65 72 6e 65 | 6c 27 73 20 63 6f 6e 74 |he.kerne|l's cont|
|000026b0| 72 6f 6c 6c 69 6e 67 20 | 74 74 79 73 20 63 6f 72 |rolling |ttys cor|
|000026c0| 72 65 63 74 6c 79 20 69 | 6e 20 61 6c 6c 20 73 69 |rectly i|n all si|
|000026d0| 74 75 61 74 69 6f 6e 73 | 2e 0a 58 0a 58 31 37 2e |tuations|..X.X17.|
|000026e0| 20 6e 65 77 70 74 79 20 | 6e 6f 77 20 74 72 65 61 | newpty |now trea|
|000026f0| 74 73 20 74 72 75 65 20 | 45 4f 46 20 6f 6e 20 69 |ts true |EOF on i|
|00002700| 6e 70 75 74 20 61 73 20 | 28 31 29 20 61 20 64 69 |nput as |(1) a di|
|00002710| 73 63 6f 6e 6e 65 63 74 | 2c 20 69 66 20 69 74 27 |sconnect|, if it'|
|00002720| 73 20 61 0a 73 65 73 73 | 69 6f 6e 3b 20 28 32 29 |s a.sess|ion; (2)|
|00002730| 20 66 6f 72 63 69 6e 67 | 20 2d 52 2c 20 73 6f 20 | forcing| -R, so |
|00002740| 74 68 61 74 20 69 74 20 | 77 6f 6e 27 74 20 72 65 |that it |won't re|
|00002750| 61 64 20 66 75 72 74 68 | 65 72 20 69 6e 70 75 74 |ad furth|er input|
|00002760| 2c 20 69 66 20 69 74 27 | 73 0a 6e 6f 74 20 61 20 |, if it'|s.not a |
|00002770| 73 65 73 73 69 6f 6e 2e | 20 54 68 69 73 20 69 73 |session.| This is|
|00002780| 20 61 20 72 65 61 6c 6c | 79 20 74 72 69 63 6b 79 | a reall|y tricky|
|00002790| 20 69 73 73 75 65 2d 2d | 2d 65 76 65 72 20 73 69 | issue--|-ever si|
|000027a0| 6e 63 65 20 55 4e 49 58 | 20 73 75 70 70 6f 72 74 |nce UNIX| support|
|000027b0| 65 64 0a 74 74 79 73 20 | 69 74 27 73 20 68 61 64 |ed.ttys |it's had|
|000027c0| 20 74 77 6f 20 64 69 66 | 66 65 72 65 6e 74 20 63 | two dif|ferent c|
|000027d0| 6f 6e 63 65 70 74 73 20 | 6f 66 20 45 4f 46 2c 20 |oncepts |of EOF, |
|000027e0| 61 6e 64 20 65 76 65 72 | 79 20 70 72 6f 67 72 61 |and ever|y progra|
|000027f0| 6d 20 74 68 61 74 0a 68 | 61 6e 64 6c 65 73 20 74 |m that.h|andles t|
|00002800| 74 79 73 20 68 61 73 20 | 74 6f 20 64 65 61 6c 20 |tys has |to deal |
|00002810| 77 69 74 68 20 62 6f 74 | 68 2e 20 49 66 20 79 6f |with bot|h. If yo|
|00002820| 75 20 68 61 76 65 20 61 | 6e 79 20 62 65 74 74 65 |u have a|ny bette|
|00002830| 72 20 73 75 67 67 65 73 | 74 69 6f 6e 73 2c 0a 6c |r sugges|tions,.l|
|00002840| 65 74 20 6d 65 20 6b 6e | 6f 77 2e 0a 45 4e 44 5f |et me kn|ow..END_|
|00002850| 4f 46 5f 46 49 4c 45 0a | 69 66 20 74 65 73 74 20 |OF_FILE.|if test |
|00002860| 39 31 36 34 20 2d 6e 65 | 20 60 77 63 20 2d 63 20 |9164 -ne| `wc -c |
|00002870| 3c 27 4e 45 57 27 60 3b | 20 74 68 65 6e 0a 20 20 |<'NEW'`;| then. |
|00002880| 20 20 65 63 68 6f 20 73 | 68 61 72 3a 20 5c 22 27 | echo s|har: \"'|
|00002890| 4e 45 57 27 5c 22 20 75 | 6e 70 61 63 6b 65 64 20 |NEW'\" u|npacked |
|000028a0| 77 69 74 68 20 77 72 6f | 6e 67 20 73 69 7a 65 21 |with wro|ng size!|
|000028b0| 0a 66 69 0a 23 20 65 6e | 64 20 6f 66 20 27 4e 45 |.fi.# en|d of 'NE|
|000028c0| 57 27 0a 66 69 0a 69 66 | 20 74 65 73 74 20 2d 66 |W'.fi.if| test -f|
|000028d0| 20 27 51 55 45 53 54 49 | 4f 4e 53 27 20 2d 61 20 | 'QUESTI|ONS' -a |
|000028e0| 22 24 7b 31 7d 22 20 21 | 3d 20 22 2d 63 22 20 3b |"${1}" !|= "-c" ;|
|000028f0| 20 74 68 65 6e 20 0a 20 | 20 65 63 68 6f 20 73 68 | then . | echo sh|
|00002900| 61 72 3a 20 57 69 6c 6c | 20 6e 6f 74 20 63 6c 6f |ar: Will| not clo|
|00002910| 62 62 65 72 20 65 78 69 | 73 74 69 6e 67 20 66 69 |bber exi|sting fi|
|00002920| 6c 65 20 5c 22 27 51 55 | 45 53 54 49 4f 4e 53 27 |le \"'QU|ESTIONS'|
|00002930| 5c 22 0a 65 6c 73 65 0a | 65 63 68 6f 20 73 68 61 |\".else.|echo sha|
|00002940| 72 3a 20 45 78 74 72 61 | 63 74 69 6e 67 20 5c 22 |r: Extra|cting \"|
|00002950| 27 51 55 45 53 54 49 4f | 4e 53 27 5c 22 20 5c 28 |'QUESTIO|NS'\" \(|
|00002960| 38 31 37 33 20 63 68 61 | 72 61 63 74 65 72 73 5c |8173 cha|racters\|
|00002970| 29 0a 73 65 64 20 22 73 | 2f 5e 58 2f 2f 22 20 3e |).sed "s|/^X//" >|
|00002980| 27 51 55 45 53 54 49 4f | 4e 53 27 20 3c 3c 27 45 |'QUESTIO|NS' <<'E|
|00002990| 4e 44 5f 4f 46 5f 46 49 | 4c 45 27 0a 49 20 73 65 |ND_OF_FI|LE'.I se|
|000029a0| 6c 65 63 74 65 64 20 74 | 68 65 20 71 75 65 73 74 |lected t|he quest|
|000029b0| 69 6f 6e 73 20 62 65 6c | 6f 77 20 66 72 6f 6d 20 |ions bel|ow from |
|000029c0| 61 72 74 69 63 6c 65 73 | 20 70 6f 73 74 65 64 20 |articles| posted |
|000029d0| 74 6f 20 74 68 65 20 55 | 53 45 4e 45 54 0a 6e 65 |to the U|SENET.ne|
|000029e0| 77 73 67 72 6f 75 70 20 | 63 6f 6d 70 2e 75 6e 69 |wsgroup |comp.uni|
|000029f0| 78 2e 71 75 65 73 74 69 | 6f 6e 73 2e 20 41 6c 6c |x.questi|ons. All|
|00002a00| 20 74 68 65 20 71 75 65 | 73 74 69 6f 6e 73 20 61 | the que|stions a|
|00002a10| 72 65 20 72 65 61 73 6f | 6e 61 62 6c 79 20 65 61 |re reaso|nably ea|
|00002a20| 73 79 20 74 6f 0a 61 6e | 73 77 65 72 20 77 69 74 |sy to.an|swer wit|
|00002a30| 68 20 70 74 79 20 61 6e | 64 20 6e 6f 74 20 74 6f |h pty an|d not to|
|00002a40| 6f 20 65 61 73 79 20 74 | 6f 20 61 6e 73 77 65 72 |o easy t|o answer|
|00002a50| 20 77 69 74 68 20 6f 74 | 68 65 72 20 77 69 64 65 | with ot|her wide|
|00002a60| 6c 79 20 61 76 61 69 6c | 61 62 6c 65 0a 74 6f 6f |ly avail|able.too|
|00002a70| 6c 73 2e 20 53 6f 20 49 | 20 68 6f 70 65 20 74 68 |ls. So I| hope th|
|00002a80| 69 73 20 66 69 6c 65 20 | 69 73 20 75 73 65 66 75 |is file |is usefu|
|00002a90| 6c 2c 20 61 6e 64 20 49 | 20 68 6f 70 65 20 6f 74 |l, and I| hope ot|
|00002aa0| 68 65 72 20 73 6f 66 74 | 77 61 72 65 20 61 75 74 |her soft|ware aut|
|00002ab0| 68 6f 72 73 0a 61 64 6f | 70 74 20 74 68 65 20 51 |hors.ado|pt the Q|
|00002ac0| 55 45 53 54 49 4f 4e 53 | 20 69 64 65 61 2e 0a 58 |UESTIONS| idea..X|
|00002ad0| 0a 58 0a 58 0a 58 31 2e | 20 48 6f 77 20 64 6f 20 |.X.X.X1.| How do |
|00002ae0| 49 20 72 65 64 69 72 65 | 63 74 20 74 65 6c 6e 65 |I redire|ct telne|
|00002af0| 74 27 73 20 69 6e 70 75 | 74 3f 0a 58 0a 41 6e 73 |t's inpu|t?.X.Ans|
|00002b00| 77 65 72 3a 20 52 75 6e | 20 70 74 79 20 74 65 6c |wer: Run| pty tel|
|00002b10| 6e 65 74 20 69 6e 73 74 | 65 61 64 20 6f 66 20 74 |net inst|ead of t|
|00002b20| 65 6c 6e 65 74 2e 0a 58 | 0a 4c 6f 6e 67 20 61 6e |elnet..X|.Long an|
|00002b30| 73 77 65 72 3a 20 42 65 | 20 63 61 72 65 66 75 6c |swer: Be| careful|
|00002b40| 2d 2d 2d 61 73 20 73 6f | 6f 6e 20 61 73 20 74 65 |---as so|on as te|
|00002b50| 6c 6e 65 74 20 73 75 63 | 63 65 73 73 66 75 6c 6c |lnet suc|cessfull|
|00002b60| 79 20 63 6f 6e 6e 65 63 | 74 73 20 74 6f 20 74 68 |y connec|ts to th|
|00002b70| 65 0a 72 65 6d 6f 74 65 | 20 68 6f 73 74 2c 20 69 |e.remote| host, i|
|00002b80| 74 20 66 6c 75 73 68 65 | 73 20 69 74 73 20 69 6e |t flushe|s its in|
|00002b90| 70 75 74 2e 20 53 6f 20 | 69 66 20 79 6f 75 20 64 |put. So |if you d|
|00002ba0| 6f 20 73 6f 6d 65 74 68 | 69 6e 67 20 6c 69 6b 65 |o someth|ing like|
|00002bb0| 0a 58 0a 58 20 20 20 28 | 65 63 68 6f 20 68 65 6c |.X.X (|echo hel|
|00002bc0| 70 3b 20 65 63 68 6f 20 | 71 75 69 74 29 20 7c 20 |p; echo |quit) | |
|00002bd0| 70 74 79 20 74 65 6c 6e | 65 74 20 77 68 61 74 65 |pty teln|et whate|
|00002be0| 76 65 72 20 32 35 0a 58 | 0a 74 65 6c 6e 65 74 20 |ver 25.X|.telnet |
|00002bf0| 77 69 6c 6c 20 72 65 61 | 64 20 60 60 68 65 6c 70 |will rea|d ``help|
|00002c00| 27 27 20 61 6e 64 20 60 | 60 71 75 69 74 27 27 2c |'' and `|`quit'',|
|00002c10| 20 74 68 65 6e 20 61 66 | 74 65 72 20 61 20 73 65 | then af|ter a se|
|00002c20| 63 6f 6e 64 20 6f 72 20 | 74 77 6f 0a 63 6f 6e 6e |cond or |two.conn|
|00002c30| 65 63 74 20 74 6f 20 74 | 68 65 20 68 6f 73 74 2c |ect to t|he host,|
|00002c40| 20 74 68 65 6e 20 66 6c | 75 73 68 20 74 68 65 20 | then fl|ush the |
|00002c50| 69 6e 70 75 74 2e 20 49 | 74 20 77 6f 6e 27 74 20 |input. I|t won't |
|00002c60| 67 65 74 20 61 6e 79 20 | 69 6e 70 75 74 20 61 66 |get any |input af|
|00002c70| 74 65 72 0a 74 68 61 74 | 2e 20 41 6e 20 65 61 73 |ter.that|. An eas|
|00002c80| 79 20 73 6f 6c 75 74 69 | 6f 6e 20 69 73 20 74 6f |y soluti|on is to|
|00002c90| 20 64 65 6c 61 79 20 74 | 68 65 20 69 6e 70 75 74 | delay t|he input|
|00002ca0| 20 61 20 66 65 77 20 73 | 65 63 6f 6e 64 73 3a 0a | a few s|econds:.|
|00002cb0| 58 0a 58 20 20 20 28 73 | 6c 65 65 70 20 35 3b 20 |X.X (s|leep 5; |
|00002cc0| 65 63 68 6f 20 68 65 6c | 70 3b 20 65 63 68 6f 20 |echo hel|p; echo |
|00002cd0| 71 75 69 74 29 20 7c 20 | 70 74 79 20 74 65 6c 6e |quit) | |pty teln|
|00002ce0| 65 74 20 77 68 61 74 65 | 76 65 72 20 32 35 0a 58 |et whate|ver 25.X|
|00002cf0| 0a 58 28 54 72 79 20 69 | 74 21 29 20 46 6f 72 20 |.X(Try i|t!) For |
|00002d00| 61 20 6d 6f 72 65 20 72 | 6f 62 75 73 74 20 73 6f |a more r|obust so|
|00002d10| 6c 75 74 69 6f 6e 2c 20 | 73 65 65 20 71 75 65 73 |lution, |see ques|
|00002d20| 74 69 6f 6e 20 23 34 20 | 62 65 6c 6f 77 2e 0a 58 |tion #4 |below..X|
|00002d30| 0a 57 68 79 20 74 68 69 | 73 20 77 61 73 20 61 20 |.Why thi|s was a |
|00002d40| 70 72 6f 62 6c 65 6d 3a | 20 55 4e 49 58 20 62 65 |problem:| UNIX be|
|00002d50| 67 69 6e 6e 65 72 73 20 | 6c 65 61 72 6e 20 74 68 |ginners |learn th|
|00002d60| 61 74 20 74 68 65 79 20 | 63 61 6e 20 66 65 65 64 |at they |can feed|
|00002d70| 20 69 6e 70 75 74 20 74 | 6f 0a 70 72 6f 67 72 61 | input t|o.progra|
|00002d80| 6d 73 20 77 69 74 68 20 | 72 65 64 69 72 65 63 74 |ms with |redirect|
|00002d90| 69 6f 6e 20 6f 72 20 77 | 69 74 68 20 70 69 70 65 |ion or w|ith pipe|
|00002da0| 73 2e 20 54 68 65 79 27 | 72 65 20 6f 66 74 65 6e |s. They'|re often|
|00002db0| 20 73 75 72 70 72 69 73 | 65 64 20 74 6f 20 73 65 | surpris|ed to se|
|00002dc0| 65 0a 74 68 61 74 20 74 | 68 69 73 20 64 6f 65 73 |e.that t|his does|
|00002dd0| 6e 27 74 20 77 6f 72 6b | 3a 0a 58 0a 58 20 20 20 |n't work|:.X.X |
|00002de0| 28 65 63 68 6f 20 68 65 | 6c 70 3b 20 65 63 68 6f |(echo he|lp; echo|
|00002df0| 20 71 75 69 74 29 20 7c | 20 74 65 6c 6e 65 74 20 | quit) || telnet |
|00002e00| 77 68 61 74 65 76 65 72 | 20 32 35 0a 58 0a 74 65 |whatever| 25.X.te|
|00002e10| 6c 6e 65 74 2c 20 6c 69 | 6b 65 20 6d 61 6e 79 20 |lnet, li|ke many |
|00002e20| 6f 74 68 65 72 20 75 74 | 69 6c 69 74 69 65 73 2c |other ut|ilities,|
|00002e30| 20 63 6f 6e 73 69 64 65 | 72 73 20 69 74 73 65 6c | conside|rs itsel|
|00002e40| 66 20 61 6e 20 60 60 69 | 6e 74 65 72 61 63 74 69 |f an ``i|nteracti|
|00002e50| 76 65 27 27 0a 70 72 6f | 67 72 61 6d 2e 20 49 74 |ve''.pro|gram. It|
|00002e60| 20 61 73 73 75 6d 65 73 | 20 74 68 61 74 20 69 74 | assumes| that it|
|00002e70| 27 73 20 74 61 6c 6b 69 | 6e 67 20 74 6f 20 61 20 |'s talki|ng to a |
|00002e80| 75 73 65 72 27 73 20 74 | 65 72 6d 69 6e 61 6c 20 |user's t|erminal |
|00002e90| 64 69 72 65 63 74 6c 79 | 2c 20 73 6f 0a 74 68 61 |directly|, so.tha|
|00002ea0| 74 20 69 74 20 63 61 6e | 20 70 75 74 20 74 68 65 |t it can| put the|
|00002eb0| 20 74 65 72 6d 69 6e 61 | 6c 20 69 6e 74 6f 20 63 | termina|l into c|
|00002ec0| 68 61 72 61 63 74 65 72 | 2d 61 74 2d 61 2d 74 69 |haracter|-at-a-ti|
|00002ed0| 6d 65 20 6d 6f 64 65 2e | 20 49 66 20 79 6f 75 0a |me mode.| If you.|
|00002ee0| 72 65 64 69 72 65 63 74 | 20 69 74 73 20 69 6e 70 |redirect| its inp|
|00002ef0| 75 74 2c 20 69 74 20 77 | 6f 6e 27 74 20 62 65 20 |ut, it w|on't be |
|00002f00| 61 62 6c 65 20 74 6f 20 | 66 69 6e 64 20 74 68 65 |able to |find the|
|00002f10| 20 74 65 72 6d 69 6e 61 | 6c 2c 20 61 6e 64 20 69 | termina|l, and i|
|00002f20| 74 27 6c 6c 0a 63 6f 6d | 70 6c 61 69 6e 20 6f 72 |t'll.com|plain or|
|00002f30| 20 64 6f 20 77 65 69 72 | 64 20 74 68 69 6e 67 73 | do weir|d things|
|00002f40| 2e 20 53 69 6d 69 6c 61 | 72 20 63 6f 6d 6d 65 6e |. Simila|r commen|
|00002f50| 74 73 20 61 70 70 6c 79 | 20 74 6f 20 65 64 69 74 |ts apply| to edit|
|00002f60| 6f 72 73 2c 20 6c 69 6b | 65 20 76 69 2e 0a 58 0a |ors, lik|e vi..X.|
|00002f70| 57 68 79 20 74 68 65 20 | 61 6e 73 77 65 72 20 73 |Why the |answer s|
|00002f80| 6f 6c 76 65 73 20 74 68 | 65 20 70 72 6f 62 6c 65 |olves th|e proble|
|00002f90| 6d 3a 20 70 74 79 20 63 | 72 65 61 74 65 73 20 61 |m: pty c|reates a|
|00002fa0| 20 70 73 65 75 64 6f 2d | 74 65 72 6d 69 6e 61 6c | pseudo-|terminal|
|00002fb0| 2d 2d 2d 0a 73 6f 6d 65 | 74 68 69 6e 67 20 77 68 |---.some|thing wh|
|00002fc0| 69 63 68 20 6c 6f 6f 6b | 73 20 6c 69 6b 65 20 61 |ich look|s like a|
|00002fd0| 20 6e 6f 72 6d 61 6c 20 | 74 65 72 6d 69 6e 61 6c | normal |terminal|
|00002fe0| 20 62 75 74 20 69 73 20 | 75 6e 64 65 72 20 70 74 | but is |under pt|
|00002ff0| 79 27 73 20 63 6f 6e 74 | 72 6f 6c 2e 0a 70 74 79 |y's cont|rol..pty|
|00003000| 20 72 75 6e 73 20 74 65 | 6c 6e 65 74 20 75 6e 64 | runs te|lnet und|
|00003010| 65 72 20 74 68 65 20 70 | 73 65 75 64 6f 2d 74 65 |er the p|seudo-te|
|00003020| 72 6d 69 6e 61 6c 20 61 | 6e 64 20 66 6f 72 77 61 |rminal a|nd forwa|
|00003030| 72 64 73 20 61 6c 6c 20 | 69 6e 70 75 74 20 61 6e |rds all |input an|
|00003040| 64 0a 6f 75 74 70 75 74 | 2e 20 4e 6f 77 20 74 65 |d.output|. Now te|
|00003050| 6c 6e 65 74 20 77 6f 72 | 6b 73 2c 20 62 65 63 61 |lnet wor|ks, beca|
|00003060| 75 73 65 20 69 74 20 73 | 65 65 73 20 74 68 65 20 |use it s|ees the |
|00003070| 70 73 65 75 64 6f 2d 74 | 65 72 6d 69 6e 61 6c 20 |pseudo-t|erminal |
|00003080| 61 6e 64 20 74 68 69 6e | 6b 73 0a 69 74 27 73 20 |and thin|ks.it's |
|00003090| 74 61 6c 6b 69 6e 67 20 | 74 6f 20 74 68 65 20 75 |talking |to the u|
|000030a0| 73 65 72 2e 0a 58 0a 58 | 0a 58 0a 58 32 2e 20 48 |ser..X.X|.X.X2. H|
|000030b0| 6f 77 20 64 6f 20 49 20 | 72 65 64 69 72 65 63 74 |ow do I |redirect|
|000030c0| 20 70 61 73 73 77 64 27 | 73 20 69 6e 70 75 74 3f | passwd'|s input?|
|000030d0| 0a 58 0a 41 6e 73 77 65 | 72 3a 20 70 74 79 20 70 |.X.Answe|r: pty p|
|000030e0| 61 73 73 77 64 2e 0a 58 | 0a 4c 6f 6e 67 20 61 6e |asswd..X|.Long an|
|000030f0| 73 77 65 72 3a 20 4c 69 | 6b 65 20 74 65 6c 6e 65 |swer: Li|ke telne|
|00003100| 74 2c 20 70 61 73 73 77 | 64 20 66 6c 75 73 68 65 |t, passw|d flushe|
|00003110| 73 20 69 74 73 20 69 6e | 70 75 74 2c 20 73 6f 20 |s its in|put, so |
|00003120| 79 6f 75 20 70 72 6f 62 | 61 62 6c 79 20 77 61 6e |you prob|ably wan|
|00003130| 74 0a 74 6f 20 64 6f 20 | 73 6f 6d 65 74 68 69 6e |t.to do |somethin|
|00003140| 67 20 6c 69 6b 65 0a 58 | 0a 58 20 20 20 28 73 6c |g like.X|.X (sl|
|00003150| 65 65 70 20 35 3b 20 65 | 63 68 6f 20 6f 6c 64 70 |eep 5; e|cho oldp|
|00003160| 61 73 73 77 6f 72 64 3b | 20 73 6c 65 65 70 20 35 |assword;| sleep 5|
|00003170| 3b 20 65 63 68 6f 20 6e | 65 77 70 61 73 73 77 6f |; echo n|ewpasswo|
|00003180| 72 64 3b 20 5c 0a 58 20 | 20 20 20 20 73 6c 65 65 |rd; \.X | slee|
|00003190| 70 20 35 3b 20 65 63 68 | 6f 20 6e 65 77 70 61 73 |p 5; ech|o newpas|
|000031a0| 73 77 6f 72 64 29 20 7c | 20 70 74 79 20 70 61 73 |sword) || pty pas|
|000031b0| 73 77 64 0a 58 0a 41 20 | 62 65 74 74 65 72 20 73 |swd.X.A |better s|
|000031c0| 6f 6c 75 74 69 6f 6e 20 | 61 70 70 65 61 72 73 20 |olution |appears |
|000031d0| 69 6e 20 23 34 20 62 65 | 6c 6f 77 2e 20 49 66 20 |in #4 be|low. If |
|000031e0| 79 6f 75 27 72 65 20 75 | 73 69 6e 67 20 70 61 73 |you're u|sing pas|
|000031f0| 73 77 64 20 61 73 20 61 | 0a 73 79 73 74 65 6d 20 |swd as a|.system |
|00003200| 61 64 6d 69 6e 69 73 74 | 72 61 74 6f 72 20 74 6f |administ|rator to|
|00003210| 20 63 68 61 6e 67 65 20 | 73 6f 6d 65 62 6f 64 79 | change |somebody|
|00003220| 20 65 6c 73 65 27 73 20 | 70 61 73 73 77 6f 72 64 | else's |password|
|00003230| 2c 20 79 6f 75 20 77 61 | 6e 74 0a 58 0a 58 20 20 |, you wa|nt.X.X |
|00003240| 20 28 73 6c 65 65 70 20 | 35 3b 20 65 63 68 6f 20 | (sleep |5; echo |
|00003250| 70 61 73 73 77 6f 72 64 | 3b 20 73 6c 65 65 70 20 |password|; sleep |
|00003260| 35 3b 20 65 63 68 6f 20 | 70 61 73 73 77 6f 72 64 |5; echo |password|
|00003270| 29 20 7c 20 70 74 79 20 | 70 61 73 73 77 64 20 73 |) | pty |passwd s|
|00003280| 68 6d 6f 65 0a 58 0a 49 | 20 63 65 72 74 61 69 6e |hmoe.X.I| certain|
|00003290| 6c 79 20 64 6f 6e 27 74 | 20 72 65 63 6f 6d 6d 65 |ly don't| recomme|
|000032a0| 6e 64 20 6b 65 65 70 69 | 6e 67 20 70 61 73 73 77 |nd keepi|ng passw|
|000032b0| 6f 72 64 73 20 76 69 73 | 69 62 6c 65 20 69 6e 20 |ords vis|ible in |
|000032c0| 73 68 65 6c 6c 20 73 63 | 72 69 70 74 73 2c 0a 62 |shell sc|ripts,.b|
|000032d0| 75 74 20 69 66 20 79 6f | 75 20 65 76 65 72 20 6e |ut if yo|u ever n|
|000032e0| 65 65 64 20 74 6f 20 64 | 6f 20 74 68 69 73 2c 20 |eed to d|o this, |
|000032f0| 79 6f 75 20 63 61 6e 2e | 20 49 6e 20 73 69 6e 67 |you can.| In sing|
|00003300| 6c 65 2d 75 73 65 72 20 | 6d 6f 64 65 20 74 68 69 |le-user |mode thi|
|00003310| 73 20 69 73 0a 72 65 61 | 73 6f 6e 61 62 6c 79 20 |s is.rea|sonably |
|00003320| 73 61 66 65 2e 0a 58 0a | 57 68 79 20 74 68 69 73 |safe..X.|Why this|
|00003330| 20 77 61 73 20 61 20 70 | 72 6f 62 6c 65 6d 3a 20 | was a p|roblem: |
|00003340| 70 61 73 73 77 64 20 69 | 73 20 65 76 65 6e 20 6d |passwd i|s even m|
|00003350| 6f 72 65 20 69 6e 73 69 | 73 74 65 6e 74 20 74 68 |ore insi|stent th|
|00003360| 61 6e 20 74 65 6c 6e 65 | 74 20 6f 6e 0a 74 61 6c |an telne|t on.tal|
|00003370| 6b 69 6e 67 20 74 6f 20 | 61 20 75 73 65 72 20 64 |king to |a user d|
|00003380| 69 72 65 63 74 6c 79 2e | 20 53 6f 20 69 74 20 6f |irectly.| So it o|
|00003390| 70 65 6e 73 20 2f 64 65 | 76 2f 74 74 79 20 66 6f |pens /de|v/tty fo|
|000033a0| 72 20 69 74 73 20 69 6e | 70 75 74 2e 20 53 6f 6d |r its in|put. Som|
|000033b0| 65 0a 6f 74 68 65 72 20 | 70 72 6f 67 72 61 6d 73 |e.other |programs|
|000033c0| 20 6f 70 65 6e 20 2f 64 | 65 76 2f 74 74 79 20 66 | open /d|ev/tty f|
|000033d0| 6f 72 20 62 6f 74 68 20 | 69 6e 70 75 74 20 61 6e |or both |input an|
|000033e0| 64 20 6f 75 74 70 75 74 | 2e 20 54 68 69 73 20 61 |d output|. This a|
|000033f0| 76 6f 69 64 73 20 61 6e | 79 0a 72 65 64 69 72 65 |voids an|y.redire|
|00003400| 63 74 69 6f 6e 20 79 6f | 75 20 6d 69 67 68 74 20 |ction yo|u might |
|00003410| 68 61 76 65 20 70 75 74 | 20 69 6e 74 6f 20 70 6c |have put| into pl|
|00003420| 61 63 65 2e 0a 58 0a 57 | 68 79 20 74 68 65 20 61 |ace..X.W|hy the a|
|00003430| 6e 73 77 65 72 20 73 6f | 6c 76 65 73 20 74 68 65 |nswer so|lves the|
|00003440| 20 70 72 6f 62 6c 65 6d | 3a 20 41 73 20 62 65 66 | problem|: As bef|
|00003450| 6f 72 65 2c 20 70 74 79 | 20 63 72 65 61 74 65 73 |ore, pty| creates|
|00003460| 20 61 0a 70 73 65 75 64 | 6f 2d 74 65 72 6d 69 6e | a.pseud|o-termin|
|00003470| 61 6c 20 66 6f 72 20 70 | 61 73 73 77 64 20 74 6f |al for p|asswd to|
|00003480| 20 74 61 6c 6b 20 74 6f | 2e 20 57 68 65 6e 20 70 | talk to|. When p|
|00003490| 61 73 73 77 64 20 6f 70 | 65 6e 73 20 2f 64 65 76 |asswd op|ens /dev|
|000034a0| 2f 74 74 79 2c 20 69 74 | 0a 67 65 74 73 20 74 68 |/tty, it|.gets th|
|000034b0| 65 20 70 73 65 75 64 6f | 2d 74 65 72 6d 69 6e 61 |e pseudo|-termina|
|000034c0| 6c 2e 20 41 6c 6c 20 74 | 68 65 20 72 65 64 69 72 |l. All t|he redir|
|000034d0| 65 63 74 69 6f 6e 20 69 | 73 20 6f 75 74 73 69 64 |ection i|s outsid|
|000034e0| 65 20 70 74 79 2c 20 73 | 61 66 65 20 66 72 6f 6d |e pty, s|afe from|
|000034f0| 0a 70 61 73 73 77 64 27 | 73 20 74 61 6d 70 65 72 |.passwd'|s tamper|
|00003500| 69 6e 67 2e 0a 58 0a 58 | 0a 58 0a 58 33 2e 20 57 |ing..X.X|.X.X3. W|
|00003510| 68 79 20 64 6f 65 73 6e | 27 74 20 74 72 20 27 5b |hy doesn|'t tr '[|
|00003520| 41 2d 5a 5d 27 20 27 5b | 61 2d 7a 5d 27 20 7c 20 |A-Z]' '[|a-z]' | |
|00003530| 63 61 74 20 2d 74 20 70 | 72 69 6e 74 20 61 6e 79 |cat -t p|rint any|
|00003540| 74 68 69 6e 67 20 49 20 | 74 79 70 65 3f 0a 58 0a |thing I |type?.X.|
|00003550| 41 6e 73 77 65 72 3a 20 | 44 6f 20 20 6e 6f 62 75 |Answer: |Do nobu|
|00003560| 66 20 74 72 20 27 5b 41 | 2d 5a 5d 27 20 27 5b 61 |f tr '[A|-Z]' '[a|
|00003570| 2d 7a 5d 27 20 7c 20 63 | 61 74 20 2d 74 2e 0a 58 |-z]' | c|at -t..X|
|00003580| 0a 4c 6f 6e 67 20 61 6e | 73 77 65 72 3a 20 59 6f |.Long an|swer: Yo|
|00003590| 75 20 63 61 6e 20 75 73 | 65 20 70 74 79 20 2d 30 |u can us|e pty -0|
|000035a0| 20 28 61 6c 73 6f 20 6b | 6e 6f 77 6e 20 61 73 20 | (also k|nown as |
|000035b0| 63 6f 6e 64 6f 6d 2c 20 | 6f 72 2c 20 69 66 20 79 |condom, |or, if y|
|000035c0| 6f 75 27 72 65 20 6e 6f | 74 0a 69 6e 20 73 75 63 |ou're no|t.in suc|
|000035d0| 68 20 61 20 70 69 63 74 | 75 72 65 73 71 75 65 20 |h a pict|uresque |
|000035e0| 6d 6f 6f 64 2c 20 61 73 | 20 74 74 79 70 72 6f 74 |mood, as| ttyprot|
|000035f0| 65 63 74 29 20 69 6e 20 | 70 6c 61 63 65 20 6f 66 |ect) in |place of|
|00003600| 20 6e 6f 62 75 66 2c 20 | 62 75 74 20 6e 6f 62 75 | nobuf, |but nobu|
|00003610| 66 0a 69 6e 76 6f 6b 65 | 73 20 70 74 79 20 63 61 |f.invoke|s pty ca|
|00003620| 72 65 66 75 6c 6c 79 20 | 73 6f 20 74 68 61 74 20 |refully |so that |
|00003630| 45 4f 46 20 6f 6e 20 74 | 68 65 20 69 6e 70 75 74 |EOF on t|he input|
|00003640| 20 77 69 6c 6c 20 62 65 | 20 70 61 73 73 65 64 20 | will be| passed |
|00003650| 74 68 72 6f 75 67 68 20 | 74 6f 0a 74 72 2e 20 54 |through |to.tr. T|
|00003660| 68 65 20 65 66 66 65 63 | 74 20 6f 66 20 74 68 69 |he effec|t of thi|
|00003670| 73 20 70 69 70 65 6c 69 | 6e 65 20 69 73 20 74 6f |s pipeli|ne is to|
|00003680| 20 63 68 61 6e 67 65 20 | 61 6c 6c 20 75 70 70 65 | change |all uppe|
|00003690| 72 63 61 73 65 20 6c 65 | 74 74 65 72 73 20 69 6e |rcase le|tters in|
|000036a0| 74 6f 0a 6c 6f 77 65 72 | 63 61 73 65 2c 20 74 68 |to.lower|case, th|
|000036b0| 65 6e 20 70 72 69 6e 74 | 20 63 6f 6e 74 72 6f 6c |en print| control|
|000036c0| 20 63 68 61 72 61 63 74 | 65 72 73 20 76 69 73 69 | charact|ers visi|
|000036d0| 62 6c 79 20 28 65 2e 67 | 2e 2c 20 5e 48 20 69 6e |bly (e.g|., ^H in|
|000036e0| 73 74 65 61 64 20 6f 66 | 0a 62 61 63 6b 73 70 61 |stead of|.backspa|
|000036f0| 63 65 29 2e 0a 58 0a 57 | 68 79 20 74 68 69 73 20 |ce)..X.W|hy this |
|00003700| 77 61 73 20 61 20 70 72 | 6f 62 6c 65 6d 3a 20 54 |was a pr|oblem: T|
|00003710| 68 65 20 6f 72 69 67 69 | 6e 61 6c 20 70 69 70 65 |he origi|nal pipe|
|00003720| 6c 69 6e 65 2c 20 77 69 | 74 68 6f 75 74 20 6e 6f |line, wi|thout no|
|00003730| 62 75 66 2c 20 64 6f 65 | 73 6e 27 74 0a 73 65 65 |buf, doe|sn't.see|
|00003740| 6d 20 74 6f 20 70 72 6f | 64 75 63 65 20 61 6e 79 |m to pro|duce any|
|00003750| 20 6f 75 74 70 75 74 2e | 20 57 68 61 74 20 68 61 | output.| What ha|
|00003760| 70 70 65 6e 73 20 69 73 | 20 74 68 61 74 20 74 72 |ppens is| that tr|
|00003770| 20 73 61 79 73 20 60 60 | 4f 68 2c 20 49 20 73 61 | says ``|Oh, I sa|
|00003780| 79 2e 0a 4d 79 20 6f 75 | 74 70 75 74 20 69 73 20 |y..My ou|tput is |
|00003790| 67 6f 69 6e 67 20 69 6e | 74 6f 20 61 20 70 69 70 |going in|to a pip|
|000037a0| 65 21 20 49 20 67 75 65 | 73 73 20 74 68 65 72 65 |e! I gue|ss there|
|000037b0| 27 73 20 6e 6f 20 70 6f | 69 6e 74 20 69 6e 20 73 |'s no po|int in s|
|000037c0| 65 6e 64 69 6e 67 0a 6f | 75 74 70 75 74 20 61 73 |ending.o|utput as|
|000037d0| 20 66 61 73 74 20 61 73 | 20 70 6f 73 73 69 62 6c | fast as| possibl|
|000037e0| 65 2e 20 53 6f 20 49 27 | 6c 6c 20 62 75 69 6c 64 |e. So I'|ll build|
|000037f0| 20 75 70 20 61 20 62 75 | 66 66 65 72 20 6f 66 20 | up a bu|ffer of |
|00003800| 6f 75 74 70 75 74 2c 20 | 73 61 79 20 75 70 0a 74 |output, |say up.t|
|00003810| 6f 20 38 31 39 32 20 63 | 68 61 72 61 63 74 65 72 |o 8192 c|haracter|
|00003820| 73 2c 20 62 65 66 6f 72 | 65 20 49 20 73 65 6e 64 |s, befor|e I send|
|00003830| 20 61 6e 79 20 6f 66 20 | 69 74 2e 27 27 20 49 6e | any of |it.'' In|
|00003840| 20 66 61 63 74 2c 20 61 | 6e 79 20 70 72 6f 67 72 | fact, a|ny progr|
|00003850| 61 6d 0a 77 68 69 63 68 | 20 75 73 65 73 20 73 74 |am.which| uses st|
|00003860| 64 69 6f 20 77 69 6c 6c | 20 64 6f 20 74 68 65 20 |dio will| do the |
|00003870| 73 61 6d 65 20 74 68 69 | 6e 67 2e 20 54 68 65 20 |same thi|ng. The |
|00003880| 70 72 6f 62 6c 65 6d 20 | 69 73 20 74 68 61 74 20 |problem |is that |
|00003890| 74 68 65 20 67 75 65 73 | 73 0a 69 73 20 77 72 6f |the gues|s.is wro|
|000038a0| 6e 67 2d 2d 2d 79 6f 75 | 20 64 6f 6e 27 74 20 77 |ng---you| don't w|
|000038b0| 61 6e 74 20 38 31 39 32 | 20 63 68 61 72 61 63 74 |ant 8192| charact|
|000038c0| 65 72 73 20 68 65 6c 64 | 20 69 6e 73 69 64 65 20 |ers held| inside |
|000038d0| 74 72 2e 20 59 6f 75 20 | 77 61 6e 74 20 65 61 63 |tr. You |want eac|
|000038e0| 68 0a 6c 69 6e 65 20 73 | 65 6e 74 20 74 68 72 6f |h.line s|ent thro|
|000038f0| 75 67 68 20 77 69 74 68 | 6f 75 74 20 61 6e 79 20 |ugh with|out any |
|00003900| 62 75 66 66 65 72 69 6e | 67 2e 0a 58 0a 57 68 79 |bufferin|g..X.Why|
|00003910| 20 74 68 65 20 61 6e 73 | 77 65 72 20 73 6f 6c 76 | the ans|wer solv|
|00003920| 65 73 20 74 68 65 20 70 | 72 6f 62 6c 65 6d 3a 20 |es the p|roblem: |
|00003930| 4f 6e 63 65 20 61 67 61 | 69 6e 2c 20 6e 6f 62 75 |Once aga|in, nobu|
|00003940| 66 20 28 72 65 61 6c 6c | 79 20 70 74 79 29 0a 63 |f (reall|y pty).c|
|00003950| 72 65 61 74 65 73 20 61 | 20 70 73 65 75 64 6f 2d |reates a| pseudo-|
|00003960| 74 65 72 6d 69 6e 61 6c | 20 61 6e 64 20 72 75 6e |terminal| and run|
|00003970| 73 20 74 72 20 69 6e 73 | 69 64 65 20 69 74 2e 20 |s tr ins|ide it. |
|00003980| 54 68 65 6e 20 74 72 20 | 28 72 65 61 6c 6c 79 20 |Then tr |(really |
|00003990| 73 74 64 69 6f 29 0a 73 | 61 79 73 20 60 60 4f 68 |stdio).s|ays ``Oh|
|000039a0| 2c 20 49 20 73 61 79 2e | 20 4d 79 20 6f 75 74 70 |, I say.| My outp|
|000039b0| 75 74 20 69 73 20 67 6f | 69 6e 67 20 69 6e 74 6f |ut is go|ing into|
|000039c0| 20 61 20 74 65 72 6d 69 | 6e 61 6c 21 20 49 27 6c | a termi|nal! I'l|
|000039d0| 6c 20 62 65 74 20 74 68 | 65 72 65 27 73 20 61 0a |l bet th|ere's a.|
|000039e0| 75 73 65 72 20 77 61 74 | 63 68 69 6e 67 20 65 76 |user wat|ching ev|
|000039f0| 65 72 79 20 77 6f 72 64 | 2e 20 53 6f 20 49 27 6c |ery word|. So I'l|
|00003a00| 6c 20 73 65 6e 64 20 65 | 61 63 68 20 6c 69 6e 65 |l send e|ach line|
|00003a10| 20 61 73 20 73 6f 6f 6e | 20 61 73 20 49 27 6d 20 | as soon| as I'm |
|00003a20| 64 6f 6e 65 0a 77 69 74 | 68 20 69 74 2e 27 27 20 |done.wit|h it.'' |
|00003a30| 41 6e 64 20 69 74 20 64 | 6f 65 73 2e 0a 58 0a 58 |And it d|oes..X.X|
|00003a40| 0a 58 0a 58 34 2e 20 48 | 6f 77 20 64 6f 20 49 20 |.X.X4. H|ow do I |
|00003a50| 73 74 61 72 74 20 61 20 | 70 72 6f 67 72 61 6d 2c |start a |program,|
|00003a60| 20 72 65 73 70 6f 6e 64 | 20 74 6f 20 69 74 73 20 | respond| to its |
|00003a70| 70 72 6f 6d 70 74 73 2c | 20 67 69 76 65 20 74 68 |prompts,| give th|
|00003a80| 65 20 63 6f 72 72 65 63 | 74 0a 58 20 20 20 72 65 |e correc|t.X re|
|00003a90| 70 6c 69 65 73 2c 20 61 | 6e 64 20 63 61 74 63 68 |plies, a|nd catch|
|00003aa0| 20 74 68 65 20 6f 75 74 | 70 75 74 2d 2d 2d 61 6c | the out|put---al|
|00003ab0| 6c 20 66 72 6f 6d 20 61 | 20 73 63 72 69 70 74 3f |l from a| script?|
|00003ac0| 0a 58 0a 49 66 20 79 6f | 75 27 72 65 20 67 6f 6f |.X.If yo|u're goo|
|00003ad0| 64 20 61 74 20 73 68 65 | 6c 6c 20 70 72 6f 67 72 |d at she|ll progr|
|00003ae0| 61 6d 6d 69 6e 67 2c 20 | 79 6f 75 20 6d 69 67 68 |amming, |you migh|
|00003af0| 74 20 68 61 76 65 20 61 | 6c 72 65 61 64 79 20 66 |t have a|lready f|
|00003b00| 69 67 75 72 65 64 20 6f | 75 74 0a 6d 6f 73 74 20 |igured o|ut.most |
|00003b10| 6f 66 20 74 68 69 73 2e | 20 4c 65 74 27 73 20 73 |of this.| Let's s|
|00003b20| 61 79 20 79 6f 75 27 72 | 65 20 6f 6e 20 61 20 6d |ay you'r|e on a m|
|00003b30| 61 63 68 69 6e 65 20 28 | 6c 69 6b 65 20 61 20 53 |achine (|like a S|
|00003b40| 75 6e 29 20 77 68 69 63 | 68 20 63 61 6e 0a 63 72 |un) whic|h can.cr|
|00003b50| 65 61 74 65 20 6e 61 6d | 65 64 20 70 69 70 65 73 |eate nam|ed pipes|
|00003b60| 20 77 69 74 68 20 6d 6b | 6e 6f 64 20 66 6f 6f 20 | with mk|nod foo |
|00003b70| 70 2e 20 59 6f 75 20 6d | 69 67 68 74 20 74 72 79 |p. You m|ight try|
|00003b80| 20 74 6f 20 61 75 74 6f | 6d 61 74 65 20 61 20 74 | to auto|mate a t|
|00003b90| 65 6c 6e 65 74 0a 73 65 | 73 73 69 6f 6e 2c 20 6b |elnet.se|ssion, k|
|00003ba0| 65 65 70 69 6e 67 20 61 | 20 72 65 63 6f 72 64 20 |eeping a| record |
|00003bb0| 69 6e 20 61 20 66 69 6c | 65 2c 20 6c 69 6b 65 20 |in a fil|e, like |
|00003bc0| 74 68 69 73 3a 0a 58 0a | 58 20 20 23 21 2f 62 69 |this:.X.|X #!/bi|
|00003bd0| 6e 2f 73 68 0a 58 20 20 | 28 75 6d 61 73 6b 20 30 |n/sh.X |(umask 0|
|00003be0| 37 37 3b 20 6d 6b 6e 6f | 64 20 69 6e 70 75 74 20 |77; mkno|d input |
|00003bf0| 70 3b 20 6d 6b 6e 6f 64 | 20 6f 75 74 70 75 74 20 |p; mknod| output |
|00003c00| 70 29 0a 58 20 20 74 65 | 6c 6e 65 74 20 66 6f 6f |p).X te|lnet foo|
|00003c10| 20 3c 20 69 6e 70 75 74 | 20 7c 20 74 65 65 20 72 | < input| | tee r|
|00003c20| 65 63 6f 72 64 20 3e 20 | 6f 75 74 70 75 74 20 26 |ecord > |output &|
|00003c30| 0a 58 20 20 65 78 65 63 | 20 34 3e 69 6e 70 75 74 |.X exec| 4>input|
|00003c40| 20 35 3c 6f 75 74 70 75 | 74 0a 58 20 20 77 61 69 | 5<outpu|t.X wai|
|00003c50| 74 66 6f 72 20 6c 6f 67 | 69 6e 3a 20 3c 26 35 20 |tfor log|in: <&5 |
|00003c60| 32 3e 2f 64 65 76 2f 6e | 75 6c 6c 0a 58 20 20 65 |2>/dev/n|ull.X e|
|00003c70| 63 68 6f 20 27 75 73 65 | 72 6e 61 6d 65 27 20 3e |cho 'use|rname' >|
|00003c80| 26 34 0a 58 20 20 77 61 | 69 74 66 6f 72 20 50 61 |&4.X wa|itfor Pa|
|00003c90| 73 73 77 6f 72 64 3a 20 | 3c 26 35 20 32 3e 2f 64 |ssword: |<&5 2>/d|
|00003ca0| 65 76 2f 6e 75 6c 6c 0a | 58 20 20 65 63 68 6f 20 |ev/null.|X echo |
|00003cb0| 27 70 61 73 73 77 6f 72 | 64 27 20 3e 26 34 0a 58 |'passwor|d' >&4.X|
|00003cc0| 20 20 23 20 65 74 63 2e | 0a 58 0a 58 28 77 61 69 | # etc.|.X.X(wai|
|00003cd0| 74 66 6f 72 20 72 65 61 | 64 73 20 69 74 73 20 69 |tfor rea|ds its i|
|00003ce0| 6e 70 75 74 2c 20 63 68 | 61 72 61 63 74 65 72 20 |nput, ch|aracter |
|00003cf0| 62 79 20 63 68 61 72 61 | 63 74 65 72 2c 20 75 6e |by chara|cter, un|
|00003d00| 74 69 6c 20 69 74 73 20 | 66 69 72 73 74 0a 61 72 |til its |first.ar|
|00003d10| 67 75 6d 65 6e 74 20 6d | 61 74 63 68 65 73 20 74 |gument m|atches t|
|00003d20| 68 65 20 6d 6f 73 74 20 | 72 65 63 65 6e 74 20 63 |he most |recent c|
|00003d30| 68 61 72 61 63 74 65 72 | 73 20 61 73 20 61 20 6c |haracter|s as a l|
|00003d40| 69 74 65 72 61 6c 20 73 | 74 72 69 6e 67 2e 29 0a |iteral s|tring.).|
|00003d50| 58 0a 54 68 69 73 20 61 | 6c 6d 6f 73 74 20 77 6f |X.This a|lmost wo|
|00003d60| 72 6b 73 2e 20 73 68 20 | 63 61 6e 20 68 61 6e 64 |rks. sh |can hand|
|00003d70| 6c 65 20 74 68 69 73 20 | 73 6f 72 74 20 6f 66 20 |le this |sort of |
|00003d80| 61 75 74 6f 6d 61 74 69 | 6f 6e 20 77 69 74 68 6f |automati|on witho|
|00003d90| 75 74 0a 74 72 6f 75 62 | 6c 65 2e 20 54 68 65 20 |ut.troub|le. The |
|00003da0| 6f 6e 6c 79 20 70 72 6f | 62 6c 65 6d 20 69 73 20 |only pro|blem is |
|00003db0| 74 68 61 74 20 74 65 6c | 6e 65 74 20 69 73 20 69 |that tel|net is i|
|00003dc0| 6e 74 65 72 61 63 74 69 | 76 65 2e 20 54 68 61 74 |nteracti|ve. That|
|00003dd0| 27 73 20 77 68 65 72 65 | 0a 70 74 79 20 63 6f 6d |'s where|.pty com|
|00003de0| 65 73 20 69 6e 2e 20 54 | 68 69 73 20 77 6f 72 6b |es in. T|his work|
|00003df0| 73 3a 0a 58 0a 58 20 20 | 23 21 2f 62 69 6e 2f 73 |s:.X.X |#!/bin/s|
|00003e00| 68 0a 58 20 20 28 75 6d | 61 73 6b 20 30 37 37 3b |h.X (um|ask 077;|
|00003e10| 20 6d 6b 6e 6f 64 20 69 | 6e 70 75 74 20 70 3b 20 | mknod i|nput p; |
|00003e20| 6d 6b 6e 6f 64 20 6f 75 | 74 70 75 74 20 70 29 0a |mknod ou|tput p).|
|00003e30| 58 20 20 70 74 79 20 2d | 30 20 74 65 6c 6e 65 74 |X pty -|0 telnet|
|00003e40| 20 66 6f 6f 20 3c 20 69 | 6e 70 75 74 20 7c 20 6e | foo < i|nput | n|
|00003e50| 6f 62 75 66 20 74 65 65 | 20 72 65 63 6f 72 64 20 |obuf tee| record |
|00003e60| 3e 20 6f 75 74 70 75 74 | 20 26 0a 58 20 20 65 78 |> output| &.X ex|
|00003e70| 65 63 20 34 3e 69 6e 70 | 75 74 20 35 3c 6f 75 74 |ec 4>inp|ut 5<out|
|00003e80| 70 75 74 0a 58 20 20 77 | 61 69 74 66 6f 72 20 6c |put.X w|aitfor l|
|00003e90| 6f 67 69 6e 3a 20 3c 26 | 35 20 32 3e 2f 64 65 76 |ogin: <&|5 2>/dev|
|00003ea0| 2f 6e 75 6c 6c 0a 58 20 | 20 65 63 68 6f 20 27 75 |/null.X | echo 'u|
|00003eb0| 73 65 72 6e 61 6d 65 27 | 20 3e 26 34 0a 58 20 20 |sername'| >&4.X |
|00003ec0| 77 61 69 74 66 6f 72 20 | 50 61 73 73 77 6f 72 64 |waitfor |Password|
|00003ed0| 3a 20 3c 26 35 20 32 3e | 2f 64 65 76 2f 6e 75 6c |: <&5 2>|/dev/nul|
|00003ee0| 6c 0a 58 20 20 65 63 68 | 6f 20 27 70 61 73 73 77 |l.X ech|o 'passw|
|00003ef0| 6f 72 64 27 20 3e 26 34 | 0a 58 20 20 23 20 65 74 |ord' >&4|.X # et|
|00003f00| 63 2e 0a 58 0a 4f 6e 20 | 6d 61 63 68 69 6e 65 73 |c..X.On |machines|
|00003f10| 20 77 69 74 68 6f 75 74 | 20 6e 61 6d 65 64 20 70 | without| named p|
|00003f20| 69 70 65 73 2c 20 79 6f | 75 27 6c 6c 20 68 61 76 |ipes, yo|u'll hav|
|00003f30| 65 20 74 6f 20 63 72 65 | 61 74 65 20 28 75 6e 6e |e to cre|ate (unn|
|00003f40| 61 6d 65 64 29 20 70 69 | 70 65 73 0a 69 6e 20 43 |amed) pi|pes.in C|
|00003f50| 2e 20 42 75 74 20 77 68 | 61 74 65 76 65 72 20 6d |. But wh|atever m|
|00003f60| 65 74 68 6f 64 20 6f 66 | 20 61 75 74 6f 6d 61 74 |ethod of| automat|
|00003f70| 69 6f 6e 20 79 6f 75 20 | 75 73 65 2c 20 70 74 79 |ion you |use, pty|
|00003f80| 20 77 69 6c 6c 20 6c 65 | 74 20 79 6f 75 20 61 70 | will le|t you ap|
|00003f90| 70 6c 79 0a 74 68 61 74 | 20 6d 65 74 68 6f 64 20 |ply.that| method |
|00003fa0| 74 6f 20 61 6e 20 69 6e | 74 65 72 61 63 74 69 76 |to an in|teractiv|
|00003fb0| 65 20 70 72 6f 67 72 61 | 6d 2e 0a 58 0a 58 0a 58 |e progra|m..X.X.X|
|00003fc0| 0a 58 35 2e 20 48 6f 77 | 20 64 6f 20 49 20 67 65 |.X5. How| do I ge|
|00003fd0| 74 20 72 6e 20 74 6f 20 | 70 72 6f 63 65 73 73 20 |t rn to |process |
|00003fe0| 4b 49 4c 4c 20 66 69 6c | 65 73 20 69 6e 20 74 68 |KILL fil|es in th|
|00003ff0| 65 20 62 61 63 6b 67 72 | 6f 75 6e 64 3f 0a 58 0a |e backgr|ound?.X.|
|00004000| 41 6e 73 77 65 72 3a 0a | 58 0a 58 20 20 20 25 20 |Answer:.|X.X % |
|00004010| 73 65 73 73 20 2d 52 20 | 73 68 20 2d 63 20 27 73 |sess -R |sh -c 's|
|00004020| 65 73 73 6e 61 6d 65 3b | 20 72 6e 27 20 26 0a 58 |essname;| rn' &.X|
|00004030| 20 20 20 5b 31 5d 20 32 | 30 34 31 37 20 20 20 20 | [1] 2|0417 |
|00004040| 20 20 20 20 3c 20 74 68 | 65 20 73 68 65 6c 6c 20 | < th|e shell |
|00004050| 70 72 69 6e 74 73 20 74 | 68 69 73 20 3e 0a 58 20 |prints t|his >.X |
|00004060| 20 20 73 65 73 73 69 6f | 6e 20 70 66 20 20 20 20 | sessio|n pf |
|00004070| 20 20 20 3c 20 74 68 69 | 73 20 63 6f 6d 65 73 20 | < thi|s comes |
|00004080| 66 72 6f 6d 20 73 65 73 | 73 6e 61 6d 65 20 3e 0a |from ses|sname >.|
|00004090| 58 20 20 20 3c 20 72 6e | 20 70 72 6f 64 75 63 65 |X < rn| produce|
|000040a0| 73 20 6f 75 74 70 75 74 | 20 69 6e 20 74 68 65 20 |s output| in the |
|000040b0| 62 61 63 6b 67 72 6f 75 | 6e 64 2c 20 61 6e 64 20 |backgrou|nd, and |
|000040c0| 79 6f 75 20 63 61 6e 20 | 64 6f 20 73 6f 6d 65 74 |you can |do somet|
|000040d0| 68 69 6e 67 20 65 6c 73 | 65 2e 20 3e 0a 58 20 20 |hing els|e. >.X |
|000040e0| 20 3c 20 2e 2e 2e 20 3e | 0a 58 20 20 20 3c 20 77 | < ... >|.X < w|
|000040f0| 68 65 6e 20 79 6f 75 20 | 77 61 6e 74 20 74 6f 20 |hen you |want to |
|00004100| 70 75 74 20 69 74 20 62 | 61 63 6b 20 69 6e 74 6f |put it b|ack into|
|00004110| 20 74 68 65 20 66 6f 72 | 65 67 72 6f 75 6e 64 3a | the for|eground:|
|00004120| 20 3e 0a 58 20 20 20 25 | 20 25 31 0a 58 20 20 20 | >.X %| %1.X |
|00004130| 73 65 73 73 20 2d 52 20 | 73 68 20 2d 63 20 27 73 |sess -R |sh -c 's|
|00004140| 65 73 73 6e 61 6d 65 3b | 20 72 6e 27 20 20 20 20 |essname;| rn' |
|00004150| 20 20 20 20 20 3c 20 74 | 68 65 20 73 68 65 6c 6c | < t|he shell|
|00004160| 20 70 72 69 6e 74 73 20 | 74 68 69 73 20 3e 0a 58 | prints |this >.X|
|00004170| 20 20 20 5e 43 0a 58 20 | 20 20 25 20 73 65 73 73 | ^C.X | % sess|
|00004180| 20 72 65 63 6f 6e 6e 65 | 63 74 20 70 66 0a 58 20 | reconne|ct pf.X |
|00004190| 20 20 3c 20 6e 6f 77 20 | 69 74 27 73 20 6a 75 73 | < now |it's jus|
|000041a0| 74 20 61 73 20 69 66 20 | 72 6e 20 68 61 64 20 73 |t as if |rn had s|
|000041b0| 74 61 72 74 65 64 20 69 | 6e 20 74 68 65 20 66 6f |tarted i|n the fo|
|000041c0| 72 65 67 72 6f 75 6e 64 | 2e 20 3e 0a 58 0a 73 65 |reground|. >.X.se|
|000041d0| 73 73 20 69 73 20 61 6e | 20 61 62 62 72 65 76 69 |ss is an| abbrevi|
|000041e0| 61 74 69 6f 6e 20 66 6f | 72 20 60 60 70 74 79 20 |ation fo|r ``pty |
|000041f0| 2d 73 27 27 2e 20 49 74 | 20 73 74 61 72 74 73 20 |-s''. It| starts |
|00004200| 61 20 5f 73 65 73 73 69 | 6f 6e 5f 20 77 68 69 63 |a _sessi|on_ whic|
|00004210| 68 20 79 6f 75 0a 63 61 | 6e 20 64 69 73 63 6f 6e |h you.ca|n discon|
|00004220| 6e 65 63 74 20 61 6e 64 | 20 72 65 63 6f 6e 6e 65 |nect and| reconne|
|00004230| 63 74 2e 20 4c 61 74 65 | 72 20 6f 6e 2c 20 77 68 |ct. Late|r on, wh|
|00004240| 65 6e 20 79 6f 75 20 70 | 75 74 20 69 74 20 69 6e |en you p|ut it in|
|00004250| 74 6f 20 74 68 65 0a 62 | 61 63 6b 67 72 6f 75 6e |to the.b|ackgroun|
|00004260| 64 20 61 6e 64 20 74 79 | 70 65 20 5e 43 2c 20 69 |d and ty|pe ^C, i|
|00004270| 74 20 73 74 61 79 73 20 | 64 69 73 63 6f 6e 6e 65 |t stays |disconne|
|00004280| 63 74 65 64 20 69 6e 20 | 74 68 65 20 62 61 63 6b |cted in |the back|
|00004290| 67 72 6f 75 6e 64 2e 20 | 54 68 65 6e 0a 79 6f 75 |ground. |Then.you|
|000042a0| 20 63 61 6e 20 73 74 61 | 72 74 20 61 20 6e 65 77 | can sta|rt a new|
|000042b0| 20 73 65 73 73 69 6f 6e | 20 61 6e 64 20 72 65 63 | session| and rec|
|000042c0| 6f 6e 6e 65 63 74 20 74 | 6f 20 69 74 2e 0a 58 0a |onnect t|o it..X.|
|000042d0| 58 2d 52 20 6d 65 61 6e | 73 20 60 60 64 6f 6e 27 |X-R mean|s ``don'|
|000042e0| 74 20 72 65 61 64 2e 27 | 27 20 49 74 27 73 20 61 |t read.'|' It's a|
|000042f0| 20 6c 6f 74 20 6c 69 6b | 65 20 72 73 68 20 2d 6e | lot lik|e rsh -n|
|00004300| 2e 20 49 74 20 74 65 6c | 6c 73 20 70 74 79 20 6e |. It tel|ls pty n|
|00004310| 6f 74 20 74 6f 0a 72 65 | 61 64 20 61 6e 79 74 68 |ot to.re|ad anyth|
|00004320| 69 6e 67 20 66 72 6f 6d | 20 74 68 65 20 6b 65 79 |ing from| the key|
|00004330| 62 6f 61 72 64 2e 20 57 | 68 65 6e 20 79 6f 75 20 |board. W|hen you |
|00004340| 73 74 61 72 74 20 60 60 | 73 65 73 73 20 72 65 63 |start ``|sess rec|
|00004350| 6f 6e 6e 65 63 74 20 70 | 66 27 27 2c 0a 79 6f 75 |onnect p|f'',.you|
|00004360| 20 64 6f 6e 27 74 20 73 | 70 65 63 69 66 79 20 2d | don't s|pecify -|
|00004370| 52 2c 20 73 6f 20 70 74 | 79 20 64 6f 65 73 20 74 |R, so pt|y does t|
|00004380| 61 6b 65 20 6b 65 79 62 | 6f 61 72 64 20 69 6e 70 |ake keyb|oard inp|
|00004390| 75 74 2e 0a 58 0a 57 68 | 79 20 74 68 69 73 20 77 |ut..X.Wh|y this w|
|000043a0| 61 73 20 61 20 70 72 6f | 62 6c 65 6d 3a 20 72 6e |as a pro|blem: rn|
|000043b0| 20 69 73 20 79 65 74 20 | 61 6e 6f 74 68 65 72 20 | is yet |another |
|000043c0| 60 60 69 6e 74 65 72 61 | 63 74 69 76 65 27 27 20 |``intera|ctive'' |
|000043d0| 70 72 6f 67 72 61 6d 2e | 20 49 74 0a 69 6e 73 69 |program.| It.insi|
|000043e0| 73 74 73 20 6f 6e 20 62 | 65 69 6e 67 20 69 6e 20 |sts on b|eing in |
|000043f0| 74 68 65 20 66 6f 72 65 | 67 72 6f 75 6e 64 20 62 |the fore|ground b|
|00004400| 65 66 6f 72 65 20 69 74 | 20 64 6f 65 73 20 61 6e |efore it| does an|
|00004410| 79 74 68 69 6e 67 20 65 | 6c 73 65 2e 0a 55 6e 66 |ything e|lse..Unf|
|00004420| 6f 72 74 75 6e 61 74 65 | 6c 79 2c 20 61 66 74 65 |ortunate|ly, afte|
|00004430| 72 20 79 6f 75 20 70 75 | 74 20 69 74 20 69 6e 74 |r you pu|t it int|
|00004440| 6f 20 74 68 65 20 66 6f | 72 65 67 72 6f 75 6e 64 |o the fo|reground|
|00004450| 2c 20 69 74 20 6d 69 67 | 68 74 20 73 70 65 6e 64 |, it mig|ht spend|
|00004460| 20 74 65 6e 0a 6d 69 6e | 75 74 65 73 20 70 72 6f | ten.min|utes pro|
|00004470| 63 65 73 73 69 6e 67 20 | 4b 49 4c 4c 20 66 69 6c |cessing |KILL fil|
|00004480| 65 73 21 0a 58 0a 57 68 | 79 20 74 68 65 20 61 6e |es!.X.Wh|y the an|
|00004490| 73 77 65 72 20 73 6f 6c | 76 65 73 20 74 68 65 20 |swer sol|ves the |
|000044a0| 70 72 6f 62 6c 65 6d 3a | 20 4f 6e 63 65 20 61 67 |problem:| Once ag|
|000044b0| 61 69 6e 2c 20 70 74 79 | 20 63 72 65 61 74 65 73 |ain, pty| creates|
|000044c0| 20 61 0a 70 73 65 75 64 | 6f 2d 74 65 72 6d 69 6e | a.pseud|o-termin|
|000044d0| 61 6c 20 66 6f 72 20 72 | 6e 2e 20 55 6e 64 65 72 |al for r|n. Under|
|000044e0| 20 74 68 61 74 20 70 73 | 65 75 64 6f 2d 74 65 72 | that ps|eudo-ter|
|000044f0| 6d 69 6e 61 6c 2c 20 72 | 6e 20 69 73 20 69 6e 20 |minal, r|n is in |
|00004500| 74 68 65 0a 66 6f 72 65 | 67 72 6f 75 6e 64 2c 20 |the.fore|ground, |
|00004510| 73 6f 20 69 74 20 77 69 | 6c 6c 20 68 61 70 70 69 |so it wi|ll happi|
|00004520| 6c 79 20 70 72 6f 63 65 | 73 73 20 4b 49 4c 4c 20 |ly proce|ss KILL |
|00004530| 66 69 6c 65 73 2e 0a 58 | 0a 58 0a 58 36 2e 20 48 |files..X|.X.X6. H|
|00004540| 6f 77 20 64 6f 20 49 20 | 67 65 74 20 74 68 65 20 |ow do I |get the |
|00004550| 74 65 72 6d 69 6e 61 6c | 20 73 70 65 65 64 20 66 |terminal| speed f|
|00004560| 72 6f 6d 20 61 20 73 68 | 65 6c 6c 20 73 63 72 69 |rom a sh|ell scri|
|00004570| 70 74 3f 0a 58 0a 41 6e | 73 77 65 72 3a 20 55 6e |pt?.X.An|swer: Un|
|00004580| 64 65 72 20 73 68 2c 20 | 73 70 65 65 64 3d 22 60 |der sh, |speed="`|
|00004590| 70 74 79 20 73 74 74 79 | 20 73 70 65 65 64 60 22 |pty stty| speed`"|
|000045a0| 2e 0a 58 0a 57 68 79 20 | 74 68 69 73 20 77 61 73 |..X.Why |this was|
|000045b0| 20 61 20 70 72 6f 62 6c | 65 6d 3a 20 57 68 65 6e | a probl|em: When|
|000045c0| 20 79 6f 75 20 74 79 70 | 65 20 60 60 73 74 74 79 | you typ|e ``stty|
|000045d0| 20 73 70 65 65 64 27 27 | 2c 20 6d 6f 73 74 20 76 | speed''|, most v|
|000045e0| 65 72 73 69 6f 6e 73 20 | 6f 66 0a 73 74 74 79 20 |ersions |of.stty |
|000045f0| 77 69 6c 6c 20 6c 6f 6f | 6b 20 66 6f 72 20 74 68 |will loo|k for th|
|00004600| 65 20 74 65 72 6d 69 6e | 61 6c 20 6f 6e 20 73 74 |e termin|al on st|
|00004610| 64 6f 75 74 2c 20 67 65 | 74 20 74 68 65 20 73 70 |dout, ge|t the sp|
|00004620| 65 65 64 20 6f 66 20 74 | 68 61 74 0a 74 65 72 6d |eed of t|hat.term|
|00004630| 69 6e 61 6c 2c 20 61 6e | 64 20 70 72 69 6e 74 20 |inal, an|d print |
|00004640| 74 68 65 20 72 65 73 75 | 6c 74 20 6f 6e 20 73 74 |the resu|lt on st|
|00004650| 64 65 72 72 2e 20 53 6f | 20 69 66 20 79 6f 75 20 |derr. So| if you |
|00004660| 74 72 79 0a 58 0a 58 20 | 20 20 73 70 65 65 64 3d |try.X.X | speed=|
|00004670| 22 60 73 74 74 79 20 73 | 70 65 65 64 60 22 0a 58 |"`stty s|peed`".X|
|00004680| 0a 66 72 6f 6d 20 73 68 | 2c 20 74 77 6f 20 74 68 |.from sh|, two th|
|00004690| 69 6e 67 73 20 67 6f 20 | 77 72 6f 6e 67 2e 20 54 |ings go |wrong. T|
|000046a0| 68 65 20 66 69 72 73 74 | 20 69 73 20 74 68 61 74 |he first| is that|
|000046b0| 20 73 68 20 69 73 20 72 | 65 61 64 69 6e 67 20 73 | sh is r|eading s|
|000046c0| 74 74 79 27 73 0a 6f 75 | 74 70 75 74 2c 20 73 6f |tty's.ou|tput, so|
|000046d0| 20 77 68 65 6e 20 73 74 | 74 79 20 6c 6f 6f 6b 73 | when st|ty looks|
|000046e0| 20 66 6f 72 20 74 68 65 | 20 74 65 72 6d 69 6e 61 | for the| termina|
|000046f0| 6c 2c 20 69 74 27 6c 6c | 20 66 69 6e 64 20 6f 6e |l, it'll| find on|
|00004700| 6c 79 20 61 20 70 69 70 | 65 2e 20 54 68 65 0a 73 |ly a pip|e. The.s|
|00004710| 65 63 6f 6e 64 20 69 73 | 20 74 68 61 74 20 77 68 |econd is| that wh|
|00004720| 65 6e 20 73 74 74 79 20 | 70 72 69 6e 74 73 20 74 |en stty |prints t|
|00004730| 68 65 20 72 65 73 75 6c | 74 2c 20 69 74 20 67 6f |he resul|t, it go|
|00004740| 65 73 20 74 6f 20 73 74 | 64 65 72 72 2c 20 77 68 |es to st|derr, wh|
|00004750| 69 63 68 20 73 68 0a 69 | 73 6e 27 74 20 70 61 79 |ich sh.i|sn't pay|
|00004760| 69 6e 67 20 61 74 74 65 | 6e 74 69 6f 6e 20 74 6f |ing atte|ntion to|
|00004770| 2e 0a 58 0a 4f 74 68 65 | 72 20 76 65 72 73 69 6f |..X.Othe|r versio|
|00004780| 6e 73 20 6f 66 20 73 74 | 74 79 20 6c 6f 6f 6b 20 |ns of st|ty look |
|00004790| 66 6f 72 20 74 68 65 20 | 74 65 72 6d 69 6e 61 6c |for the |terminal|
|000047a0| 20 6f 6e 20 73 74 64 69 | 6e 20 6f 72 20 73 74 64 | on stdi|n or std|
|000047b0| 65 72 72 2c 20 61 6e 64 | 0a 70 72 69 6e 74 20 74 |err, and|.print t|
|000047c0| 68 65 20 72 65 73 75 6c | 74 20 74 6f 20 73 74 64 |he resul|t to std|
|000047d0| 6f 75 74 2e 20 53 6f 20 | 65 76 65 6e 20 69 66 20 |out. So |even if |
|000047e0| 79 6f 75 20 6b 6c 75 64 | 67 65 20 61 72 6f 75 6e |you klud|ge aroun|
|000047f0| 64 20 74 68 65 20 66 69 | 72 73 74 0a 70 72 6f 62 |d the fi|rst.prob|
|00004800| 6c 65 6d 20 62 79 20 6d | 6f 76 69 6e 67 20 66 69 |lem by m|oving fi|
|00004810| 6c 65 20 64 65 73 63 72 | 69 70 74 6f 72 73 20 61 |le descr|iptors a|
|00004820| 72 6f 75 6e 64 2c 20 63 | 68 61 6e 63 65 73 20 61 |round, c|hances a|
|00004830| 72 65 20 79 6f 75 72 20 | 63 6f 64 65 20 77 69 6c |re your |code wil|
|00004840| 6c 0a 6d 79 73 74 65 72 | 69 6f 75 73 6c 79 20 62 |l.myster|iously b|
|00004850| 6c 6f 77 20 75 70 20 6f | 6e 20 74 68 65 20 6e 65 |low up o|n the ne|
|00004860| 78 74 20 6d 61 63 68 69 | 6e 65 2e 0a 58 0a 57 68 |xt machi|ne..X.Wh|
|00004870| 79 20 74 68 65 20 61 6e | 73 77 65 72 20 73 6f 6c |y the an|swer sol|
|00004880| 76 65 73 20 74 68 65 20 | 70 72 6f 62 6c 65 6d 3a |ves the |problem:|
|00004890| 20 70 74 79 20 63 72 65 | 61 74 65 73 20 61 20 70 | pty cre|ates a p|
|000048a0| 73 65 75 64 6f 2d 74 65 | 72 6d 69 6e 61 6c 20 66 |seudo-te|rminal f|
|000048b0| 6f 72 0a 73 74 74 79 2c | 20 77 69 74 68 20 65 78 |or.stty,| with ex|
|000048c0| 61 63 74 6c 79 20 74 68 | 65 20 73 61 6d 65 20 63 |actly th|e same c|
|000048d0| 68 61 72 61 63 74 65 72 | 69 73 74 69 63 73 20 28 |haracter|istics (|
|000048e0| 69 6e 63 6c 75 64 69 6e | 67 20 73 70 65 65 64 29 |includin|g speed)|
|000048f0| 20 61 73 20 74 68 65 0a | 6f 72 69 67 69 6e 61 6c | as the.|original|
|00004900| 20 74 74 79 2e 20 49 74 | 20 64 6f 65 73 6e 27 74 | tty. It| doesn't|
|00004910| 20 6d 61 74 74 65 72 20 | 77 68 65 74 68 65 72 20 | matter |whether |
|00004920| 73 74 74 79 20 6c 6f 6f | 6b 73 20 61 74 20 73 74 |stty loo|ks at st|
|00004930| 64 69 6e 20 6f 72 20 73 | 74 64 6f 75 74 20 6f 72 |din or s|tdout or|
|00004940| 0a 73 74 64 65 72 72 2e | 20 49 74 27 6c 6c 20 6a |.stderr.| It'll j|
|00004950| 75 73 74 20 73 65 65 20 | 74 68 65 20 70 73 65 75 |ust see |the pseu|
|00004960| 64 6f 2d 74 74 79 2e 20 | 49 74 20 61 6c 73 6f 20 |do-tty. |It also |
|00004970| 64 6f 65 73 6e 27 74 20 | 6d 61 74 74 65 72 20 77 |doesn't |matter w|
|00004980| 68 65 74 68 65 72 0a 73 | 74 74 79 20 70 72 69 6e |hether.s|tty prin|
|00004990| 74 73 20 69 74 73 20 72 | 65 73 75 6c 74 20 74 6f |ts its r|esult to|
|000049a0| 20 73 74 64 6f 75 74 20 | 6f 72 20 73 74 64 65 72 | stdout |or stder|
|000049b0| 72 2e 20 70 74 79 20 77 | 69 6c 6c 20 63 6f 6c 6c |r. pty w|ill coll|
|000049c0| 65 63 74 20 62 6f 74 68 | 0a 72 65 73 75 6c 74 73 |ect both|.results|
|000049d0| 20 69 6e 74 6f 20 69 74 | 73 20 73 74 64 6f 75 74 | into it|s stdout|
|000049e0| 20 66 6f 72 20 74 68 65 | 20 73 68 65 6c 6c 2e 0a | for the| shell..|
|000049f0| 45 4e 44 5f 4f 46 5f 46 | 49 4c 45 0a 69 66 20 74 |END_OF_F|ILE.if t|
|00004a00| 65 73 74 20 38 31 37 33 | 20 2d 6e 65 20 60 77 63 |est 8173| -ne `wc|
|00004a10| 20 2d 63 20 3c 27 51 55 | 45 53 54 49 4f 4e 53 27 | -c <'QU|ESTIONS'|
|00004a20| 60 3b 20 74 68 65 6e 0a | 20 20 20 20 65 63 68 6f |`; then.| echo|
|00004a30| 20 73 68 61 72 3a 20 5c | 22 27 51 55 45 53 54 49 | shar: \|"'QUESTI|
|00004a40| 4f 4e 53 27 5c 22 20 75 | 6e 70 61 63 6b 65 64 20 |ONS'\" u|npacked |
|00004a50| 77 69 74 68 20 77 72 6f | 6e 67 20 73 69 7a 65 21 |with wro|ng size!|
|00004a60| 0a 66 69 0a 23 20 65 6e | 64 20 6f 66 20 27 51 55 |.fi.# en|d of 'QU|
|00004a70| 45 53 54 49 4f 4e 53 27 | 0a 66 69 0a 69 66 20 74 |ESTIONS'|.fi.if t|
|00004a80| 65 73 74 20 2d 66 20 27 | 55 4c 4f 47 53 2e 64 72 |est -f '|ULOGS.dr|
|00004a90| 61 66 74 31 27 20 2d 61 | 20 22 24 7b 31 7d 22 20 |aft1' -a| "${1}" |
|00004aa0| 21 3d 20 22 2d 63 22 20 | 3b 20 74 68 65 6e 20 0a |!= "-c" |; then .|
|00004ab0| 20 20 65 63 68 6f 20 73 | 68 61 72 3a 20 57 69 6c | echo s|har: Wil|
|00004ac0| 6c 20 6e 6f 74 20 63 6c | 6f 62 62 65 72 20 65 78 |l not cl|obber ex|
|00004ad0| 69 73 74 69 6e 67 20 66 | 69 6c 65 20 5c 22 27 55 |isting f|ile \"'U|
|00004ae0| 4c 4f 47 53 2e 64 72 61 | 66 74 31 27 5c 22 0a 65 |LOGS.dra|ft1'\".e|
|00004af0| 6c 73 65 0a 65 63 68 6f | 20 73 68 61 72 3a 20 45 |lse.echo| shar: E|
|00004b00| 78 74 72 61 63 74 69 6e | 67 20 5c 22 27 55 4c 4f |xtractin|g \"'ULO|
|00004b10| 47 53 2e 64 72 61 66 74 | 31 27 5c 22 20 5c 28 36 |GS.draft|1'\" \(6|
|00004b20| 32 37 31 20 63 68 61 72 | 61 63 74 65 72 73 5c 29 |271 char|acters\)|
|00004b30| 0a 73 65 64 20 22 73 2f | 5e 58 2f 2f 22 20 3e 27 |.sed "s/|^X//" >'|
|00004b40| 55 4c 4f 47 53 2e 64 72 | 61 66 74 31 27 20 3c 3c |ULOGS.dr|aft1' <<|
|00004b50| 27 45 4e 44 5f 4f 46 5f | 46 49 4c 45 27 0a 41 6e |'END_OF_|FILE'.An|
|00004b60| 20 61 6e 61 6c 79 73 69 | 73 20 6f 66 20 75 73 65 | analysi|s of use|
|00004b70| 72 20 6c 6f 67 69 6e 20 | 72 65 63 6f 72 64 73 0a |r login |records.|
|00004b80| 44 61 6e 69 65 6c 20 4a | 2e 20 42 65 72 6e 73 74 |Daniel J|. Bernst|
|00004b90| 65 69 6e 0a 64 72 61 66 | 74 20 31 0a 58 31 30 2f |ein.draf|t 1.X10/|
|00004ba0| 35 2f 39 31 0a 58 0a 58 | 0a 58 31 2e 20 42 53 44 |5/91.X.X|.X1. BSD|
|00004bb0| 20 6c 6f 67 69 6e 20 72 | 65 63 6f 72 64 73 0a 58 | login r|ecords.X|
|00004bc0| 0a 4f 6e 20 61 20 42 53 | 44 20 55 4e 49 58 20 73 |.On a BS|D UNIX s|
|00004bd0| 79 73 74 65 6d 2c 20 74 | 68 72 65 65 20 66 69 6c |ystem, t|hree fil|
|00004be0| 65 73 20 6b 65 65 70 20 | 74 72 61 63 6b 20 6f 66 |es keep |track of|
|00004bf0| 20 75 73 65 72 20 6c 6f | 67 69 6e 73 2e 20 2f 65 | user lo|gins. /e|
|00004c00| 74 63 2f 75 74 6d 70 0a | 72 65 63 6f 72 64 73 20 |tc/utmp.|records |
|00004c10| 77 68 69 63 68 20 75 73 | 65 72 73 20 61 72 65 20 |which us|ers are |
|00004c20| 6f 6e 20 77 68 69 63 68 | 20 6c 69 6e 65 73 2c 20 |on which| lines, |
|00004c30| 61 6e 64 20 77 68 65 6e | 20 74 68 65 79 20 6c 6f |and when| they lo|
|00004c40| 67 67 65 64 20 69 6e 20 | 28 6f 72 2c 20 66 6f 72 |gged in |(or, for|
|00004c50| 0a 75 6e 75 73 65 64 20 | 6c 69 6e 65 73 2c 20 6c |.unused |lines, l|
|00004c60| 6f 67 67 65 64 20 6f 75 | 74 29 2e 20 54 6f 20 70 |ogged ou|t). To p|
|00004c70| 75 74 20 69 74 20 64 69 | 66 66 65 72 65 6e 74 6c |ut it di|fferentl|
|00004c80| 79 2c 20 75 74 6d 70 20 | 72 65 63 6f 72 64 73 20 |y, utmp |records |
|00004c90| 74 68 65 20 6d 6f 73 74 | 0a 72 65 63 65 6e 74 20 |the most|.recent |
|00004ca0| 73 74 61 72 74 20 6f 72 | 20 73 74 6f 70 20 74 69 |start or| stop ti|
|00004cb0| 6d 65 20 6f 66 20 74 68 | 65 20 6c 61 74 65 73 74 |me of th|e latest|
|00004cc0| 20 73 65 73 73 69 6f 6e | 20 6f 6e 20 65 61 63 68 | session| on each|
|00004cd0| 20 6c 69 6e 65 2c 20 61 | 6e 64 20 77 68 69 63 68 | line, a|nd which|
|00004ce0| 0a 75 73 65 72 20 6f 77 | 6e 73 20 6f 72 20 6f 77 |.user ow|ns or ow|
|00004cf0| 6e 65 64 20 74 68 61 74 | 20 73 65 73 73 69 6f 6e |ned that| session|
|00004d00| 2e 20 75 74 6d 70 20 61 | 6c 73 6f 20 72 65 63 6f |. utmp a|lso reco|
|00004d10| 72 64 73 20 74 68 65 20 | 66 69 72 73 74 20 31 36 |rds the |first 16|
|00004d20| 0a 63 68 61 72 61 63 74 | 65 72 73 20 6f 66 20 74 |.charact|ers of t|
|00004d30| 68 65 20 72 65 6d 6f 74 | 65 20 68 6f 73 74 6e 61 |he remot|e hostna|
|00004d40| 6d 65 20 66 6f 72 20 61 | 6e 79 20 6e 65 74 77 6f |me for a|ny netwo|
|00004d50| 72 6b 20 63 6f 6e 6e 65 | 63 74 69 6f 6e 2e 0a 58 |rk conne|ction..X|
|00004d60| 0a 41 20 70 61 72 61 6c | 6c 65 6c 20 66 69 6c 65 |.A paral|lel file|
|00004d70| 20 2f 75 73 72 2f 61 64 | 6d 2f 77 74 6d 70 20 72 | /usr/ad|m/wtmp r|
|00004d80| 65 63 6f 72 64 73 20 61 | 6c 6c 20 63 68 61 6e 67 |ecords a|ll chang|
|00004d90| 65 73 20 74 6f 20 75 74 | 6d 70 2e 20 54 68 65 20 |es to ut|mp. The |
|00004da0| 6c 61 73 74 20 77 74 6d | 70 0a 65 6e 74 72 79 20 |last wtm|p.entry |
|00004db0| 66 6f 72 20 6c 69 6e 65 | 20 78 78 20 69 73 20 74 |for line| xx is t|
|00004dc0| 68 65 20 63 75 72 72 65 | 6e 74 20 75 74 6d 70 20 |he curre|nt utmp |
|00004dd0| 65 6e 74 72 79 20 66 6f | 72 20 6c 69 6e 65 20 78 |entry fo|r line x|
|00004de0| 78 2e 20 77 74 6d 70 20 | 61 6c 73 6f 20 75 73 65 |x. wtmp |also use|
|00004df0| 73 0a 73 70 65 63 69 61 | 6c 20 63 6f 64 65 73 20 |s.specia|l codes |
|00004e00| 74 6f 20 69 6e 64 69 63 | 61 74 65 20 72 65 62 6f |to indic|ate rebo|
|00004e10| 6f 74 73 20 61 6e 64 20 | 6f 74 68 65 72 20 75 6e |ots and |other un|
|00004e20| 75 73 75 61 6c 20 65 76 | 65 6e 74 73 2e 20 54 79 |usual ev|ents. Ty|
|00004e30| 70 69 63 61 6c 6c 79 0a | 77 74 6d 70 20 69 73 20 |pically.|wtmp is |
|00004e40| 60 60 72 6f 74 61 74 65 | 64 27 27 20 65 76 65 72 |``rotate|d'' ever|
|00004e50| 79 20 6d 6f 6e 74 68 3a | 20 2f 75 73 72 2f 61 64 |y month:| /usr/ad|
|00004e60| 6d 2f 77 74 6d 70 20 69 | 73 20 63 6c 65 61 72 65 |m/wtmp i|s cleare|
|00004e70| 64 2c 20 77 69 74 68 20 | 61 20 63 6f 70 79 0a 6f |d, with |a copy.o|
|00004e80| 66 20 74 68 65 20 6f 6c | 64 20 69 6e 66 6f 72 6d |f the ol|d inform|
|00004e90| 61 74 69 6f 6e 20 73 61 | 76 65 64 20 69 6e 20 2f |ation sa|ved in /|
|00004ea0| 75 73 72 2f 61 64 6d 2f | 77 74 6d 70 2e 30 2e 20 |usr/adm/|wtmp.0. |
|00004eb0| 41 6e 79 20 70 72 65 76 | 69 6f 75 73 20 77 74 6d |Any prev|ious wtm|
|00004ec0| 70 2e 30 20 69 73 0a 73 | 61 76 65 64 20 69 6e 20 |p.0 is.s|aved in |
|00004ed0| 77 74 6d 70 2e 31 2c 20 | 61 6e 64 20 73 6f 20 6f |wtmp.1, |and so o|
|00004ee0| 6e 20 75 70 20 74 6f 20 | 77 74 6d 70 2e 37 2c 20 |n up to |wtmp.7, |
|00004ef0| 77 68 69 63 68 20 69 73 | 20 74 68 72 6f 77 6e 20 |which is| thrown |
|00004f00| 61 77 61 79 2e 0a 58 0a | 54 68 65 20 74 68 69 72 |away..X.|The thir|
|00004f10| 64 20 66 69 6c 65 20 69 | 73 20 2f 75 73 72 2f 61 |d file i|s /usr/a|
|00004f20| 64 6d 2f 6c 61 73 74 6c | 6f 67 2c 20 61 20 66 6c |dm/lastl|og, a fl|
|00004f30| 61 74 20 64 61 74 61 62 | 61 73 65 20 69 6e 64 65 |at datab|ase inde|
|00004f40| 78 65 64 20 62 79 20 75 | 69 64 0a 73 68 6f 77 69 |xed by u|id.showi|
|00004f50| 6e 67 20 74 68 65 20 6d | 6f 73 74 20 72 65 63 65 |ng the m|ost rece|
|00004f60| 6e 74 20 6c 6f 67 69 6e | 20 65 6e 74 72 79 20 66 |nt login| entry f|
|00004f70| 6f 72 20 65 61 63 68 20 | 75 73 65 72 2e 20 6c 61 |or each |user. la|
|00004f80| 73 74 6c 6f 67 20 61 6e | 64 20 75 74 6d 70 20 68 |stlog an|d utmp h|
|00004f90| 61 76 65 0a 64 69 66 66 | 65 72 65 6e 74 20 66 6f |ave.diff|erent fo|
|00004fa0| 72 6d 61 74 73 20 62 75 | 74 20 63 61 72 72 79 20 |rmats bu|t carry |
|00004fb0| 65 73 73 65 6e 74 69 61 | 6c 6c 79 20 74 68 65 20 |essentia|lly the |
|00004fc0| 73 61 6d 65 20 69 6e 66 | 6f 72 6d 61 74 69 6f 6e |same inf|ormation|
|00004fd0| 2e 0a 58 0a 58 0a 58 32 | 2e 20 50 72 6f 62 6c 65 |..X.X.X2|. Proble|
|00004fe0| 6d 73 0a 58 0a 75 74 6d | 70 20 70 72 6f 76 69 64 |ms.X.utm|p provid|
|00004ff0| 65 73 20 6f 6e 6c 79 20 | 31 36 20 63 68 61 72 61 |es only |16 chara|
|00005000| 63 74 65 72 73 20 66 6f | 72 20 68 6f 73 74 6e 61 |cters fo|r hostna|
|00005010| 6d 65 73 20 77 68 69 63 | 68 20 61 72 65 20 6f 66 |mes whic|h are of|
|00005020| 74 65 6e 20 6d 75 63 68 | 20 74 6f 6f 0a 6c 6f 6e |ten much| too.lon|
|00005030| 67 20 74 6f 20 66 69 74 | 2e 20 4f 6e 63 65 20 75 |g to fit|. Once u|
|00005040| 74 6d 70 20 28 61 6e 64 | 20 77 74 6d 70 20 61 6e |tmp (and| wtmp an|
|00005050| 64 20 6c 61 73 74 6c 6f | 67 29 20 74 72 75 6e 63 |d lastlo|g) trunc|
|00005060| 61 74 65 20 61 20 6e 61 | 6d 65 2c 20 61 6e 79 20 |ate a na|me, any |
|00005070| 65 78 74 72 61 0a 63 68 | 61 72 61 63 74 65 72 73 |extra.ch|aracters|
|00005080| 20 61 72 65 20 6c 6f 73 | 74 20 70 65 72 6d 61 6e | are los|t perman|
|00005090| 65 6e 74 6c 79 2e 20 4f | 74 68 65 72 20 69 6e 66 |ently. O|ther inf|
|000050a0| 6f 72 6d 61 74 69 6f 6e | 2d 2d 2d 74 68 65 20 72 |ormation|---the r|
|000050b0| 65 6d 6f 74 65 20 54 43 | 50 0a 70 6f 72 74 2c 20 |emote TC|P.port, |
|000050c0| 74 68 65 20 72 65 6d 6f | 74 65 20 75 73 65 72 20 |the remo|te user |
|000050d0| 61 73 20 73 65 65 6e 20 | 62 79 20 72 6c 6f 67 69 |as seen |by rlogi|
|000050e0| 6e 64 20 6f 72 20 76 69 | 61 20 52 46 43 20 39 33 |nd or vi|a RFC 93|
|000050f0| 31 2c 20 65 74 63 2e 2d | 2d 2d 69 73 6e 27 74 0a |1, etc.-|--isn't.|
|00005100| 72 65 63 6f 72 64 65 64 | 20 61 74 20 61 6c 6c 2e |recorded| at all.|
|00005110| 20 54 68 69 73 20 6d 61 | 6b 65 73 20 69 74 20 76 | This ma|kes it v|
|00005120| 65 72 79 20 64 69 66 66 | 69 63 75 6c 74 20 74 6f |ery diff|icult to|
|00005130| 20 74 72 61 63 65 20 6e | 65 74 77 6f 72 6b 20 61 | trace n|etwork a|
|00005140| 74 74 61 63 6b 73 2e 0a | 58 0a 58 46 75 72 74 68 |ttacks..|X.XFurth|
|00005150| 65 72 6d 6f 72 65 2c 20 | 77 68 65 6e 20 75 73 65 |ermore, |when use|
|00005160| 72 73 20 74 61 6b 65 20 | 61 64 76 61 6e 74 61 67 |rs take |advantag|
|00005170| 65 20 6f 66 20 73 65 73 | 73 69 6f 6e 20 6d 61 6e |e of ses|sion man|
|00005180| 61 67 65 6d 65 6e 74 20 | 28 61 73 0a 64 65 73 63 |agement |(as.desc|
|00005190| 72 69 62 65 64 20 69 6e | 20 5b 5d 29 2c 20 75 74 |ribed in| []), ut|
|000051a0| 6d 70 20 61 6e 64 20 77 | 74 6d 70 20 6c 6f 73 65 |mp and w|tmp lose|
|000051b0| 20 65 76 65 6e 20 6d 6f | 72 65 20 69 6e 66 6f 72 | even mo|re infor|
|000051c0| 6d 61 74 69 6f 6e 2e 20 | 41 20 75 73 65 72 20 6d |mation. |A user m|
|000051d0| 61 79 0a 73 74 61 72 74 | 20 61 20 73 65 73 73 69 |ay.start| a sessi|
|000051e0| 6f 6e 20 61 74 20 77 6f | 72 6b 2c 20 64 69 73 63 |on at wo|rk, disc|
|000051f0| 6f 6e 6e 65 63 74 20 69 | 74 20 77 69 74 68 6f 75 |onnect i|t withou|
|00005200| 74 20 6c 6f 67 67 69 6e | 67 20 6f 75 74 2c 20 67 |t loggin|g out, g|
|00005210| 6f 20 68 6f 6d 65 2c 20 | 61 6e 64 0a 72 65 63 6f |o home, |and.reco|
|00005220| 6e 6e 65 63 74 20 74 6f | 20 74 68 65 20 73 65 73 |nnect to| the ses|
|00005230| 73 69 6f 6e 20 66 72 6f | 6d 20 61 6e 20 65 6e 74 |sion fro|m an ent|
|00005240| 69 72 65 6c 79 20 64 69 | 66 66 65 72 65 6e 74 20 |irely di|fferent |
|00005250| 6c 6f 63 61 74 69 6f 6e | 2e 20 49 74 20 6d 61 6b |location|. It mak|
|00005260| 65 73 0a 73 65 6e 73 65 | 20 74 6f 20 74 61 6c 6b |es.sense| to talk|
|00005270| 20 61 62 6f 75 74 20 74 | 68 65 20 73 74 61 72 74 | about t|he start|
|00005280| 20 61 6e 64 20 73 74 6f | 70 20 74 69 6d 65 20 6f | and sto|p time o|
|00005290| 66 20 74 68 65 20 73 65 | 73 73 69 6f 6e 2c 20 65 |f the se|ssion, e|
|000052a0| 61 63 68 20 63 6f 6e 6e | 65 63 74 0a 61 6e 64 20 |ach conn|ect.and |
|000052b0| 64 69 73 63 6f 6e 6e 65 | 63 74 20 74 69 6d 65 2c |disconne|ct time,|
|000052c0| 20 61 6e 64 20 65 61 63 | 68 20 63 6f 6e 6e 65 63 | and eac|h connec|
|000052d0| 74 20 6c 6f 63 61 74 69 | 6f 6e 2e 20 75 74 6d 70 |t locati|on. utmp|
|000052e0| 20 61 6e 64 20 77 74 6d | 70 20 72 65 63 6f 72 64 | and wtm|p record|
|000052f0| 0a 6e 6f 6e 65 20 6f 66 | 20 74 68 69 73 2e 0a 58 |.none of| this..X|
|00005300| 0a 41 6e 6f 74 68 65 72 | 20 70 72 6f 62 6c 65 6d |.Another| problem|
|00005310| 20 77 69 74 68 20 75 74 | 6d 70 20 69 73 20 74 68 | with ut|mp is th|
|00005320| 61 74 20 69 74 20 68 61 | 73 20 6e 65 76 65 72 20 |at it ha|s never |
|00005330| 62 65 65 6e 20 63 6c 65 | 61 72 20 77 68 65 74 68 |been cle|ar wheth|
|00005340| 65 72 20 75 74 6d 70 0a | 73 68 6f 75 6c 64 20 72 |er utmp.|should r|
|00005350| 65 63 6f 72 64 20 61 6c | 6c 20 63 6f 6e 6e 65 63 |ecord al|l connec|
|00005360| 74 69 6f 6e 73 20 28 73 | 65 65 20 5b 5d 29 20 6f |tions (s|ee []) o|
|00005370| 72 20 6f 6e 6c 79 20 69 | 6e 74 65 72 61 63 74 69 |r only i|nteracti|
|00005380| 76 65 20 63 6f 6e 6e 65 | 63 74 69 6f 6e 73 2e 0a |ve conne|ctions..|
|00005390| 47 69 76 65 6e 20 74 68 | 61 74 20 74 68 65 20 70 |Given th|at the p|
|000053a0| 72 6f 67 72 61 6d 73 20 | 77 68 69 63 68 20 64 65 |rograms |which de|
|000053b0| 70 65 6e 64 20 6d 6f 73 | 74 20 68 65 61 76 69 6c |pend mos|t heavil|
|000053c0| 79 20 6f 6e 20 75 74 6d | 70 2d 2d 2d 74 6f 20 77 |y on utm|p---to w|
|000053d0| 69 74 2c 20 75 73 65 72 | 0a 63 6f 6d 6d 75 6e 69 |it, user|.communi|
|000053e0| 63 61 74 69 6f 6e 20 70 | 72 6f 67 72 61 6d 73 20 |cation p|rograms |
|000053f0| 73 75 63 68 20 61 73 20 | 60 60 74 61 6c 6b 27 27 |such as |``talk''|
|00005400| 20 61 6e 64 20 60 60 77 | 72 69 74 65 27 27 2d 2d | and ``w|rite''--|
|00005410| 2d 73 68 6f 75 6c 64 20 | 6f 6e 6c 79 20 73 65 65 |-should |only see|
|00005420| 0a 69 6e 74 65 72 61 63 | 74 69 76 65 20 63 6f 6e |.interac|tive con|
|00005430| 6e 65 63 74 69 6f 6e 73 | 2c 20 69 74 20 6d 61 6b |nections|, it mak|
|00005440| 65 73 20 73 65 6e 73 65 | 20 74 6f 20 6f 6d 69 74 |es sense| to omit|
|00005450| 20 77 69 6e 64 6f 77 73 | 20 61 6e 64 20 73 75 62 | windows| and sub|
|00005460| 73 68 65 6c 6c 73 2c 0a | 62 75 74 20 74 68 65 6e |shells,.|but then|
|00005470| 20 77 69 6e 64 6f 77 20 | 69 6e 66 6f 72 6d 61 74 | window |informat|
|00005480| 69 6f 6e 20 69 73 20 6c | 6f 73 74 2e 0a 58 0a 6c |ion is l|ost..X.l|
|00005490| 61 73 74 6c 6f 67 20 69 | 73 20 6d 61 69 6e 6c 79 |astlog i|s mainly|
|000054a0| 20 61 6e 20 6f 70 74 69 | 6d 69 7a 61 74 69 6f 6e | an opti|mization|
|000054b0| 3a 20 6c 6f 67 69 6e 20 | 61 6e 64 20 66 69 6e 67 |: login |and fing|
|000054c0| 65 72 20 62 6f 74 68 20 | 72 65 70 6f 72 74 20 74 |er both |report t|
|000054d0| 68 65 20 6c 61 73 74 0a | 6c 6f 67 69 6e 20 74 69 |he last.|login ti|
|000054e0| 6d 65 20 66 6f 72 20 61 | 20 70 61 72 74 69 63 75 |me for a| particu|
|000054f0| 6c 61 72 20 75 73 65 72 | 2c 20 61 6e 64 20 69 74 |lar user|, and it|
|00005500| 20 77 6f 75 6c 64 20 62 | 65 20 77 61 73 74 65 66 | would b|e wastef|
|00005510| 75 6c 20 74 6f 20 73 65 | 61 72 63 68 0a 74 68 72 |ul to se|arch.thr|
|00005520| 6f 75 67 68 20 77 74 6d | 70 20 65 61 63 68 20 74 |ough wtm|p each t|
|00005530| 69 6d 65 2e 20 42 75 74 | 20 6c 61 73 74 6c 6f 67 |ime. But| lastlog|
|00005540| 20 6f 6e 6c 79 20 6b 65 | 65 70 73 20 74 72 61 63 | only ke|eps trac|
|00005550| 6b 20 6f 66 20 74 68 65 | 20 76 65 72 79 20 6c 61 |k of the| very la|
|00005560| 74 65 73 74 0a 6c 6f 67 | 69 6e 2c 20 77 69 74 68 |test.log|in, with|
|00005570| 20 6e 6f 20 69 6e 64 69 | 63 61 74 69 6f 6e 20 6f | no indi|cation o|
|00005580| 66 20 61 6e 79 20 70 72 | 65 76 69 6f 75 73 20 6c |f any pr|evious l|
|00005590| 6f 67 69 6e 73 2e 20 49 | 74 20 64 6f 65 73 20 6e |ogins. I|t does n|
|000055a0| 6f 74 20 72 65 63 6f 72 | 64 0a 6c 6f 67 6f 75 74 |ot recor|d.logout|
|000055b0| 20 74 69 6d 65 2e 20 45 | 76 65 6e 20 77 6f 72 73 | time. E|ven wors|
|000055c0| 65 2c 20 75 73 65 72 73 | 20 61 6e 64 20 61 64 6d |e, users| and adm|
|000055d0| 69 6e 69 73 74 72 61 74 | 6f 72 73 20 63 61 6e 6e |inistrat|ors cann|
|000055e0| 6f 74 20 66 69 6e 64 20 | 6f 75 74 20 77 68 65 6e |ot find |out when|
|000055f0| 0a 74 68 65 69 72 20 61 | 63 63 6f 75 6e 74 73 20 |.their a|ccounts |
|00005600| 61 72 65 20 62 65 69 6e | 67 20 61 74 74 61 63 6b |are bein|g attack|
|00005610| 65 64 2c 20 62 65 63 61 | 75 73 65 20 6c 61 73 74 |ed, beca|use last|
|00005620| 6c 6f 67 20 6f 6e 6c 79 | 20 72 65 63 6f 72 64 73 |log only| records|
|00005630| 0a 73 75 63 63 65 73 73 | 66 75 6c 20 6c 6f 67 69 |.success|ful logi|
|00005640| 6e 73 2e 0a 58 0a 58 0a | 58 33 2e 20 53 6f 6c 75 |ns..X.X.|X3. Solu|
|00005650| 74 69 6f 6e 73 0a 58 0a | 4f 6e 65 20 60 60 73 6f |tions.X.|One ``so|
|00005660| 6c 75 74 69 6f 6e 27 27 | 20 69 73 20 74 6f 20 61 |lution''| is to a|
|00005670| 64 64 20 6d 6f 72 65 20 | 61 6e 64 20 6d 6f 72 65 |dd more |and more|
|00005680| 20 66 69 65 6c 64 73 20 | 74 6f 20 75 74 6d 70 2c | fields |to utmp,|
|00005690| 20 72 65 63 6f 72 64 69 | 6e 67 20 6d 6f 72 65 0a | recordi|ng more.|
|000056a0| 61 6e 64 20 6d 6f 72 65 | 20 69 6e 66 6f 72 6d 61 |and more| informa|
|000056b0| 74 69 6f 6e 2e 20 42 75 | 74 20 74 68 69 73 20 69 |tion. Bu|t this i|
|000056c0| 73 20 74 68 65 20 77 72 | 6f 6e 67 20 73 74 72 61 |s the wr|ong stra|
|000056d0| 74 65 67 79 2e 20 43 6f | 6e 73 69 64 65 72 20 74 |tegy. Co|nsider t|
|000056e0| 68 65 0a 70 61 72 61 6c | 6c 65 6c 20 77 74 6d 70 |he.paral|lel wtmp|
|000056f0| 20 66 69 6c 65 2e 20 49 | 66 20 75 74 6d 70 20 68 | file. I|f utmp h|
|00005700| 61 73 20 28 66 6f 72 20 | 69 6e 73 74 61 6e 63 65 |as (for |instance|
|00005710| 29 20 66 69 65 6c 64 73 | 20 66 6f 72 20 74 68 65 |) fields| for the|
|00005720| 20 6c 61 74 65 73 74 0a | 63 6f 6e 6e 65 63 74 69 | latest.|connecti|
|00005730| 6f 6e 2c 20 74 68 65 6e | 20 65 76 65 72 79 20 74 |on, then| every t|
|00005740| 69 6d 65 20 61 20 75 73 | 65 72 20 63 6f 6e 6e 65 |ime a us|er conne|
|00005750| 63 74 73 20 6f 72 20 64 | 69 73 63 6f 6e 6e 65 63 |cts or d|isconnec|
|00005760| 74 73 2c 20 74 68 65 20 | 62 61 73 69 63 0a 73 65 |ts, the |basic.se|
|00005770| 73 73 69 6f 6e 20 66 69 | 65 6c 64 73 20 77 69 6c |ssion fi|elds wil|
|00005780| 6c 20 62 65 20 72 65 70 | 65 61 74 65 64 20 69 6e |l be rep|eated in|
|00005790| 20 77 74 6d 70 20 66 6f | 72 20 6e 6f 20 67 6f 6f | wtmp fo|r no goo|
|000057a0| 64 20 72 65 61 73 6f 6e | 2e 20 54 68 69 73 20 77 |d reason|. This w|
|000057b0| 61 73 74 65 73 0a 64 69 | 73 6b 20 73 70 61 63 65 |astes.di|sk space|
|000057c0| 20 62 75 74 20 61 6c 73 | 6f 20 69 6e 64 69 63 61 | but als|o indica|
|000057d0| 74 65 73 20 61 20 66 75 | 6e 64 61 6d 65 6e 74 61 |tes a fu|ndamenta|
|000057e0| 6c 20 66 61 69 6c 75 72 | 65 20 69 6e 20 74 68 65 |l failur|e in the|
|000057f0| 20 6d 6f 64 65 6c 2e 0a | 58 0a 54 68 65 20 72 69 | model..|X.The ri|
|00005800| 67 68 74 20 73 6f 6c 75 | 74 69 6f 6e 20 69 73 20 |ght solu|tion is |
|00005810| 74 6f 20 67 69 76 65 20 | 65 61 63 68 20 66 69 6c |to give |each fil|
|00005820| 65 20 61 20 73 70 65 63 | 69 66 69 63 20 70 75 72 |e a spec|ific pur|
|00005830| 70 6f 73 65 2e 20 75 74 | 6d 70 20 73 68 6f 75 6c |pose. ut|mp shoul|
|00005840| 64 0a 6f 6e 6c 79 20 6b | 65 65 70 20 74 72 61 63 |d.only k|eep trac|
|00005850| 6b 20 6f 66 20 73 65 73 | 73 69 6f 6e 73 3b 20 74 |k of ses|sions; t|
|00005860| 68 65 20 68 6f 73 74 20 | 66 69 65 6c 64 20 73 68 |he host |field sh|
|00005870| 6f 75 6c 64 20 62 65 20 | 72 65 6d 6f 76 65 64 2e |ould be |removed.|
|00005880| 20 43 6f 6d 70 6c 65 74 | 65 0a 63 6f 6e 6e 65 63 | Complet|e.connec|
|00005890| 74 69 6f 6e 20 69 6e 66 | 6f 72 6d 61 74 69 6f 6e |tion inf|ormation|
|000058a0| 2c 20 69 6e 63 6c 75 64 | 69 6e 67 20 63 6f 6e 6e |, includ|ing conn|
|000058b0| 65 63 74 20 61 6e 64 20 | 64 69 73 63 6f 6e 6e 65 |ect and |disconne|
|000058c0| 63 74 20 74 69 6d 65 73 | 2c 20 72 65 6d 6f 74 65 |ct times|, remote|
|000058d0| 0a 68 6f 73 74 20 61 73 | 20 62 6f 74 68 20 49 50 |.host as| both IP|
|000058e0| 20 61 64 64 72 65 73 73 | 20 61 6e 64 20 6e 61 6d | address| and nam|
|000058f0| 65 2c 20 72 65 6d 6f 74 | 65 20 70 6f 72 74 2c 20 |e, remot|e port, |
|00005900| 61 6e 64 20 72 65 6d 6f | 74 65 20 75 73 65 72 20 |and remo|te user |
|00005910| 69 66 20 6b 6e 6f 77 6e | 2c 0a 63 61 6e 20 67 6f |if known|,.can go|
|00005920| 20 69 6e 74 6f 20 61 20 | 73 65 70 61 72 61 74 65 | into a |separate|
|00005930| 20 66 69 6c 65 2e 0a 58 | 0a 54 6f 20 73 6f 6c 76 | file..X|.To solv|
|00005940| 65 20 74 68 65 20 70 72 | 6f 62 6c 65 6d 20 6f 66 |e the pr|oblem of|
|00005950| 20 69 6e 74 65 72 61 63 | 74 69 76 65 20 76 65 72 | interac|tive ver|
|00005960| 73 75 73 20 6e 6f 6e 2d | 69 6e 74 65 72 61 63 74 |sus non-|interact|
|00005970| 69 76 65 20 73 65 73 73 | 69 6f 6e 73 2c 0a 75 74 |ive sess|ions,.ut|
|00005980| 6d 70 20 73 68 6f 75 6c | 64 20 62 65 20 73 70 6c |mp shoul|d be spl|
|00005990| 69 74 20 69 6e 20 74 77 | 6f 2e 20 54 68 65 20 6f |it in tw|o. The o|
|000059a0| 72 69 67 69 6e 61 6c 20 | 75 74 6d 70 20 73 68 6f |riginal |utmp sho|
|000059b0| 75 6c 64 20 62 65 20 70 | 72 65 73 65 72 76 65 64 |uld be p|reserved|
|000059c0| 20 66 6f 72 0a 69 6e 74 | 65 72 61 63 74 69 76 65 | for.int|eractive|
|000059d0| 2c 20 75 73 65 72 2d 74 | 6f 2d 75 73 65 72 20 63 |, user-t|o-user c|
|000059e0| 6f 6d 6d 75 6e 69 63 61 | 74 69 6f 6e 2e 20 41 20 |ommunica|tion. A |
|000059f0| 73 65 70 61 72 61 74 65 | 20 66 69 6c 65 20 73 68 |separate| file sh|
|00005a00| 6f 75 6c 64 20 72 65 63 | 6f 72 64 0a 61 6c 6c 20 |ould rec|ord.all |
|00005a10| 73 65 73 73 69 6f 6e 73 | 2e 0a 58 0a 6c 61 73 74 |sessions|..X.last|
|00005a20| 6c 6f 67 20 63 61 6e 20 | 62 65 20 69 6d 70 72 6f |log can |be impro|
|00005a30| 76 65 64 20 69 6e 20 6d | 61 6e 79 20 77 61 79 73 |ved in m|any ways|
|00005a40| 2c 20 77 68 69 63 68 20 | 77 65 20 77 69 6c 6c 20 |, which |we will |
|00005a50| 6e 6f 74 20 64 69 73 63 | 75 73 73 20 69 6e 0a 64 |not disc|uss in.d|
|00005a60| 65 74 61 69 6c 20 68 65 | 72 65 2e 20 56 61 72 69 |etail he|re. Vari|
|00005a70| 6f 75 73 20 76 65 6e 64 | 6f 72 73 20 28 65 2e 67 |ous vend|ors (e.g|
|00005a80| 2e 2c 20 44 45 43 29 20 | 68 61 76 65 20 61 6c 72 |., DEC) |have alr|
|00005a90| 65 61 64 79 20 61 64 64 | 65 64 20 66 65 61 74 75 |eady add|ed featu|
|00005aa0| 72 65 73 0a 61 6c 6f 6e | 67 20 74 68 65 73 65 20 |res.alon|g these |
|00005ab0| 6c 69 6e 65 73 2e 0a 58 | 0a 58 0a 58 34 2e 20 70 |lines..X|.X.X4. p|
|00005ac0| 74 79 20 75 73 65 72 20 | 6c 6f 67 69 6e 20 66 69 |ty user |login fi|
|00005ad0| 6c 65 73 0a 58 0a 54 68 | 65 20 61 75 74 68 6f 72 |les.X.Th|e author|
|00005ae0| 27 73 20 70 73 65 75 64 | 6f 2d 74 74 79 20 73 65 |'s pseud|o-tty se|
|00005af0| 73 73 69 6f 6e 20 6d 61 | 6e 61 67 65 72 2c 20 70 |ssion ma|nager, p|
|00005b00| 74 79 20 34 2e 30 20 28 | 5b 5d 29 2c 20 6d 61 69 |ty 4.0 (|[]), mai|
|00005b10| 6e 74 61 69 6e 73 20 73 | 65 76 65 72 61 6c 0a 75 |ntains s|everal.u|
|00005b20| 73 65 72 20 6c 6f 67 69 | 6e 20 66 69 6c 65 73 2e |ser logi|n files.|
|00005b30| 20 75 74 6d 70 20 61 6e | 64 20 77 74 6d 70 20 72 | utmp an|d wtmp r|
|00005b40| 65 63 6f 72 64 20 69 6e | 74 65 72 61 63 74 69 76 |ecord in|teractiv|
|00005b50| 65 20 73 65 73 73 69 6f | 6e 73 20 61 73 20 61 62 |e sessio|ns as ab|
|00005b60| 6f 76 65 2e 0a 54 68 65 | 20 75 73 65 72 20 63 61 |ove..The| user ca|
|00005b70| 6e 20 73 70 65 63 69 66 | 79 20 61 74 20 73 65 73 |n specif|y at ses|
|00005b80| 73 69 6f 6e 20 73 74 61 | 72 74 75 70 20 77 68 65 |sion sta|rtup whe|
|00005b90| 74 68 65 72 20 74 68 65 | 20 73 65 73 73 69 6f 6e |ther the| session|
|00005ba0| 20 69 73 0a 69 6e 74 65 | 72 61 63 74 69 76 65 20 | is.inte|ractive |
|00005bb0| 6f 72 20 6e 6f 74 2e 20 | 46 6f 72 20 6d 61 78 69 |or not. |For maxi|
|00005bc0| 6d 75 6d 20 66 6c 65 78 | 69 62 69 6c 69 74 79 2c |mum flex|ibility,|
|00005bd0| 20 70 74 79 20 6c 65 74 | 73 20 74 68 65 20 75 73 | pty let|s the us|
|00005be0| 65 72 20 63 68 6f 6f 73 | 65 0a 68 69 73 20 68 6f |er choos|e.his ho|
|00005bf0| 73 74 20 66 69 65 6c 64 | 20 69 6e 20 75 74 6d 70 |st field| in utmp|
|00005c00| 2e 20 54 68 69 73 20 77 | 61 79 20 74 68 65 20 75 |. This w|ay the u|
|00005c10| 73 65 72 20 63 61 6e 20 | 63 6f 6e 66 69 67 75 72 |ser can |configur|
|00005c20| 65 20 68 69 73 20 73 65 | 73 73 69 6f 6e 73 20 74 |e his se|ssions t|
|00005c30| 6f 0a 77 6f 72 6b 20 70 | 72 6f 70 65 72 6c 79 20 |o.work p|roperly |
|00005c40| 77 69 74 68 20 76 61 72 | 69 6f 75 73 20 75 74 6d |with var|ious utm|
|00005c50| 70 2d 70 72 6f 63 65 73 | 73 69 6e 67 20 70 72 6f |p-proces|sing pro|
|00005c60| 67 72 61 6d 73 2e 20 28 | 54 68 65 20 73 79 73 74 |grams. (|The syst|
|00005c70| 65 6d 0a 61 64 6d 69 6e | 69 73 74 72 61 74 6f 72 |em.admin|istrator|
|00005c80| 20 6d 61 79 20 64 69 73 | 61 62 6c 65 20 74 68 65 | may dis|able the|
|00005c90| 73 65 20 66 65 61 74 75 | 72 65 73 2e 29 0a 58 0a |se featu|res.).X.|
|00005ca0| 41 6c 6c 20 64 69 73 63 | 6f 6e 6e 65 63 74 61 62 |All disc|onnectab|
|00005cb0| 6c 65 20 73 65 73 73 69 | 6f 6e 73 20 61 72 65 20 |le sessi|ons are |
|00005cc0| 72 65 63 6f 72 64 65 64 | 20 69 6e 20 73 65 73 73 |recorded| in sess|
|00005cd0| 6e 6f 77 2c 20 77 68 69 | 63 68 20 68 61 73 20 66 |now, whi|ch has f|
|00005ce0| 69 65 6c 64 73 0a 66 6f | 72 20 75 73 65 72 6e 61 |ields.fo|r userna|
|00005cf0| 6d 65 2c 20 75 69 64 2c | 20 73 74 61 72 74 2f 73 |me, uid,| start/s|
|00005d00| 74 6f 70 20 74 69 6d 65 | 2c 20 73 65 73 73 69 6f |top time|, sessio|
|00005d10| 6e 20 6d 61 73 74 65 72 | 20 70 72 6f 63 65 73 73 |n master| process|
|00005d20| 20 69 64 2c 20 61 6e 64 | 20 6c 69 6e 65 2e 0a 73 | id, and| line..s|
|00005d30| 65 73 73 6c 6f 67 20 6b | 65 65 70 73 20 61 20 70 |esslog k|eeps a p|
|00005d40| 65 72 6d 61 6e 65 6e 74 | 20 72 65 63 6f 72 64 20 |ermanent| record |
|00005d50| 6f 66 20 63 68 61 6e 67 | 65 73 20 74 6f 20 73 65 |of chang|es to se|
|00005d60| 73 73 6e 6f 77 2e 20 4c | 69 6e 65 73 20 61 72 65 |ssnow. L|ines are|
|00005d70| 0a 73 70 65 63 69 66 69 | 65 64 20 62 79 20 74 77 |.specifi|ed by tw|
|00005d80| 6f 20 63 68 61 72 61 63 | 74 65 72 73 20 28 65 2e |o charac|ters (e.|
|00005d90| 67 2e 2c 20 70 30 20 66 | 6f 72 20 2f 64 65 76 2f |g., p0 f|or /dev/|
|00005da0| 74 74 79 70 30 29 2e 0a | 58 0a 54 68 65 20 72 65 |ttyp0)..|X.The re|
|00005db0| 6c 61 74 69 6f 6e 20 62 | 65 74 77 65 65 6e 20 73 |lation b|etween s|
|00005dc0| 65 73 73 69 6f 6e 73 20 | 61 6e 64 20 63 6f 6e 6e |essions |and conn|
|00005dd0| 65 63 74 69 6f 6e 73 20 | 69 73 20 72 65 63 6f 72 |ections |is recor|
|00005de0| 64 65 64 20 69 6e 20 73 | 63 6e 6f 77 2e 0a 73 63 |ded in s|cnow..sc|
|00005df0| 6e 6f 77 20 6c 69 73 74 | 73 20 65 61 63 68 20 73 |now list|s each s|
|00005e00| 65 73 73 69 6f 6e 20 62 | 79 20 6c 69 6e 65 2c 20 |ession b|y line, |
|00005e10| 74 68 65 20 6c 61 74 65 | 73 74 20 63 6f 6e 6e 65 |the late|st conne|
|00005e20| 63 74 69 6f 6e 20 73 74 | 61 72 74 2f 73 74 6f 70 |ction st|art/stop|
|00005e30| 20 74 69 6d 65 2c 0a 61 | 6e 64 20 63 6f 6d 70 6c | time,.a|nd compl|
|00005e40| 65 74 65 20 72 65 6d 6f | 74 65 20 68 6f 73 74 20 |ete remo|te host |
|00005e50| 69 6e 66 6f 72 6d 61 74 | 69 6f 6e 2e 20 41 6c 6c |informat|ion. All|
|00005e60| 20 63 68 61 6e 67 65 73 | 20 74 6f 20 73 63 6e 6f | changes| to scno|
|00005e70| 77 20 61 72 65 20 6c 69 | 73 74 65 64 20 69 6e 0a |w are li|sted in.|
|00005e80| 73 63 6c 6f 67 2e 0a 58 | 0a 4e 6f 74 65 20 74 68 |sclog..X|.Note th|
|00005e90| 61 74 20 69 74 20 6d 61 | 6b 65 73 20 73 65 6e 73 |at it ma|kes sens|
|00005ea0| 65 20 74 6f 20 72 65 63 | 6f 72 64 20 63 6f 6e 6e |e to rec|ord conn|
|00005eb0| 65 63 74 69 6f 6e 73 20 | 73 65 70 61 72 61 74 65 |ections |separate|
|00005ec0| 6c 79 2c 20 65 76 65 6e | 20 74 68 6f 73 65 0a 6e |ly, even| those.n|
|00005ed0| 6f 74 20 63 6f 6e 6e 65 | 63 74 65 64 20 74 6f 20 |ot conne|cted to |
|00005ee0| 61 6e 79 20 70 61 72 74 | 69 63 75 6c 61 72 20 73 |any part|icular s|
|00005ef0| 65 73 73 69 6f 6e 2e 20 | 54 68 65 20 63 6f 6e 6e |ession. |The conn|
|00005f00| 65 63 74 69 6f 6e 20 6d | 61 6e 61 67 65 72 73 20 |ection m|anagers |
|00005f10| 28 67 65 74 74 79 2c 0a | 74 65 6c 6e 65 74 64 2c |(getty,.|telnetd,|
|00005f20| 20 65 74 63 2e 29 20 6d | 69 67 68 74 20 6b 65 65 | etc.) m|ight kee|
|00005f30| 70 20 63 6f 6e 6e 6e 6f | 77 20 61 6e 64 20 63 6f |p connno|w and co|
|00005f40| 6e 6e 6c 6f 67 20 66 69 | 6c 65 73 20 6c 69 73 74 |nnlog fi|les list|
|00005f50| 69 6e 67 20 63 75 72 72 | 65 6e 74 0a 63 6f 6e 6e |ing curr|ent.conn|
|00005f60| 65 63 74 69 6f 6e 73 2e | 20 49 6e 20 74 68 65 20 |ections.| In the |
|00005f70| 6d 65 61 6e 74 69 6d 65 | 20 70 74 79 20 6d 61 69 |meantime| pty mai|
|00005f80| 6e 74 61 69 6e 73 20 73 | 65 73 73 6e 6f 77 2c 20 |ntains s|essnow, |
|00005f90| 73 65 73 73 6c 6f 67 2c | 20 73 63 6e 6f 77 2c 0a |sesslog,| scnow,.|
|00005fa0| 73 63 6c 6f 67 2c 20 75 | 74 6d 70 2c 20 61 6e 64 |sclog, u|tmp, and|
|00005fb0| 20 77 74 6d 70 2e 20 54 | 68 69 73 20 66 69 6e 61 | wtmp. T|his fina|
|00005fc0| 6c 6c 79 20 6d 61 6b 65 | 73 20 61 20 6c 6f 67 69 |lly make|s a logi|
|00005fd0| 63 61 6c 20 73 65 74 20 | 6f 66 20 72 65 63 6f 72 |cal set |of recor|
|00005fe0| 64 73 20 66 6f 72 0a 77 | 68 69 63 68 20 75 73 65 |ds for.w|hich use|
|00005ff0| 72 20 77 61 73 20 75 73 | 69 6e 67 20 77 68 61 74 |r was us|ing what|
|00006000| 20 73 65 73 73 69 6f 6e | 20 66 72 6f 6d 20 77 68 | session| from wh|
|00006010| 65 72 65 2e 0a 58 0a 4e | 6f 74 69 63 65 20 74 68 |ere..X.N|otice th|
|00006020| 65 20 63 6c 65 61 6e 20 | 64 69 73 74 69 6e 63 74 |e clean |distinct|
|00006030| 69 6f 6e 20 62 65 74 77 | 65 65 6e 20 63 6f 6e 6e |ion betw|een conn|
|00006040| 65 63 74 69 6f 6e 20 69 | 6e 66 6f 72 6d 61 74 69 |ection i|nformati|
|00006050| 6f 6e 20 61 6e 64 20 73 | 65 73 73 69 6f 6e 0a 69 |on and s|ession.i|
|00006060| 6e 66 6f 72 6d 61 74 69 | 6f 6e 2e 20 41 6c 6c 20 |nformati|on. All |
|00006070| 73 65 73 73 69 6f 6e 20 | 69 6e 66 6f 72 6d 61 74 |session |informat|
|00006080| 69 6f 6e 20 69 73 20 6d | 61 69 6e 74 61 69 6e 65 |ion is m|aintaine|
|00006090| 64 20 62 79 20 6f 6e 65 | 20 70 72 6f 67 72 61 6d |d by one| program|
|000060a0| 2c 20 70 74 79 2e 0a 54 | 68 65 20 75 74 6d 70 20 |, pty..T|he utmp |
|000060b0| 68 61 6e 64 6c 69 6e 67 | 20 63 61 6e 20 62 65 20 |handling| can be |
|000060c0| 63 6f 6d 70 6c 65 74 65 | 6c 79 20 72 65 6d 6f 76 |complete|ly remov|
|000060d0| 65 64 20 66 72 6f 6d 20 | 69 6e 69 74 2c 20 67 65 |ed from |init, ge|
|000060e0| 74 74 79 2c 20 74 65 6c | 6e 65 74 64 2c 0a 6c 6f |tty, tel|netd,.lo|
|000060f0| 67 69 6e 2c 20 72 6c 6f | 67 69 6e 64 2c 20 73 63 |gin, rlo|gind, sc|
|00006100| 72 65 65 6e 2c 20 78 74 | 65 72 6d 2c 20 73 75 6e |reen, xt|erm, sun|
|00006110| 76 69 65 77 2c 20 61 6e | 64 20 64 6f 7a 65 6e 73 |view, an|d dozens|
|00006120| 20 6f 66 20 6f 74 68 65 | 72 20 70 72 6f 67 72 61 | of othe|r progra|
|00006130| 6d 73 2e 0a 58 0a 58 0a | 58 35 2e 20 53 65 63 75 |ms..X.X.|X5. Secu|
|00006140| 72 69 74 79 20 69 73 73 | 75 65 73 0a 58 0a 49 74 |rity iss|ues.X.It|
|00006150| 20 69 73 20 77 6f 72 74 | 68 20 6e 6f 74 69 6e 67 | is wort|h noting|
|00006160| 20 74 68 61 74 20 53 75 | 6e 20 64 65 73 74 72 6f | that Su|n destro|
|00006170| 79 65 64 20 61 6e 79 20 | 63 72 65 64 69 62 69 6c |yed any |credibil|
|00006180| 69 74 79 20 69 74 20 6d | 69 67 68 74 20 68 61 76 |ity it m|ight hav|
|00006190| 65 20 68 61 64 0a 69 6e | 20 69 74 73 20 75 73 65 |e had.in| its use|
|000061a0| 72 20 6c 6f 67 69 6e 20 | 66 69 6c 65 73 20 62 79 |r login |files by|
|000061b0| 20 6d 61 6b 69 6e 67 20 | 2f 65 74 63 2f 75 74 6d | making |/etc/utm|
|000061c0| 70 20 6d 6f 64 65 20 36 | 36 36 2e 20 54 68 69 73 |p mode 6|66. This|
|000061d0| 20 69 73 20 77 68 61 74 | 20 74 68 65 0a 61 75 74 | is what| the.aut|
|000061e0| 68 6f 72 20 63 61 6c 6c | 73 20 61 20 53 43 49 4e |hor call|s a SCIN|
|000061f0| 55 50 3a 20 53 65 63 75 | 72 69 74 79 20 43 6f 6d |UP: Secu|rity Com|
|00006200| 70 72 6f 6d 69 73 65 20 | 49 6e 74 72 6f 64 75 63 |promise |Introduc|
|00006210| 65 64 20 69 6e 20 74 68 | 65 20 4e 61 6d 65 20 6f |ed in th|e Name o|
|00006220| 66 0a 55 73 65 72 20 50 | 6f 77 65 72 2e 20 53 75 |f.User P|ower. Su|
|00006230| 6e 20 66 6f 75 6e 64 20 | 73 6f 20 6d 61 6e 79 20 |n found |so many |
|00006240| 70 72 6f 67 72 61 6d 73 | 20 69 6e 20 69 74 73 20 |programs| in its |
|00006250| 74 6f 6f 6c 73 65 74 20 | 74 68 61 74 20 77 61 6e |toolset |that wan|
|00006260| 74 65 64 20 74 6f 0a 75 | 70 64 61 74 65 20 75 74 |ted to.u|pdate ut|
|00006270| 6d 70 20 74 68 61 74 20 | 69 74 20 72 65 6d 6f 76 |mp that |it remov|
|00006280| 65 64 20 61 6c 6c 20 75 | 74 6d 70 20 70 72 6f 74 |ed all u|tmp prot|
|00006290| 65 63 74 69 6f 6e 20 72 | 61 74 68 65 72 20 74 68 |ection r|ather th|
|000062a0| 61 6e 20 69 6d 70 6c 65 | 6d 65 6e 74 20 61 0a 70 |an imple|ment a.p|
|000062b0| 72 6f 70 65 72 20 73 65 | 63 75 72 69 74 79 20 6d |roper se|curity m|
|000062c0| 65 63 68 61 6e 69 73 6d | 2e 20 59 65 61 72 73 20 |echanism|. Years |
|000062d0| 6c 61 74 65 72 2c 20 73 | 65 63 75 72 69 74 79 20 |later, s|ecurity |
|000062e0| 65 78 70 65 72 74 73 20 | 28 61 6e 64 20 73 79 73 |experts |(and sys|
|000062f0| 74 65 6d 0a 63 72 61 63 | 6b 65 72 73 29 20 61 72 |tem.crac|kers) ar|
|00006300| 65 20 73 74 69 6c 6c 20 | 66 69 6e 64 69 6e 67 20 |e still |finding |
|00006310| 64 65 76 61 73 74 61 74 | 69 6e 67 20 68 6f 6c 65 |devastat|ing hole|
|00006320| 73 20 63 61 75 73 65 64 | 20 62 79 20 53 75 6e 27 |s caused| by Sun'|
|00006330| 73 20 69 6e 63 72 65 64 | 69 62 6c 79 0a 70 6f 6f |s incred|ibly.poo|
|00006340| 72 20 6a 75 64 67 6d 65 | 6e 74 2e 0a 58 0a 4e 65 |r judgme|nt..X.Ne|
|00006350| 65 64 6c 65 73 73 20 74 | 6f 20 73 61 79 2c 20 74 |edless t|o say, t|
|00006360| 68 65 20 61 75 74 68 6f | 72 20 64 6f 65 73 20 6e |he autho|r does n|
|00006370| 6f 74 20 61 70 70 72 6f | 76 65 20 6f 66 20 75 6e |ot appro|ve of un|
|00006380| 70 72 6f 74 65 63 74 65 | 64 20 6c 6f 67 69 6e 20 |protecte|d login |
|00006390| 66 69 6c 65 73 2e 0a 41 | 20 73 69 6e 67 6c 65 20 |files..A| single |
|000063a0| 70 72 6f 67 72 61 6d 2d | 2d 2d 70 74 79 2d 2d 2d |program-|--pty---|
|000063b0| 63 61 6e 20 70 72 6f 76 | 69 64 65 20 73 61 66 65 |can prov|ide safe|
|000063c0| 20 75 74 6d 70 20 73 65 | 72 76 69 63 65 20 66 6f | utmp se|rvice fo|
|000063d0| 72 20 61 6c 6c 20 70 72 | 6f 67 72 61 6d 73 0a 77 |r all pr|ograms.w|
|000063e0| 68 69 63 68 20 6e 65 65 | 64 20 69 74 2e 0a 58 0a |hich nee|d it..X.|
|000063f0| 58 0a 52 65 66 65 72 65 | 6e 63 65 73 0a 58 0a 58 |X.Refere|nces.X.X|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.