summaryrefslogtreecommitdiffstats
path: root/ipa-server/ipa-install
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2007-10-15 13:27:05 -0400
committerRob Crittenden <rcritten@redhat.com>2007-10-15 13:27:05 -0400
commitaf0a1d989b1eb483ae3e76fa5a3008fda3fafb5e (patch)
treef37b4f22adf92228a6aa064dad9bc47c230a4076 /ipa-server/ipa-install
parent95f0c52013270fd83e33c480254a8001211fe9fa (diff)
downloadfreeipa-af0a1d989b1eb483ae3e76fa5a3008fda3fafb5e.tar.gz
freeipa-af0a1d989b1eb483ae3e76fa5a3008fda3fafb5e.tar.xz
freeipa-af0a1d989b1eb483ae3e76fa5a3008fda3fafb5e.zip
Verify that the LDAP ports are available during installation.
Diffstat (limited to 'ipa-server/ipa-install')
-rw-r--r--ipa-server/ipa-install/ipa-server-install44
1 files changed, 44 insertions, 0 deletions
diff --git a/ipa-server/ipa-install/ipa-server-install b/ipa-server/ipa-install/ipa-server-install
index 34666af55..f970d5ef8 100644
--- a/ipa-server/ipa-install/ipa-server-install
+++ b/ipa-server/ipa-install/ipa-server-install
@@ -31,6 +31,7 @@ sys.path.append("/usr/share/ipa")
import os
import socket
+import errno
import logging
import pwd
import getpass
@@ -138,6 +139,18 @@ def check_existing_installation():
if 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():
fqdn = ""
try:
@@ -234,6 +247,36 @@ def read_ip_address():
hosts_fd.close()
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():
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"
@@ -344,6 +387,7 @@ def main():
print "To accept the default shown in brackets, press the Enter key."
print ""
+ check_ports()
check_existing_installation()
options = parse_options()