chgserver: use basename for socket symlink
authorJun Wu <quark@fb.com>
Fri, 04 Mar 2016 13:18:02 +0000
changeset 28342 bd05d38a1002
parent 28341 8286f551b7ee
child 28343 a6c2310b3827
chgserver: use basename for socket symlink Previously we use full path and the symlink may point to outside (unsafe) world if the directory is moved. This patch fixes it by only linking to basename of the target. Therefore the symbolic link and socket files will always stay in the same directory.
hgext/chgserver.py
--- a/hgext/chgserver.py	Thu Mar 03 18:34:19 2016 +0100
+++ b/hgext/chgserver.py	Fri Mar 04 13:18:02 2016 +0000
@@ -613,7 +613,7 @@
         if self.baseaddress == self.address:
             return
         tempaddress = _tempaddress(self.baseaddress)
-        os.symlink(self.address, tempaddress)
+        os.symlink(os.path.basename(self.address), tempaddress)
         util.rename(tempaddress, self.baseaddress)
 
     def _reloadconfig(self, signum, frame):