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
|
||||
if password is not None:
|
||||
try:
|
||||
client.modifyPassword(principal, None, password)
|
||||
client.modifyPassword(principal, '', password)
|
||||
except ipa.ipaerror.IPAError, e:
|
||||
print "User added but setting the password failed."
|
||||
print "%s" % (e.message)
|
||||
|
@ -98,7 +98,7 @@ def main():
|
||||
|
||||
try:
|
||||
client = ipaclient.IPAClient()
|
||||
client.modifyPassword(principal, None, password)
|
||||
client.modifyPassword(principal, '', password)
|
||||
except xmlrpclib.Fault, fault:
|
||||
if fault.faultCode == errno.ECONNREFUSED:
|
||||
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],
|
||||
[0.5.0],
|
||||
[https://hosted.fedoraproject.org/projects/freeipa/newticket])
|
||||
|
@ -33,6 +33,22 @@ from string import lower
|
||||
import re
|
||||
import xmlrpclib
|
||||
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):
|
||||
s = realm_name.split(".")
|
||||
@ -63,7 +79,7 @@ def run(args, stdin=None):
|
||||
logging.info(stderr)
|
||||
|
||||
if p.returncode != 0:
|
||||
raise subprocess.CalledProcessError(p.returncode, ' '.join(args))
|
||||
raise self.CalledProcessError(p.returncode, ' '.join(args))
|
||||
|
||||
def file_exists(filename):
|
||||
try:
|
||||
|
@ -1,4 +1,4 @@
|
||||
AC_PREREQ(2.59c)
|
||||
AC_PREREQ(2.59)
|
||||
AC_INIT([ipa-server],
|
||||
[0.5],
|
||||
[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)
|
||||
|
||||
class DelegateFields():
|
||||
class DelegateFields(object):
|
||||
name = widgets.TextField(name="name", label="Delegation Name")
|
||||
|
||||
source_group_dn = widgets.HiddenField(name="source_group_dn")
|
||||
|
@ -2,7 +2,7 @@ import turbogears
|
||||
from turbogears import validators, widgets
|
||||
from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm
|
||||
|
||||
class GroupFields():
|
||||
class GroupFields(object):
|
||||
cn = widgets.TextField(name="cn", label="Name")
|
||||
gidnumber = widgets.TextField(name="gidnumber", label="GID")
|
||||
description = widgets.TextField(name="description", label="Description")
|
||||
|
@ -1,9 +1,9 @@
|
||||
import turbogears
|
||||
from turbogears import validators, widgets
|
||||
|
||||
class IPAPolicyFields():
|
||||
class IPAPolicyFields(object):
|
||||
# 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")
|
||||
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))
|
||||
|
@ -2,7 +2,7 @@ import turbogears
|
||||
from turbogears import validators, widgets
|
||||
from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm
|
||||
|
||||
class UserFields():
|
||||
class UserFields(object):
|
||||
givenname = widgets.TextField(name="givenname", label="Given Name")
|
||||
sn = widgets.TextField(name="sn", label="Family Name")
|
||||
cn = widgets.TextField(name="cn", label="Common Names")
|
||||
|
@ -29,7 +29,6 @@ import sys
|
||||
|
||||
from ipa.ipautil import *
|
||||
import service
|
||||
|
||||
import installutils
|
||||
|
||||
SERVER_ROOT_64 = "/usr/lib64/dirsrv"
|
||||
@ -188,7 +187,7 @@ class DsInstance(service.Service):
|
||||
try:
|
||||
run(args)
|
||||
logging.debug("done adding user")
|
||||
except subprocess.CalledProcessError, e:
|
||||
except ipautil.CalledProcessError, e:
|
||||
logging.critical("failed to add user %s" % e)
|
||||
|
||||
def __create_instance(self):
|
||||
@ -206,13 +205,13 @@ class DsInstance(service.Service):
|
||||
try:
|
||||
run(args)
|
||||
logging.debug("completed creating ds instance")
|
||||
except subprocess.CalledProcessError, e:
|
||||
except ipautil.CalledProcessError, e:
|
||||
logging.critical("failed to restart ds instance %s" % e)
|
||||
logging.debug("restarting ds instance")
|
||||
try:
|
||||
self.restart()
|
||||
logging.debug("done restarting ds instance")
|
||||
except subprocess.CalledProcessError, e:
|
||||
except ipautil.CalledProcessError, e:
|
||||
print "failed to restart ds instance", 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)
|
||||
try:
|
||||
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))
|
||||
memberof_fd.close()
|
||||
|
||||
@ -243,7 +242,7 @@ class DsInstance(service.Service):
|
||||
memberof_fd = write_tmp_file(memberof_txt)
|
||||
try:
|
||||
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))
|
||||
memberof_fd.close()
|
||||
|
||||
@ -253,7 +252,7 @@ class DsInstance(service.Service):
|
||||
referint_fd = write_tmp_file(referint_txt)
|
||||
try:
|
||||
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
|
||||
referint_fd.close()
|
||||
|
||||
@ -263,7 +262,7 @@ class DsInstance(service.Service):
|
||||
dna_fd = write_tmp_file(dna_txt)
|
||||
try:
|
||||
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
|
||||
dna_fd.close()
|
||||
|
||||
@ -273,7 +272,7 @@ class DsInstance(service.Service):
|
||||
dna_fd = write_tmp_file(dna_txt)
|
||||
try:
|
||||
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
|
||||
dna_fd.close()
|
||||
|
||||
@ -283,7 +282,7 @@ class DsInstance(service.Service):
|
||||
master_fd = write_tmp_file(master_txt)
|
||||
try:
|
||||
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
|
||||
master_fd.close()
|
||||
|
||||
@ -295,7 +294,7 @@ class DsInstance(service.Service):
|
||||
try:
|
||||
run(args)
|
||||
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)
|
||||
|
||||
def __add_default_layout(self):
|
||||
@ -308,7 +307,7 @@ class DsInstance(service.Service):
|
||||
try:
|
||||
run(args)
|
||||
logging.debug("done adding default ds layout")
|
||||
except subprocess.CalledProcessError, e:
|
||||
except ipautil.CalledProcessError, e:
|
||||
print "Failed to add default ds layout", e
|
||||
logging.critical("Failed to add default ds layout %s" % e)
|
||||
|
||||
@ -322,7 +321,7 @@ class DsInstance(service.Service):
|
||||
try:
|
||||
run(args)
|
||||
logging.debug("done adding/updating indeces")
|
||||
except subprocess.CalledProcessError, e:
|
||||
except ipautil.CalledProcessError, e:
|
||||
logging.critical("Failed to add/update indeces %s" % str(e))
|
||||
|
||||
def __certmap_conf(self):
|
||||
@ -347,7 +346,7 @@ class DsInstance(service.Service):
|
||||
try:
|
||||
run(args)
|
||||
logging.debug("ldappasswd done")
|
||||
except subprocess.CalledProcessError, e:
|
||||
except ipautil.CalledProcessError, e:
|
||||
print "Unable to set admin password", 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')):
|
||||
run(["/usr/sbin/selinuxenabled"])
|
||||
selinux=1
|
||||
except subprocess.CalledProcessError:
|
||||
except ipautil.CalledProcessError:
|
||||
# selinuxenabled returns 1 if not enabled
|
||||
pass
|
||||
|
||||
|
@ -33,7 +33,6 @@ import time
|
||||
import shutil
|
||||
|
||||
import service
|
||||
from ipa.ipautil import *
|
||||
from ipa import ipaerror
|
||||
|
||||
import ipaldap
|
||||
@ -47,6 +46,7 @@ import pyasn1.codec.ber.encoder
|
||||
import pyasn1.codec.ber.decoder
|
||||
import struct
|
||||
import base64
|
||||
from ipa.ipautil import *
|
||||
|
||||
def host_to_domain(fqdn):
|
||||
s = fqdn.split(".")
|
||||
@ -245,7 +245,7 @@ class KrbInstance(service.Service):
|
||||
kerberos_fd = write_tmp_file(kerberos_txt)
|
||||
try:
|
||||
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))
|
||||
kerberos_fd.close()
|
||||
|
||||
@ -254,7 +254,7 @@ class KrbInstance(service.Service):
|
||||
aci_fd = write_tmp_file(aci_txt)
|
||||
try:
|
||||
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))
|
||||
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"]
|
||||
try:
|
||||
run(args)
|
||||
except subprocess.CalledProcessError, e:
|
||||
except ipautil.CalledProcessError, e:
|
||||
print "Failed to populate the realm structure in kerberos", e
|
||||
|
||||
def __write_stash_from_ds(self):
|
||||
@ -322,7 +322,7 @@ class KrbInstance(service.Service):
|
||||
extop_fd = write_tmp_file(extop_txt)
|
||||
try:
|
||||
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))
|
||||
extop_fd.close()
|
||||
|
||||
|
@ -1270,11 +1270,12 @@ class IPAServer:
|
||||
|
||||
conn = self.getConnection(opts)
|
||||
try:
|
||||
results = conn.getListAsync(self.basedn, self.scope,
|
||||
filter, attr_list, 0, None, None, timelimit,
|
||||
searchlimit)
|
||||
except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
|
||||
results = [0]
|
||||
try:
|
||||
results = conn.getListAsync(self.basedn, self.scope,
|
||||
filter, attr_list, 0, None, None, timelimit,
|
||||
searchlimit)
|
||||
except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
|
||||
results = [0]
|
||||
finally:
|
||||
self.releaseConnection(conn)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user