|
@@ -63,6 +63,7 @@ import pwd
|
|
import posix
|
|
import posix
|
|
|
|
|
|
import isc.cc
|
|
import isc.cc
|
|
|
|
+import isc.net.parse
|
|
import isc.utils.process
|
|
import isc.utils.process
|
|
|
|
|
|
# Assign this process some longer name
|
|
# Assign this process some longer name
|
|
@@ -183,35 +184,10 @@ class ProcessInfo:
|
|
def respawn(self):
|
|
def respawn(self):
|
|
self._spawn()
|
|
self._spawn()
|
|
|
|
|
|
-class IPAddr:
|
|
|
|
- """Stores an IPv4 or IPv6 address."""
|
|
|
|
- family = None
|
|
|
|
- addr = None
|
|
|
|
-
|
|
|
|
- def __init__(self, addr):
|
|
|
|
- try:
|
|
|
|
- a = socket.inet_pton(socket.AF_INET, addr)
|
|
|
|
- self.family = socket.AF_INET
|
|
|
|
- self.addr = a
|
|
|
|
- return
|
|
|
|
- except:
|
|
|
|
- pass
|
|
|
|
-
|
|
|
|
- try:
|
|
|
|
- a = socket.inet_pton(socket.AF_INET6, addr)
|
|
|
|
- self.family = socket.AF_INET6
|
|
|
|
- self.addr = a
|
|
|
|
- return
|
|
|
|
- except Exception as e:
|
|
|
|
- raise e
|
|
|
|
-
|
|
|
|
- def __str__(self):
|
|
|
|
- return socket.inet_ntop(self.family, self.addr)
|
|
|
|
-
|
|
|
|
class BoB:
|
|
class BoB:
|
|
"""Boss of BIND class."""
|
|
"""Boss of BIND class."""
|
|
|
|
|
|
- def __init__(self, msgq_socket_file=None, auth_port=5300, address='',
|
|
|
|
|
|
+ def __init__(self, msgq_socket_file=None, auth_port=5300, address=None,
|
|
nocache=False, verbose=False, setuid=None, username=None):
|
|
nocache=False, verbose=False, setuid=None, username=None):
|
|
"""Initialize the Boss of BIND. This is a singleton (only one
|
|
"""Initialize the Boss of BIND. This is a singleton (only one
|
|
can run).
|
|
can run).
|
|
@@ -225,7 +201,7 @@ class BoB:
|
|
self.auth_port = auth_port
|
|
self.auth_port = auth_port
|
|
self.address = None
|
|
self.address = None
|
|
if address:
|
|
if address:
|
|
- self.address = IPAddr(address)
|
|
|
|
|
|
+ self.address = address
|
|
self.cc_session = None
|
|
self.cc_session = None
|
|
self.ccs = None
|
|
self.ccs = None
|
|
self.processes = {}
|
|
self.processes = {}
|
|
@@ -608,7 +584,7 @@ def reaper(signal_number, stack_frame):
|
|
# the Python signal handler has been set up to write
|
|
# the Python signal handler has been set up to write
|
|
# down a pipe, waking up our select() bit
|
|
# down a pipe, waking up our select() bit
|
|
pass
|
|
pass
|
|
-
|
|
|
|
|
|
+
|
|
def get_signame(signal_number):
|
|
def get_signame(signal_number):
|
|
"""Return the symbolic name for a signal."""
|
|
"""Return the symbolic name for a signal."""
|
|
for sig in dir(signal):
|
|
for sig in dir(signal):
|
|
@@ -630,26 +606,24 @@ def fatal_signal(signal_number, stack_frame):
|
|
def check_port(option, opt_str, value, parser):
|
|
def check_port(option, opt_str, value, parser):
|
|
"""Function to insure that the port we are passed is actually
|
|
"""Function to insure that the port we are passed is actually
|
|
a valid port number. Used by OptionParser() on startup."""
|
|
a valid port number. Used by OptionParser() on startup."""
|
|
- if not re.match('^(6553[0-5]|655[0-2]\d|65[0-4]\d\d|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3}|0)$', value):
|
|
|
|
- raise OptionValueError("%s requires a port number (0-65535)" % opt_str)
|
|
|
|
- if (opt_str == '-m' or opt_str == '--msgq-port'):
|
|
|
|
- parser.values.msgq_port = value
|
|
|
|
- elif (opt_str == '-p' or opt_str == '--port'):
|
|
|
|
- parser.values.auth_port = value
|
|
|
|
- else:
|
|
|
|
- raise OptionValueError("Unknown option " + opt_str)
|
|
|
|
-
|
|
|
|
|
|
+ try:
|
|
|
|
+ if opt_str in ['-p', '--port']:
|
|
|
|
+ parser.values.auth_port = isc.net.parse.port_parse(value)
|
|
|
|
+ else:
|
|
|
|
+ raise OptionValueError("Unknown option " + opt_str)
|
|
|
|
+ except ValueError as e:
|
|
|
|
+ raise OptionValueError(str(e))
|
|
|
|
+
|
|
def check_addr(option, opt_str, value, parser):
|
|
def check_addr(option, opt_str, value, parser):
|
|
"""Function to insure that the address we are passed is actually
|
|
"""Function to insure that the address we are passed is actually
|
|
a valid address. Used by OptionParser() on startup."""
|
|
a valid address. Used by OptionParser() on startup."""
|
|
try:
|
|
try:
|
|
- IPAddr(value)
|
|
|
|
- except:
|
|
|
|
|
|
+ if opt_str in ['-a', '--address']:
|
|
|
|
+ parser.values.address = isc.net.parse.addr_parse(value)
|
|
|
|
+ else:
|
|
|
|
+ raise OptionValueError("Unknown option " + opt_str)
|
|
|
|
+ except ValueError:
|
|
raise OptionValueError("%s requires a valid IPv4 or IPv6 address" % opt_str)
|
|
raise OptionValueError("%s requires a valid IPv4 or IPv6 address" % opt_str)
|
|
- if (opt_str == '-a' or opt_str == '--address'):
|
|
|
|
- parser.values.address = value
|
|
|
|
- else:
|
|
|
|
- raise OptionValueError("Unknown option " + opt_str)
|
|
|
|
|
|
|
|
def process_rename(option, opt_str, value, parser):
|
|
def process_rename(option, opt_str, value, parser):
|
|
"""Function that renames the process if it is requested by a option."""
|
|
"""Function that renames the process if it is requested by a option."""
|
|
@@ -672,8 +646,8 @@ def main():
|
|
help="UNIX domain socket file the b10-msgq daemon will use")
|
|
help="UNIX domain socket file the b10-msgq daemon will use")
|
|
parser.add_option("-n", "--no-cache", action="store_true", dest="nocache",
|
|
parser.add_option("-n", "--no-cache", action="store_true", dest="nocache",
|
|
default=False, help="disable hot-spot cache in b10-auth")
|
|
default=False, help="disable hot-spot cache in b10-auth")
|
|
- parser.add_option("-p", "--port", dest="auth_port", type="string",
|
|
|
|
- action="callback", callback=check_port, default="5300",
|
|
|
|
|
|
+ parser.add_option("-p", "--port", dest="auth_port", type="int",
|
|
|
|
+ action="callback", callback=check_port, default=5300,
|
|
help="port the b10-auth daemon will use (default 5300)")
|
|
help="port the b10-auth daemon will use (default 5300)")
|
|
parser.add_option("-u", "--user", dest="user",
|
|
parser.add_option("-u", "--user", dest="user",
|
|
type="string", default=None,
|
|
type="string", default=None,
|
|
@@ -740,7 +714,7 @@ def main():
|
|
signal.signal(signal.SIGPIPE, signal.SIG_IGN)
|
|
signal.signal(signal.SIGPIPE, signal.SIG_IGN)
|
|
|
|
|
|
# Go bob!
|
|
# Go bob!
|
|
- boss_of_bind = BoB(options.msgq_socket_file, int(options.auth_port),
|
|
|
|
|
|
+ boss_of_bind = BoB(options.msgq_socket_file, options.auth_port,
|
|
options.address, options.nocache, options.verbose,
|
|
options.address, options.nocache, options.verbose,
|
|
setuid, username)
|
|
setuid, username)
|
|
startup_result = boss_of_bind.startup()
|
|
startup_result = boss_of_bind.startup()
|