[PATCH 1 of 5 V2] chgserver: use basename for socket symlink

Jun Wu quark at fb.com
Fri Mar 4 08:28:54 EST 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1457097482 0
#      Fri Mar 04 13:18:02 2016 +0000
# Node ID 8868538a8a0d5ca8f36f0bdea8d11192ff4e8ca0
# Parent  e00e57d836535aadcb13337613d2f891492d8e04
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.

diff --git a/hgext/chgserver.py b/hgext/chgserver.py
--- a/hgext/chgserver.py
+++ b/hgext/chgserver.py
@@ -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):


More information about the Mercurial-devel mailing list