Skip to content

Commit 24d7277

Browse files
Merge pull request #151 from matyasselmeci/pr/authfile-update-merge-grid-mapfile.SOFTWARE-5468
Use grid-mapfile downloaded from Topology
2 parents ec61a8a + 5ac1688 commit 24d7277

2 files changed

Lines changed: 37 additions & 4 deletions

File tree

configs/xcache/config.d/40-xcache-auth.cfg

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,25 @@ if named stash-cache
1414
else
1515
setenv X509_USER_PROXY = /run/xcache-auth/x509_proxy
1616
fi
17+
18+
19+
if defined ?GridMapfile
20+
# pass
21+
else if named stash-cache-auth
22+
set GridMapfile = /run/stash-cache-auth/grid-mapfile
23+
else if named stash-origin-auth
24+
set GridMapfile = /run/stash-origin-auth/grid-mapfile
25+
else
26+
set GridMapfile = /etc/grid-security/grid-mapfile
27+
fi
28+
29+
if defined ?GmapOpt
30+
# pass
31+
else if named stash-cache-auth
32+
set GmapOpt = usemap
33+
else if named stash-origin-auth
34+
set GmapOpt = usemap
35+
else
36+
set GmapOpt = trymap
37+
fi
38+

src/authfile-update

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,20 @@ class Download:
8989

9090
self.full_destdir = f"{self.destdir}/{self.instance}"
9191
self.dest_file = f"{self.full_destdir}/{self.config_file}"
92-
self.local_files = [
92+
self.local_files = []
93+
if config_file == "grid-mapfile":
94+
# Local additions to the grid-mapfile are prepended, not appended
95+
# to what's downloaded from topology because we want them to "win"
96+
self.prepend_local = True
97+
98+
# Backward compat: also read /etc/grid-security/grid-mapfile
99+
self.local_files.append("/etc/grid-security/grid-mapfile")
100+
else:
101+
self.prepend_local = False
102+
self.local_files += [
93103
f"{self.destdir}/{self.instance}/{self.config_file}.local",
94104
f"/etc/xrootd/{self.instance}-{self.config_file}.local",
95105
]
96-
self.prepend_local = config_file == "grid-mapfile"
97-
# ^^ local additions to the grid-mapfile are prepended, not appended
98-
# to what's downloaded from topology
99106

100107
def fetch(self) -> Tuple[Optional[str], bool]:
101108
"""Download the data for this config file from Topology and return
@@ -137,6 +144,10 @@ class Download:
137144
new_text = ""
138145
for local_file in self.local_files:
139146
try:
147+
if os.path.samefile(os.path.realpath(local_file), os.path.realpath(self.dest_file)):
148+
# The local file is a symlink to the destination file or something similar.
149+
# Skip it to avoid a loop.
150+
continue
140151
with open(local_file, "rt", encoding="utf-8", errors="replace") as fh:
141152
new_text += (
142153
f"## The following lines are from {local_file}:\n"

0 commit comments

Comments
 (0)