Skip to content

Commit 40c839c

Browse files
committed
add comments explaining format and design choices for stashservers api
1 parent 667853d commit 40c839c

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

stashcp/__init__.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,34 @@ def get_best_stashcache():
668668
if len(caches_list) == 0:
669669
# Used the stashservers.dat api
670670

671+
# After the geo order of the selected server list on line zero,
672+
# the rest of the response is in .cvmfswhitelist format.
673+
# This is done to avoid using https for every request on the
674+
# wlcg-wpad servers and takes advantage of conveniently
675+
# existing infrastructure.
676+
# The format contains the following lines:
677+
# 1. Creation date stamp, e.g. 20200414170005. For debugging
678+
# only.
679+
# 2. Expiration date stamp, e.g. E20200421170005. cvmfs clients
680+
# check this to avoid replay attacks, but for this api that
681+
# is not much of a risk so it is ignored.
682+
# 3. "Repository" name, e.g. Nstash-servers. cvmfs clients
683+
# also check this but it is not important here.
684+
# 4. With cvmfs the 4th line has a repository fingerprint, but
685+
# for this api it instead contains a semi-colon separated list
686+
# of named server lists. Each server list is of the form
687+
# name=servers where servers is comma-separated. Ends with
688+
# "hash=-sha1" because cvmfs_server expects the hash name
689+
# to be there. e.g.
690+
# xroot=stashcache.t2.ucsd.edu,sg-gftp.pace.gatech.edu;xroots=xrootd-local.unl.edu,stashcache.t2.ucsd.edu;hash=-sha1
691+
# 5. A two-dash separator, i.e "--"
692+
# 6. The sha1 hash of lines 1 through 4.
693+
# 7. The signature, i.e. an RSA encryption of the hash that can
694+
# be decrypted by the OSG cvmfs public key. Contains binary
695+
# information so it may contain a variable number of newlines
696+
# which would have caused it to have been split into multiple
697+
# response "lines".
698+
671699
if len(responselines) < 8:
672700
logging.error("stashservers response too short, less than 8 lines")
673701
return None
@@ -683,7 +711,12 @@ def get_best_stashcache():
683711
logging.error("stashservers response hash does not match expected hash")
684712
return None
685713

714+
# Call out to /usr/bin/openssl if present, in order to avoid
715+
# python dependency on a crypto package.
686716
if not os.path.exists("/usr/bin/openssl"):
717+
# The signature check isn't critical to be done everywhere;
718+
# any tampering will likely to be caught somewhere and
719+
# investigated. Usually openssl is present.
687720
logging.debug("openssl not installed, skipping signature check")
688721
else:
689722
sig = '\n'.join(responselines[7:])

0 commit comments

Comments
 (0)