Print this page
305 http_proxy value needs more checking for valid url syntax
2341 Client should be more conservative about closing sockets
4235 Misleading "node name" unknown messages when http_proxy set incorrectly
4495 Want ability to cancel individual file downloads
8902 Need a transport that downloads files by GET
9508 Captive portal test only run during catalog refresh
9613 Implicit refresh should raise InvalidDepotResponseException
9615 EOL clientside search v0
9629 EOL clientside support for filelist
9630 Hostile depot should live with other depot code
9631 HTTPS transport should be more rigorous in verification
9670 More specific error exceptions requested from search
9686 network operations should use accept-encoding when appropriate
9715 The info() operation should use the activity_lock

Split Close
Expand all
Collapse all
          --- old/src/depot.py
          +++ new/src/depot.py
↓ open down ↓ 120 lines elided ↑ open up ↑
 121  121                  """Discard the bits."""
 122  122                  pass
 123  123  
 124  124  def usage(text):
 125  125          if text:
 126  126                  emsg(text)
 127  127  
 128  128          print """\
 129  129  Usage: /usr/lib/pkg.depotd [-d repo_dir] [-p port] [-s threads]
 130  130             [-t socket_timeout] [--cfg-file] [--content-root] [--debug]
 131      -           [--log-access dest] [--log-errors dest] [--mirror] [--proxy-base url]
 132      -           [--readonly] [--rebuild] [--ssl-cert-file] [--ssl-dialog]
 133      -           [--ssl-key-file] [--writable-root dir]
      131 +           [--log-access dest] [--log-errors dest] [--mirror] [--nasty]
      132 +           [--proxy-base url] [--readonly] [--rebuild] [--ssl-cert-file]
      133 +           [--ssl-dialog] [--ssl-key-file] [--writable-root dir]
 134  134  
 135  135          --cfg-file      The pathname of the file from which to read and to
 136  136                          write configuration information.
 137  137          --content-root  The file system path to the directory containing the
 138  138                          the static and other web content used by the depot's
 139  139                          browser user interface.  The default value is
 140  140                          '/usr/share/lib/pkg'.
 141  141          --debug         The name of a debug feature to enable; or a whitespace
 142  142                          or comma separated list of features to enable.  Possible
 143  143                          values are: headers.
↓ open down ↓ 2 lines elided ↑ open up ↑
 146  146                          stderr, stdout, none, or an absolute pathname.  The
 147  147                          default value is stdout if stdout is a tty; otherwise
 148  148                          the default value is none.
 149  149          --log-errors    The destination for any errors or other information
 150  150                          logged by the depot process.  Possible values are:
 151  151                          stderr, stdout, none, or an absolute pathname.  The
 152  152                          default value is stderr.
 153  153          --mirror        Package mirror mode; publishing and metadata operations
 154  154                          disallowed.  Cannot be used with --readonly or
 155  155                          --rebuild.
      156 +        --nasty         Instruct the server to misbehave.  At random intervals
      157 +                        it will time-out, send bad responses, hang up on
      158 +                        clients, and generally be hostile.  The option
      159 +                        takes a value (1 to 100) for how nasty the server
      160 +                        should be.
 156  161          --proxy-base    The url to use as the base for generating internal
 157  162                          redirects and content.
 158  163          --readonly      Read-only operation; modifying operations disallowed.
 159  164                          Cannot be used with --mirror or --rebuild.
 160  165          --rebuild       Re-build the catalog from pkgs in depot.  Cannot be
 161  166                          used with --mirror or --readonly.
 162  167          --ssl-cert-file The absolute pathname to a PEM-encoded Certificate file.
 163  168                          This option must be used with --ssl-key-file.  Usage of
 164  169                          this option will cause the depot to only respond to SSL
 165  170                          requests on the provided port.
↓ open down ↓ 29 lines elided ↑ open up ↑
 195  200          }
 196  201          port = PORT_DEFAULT
 197  202          port_provided = False
 198  203          threads = THREADS_DEFAULT
 199  204          socket_timeout = SOCKET_TIMEOUT_DEFAULT
 200  205          readonly = READONLY_DEFAULT
 201  206          rebuild = REBUILD_DEFAULT
 202  207          reindex = REINDEX_DEFAULT
 203  208          proxy_base = None
 204  209          mirror = MIRROR_DEFAULT
      210 +        nasty = False
      211 +        nasty_value = 0
 205  212          repo_config_file = None
 206  213          ssl_cert_file = None
 207  214          ssl_key_file = None
 208  215          ssl_dialog = "builtin"
 209  216          writable_root = None
 210  217  
 211  218          if "PKG_REPO" in os.environ:
 212  219                  repo_path = os.environ["PKG_REPO"]
 213  220          else:
 214  221                  repo_path = REPO_PATH_DEFAULT
↓ open down ↓ 16 lines elided ↑ open up ↑
 231  238          log_opts = ["--log-%s" % log_type for log_type in log_routes]
 232  239  
 233  240          # If stdout is a tty, then send access output there by default instead
 234  241          # of discarding it.
 235  242          if os.isatty(sys.stdout.fileno()):
 236  243                  log_routes["access"] = "stdout"
 237  244  
 238  245          opt = None
 239  246          try:
 240  247                  long_opts = ["cfg-file=", "content-root=", "debug=", "mirror",
 241      -                    "proxy-base=", "readonly", "rebuild", "refresh-index",
 242      -                    "ssl-cert-file=", "ssl-dialog=", "ssl-key-file=",
 243      -                    "writable-root="]
      248 +                    "nasty=", "proxy-base=", "readonly", "rebuild",
      249 +                    "refresh-index", "ssl-cert-file=", "ssl-dialog=",
      250 +                    "ssl-key-file=", "writable-root="]
 244  251                  for opt in log_opts:
 245  252                          long_opts.append("%s=" % opt.lstrip('--'))
 246  253                  opts, pargs = getopt.getopt(sys.argv[1:], "d:np:s:t:",
 247  254                      long_opts)
 248  255                  for opt, arg in opts:
 249  256                          if opt == "-n":
 250  257                                  sys.exit(0)
 251  258                          elif opt == "-d":
 252  259                                  repo_path = arg
 253  260                          elif opt == "-p":
↓ open down ↓ 35 lines elided ↑ open up ↑
 289  296                                                      "%s." % f
 290  297                                          debug_features[f] = True
 291  298                          elif opt in log_opts:
 292  299                                  if arg is None or arg == "":
 293  300                                          raise OptionError, \
 294  301                                              "You must specify a log " \
 295  302                                              "destination."
 296  303                                  log_routes[opt.lstrip("--log-")] = arg
 297  304                          elif opt == "--mirror":
 298  305                                  mirror = True
      306 +                        elif opt == "--nasty":
      307 +                                value_err = None
      308 +                                try:
      309 +                                        nasty_value = int(arg)
      310 +                                except ValueError, e:
      311 +                                        value_err = e
      312 +
      313 +                                if value_err or (nasty_value > 100 or
      314 +                                    nasty_value < 1):
      315 +                                        raise OptionError, "Invalid value " \
      316 +                                            "for nasty option.\n Please " \
      317 +                                            "choose a value between 1 and 100."
      318 +                                nasty = True
 299  319                          elif opt == "--proxy-base":
 300  320                                  # Attempt to decompose the url provided into
 301  321                                  # its base parts.  This is done so we can
 302  322                                  # remove any scheme information since we
 303  323                                  # don't need it.
 304  324                                  scheme, netloc, path, params, query, \
 305  325                                      fragment = urlparse.urlparse(arg,
 306  326                                      "http", allow_fragments=0)
 307  327  
 308  328                                  if not netloc:
↓ open down ↓ 127 lines elided ↑ open up ↑
 436  456                  if not available:
 437  457                          print "pkg.depotd: unable to bind to the specified " \
 438  458                              "port: %d. Reason: %s" % (port, msg)
 439  459                          sys.exit(1)
 440  460          else:
 441  461                  # Not applicable for reindexing operations.
 442  462                  content_root = None
 443  463  
 444  464          fork_allowed = not reindex
 445  465                  
 446      -        scfg = config.SvrConfig(repo_path, content_root, AUTH_DEFAULT,
 447      -            auto_create=not readonly, fork_allowed=fork_allowed,
 448      -            writable_root=writable_root)
      466 +        if nasty:
      467 +                scfg = config.NastySvrConfig(repo_path, content_root,
      468 +                    AUTH_DEFAULT, auto_create=not readonly,
      469 +                    fork_allowed=fork_allowed, writable_root=writable_root)
      470 +                scfg.set_nasty(nasty_value)
      471 +        else:
      472 +                scfg = config.SvrConfig(repo_path, content_root, AUTH_DEFAULT,
      473 +                    auto_create=not readonly, fork_allowed=fork_allowed,
      474 +                    writable_root=writable_root)
 449  475  
 450  476          if readonly:
 451  477                  scfg.set_read_only()
 452  478  
 453  479          if mirror:
 454  480                  scfg.set_mirror()
 455  481  
      482 +
 456  483          try:
 457  484                  scfg.init_dirs()
 458  485          except (errors.SvrConfigError, EnvironmentError), _e:
 459  486                  print "pkg.depotd: an error occurred while trying to " \
 460  487                      "initialize the depot repository directory " \
 461  488                      "structures:\n%s" % _e
 462  489                  sys.exit(1)
 463  490  
 464  491          key_data = None
 465  492          if not reindex and ssl_cert_file and ssl_key_file and \
↓ open down ↓ 155 lines elided ↑ open up ↑
 621  648                          conf["/"][entry] = proxy_conf[entry]
 622  649  
 623  650          scfg.acquire_in_flight()
 624  651          try:
 625  652                  scfg.acquire_catalog(rebuild=rebuild, verbose=True)
 626  653          except (catalog.CatalogPermissionsException, errors.SvrConfigError), _e:
 627  654                  emsg("pkg.depotd: %s" % _e)
 628  655                  sys.exit(1)
 629  656  
 630  657          try:
 631      -                root = cherrypy.Application(depot.DepotHTTP(scfg,
 632      -                    repo_config_file))
      658 +                if nasty:
      659 +                        root = cherrypy.Application(depot.NastyDepotHTTP(scfg,
      660 +                            repo_config_file))
      661 +                else:
      662 +                        root = cherrypy.Application(depot.DepotHTTP(scfg,
      663 +                            repo_config_file))
 633  664          except rc.InvalidAttributeValueError, _e:
 634  665                  emsg("pkg.depotd: repository.conf error: %s" % _e)
 635  666                  sys.exit(1)
 636  667  
 637  668          try:
 638  669                  cherrypy.quickstart(root, config=conf)
 639  670          except Exception, _e:
 640  671                  emsg("pkg.depotd: unknown error starting depot server, " \
 641  672                      "illegal option value specified?")
 642  673                  emsg(_e)
 643  674                  sys.exit(1)
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX