mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Compatibility changes to work on RHEL 5 with python 2.4
This commit is contained in:
parent
b04bed4e82
commit
c32a960cae
@ -228,7 +228,7 @@ def main():
|
|||||||
# Set the User's password
|
# Set the User's password
|
||||||
if password is not None:
|
if password is not None:
|
||||||
try:
|
try:
|
||||||
client.modifyPassword(principal, None, password)
|
client.modifyPassword(principal, '', password)
|
||||||
except ipa.ipaerror.IPAError, e:
|
except ipa.ipaerror.IPAError, e:
|
||||||
print "User added but setting the password failed."
|
print "User added but setting the password failed."
|
||||||
print "%s" % (e.message)
|
print "%s" % (e.message)
|
||||||
|
@ -98,7 +98,7 @@ def main():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
client = ipaclient.IPAClient()
|
client = ipaclient.IPAClient()
|
||||||
client.modifyPassword(principal, None, password)
|
client.modifyPassword(principal, '', password)
|
||||||
except xmlrpclib.Fault, fault:
|
except xmlrpclib.Fault, fault:
|
||||||
if fault.faultCode == errno.ECONNREFUSED:
|
if fault.faultCode == errno.ECONNREFUSED:
|
||||||
print "The IPA XML-RPC service is not responding."
|
print "The IPA XML-RPC service is not responding."
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
AC_PREREQ(2.59c)
|
AC_PREREQ(2.59)
|
||||||
AC_INIT([ipa-client],
|
AC_INIT([ipa-client],
|
||||||
[0.5.0],
|
[0.5.0],
|
||||||
[https://hosted.fedoraproject.org/projects/freeipa/newticket])
|
[https://hosted.fedoraproject.org/projects/freeipa/newticket])
|
||||||
|
@ -33,6 +33,22 @@ from string import lower
|
|||||||
import re
|
import re
|
||||||
import xmlrpclib
|
import xmlrpclib
|
||||||
import datetime
|
import datetime
|
||||||
|
try:
|
||||||
|
from subprocess import CalledProcessError
|
||||||
|
class CalledProcessError(subprocess.CalledProcessError):
|
||||||
|
def __init__(self, returncode, cmd):
|
||||||
|
super(CalledProcessError, self).__init__(returncode, cmd)
|
||||||
|
except ImportError:
|
||||||
|
# Python 2.4 doesn't implement CalledProcessError
|
||||||
|
class CalledProcessError(Exception):
|
||||||
|
"""This exception is raised when a process run by check_call() returns
|
||||||
|
a non-zero exit status. The exit status will be stored in the
|
||||||
|
returncode attribute."""
|
||||||
|
def __init__(self, returncode, cmd):
|
||||||
|
self.returncode = returncode
|
||||||
|
self.cmd = cmd
|
||||||
|
def __str__(self):
|
||||||
|
return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode)
|
||||||
|
|
||||||
def realm_to_suffix(realm_name):
|
def realm_to_suffix(realm_name):
|
||||||
s = realm_name.split(".")
|
s = realm_name.split(".")
|
||||||
@ -63,7 +79,7 @@ def run(args, stdin=None):
|
|||||||
logging.info(stderr)
|
logging.info(stderr)
|
||||||
|
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
raise subprocess.CalledProcessError(p.returncode, ' '.join(args))
|
raise self.CalledProcessError(p.returncode, ' '.join(args))
|
||||||
|
|
||||||
def file_exists(filename):
|
def file_exists(filename):
|
||||||
try:
|
try:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
AC_PREREQ(2.59c)
|
AC_PREREQ(2.59)
|
||||||
AC_INIT([ipa-server],
|
AC_INIT([ipa-server],
|
||||||
[0.5],
|
[0.5],
|
||||||
[https://hosted.fedoraproject.org/projects/freeipa/newticket])
|
[https://hosted.fedoraproject.org/projects/freeipa/newticket])
|
||||||
|
@ -43,7 +43,7 @@ aci_checkbox_attrs = [(field.name, field.label) for field in aci_attrs]
|
|||||||
|
|
||||||
aci_name_to_label = dict(aci_checkbox_attrs)
|
aci_name_to_label = dict(aci_checkbox_attrs)
|
||||||
|
|
||||||
class DelegateFields():
|
class DelegateFields(object):
|
||||||
name = widgets.TextField(name="name", label="Delegation Name")
|
name = widgets.TextField(name="name", label="Delegation Name")
|
||||||
|
|
||||||
source_group_dn = widgets.HiddenField(name="source_group_dn")
|
source_group_dn = widgets.HiddenField(name="source_group_dn")
|
||||||
|
@ -2,7 +2,7 @@ import turbogears
|
|||||||
from turbogears import validators, widgets
|
from turbogears import validators, widgets
|
||||||
from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm
|
from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm
|
||||||
|
|
||||||
class GroupFields():
|
class GroupFields(object):
|
||||||
cn = widgets.TextField(name="cn", label="Name")
|
cn = widgets.TextField(name="cn", label="Name")
|
||||||
gidnumber = widgets.TextField(name="gidnumber", label="GID")
|
gidnumber = widgets.TextField(name="gidnumber", label="GID")
|
||||||
description = widgets.TextField(name="description", label="Description")
|
description = widgets.TextField(name="description", label="Description")
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import turbogears
|
import turbogears
|
||||||
from turbogears import validators, widgets
|
from turbogears import validators, widgets
|
||||||
|
|
||||||
class IPAPolicyFields():
|
class IPAPolicyFields(object):
|
||||||
# From cn=ipaConfig
|
# From cn=ipaConfig
|
||||||
ipausersearchfields = widgets.TextField(name="ipausersearchfields", label="User Search Fields")
|
ipausersearchfields = widgets.TextField(name="ipausersearchfields", label="User Search Fields", attrs=dict(size=50))
|
||||||
ipagroupsearchfields = widgets.TextField(name="ipagroupsearchfields", label="Group Search Fields")
|
ipagroupsearchfields = widgets.TextField(name="ipagroupsearchfields", label="Group Search Fields")
|
||||||
ipasearchtimelimit = widgets.TextField(name="ipasearchtimelimit", label="Search Time Limit (sec.)", attrs=dict(size=6,maxlength=6))
|
ipasearchtimelimit = widgets.TextField(name="ipasearchtimelimit", label="Search Time Limit (sec.)", attrs=dict(size=6,maxlength=6))
|
||||||
ipasearchrecordslimit = widgets.TextField(name="ipasearchrecordslimit", label="Search Records Limit", attrs=dict(size=6,maxlength=6))
|
ipasearchrecordslimit = widgets.TextField(name="ipasearchrecordslimit", label="Search Records Limit", attrs=dict(size=6,maxlength=6))
|
||||||
|
@ -2,7 +2,7 @@ import turbogears
|
|||||||
from turbogears import validators, widgets
|
from turbogears import validators, widgets
|
||||||
from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm
|
from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm
|
||||||
|
|
||||||
class UserFields():
|
class UserFields(object):
|
||||||
givenname = widgets.TextField(name="givenname", label="Given Name")
|
givenname = widgets.TextField(name="givenname", label="Given Name")
|
||||||
sn = widgets.TextField(name="sn", label="Family Name")
|
sn = widgets.TextField(name="sn", label="Family Name")
|
||||||
cn = widgets.TextField(name="cn", label="Common Names")
|
cn = widgets.TextField(name="cn", label="Common Names")
|
||||||
|
@ -29,7 +29,6 @@ import sys
|
|||||||
|
|
||||||
from ipa.ipautil import *
|
from ipa.ipautil import *
|
||||||
import service
|
import service
|
||||||
|
|
||||||
import installutils
|
import installutils
|
||||||
|
|
||||||
SERVER_ROOT_64 = "/usr/lib64/dirsrv"
|
SERVER_ROOT_64 = "/usr/lib64/dirsrv"
|
||||||
@ -188,7 +187,7 @@ class DsInstance(service.Service):
|
|||||||
try:
|
try:
|
||||||
run(args)
|
run(args)
|
||||||
logging.debug("done adding user")
|
logging.debug("done adding user")
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
logging.critical("failed to add user %s" % e)
|
logging.critical("failed to add user %s" % e)
|
||||||
|
|
||||||
def __create_instance(self):
|
def __create_instance(self):
|
||||||
@ -206,13 +205,13 @@ class DsInstance(service.Service):
|
|||||||
try:
|
try:
|
||||||
run(args)
|
run(args)
|
||||||
logging.debug("completed creating ds instance")
|
logging.debug("completed creating ds instance")
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
logging.critical("failed to restart ds instance %s" % e)
|
logging.critical("failed to restart ds instance %s" % e)
|
||||||
logging.debug("restarting ds instance")
|
logging.debug("restarting ds instance")
|
||||||
try:
|
try:
|
||||||
self.restart()
|
self.restart()
|
||||||
logging.debug("done restarting ds instance")
|
logging.debug("done restarting ds instance")
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
print "failed to restart ds instance", e
|
print "failed to restart ds instance", e
|
||||||
logging.debug("failed to restart ds instance %s" % e)
|
logging.debug("failed to restart ds instance %s" % e)
|
||||||
|
|
||||||
@ -233,7 +232,7 @@ class DsInstance(service.Service):
|
|||||||
memberof_fd = write_tmp_file(memberof_txt)
|
memberof_fd = write_tmp_file(memberof_txt)
|
||||||
try:
|
try:
|
||||||
ldap_mod(memberof_fd, "cn=Directory Manager", self.dm_password)
|
ldap_mod(memberof_fd, "cn=Directory Manager", self.dm_password)
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
logging.critical("Failed to load memberof-conf.ldif: %s" % str(e))
|
logging.critical("Failed to load memberof-conf.ldif: %s" % str(e))
|
||||||
memberof_fd.close()
|
memberof_fd.close()
|
||||||
|
|
||||||
@ -243,7 +242,7 @@ class DsInstance(service.Service):
|
|||||||
memberof_fd = write_tmp_file(memberof_txt)
|
memberof_fd = write_tmp_file(memberof_txt)
|
||||||
try:
|
try:
|
||||||
ldap_mod(memberof_fd, "cn=Directory Manager", self.dm_password)
|
ldap_mod(memberof_fd, "cn=Directory Manager", self.dm_password)
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
logging.critical("Failed to load memberof-conf.ldif: %s" % str(e))
|
logging.critical("Failed to load memberof-conf.ldif: %s" % str(e))
|
||||||
memberof_fd.close()
|
memberof_fd.close()
|
||||||
|
|
||||||
@ -253,7 +252,7 @@ class DsInstance(service.Service):
|
|||||||
referint_fd = write_tmp_file(referint_txt)
|
referint_fd = write_tmp_file(referint_txt)
|
||||||
try:
|
try:
|
||||||
ldap_mod(referint_fd, "cn=Directory Manager", self.dm_password)
|
ldap_mod(referint_fd, "cn=Directory Manager", self.dm_password)
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
print "Failed to load referint-conf.ldif", e
|
print "Failed to load referint-conf.ldif", e
|
||||||
referint_fd.close()
|
referint_fd.close()
|
||||||
|
|
||||||
@ -263,7 +262,7 @@ class DsInstance(service.Service):
|
|||||||
dna_fd = write_tmp_file(dna_txt)
|
dna_fd = write_tmp_file(dna_txt)
|
||||||
try:
|
try:
|
||||||
ldap_mod(dna_fd, "cn=Directory Manager", self.dm_password)
|
ldap_mod(dna_fd, "cn=Directory Manager", self.dm_password)
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
print "Failed to load dna-conf.ldif", e
|
print "Failed to load dna-conf.ldif", e
|
||||||
dna_fd.close()
|
dna_fd.close()
|
||||||
|
|
||||||
@ -273,7 +272,7 @@ class DsInstance(service.Service):
|
|||||||
dna_fd = write_tmp_file(dna_txt)
|
dna_fd = write_tmp_file(dna_txt)
|
||||||
try:
|
try:
|
||||||
ldap_mod(dna_fd, "cn=Directory Manager", self.dm_password)
|
ldap_mod(dna_fd, "cn=Directory Manager", self.dm_password)
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
print "Failed to configure Posix uid/gid generation with dna-posix.ldif", e
|
print "Failed to configure Posix uid/gid generation with dna-posix.ldif", e
|
||||||
dna_fd.close()
|
dna_fd.close()
|
||||||
|
|
||||||
@ -283,7 +282,7 @@ class DsInstance(service.Service):
|
|||||||
master_fd = write_tmp_file(master_txt)
|
master_fd = write_tmp_file(master_txt)
|
||||||
try:
|
try:
|
||||||
ldap_mod(master_fd, "cn=Directory Manager", self.dm_password)
|
ldap_mod(master_fd, "cn=Directory Manager", self.dm_password)
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
print "Failed to add master-entry.ldif", e
|
print "Failed to add master-entry.ldif", e
|
||||||
master_fd.close()
|
master_fd.close()
|
||||||
|
|
||||||
@ -295,7 +294,7 @@ class DsInstance(service.Service):
|
|||||||
try:
|
try:
|
||||||
run(args)
|
run(args)
|
||||||
logging.debug("done configuring ssl for ds instance")
|
logging.debug("done configuring ssl for ds instance")
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
logging.critical("Failed to configure ssl in ds instance %s" % e)
|
logging.critical("Failed to configure ssl in ds instance %s" % e)
|
||||||
|
|
||||||
def __add_default_layout(self):
|
def __add_default_layout(self):
|
||||||
@ -308,7 +307,7 @@ class DsInstance(service.Service):
|
|||||||
try:
|
try:
|
||||||
run(args)
|
run(args)
|
||||||
logging.debug("done adding default ds layout")
|
logging.debug("done adding default ds layout")
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
print "Failed to add default ds layout", e
|
print "Failed to add default ds layout", e
|
||||||
logging.critical("Failed to add default ds layout %s" % e)
|
logging.critical("Failed to add default ds layout %s" % e)
|
||||||
|
|
||||||
@ -322,7 +321,7 @@ class DsInstance(service.Service):
|
|||||||
try:
|
try:
|
||||||
run(args)
|
run(args)
|
||||||
logging.debug("done adding/updating indeces")
|
logging.debug("done adding/updating indeces")
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
logging.critical("Failed to add/update indeces %s" % str(e))
|
logging.critical("Failed to add/update indeces %s" % str(e))
|
||||||
|
|
||||||
def __certmap_conf(self):
|
def __certmap_conf(self):
|
||||||
@ -347,7 +346,7 @@ class DsInstance(service.Service):
|
|||||||
try:
|
try:
|
||||||
run(args)
|
run(args)
|
||||||
logging.debug("ldappasswd done")
|
logging.debug("ldappasswd done")
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
print "Unable to set admin password", e
|
print "Unable to set admin password", e
|
||||||
logging.debug("Unable to set admin password %s" % e)
|
logging.debug("Unable to set admin password %s" % e)
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ class HTTPInstance(service.Service):
|
|||||||
if (os.path.exists('/usr/sbin/selinuxenabled')):
|
if (os.path.exists('/usr/sbin/selinuxenabled')):
|
||||||
run(["/usr/sbin/selinuxenabled"])
|
run(["/usr/sbin/selinuxenabled"])
|
||||||
selinux=1
|
selinux=1
|
||||||
except subprocess.CalledProcessError:
|
except ipautil.CalledProcessError:
|
||||||
# selinuxenabled returns 1 if not enabled
|
# selinuxenabled returns 1 if not enabled
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ import time
|
|||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
import service
|
import service
|
||||||
from ipa.ipautil import *
|
|
||||||
from ipa import ipaerror
|
from ipa import ipaerror
|
||||||
|
|
||||||
import ipaldap
|
import ipaldap
|
||||||
@ -47,6 +46,7 @@ import pyasn1.codec.ber.encoder
|
|||||||
import pyasn1.codec.ber.decoder
|
import pyasn1.codec.ber.decoder
|
||||||
import struct
|
import struct
|
||||||
import base64
|
import base64
|
||||||
|
from ipa.ipautil import *
|
||||||
|
|
||||||
def host_to_domain(fqdn):
|
def host_to_domain(fqdn):
|
||||||
s = fqdn.split(".")
|
s = fqdn.split(".")
|
||||||
@ -245,7 +245,7 @@ class KrbInstance(service.Service):
|
|||||||
kerberos_fd = write_tmp_file(kerberos_txt)
|
kerberos_fd = write_tmp_file(kerberos_txt)
|
||||||
try:
|
try:
|
||||||
ldap_mod(kerberos_fd, "cn=Directory Manager", self.admin_password)
|
ldap_mod(kerberos_fd, "cn=Directory Manager", self.admin_password)
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
logging.critical("Failed to load kerberos.ldif: %s" % str(e))
|
logging.critical("Failed to load kerberos.ldif: %s" % str(e))
|
||||||
kerberos_fd.close()
|
kerberos_fd.close()
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ class KrbInstance(service.Service):
|
|||||||
aci_fd = write_tmp_file(aci_txt)
|
aci_fd = write_tmp_file(aci_txt)
|
||||||
try:
|
try:
|
||||||
ldap_mod(aci_fd, "cn=Directory Manager", self.admin_password)
|
ldap_mod(aci_fd, "cn=Directory Manager", self.admin_password)
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
logging.critical("Failed to load default-aci.ldif: %s" % str(e))
|
logging.critical("Failed to load default-aci.ldif: %s" % str(e))
|
||||||
aci_fd.close()
|
aci_fd.close()
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ class KrbInstance(service.Service):
|
|||||||
args = ["/usr/kerberos/sbin/kdb5_ldap_util", "-D", "uid=kdc,cn=sysaccounts,cn=etc,"+self.suffix, "-w", self.kdc_password, "create", "-s", "-P", self.master_password, "-r", self.realm, "-subtrees", self.suffix, "-sscope", "sub"]
|
args = ["/usr/kerberos/sbin/kdb5_ldap_util", "-D", "uid=kdc,cn=sysaccounts,cn=etc,"+self.suffix, "-w", self.kdc_password, "create", "-s", "-P", self.master_password, "-r", self.realm, "-subtrees", self.suffix, "-sscope", "sub"]
|
||||||
try:
|
try:
|
||||||
run(args)
|
run(args)
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
print "Failed to populate the realm structure in kerberos", e
|
print "Failed to populate the realm structure in kerberos", e
|
||||||
|
|
||||||
def __write_stash_from_ds(self):
|
def __write_stash_from_ds(self):
|
||||||
@ -322,7 +322,7 @@ class KrbInstance(service.Service):
|
|||||||
extop_fd = write_tmp_file(extop_txt)
|
extop_fd = write_tmp_file(extop_txt)
|
||||||
try:
|
try:
|
||||||
ldap_mod(extop_fd, "cn=Directory Manager", self.admin_password)
|
ldap_mod(extop_fd, "cn=Directory Manager", self.admin_password)
|
||||||
except subprocess.CalledProcessError, e:
|
except ipautil.CalledProcessError, e:
|
||||||
logging.critical("Failed to load pwd-extop-conf.ldif: %s" % str(e))
|
logging.critical("Failed to load pwd-extop-conf.ldif: %s" % str(e))
|
||||||
extop_fd.close()
|
extop_fd.close()
|
||||||
|
|
||||||
|
@ -1270,11 +1270,12 @@ class IPAServer:
|
|||||||
|
|
||||||
conn = self.getConnection(opts)
|
conn = self.getConnection(opts)
|
||||||
try:
|
try:
|
||||||
results = conn.getListAsync(self.basedn, self.scope,
|
try:
|
||||||
filter, attr_list, 0, None, None, timelimit,
|
results = conn.getListAsync(self.basedn, self.scope,
|
||||||
searchlimit)
|
filter, attr_list, 0, None, None, timelimit,
|
||||||
except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
|
searchlimit)
|
||||||
results = [0]
|
except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
|
||||||
|
results = [0]
|
||||||
finally:
|
finally:
|
||||||
self.releaseConnection(conn)
|
self.releaseConnection(conn)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user