| 30 | # if the machine might be a multi-user machine and not all users are trusted. |
| 31 | # We only serve via the loopback interface. |
| 32 | def SanityCheckDirectory(dirname): |
| 33 | abs_serve_dir = os.path.abspath(dirname) |
| 34 | |
| 35 | # Verify we don't serve anywhere above NACL_SDK_ROOT. |
| 36 | if abs_serve_dir[:len(NACL_SDK_ROOT)] == NACL_SDK_ROOT: |
| 37 | return |
| 38 | logging.error('For security, httpd.py should only be run from within the') |
| 39 | logging.error('example directory tree.') |
| 40 | logging.error('Attempting to serve from %s.' % abs_serve_dir) |
| 41 | logging.error('Run with --no_dir_check to bypass this check.') |
| 42 | sys.exit(1) |
| 43 | |
| 44 | |
| 45 | class PluggableHTTPServer(BaseHTTPServer.HTTPServer): |