mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Properly detect when ports are available.
The DS setup program uses Perl and does a similar port available test. It seems that perl always sets FD_CLOEXEC and python does not. This is why the port test would pass in python but fail in perl. 439024
This commit is contained in:
@@ -27,6 +27,7 @@ import fileinput
|
||||
import sys
|
||||
import time
|
||||
import struct
|
||||
import fcntl
|
||||
|
||||
from ipa import ipautil
|
||||
from ipa import dnsclient
|
||||
@@ -104,9 +105,8 @@ def port_available(port):
|
||||
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
fcntl.fcntl(s, fcntl.F_SETFD, fcntl.FD_CLOEXEC)
|
||||
s.bind(('', port))
|
||||
s.shutdown(0)
|
||||
s.close()
|
||||
except socket.error, e:
|
||||
if e[0] == errno.EADDRINUSE:
|
||||
@@ -115,9 +115,8 @@ def port_available(port):
|
||||
if rv:
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
fcntl.fcntl(s, fcntl.F_SETFD, fcntl.FD_CLOEXEC)
|
||||
s.bind(('', port))
|
||||
s.shutdown(0)
|
||||
s.close()
|
||||
except socket.error, e:
|
||||
if e[0] == errno.EADDRINUSE:
|
||||
|
||||
Reference in New Issue
Block a user