@@ -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