Hex Artifact Content

Artifact dc3dfdd9b3b14d4a970a39c793074532191146c8:


0000: 66 69 6c 65 64 0a 3d 3d 3d 3d 3d 0a 0a 49 6e 74  filed.=====..Int
0010: 72 6f 64 75 63 74 69 6f 6e 0a 2d 2d 2d 2d 2d 2d  roduction.------
0020: 2d 2d 2d 2d 2d 2d 0a 22 66 69 6c 65 64 22 20 69  ------."filed" i
0030: 73 20 61 20 73 69 6d 70 6c 65 20 48 54 54 50 20  s a simple HTTP 
0040: 73 65 72 76 65 72 20 66 6f 72 20 73 65 72 76 69  server for servi
0050: 6e 67 20 6c 6f 63 61 6c 20 73 74 61 74 69 63 20  ng local static 
0060: 66 69 6c 65 73 20 6f 76 65 72 20 48 54 54 50 20  files over HTTP 
0070: 66 72 6f 6d 0a 4c 69 6e 75 78 2e 20 49 74 20 64  from.Linux. It d
0080: 6f 65 73 20 74 68 65 20 6c 65 61 73 74 20 61 6d  oes the least am
0090: 6f 75 6e 74 20 6f 66 20 65 66 66 6f 72 74 20 70  ount of effort p
00a0: 6f 73 73 69 62 6c 65 20 74 6f 20 67 65 74 20 74  ossible to get t
00b0: 6f 20 74 68 65 20 70 6f 69 6e 74 20 6f 66 0a 68  o the point of.h
00c0: 61 6e 64 69 6e 67 20 74 68 65 20 61 63 74 75 61  anding the actua
00d0: 6c 20 74 72 61 6e 73 66 65 72 20 6f 76 65 72 20  l transfer over 
00e0: 74 6f 20 74 68 65 20 6b 65 72 6e 65 6c 2e 0a 0a  to the kernel...
00f0: 49 74 20 69 73 20 6d 75 6c 74 69 74 68 72 65 61  It is multithrea
0100: 64 65 64 20 77 68 65 72 65 20 65 76 65 72 79 20  ded where every 
0110: 74 68 72 65 61 64 20 73 65 72 76 69 63 65 73 20  thread services 
0120: 61 20 73 69 6e 67 6c 65 20 63 6f 6e 63 75 72 72  a single concurr
0130: 65 6e 74 20 63 6c 69 65 6e 74 2e 0a 49 74 20 61  ent client..It a
0140: 74 74 65 6d 70 74 73 20 74 6f 20 72 65 64 75 63  ttempts to reduc
0150: 65 20 6c 61 74 65 6e 63 79 20 62 79 20 63 61 63  e latency by cac
0160: 68 69 6e 67 20 6f 70 65 6e 20 66 69 6c 65 20 64  hing open file d
0170: 65 73 63 72 69 70 74 6f 72 73 20 61 73 20 77 65  escriptors as we
0180: 6c 6c 2e 0a 0a 49 74 20 68 61 73 20 6e 6f 20 63  ll...It has no c
0190: 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 66 69 6c  onfiguration fil
01a0: 65 20 61 6e 64 20 73 75 70 70 6f 72 74 73 20 6f  e and supports o
01b0: 6e 6c 79 20 6d 69 6e 69 6d 61 6c 20 63 6f 6e 66  nly minimal conf
01c0: 69 67 75 72 61 74 69 6f 6e 2e 0a 4f 70 65 72 61  iguration..Opera
01d0: 74 69 6f 6e 20 69 73 20 64 65 73 63 72 69 62 65  tion is describe
01e0: 64 20 69 6e 20 74 68 65 20 6d 61 6e 75 61 6c 20  d in the manual 
01f0: 70 61 67 65 2e 0a 0a 55 73 61 67 65 0a 2d 2d 2d  page...Usage.---
0200: 2d 2d 0a 54 68 65 20 73 69 6d 70 6c 65 73 74 20  --.The simplest 
0210: 75 73 61 67 65 20 6f 66 20 22 66 69 6c 65 64 22  usage of "filed"
0220: 20 69 73 20 74 6f 20 72 75 6e 20 69 74 20 77 69   is to run it wi
0230: 74 68 20 6e 6f 20 61 72 67 75 6d 65 6e 74 73 2e  th no arguments.
0240: 20 20 54 68 69 73 20 77 69 6c 6c 20 73 74 61 72    This will star
0250: 74 0a 75 70 20 61 6e 20 48 54 54 50 20 73 65 72  t.up an HTTP ser
0260: 76 65 72 20 6c 69 73 74 65 6e 69 6e 67 20 6f 6e  ver listening on
0270: 20 70 6f 72 74 20 38 30 20 61 6e 64 20 73 68 61   port 80 and sha
0280: 72 69 6e 67 20 6f 75 74 20 74 68 65 20 72 6f 6f  ring out the roo
0290: 74 20 66 69 6c 65 73 79 73 74 65 6d 20 66 6f 72  t filesystem for
02a0: 0a 74 68 65 20 73 79 73 74 65 6d 20 61 73 20 74  .the system as t
02b0: 68 65 20 63 75 72 72 65 6e 74 20 75 73 65 72 2e  he current user.
02c0: 20 20 59 6f 75 20 70 72 6f 62 61 62 6c 79 20 64    You probably d
02d0: 6f 20 6e 6f 74 20 77 61 6e 74 20 74 6f 20 73 68  o not want to sh
02e0: 61 72 65 20 6f 75 74 20 79 6f 75 72 0a 72 6f 6f  are out your.roo
02f0: 74 20 66 69 6c 65 73 79 73 74 65 6d 20 73 69 6e  t filesystem sin
0300: 63 65 20 74 68 61 74 20 77 69 6c 6c 20 65 78 70  ce that will exp
0310: 6f 73 65 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20  ose information 
0320: 73 75 63 68 20 61 73 20 22 2f 65 74 63 2f 70 61  such as "/etc/pa
0330: 73 73 77 64 22 20 74 6f 0a 61 6e 6f 6e 79 6d 6f  sswd" to.anonymo
0340: 75 73 20 61 63 63 65 73 73 2e 20 20 59 6f 75 20  us access.  You 
0350: 70 72 6f 62 61 62 6c 79 20 61 6c 73 6f 20 64 6f  probably also do
0360: 6e 27 74 20 77 61 6e 74 20 74 6f 20 64 6f 20 74  n't want to do t
0370: 68 61 74 20 61 73 20 72 6f 6f 74 20 73 69 6e 63  hat as root sinc
0380: 65 20 74 68 65 6e 0a 73 65 6e 73 69 74 69 76 65  e then.sensitive
0390: 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 73 75 63   information suc
03a0: 68 20 61 73 20 22 2f 65 74 63 2f 73 68 61 64 6f  h as "/etc/shado
03b0: 77 22 20 63 6f 75 6c 64 20 62 65 20 75 73 65 64  w" could be used
03c0: 20 74 6f 20 63 6f 6d 70 72 6f 6d 69 73 65 20 74   to compromise t
03d0: 68 65 0a 73 79 73 74 65 6d 2e 0a 0a 54 68 65 72  he.system...Ther
03e0: 65 66 6f 72 65 2c 20 74 68 65 20 22 2d 2d 75 73  efore, the "--us
03f0: 65 72 22 20 61 6e 64 20 22 2d 2d 72 6f 6f 74 22  er" and "--root"
0400: 20 6f 70 74 69 6f 6e 73 20 73 68 6f 75 6c 64 20   options should 
0410: 62 65 20 75 73 65 64 20 74 6f 20 73 70 65 63 69  be used to speci
0420: 66 79 20 61 20 75 73 65 72 0a 66 6f 72 20 22 66  fy a user.for "f
0430: 69 6c 65 64 22 20 74 6f 20 72 75 6e 20 61 73 20  iled" to run as 
0440: 69 6e 20 61 64 64 69 74 69 6f 6e 20 74 6f 20 61  in addition to a
0450: 20 64 69 72 65 63 74 6f 72 79 20 74 6f 20 63 68   directory to ch
0460: 61 6e 67 65 20 72 6f 6f 74 20 28 63 68 72 6f 6f  ange root (chroo
0470: 74 28 32 29 29 20 74 6f 0a 70 72 69 6f 72 20 74  t(2)) to.prior t
0480: 6f 20 73 65 72 76 69 6e 67 20 6f 75 74 20 66 69  o serving out fi
0490: 6c 65 73 2e 0a 0a 45 78 61 6d 70 6c 65 20 31 2c  les...Example 1,
04a0: 20 69 6e 73 65 63 75 72 65 20 66 69 6c 65 20 73   insecure file s
04b0: 68 61 72 69 6e 67 3a 0a 09 24 20 66 69 6c 65 64  haring:..$ filed
04c0: 0a 0a 45 78 61 6d 70 6c 65 20 32 2c 20 73 68 61  ..Example 2, sha
04d0: 72 69 6e 67 20 73 65 6e 73 69 74 69 76 65 20 69  ring sensitive i
04e0: 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 09 23 20 66  nformation:..# f
04f0: 69 6c 65 64 0a 0a 45 78 61 6d 70 6c 65 20 33 2c  iled..Example 3,
0500: 20 73 68 61 72 69 6e 67 20 6f 6e 6c 79 20 61 20   sharing only a 
0510: 73 70 65 63 69 66 69 63 20 64 69 72 65 63 74 6f  specific directo
0520: 72 79 3a 0a 09 23 20 66 69 6c 65 64 20 2d 2d 72  ry:..# filed --r
0530: 6f 6f 74 20 2f 77 77 77 20 2d 2d 75 73 65 72 20  oot /www --user 
0540: 6e 6f 62 6f 64 79 0a 0a 45 78 61 6d 70 6c 65 20  nobody..Example 
0550: 34 2c 20 72 75 6e 6e 69 6e 67 20 61 73 20 61 20  4, running as a 
0560: 64 61 65 6d 6f 6e 3a 0a 09 23 20 66 69 6c 65 64  daemon:..# filed
0570: 20 2d 2d 72 6f 6f 74 20 2f 77 77 77 20 2d 2d 75   --root /www --u
0580: 73 65 72 20 6e 6f 62 6f 64 79 20 2d 2d 64 61 65  ser nobody --dae
0590: 6d 6f 6e 0a 0a 42 75 69 6c 64 20 54 69 6d 65 20  mon..Build Time 
05a0: 43 6f 6e 73 69 64 65 72 61 74 69 6f 6e 73 0a 2d  Considerations.-
05b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
05c0: 2d 2d 2d 2d 2d 2d 2d 2d 0a 49 6e 20 67 65 6e 65  --------.In gene
05d0: 72 61 6c 2c 20 69 74 20 69 73 20 62 65 73 74 20  ral, it is best 
05e0: 74 6f 20 6c 65 61 76 65 20 61 6c 6c 20 63 6f 6e  to leave all con
05f0: 66 69 67 75 72 61 74 69 6f 6e 20 74 6f 20 72 75  figuration to ru
0600: 6e 2d 74 69 6d 65 20 73 6f 20 74 68 61 74 20 61  n-time so that a
0610: 0a 63 6f 6d 70 69 6c 65 64 20 62 69 6e 61 72 79  .compiled binary
0620: 20 63 61 6e 20 64 6f 20 61 73 20 6d 75 63 68 20   can do as much 
0630: 61 73 20 70 6f 73 73 69 62 6c 65 20 77 69 74 68  as possible with
0640: 6f 75 74 20 6e 65 65 64 69 6e 67 20 74 6f 20 62  out needing to b
0650: 65 20 72 65 63 6f 6d 70 69 6c 65 64 2e 0a 48 6f  e recompiled..Ho
0660: 77 65 76 65 72 2c 20 74 68 65 72 65 20 61 72 65  wever, there are
0670: 20 73 6f 6d 65 20 74 68 69 6e 67 73 20 74 68 61   some things tha
0680: 74 20 61 72 65 20 62 65 73 74 20 64 6f 6e 65 20  t are best done 
0690: 61 74 20 63 6f 6d 70 69 6c 65 20 74 69 6d 65 20  at compile time 
06a0: 66 6f 72 0a 76 61 72 69 6f 75 73 20 72 65 61 73  for.various reas
06b0: 6f 6e 73 2c 20 65 73 70 65 63 69 61 6c 6c 79 20  ons, especially 
06c0: 69 6e 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 70  in the name of p
06d0: 65 72 66 6f 72 6d 61 6e 63 65 20 6f 72 20 65 78  erformance or ex
06e0: 65 63 75 74 61 62 6c 65 20 73 69 7a 65 2e 0a 0a  ecutable size...
06f0: 66 69 6c 65 64 20 61 64 6d 69 74 73 20 74 68 6f  filed admits tho
0700: 73 65 20 74 72 61 64 65 2d 6f 66 66 73 20 61 72  se trade-offs ar
0710: 65 20 6f 63 63 61 73 69 6f 6e 61 6c 6c 79 20 72  e occasionally r
0720: 65 71 75 69 72 65 64 20 61 6e 64 20 6f 66 66 65  equired and offe
0730: 72 73 20 74 68 65 0a 66 6f 6c 6c 6f 77 69 6e 67  rs the.following
0740: 20 74 75 6e 61 62 6c 65 73 20 74 68 61 74 20 63   tunables that c
0750: 61 6e 20 6f 6e 6c 79 20 62 65 20 74 6f 67 67 6c  an only be toggl
0760: 65 64 20 64 75 72 69 6e 67 20 63 6f 6d 70 69 6c  ed during compil
0770: 65 2d 74 69 6d 65 3a 0a 0a 20 20 20 31 2e 20 4c  e-time:..   1. L
0780: 6f 67 67 69 6e 67 20 28 43 46 4c 41 47 53 2c 20  ogging (CFLAGS, 
0790: 2d 44 46 49 4c 45 44 5f 44 4f 4e 54 5f 4c 4f 47  -DFILED_DONT_LOG
07a0: 3d 31 29 0a 09 49 74 20 69 73 20 70 6f 73 73 69  =1)..It is possi
07b0: 62 6c 65 20 74 6f 20 64 69 73 61 62 6c 65 20 41  ble to disable A
07c0: 4c 4c 20 6c 6f 67 67 69 6e 67 20 66 72 6f 6d 20  LL logging from 
07d0: 66 69 6c 65 64 2e 20 20 57 68 65 6e 20 6c 6f 67  filed.  When log
07e0: 67 69 6e 67 20 69 73 0a 09 63 6f 6d 70 6c 65 74  ging is..complet
07f0: 65 6c 79 20 64 69 73 61 62 6c 65 64 20 69 6e 74  ely disabled int
0800: 65 72 6c 6f 63 6b 73 20 28 6d 75 74 65 78 65 73  erlocks (mutexes
0810: 29 20 66 6f 72 20 74 68 65 20 6c 6f 67 67 69 6e  ) for the loggin
0820: 67 20 70 6f 69 6e 74 65 72 20 61 72 65 0a 09 6e  g pointer are..n
0830: 6f 74 20 65 6e 67 61 67 65 64 20 61 6e 64 20 74  ot engaged and t
0840: 68 65 20 6c 6f 67 67 69 6e 67 20 66 75 6e 63 74  he logging funct
0850: 69 6f 6e 73 20 61 72 65 20 6e 6f 74 20 63 6f 6d  ions are not com
0860: 70 69 6c 65 64 20 61 74 20 61 6c 6c 2e 0a 09 54  piled at all...T
0870: 68 69 73 20 72 65 73 75 6c 74 73 20 69 6e 20 61  his results in a
0880: 20 73 6c 69 67 68 74 6c 79 20 73 6d 61 6c 6c 65   slightly smalle
0890: 72 20 61 6e 64 20 66 61 73 74 65 72 20 62 69 6e  r and faster bin
08a0: 61 72 79 0a 0a 20 20 20 32 2e 20 44 65 62 75 67  ary..   2. Debug
08b0: 67 69 6e 67 20 28 43 46 4c 41 47 53 2c 20 2d 44  ging (CFLAGS, -D
08c0: 46 49 4c 45 44 5f 44 45 42 55 47 3d 31 29 0a 09  FILED_DEBUG=1)..
08d0: 54 68 69 73 20 69 73 20 61 6e 20 69 6e 74 65 72  This is an inter
08e0: 6e 61 6c 20 6f 70 74 69 6f 6e 20 61 6e 64 20 73  nal option and s
08f0: 68 6f 75 6c 64 20 6f 6e 6c 79 20 62 65 20 75 73  hould only be us
0900: 65 64 20 64 75 72 69 6e 67 20 64 65 76 65 6c 6f  ed during develo
0910: 70 6d 65 6e 74 2e 0a 0a 20 20 20 33 2e 20 44 69  pment...   3. Di
0920: 66 66 65 72 69 6e 67 20 48 54 54 50 20 73 65 6d  ffering HTTP sem
0930: 61 6e 74 69 63 73 20 28 43 46 4c 41 47 53 2c 20  antics (CFLAGS, 
0940: 2d 44 46 49 4c 45 44 5f 4e 4f 4e 42 4c 4f 43 4b  -DFILED_NONBLOCK
0950: 5f 48 54 54 50 3d 31 29 0a 09 49 74 20 69 73 20  _HTTP=1)..It is 
0960: 70 6f 73 73 69 62 6c 65 20 74 68 61 74 20 73 6f  possible that so
0970: 6d 65 20 48 54 54 50 20 63 6c 69 65 6e 74 73 20  me HTTP clients 
0980: 6d 61 79 20 6e 6f 74 20 70 72 6f 63 65 73 73 20  may not process 
0990: 74 68 65 20 48 54 54 50 20 73 74 72 65 61 6d 0a  the HTTP stream.
09a0: 09 62 65 69 6e 67 20 64 65 6c 69 76 65 72 65 64  .being delivered
09b0: 20 69 66 20 74 68 65 79 20 63 61 6e 6e 6f 74 20   if they cannot 
09c0: 77 72 69 74 65 20 74 6f 20 74 68 65 20 48 54 54  write to the HTT
09d0: 50 20 73 74 72 65 61 6d 20 69 74 73 65 6c 66 2e  P stream itself.
09e0: 20 20 54 68 69 73 0a 09 68 61 73 20 6e 6f 74 20    This..has not 
09f0: 62 65 65 6e 20 6f 62 73 65 72 76 65 64 20 79 65  been observed ye
0a00: 74 2c 20 62 75 74 20 69 74 20 69 73 20 70 6f 73  t, but it is pos
0a10: 73 69 62 6c 65 2e 20 20 49 66 20 74 68 65 73 65  sible.  If these
0a20: 20 73 65 6d 61 6e 74 69 63 73 20 61 72 65 0a 09   semantics are..
0a30: 6e 65 65 64 65 64 20 28 61 6e 64 20 74 68 65 79  needed (and they
0a40: 20 73 68 6f 75 6c 64 20 6e 6f 74 20 62 65 29 20   should not be) 
0a50: 74 68 65 6e 20 74 68 65 79 20 63 61 6e 20 62 65  then they can be
0a60: 20 65 6e 61 62 6c 65 64 20 77 69 74 68 20 74 68   enabled with th
0a70: 69 73 0a 09 66 6c 61 67 20 61 74 20 74 68 65 20  is..flag at the 
0a80: 63 6f 73 74 20 6f 66 20 70 65 72 66 6f 72 6d 61  cost of performa
0a90: 6e 63 65 2e 0a 0a 20 20 20 34 2e 20 44 69 66 66  nce...   4. Diff
0aa0: 65 72 69 6e 67 20 63 68 72 6f 6f 74 28 29 20 73  ering chroot() s
0ab0: 65 6d 61 6e 74 69 63 73 20 28 43 46 4c 41 47 53  emantics (CFLAGS
0ac0: 2c 20 2d 44 46 49 4c 45 44 5f 46 41 4b 45 5f 43  , -DFILED_FAKE_C
0ad0: 48 52 4f 4f 54 3d 31 29 0a 20 20 20 20 20 20 20  HROOT=1).       
0ae0: 20 49 6e 20 73 6f 6d 65 20 63 61 73 65 73 20 69   In some cases i
0af0: 74 20 69 73 20 64 65 73 69 72 61 62 6c 65 20 74  t is desirable t
0b00: 6f 20 6d 61 6e 67 6c 65 20 70 61 74 68 73 20 77  o mangle paths w
0b10: 69 74 68 20 61 20 70 61 74 68 20 70 72 65 66 69  ith a path prefi
0b20: 78 0a 20 20 20 20 20 20 20 20 72 61 74 68 65 72  x.        rather
0b30: 20 74 68 61 6e 20 63 61 6c 6c 20 63 68 72 6f 6f   than call chroo
0b40: 74 28 29 20 61 74 20 73 74 61 72 74 75 70 2e 20  t() at startup. 
0b50: 20 54 68 69 73 20 69 73 20 6c 65 73 73 20 73 65   This is less se
0b60: 63 75 72 65 20 61 6e 64 20 73 6c 6f 77 65 72 0a  cure and slower.
0b70: 20 20 20 20 20 20 20 20 61 6e 64 20 73 68 6f 75          and shou
0b80: 6c 64 20 62 65 20 67 65 6e 65 72 61 6c 6c 79 20  ld be generally 
0b90: 61 76 6f 69 64 65 64 20 2d 2d 20 68 6f 77 65 76  avoided -- howev
0ba0: 65 72 20 69 74 20 6d 61 79 20 62 65 20 6e 65 63  er it may be nec
0bb0: 65 73 73 61 72 79 20 74 6f 20 64 6f 2e 0a 20 20  essary to do..  
0bc0: 20 20 20 20 20 20 49 6e 20 74 68 65 73 65 20 63        In these c
0bd0: 61 73 65 73 20 74 68 65 20 65 78 65 63 75 74 61  ases the executa
0be0: 62 6c 65 20 6d 61 79 20 62 65 20 63 6f 6d 70 69  ble may be compi
0bf0: 6c 65 64 20 77 69 74 68 20 74 68 65 0a 20 20 20  led with the.   
0c00: 20 20 20 20 20 46 49 4c 45 44 5f 46 41 4b 45 5f       FILED_FAKE_
0c10: 43 48 52 4f 4f 54 20 43 20 70 72 65 70 72 6f 63  CHROOT C preproc
0c20: 65 73 73 6f 72 20 6d 61 63 72 6f 20 64 65 66 69  essor macro defi
0c30: 6e 65 64 20 61 6e 64 20 69 6e 73 74 65 61 64 20  ned and instead 
0c40: 6f 66 20 63 61 6c 6c 69 6e 67 0a 20 20 20 20 20  of calling.     
0c50: 20 20 20 63 68 72 6f 6f 74 28 29 20 61 6c 6c 20     chroot() all 
0c60: 48 54 54 50 20 72 65 71 75 65 73 74 73 20 77 69  HTTP requests wi
0c70: 6c 6c 20 68 61 76 65 20 74 68 65 20 72 6f 6f 74  ll have the root
0c80: 20 73 75 66 66 69 78 20 73 70 65 63 69 66 69 65   suffix specifie
0c90: 64 20 61 73 20 74 68 65 0a 20 20 20 20 20 20 20  d as the.       
0ca0: 20 61 72 67 75 6d 65 6e 74 20 74 6f 20 74 68 65   argument to the
0cb0: 20 22 2d 72 22 20 6f 72 20 22 2d 2d 72 6f 6f 74   "-r" or "--root
0cc0: 22 20 6f 70 74 69 6f 6e 20 70 72 65 70 65 6e 64  " option prepend
0cd0: 65 64 20 74 6f 20 74 68 65 6d 2e 0a 0a 20 20 20  ed to them...   
0ce0: 35 2e 20 44 69 66 66 65 72 69 6e 67 20 22 69 6e  5. Differing "in
0cf0: 64 65 78 2e 68 74 6d 6c 22 20 68 61 6e 64 6c 69  dex.html" handli
0d00: 6e 67 20 28 43 46 4c 41 47 53 2c 20 2d 44 46 49  ng (CFLAGS, -DFI
0d10: 4c 45 44 5f 44 4f 4e 54 5f 52 45 44 49 52 45 43  LED_DONT_REDIREC
0d20: 54 5f 44 49 52 45 43 54 4f 52 49 45 53 3d 31 29  T_DIRECTORIES=1)
0d30: 0a 20 20 20 20 20 20 20 20 4e 6f 72 6d 61 6c 6c  .        Normall
0d40: 79 20 22 66 69 6c 65 64 22 20 72 65 64 69 72 65  y "filed" redire
0d50: 63 74 73 20 75 73 65 72 73 20 77 68 6f 20 72 65  cts users who re
0d60: 71 75 65 73 74 20 61 20 64 69 72 65 63 74 6f 72  quest a director
0d70: 79 20 74 6f 20 74 68 65 0a 20 20 20 20 20 20 20  y to the.       
0d80: 20 69 6e 64 65 78 2e 68 74 6d 6c 20 66 69 6c 65   index.html file
0d90: 20 69 6e 20 74 68 61 74 20 64 69 72 65 63 74 6f   in that directo
0da0: 72 79 20 73 6f 20 74 68 61 74 20 6e 6f 20 6d 65  ry so that no me
0db0: 6d 6f 72 79 20 61 6c 6c 6f 63 61 74 69 6f 6e 73  mory allocations
0dc0: 20 61 72 65 0a 20 20 20 20 20 20 20 20 72 65 71   are.        req
0dd0: 75 69 72 65 64 3b 20 20 54 68 69 73 20 6f 70 74  uired;  This opt
0de0: 69 6f 6e 20 6c 65 74 73 20 74 68 65 20 73 65 72  ion lets the ser
0df0: 76 65 72 20 67 65 6e 65 72 61 74 65 20 74 68 65  ver generate the
0e00: 20 6e 65 77 20 70 61 74 68 2e 0a 0a 20 20 20 36   new path...   6
0e10: 2e 20 4d 49 4d 45 20 54 79 70 65 73 20 28 4d 49  . MIME Types (MI
0e20: 4d 45 54 59 50 45 53 29 0a 09 46 6f 72 20 73 69  METYPES)..For si
0e30: 6e 67 6c 65 2d 66 69 6c 65 20 63 6f 6e 76 65 6e  ngle-file conven
0e40: 69 65 6e 63 65 20 22 66 69 6c 65 64 22 20 63 6f  ience "filed" co
0e50: 6d 70 69 6c 65 73 20 74 68 65 20 6d 61 70 70 69  mpiles the mappi
0e60: 6e 67 20 6f 66 20 66 69 6c 65 0a 09 65 78 74 65  ng of file..exte
0e70: 6e 73 69 6f 6e 73 20 28 74 68 65 20 73 74 72 69  nsions (the stri
0e80: 6e 67 20 69 6e 20 74 68 65 20 66 69 6c 65 6e 61  ng in the filena
0e90: 6d 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 69 74 73  me following its
0ea0: 20 6c 61 73 74 20 64 6f 74 20 28 22 2e 22 29 29   last dot ("."))
0eb0: 0a 09 69 6e 74 6f 20 74 68 65 20 65 78 65 63 75  ..into the execu
0ec0: 74 61 62 6c 65 2e 20 20 54 68 69 73 20 6d 61 70  table.  This map
0ed0: 70 69 6e 67 20 63 6f 6d 65 73 20 66 72 6f 6d 20  ping comes from 
0ee0: 61 20 66 69 6c 65 20 69 6e 20 74 68 65 20 66 6f  a file in the fo
0ef0: 72 6d 61 74 20 6f 66 0a 09 09 74 79 70 65 31 20  rmat of...type1 
0f00: 20 20 74 79 70 65 31 5f 65 78 74 65 6e 73 69 6f    type1_extensio
0f10: 6e 31 20 74 79 70 65 31 5f 65 78 74 65 6e 73 69  n1 type1_extensi
0f20: 6f 6e 32 2e 2e 2e 0a 09 09 74 79 70 65 32 20 20  on2......type2  
0f30: 20 74 79 70 65 32 5f 65 78 74 65 6e 73 69 6f 6e   type2_extension
0f40: 31 20 74 79 70 65 32 5f 65 78 74 65 6e 73 69 6f  1 type2_extensio
0f50: 6e 32 2e 2e 2e 0a 09 09 2e 2e 2e 0a 09 48 6f 77  n2...........How
0f60: 65 76 65 72 20 69 74 20 6d 61 79 20 6e 6f 74 20  ever it may not 
0f70: 62 65 20 64 65 73 69 72 61 62 6c 65 20 74 6f 20  be desirable to 
0f80: 69 6e 63 6c 75 64 65 20 74 68 69 73 20 6d 61 70  include this map
0f90: 70 69 6e 67 2c 20 6f 72 20 69 74 20 6d 61 79 20  ping, or it may 
0fa0: 62 65 0a 09 64 65 73 69 72 61 62 6c 65 20 74 6f  be..desirable to
0fb0: 20 75 73 65 20 79 6f 75 72 20 6f 77 6e 20 6d 61   use your own ma
0fc0: 70 70 69 6e 67 20 72 61 74 68 65 72 20 74 68 61  pping rather tha
0fd0: 6e 20 74 68 65 20 64 65 66 61 75 6c 74 20 6f 6e  n the default on
0fe0: 65 2e 20 20 54 68 69 73 0a 09 63 61 6e 20 62 65  e.  This..can be
0ff0: 20 64 6f 6e 65 20 62 79 20 73 70 65 63 69 66 79   done by specify
1000: 69 6e 67 20 74 68 65 20 4d 49 4d 45 54 59 50 45  ing the MIMETYPE
1010: 53 20 6d 61 63 72 6f 20 74 6f 20 22 6d 61 6b 65  S macro to "make
1020: 22 2e 20 20 49 66 20 6e 6f 0a 09 6d 61 70 70 69  ".  If no..mappi
1030: 6e 67 20 69 73 20 64 65 73 69 72 65 64 2c 20 22  ng is desired, "
1040: 2f 64 65 76 2f 6e 75 6c 6c 22 20 6d 61 79 20 62  /dev/null" may b
1050: 65 20 73 70 65 63 69 66 69 65 64 2e 0a 0a 4c 6f  e specified...Lo
1060: 67 20 46 69 6c 65 73 0a 2d 2d 2d 2d 2d 2d 2d 2d  g Files.--------
1070: 2d 0a 42 65 63 61 75 73 65 20 22 66 69 6c 65 64  -.Because "filed
1080: 22 20 72 65 6c 69 65 73 20 6f 6e 20 63 68 72 6f  " relies on chro
1090: 6f 74 28 32 29 20 61 6e 64 20 73 65 74 75 69 64  ot(2) and setuid
10a0: 28 32 29 2c 20 6c 6f 67 20 66 69 6c 65 73 20 63  (2), log files c
10b0: 61 6e 6e 6f 74 20 72 65 6c 69 61 62 6c 79 0a 62  annot reliably.b
10c0: 65 20 72 65 2d 6f 70 65 6e 65 64 2e 20 20 49 66  e re-opened.  If
10d0: 20 79 6f 75 20 6e 65 65 64 20 6c 6f 67 20 72 6f   you need log ro
10e0: 74 61 74 69 6f 6e 20 74 68 65 6e 20 61 20 73 65  tation then a se
10f0: 63 6f 6e 64 20 70 72 6f 63 65 73 73 2c 20 77 68  cond process, wh
1100: 69 63 68 20 63 61 6e 20 63 6c 6f 73 65 0a 61 6e  ich can close.an
1110: 64 20 72 65 2d 6f 70 65 6e 20 6c 6f 67 20 66 69  d re-open log fi
1120: 6c 65 73 2c 20 6d 75 73 74 20 62 65 20 75 73 65  les, must be use
1130: 64 2e 20 20 41 6e 79 20 70 72 6f 63 65 73 73 20  d.  Any process 
1140: 6d 61 79 20 62 65 20 75 73 65 64 20 66 6f 72 20  may be used for 
1150: 77 72 69 74 69 6e 67 20 6c 6f 67 73 0a 62 75 74  writing logs.but
1160: 20 69 66 20 74 68 65 20 70 72 6f 63 65 73 73 20   if the process 
1170: 64 6f 65 73 20 6e 6f 74 20 73 75 70 70 6f 72 74  does not support
1180: 20 6c 6f 67 20 72 6f 74 61 74 69 6f 6e 20 74 68   log rotation th
1190: 65 6e 20 69 74 20 77 69 6c 6c 20 6e 6f 74 20 70  en it will not p
11a0: 72 6f 76 69 64 65 20 74 68 61 74 0a 62 65 6e 65  rovide that.bene
11b0: 66 69 74 2e 20 20 46 6f 72 20 65 78 61 6d 70 6c  fit.  For exampl
11c0: 65 2c 20 69 66 20 79 6f 75 20 77 69 73 68 20 74  e, if you wish t
11d0: 6f 20 77 72 69 74 65 20 6c 6f 67 73 20 74 6f 20  o write logs to 
11e0: 73 79 73 6c 6f 67 64 28 38 29 20 79 6f 75 20 63  syslogd(8) you c
11f0: 61 6e 20 75 73 65 0a 6c 6f 67 67 65 72 28 31 29  an use.logger(1)
1200: 2c 20 73 75 63 68 20 61 73 3a 0a 09 23 20 2e 2f  , such as:..# ./
1210: 66 69 6c 65 64 20 2d 2d 72 6f 6f 74 20 2f 77 77  filed --root /ww
1220: 77 20 2d 2d 75 73 65 72 20 6e 6f 62 6f 64 79 20  w --user nobody 
1230: 2d 2d 6c 6f 67 20 27 7c 6c 6f 67 67 65 72 20 2d  --log '|logger -
1240: 74 20 66 69 6c 65 64 27 20 2d 2d 64 61 65 6d 6f  t filed' --daemo
1250: 6e 0a                                            n.