Show More
@@ -578,18 +578,7 b' class AutoExitMixIn: # use old-style to' | |||||
578 | # use a unique temp address so we can stat the file and do ownership |
|
578 | # use a unique temp address so we can stat the file and do ownership | |
579 | # check later |
|
579 | # check later | |
580 | tempaddress = _tempaddress(self.server_address) |
|
580 | tempaddress = _tempaddress(self.server_address) | |
581 | # use relative path instead of full path at bind() if possible, since |
|
581 | util.bindunixsocket(self.socket, tempaddress) | |
582 | # AF_UNIX path has very small length limit (107 chars) on common |
|
|||
583 | # platforms (see sys/un.h) |
|
|||
584 | dirname, basename = os.path.split(tempaddress) |
|
|||
585 | bakwdfd = None |
|
|||
586 | if dirname: |
|
|||
587 | bakwdfd = os.open('.', os.O_DIRECTORY) |
|
|||
588 | os.chdir(dirname) |
|
|||
589 | self.socket.bind(basename) |
|
|||
590 | if bakwdfd: |
|
|||
591 | os.fchdir(bakwdfd) |
|
|||
592 | os.close(bakwdfd) |
|
|||
593 | self._socketstat = os.stat(tempaddress) |
|
582 | self._socketstat = os.stat(tempaddress) | |
594 | # rename will replace the old socket file if exists atomically. the |
|
583 | # rename will replace the old socket file if exists atomically. the | |
595 | # old server will detect ownership change and exit. |
|
584 | # old server will detect ownership change and exit. |
@@ -598,3 +598,18 b' def readpipe(pipe):' | |||||
598 | return ''.join(chunks) |
|
598 | return ''.join(chunks) | |
599 | finally: |
|
599 | finally: | |
600 | fcntl.fcntl(pipe, fcntl.F_SETFL, oldflags) |
|
600 | fcntl.fcntl(pipe, fcntl.F_SETFL, oldflags) | |
|
601 | ||||
|
602 | def bindunixsocket(sock, path): | |||
|
603 | """Bind the UNIX domain socket to the specified path""" | |||
|
604 | # use relative path instead of full path at bind() if possible, since | |||
|
605 | # AF_UNIX path has very small length limit (107 chars) on common | |||
|
606 | # platforms (see sys/un.h) | |||
|
607 | dirname, basename = os.path.split(path) | |||
|
608 | bakwdfd = None | |||
|
609 | if dirname: | |||
|
610 | bakwdfd = os.open('.', os.O_DIRECTORY) | |||
|
611 | os.chdir(dirname) | |||
|
612 | sock.bind(basename) | |||
|
613 | if bakwdfd: | |||
|
614 | os.fchdir(bakwdfd) | |||
|
615 | os.close(bakwdfd) |
@@ -70,6 +70,7 b' else:' | |||||
70 |
|
70 | |||
71 | _ = i18n._ |
|
71 | _ = i18n._ | |
72 |
|
72 | |||
|
73 | bindunixsocket = platform.bindunixsocket | |||
73 | cachestat = platform.cachestat |
|
74 | cachestat = platform.cachestat | |
74 | checkexec = platform.checkexec |
|
75 | checkexec = platform.checkexec | |
75 | checklink = platform.checklink |
|
76 | checklink = platform.checklink |
General Comments 0
You need to be logged in to leave comments.
Login now