home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume05 / secure < prev    next >
SHell self-extracting ARchive  |  1991-08-27  |  4.6 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

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

You can browse this item here: secure

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file ASCII text default
100% TrID E-Mail message (Var. 2) default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime application/mbox default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 46 72 6f 6d 20 64 65 63 | 77 72 6c 21 6c 61 62 72 |From dec|wrl!labr|
|00000010| 65 61 21 65 6f 73 21 61 | 6d 65 73 21 6d 61 69 6c |ea!eos!a|mes!mail|
|00000020| 72 75 73 21 74 75 74 2e | 63 69 73 2e 6f 68 69 6f |rus!tut.|cis.ohio|
|00000030| 2d 73 74 61 74 65 2e 65 | 64 75 21 63 77 6a 63 63 |-state.e|du!cwjcc|
|00000040| 21 68 61 6c 21 6e 63 6f | 61 73 74 21 61 6c 6c 62 |!hal!nco|ast!allb|
|00000050| 65 72 79 20 53 61 74 20 | 44 65 63 20 20 33 20 31 |ery Sat |Dec 3 1|
|00000060| 37 3a 32 31 3a 34 30 20 | 50 53 54 20 31 39 38 38 |7:21:40 |PST 1988|
|00000070| 0a 41 72 74 69 63 6c 65 | 20 37 33 39 20 6f 66 20 |.Article| 739 of |
|00000080| 63 6f 6d 70 2e 73 6f 75 | 72 63 65 73 2e 6d 69 73 |comp.sou|rces.mis|
|00000090| 63 3a 0a 50 61 74 68 3a | 20 67 72 61 6e 69 74 65 |c:.Path:| granite|
|000000a0| 21 64 65 63 77 72 6c 21 | 6c 61 62 72 65 61 21 65 |!decwrl!|labrea!e|
|000000b0| 6f 73 21 61 6d 65 73 21 | 6d 61 69 6c 72 75 73 21 |os!ames!|mailrus!|
|000000c0| 74 75 74 2e 63 69 73 2e | 6f 68 69 6f 2d 73 74 61 |tut.cis.|ohio-sta|
|000000d0| 74 65 2e 65 64 75 21 63 | 77 6a 63 63 21 68 61 6c |te.edu!c|wjcc!hal|
|000000e0| 21 6e 63 6f 61 73 74 21 | 61 6c 6c 62 65 72 79 0a |!ncoast!|allbery.|
|000000f0| 46 72 6f 6d 3a 20 64 67 | 40 6c 61 6b 61 72 74 2e |From: dg|@lakart.|
|00000100| 55 55 43 50 20 28 44 61 | 76 69 64 20 47 6f 6f 64 |UUCP (Da|vid Good|
|00000110| 65 6e 6f 75 67 68 29 0a | 4e 65 77 73 67 72 6f 75 |enough).|Newsgrou|
|00000120| 70 73 3a 20 63 6f 6d 70 | 2e 73 6f 75 72 63 65 73 |ps: comp|.sources|
|00000130| 2e 6d 69 73 63 0a 53 75 | 62 6a 65 63 74 3a 20 76 |.misc.Su|bject: v|
|00000140| 30 35 69 30 36 33 3a 20 | 53 6f 6c 76 69 6e 67 20 |05i063: |Solving |
|00000150| 74 68 65 20 73 65 74 75 | 69 64 20 73 63 72 69 70 |the setu|id scrip|
|00000160| 74 20 70 72 6f 62 6c 65 | 6d 0a 4d 65 73 73 61 67 |t proble|m.Messag|
|00000170| 65 2d 49 44 3a 20 3c 38 | 38 31 31 32 33 31 35 32 |e-ID: <8|81123152|
|00000180| 32 2e 41 41 31 34 38 38 | 34 40 6c 61 6b 61 72 74 |2.AA1488|4@lakart|
|00000190| 2e 55 55 43 50 3e 0a 44 | 61 74 65 3a 20 33 20 44 |.UUCP>.D|ate: 3 D|
|000001a0| 65 63 20 38 38 20 30 30 | 3a 32 37 3a 35 37 20 47 |ec 88 00|:27:57 G|
|000001b0| 4d 54 0a 53 65 6e 64 65 | 72 3a 20 61 6c 6c 62 65 |MT.Sende|r: allbe|
|000001c0| 72 79 40 6e 63 6f 61 73 | 74 2e 55 55 43 50 0a 52 |ry@ncoas|t.UUCP.R|
|000001d0| 65 70 6c 79 2d 54 6f 3a | 20 64 67 40 6c 61 6b 61 |eply-To:| dg@laka|
|000001e0| 72 74 2e 55 55 43 50 20 | 28 44 61 76 69 64 20 47 |rt.UUCP |(David G|
|000001f0| 6f 6f 64 65 6e 6f 75 67 | 68 29 0a 4c 69 6e 65 73 |oodenoug|h).Lines|
|00000200| 3a 20 31 33 39 0a 41 70 | 70 72 6f 76 65 64 3a 20 |: 139.Ap|proved: |
|00000210| 61 6c 6c 62 65 72 79 40 | 6e 63 6f 61 73 74 2e 55 |allbery@|ncoast.U|
|00000220| 55 43 50 0a 0a 50 6f 73 | 74 69 6e 67 2d 6e 75 6d |UCP..Pos|ting-num|
|00000230| 62 65 72 3a 20 56 6f 6c | 75 6d 65 20 35 2c 20 49 |ber: Vol|ume 5, I|
|00000240| 73 73 75 65 20 36 33 0a | 53 75 62 6d 69 74 74 65 |ssue 63.|Submitte|
|00000250| 64 2d 62 79 3a 20 22 44 | 61 76 69 64 20 47 6f 6f |d-by: "D|avid Goo|
|00000260| 64 65 6e 6f 75 67 68 22 | 20 3c 64 67 40 6c 61 6b |denough"| <dg@lak|
|00000270| 61 72 74 2e 55 55 43 50 | 3e 0a 41 72 63 68 69 76 |art.UUCP|>.Archiv|
|00000280| 65 2d 6e 61 6d 65 3a 20 | 73 65 63 75 72 65 0a 0a |e-name: |secure..|
|00000290| 5b 41 6e 79 20 73 65 74 | 75 69 64 20 67 75 72 75 |[Any set|uid guru|
|000002a0| 73 20 77 61 6e 74 20 74 | 6f 20 73 61 79 20 77 68 |s want t|o say wh|
|000002b0| 65 74 68 65 72 20 74 68 | 69 73 20 69 73 20 61 63 |ether th|is is ac|
|000002c0| 74 75 61 6c 6c 79 20 73 | 65 63 75 72 65 20 6f 72 |tually s|ecure or|
|000002d0| 20 6e 6f 74 3f 20 2b 2b | 62 73 61 5d 0a 0a 41 66 | not? ++|bsa]..Af|
|000002e0| 74 65 72 20 61 6c 6c 20 | 74 68 65 20 64 69 73 63 |ter all |the disc|
|000002f0| 75 73 73 69 6f 6e 20 61 | 62 6f 75 74 20 74 68 65 |ussion a|bout the|
|00000300| 20 6c 61 63 6b 20 6f 66 | 20 73 65 63 75 72 69 74 | lack of| securit|
|00000310| 79 20 6f 66 20 73 65 74 | 75 69 64 20 73 68 65 6c |y of set|uid shel|
|00000320| 6c 20 73 63 72 69 70 74 | 73 2c 0a 49 20 70 75 74 |l script|s,.I put|
|00000330| 20 74 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 20 74 | the fol|lowing t|
|00000340| 6f 67 65 74 68 65 72 2e | 20 49 74 20 72 75 6e 73 |ogether.| It runs|
|00000350| 20 73 68 65 6c 6c 20 73 | 63 72 69 70 74 73 2c 20 | shell s|cripts, |
|00000360| 62 75 74 20 69 73 20 61 | 20 6c 69 74 74 6c 65 20 |but is a| little |
|00000370| 6d 6f 72 65 0a 63 61 72 | 65 66 75 6c 20 61 73 20 |more.car|eful as |
|00000380| 74 6f 20 77 68 61 74 20 | 69 74 20 77 69 6c 6c 20 |to what |it will |
|00000390| 72 75 6e 2e 20 54 68 65 | 72 65 27 73 20 6e 6f 20 |run. The|re's no |
|000003a0| 6d 61 6b 65 66 69 6c 65 | 20 2d 20 6a 75 73 74 20 |makefile| - just |
|000003b0| 63 6f 6d 70 69 6c 65 20 | 74 68 69 73 2c 0a 63 6f |compile |this,.co|
|000003c0| 70 79 20 69 74 20 74 6f | 20 2f 62 69 6e 2f 73 65 |py it to| /bin/se|
|000003d0| 63 75 72 65 2c 20 63 68 | 6f 77 6e 20 69 74 20 74 |cure, ch|own it t|
|000003e0| 6f 20 72 6f 6f 74 2c 20 | 61 6e 64 20 63 68 6d 6f |o root, |and chmo|
|000003f0| 64 20 69 74 20 34 37 35 | 35 2e 20 73 65 63 75 72 |d it 475|5. secur|
|00000400| 65 2e 38 0a 64 65 73 63 | 72 69 62 65 73 20 74 68 |e.8.desc|ribes th|
|00000410| 65 20 6c 61 79 6f 75 74 | 20 6f 66 20 2f 65 74 63 |e layout| of /etc|
|00000420| 2f 73 65 63 75 72 65 20 | 2d 20 69 74 27 73 20 6a |/secure |- it's j|
|00000430| 75 73 74 20 61 20 6c 69 | 6e 65 20 66 6f 72 20 65 |ust a li|ne for e|
|00000440| 61 63 68 20 73 61 66 65 | 20 73 68 65 6c 6c 0a 73 |ach safe| shell.s|
|00000450| 63 72 69 70 74 2c 20 63 | 6f 6e 74 61 69 6e 69 6e |cript, c|ontainin|
|00000460| 67 20 74 68 65 20 66 75 | 6c 6c 20 70 61 74 68 6e |g the fu|ll pathn|
|00000470| 61 6d 65 20 66 69 72 73 | 74 2c 20 61 6e 64 20 74 |ame firs|t, and t|
|00000480| 68 65 20 6e 75 6d 65 72 | 69 63 20 75 69 64 20 74 |he numer|ic uid t|
|00000490| 68 65 20 72 75 6e 20 74 | 68 65 0a 73 63 72 69 70 |he run t|he.scrip|
|000004a0| 74 2e 0a 2d 2d 20 0a 09 | 64 67 40 6c 61 6b 61 72 |t..-- ..|dg@lakar|
|000004b0| 74 2e 55 55 43 50 20 2d | 20 44 61 76 69 64 20 47 |t.UUCP -| David G|
|000004c0| 6f 6f 64 65 6e 6f 75 67 | 68 09 09 2b 2d 2d 2d 2b |oodenoug|h..+---+|
|000004d0| 0a 09 09 09 09 09 09 09 | 7c 20 2b 2d 2b 2d 2b 0a |........|| +-+-+.|
|000004e0| 09 2e 2e 2e 2e 2e 2e 2e | 20 21 68 61 72 76 61 72 |........| !harvar|
|000004f0| 64 21 78 61 69 74 21 6c | 61 6b 61 72 74 21 64 67 |d!xait!l|akart!dg|
|00000500| 09 09 09 2b 2d 2b 2d 2b | 20 7c 0a 41 4b 41 3a 09 |...+-+-+| |.AKA:.|
|00000510| 64 67 25 6c 61 6b 61 72 | 74 2e 75 75 63 70 40 68 |dg%lakar|t.uucp@h|
|00000520| 61 72 76 61 72 64 2e 68 | 61 72 76 61 72 64 2e 65 |arvard.h|arvard.e|
|00000530| 64 75 09 20 20 09 20 20 | 2b 2d 2d 2d 2b 0a 0a 2d |du. . |+---+..-|
|00000540| 2d 2d 20 63 75 74 20 68 | 65 72 65 20 2d 2d 2d 20 |-- cut h|ere --- |
|00000550| 63 75 74 20 68 65 72 65 | 20 2d 2d 2d 20 63 75 74 |cut here| --- cut|
|00000560| 20 68 65 72 65 20 2d 2d | 2d 20 63 75 74 20 68 65 | here --|- cut he|
|00000570| 72 65 20 2d 2d 2d 20 63 | 75 74 20 68 65 72 65 20 |re --- c|ut here |
|00000580| 2d 2d 2d 0a 23 21 20 2f | 62 69 6e 2f 73 68 0a 23 |---.#! /|bin/sh.#|
|00000590| 20 54 68 69 73 20 69 73 | 20 61 20 73 68 65 6c 6c | This is| a shell|
|000005a0| 20 61 72 63 68 69 76 65 | 2c 20 6d 65 61 6e 69 6e | archive|, meanin|
|000005b0| 67 3a 0a 23 20 31 2e 20 | 52 65 6d 6f 76 65 20 65 |g:.# 1. |Remove e|
|000005c0| 76 65 72 79 74 68 69 6e | 67 20 61 62 6f 76 65 20 |verythin|g above |
|000005d0| 74 68 65 20 27 23 21 20 | 2f 62 69 6e 2f 73 68 27 |the '#! |/bin/sh'|
|000005e0| 20 6c 69 6e 65 2e 0a 23 | 20 32 2e 20 53 61 76 65 | line..#| 2. Save|
|000005f0| 20 74 68 65 20 72 65 73 | 75 6c 74 69 6e 67 20 74 | the res|ulting t|
|00000600| 65 78 74 20 69 6e 20 61 | 20 66 69 6c 65 2e 0a 23 |ext in a| file..#|
|00000610| 20 33 2e 20 45 78 65 63 | 75 74 65 20 74 68 65 20 | 3. Exec|ute the |
|00000620| 66 69 6c 65 20 77 69 74 | 68 20 2f 62 69 6e 2f 73 |file wit|h /bin/s|
|00000630| 68 20 28 4e 4f 54 20 63 | 73 68 29 20 74 6f 20 63 |h (NOT c|sh) to c|
|00000640| 72 65 61 74 65 20 74 68 | 65 20 66 69 6c 65 73 3a |reate th|e files:|
|00000650| 0a 23 09 41 3a 20 73 65 | 63 75 72 65 2e 63 0a 23 |.#.A: se|cure.c.#|
|00000660| 09 42 3a 20 73 65 63 75 | 72 65 2e 38 0a 23 0a 23 |.B: secu|re.8.#.#|
|00000670| 20 55 6e 77 72 61 70 70 | 69 6e 67 20 77 69 74 68 | Unwrapp|ing with|
|00000680| 20 6e 6f 20 6f 70 74 69 | 6f 6e 73 20 70 72 65 76 | no opti|ons prev|
|00000690| 65 6e 74 73 20 6f 76 65 | 72 77 72 69 74 69 6e 67 |ents ove|rwriting|
|000006a0| 20 66 69 6c 65 73 20 74 | 68 61 74 20 61 6c 72 65 | files t|hat alre|
|000006b0| 61 64 79 20 65 78 69 73 | 74 3b 0a 23 20 67 69 76 |ady exis|t;.# giv|
|000006c0| 69 6e 67 20 61 20 27 2d | 63 27 20 73 77 69 74 63 |ing a '-|c' switc|
|000006d0| 68 20 63 61 75 73 65 73 | 20 66 69 6c 65 73 20 74 |h causes| files t|
|000006e0| 6f 20 62 65 20 6f 76 65 | 72 77 72 69 74 74 65 6e |o be ove|rwritten|
|000006f0| 20 72 65 67 61 72 64 6c | 65 73 73 2e 0a 23 0a 23 | regardl|ess..#.#|
|00000700| 20 77 72 61 70 70 65 64 | 20 62 79 20 64 67 40 6c | wrapped| by dg@l|
|00000710| 61 6b 61 72 74 28 44 61 | 76 69 64 20 47 6f 6f 64 |akart(Da|vid Good|
|00000720| 65 6e 6f 75 67 68 29 20 | 6f 6e 20 57 65 64 20 4e |enough) |on Wed N|
|00000730| 6f 76 20 32 33 20 31 30 | 3a 31 33 3a 31 38 20 45 |ov 23 10|:13:18 E|
|00000740| 53 54 20 31 39 38 38 0a | 23 0a 69 66 20 74 65 73 |ST 1988.|#.if tes|
|00000750| 74 20 2d 66 20 73 65 63 | 75 72 65 2e 63 20 2d 61 |t -f sec|ure.c -a|
|00000760| 20 78 24 31 20 21 3d 20 | 78 2d 63 0a 74 68 65 6e | x$1 != |x-c.then|
|00000770| 0a 20 20 20 20 65 63 68 | 6f 20 73 68 61 72 3a 20 |. ech|o shar: |
|00000780| 66 69 6c 65 20 73 65 63 | 75 72 65 2e 63 20 61 6c |file sec|ure.c al|
|00000790| 72 65 61 64 79 20 65 78 | 69 73 74 73 0a 65 6c 73 |ready ex|ists.els|
|000007a0| 65 0a 20 20 20 20 65 63 | 68 6f 20 73 68 61 72 3a |e. ec|ho shar:|
|000007b0| 20 65 78 74 72 61 63 74 | 69 6e 67 20 73 65 63 75 | extract|ing secu|
|000007c0| 72 65 2e 63 0a 73 65 64 | 20 22 73 2f 5e 58 2f 2f |re.c.sed| "s/^X//|
|000007d0| 22 20 3c 3c 5c 23 23 5f | 5f 45 4f 46 2e 2e 73 65 |" <<\##_|_EOF..se|
|000007e0| 63 75 72 65 2e 63 5f 5f | 23 23 20 3e 73 65 63 75 |cure.c__|## >secu|
|000007f0| 72 65 2e 63 0a 58 23 69 | 6e 63 6c 75 64 65 09 3c |re.c.X#i|nclude.<|
|00000800| 73 74 64 69 6f 2e 68 3e | 0a 58 0a 58 23 64 65 66 |stdio.h>|.X.X#def|
|00000810| 69 6e 65 09 09 53 45 43 | 55 52 45 09 09 22 2f 65 |ine..SEC|URE.."/e|
|00000820| 74 63 2f 73 65 63 75 72 | 65 22 0a 58 0a 58 6d 61 |tc/secur|e".X.Xma|
|00000830| 69 6e 28 6e 2c 20 61 29 | 0a 58 63 68 61 72 20 2a |in(n, a)|.Xchar *|
|00000840| 2a 61 3b 0a 58 20 7b 0a | 58 20 20 20 20 69 6e 74 |*a;.X {.|X int|
|00000850| 20 75 69 64 3b 0a 58 20 | 20 20 20 46 49 4c 45 20 | uid;.X | FILE |
|00000860| 2a 66 70 3b 0a 58 20 20 | 20 20 63 68 61 72 20 70 |*fp;.X | char p|
|00000870| 72 6f 67 72 61 6d 5b 31 | 30 30 5d 3b 0a 58 0a 58 |rogram[1|00];.X.X|
|00000880| 20 20 20 20 69 66 20 28 | 73 74 72 63 6d 70 28 61 | if (|strcmp(a|
|00000890| 5b 30 5d 2c 20 22 53 45 | 43 2d 55 52 45 22 29 29 |[0], "SE|C-URE"))|
|000008a0| 2f 2a 20 49 27 6d 20 64 | 61 6d 6e 65 64 20 69 66 |/* I'm d|amned if|
|000008b0| 20 49 20 6b 6e 6f 77 20 | 77 68 79 20 74 68 69 73 | I know |why this|
|000008c0| 20 69 73 20 2a 2f 0a 58 | 20 20 20 20 20 7b 09 09 | is */.X| {..|
|000008d0| 09 09 2f 2a 20 6e 65 63 | 65 73 73 61 72 79 2c 20 |../* nec|essary, |
|000008e0| 62 75 74 20 69 74 20 69 | 73 20 2a 2f 0a 58 09 28 |but it i|s */.X.(|
|000008f0| 76 6f 69 64 29 20 73 74 | 72 63 70 79 28 70 72 6f |void) st|rcpy(pro|
|00000900| 67 72 61 6d 2c 20 61 5b | 30 5d 29 3b 0a 58 09 61 |gram, a[|0]);.X.a|
|00000910| 5b 30 5d 20 3d 20 22 53 | 45 43 2d 55 52 45 22 3b |[0] = "S|EC-URE";|
|00000920| 0a 58 09 65 78 65 63 76 | 28 70 72 6f 67 72 61 6d |.X.execv|(program|
|00000930| 2c 20 61 29 3b 09 2f 2a | 20 72 65 20 65 78 65 63 |, a);./*| re exec|
|00000940| 20 6f 75 72 73 65 6c 76 | 65 73 20 73 6f 20 73 65 | ourselv|es so se|
|00000950| 74 75 69 64 20 62 69 74 | 73 20 77 6f 72 6b 20 2a |tuid bit|s work *|
|00000960| 2f 0a 58 09 65 78 69 74 | 28 31 29 3b 09 09 2f 2a |/.X.exit|(1);../*|
|00000970| 20 74 68 69 73 20 73 68 | 6f 75 6c 64 20 6e 65 76 | this sh|ould nev|
|00000980| 65 72 20 68 61 70 70 65 | 6e 20 2a 2f 0a 58 20 20 |er happe|n */.X |
|00000990| 20 20 20 7d 0a 58 20 20 | 20 20 69 66 20 28 28 66 | }.X | if ((f|
|000009a0| 70 20 3d 20 66 6f 70 65 | 6e 28 61 5b 31 5d 2c 20 |p = fope|n(a[1], |
|000009b0| 22 72 22 29 29 20 3d 3d | 20 28 46 49 4c 45 20 2a |"r")) ==| (FILE *|
|000009c0| 29 20 4e 55 4c 4c 29 0a | 58 20 20 20 20 20 20 65 |) NULL).|X e|
|000009d0| 78 69 74 28 31 29 3b 09 | 09 09 2f 2a 20 66 69 6c |xit(1);.|../* fil|
|000009e0| 65 20 6e 6f 74 20 66 6f | 75 6e 64 20 2a 2f 0a 58 |e not fo|und */.X|
|000009f0| 20 20 20 20 28 76 6f 69 | 64 29 20 66 63 6c 6f 73 | (voi|d) fclos|
|00000a00| 65 28 66 70 29 3b 0a 58 | 20 20 20 20 69 66 20 28 |e(fp);.X| if (|
|00000a10| 61 5b 31 5d 5b 30 5d 20 | 21 3d 20 27 2f 27 29 0a |a[1][0] |!= '/').|
|00000a20| 58 20 20 20 20 20 20 65 | 78 69 74 28 31 29 3b 09 |X e|xit(1);.|
|00000a30| 09 09 2f 2a 20 6f 6e 6c | 79 20 70 61 73 73 20 61 |../* onl|y pass a|
|00000a40| 6e 20 61 62 73 6f 6c 75 | 74 65 20 70 61 74 68 6e |n absolu|te pathn|
|00000a50| 61 6d 65 20 74 6f 20 2f | 62 69 6e 2f 73 68 20 2a |ame to /|bin/sh *|
|00000a60| 2f 0a 58 20 20 20 20 69 | 66 20 28 28 66 70 20 3d |/.X i|f ((fp =|
|00000a70| 20 66 6f 70 65 6e 28 53 | 45 43 55 52 45 2c 20 22 | fopen(S|ECURE, "|
|00000a80| 72 22 29 29 20 3d 3d 20 | 28 46 49 4c 45 20 2a 29 |r")) == |(FILE *)|
|00000a90| 20 4e 55 4c 4c 29 0a 58 | 20 20 20 20 20 20 65 78 | NULL).X| ex|
|00000aa0| 69 74 28 31 29 3b 09 09 | 09 2f 2a 20 63 61 6e 27 |it(1);..|./* can'|
|00000ab0| 74 20 66 69 6e 64 20 74 | 68 65 20 66 69 6c 65 20 |t find t|he file |
|00000ac0| 6f 66 20 73 65 63 75 72 | 65 20 70 72 6f 67 72 61 |of secur|e progra|
|00000ad0| 6d 73 20 2a 2f 0a 58 20 | 20 20 20 77 68 69 6c 65 |ms */.X | while|
|00000ae0| 20 28 66 73 63 61 6e 66 | 28 66 70 2c 20 22 25 73 | (fscanf|(fp, "%s|
|00000af0| 20 25 64 22 2c 20 70 72 | 6f 67 72 61 6d 2c 20 26 | %d", pr|ogram, &|
|00000b00| 75 69 64 29 20 3d 3d 20 | 32 29 0a 58 20 20 20 20 |uid) == |2).X |
|00000b10| 20 7b 0a 58 09 69 66 20 | 28 73 74 72 63 6d 70 28 | {.X.if |(strcmp(|
|00000b20| 70 72 6f 67 72 61 6d 2c | 20 61 5b 31 5d 29 20 3d |program,| a[1]) =|
|00000b30| 3d 20 30 29 0a 58 09 20 | 7b 09 09 09 2f 2a 20 61 |= 0).X. |{.../* a|
|00000b40| 68 61 20 2e 2e 2e 2e 2e | 20 77 65 20 66 6f 75 6e |ha .....| we foun|
|00000b50| 64 20 6f 75 72 20 70 72 | 6f 67 72 61 6d 20 2a 2f |d our pr|ogram */|
|00000b60| 0a 58 09 20 20 20 20 28 | 76 6f 69 64 29 20 66 63 |.X. (|void) fc|
|00000b70| 6c 6f 73 65 28 66 70 29 | 3b 0a 58 09 20 20 20 20 |lose(fp)|;.X. |
|00000b80| 28 76 6f 69 64 29 20 75 | 6e 73 65 74 65 6e 76 28 |(void) u|nsetenv(|
|00000b90| 22 49 46 53 22 29 3b 0a | 58 09 09 09 09 2f 2a 20 |"IFS");.|X..../* |
|00000ba0| 74 77 65 61 6b 20 74 68 | 65 20 65 6e 76 69 72 6f |tweak th|e enviro|
|00000bb0| 6e 6d 65 6e 74 20 66 6f | 72 20 61 64 64 65 64 20 |nment fo|r added |
|00000bc0| 73 61 66 65 74 79 20 2a | 2f 0a 58 09 20 20 20 20 |safety *|/.X. |
|00000bd0| 28 76 6f 69 64 29 20 73 | 65 74 65 6e 76 28 22 50 |(void) s|etenv("P|
|00000be0| 41 54 48 22 2c 20 22 2f | 62 69 6e 3a 2f 75 73 72 |ATH", "/|bin:/usr|
|00000bf0| 2f 62 69 6e 22 2c 20 31 | 29 3b 0a 58 09 20 20 20 |/bin", 1|);.X. |
|00000c00| 20 28 76 6f 69 64 29 20 | 73 65 74 75 69 64 28 75 | (void) |setuid(u|
|00000c10| 69 64 29 3b 09 2f 2a 20 | 73 65 74 20 74 68 65 20 |id);./* |set the |
|00000c20| 75 69 64 20 2a 2f 0a 58 | 09 20 20 20 20 61 5b 30 |uid */.X|. a[0|
|00000c30| 5d 20 3d 20 22 2d 73 68 | 22 3b 0a 58 09 20 20 20 |] = "-sh|";.X. |
|00000c40| 20 65 78 65 63 76 28 22 | 2f 62 69 6e 2f 73 68 22 | execv("|/bin/sh"|
|00000c50| 2c 20 61 29 3b 0a 58 09 | 20 20 20 20 65 78 69 74 |, a);.X.| exit|
|00000c60| 28 31 29 3b 09 09 2f 2a | 20 74 68 69 73 20 73 68 |(1);../*| this sh|
|00000c70| 6f 75 6c 64 20 6e 65 76 | 65 72 20 68 61 70 70 65 |ould nev|er happe|
|00000c80| 6e 20 2a 2f 0a 58 09 20 | 7d 0a 58 20 20 20 20 20 |n */.X. |}.X |
|00000c90| 7d 0a 58 20 20 20 20 65 | 78 69 74 28 31 29 3b 09 |}.X e|xit(1);.|
|00000ca0| 09 09 2f 2a 20 63 6f 6d | 65 20 68 65 72 65 20 69 |../* com|e here i|
|00000cb0| 66 20 77 65 20 64 69 64 | 6e 27 74 20 66 69 6e 64 |f we did|n't find|
|00000cc0| 20 74 68 65 20 70 72 6f | 67 72 61 6d 20 2a 2f 0a | the pro|gram */.|
|00000cd0| 58 20 7d 0a 23 23 5f 5f | 45 4f 46 2e 2e 73 65 63 |X }.##__|EOF..sec|
|00000ce0| 75 72 65 2e 63 5f 5f 23 | 23 0a 66 69 0a 69 66 20 |ure.c__#|#.fi.if |
|00000cf0| 74 65 73 74 20 2d 66 20 | 73 65 63 75 72 65 2e 38 |test -f |secure.8|
|00000d00| 20 2d 61 20 78 24 31 20 | 21 3d 20 78 2d 63 0a 74 | -a x$1 |!= x-c.t|
|00000d10| 68 65 6e 0a 20 20 20 20 | 65 63 68 6f 20 73 68 61 |hen. |echo sha|
|00000d20| 72 3a 20 66 69 6c 65 20 | 73 65 63 75 72 65 2e 38 |r: file |secure.8|
|00000d30| 20 61 6c 72 65 61 64 79 | 20 65 78 69 73 74 73 0a | already| exists.|
|00000d40| 65 6c 73 65 0a 20 20 20 | 20 65 63 68 6f 20 73 68 |else. | echo sh|
|00000d50| 61 72 3a 20 65 78 74 72 | 61 63 74 69 6e 67 20 73 |ar: extr|acting s|
|00000d60| 65 63 75 72 65 2e 38 0a | 73 65 64 20 22 73 2f 5e |ecure.8.|sed "s/^|
|00000d70| 58 2f 2f 22 20 3c 3c 5c | 23 23 5f 5f 45 4f 46 2e |X//" <<\|##__EOF.|
|00000d80| 2e 73 65 63 75 72 65 2e | 38 5f 5f 23 23 20 3e 73 |.secure.|8__## >s|
|00000d90| 65 63 75 72 65 2e 38 0a | 58 2e 5c 22 20 64 67 40 |ecure.8.|X.\" dg@|
|00000da0| 6c 61 6b 61 72 74 20 2d | 20 44 61 76 69 64 20 47 |lakart -| David G|
|00000db0| 6f 6f 64 65 6e 6f 75 67 | 68 20 57 65 64 20 4e 6f |oodenoug|h Wed No|
|00000dc0| 76 20 32 33 20 30 39 3a | 34 37 3a 31 32 20 45 53 |v 23 09:|47:12 ES|
|00000dd0| 54 20 31 39 38 38 0a 58 | 2e 5c 22 0a 58 2e 54 48 |T 1988.X|.\".X.TH|
|00000de0| 20 53 45 43 55 52 45 20 | 38 20 22 4e 6f 76 20 32 | SECURE |8 "Nov 2|
|00000df0| 33 2c 20 31 39 38 38 22 | 0a 58 2e 55 43 20 34 0a |3, 1988"|.X.UC 4.|
|00000e00| 58 2e 53 48 20 4e 41 4d | 45 0a 58 2e 42 20 73 65 |X.SH NAM|E.X.B se|
|00000e10| 63 75 72 65 0a 58 5c 2d | 20 72 75 6e 20 73 65 74 |cure.X\-| run set|
|00000e20| 75 69 64 20 73 68 65 6c | 6c 20 73 63 72 69 70 74 |uid shel|l script|
|00000e30| 73 20 73 61 66 65 6c 79 | 0a 58 2e 53 48 20 53 59 |s safely|.X.SH SY|
|00000e40| 4e 4f 50 53 49 53 0a 58 | 2e 42 20 23 21 20 2f 62 |NOPSIS.X|.B #! /b|
|00000e50| 69 6e 2f 73 65 63 75 72 | 65 0a 58 2e 62 72 0a 58 |in/secur|e.X.br.X|
|00000e60| 2e 53 48 20 44 45 53 43 | 52 49 50 54 49 4f 4e 0a |.SH DESC|RIPTION.|
|00000e70| 58 2e 42 20 53 65 63 75 | 72 65 0a 58 69 73 20 6e |X.B Secu|re.Xis n|
|00000e80| 65 76 65 72 20 6e 6f 72 | 6d 61 6c 6c 79 20 65 78 |ever nor|mally ex|
|00000e90| 65 63 75 74 65 64 20 66 | 72 6f 6d 20 61 20 73 68 |ecuted f|rom a sh|
|00000ea0| 65 6c 6c 2e 20 49 6e 73 | 74 65 61 64 20 69 74 20 |ell. Ins|tead it |
|00000eb0| 63 61 6e 20 62 65 20 75 | 73 65 64 0a 58 61 73 20 |can be u|sed.Xas |
|00000ec0| 74 68 65 20 69 6e 74 65 | 72 70 72 65 74 65 72 20 |the inte|rpreter |
|00000ed0| 66 6f 72 20 73 68 65 6c | 6c 20 73 63 72 69 70 74 |for shel|l script|
|00000ee0| 73 20 74 68 61 74 20 6e | 65 65 64 20 74 6f 20 62 |s that n|eed to b|
|00000ef0| 65 20 72 75 6e 20 73 65 | 74 75 69 64 20 73 6f 6d |e run se|tuid som|
|00000f00| 65 6f 6e 65 0a 58 65 6c | 73 65 3a 20 74 68 69 73 |eone.Xel|se: this|
|00000f10| 20 69 73 20 64 6f 6e 65 | 20 62 79 20 6d 61 6b 69 | is done| by maki|
|00000f20| 6e 67 20 74 68 65 20 66 | 69 72 73 74 20 6c 69 6e |ng the f|irst lin|
|00000f30| 65 20 6f 66 20 74 68 65 | 20 73 63 72 69 70 74 0a |e of the| script.|
|00000f40| 58 2e 50 50 0a 58 2e 74 | 69 2b 35 6e 0a 58 23 21 |X.PP.X.t|i+5n.X#!|
|00000f50| 20 2f 62 69 6e 2f 73 65 | 63 75 72 65 0a 58 2e 50 | /bin/se|cure.X.P|
|00000f60| 50 0a 58 72 61 74 68 65 | 72 20 74 68 61 6e 20 74 |P.Xrathe|r than t|
|00000f70| 68 65 20 75 73 75 61 6c | 0a 58 2e 50 50 0a 58 2e |he usual|.X.PP.X.|
|00000f80| 74 69 2b 35 6e 0a 58 23 | 21 20 2f 62 69 6e 2f 73 |ti+5n.X#|! /bin/s|
|00000f90| 68 0a 58 2e 50 50 0a 58 | 2e 42 20 53 65 63 75 72 |h.X.PP.X|.B Secur|
|00000fa0| 65 0a 58 64 65 74 65 72 | 6d 69 6e 65 73 20 69 66 |e.Xdeter|mines if|
|00000fb0| 20 61 20 73 63 72 69 70 | 74 20 63 61 6e 20 62 65 | a scrip|t can be|
|00000fc0| 20 73 61 66 65 6c 79 20 | 72 75 6e 20 62 79 20 6c | safely |run by l|
|00000fd0| 6f 6f 6b 69 6e 67 20 69 | 6e 0a 58 2f 65 74 63 2f |ooking i|n.X/etc/|
|00000fe0| 73 65 63 75 72 65 2e 20 | 54 68 69 73 20 69 73 20 |secure. |This is |
|00000ff0| 61 20 6c 69 73 74 20 6f | 66 20 73 65 63 75 72 65 |a list o|f secure|
|00001000| 20 73 68 65 6c 6c 20 73 | 63 72 69 70 74 73 2c 20 | shell s|cripts, |
|00001010| 61 6e 64 20 74 68 65 20 | 6e 75 6d 65 72 69 63 0a |and the |numeric.|
|00001020| 58 75 73 65 72 20 69 64 | 20 74 68 61 74 20 74 68 |Xuser id| that th|
|00001030| 65 20 73 63 72 69 70 74 | 20 69 73 20 74 6f 20 62 |e script| is to b|
|00001040| 65 20 72 75 6e 20 77 69 | 74 68 2e 20 41 20 74 79 |e run wi|th. A ty|
|00001050| 70 69 63 61 6c 20 6c 69 | 6e 65 20 66 72 6f 6d 0a |pical li|ne from.|
|00001060| 58 2f 65 74 63 2f 73 65 | 63 75 72 65 20 6d 69 67 |X/etc/se|cure mig|
|00001070| 68 74 20 62 65 0a 58 2e | 50 50 0a 58 2e 74 69 2b |ht be.X.|PP.X.ti+|
|00001080| 35 6e 0a 58 2f 75 73 72 | 2f 73 63 72 69 70 74 09 |5n.X/usr|/script.|
|00001090| 09 30 0a 58 2e 50 50 0a | 58 77 68 69 63 68 20 77 |.0.X.PP.|Xwhich w|
|000010a0| 6f 75 6c 64 20 6d 65 61 | 6e 20 74 68 61 74 20 2f |ould mea|n that /|
|000010b0| 75 73 72 2f 73 63 72 69 | 70 74 20 73 68 6f 75 6c |usr/scri|pt shoul|
|000010c0| 64 20 62 65 20 72 75 6e | 20 61 73 20 72 6f 6f 74 |d be run| as root|
|000010d0| 2e 0a 58 2e 50 50 0a 58 | 42 65 63 61 75 73 65 0a |..X.PP.X|Because.|
|000010e0| 58 2e 42 20 73 65 63 75 | 72 65 0a 58 77 69 6c 6c |X.B secu|re.Xwill|
|000010f0| 20 6f 6e 6c 79 0a 58 65 | 78 65 63 20 61 20 70 61 | only.Xe|xec a pa|
|00001100| 74 68 6e 61 6d 65 20 62 | 65 67 69 6e 6e 69 6e 67 |thname b|eginning|
|00001110| 20 77 69 74 68 20 27 2f | 27 2c 20 74 68 61 74 20 | with '/|', that |
|00001120| 63 6f 6d 65 73 20 66 72 | 6f 6d 20 2f 65 74 63 2f |comes fr|om /etc/|
|00001130| 73 65 63 75 72 65 2c 20 | 69 74 0a 58 63 61 6e 6e |secure, |it.Xcann|
|00001140| 6f 74 20 62 65 20 75 73 | 65 64 20 74 6f 20 69 6c |ot be us|ed to il|
|00001150| 6c 65 67 61 6c 6c 79 20 | 67 61 69 6e 20 72 6f 6f |legally |gain roo|
|00001160| 74 20 61 63 63 65 73 73 | 2e 0a 58 2e 50 50 0a 58 |t access|..X.PP.X|
|00001170| 49 6e 20 61 64 64 69 74 | 69 6f 6e 2c 20 66 6f 72 |In addit|ion, for|
|00001180| 20 74 68 65 20 73 61 6b | 65 20 6f 66 20 73 65 63 | the sak|e of sec|
|00001190| 75 72 69 74 79 2c 0a 58 | 2e 42 20 73 65 63 75 72 |urity,.X|.B secur|
|000011a0| 65 0a 58 73 65 74 73 20 | 74 68 65 20 50 41 54 48 |e.Xsets |the PATH|
|000011b0| 20 65 6e 76 69 72 6f 6e | 6d 65 6e 74 20 76 61 72 | environ|ment var|
|000011c0| 69 61 62 6c 65 20 62 61 | 63 6b 20 74 6f 20 61 20 |iable ba|ck to a |
|000011d0| 73 69 6d 70 6c 65 20 64 | 65 66 61 75 6c 74 2c 20 |simple d|efault, |
|000011e0| 61 6e 64 20 64 65 6c 65 | 74 65 73 0a 58 74 68 65 |and dele|tes.Xthe|
|000011f0| 20 49 46 53 20 65 6e 76 | 69 72 6f 6e 6d 65 6e 74 | IFS env|ironment|
|00001200| 20 76 61 72 69 61 62 6c | 65 2e 0a 58 2e 53 48 20 | variabl|e..X.SH |
|00001210| 22 53 45 45 20 41 4c 53 | 4f 22 0a 58 2e 42 52 20 |"SEE ALS|O".X.BR |
|00001220| 73 68 20 28 31 29 2c 0a | 23 23 5f 5f 45 4f 46 2e |sh (1),.|##__EOF.|
|00001230| 2e 73 65 63 75 72 65 2e | 38 5f 5f 23 23 0a 66 69 |.secure.|8__##.fi|
|00001240| 0a 23 20 65 6e 64 20 6f | 66 20 73 68 65 6c 6c 20 |.# end o|f shell |
|00001250| 61 72 63 68 69 76 65 0a | 65 78 69 74 20 30 0a 0a |archive.|exit 0..|
|00001260| 0a | |. | |
+--------+-------------------------+-------------------------+--------+--------+