Opened 10 years ago

Closed 10 years ago

#226 closed defect (fixed)

store flappserver services in JSON, not separate files

Reported by: Brian Warner Owned by: Brian Warner
Priority: major Milestone: 0.7.0
Component: appserver Version: 0.6.5
Keywords: Cc:

Description (last modified by Brian Warner)

To help with https://github.com/warner/git-foolscap/issues/1 (ex #200), as well as fix a minor security problem with flappserver service lookup, we need to change the way that it stores the service information.

Currently (in 0.6.5) these services are stored as a collection of small files, three per service (named service_type, service_args, and an optional comment), in a subdirectory named after the service's swissnum. These all live in a directory named services which itself lives inside the flappserver's basedir. The complete path looks like BASEDIR/services/SWISSNUM/service_type. The flappserver uses the incoming swissnum to locate the service information, instantiates something according to the service_type, and connects the new service object to the caller.

But swissnums are allowed to be pretty arbitrary: git-foolscap puts a slash in them (SWISSNUM/REPONAME) so that "git clone" behaves well. And flappserver list does a simple os.listdir("BASEDIR/services") to enumerate the swissnums, which breaks on the embedded slashes (as they wind up creating intermediate directories).

So the new plan is:

  • store service info in a single JSON file, BASEDIR/services.json
  • write one function that loads a dict of services (swissnum -> {service_type, service_args, comment}), by loading the JSON file if present, otherwise scanning services with os.walk() for all service_type files and reconstructing swissnums from the (possibly multi-part) paths
  • use this dict for:
    • flappserver list
    • service lookup
    • flappserver add (load the dict, add keys, write services.json)

This will basically force an upgrade if you use flappserver add on an old-format basedir, otherwise it'll leave things alone (but use the contents more safely).

Change History (3)

comment:1 Changed 10 years ago by Brian Warner

Description: modified (diff)

comment:2 Changed 10 years ago by Brian Warner

Description: modified (diff)

comment:3 Changed 10 years ago by Brian Warner

Resolution: fixed
Status: newclosed

Fixed in [e35ce531a8]

Note: See TracTickets for help on using tickets.