mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Verify that the LDAP ports are available during installation.
This commit is contained in:
@@ -31,6 +31,7 @@ sys.path.append("/usr/share/ipa")
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
|
import errno
|
||||||
import logging
|
import logging
|
||||||
import pwd
|
import pwd
|
||||||
import getpass
|
import getpass
|
||||||
@@ -138,6 +139,18 @@ def check_existing_installation():
|
|||||||
if serverid:
|
if serverid:
|
||||||
erase_ds_instance_data(serverid)
|
erase_ds_instance_data(serverid)
|
||||||
|
|
||||||
|
def check_ports():
|
||||||
|
ds_unsecure = port_available(389)
|
||||||
|
ds_secure = port_available(636)
|
||||||
|
if not ds_unsecure or not ds_secure:
|
||||||
|
print "IPA requires ports 389 and 636 for the Directory Server."
|
||||||
|
print "These are currently in use:"
|
||||||
|
if not ds_unsecure:
|
||||||
|
print "\t389"
|
||||||
|
if not ds_secure:
|
||||||
|
print "\t636"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def get_fqdn():
|
def get_fqdn():
|
||||||
fqdn = ""
|
fqdn = ""
|
||||||
try:
|
try:
|
||||||
@@ -234,6 +247,36 @@ def read_ip_address():
|
|||||||
hosts_fd.close()
|
hosts_fd.close()
|
||||||
askip = False
|
askip = False
|
||||||
|
|
||||||
|
def port_available(port):
|
||||||
|
"""Try to bind to a port on the wildcard host
|
||||||
|
Return 1 if the port is available
|
||||||
|
Return 0 if the port is in use
|
||||||
|
"""
|
||||||
|
rv = 1
|
||||||
|
|
||||||
|
try:
|
||||||
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
|
s.bind(('', port))
|
||||||
|
s.shutdown(0)
|
||||||
|
s.close()
|
||||||
|
except socket.error, e:
|
||||||
|
if e[0] == errno.EADDRINUSE:
|
||||||
|
rv = 0
|
||||||
|
|
||||||
|
if rv:
|
||||||
|
try:
|
||||||
|
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
||||||
|
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
|
s.bind(('', port))
|
||||||
|
s.shutdown(0)
|
||||||
|
s.close()
|
||||||
|
except socket.error, e:
|
||||||
|
if e[0] == errno.EADDRINUSE:
|
||||||
|
rv = 0
|
||||||
|
|
||||||
|
return rv
|
||||||
|
|
||||||
def read_ds_user():
|
def read_ds_user():
|
||||||
print "The server must run as a specific user in a specific group."
|
print "The server must run as a specific user in a specific group."
|
||||||
print "It is strongly recommended that this user should have no privileges"
|
print "It is strongly recommended that this user should have no privileges"
|
||||||
@@ -344,6 +387,7 @@ def main():
|
|||||||
print "To accept the default shown in brackets, press the Enter key."
|
print "To accept the default shown in brackets, press the Enter key."
|
||||||
print ""
|
print ""
|
||||||
|
|
||||||
|
check_ports()
|
||||||
check_existing_installation()
|
check_existing_installation()
|
||||||
|
|
||||||
options = parse_options()
|
options = parse_options()
|
||||||
|
|||||||
Reference in New Issue
Block a user