mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-12 01:01:55 -06:00
More ipautil fixing
Recently, dsinstance and krbinstance was fixed to not import * from ipautil; do the same for the rest of ipaserver. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
This commit is contained in:
parent
a39f1cb2cb
commit
2a036abe7a
@ -29,7 +29,7 @@ import logging
|
||||
import pwd
|
||||
import time
|
||||
import sys
|
||||
from ipa.ipautil import *
|
||||
from ipa import ipautil
|
||||
from ipa import radius_util
|
||||
|
||||
from ipaserver import service
|
||||
@ -46,7 +46,7 @@ from ipaserver.funcs import DefaultUserContainer, DefaultGroupContainer
|
||||
|
||||
def ldap_mod(fd, dn, pwd):
|
||||
args = ["/usr/bin/ldapmodify", "-h", "127.0.0.1", "-xv", "-D", dn, "-w", pwd, "-f", fd.name]
|
||||
run(args)
|
||||
ipautil.run(args)
|
||||
|
||||
def get_radius_version():
|
||||
version = None
|
||||
@ -76,7 +76,7 @@ class RadiusInstance(service.Service):
|
||||
|
||||
def create_instance(self, realm_name, host_name, ldap_server):
|
||||
self.realm = realm_name.upper()
|
||||
self.suffix = realm_to_suffix(self.realm)
|
||||
self.suffix = ipautil.realm_to_suffix(self.realm)
|
||||
self.fqdn = host_name
|
||||
self.ldap_server = ldap_server
|
||||
self.principal = "%s/%s@%s" % (radius_util.RADIUS_SERVICE_NAME, self.fqdn, self.realm)
|
||||
@ -119,7 +119,7 @@ class RadiusInstance(service.Service):
|
||||
'SUFFIX' : self.suffix,
|
||||
}
|
||||
try:
|
||||
radiusd_conf = template_file(radius_util.RADIUSD_CONF_TEMPLATE_FILEPATH, sub_dict)
|
||||
radiusd_conf = ipautil.template_file(radius_util.RADIUSD_CONF_TEMPLATE_FILEPATH, sub_dict)
|
||||
radiusd_fd = open(radius_util.RADIUSD_CONF_FILEPATH, 'w+')
|
||||
radiusd_fd.write(radiusd_conf)
|
||||
radiusd_fd.close()
|
||||
@ -129,7 +129,7 @@ class RadiusInstance(service.Service):
|
||||
def __create_radius_keytab(self):
|
||||
self.step("creating a keytab for radiusd")
|
||||
try:
|
||||
if file_exists(radius_util.RADIUS_IPA_KEYTAB_FILEPATH):
|
||||
if ipautil.file_exists(radius_util.RADIUS_IPA_KEYTAB_FILEPATH):
|
||||
os.remove(radius_util.RADIUS_IPA_KEYTAB_FILEPATH)
|
||||
except os.error:
|
||||
logging.error("Failed to remove %s", radius_util.RADIUS_IPA_KEYTAB_FILEPATH)
|
||||
@ -145,7 +145,7 @@ class RadiusInstance(service.Service):
|
||||
|
||||
# give kadmin time to actually write the file before we go on
|
||||
retry = 0
|
||||
while not file_exists(radius_util.RADIUS_IPA_KEYTAB_FILEPATH):
|
||||
while not ipautil.file_exists(radius_util.RADIUS_IPA_KEYTAB_FILEPATH):
|
||||
time.sleep(1)
|
||||
retry += 1
|
||||
if retry > 15:
|
||||
@ -161,11 +161,11 @@ class RadiusInstance(service.Service):
|
||||
def __set_ldap_encrypted_attributes(self):
|
||||
ldif_file = 'encrypted_attribute.ldif'
|
||||
self.step("setting ldap encrypted attributes")
|
||||
ldif_txt = template_file(SHARE_DIR + ldif_file, {'ENCRYPTED_ATTRIBUTE':'radiusClientSecret'})
|
||||
ldif_fd = write_tmp_file(ldif_txt)
|
||||
ldif_txt = ipautil.template_file(ipautil.SHARE_DIR + ldif_file, {'ENCRYPTED_ATTRIBUTE':'radiusClientSecret'})
|
||||
ldif_fd = ipautil.write_tmp_file(ldif_txt)
|
||||
try:
|
||||
ldap_mod(ldif_fd, "cn=Directory Manager", self.dm_password)
|
||||
except subprocess.CalledProcessError, e:
|
||||
except ipautil.CalledProcessError, e:
|
||||
logging.critical("Failed to load %s: %s" % (ldif_file, str(e)))
|
||||
ldif_fd.close()
|
||||
|
||||
|
@ -23,10 +23,13 @@ import tempfile
|
||||
import shutil
|
||||
import os
|
||||
import socket
|
||||
from ipa.ipautil import *
|
||||
|
||||
class BindInstance:
|
||||
import service
|
||||
from ipa import ipautil
|
||||
|
||||
class BindInstance(service.Service):
|
||||
def __init__(self):
|
||||
service.Service.__init__(self, "named")
|
||||
self.fqdn = None
|
||||
self.domain = None
|
||||
self.host = None
|
||||
@ -52,7 +55,7 @@ class BindInstance:
|
||||
return True
|
||||
|
||||
def create_sample_bind_zone(self):
|
||||
bind_txt = template_file(SHARE_DIR + "bind.zone.db.template", self.sub_dict)
|
||||
bind_txt = ipautil.template_file(ipautil.SHARE_DIR + "bind.zone.db.template", self.sub_dict)
|
||||
[bind_fd, bind_name] = tempfile.mkstemp(".db","sample.zone.")
|
||||
os.write(bind_fd, bind_txt)
|
||||
os.close(bind_fd)
|
||||
@ -73,15 +76,6 @@ class BindInstance:
|
||||
except:
|
||||
print "named service failed to start"
|
||||
|
||||
def stop(self):
|
||||
run(["/sbin/service", "named", "stop"])
|
||||
|
||||
def start(self):
|
||||
run(["/sbin/service", "named", "start"])
|
||||
|
||||
def restart(self):
|
||||
run(["/sbin/service", "named", "restart"])
|
||||
|
||||
def __setup_sub_dict(self):
|
||||
self.sub_dict = dict(FQDN=self.fqdn,
|
||||
IP=self.ip_address,
|
||||
@ -90,7 +84,7 @@ class BindInstance:
|
||||
REALM=self.realm)
|
||||
|
||||
def __setup_zone(self):
|
||||
zone_txt = template_file(SHARE_DIR + "bind.zone.db.template", self.sub_dict)
|
||||
zone_txt = ipautil.template_file(ipautil.SHARE_DIR + "bind.zone.db.template", self.sub_dict)
|
||||
zone_fd = open('/var/named/'+self.domain+'.zone.db', 'w')
|
||||
zone_fd.write(zone_txt)
|
||||
zone_fd.close()
|
||||
@ -98,7 +92,7 @@ class BindInstance:
|
||||
def __setup_named_conf(self):
|
||||
if os.path.exists('/etc/named.conf'):
|
||||
shutil.copy2('/etc/named.conf', '/etc/named.conf.ipabkp')
|
||||
named_txt = template_file(SHARE_DIR + "bind.named.conf.template", self.sub_dict)
|
||||
named_txt = ipautil.template_file(ipautil.SHARE_DIR + "bind.named.conf.template", self.sub_dict)
|
||||
named_fd = open('/etc/named.conf', 'w')
|
||||
named_fd.seek(0)
|
||||
named_fd.truncate(0)
|
||||
|
@ -17,6 +17,8 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import subprocess
|
||||
import string
|
||||
import tempfile
|
||||
@ -31,7 +33,7 @@ import service
|
||||
import certs
|
||||
import dsinstance
|
||||
import installutils
|
||||
from ipa.ipautil import *
|
||||
from ipa import ipautil
|
||||
|
||||
HTTPD_DIR = "/etc/httpd"
|
||||
SSL_CONF = HTTPD_DIR + "/conf.d/ssl.conf"
|
||||
@ -77,7 +79,7 @@ class HTTPInstance(service.Service):
|
||||
selinux=0
|
||||
try:
|
||||
if (os.path.exists('/usr/sbin/selinuxenabled')):
|
||||
run(["/usr/sbin/selinuxenabled"])
|
||||
ipautil.run(["/usr/sbin/selinuxenabled"])
|
||||
selinux=1
|
||||
except ipautil.CalledProcessError:
|
||||
# selinuxenabled returns 1 if not enabled
|
||||
@ -87,14 +89,14 @@ class HTTPInstance(service.Service):
|
||||
# Allow apache to connect to the turbogears web gui
|
||||
# This can still fail even if selinux is enabled
|
||||
try:
|
||||
run(["/usr/sbin/setsebool", "-P", "httpd_can_network_connect", "true"])
|
||||
ipautil.run(["/usr/sbin/setsebool", "-P", "httpd_can_network_connect", "true"])
|
||||
except:
|
||||
self.print_msg(selinux_warning)
|
||||
|
||||
def __create_http_keytab(self):
|
||||
self.step("creating a keytab for httpd")
|
||||
try:
|
||||
if file_exists("/etc/httpd/conf/ipa.keytab"):
|
||||
if ipautil.file_exists("/etc/httpd/conf/ipa.keytab"):
|
||||
os.remove("/etc/httpd/conf/ipa.keytab")
|
||||
except os.error:
|
||||
print "Failed to remove /etc/httpd/conf/ipa.keytab."
|
||||
@ -109,7 +111,7 @@ class HTTPInstance(service.Service):
|
||||
|
||||
# give kadmin time to actually write the file before we go on
|
||||
retry = 0
|
||||
while not file_exists("/etc/httpd/conf/ipa.keytab"):
|
||||
while not ipautil.file_exists("/etc/httpd/conf/ipa.keytab"):
|
||||
time.sleep(1)
|
||||
retry += 1
|
||||
if retry > 15:
|
||||
@ -121,7 +123,7 @@ class HTTPInstance(service.Service):
|
||||
|
||||
def __configure_http(self):
|
||||
self.step("configuring httpd")
|
||||
http_txt = template_file(SHARE_DIR + "ipa.conf", self.sub_dict)
|
||||
http_txt = ipautil.template_file(ipautil.SHARE_DIR + "ipa.conf", self.sub_dict)
|
||||
http_fd = open("/etc/httpd/conf.d/ipa.conf", "w")
|
||||
http_fd.write(http_txt)
|
||||
http_fd.close()
|
||||
@ -147,7 +149,7 @@ class HTTPInstance(service.Service):
|
||||
ca.create_signing_cert("Signing-Cert", "cn=%s,ou=Signing Certificate,o=Identity Policy Audit" % self.fqdn, ds_ca)
|
||||
|
||||
def __setup_autoconfig(self):
|
||||
prefs_txt = template_file(SHARE_DIR + "preferences.html.template", self.sub_dict)
|
||||
prefs_txt = ipautil.template_file(ipautil.SHARE_DIR + "preferences.html.template", self.sub_dict)
|
||||
prefs_fd = open("/usr/share/ipa/html/preferences.html", "w")
|
||||
prefs_fd.write(prefs_txt)
|
||||
prefs_fd.close()
|
||||
|
@ -17,10 +17,10 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
from ipa.ipautil import *
|
||||
import shutil
|
||||
|
||||
import service
|
||||
from ipa import ipautil
|
||||
|
||||
class NTPInstance(service.Service):
|
||||
def __init__(self):
|
||||
@ -36,9 +36,9 @@ class NTPInstance(service.Service):
|
||||
# or fedora pools. Other distros should be added in the future
|
||||
# or we can get our own pool.
|
||||
os = ""
|
||||
if file_exists("/etc/fedora-release"):
|
||||
if ipautil.file_exists("/etc/fedora-release"):
|
||||
os = "fedora."
|
||||
elif file_exists("/etc/redhat-release"):
|
||||
elif ipautil.file_exists("/etc/redhat-release"):
|
||||
os = "rhel."
|
||||
|
||||
sub_dict = { }
|
||||
@ -46,7 +46,7 @@ class NTPInstance(service.Service):
|
||||
sub_dict["SERVERB"] = "1.%spool.ntp.org" % os
|
||||
sub_dict["SERVERC"] = "2.%spool.ntp.org" % os
|
||||
|
||||
ntp_conf = template_file(SHARE_DIR + "ntp.conf.server.template", sub_dict)
|
||||
ntp_conf = ipautil.template_file(ipautil.SHARE_DIR + "ntp.conf.server.template", sub_dict)
|
||||
|
||||
shutil.copy("/etc/ntp.conf", "/etc/ntp.conf.ipasave")
|
||||
|
||||
|
@ -17,24 +17,24 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
from ipa.ipautil import *
|
||||
import logging, sys
|
||||
from ipa import ipautil
|
||||
|
||||
|
||||
def stop(service_name):
|
||||
run(["/sbin/service", service_name, "stop"])
|
||||
ipautil.run(["/sbin/service", service_name, "stop"])
|
||||
|
||||
def start(service_name):
|
||||
run(["/sbin/service", service_name, "start"])
|
||||
ipautil.run(["/sbin/service", service_name, "start"])
|
||||
|
||||
def restart(service_name):
|
||||
run(["/sbin/service", service_name, "restart"])
|
||||
ipautil.run(["/sbin/service", service_name, "restart"])
|
||||
|
||||
def chkconfig_on(service_name):
|
||||
run(["/sbin/chkconfig", service_name, "on"])
|
||||
ipautil.run(["/sbin/chkconfig", service_name, "on"])
|
||||
|
||||
def chkconfig_off(service_name):
|
||||
run(["/sbin/chkconfig", service_name, "off"])
|
||||
ipautil.run(["/sbin/chkconfig", service_name, "off"])
|
||||
|
||||
def print_msg(message, output_fd=sys.stdout):
|
||||
logging.debug(message)
|
||||
|
@ -17,9 +17,6 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
import logging
|
||||
|
||||
from ipa.ipautil import *
|
||||
import service
|
||||
|
||||
class WebGuiInstance(service.Service):
|
||||
|
Loading…
Reference in New Issue
Block a user