From 39dcd194ca6e2b677aa1f4726bf1a60016b20a67 Mon Sep 17 00:00:00 2001
From: Karl MacMillan
Date: Tue, 13 Nov 2007 13:10:27 -0500
Subject: [PATCH 01/60] Allow setting of lib directory to correct non-rpm
builds on x86_64.
With this patch you will need to run:
make autogen LIBDIR=/usr/lib64
Also works for 'make all'.
---
Makefile | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index dac507949..cf919fda9 100644
--- a/Makefile
+++ b/Makefile
@@ -35,18 +35,20 @@ CLI_VERSION=$(CLI_MAJOR).$(CLI_MINOR).$(CLI_RELEASE)
CLI_TARBALL_PREFIX=$(PRJ_PREFIX)-client-$(CLI_VERSION)
CLI_TARBALL=$(CLI_TARBALL_PREFIX).tgz
+LIBDIR ?= /usr/lib
+
all: bootstrap-autogen
@for subdir in $(SUBDIRS); do \
(cd $$subdir && $(MAKE) $@) || exit 1; \
done
bootstrap-autogen:
- cd ipa-server; if [ ! -e Makefile ]; then ./autogen.sh --prefix=/usr --sysconfdir=/etc; fi
- cd ipa-client; if [ ! -e Makefile ]; then ./autogen.sh --prefix=/usr --sysconfdir=/etc; fi
+ cd ipa-server; if [ ! -e Makefile ]; then ./autogen.sh --prefix=/usr --sysconfdir=/etc --libdir=$(LIBDIR); fi
+ cd ipa-client; if [ ! -e Makefile ]; then ./autogen.sh --prefix=/usr --sysconfdir=/etc --libdir=$(LIBDIR); fi
autogen:
- cd ipa-server; ./autogen.sh --prefix=/usr --sysconfdir=/etc;
- cd ipa-client; ./autogen.sh --prefix=/usr --sysconfdir=/etc;
+ cd ipa-server; ./autogen.sh --prefix=/usr --sysconfdir=/etc --libdir=$(LIBDIR)
+ cd ipa-client; ./autogen.sh --prefix=/usr --sysconfdir=/etc --libdir=$(LIBDIR)
configure:
cd ipa-server; ./configure --prefix=/usr --sysconfdir=/etc
From e9dfbfa773149c57544e5c8e4d87a00fc9960bf1 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Thu, 8 Nov 2007 22:12:42 -0500
Subject: [PATCH 02/60] Enable multi-value field support for some attributes on
the edit pages Better error reporting in the GUI Include a document
describing how multi-valued fields work
---
ipa-python/ipaerror.py | 5 +
ipa-server/ipa-gui/README.multivalue | 27 +++
ipa-server/ipa-gui/ipagui/forms/group.py | 3 +
ipa-server/ipa-gui/ipagui/forms/user.py | 8 +
.../ipa-gui/ipagui/subcontrollers/group.py | 49 +++-
.../ipa-gui/ipagui/subcontrollers/user.py | 87 ++++++-
.../ipagui/templates/groupeditform.kid | 34 ++-
.../ipa-gui/ipagui/templates/groupshow.kid | 20 +-
.../ipa-gui/ipagui/templates/usereditform.kid | 217 ++++++++++++++----
.../ipa-gui/ipagui/templates/usernewform.kid | 2 +
.../ipa-gui/ipagui/templates/usershow.kid | 96 +++++++-
11 files changed, 473 insertions(+), 75 deletions(-)
create mode 100644 ipa-server/ipa-gui/README.multivalue
diff --git a/ipa-python/ipaerror.py b/ipa-python/ipaerror.py
index 0106132ca..b10a9a8fc 100644
--- a/ipa-python/ipaerror.py
+++ b/ipa-python/ipaerror.py
@@ -28,6 +28,11 @@ class IPAError(exceptions.Exception):
error."""
self.code = code
self.message = message
+ # Fill this in as an empty LDAP error message so we don't have a lot
+ # of "if e.detail ..." everywhere
+ if detail is None:
+ detail = []
+ detail.append({'desc':'','info':''})
self.detail = detail
def __str__(self):
diff --git a/ipa-server/ipa-gui/README.multivalue b/ipa-server/ipa-gui/README.multivalue
new file mode 100644
index 000000000..ba315181d
--- /dev/null
+++ b/ipa-server/ipa-gui/README.multivalue
@@ -0,0 +1,27 @@
+The way multi-valued fields work is this:
+ - A new widget is added to the form. I name it as the attribute + s.
+ For example, I use cns for the cn attribute.
+ - If you need a new validator use a ForEach() so that each value is
+ checked.
+ - This attribute is populated from the incoming attribute from the
+ user or group record. The widget can support multiple fields at once
+ but I'm using it for just one field. In fact, I don't know if it
+ will work with more the way I'm using it.
+ - In the GUI an operator can add/remove values to each multi-valued field.
+ - Naming is very important in the widget. TurboGears automatically
+ re-assembles the data into a list of dict entries if you name things
+ properly. For example, the cns (multiple CN entries) looks like:
+ cns-0.cn=Rob+Crittenden&cns-1.cn=Robert+Crittenden&cns-2.cn=rcrit
+ - This gets converted to:
+ [{'cn': u'Rob Crittenden'}, {'cn': u'Robert Crittenden'}, {'cn': u'rcrit'}]
+ - I take this list of dicts and pull out each value and append it to a new
+ list that represents the original multi-valued field
+ - Then the list/dict version is removed (in this case, kw['cns']).
+
+When adding a new field you have to update:
+
+1. The form to add the new ExpandingForm() field and perhaps a validator
+2. The edit template to add the boilerplate to display the field
+3. The show template to be able to display all the fields separately
+4. The new template if you want to be able to enter these on new entries
+5. The subcontroller so you can do the input and output conversions
diff --git a/ipa-server/ipa-gui/ipagui/forms/group.py b/ipa-server/ipa-gui/ipagui/forms/group.py
index 380c904a4..f9ae5e5ea 100644
--- a/ipa-server/ipa-gui/ipagui/forms/group.py
+++ b/ipa-server/ipa-gui/ipagui/forms/group.py
@@ -1,8 +1,10 @@
import turbogears
from turbogears import validators, widgets
+from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm
class GroupFields():
cn = widgets.TextField(name="cn", label="Name")
+ cns = ExpandingForm(name="cns", label="Common Names", fields=[cn])
gidnumber = widgets.TextField(name="gidnumber", label="GID")
description = widgets.TextField(name="description", label="Description")
@@ -37,6 +39,7 @@ class GroupNewForm(widgets.Form):
class GroupEditValidator(validators.Schema):
+ cn = validators.ForEach(validators.String(not_empty=True))
gidnumber = validators.Int(not_empty=False)
description = validators.String(not_empty=False)
diff --git a/ipa-server/ipa-gui/ipagui/forms/user.py b/ipa-server/ipa-gui/ipagui/forms/user.py
index 1a35b4e07..b426f8e91 100644
--- a/ipa-server/ipa-gui/ipagui/forms/user.py
+++ b/ipa-server/ipa-gui/ipagui/forms/user.py
@@ -1,10 +1,12 @@
import turbogears
from turbogears import validators, widgets
+from tg_expanding_form_widget.tg_expanding_form_widget import ExpandingForm
class UserFields():
givenname = widgets.TextField(name="givenname", label="Given Name")
sn = widgets.TextField(name="sn", label="Family Name")
cn = widgets.TextField(name="cn", label="Common Names")
+ cns = ExpandingForm(name="cns", label="Common Names", fields=[cn])
title = widgets.TextField(name="title", label="Title")
displayname = widgets.TextField(name="displayname", label="Display Name")
initials = widgets.TextField(name="initials", label="Initials")
@@ -21,11 +23,16 @@ class UserFields():
mail = widgets.TextField(name="mail", label="E-mail Address")
telephonenumber = widgets.TextField(name="telephonenumber", label="Work Number")
+ telephonenumbers = ExpandingForm(name="telephonenumbers", label="Work Numbers", fields=[telephonenumber])
facsimiletelephonenumber = widgets.TextField(name="facsimiletelephonenumber",
label="Fax Number")
+ facsimiletelephonenumbers = ExpandingForm(name="facsimiletelephonenumbers", label="Fax Numbers", fields=[facsimiletelephonenumber])
mobile = widgets.TextField(name="mobile", label="Cell Number")
+ mobiles = ExpandingForm(name="mobiles", label="Cell Numbers", fields=[mobile])
pager = widgets.TextField(name="pager", label="Pager Number")
+ pagers = ExpandingForm(name="pagers", label="Pager Numbers", fields=[pager])
homephone = widgets.TextField(name="homephone", label="Home Number")
+ homephones = ExpandingForm(name="homephones", label="Home Numbers", fields=[homephone])
street = widgets.TextField(name="street", label="Street Address")
l = widgets.TextField(name="l", label="City")
@@ -102,6 +109,7 @@ class UserEditValidator(validators.Schema):
userpassword_confirm = validators.String(not_empty=False)
givenname = validators.String(not_empty=True)
sn = validators.String(not_empty=True)
+ cn = validators.ForEach(validators.String(not_empty=True))
mail = validators.Email(not_empty=True)
uidnumber = validators.Int(not_empty=False)
gidnumber = validators.Int(not_empty=False)
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/group.py b/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
index f0574a21c..8ea87641e 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
@@ -90,7 +90,7 @@ class GroupController(IPAController):
# on any error, we redirect to the _edit_ group page.
# this code does data setup, similar to groupedit()
#
- group = client.get_entry_by_cn(kw['cn'], group_fields)
+ group = client.get_entry_by_cn(kw['cn'][0], group_fields)
group_dict = group.toDict()
member_dicts = []
@@ -180,6 +180,14 @@ class GroupController(IPAController):
group_dict = group.toDict()
+ # Load potential multi-valued fields
+ if isinstance(group_dict['cn'], str):
+ group_dict['cn'] = [group_dict['cn']]
+ cns = []
+ for cn in group_dict['cn']:
+ cns.append(dict(cn=cn))
+ group_dict['cns'] = cns
+
#
# convert members to users, for easier manipulation on the page
#
@@ -210,14 +218,19 @@ class GroupController(IPAController):
self.restrict_post()
client = self.get_ipaclient()
+ # Fix incoming multi-valued form fields
+ kw['cn'] = []
+ for i in range(len(kw['cns'])):
+ kw['cn'].append(kw['cns'][i]['cn'])
+ del(kw['cns'])
+
if kw.get('submit') == 'Cancel Edit':
turbogears.flash("Edit group cancelled")
- raise turbogears.redirect('/group/show', cn=kw.get('cn'))
+ raise turbogears.redirect('/group/show', cn=kw.get('cn')[0])
# Decode the member data, in case we need to round trip
member_dicts = loads(b64decode(kw.get('member_data')))
-
tg_errors, kw = self.groupupdatevalidate(**kw)
if tg_errors:
turbogears.flash("There were validation errors. " +
@@ -233,6 +246,9 @@ class GroupController(IPAController):
try:
orig_group_dict = loads(b64decode(kw.get('group_orig')))
+ # remove multi-valued form fields
+ del(orig_group_dict['cns'])
+
new_group = ipa.group.Group(orig_group_dict)
if new_group.description != kw.get('description'):
group_modified = True
@@ -243,6 +259,14 @@ class GroupController(IPAController):
group_modified = True
new_group.setValue('gidnumber', new_gid)
+ # Did any cn entries change?
+ oldcn = new_group.getValues('cn')
+ if isinstance(oldcn, str):
+ oldcn = [oldcn]
+ if oldcn != kw['cn']:
+ group_modified = True
+ new_group.setValue('cn', kw['cn'])
+
if group_modified:
rv = client.update_group(new_group)
#
@@ -252,7 +276,7 @@ class GroupController(IPAController):
#
kw['group_orig'] = b64encode(dumps(new_group.toDict()))
except ipaerror.IPAError, e:
- turbogears.flash("Group update failed: " + str(e))
+ turbogears.flash("Group update failed: " + str(e) + " " + e.detail[0]['desc'])
return dict(form=group_edit_form, group=kw, members=member_dicts,
tg_template='ipagui.templates.groupedit')
@@ -268,8 +292,9 @@ class GroupController(IPAController):
failed_adds = client.add_members_to_group(
utf8_encode_values(dnadds), new_group.dn)
kw['dnadd'] = failed_adds
+ group_modified = True
except ipaerror.IPAError, e:
- turbogears.flash("Group update failed: " + str(e))
+ turbogears.flash("Group update failed: " + str(e) + " " + e.detail[0]['desc'])
return dict(form=group_edit_form, group=kw, members=member_dicts,
tg_template='ipagui.templates.groupedit')
@@ -285,8 +310,9 @@ class GroupController(IPAController):
failed_dels = client.remove_members_from_group(
utf8_encode_values(dndels), new_group.dn)
kw['dndel'] = failed_dels
+ group_modified = True
except ipaerror.IPAError, e:
- turbogears.flash("Group update failed: " + str(e))
+ turbogears.flash("Group update failed: " + str(e) + " " + e.detail[0]['desc'])
return dict(form=group_edit_form, group=kw, members=member_dicts,
tg_template='ipagui.templates.groupedit')
@@ -308,8 +334,11 @@ class GroupController(IPAController):
return dict(form=group_edit_form, group=kw, members=member_dicts,
tg_template='ipagui.templates.groupedit')
- turbogears.flash("%s updated!" % kw['cn'])
- raise turbogears.redirect('/group/show', cn=kw['cn'])
+ if group_modified == True:
+ turbogears.flash("%s updated!" % kw['cn'][0])
+ else:
+ turbogears.flash("No modifications requested.")
+ raise turbogears.redirect('/group/show', cn=kw['cn'][0])
@expose("ipagui.templates.grouplist")
@@ -330,7 +359,7 @@ class GroupController(IPAController):
turbogears.flash("These results are truncated. " +
"Please refine your search and try again.")
except ipaerror.IPAError, e:
- turbogears.flash("Find groups failed: " + str(e))
+ turbogears.flash("Find groups failed: " + str(e) + " " + e.detail[0]['desc'])
raise turbogears.redirect("/group/list")
return dict(groups=groups, criteria=criteria,
@@ -358,7 +387,7 @@ class GroupController(IPAController):
return dict(group=group_dict, fields=ipagui.forms.group.GroupFields(),
members = member_dicts)
except ipaerror.IPAError, e:
- turbogears.flash("Group show failed: " + str(e))
+ turbogears.flash("Group show failed: " + str(e) + " " + e.detail[0]['desc'])
raise turbogears.redirect("/")
@expose()
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
index d328052b1..a33307ae6 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
@@ -61,6 +61,35 @@ class UserController(IPAController):
user_new_form.validator.add_field(s['field'], validator)
user_edit_form.validator.add_field(s['field'], validator)
+ def setup_mv_fields(self, field, fieldname):
+ """Given a field (must be a list) and field name, convert that
+ field into a list of dictionaries of the form:
+ [ { fieldname : v1}, { fieldname : v2 }, .. ]
+
+ This is how we pre-fill values for multi-valued fields.
+ """
+ mvlist = []
+ if field is not None:
+ for v in field:
+ mvlist.append({ fieldname : v } )
+ else:
+ # We need to return an empty value so something can be
+ # displayed on the edit page. Otherwise only an Add link
+ # will show, not an empty field.
+ mvlist.append({ fieldname : '' } )
+ return mvlist
+
+ def fix_incoming_fields(self, fields, fieldname, multifieldname):
+ """This is called by the update() function. It takes the incoming
+ list of dictionaries and converts it into back into the original
+ field, then removes the multiple field.
+ """
+ fields[fieldname] = []
+ for i in range(len(fields[multifieldname])):
+ fields[fieldname].append(fields[multifieldname][i][fieldname])
+ del(fields[multifieldname])
+
+ return fields
@expose()
def index(self):
@@ -150,7 +179,7 @@ class UserController(IPAController):
return dict(form=user_new_form, user=kw,
tg_template='ipagui.templates.usernew')
except ipaerror.IPAError, e:
- turbogears.flash("User add failed: " + str(e))
+ turbogears.flash("User add failed: " + str(e) + " " + e.detail[0]['desc'])
return dict(form=user_new_form, user=kw,
tg_template='ipagui.templates.usernew')
@@ -259,6 +288,32 @@ class UserController(IPAController):
turbogears.flash("User edit failed: No uid or principal provided")
raise turbogears.redirect('/')
user_dict = user.toDict()
+
+ # Load potential multi-valued fields
+ if isinstance(user_dict['cn'], str):
+ user_dict['cn'] = [user_dict['cn']]
+ user_dict['cns'] = self.setup_mv_fields(user_dict['cn'], 'cn')
+
+ if isinstance(user_dict.get('telephonenumber',''), str):
+ user_dict['telephonenumber'] = [user_dict.get('telephonenumber'),'']
+ user_dict['telephonenumbers'] = self.setup_mv_fields(user_dict.get('telephonenumber'), 'telephonenumber')
+
+ if isinstance(user_dict.get('facsimiletelephonenumber',''), str):
+ user_dict['facsimiletelephonenumber'] = [user_dict.get('facsimiletelephonenumber'),'']
+ user_dict['facsimiletelephonenumbers'] = self.setup_mv_fields(user_dict.get('facsimiletelephonenumber'), 'facsimiletelephonenumber')
+
+ if isinstance(user_dict.get('mobile',''), str):
+ user_dict['mobile'] = [user_dict.get('mobile'),'']
+ user_dict['mobiles'] = self.setup_mv_fields(user_dict.get('mobile'), 'mobile')
+
+ if isinstance(user_dict.get('pager',''), str):
+ user_dict['pager'] = [user_dict.get('pager'),'']
+ user_dict['pagers'] = self.setup_mv_fields(user_dict.get('pager'), 'pager')
+
+ if isinstance(user_dict.get('homephone',''), str):
+ user_dict['homephone'] = [user_dict.get('homephone'),'']
+ user_dict['homephones'] = self.setup_mv_fields(user_dict.get('homephone'), 'homephone')
+
# Edit shouldn't fill in the password field.
if user_dict.has_key('userpassword'):
del(user_dict['userpassword'])
@@ -300,7 +355,7 @@ class UserController(IPAController):
except ipaerror.IPAError, e:
if uid is None:
uid = principal
- turbogears.flash("User edit failed: " + str(e))
+ turbogears.flash("User edit failed: " + str(e) + " " + e.detail[0]['desc'])
raise turbogears.redirect('/user/show', uid=uid)
@expose()
@@ -314,6 +369,14 @@ class UserController(IPAController):
turbogears.flash("Edit user cancelled")
raise turbogears.redirect('/user/show', uid=kw.get('uid'))
+ # Fix incoming multi-valued fields we created for the form
+ kw = self.fix_incoming_fields(kw, 'cn', 'cns')
+ kw = self.fix_incoming_fields(kw, 'telephonenumber', 'telephonenumbers')
+ kw = self.fix_incoming_fields(kw, 'facsimiletelephonenumber', 'facsimiletelephonenumbers')
+ kw = self.fix_incoming_fields(kw, 'mobile', 'mobiles')
+ kw = self.fix_incoming_fields(kw, 'pager', 'pagers')
+ kw = self.fix_incoming_fields(kw, 'homephone', 'homephones')
+
# Decode the group data, in case we need to round trip
user_groups_dicts = loads(b64decode(kw.get('user_groups_data')))
@@ -334,6 +397,14 @@ class UserController(IPAController):
try:
orig_user_dict = loads(b64decode(kw.get('user_orig')))
+ # remove multi-valued fields we created for the form
+ del(orig_user_dict['cns'])
+ del(orig_user_dict['telephonenumbers'])
+ del(orig_user_dict['facsimiletelephonenumbers'])
+ del(orig_user_dict['mobiles'])
+ del(orig_user_dict['pagers'])
+ del(orig_user_dict['homephones'])
+
new_user = ipa.user.User(orig_user_dict)
new_user.setValue('title', kw.get('title'))
new_user.setValue('givenname', kw.get('givenname'))
@@ -400,7 +471,7 @@ class UserController(IPAController):
# too much work to figure out unless someone really screams
pass
except ipaerror.IPAError, e:
- turbogears.flash("User update failed: " + str(e))
+ turbogears.flash("User update failed: " + str(e) + " " + e.detail[0]['desc'])
return dict(form=user_edit_form, user=kw,
user_groups=user_groups_dicts,
tg_template='ipagui.templates.useredit')
@@ -412,7 +483,7 @@ class UserController(IPAController):
if password_change:
rv = client.modifyPassword(kw['krbprincipalname'], "", kw.get('userpassword'))
except ipaerror.IPAError, e:
- turbogears.flash("User password change failed: " + str(e))
+ turbogears.flash("User password change failed: " + str(e) + " " + e.detail[0]['desc'])
return dict(form=user_edit_form, user=kw,
user_groups=user_groups_dicts,
tg_template='ipagui.templates.useredit')
@@ -481,7 +552,7 @@ class UserController(IPAController):
turbogears.flash("These results are truncated. " +
"Please refine your search and try again.")
except ipaerror.IPAError, e:
- turbogears.flash("User list failed: " + str(e))
+ turbogears.flash("User list failed: " + str(e) + " " + e.detail[0]['desc'])
raise turbogears.redirect("/user/list")
return dict(users=users, uid=uid, fields=ipagui.forms.user.UserFields())
@@ -523,7 +594,7 @@ class UserController(IPAController):
user_groups=user_groups, user_reports=user_reports,
user_manager=user_manager, user_secretary=user_secretary)
except ipaerror.IPAError, e:
- turbogears.flash("User show failed: " + str(e))
+ turbogears.flash("User show failed: " + str(e) + " " + e.detail[0]['desc'])
raise turbogears.redirect("/")
@expose()
@@ -539,7 +610,7 @@ class UserController(IPAController):
turbogears.flash("user deleted")
raise turbogears.redirect('/user/list')
except (SyntaxError, ipaerror.IPAError), e:
- turbogears.flash("User deletion failed: " + str(e))
+ turbogears.flash("User deletion failed: " + str(e) + " " + e.detail[0]['desc'])
raise turbogears.redirect('/user/list')
@validate(form=user_new_form)
@@ -661,7 +732,7 @@ class UserController(IPAController):
users_counter = users[0]
users = users[1:]
except ipaerror.IPAError, e:
- turbogears.flash("search failed: " + str(e))
+ turbogears.flash("search failed: " + str(e) + " " + e.detail[0]['desc'])
return dict(users=users, criteria=criteria,
which_select=kw.get('which_select'),
diff --git a/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid b/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid
index cab585fcc..865cdfcc3 100644
--- a/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/groupeditform.kid
@@ -25,6 +25,8 @@ from ipagui.helpers import ipahelper
+
@@ -66,15 +68,35 @@ from ipagui.helpers import ipahelper
@@ -655,7 +787,7 @@ from ipagui.helpers import ipahelper
group_dn = group.get('dn')
group_dn_esc = ipahelper.javascript_string_escape(group_dn)
- group_name = group.get('cn')
+ group_name = group.get('cn')[0]
group_descr = "[group]"
group_type = "group"
@@ -685,6 +817,7 @@ from ipagui.helpers import ipahelper
div_counter = div_counter + 1
?>
+
diff --git a/ipa-server/ipa-gui/ipagui/templates/usernewform.kid b/ipa-server/ipa-gui/ipagui/templates/usernewform.kid
index eeaa87fa4..82a90982d 100644
--- a/ipa-server/ipa-gui/ipagui/templates/usernewform.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/usernewform.kid
@@ -13,6 +13,8 @@ from ipagui.helpers import ipahelper
src="${tg.url('/static/javascript/dynamicedit.js')}">
+
:
- ${user.get("cn")}
+
+
+
+
+
+ ${values[index]}
+
+
+
+
@@ -132,31 +146,101 @@ else:
:
- ${user.get("telephonenumber")}
+
+
+
+
+
+ ${values[index]}
+
+
+
+
:
- ${user.get("facsimiletelephonenumber")}
+
+
+
+
+
+ ${values[index]}
+
+
+
+
:
- ${user.get("mobile")}
+
+
+
+
+
+ ${values[index]}
+
+
+
+
:
- ${user.get("pager")}
+
+
+
+
+
+ ${values[index]}
+
+
+
+
:
- ${user.get("homephone")}
+
+
+
+
+
+ ${values[index]}
+
+
+
+
From e1ca8c235c5bdd9001c2bbabaded1f1773196eca Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Mon, 12 Nov 2007 14:19:05 -0500
Subject: [PATCH 03/60] Initial support for policy editing More work is needed
as the values are currently hardcoded and not saved
---
ipa-server/ipa-gui/ipagui/controllers.py | 4 +
ipa-server/ipa-gui/ipagui/forms/Makefile.am | 4 +-
ipa-server/ipa-gui/ipagui/forms/ipapolicy.py | 29 ++++++
.../ipa-gui/ipagui/subcontrollers/Makefile.am | 2 +
.../ipagui/subcontrollers/ipapolicy.py | 96 +++++++++++++++++++
.../ipa-gui/ipagui/subcontrollers/policy.py | 32 +++++++
.../ipa-gui/ipagui/templates/Makefile.am | 6 ++
.../ipagui/templates/ipapolicyedit.kid | 15 +++
.../ipagui/templates/ipapolicyeditform.kid | 62 ++++++++++++
.../ipagui/templates/ipapolicyshow.kid | 51 ++++++++++
.../ipa-gui/ipagui/templates/master.kid | 2 +-
.../ipa-gui/ipagui/templates/policyindex.kid | 31 ++++++
.../ipa-gui/ipagui/templates/policylayout.kid | 17 ++++
13 files changed, 349 insertions(+), 2 deletions(-)
create mode 100644 ipa-server/ipa-gui/ipagui/forms/ipapolicy.py
create mode 100644 ipa-server/ipa-gui/ipagui/subcontrollers/ipapolicy.py
create mode 100644 ipa-server/ipa-gui/ipagui/subcontrollers/policy.py
create mode 100644 ipa-server/ipa-gui/ipagui/templates/ipapolicyedit.kid
create mode 100644 ipa-server/ipa-gui/ipagui/templates/ipapolicyeditform.kid
create mode 100644 ipa-server/ipa-gui/ipagui/templates/ipapolicyshow.kid
create mode 100644 ipa-server/ipa-gui/ipagui/templates/policyindex.kid
create mode 100644 ipa-server/ipa-gui/ipagui/templates/policylayout.kid
diff --git a/ipa-server/ipa-gui/ipagui/controllers.py b/ipa-server/ipa-gui/ipagui/controllers.py
index 5d0bfee03..d1ee22e01 100644
--- a/ipa-server/ipa-gui/ipagui/controllers.py
+++ b/ipa-server/ipa-gui/ipagui/controllers.py
@@ -17,6 +17,8 @@ import ipa.ipaclient
from subcontrollers.user import UserController
from subcontrollers.group import GroupController
from subcontrollers.delegation import DelegationController
+from subcontrollers.policy import PolicyController
+from subcontrollers.ipapolicy import IPAPolicyController
ipa.config.init_config()
@@ -27,6 +29,8 @@ class Root(controllers.RootController):
user = UserController()
group = GroupController()
delegate = DelegationController()
+ policy = PolicyController()
+ ipapolicy = IPAPolicyController()
@expose(template="ipagui.templates.welcome")
@identity.require(identity.not_anonymous())
diff --git a/ipa-server/ipa-gui/ipagui/forms/Makefile.am b/ipa-server/ipa-gui/ipagui/forms/Makefile.am
index 5f07e4cb0..5b0bfd337 100644
--- a/ipa-server/ipa-gui/ipagui/forms/Makefile.am
+++ b/ipa-server/ipa-gui/ipagui/forms/Makefile.am
@@ -4,8 +4,10 @@ appdir = $(IPA_DATA_DIR)/ipagui/forms
app_PYTHON = \
__init__.py \
group.py \
+ ipapolicy.py \
+ policy.py \
user.py \
- delegate.py \
+ delegate.py \
$(NULL)
EXTRA_DIST = \
diff --git a/ipa-server/ipa-gui/ipagui/forms/ipapolicy.py b/ipa-server/ipa-gui/ipagui/forms/ipapolicy.py
new file mode 100644
index 000000000..63eebbe9e
--- /dev/null
+++ b/ipa-server/ipa-gui/ipagui/forms/ipapolicy.py
@@ -0,0 +1,29 @@
+import turbogears
+from turbogears import validators, widgets
+
+class IPAPolicyFields():
+ searchlimit = widgets.TextField(name="searchlimit", label="Search Time Limit", attrs=dict(size=6,maxlength=6))
+ maxuidlength = widgets.TextField(name="maxuidlength", label="Max. UID Length", attrs=dict(size=3,maxlength=3))
+ passwordnotif = widgets.TextField(name="passwordnotif", label="Password Expiration Notification (days)", attrs=dict(size=3,maxlength=3))
+
+class IPAPolicyValidator(validators.Schema):
+ searchlimit = validators.Number(not_empty=True)
+ maxuidlength = validators.Number(not_empty=True)
+ passwordnotif = validators.Number(not_empty=True)
+
+class IPAPolicyForm(widgets.Form):
+ params = ['ipapolicy_fields']
+
+ hidden_fields = [
+ ]
+
+ validator = IPAPolicyValidator()
+
+ def __init__(self, *args, **kw):
+ super(IPAPolicyForm,self).__init__(*args, **kw)
+ (self.template_c, self.template) = widgets.meta.load_kid_template(
+ "ipagui.templates.ipapolicyeditform")
+ self.ipapolicy_fields = IPAPolicyFields
+
+ def update_params(self, params):
+ super(IPAPolicyForm,self).update_params(params)
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/Makefile.am b/ipa-server/ipa-gui/ipagui/subcontrollers/Makefile.am
index d409bac7d..2f596f2ef 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/Makefile.am
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/Makefile.am
@@ -5,6 +5,8 @@ app_PYTHON = \
__init__.py \
group.py \
ipacontroller.py \
+ ipapolicy.py \
+ policy.py \
user.py \
delegation.py \
$(NULL)
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/ipapolicy.py b/ipa-server/ipa-gui/ipagui/subcontrollers/ipapolicy.py
new file mode 100644
index 000000000..bbef94582
--- /dev/null
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/ipapolicy.py
@@ -0,0 +1,96 @@
+import os
+from pickle import dumps, loads
+from base64 import b64encode, b64decode
+import copy
+import logging
+
+import cherrypy
+import turbogears
+from turbogears import controllers, expose, flash
+from turbogears import validators, validate
+from turbogears import widgets, paginate
+from turbogears import error_handler
+from turbogears import identity
+
+from ipacontroller import IPAController
+from ipa.entity import utf8_encode_values
+from ipa import ipaerror
+import ipagui.forms.ipapolicy
+
+import ldap.dn
+
+log = logging.getLogger(__name__)
+
+ipapolicy_edit_form = ipagui.forms.ipapolicy.IPAPolicyForm()
+
+class IPAPolicyController(IPAController):
+
+ @expose()
+ def index(self):
+ raise turbogears.redirect("/ipapolicy/show")
+
+ @expose("ipagui.templates.ipapolicyshow")
+ @identity.require(identity.not_anonymous())
+ def show(self, tg_errors=None):
+ """Displays the one policy page"""
+
+ # TODO: Get this dict from LDAP
+ ipapolicy = {}
+ ipapolicy['searchlimit'] = 2
+ ipapolicy['maxuidlength'] = 3
+ ipapolicy['passwordnotif'] = 4
+ return dict(ipapolicy=ipapolicy,fields=ipagui.forms.ipapolicy.IPAPolicyFields())
+
+ @expose("ipagui.templates.ipapolicyedit")
+ @identity.require(identity.not_anonymous())
+ def edit(self, tg_errors=None):
+ """Displays the edit IPA policy form"""
+ if tg_errors:
+ turbogears.flash("There were validation errors. " +
+ "Please see the messages below for details.")
+
+ try:
+ # TODO: Get this dict from LDAP
+ ipapolicy_dict = {}
+ ipapolicy_dict['searchlimit'] = 2
+ ipapolicy_dict['maxuidlength'] = 3
+ ipapolicy_dict['passwordnotif'] = 4
+ return dict(form=ipapolicy_edit_form, ipapolicy=ipapolicy_dict)
+ except ipaerror.IPAError, e:
+ turbogears.flash("IPA Policy edit failed: " + str(e) + " " + str(e.detail))
+ raise turbogears.redirect('/group/show', uid=cn)
+
+
+ @expose()
+ @identity.require(identity.not_anonymous())
+ def update(self, **kw):
+ """Display delegate page"""
+ self.restrict_post()
+ client = self.get_ipaclient()
+
+ if kw.get('submit', '').startswith('Cancel'):
+ turbogears.flash("Edit policy cancelled")
+ raise turbogears.redirect('/ipapolicy/show')
+
+ tg_errors, kw = self.ipapolicyupdatevalidate(**kw)
+ if tg_errors:
+ turbogears.flash("There were validation errors. " +
+ "Please see the messages below for details.")
+ return dict(form=ipapolicy_edit_form, ipapolicy=kw,
+ tg_template='ipagui.templates.ipapolicyedit')
+
+ try:
+
+ # TODO: Actually save the data
+
+ turbogears.flash("IPA Policy updated")
+ raise turbogears.redirect('/ipapolicy/show')
+ except (SyntaxError, ipaerror.IPAError), e:
+ turbogears.flash("Policy update failed: " + str(e))
+ return dict(form=policy_form, policy=kw,
+ tg_template='ipagui.templates.policyindex')
+
+ @validate(form=ipapolicy_edit_form)
+ @identity.require(identity.not_anonymous())
+ def ipapolicyupdatevalidate(self, tg_errors=None, **kw):
+ return tg_errors, kw
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/policy.py b/ipa-server/ipa-gui/ipagui/subcontrollers/policy.py
new file mode 100644
index 000000000..a9fd3271f
--- /dev/null
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/policy.py
@@ -0,0 +1,32 @@
+import os
+from pickle import dumps, loads
+from base64 import b64encode, b64decode
+import copy
+import logging
+
+import cherrypy
+import turbogears
+from turbogears import controllers, expose, flash
+from turbogears import validators, validate
+from turbogears import widgets, paginate
+from turbogears import error_handler
+from turbogears import identity
+
+from ipacontroller import IPAController
+from ipa.entity import utf8_encode_values
+from ipa import ipaerror
+
+import ldap.dn
+
+log = logging.getLogger(__name__)
+
+class PolicyController(IPAController):
+
+ @expose("ipagui.templates.policyindex")
+ @identity.require(identity.not_anonymous())
+ def index(self, tg_errors=None):
+ """Displays the one policy page"""
+
+ # TODO: return a dict of the items and URLs to display on
+ # Manage Policy
+ return dict()
diff --git a/ipa-server/ipa-gui/ipagui/templates/Makefile.am b/ipa-server/ipa-gui/ipagui/templates/Makefile.am
index 18db5fffc..a166952e9 100644
--- a/ipa-server/ipa-gui/ipagui/templates/Makefile.am
+++ b/ipa-server/ipa-gui/ipagui/templates/Makefile.am
@@ -20,8 +20,14 @@ app_DATA = \
groupnewform.kid \
groupnew.kid \
groupshow.kid \
+ ipapolicyeditform.kid \
+ ipapolicyedit.kid \
+ ipapolicyindex.kid \
+ ipapolicyshow.kid \
loginfailed.kid \
master.kid \
+ policyindex.kid \
+ policylayout.kid \
usereditform.kid \
useredit.kid \
userlayout.kid \
diff --git a/ipa-server/ipa-gui/ipagui/templates/ipapolicyedit.kid b/ipa-server/ipa-gui/ipagui/templates/ipapolicyedit.kid
new file mode 100644
index 000000000..5987cc40a
--- /dev/null
+++ b/ipa-server/ipa-gui/ipagui/templates/ipapolicyedit.kid
@@ -0,0 +1,15 @@
+
+
+
+
+ Edit IPA Policy
+
+
+
+
Edit IPA Policy
+
+ ${form.display(action=tg.url('/ipapolicy/update'), value=ipapolicy)}
+
+
+
diff --git a/ipa-server/ipa-gui/ipagui/templates/ipapolicyeditform.kid b/ipa-server/ipa-gui/ipagui/templates/ipapolicyeditform.kid
new file mode 100644
index 000000000..2ba5e123b
--- /dev/null
+++ b/ipa-server/ipa-gui/ipagui/templates/ipapolicyeditform.kid
@@ -0,0 +1,62 @@
+
diff --git a/ipa-server/ipa-gui/ipagui/templates/ipapolicyshow.kid b/ipa-server/ipa-gui/ipagui/templates/ipapolicyshow.kid
new file mode 100644
index 000000000..f47dfc27f
--- /dev/null
+++ b/ipa-server/ipa-gui/ipagui/templates/ipapolicyshow.kid
@@ -0,0 +1,51 @@
+
+
+
+
+Manage IPA Policy
+
+
+
+
+
+
+
+ Manage IPA Policy
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ipa-server/ipa-gui/ipagui/templates/master.kid b/ipa-server/ipa-gui/ipagui/templates/master.kid
index fd527a278..4fa27e6c5 100644
--- a/ipa-server/ipa-gui/ipagui/templates/master.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/master.kid
@@ -78,7 +78,7 @@
Find Groups
diff --git a/ipa-server/ipa-gui/ipagui/templates/policyindex.kid b/ipa-server/ipa-gui/ipagui/templates/policyindex.kid
new file mode 100644
index 000000000..88fa4bcc2
--- /dev/null
+++ b/ipa-server/ipa-gui/ipagui/templates/policyindex.kid
@@ -0,0 +1,31 @@
+
+
+
+
+Manage Policy
+
+
+
+
+
+
+
+ Manage Policy
+
+
+
+
+
+
diff --git a/ipa-server/ipa-gui/ipagui/templates/policylayout.kid b/ipa-server/ipa-gui/ipagui/templates/policylayout.kid
new file mode 100644
index 000000000..171326539
--- /dev/null
+++ b/ipa-server/ipa-gui/ipagui/templates/policylayout.kid
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
From 547e6e920e13a312813b21b62091051424bafacb Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Mon, 12 Nov 2007 14:47:48 -0500
Subject: [PATCH 04/60] Redirect to the FQDN otherwise kerberos auth may fail
---
ipa-server/xmlrpc-server/ipa.conf | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/ipa-server/xmlrpc-server/ipa.conf b/ipa-server/xmlrpc-server/ipa.conf
index 2931b86dd..fbf26b67c 100644
--- a/ipa-server/xmlrpc-server/ipa.conf
+++ b/ipa-server/xmlrpc-server/ipa.conf
@@ -2,12 +2,18 @@
ProxyRequests Off
-# Make all requests use SSL except for Kerberos authentication errors
RewriteEngine on
+# Redirect to the fully-qualified hostname. Not redirecting to secure
+# port so configuration files can be retrieved without requiring SSL.
+RewriteCond %{HTTP_HOST} !^$FQDN$$ [NC]
+RewriteRule ^/(.*) http://$FQDN/$$1 [L,R=301]
+
+# Redirect to the secure port if not displaying an error or retrieving
+# configuration.
RewriteCond %{SERVER_PORT} !^443$$
RewriteCond %{REQUEST_URI} !^/(errors|config)/
-RewriteRule ^/(.*) https://%{SERVER_NAME}/$$1 [L,R,NC]
+RewriteRule ^/(.*) https://$FQDN/$$1 [L,R=301,NC]
AuthType Kerberos
From 6f03dde1ab92f391f413f8cb0beded72a279d230 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Mon, 12 Nov 2007 15:14:35 -0500
Subject: [PATCH 05/60] Underline columns on sort results page so users will
know it is a link Restore the CSS to display the up/down arrow on sort
columns
---
.../ipa-gui/ipagui/static/css/style.css | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/ipa-server/ipa-gui/ipagui/static/css/style.css b/ipa-server/ipa-gui/ipagui/static/css/style.css
index 28f501352..1a7cbb1fb 100644
--- a/ipa-server/ipa-gui/ipagui/static/css/style.css
+++ b/ipa-server/ipa-gui/ipagui/static/css/style.css
@@ -383,3 +383,22 @@ ul.checkboxlist li input {
#inactive {
background-color: silver;
}
+
+/*
+ * * TableKit css
+ *
+ */
+
+.sortcol {
+ cursor: pointer;
+ padding-right: 20px !important;
+ background-repeat: no-repeat !important;
+ background-position: right center !important;
+ text-decoration: underline;
+}
+.sortasc {
+ background-image: url(/static/images/up.gif) !important;
+}
+.sortdesc {
+ background-image: url(/static/images/down.gif) !important;
+}
From 705d68ddcb3dfb98e7ce9a0ef4c9397977ab3f53 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Fri, 9 Nov 2007 13:58:36 -0500
Subject: [PATCH 06/60] Require uniqueness in the name/comment field of
delegations Fix error reporting in the UI to include the detailed message
Sort delegations by name when displaying them Update the name field from
"Name" to "Delegation Name"
---
ipa-admintools/ipa-adddelegation | 19 ++++++++++
ipa-admintools/ipa-listdelegation | 4 ++-
ipa-python/aci.py | 10 ++++++
ipa-server/ipa-gui/ipagui/forms/delegate.py | 2 +-
.../ipagui/subcontrollers/delegation.py | 35 ++++++++++++++++---
5 files changed, 63 insertions(+), 7 deletions(-)
diff --git a/ipa-admintools/ipa-adddelegation b/ipa-admintools/ipa-adddelegation
index 8dde908f0..3ac053e57 100644
--- a/ipa-admintools/ipa-adddelegation
+++ b/ipa-admintools/ipa-adddelegation
@@ -90,6 +90,25 @@ def main():
new_aci.dest_group = target_grp[1].dn
new_aci.attrs = attr_list
+ aci_entry = client.get_aci_entry(['*', 'aci'])
+
+ # Look for an existing ACI of the same name
+ aci_str_list = aci_entry.getValues('aci')
+ if aci_str_list is None:
+ aci_str_list = []
+ if not(isinstance(aci_str_list,list) or isinstance(aci_str_list,tuple)):
+ aci_str_list = [aci_str_list]
+
+ for aci_str in aci_str_list:
+ try:
+ old_aci = ipa.aci.ACI(aci_str)
+ if old_aci.name == new_aci.name:
+ print "A delegation of that name already exists"
+ return 2
+ except SyntaxError:
+ # ignore aci_str's that ACI can't parse
+ pass
+
aci_entry = client.get_aci_entry(['dn'])
aci_entry.setValue('aci', new_aci.export_to_string())
diff --git a/ipa-admintools/ipa-listdelegation b/ipa-admintools/ipa-listdelegation
index 54ab346b0..4c059c4a9 100644
--- a/ipa-admintools/ipa-listdelegation
+++ b/ipa-admintools/ipa-listdelegation
@@ -23,6 +23,7 @@ from optparse import OptionParser
import ipa.ipaclient as ipaclient
import ipa.config
+import operator
import xmlrpclib
import kerberos
@@ -75,7 +76,8 @@ def main():
group_dn_to_cn = ipa.aci.extract_group_cns(aci_list, client)
- for a in aci_list:
+ # the operator.itemgetter(0) lets us sort by the name field
+ for a in sorted(aci_list, key=operator.itemgetter(0)):
labels = client.attrs_to_labels(a.attrs)
print "Delegation Name: " + a.name
print "Group " + group_dn_to_cn[a.source_group]
diff --git a/ipa-python/aci.py b/ipa-python/aci.py
index 60e19075a..d35da8dab 100644
--- a/ipa-python/aci.py
+++ b/ipa-python/aci.py
@@ -37,6 +37,16 @@ class ACI:
if acistr is not None:
self.parse_acistr(acistr)
+ def __getitem__(self,key):
+ """Fake getting attributes by key for sorting"""
+ if key == 0:
+ return self.name
+ if key == 1:
+ return self.source_group
+ if key == 2:
+ return self.dest_group
+ raise TypeError("Unknown key value %s" % key)
+
def export_to_string(self):
"""Converts the ACI to a string suitable for an LDAP aci attribute."""
attrs_str = ' || '.join(self.attrs)
diff --git a/ipa-server/ipa-gui/ipagui/forms/delegate.py b/ipa-server/ipa-gui/ipagui/forms/delegate.py
index 89011f4a2..419df4fc7 100644
--- a/ipa-server/ipa-gui/ipagui/forms/delegate.py
+++ b/ipa-server/ipa-gui/ipagui/forms/delegate.py
@@ -44,7 +44,7 @@ aci_checkbox_attrs = [(field.name, field.label) for field in aci_attrs]
aci_name_to_label = dict(aci_checkbox_attrs)
class DelegateFields():
- name = widgets.TextField(name="name", label="Name")
+ name = widgets.TextField(name="name", label="Delegation Name")
source_group_dn = widgets.HiddenField(name="source_group_dn")
dest_group_dn = widgets.HiddenField(name="dest_group_dn")
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py b/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
index 1515b04c1..d7149265e 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
@@ -19,6 +19,7 @@ import ipagui.forms.delegate
import ipa.aci
import ldap.dn
+import operator
log = logging.getLogger(__name__)
@@ -63,11 +64,34 @@ class DelegationController(IPAController):
tg_template='ipagui.templates.delegatenew')
try:
+ aci_entry = client.get_aci_entry(aci_fields)
+
new_aci = ipa.aci.ACI()
new_aci.name = kw.get('name')
new_aci.source_group = kw.get('source_group_dn')
new_aci.dest_group = kw.get('dest_group_dn')
new_aci.attrs = kw.get('attrs')
+ if (new_aci.attrs, str):
+ new_aci.attrs = [new_aci.attrs]
+
+ # Look for an existing ACI of the same name
+ aci_str_list = aci_entry.getValues('aci')
+ if aci_str_list is None:
+ aci_str_list = []
+ if not(isinstance(aci_str_list,list) or isinstance(aci_str_list,tuple)):
+ aci_str_list = [aci_str_list]
+
+ for aci_str in aci_str_list:
+ try:
+ old_aci = ipa.aci.ACI(aci_str)
+ if old_aci.name == new_aci.name:
+ turbogears.flash("Delgate add failed: a delegation of that name already exists")
+ return dict(form=delegate_form, delegate=kw,
+ tg_template='ipagui.templates.delegatenew')
+ except SyntaxError:
+ # ignore aci_str's that ACI can't parse
+ pass
+
# not pulling down existing aci attributes
aci_entry = client.get_aci_entry(['dn'])
@@ -75,7 +99,7 @@ class DelegationController(IPAController):
client.update_entry(aci_entry)
except ipaerror.IPAError, e:
- turbogears.flash("Delgate add failed: " + str(e))
+ turbogears.flash("Delgate add failed: " + str(e) + " " + e.detail[0]['desc'])
return dict(form=delegate_form, delegate=kw,
tg_template='ipagui.templates.delegatenew')
@@ -105,7 +129,7 @@ class DelegationController(IPAController):
return dict(form=delegate_form, delegate=delegate)
except (SyntaxError, ipaerror.IPAError), e:
- turbogears.flash("Delegation edit failed: " + str(e))
+ turbogears.flash("Delegation edit failed: " + str(e) + " " + e.detail[0]['desc'])
raise turbogears.redirect('/delegate/list')
@@ -162,7 +186,7 @@ class DelegationController(IPAController):
turbogears.flash("delegate updated")
raise turbogears.redirect('/delegate/list')
except (SyntaxError, ipaerror.IPAError), e:
- turbogears.flash("Delegation update failed: " + str(e))
+ turbogears.flash("Delegation update failed: " + str(e) + " " + e.detail[0]['desc'])
return dict(form=delegate_form, delegate=kw,
tg_template='ipagui.templates.delegateedit')
@@ -175,7 +199,7 @@ class DelegationController(IPAController):
try:
aci_entry = client.get_aci_entry(aci_fields)
except ipaerror.IPAError, e:
- turbogears.flash("Delegation list failed: " + str(e))
+ turbogears.flash("Delegation list failed: " + str(e) + " " + e.detail[0]['desc'])
raise turbogears.redirect('/')
aci_str_list = aci_entry.getValues('aci')
@@ -194,6 +218,7 @@ class DelegationController(IPAController):
pass
group_dn_to_cn = ipa.aci.extract_group_cns(aci_list, client)
+ aci_list = sorted(aci_list, key=operator.itemgetter(0))
# The list page needs to display field labels, not raw
# LDAP attributes
for aci in aci_list:
@@ -237,7 +262,7 @@ class DelegationController(IPAController):
turbogears.flash("delegate deleted")
raise turbogears.redirect('/delegate/list')
except (SyntaxError, ipaerror.IPAError), e:
- turbogears.flash("Delegation deletion failed: " + str(e))
+ turbogears.flash("Delegation deletion failed: " + str(e) + " " + e.detail[0]['desc'])
raise turbogears.redirect('/delegate/list')
@expose("ipagui.templates.delegategroupsearch")
From b7506a5ea68a694932053a75ca9287dfb4fb1516 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Fri, 9 Nov 2007 14:01:28 -0500
Subject: [PATCH 07/60] Fix editing groups when cn is a single-valued field Fix
some error messages that were printing the entire detail message
---
ipa-server/ipa-gui/ipagui/subcontrollers/group.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/group.py b/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
index 8ea87641e..bcc3e1ccd 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
@@ -81,7 +81,7 @@ class GroupController(IPAController):
return dict(form=group_new_form, group=kw,
tg_template='ipagui.templates.groupnew')
except ipaerror.IPAError, e:
- turbogears.flash("Group add failed: " + str(e) + " " + str(e.detail))
+ turbogears.flash("Group add failed: " + str(e) + " " + e.detail[0]['desc'])
return dict(form=group_new_form, group=kw,
tg_template='ipagui.templates.groupnew')
@@ -90,6 +90,8 @@ class GroupController(IPAController):
# on any error, we redirect to the _edit_ group page.
# this code does data setup, similar to groupedit()
#
+ if isinstance(kw['cn'], str):
+ kw['cn'] = [kw['cn']]
group = client.get_entry_by_cn(kw['cn'][0], group_fields)
group_dict = group.toDict()
member_dicts = []
@@ -403,7 +405,7 @@ class GroupController(IPAController):
turbogears.flash("group deleted")
raise turbogears.redirect('/group/list')
except (SyntaxError, ipaerror.IPAError), e:
- turbogears.flash("Group deletion failed: " + str(e) + " " + str(e.detail))
+ turbogears.flash("Group deletion failed: " + str(e) + " " + e.detail[0]['desc'])
raise turbogears.redirect('/group/list')
@validate(form=group_new_form)
From d9194cdd098f24f85443cda3dbda730172d6234a Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Fri, 9 Nov 2007 14:55:41 -0500
Subject: [PATCH 08/60] Don't continue if a kerberos credentials cache is not
available forked-model detection was incorrect. Both of these return an error
instead of raising one
---
ipa-server/xmlrpc-server/ipaxmlrpc.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/ipa-server/xmlrpc-server/ipaxmlrpc.py b/ipa-server/xmlrpc-server/ipaxmlrpc.py
index 6aaad1170..86f5fda02 100644
--- a/ipa-server/xmlrpc-server/ipaxmlrpc.py
+++ b/ipa-server/xmlrpc-server/ipaxmlrpc.py
@@ -141,8 +141,8 @@ class ModXMLRPCRequestHandler(object):
if req.subprocess_env.get("KRB5CCNAME") is not None:
opts['krbccache'] = req.subprocess_env.get("KRB5CCNAME")
else:
- sys.stderr.write("IPA: did not receive a Kerberos credentials cache. Expect problems")
- sys.stderr.flush()
+ response = dumps(Fault(5, "Did not receive Kerberos credentials."))
+ return response
if pythonopts.get("IPADebug"):
opts['ipadebug'] = pythonopts.get("IPADebug")
@@ -277,17 +277,17 @@ class ModXMLRPCRequestHandler(object):
def handle_request(self,req):
"""Handle a single XML-RPC request"""
- # The LDAP connection pool is not thread-safe. Avoid problems and
- # force the forked model for now.
- if not apache.mpm_query(apache.AP_MPMQ_IS_FORKED):
- raise Fault(3, "Apache must use the forked model")
-
# XMLRPC uses POST only. Reject anything else
if req.method != 'POST':
req.allow_methods(['POST'],1)
raise apache.SERVER_RETURN, apache.HTTP_METHOD_NOT_ALLOWED
- response = self._marshaled_dispatch(req.read(), req)
+ # The LDAP connection pool is not thread-safe. Avoid problems and
+ # force the forked model for now.
+ if apache.mpm_query(apache.AP_MPMQ_IS_THREADED):
+ response = dumps(Fault(3, "Apache must use the forked model"))
+ else:
+ response = self._marshaled_dispatch(req.read(), req)
req.content_type = "text/xml"
req.set_content_length(len(response))
From f7358533d0b81f70f10e9116652f4e7d71e29b02 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Fri, 9 Nov 2007 15:45:11 -0500
Subject: [PATCH 09/60] Add the capability to completely delete a user from the
database. The default remains to inactivate them.
---
ipa-admintools/ipa-deluser | 11 +++++++++--
ipa-admintools/man/ipa-deluser.1 | 14 ++++++++++----
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/ipa-admintools/ipa-deluser b/ipa-admintools/ipa-deluser
index 18adf75c0..d14961c84 100644
--- a/ipa-admintools/ipa-deluser
+++ b/ipa-admintools/ipa-deluser
@@ -33,6 +33,8 @@ def usage():
def parse_options():
parser = OptionParser()
+ parser.add_option("-d", "--delete", action="store_true", dest="deluser",
+ help="Delete the user, don't inactivate them.")
parser.add_option("--usage", action="store_true",
help="Program usage")
@@ -47,11 +49,16 @@ def main():
if len(args) != 2:
usage()
+ msg = "inactivated"
try:
client = ipaclient.IPAClient()
- ret = client.mark_user_deleted(args[1])
+ if options.deluser:
+ ret = client.delete_user(args[1])
+ msg = "deleted"
+ else:
+ ret = client.mark_user_deleted(args[1])
if (ret == "Success"):
- print args[1] + " successfully deleted"
+ print args[1] + " successfully %s" % msg
else:
print args[1] + " " + ret
except xmlrpclib.Fault, f:
diff --git a/ipa-admintools/man/ipa-deluser.1 b/ipa-admintools/man/ipa-deluser.1
index ab0303d75..8d82dcebe 100644
--- a/ipa-admintools/man/ipa-deluser.1
+++ b/ipa-admintools/man/ipa-deluser.1
@@ -19,14 +19,20 @@
.\"
.TH "ipa-deluser" "1" "Oct 10 2007" "freeipa" ""
.SH "NAME"
-ipa\-deluser \- Delete a user
+ipa\-deluser \- Delete or inactivate a user
.SH "SYNOPSIS"
-ipa\-deluser \fIuser\fR
+ipa\-deluser [\fIOPTION\fR]... \fIuser\fR
.SH "DESCRIPTION"
-Deletes a user with name \fIname\fR.
+Inactivates a user with login name \fIname\fR.
-Users are not completely removed with the command, just marked as inactive.
+By default users are not completely removed. They are marked as inactive. Use the [\-d|\-\-delete] option to completely remove them.
+
+Users are automatically removed from groups when they are deleted. The are not when inactivated.
+.SH "OPTIONS"
+.TP
+\fB\-d\fR, \fB\-\-delete
+Completely remove the user from the database. The default is to mark the user inactive.
.SH "EXIT STATUS"
The exit status is 0 on success, nonzero on error.
From 99b84bfd01e0b3f4e9e69ea7c2912545bef0d71a Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Fri, 9 Nov 2007 16:34:52 -0500
Subject: [PATCH 10/60] Handle ldap.UNWILLING_TO_PERFORM more gracefully
---
ipa-python/ipaerror.py | 5 +++++
ipa-server/xmlrpc-server/funcs.py | 5 ++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/ipa-python/ipaerror.py b/ipa-python/ipaerror.py
index b10a9a8fc..f583322e6 100644
--- a/ipa-python/ipaerror.py
+++ b/ipa-python/ipaerror.py
@@ -152,3 +152,8 @@ CONNECTION_GSSAPI_CREDENTIALS = gen_error_code(
CONNECTION_CATEGORY,
0x0003,
"GSSAPI Authorization error")
+
+CONNECTION_UNWILLING = gen_error_code(
+ CONNECTION_CATEGORY,
+ 0x0004,
+ "Account inactivated. Server is unwilling to perform.")
diff --git a/ipa-server/xmlrpc-server/funcs.py b/ipa-server/xmlrpc-server/funcs.py
index 6fdaaca51..a45124525 100644
--- a/ipa-server/xmlrpc-server/funcs.py
+++ b/ipa-server/xmlrpc-server/funcs.py
@@ -77,7 +77,10 @@ class IPAConnPool:
conn = ipaserver.ipaldap.IPAdmin(host,port,None,None,None,debug)
# This will bind the connection
- conn.set_krbccache(krbccache, cprinc.name)
+ try:
+ conn.set_krbccache(krbccache, cprinc.name)
+ except ldap.UNWILLING_TO_PERFORM, e:
+ raise ipaerror.gen_exception(ipaerror.CONNECTION_UNWILLING)
return conn
From cd489f0a73bcdb2583a5f69defb08ea45278c05a Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Mon, 12 Nov 2007 23:11:55 -0500
Subject: [PATCH 11/60] Allow a user or group to change an attribute in its RDN
Add secretary to the list of indexes otherwise RDN changing could be slow
Port --addattr, --setattr and --delattr from usermod to groupmod
---
ipa-admintools/ipa-groupmod | 67 ++++++++++++++---
ipa-admintools/ipa-usermod | 6 +-
ipa-admintools/man/ipa-groupmod.1 | 12 ++++
ipa-admintools/man/ipa-usermod.1 | 16 ++++-
ipa-server/ipa-install/share/indeces.ldif | 8 +++
ipa-server/ipaserver/ipaldap.py | 17 +++++
ipa-server/xmlrpc-server/funcs.py | 88 +++++++++++++++++++++--
7 files changed, 195 insertions(+), 19 deletions(-)
diff --git a/ipa-admintools/ipa-groupmod b/ipa-admintools/ipa-groupmod
index 4d8dd4d5e..9145d19da 100644
--- a/ipa-admintools/ipa-groupmod
+++ b/ipa-admintools/ipa-groupmod
@@ -31,10 +31,13 @@ import kerberos
import ldap
def usage():
- print "ipa-groupmod [-a] [-r] user group"
- print "ipa-groupmod [-d|--desc description STRING] group"
+ print "ipa-groupmod [-a|--add] [-r|--remove] user group"
+ print "ipa-groupmod [-d|--desc description STRING] [--addattr attribute=value] [--delattr attribute] [--setattr attribute=value] group"
sys.exit(1)
+def set_add_usage(which):
+ print "%s option usage: --%s NAME=VALUE" % (which, which)
+
def parse_options():
parser = OptionParser()
parser.add_option("-a", "--add", dest="add", action="store_true",
@@ -43,13 +46,22 @@ def parse_options():
help="Remove a user from the group")
parser.add_option("-d", "--description", dest="desc",
help="Modify the description of the group")
+ parser.add_option("--addattr", dest="addattr",
+ help="Adds an attribute or values to that attribute, attr=value",
+ action="append")
+ parser.add_option("--delattr", dest="delattr",
+ help="Remove an attribute", action="append")
+ parser.add_option("--setattr", dest="setattr",
+ help="Set an attribute, dropping any existing values that may exist",
+ action="append")
parser.add_option("--usage", action="store_true",
help="Program usage")
args = ipa.config.init_config(sys.argv)
options, args = parser.parse_args(args)
- if (not options.add and not options.remove) and (not options.desc):
+ if (not options.add and not options.remove) and (not options.desc and
+ not options.addattr and not options.delattr and not options.setattr):
usage()
return options, args
@@ -69,7 +81,7 @@ def main():
if (options.add or options.remove) and (len(args) != 3):
usage()
- if (options.desc and (len(args) != 2)):
+ elif ((options.desc or options.addattr or options.delattr or options.setattr) and (len(args) != 2)):
usage()
try:
@@ -78,19 +90,54 @@ def main():
group = get_group(client, args[2])
if group is None:
return 1
- client.add_user_to_group(args[1], group.dn)
- print args[1] + " successfully added to " + args[2]
+ users = args[1].split(',')
+ for user in users:
+ client.add_user_to_group(user, group.dn)
+ print user + " successfully added to " + args[2]
elif options.remove:
group = get_group(client, args[2])
if group is None:
return 1
- client.remove_user_from_group(args[1], group.dn)
- print args[1] + " successfully removed"
- elif options.desc:
+ users = args[1].split(',')
+ for user in users:
+ client.remove_user_from_group(user, group.dn)
+ print user + " successfully removed"
+ else:
group = get_group(client, args[1])
if group is None:
return 1
- group.setValue('description', options.desc)
+
+ if options.desc:
+ group.setValue('description', options.desc)
+
+ if options.delattr:
+ for d in options.delattr:
+ # doesn't truly delete the attribute but does null out the value
+ group.setValue(d, '')
+
+ if options.setattr:
+ for s in options.setattr:
+ s = s.split('=')
+ if len(s) != 2:
+ set_add_usage("set")
+ sys.exit(1)
+ (attr,value) = s
+ group.setValue(attr, value)
+
+ if options.addattr:
+ for a in options.addattr:
+ a = a.split('=')
+ if len(a) != 2:
+ set_add_usage("add")
+ sys.exit(1)
+ (attr,value) = a
+ cvalue = group.getValue(attr)
+ if cvalue:
+ if isinstance(cvalue,str):
+ cvalue = [cvalue]
+ value = cvalue + [value]
+ group.setValue(attr, value)
+
client.update_group(group)
print args[1] + " successfully updated"
except xmlrpclib.Fault, f:
diff --git a/ipa-admintools/ipa-usermod b/ipa-admintools/ipa-usermod
index c220b3f7d..50e86661d 100644
--- a/ipa-admintools/ipa-usermod
+++ b/ipa-admintools/ipa-usermod
@@ -49,12 +49,12 @@ def parse_options():
help="User's last name")
parser.add_option("-s", "--shell", dest="shell",
help="Set user's login shell to shell")
- parser.add_option("--add", dest="addattr",
+ parser.add_option("--addattr", dest="addattr",
help="Adds an attribute or values to that attribute, attr=value",
action="append")
- parser.add_option("--del", dest="delattr",
+ parser.add_option("--delattr", dest="delattr",
help="Remove an attribute", action="append")
- parser.add_option("--set", dest="setattr",
+ parser.add_option("--setattr", dest="setattr",
help="Set an attribute, dropping any existing values that may exist",
action="append")
parser.add_option("-M", "--mailAddress", dest="mail",
diff --git a/ipa-admintools/man/ipa-groupmod.1 b/ipa-admintools/man/ipa-groupmod.1
index 5b9925468..5d107de2f 100644
--- a/ipa-admintools/man/ipa-groupmod.1
+++ b/ipa-admintools/man/ipa-groupmod.1
@@ -37,5 +37,17 @@ Modify the description of the group
.TP
\fB\-r\fR, \fB\-\-remove\fR=\fIuser1,user2,...usern\fR
Remove one or more users from the group
+
+.TP
+\fB\-\-addattr\fR=\fIattr=value\fR
+Add a new attribute, or value to an existing attribute
+
+.TP
+\fB\-\-delattr\fR=\fIattr=value\fR
+Remove an attribute and all values
+
+.TP
+\fB\-\-setattr\fR=\fIattr=value\fR
+Set an attribute to a new value, removing all old ones
.SH "EXIT STATUS"
The exit status is 0 on success, nonzero on error.
diff --git a/ipa-admintools/man/ipa-usermod.1 b/ipa-admintools/man/ipa-usermod.1
index 760e6d057..43c74e450 100644
--- a/ipa-admintools/man/ipa-usermod.1
+++ b/ipa-admintools/man/ipa-usermod.1
@@ -21,10 +21,10 @@
.SH "NAME"
ipa\-usermod \- Modify a user
.SH "SYNOPSIS"
-ipa\-usermod [\fIOPTION\fR]... \fIgroup\fR
+ipa\-usermod [\fIOPTION\fR]... \fIname\fR
.SH "DESCRIPTION"
-Updates the members or description of \fIgroup\fR.
+Updates the user \fIname\fR.
.SH "OPTIONS"
.TP
\fB\-a\fR, \fB\-\-add\fR=\fIuser1,user2,...usern\fR
@@ -37,5 +37,17 @@ Modify the description of the group
.TP
\fB\-r\fR, \fB\-\-remove\fR=\fIuser1,user2,...usern\fR
Remove one or more users from the group
+
+.TP
+\fB\-\-addattr\fR=\fIattr=value\fR
+Add a new attribute, or value to an existing attribute
+
+.TP
+\fB\-\-delattr\fR=\fIattr=value\fR
+Remove an attribute and all values
+
+.TP
+\fB\-\-setattr\fR=\fIattr=value\fR
+Set an attribute to a new value, removing all old ones
.SH "EXIT STATUS"
The exit status is 0 on success, nonzero on error.
diff --git a/ipa-server/ipa-install/share/indeces.ldif b/ipa-server/ipa-install/share/indeces.ldif
index 11dc3c0ec..31cbc30ab 100644
--- a/ipa-server/ipa-install/share/indeces.ldif
+++ b/ipa-server/ipa-install/share/indeces.ldif
@@ -42,6 +42,14 @@ cn:manager
nsSystemIndex:false
nsIndexType:eq
+dn: cn=secretary,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config
+changetype: add
+objectClass:top
+objectClass:nsIndex
+cn:secretary
+nsSystemIndex:false
+nsIndexType:eq
+
dn: cn=displayname,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config
changetype: add
objectClass:top
diff --git a/ipa-server/ipaserver/ipaldap.py b/ipa-server/ipaserver/ipaldap.py
index 69f040eb5..d319869dc 100644
--- a/ipa-server/ipaserver/ipaldap.py
+++ b/ipa-server/ipaserver/ipaldap.py
@@ -377,6 +377,23 @@ class IPAdmin(SimpleLDAPObject):
raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR, None, e)
return "Success"
+ def updateRDN(self, dn, newrdn):
+ """Wrap the modrdn function."""
+
+ sctrl = self.__get_server_controls__()
+
+ if dn == newrdn:
+ # no need to report an error
+ return "Success"
+
+ try:
+ if sctrl is not None:
+ self.set_option(ldap.OPT_SERVER_CONTROLS, sctrl)
+ self.modrdn_s(dn, newrdn, delold=1)
+ except ldap.LDAPError, e:
+ raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR, None, e)
+ return "Success"
+
def updateEntry(self,dn,olduser,newuser):
"""This wraps the mod function. It assumes that the entry is already
populated with all of the desired objectclasses and attributes"""
diff --git a/ipa-server/xmlrpc-server/funcs.py b/ipa-server/xmlrpc-server/funcs.py
index a45124525..5ae901ee4 100644
--- a/ipa-server/xmlrpc-server/funcs.py
+++ b/ipa-server/xmlrpc-server/funcs.py
@@ -604,8 +604,40 @@ class IPAServer:
return new_dict
def update_user (self, oldentry, newentry, opts=None):
- """Thin wrapper around update_entry"""
- return self.update_entry(oldentry, newentry, opts)
+ """Wrapper around update_entry with user-specific handling.
+
+ If you want to change the RDN of a user you must use
+ this function. update_entry will fail.
+ """
+
+ newrdn = 0
+
+ if oldentry.get('uid') != newentry.get('uid'):
+ # RDN change
+ conn = self.getConnection(opts)
+ try:
+ res = conn.updateRDN(oldentry.get('dn'), "uid=" + newentry.get('uid'))
+ newdn = oldentry.get('dn')
+ newdn = newdn.replace("uid=%s" % oldentry.get('uid'), "uid=%s" % newentry.get('uid'))
+
+ # Now fix up the dns and uids so they aren't seen as having
+ # changed.
+ oldentry['dn'] = newdn
+ newentry['dn'] = newdn
+ oldentry['uid'] = newentry['uid']
+ newrdn = 1
+ finally:
+ self.releaseConnection(conn)
+
+ try:
+ rv = self.update_entry(oldentry, newentry, opts)
+ return rv
+ except ipaerror.exception_for(ipaerror.LDAP_EMPTY_MODLIST):
+ # This means that there was just an rdn change, nothing else.
+ if newrdn == 1:
+ return "Success"
+ else:
+ raise
def mark_user_deleted (self, uid, opts=None):
"""Mark a user as inactive in LDAP. We aren't actually deleting
@@ -1005,8 +1037,56 @@ class IPAServer:
return failed
def update_group (self, oldentry, newentry, opts=None):
- """Thin wrapper around update_entry"""
- return self.update_entry(oldentry, newentry, opts)
+ """Wrapper around update_entry with group-specific handling.
+
+ If you want to change the RDN of a group you must use
+ this function. update_entry will fail.
+ """
+
+ newrdn = 0
+
+ oldcn=oldentry.get('cn')
+ newcn=newentry.get('cn')
+ if isinstance(oldcn, str):
+ oldcn = [oldcn]
+ if isinstance(newcn, str):
+ newcn = [newcn]
+
+ oldcn.sort()
+ newcn.sort()
+ if oldcn != newcn:
+ # RDN change
+ conn = self.getConnection(opts)
+ try:
+ res = conn.updateRDN(oldentry.get('dn'), "cn=" + newcn[0])
+ newdn = oldentry.get('dn')
+
+ # Ick. Need to find the exact cn used in the old DN so we'll
+ # walk the list of cns and skip the obviously bad ones:
+ for c in oldentry.get('dn').split("cn="):
+ if c and c != "groups" and not c.startswith("accounts"):
+ newdn = newdn.replace("cn=%s" % c, "uid=%s" % newentry.get('cn')[0])
+ break
+
+ # Now fix up the dns and cns so they aren't seen as having
+ # changed.
+ oldentry['dn'] = newdn
+ newentry['dn'] = newdn
+ oldentry['cn'] = newentry['cn']
+ newrdn = 1
+ finally:
+ self.releaseConnection(conn)
+
+ try:
+ rv = self.update_entry(oldentry, newentry, opts)
+ return rv
+ except ipaerror.exception_for(ipaerror.LDAP_EMPTY_MODLIST):
+ if newrdn == 1:
+ # This means that there was just the rdn change, no other
+ # attributes
+ return "Success"
+ else:
+ raise
def delete_group (self, group_dn, opts=None):
"""Delete a group
From 5011f642436acd1a5de859d9bb7d38c7e269f35c Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Tue, 13 Nov 2007 11:15:07 -0500
Subject: [PATCH 12/60] Restrict access to some parts of the UI to those in the
admins group
---
ipa-server/ipa-gui/ipagui/proxyprovider.py | 39 ++++++++++++++++---
.../ipa-gui/ipagui/subcontrollers/group.py | 4 +-
.../ipa-gui/ipagui/subcontrollers/user.py | 4 +-
.../ipa-gui/ipagui/templates/master.kid | 8 ++--
4 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/ipa-server/ipa-gui/ipagui/proxyprovider.py b/ipa-server/ipa-gui/ipagui/proxyprovider.py
index e8ef69830..bd9cf87a8 100644
--- a/ipa-server/ipa-gui/ipagui/proxyprovider.py
+++ b/ipa-server/ipa-gui/ipagui/proxyprovider.py
@@ -2,6 +2,11 @@ from turbogears.identity.soprovider import *
from turbogears.identity.visitor import *
import logging
import os
+import ipa.ipaclient
+from ipaserver import funcs
+import ipa.config
+import ipa.group
+import ipa.user
log = logging.getLogger("turbogears.identity")
@@ -15,7 +20,25 @@ class IPA_User(object):
(principal, realm) = user_name.split('@')
self.display_name = principal
self.permissions = None
- self.groups = None
+ transport = funcs.IPAServer()
+ client = ipa.ipaclient.IPAClient(transport)
+ client.set_krbccache(os.environ["KRB5CCNAME"])
+ try:
+ user = client.get_user_by_principal(user_name, ['dn'])
+ self.groups = []
+ groups = client.get_groups_by_member(user.dn, ['dn', 'cn'])
+ if isinstance(groups, str):
+ groups = [groups]
+ for ginfo in groups:
+ # cn may be multi-valued, add them all just in case
+ cn = ginfo.getValue('cn')
+ if isinstance(cn, str):
+ cn = [cn]
+ for c in cn:
+ self.groups.append(c)
+ except:
+ raise
+
return
class ProxyIdentity(object):
@@ -57,7 +80,7 @@ class ProxyIdentity(object):
def _get_groups(self):
try:
- return self._groups
+ return self._user.groups
except AttributeError:
# Groups haven't been computed yet
return None
@@ -87,10 +110,14 @@ class ProxyIdentityProvider(SqlObjectIdentityProvider):
pass
def validate_identity(self, user_name, password, visit_key):
- user = IPA_User(user_name)
- log.debug( "validate_identity %s" % user_name)
-
- return ProxyIdentity(visit_key, user)
+ try:
+ user = IPA_User(user_name)
+ log.debug( "validate_identity %s" % user_name)
+ return ProxyIdentity(visit_key, user)
+ except:
+ # Something went wrong in fetching the user. Set to
+ # anonymous which will deny access.
+ return ProxyIdentity( None )
def validate_password(self, user, user_name, password):
'''Validation has already occurred in the proxy'''
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/group.py b/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
index bcc3e1ccd..b412b6d15 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
@@ -37,7 +37,7 @@ class GroupController(IPAController):
raise turbogears.redirect("/group/list")
@expose("ipagui.templates.groupnew")
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def new(self, tg_errors=None):
"""Displays the new group form"""
if tg_errors:
@@ -49,7 +49,7 @@ class GroupController(IPAController):
return dict(form=group_new_form, group={})
@expose()
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def create(self, **kw):
"""Creates a new group"""
self.restrict_post()
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
index a33307ae6..a527c0983 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
@@ -96,7 +96,7 @@ class UserController(IPAController):
raise turbogears.redirect("/user/list")
@expose("ipagui.templates.usernew")
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def new(self, tg_errors=None):
"""Displays the new user form"""
if tg_errors:
@@ -106,7 +106,7 @@ class UserController(IPAController):
return dict(form=user_new_form, user={})
@expose()
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def create(self, **kw):
"""Creates a new user"""
self.restrict_post()
diff --git a/ipa-server/ipa-gui/ipagui/templates/master.kid b/ipa-server/ipa-gui/ipagui/templates/master.kid
index 4fa27e6c5..f395f31bf 100644
--- a/ipa-server/ipa-gui/ipagui/templates/master.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/master.kid
@@ -70,19 +70,19 @@
From 79544637d61336d43f8d42dde4f6aad0d60afb64 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Tue, 13 Nov 2007 15:49:06 -0500
Subject: [PATCH 13/60] The e-mail field should not be required.
---
ipa-server/ipa-gui/ipagui/forms/user.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ipa-server/ipa-gui/ipagui/forms/user.py b/ipa-server/ipa-gui/ipagui/forms/user.py
index b426f8e91..7cc150eff 100644
--- a/ipa-server/ipa-gui/ipagui/forms/user.py
+++ b/ipa-server/ipa-gui/ipagui/forms/user.py
@@ -74,7 +74,7 @@ class UserNewValidator(validators.Schema):
userpassword_confirm = validators.String(not_empty=False)
givenname = validators.String(not_empty=True)
sn = validators.String(not_empty=True)
- mail = validators.Email(not_empty=True)
+ mail = validators.Email(not_empty=False)
chained_validators = [
validators.FieldsMatch('userpassword', 'userpassword_confirm')
From eecbaf91e2c9dfd6a24c1d2c8b85c50adcff9d42 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Tue, 13 Nov 2007 15:03:20 -0500
Subject: [PATCH 14/60] Use the dna plugin to automatically assign uid Set gid
to the group "ipausers" Add the user to this default group
---
ipa-server/xmlrpc-server/funcs.py | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/ipa-server/xmlrpc-server/funcs.py b/ipa-server/xmlrpc-server/funcs.py
index 5ae901ee4..82c84855e 100644
--- a/ipa-server/xmlrpc-server/funcs.py
+++ b/ipa-server/xmlrpc-server/funcs.py
@@ -426,11 +426,18 @@ class IPAServer:
if user.get('gecos') is None:
user['gecos'] = user['uid']
- # FIXME: This can be removed once the DS plugin is installed
- user['uidnumber'] = '501'
+ # If uidnumber is blank the the FDS dna_plugin will automatically
+ # assign the next value. So we don't have to do anything with it.
- # FIXME: What is the default group for users?
- user['gidnumber'] = '501'
+ # FIXME: put the default group in a config file
+ group_dn="cn=%s,%s,%s" % ("ipausers", DefaultGroupContainer, self.basedn)
+ try:
+ default_group = self.get_entry_by_dn(group_dn, ['dn','gidNumber'], opts)
+ if default_group:
+ user['gidnumber'] = default_group.get('gidnumber')
+ except ipaerror.exception_for(ipaerror.LDAP_DATABASE_ERROR):
+ # Fake an LDAP error so we can return something useful to the user
+ raise ipaerror.gen_exception(ipaerror.LDAP_NOT_FOUND, "No default group for new users can be found.")
if user.get('krbprincipalname') is None:
user['krbprincipalname'] = "%s@%s" % (user.get('uid'), self.realm)
@@ -455,6 +462,7 @@ class IPAServer:
conn = self.getConnection(opts)
try:
res = conn.addEntry(entry)
+ self.add_user_to_group(user.get('uid'), group_dn, opts)
finally:
self.releaseConnection(conn)
return res
@@ -742,9 +750,8 @@ class IPAServer:
entry.setValues('objectClass', 'top', 'groupofuniquenames', 'posixGroup',
'inetUser')
- # FIXME, need a gidNumber generator
- if group.get('gidnumber') is None:
- entry.setValues('gidNumber', '501')
+ # No need to explicitly set gidNumber. The dna_plugin will do this
+ # for us if the value isn't provided by the user.
# fill in our new entry with everything sent by the user
for g in group:
From 83dd26c6e351c020ddde21bba310b8076360f890 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Tue, 13 Nov 2007 17:24:00 -0500
Subject: [PATCH 15/60] Remove non-existent files from Makefile targets
---
ipa-server/ipa-gui/ipagui/forms/Makefile.am | 1 -
ipa-server/ipa-gui/ipagui/templates/Makefile.am | 1 -
2 files changed, 2 deletions(-)
diff --git a/ipa-server/ipa-gui/ipagui/forms/Makefile.am b/ipa-server/ipa-gui/ipagui/forms/Makefile.am
index 5b0bfd337..c075b9f47 100644
--- a/ipa-server/ipa-gui/ipagui/forms/Makefile.am
+++ b/ipa-server/ipa-gui/ipagui/forms/Makefile.am
@@ -5,7 +5,6 @@ app_PYTHON = \
__init__.py \
group.py \
ipapolicy.py \
- policy.py \
user.py \
delegate.py \
$(NULL)
diff --git a/ipa-server/ipa-gui/ipagui/templates/Makefile.am b/ipa-server/ipa-gui/ipagui/templates/Makefile.am
index a166952e9..6626ad8c2 100644
--- a/ipa-server/ipa-gui/ipagui/templates/Makefile.am
+++ b/ipa-server/ipa-gui/ipagui/templates/Makefile.am
@@ -22,7 +22,6 @@ app_DATA = \
groupshow.kid \
ipapolicyeditform.kid \
ipapolicyedit.kid \
- ipapolicyindex.kid \
ipapolicyshow.kid \
loginfailed.kid \
master.kid \
From bd78fe06877e80b19bd0358f525bed73efe17004 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Tue, 13 Nov 2007 15:36:52 -0500
Subject: [PATCH 16/60] Add more fields to the IPA Policy form
---
ipa-server/ipa-gui/ipagui/forms/ipapolicy.py | 8 ++++-
.../ipagui/subcontrollers/ipapolicy.py | 6 ++++
.../ipagui/templates/ipapolicyeditform.kid | 34 +++++++++++++++++++
.../ipagui/templates/ipapolicyshow.kid | 21 ++++++++++++
4 files changed, 68 insertions(+), 1 deletion(-)
diff --git a/ipa-server/ipa-gui/ipagui/forms/ipapolicy.py b/ipa-server/ipa-gui/ipagui/forms/ipapolicy.py
index 63eebbe9e..660a34b68 100644
--- a/ipa-server/ipa-gui/ipagui/forms/ipapolicy.py
+++ b/ipa-server/ipa-gui/ipagui/forms/ipapolicy.py
@@ -2,14 +2,20 @@ import turbogears
from turbogears import validators, widgets
class IPAPolicyFields():
- searchlimit = widgets.TextField(name="searchlimit", label="Search Time Limit", attrs=dict(size=6,maxlength=6))
+ searchlimit = widgets.TextField(name="searchlimit", label="Search Time Limit (sec.)", attrs=dict(size=6,maxlength=6))
maxuidlength = widgets.TextField(name="maxuidlength", label="Max. UID Length", attrs=dict(size=3,maxlength=3))
passwordnotif = widgets.TextField(name="passwordnotif", label="Password Expiration Notification (days)", attrs=dict(size=3,maxlength=3))
+ homedir = widgets.TextField(name="homedir", label="Root for Home Directories")
+ defaultshell = widgets.TextField(name="defaultshell", label="Default shell")
+ defaultgroup = widgets.TextField(name="defaultgroup", label="Default Users group")
class IPAPolicyValidator(validators.Schema):
searchlimit = validators.Number(not_empty=True)
maxuidlength = validators.Number(not_empty=True)
passwordnotif = validators.Number(not_empty=True)
+ homedir = validators.String(not_empty=True)
+ defaultshell = validators.String(not_empty=True)
+ defaultgroup = validators.String(not_empty=True)
class IPAPolicyForm(widgets.Form):
params = ['ipapolicy_fields']
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/ipapolicy.py b/ipa-server/ipa-gui/ipagui/subcontrollers/ipapolicy.py
index bbef94582..a1c1a9f03 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/ipapolicy.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/ipapolicy.py
@@ -39,6 +39,9 @@ class IPAPolicyController(IPAController):
ipapolicy['searchlimit'] = 2
ipapolicy['maxuidlength'] = 3
ipapolicy['passwordnotif'] = 4
+ ipapolicy['homedir'] = "/home"
+ ipapolicy['defaultgroup'] = "ipausers"
+ ipapolicy['defaultshell'] = "/bin/bash"
return dict(ipapolicy=ipapolicy,fields=ipagui.forms.ipapolicy.IPAPolicyFields())
@expose("ipagui.templates.ipapolicyedit")
@@ -55,6 +58,9 @@ class IPAPolicyController(IPAController):
ipapolicy_dict['searchlimit'] = 2
ipapolicy_dict['maxuidlength'] = 3
ipapolicy_dict['passwordnotif'] = 4
+ ipapolicy_dict['homedir'] = "/home"
+ ipapolicy_dict['defaultgroup'] = "ipausers"
+ ipapolicy_dict['defaultshell'] = "/bin/bash"
return dict(form=ipapolicy_edit_form, ipapolicy=ipapolicy_dict)
except ipaerror.IPAError, e:
turbogears.flash("IPA Policy edit failed: " + str(e) + " " + str(e.detail))
diff --git a/ipa-server/ipa-gui/ipagui/templates/ipapolicyeditform.kid b/ipa-server/ipa-gui/ipagui/templates/ipapolicyeditform.kid
index 2ba5e123b..bcdef8c27 100644
--- a/ipa-server/ipa-gui/ipagui/templates/ipapolicyeditform.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/ipapolicyeditform.kid
@@ -46,6 +46,10 @@ from ipagui.helpers import ipahelper
py:content="tg.errors.get('passwordnotif')" />
+
+
+
+
diff --git a/ipa-server/ipa-gui/ipagui/templates/ipapolicyshow.kid b/ipa-server/ipa-gui/ipagui/templates/ipapolicyshow.kid
index f47dfc27f..e14485f2a 100644
--- a/ipa-server/ipa-gui/ipagui/templates/ipapolicyshow.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/ipapolicyshow.kid
@@ -34,12 +34,33 @@ edit_url = tg.url('/ipapolicy/edit')
${ipapolicy.get("passwordnotif")}
+
+
+
Date: Tue, 13 Nov 2007 16:21:03 -0500
Subject: [PATCH 17/60] Initial implementation of policies support. This patch
uses the kerberos schema policy, this is the same policy used by kadmin.
While this patch allows for krbPwdPolicy objects anywhere the kldap module
will make the kdc fail to provide tickets if the "krbPwdPolicyReference"
points to any object that is not a child of cn=,cn=kerberos,dc=.... To
let us set policies anywhere in the tree I enabled the code to actually look
at parent entries and the user entry itself and specify policies directly on
these objects by adding the krbPwdPolicy objectclass to them (I know its
structural but DS seem to allow multiple Structural classes on the same
entry). The only side effect is that kadmin will not understand this, but we
don't want to use kadmin anyway as it does not understand way too many things
about the directory.
I've tested a few scenarios and all seem working as expected, but further
testing is welcome of course.
---
ipa-server/ipa-kpasswd/ipa_kpasswd.c | 6 +-
.../ipa-pwd-extop/ipa_pwd_extop.c | 637 +++++++++++++++---
2 files changed, 536 insertions(+), 107 deletions(-)
diff --git a/ipa-server/ipa-kpasswd/ipa_kpasswd.c b/ipa-server/ipa-kpasswd/ipa_kpasswd.c
index f5540b74c..fdaa8197c 100644
--- a/ipa-server/ipa-kpasswd/ipa_kpasswd.c
+++ b/ipa-server/ipa-kpasswd/ipa_kpasswd.c
@@ -399,7 +399,11 @@ int ldap_pwd_change(char *client_name, char *realm_name, krb5_data pwd)
if (ret != LDAP_SUCCESS) {
syslog(LOG_ERR, "Search for %s failed with error %d",
filter, ret);
- ret = KRB5_KPASSWD_HARDERROR;
+ if (ret == LDAP_CONSTRAINT_VIOLATION) {
+ ret = KRB5_KPASSWD_SOFTERROR;
+ } else {
+ ret = KRB5_KPASSWD_HARDERROR;
+ }
goto done;
}
free(filter);
diff --git a/ipa-server/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c b/ipa-server/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c
index e4e9d4615..889f9a1fd 100644
--- a/ipa-server/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c
+++ b/ipa-server/ipa-slapi-plugins/ipa-pwd-extop/ipa_pwd_extop.c
@@ -58,6 +58,7 @@
#include
#include
#include
+#include
#include
#include
@@ -129,6 +130,7 @@ static void *ipapwd_plugin_id;
krb5_keyblock kmkey;
+char *ipa_realm;
struct krb5p_keysalt *keysalts;
int n_keysalts;
@@ -183,14 +185,22 @@ static inline void encode_int16(unsigned int val, unsigned char *p)
p[0] = (val ) & 0xff;
}
-static Slapi_Value **encrypt_encode_key(krb5_context krbctx, Slapi_Entry *e, const char *newPasswd)
+struct ipapwd_data {
+ Slapi_Entry *target;
+ const char *dn;
+ const char *password;
+ time_t timeNow;
+ time_t lastPwChange;
+ time_t expireTime;
+ int adminChange;
+};
+
+static Slapi_Value **encrypt_encode_key(krb5_context krbctx, struct ipapwd_data *data)
{
const char *krbPrincipalName;
- const char *krbLastPwdChange;
uint32_t krbMaxTicketLife;
Slapi_Attr *krbPrincipalKey = NULL;
struct kbvals *kbvals = NULL;
- time_t lastpwchange;
time_t time_now;
int kvno;
int num_versions, num_keys;
@@ -206,53 +216,31 @@ static Slapi_Value **encrypt_encode_key(krb5_context krbctx, Slapi_Entry *e, con
time_now = time(NULL);
- krbPrincipalName = slapi_entry_attr_get_charptr(e, "krbPrincipalName");
+ krbPrincipalName = slapi_entry_attr_get_charptr(data->target, "krbPrincipalName");
if (!krbPrincipalName) {
slapi_log_error(SLAPI_LOG_FATAL, "ipa_pwd_extop", "no krbPrincipalName present in this entry\n");
return NULL;
}
- krbMaxTicketLife = slapi_entry_attr_get_uint(e, "krbMaxTicketLife");
+ krbMaxTicketLife = slapi_entry_attr_get_uint(data->target, "krbMaxTicketLife");
if (krbMaxTicketLife == 0) {
/* FIXME: retrieve the default from config (max_life from kdc.conf) */
krbMaxTicketLife = 86400; /* just set the default 24h for now */
}
- krbLastPwdChange = slapi_entry_attr_get_charptr(e, "krbLastPwdChange");
- if (!krbLastPwdChange) {
- lastpwchange = -1;
- } else {
- struct tm tm;
-
- memset(&tm, 0, sizeof(struct tm));
- ret = sscanf(krbLastPwdChange,
- "%04u%02u%02u%02u%02u%02u",
- &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
- &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
-
- if (ret == 6) {
- tm.tm_year -= 1900;
- tm.tm_mon -= 1;
- lastpwchange = timegm(&tm);
- } else {
- /* FIXME: report an error ? */
- lastpwchange = -1;
- }
- }
- /* FIXME: warn if lastpwchange == -1 ? */
-
kvno = 0;
num_keys = 0;
num_versions = 1;
/* retrieve current kvno and and keys */
- ret = slapi_entry_attr_find(e, "krbPrincipalKey", &krbPrincipalKey);
+ ret = slapi_entry_attr_find(data->target, "krbPrincipalKey", &krbPrincipalKey);
if (ret == 0) {
int i, n, count, idx;
ber_int_t tkvno;
Slapi_ValueSet *svs;
Slapi_Value *sv;
ber_tag_t tag, tmp;
+ const struct berval *cbval;
slapi_attr_get_valueset(krbPrincipalKey, &svs);
count = slapi_valueset_count(svs);
@@ -271,13 +259,13 @@ static Slapi_Value **encrypt_encode_key(krb5_context krbctx, Slapi_Entry *e, con
"Array of stored keys shorter than expected\n");
break;
}
- bval = slapi_value_get_berval(sv);
- if (!bval) {
+ cbval = slapi_value_get_berval(sv);
+ if (!cbval) {
slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
"Error retrieving berval from Slapi_Value\n");
continue;
}
- be = ber_init(bval);
+ be = ber_init(cbval);
if (!be) {
slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
"ber_init() failed!\n");
@@ -293,7 +281,7 @@ static Slapi_Value **encrypt_encode_key(krb5_context krbctx, Slapi_Entry *e, con
}
kbvals[n].kvno = tkvno;
- kbvals[n].bval = bval;
+ kbvals[n].bval = cbval;
n++;
if (tkvno > kvno) {
@@ -305,8 +293,8 @@ static Slapi_Value **encrypt_encode_key(krb5_context krbctx, Slapi_Entry *e, con
num_keys = n;
/* now verify how many keys we need to keep around */
- if (num_keys > 0 && lastpwchange != -1) {
- if (time_now > lastpwchange + krbMaxTicketLife) {
+ if (num_keys) {
+ if (time_now > data->lastPwChange + krbMaxTicketLife) {
/* the last password change was long ago,
* at most only the last entry need to be kept */
num_versions = 2;
@@ -345,6 +333,8 @@ static Slapi_Value **encrypt_encode_key(krb5_context krbctx, Slapi_Entry *e, con
}
}
+ if (kbvals) free(kbvals);
+
krberr = krb5_parse_name(krbctx, krbPrincipalName, &princ);
if (krberr) {
slapi_log_error(SLAPI_LOG_FATAL, "ipa_pwd_extop",
@@ -353,10 +343,10 @@ static Slapi_Value **encrypt_encode_key(krb5_context krbctx, Slapi_Entry *e, con
goto enc_error;
}
- krbTicketFlags = slapi_entry_attr_get_int(e, "krbTicketFlags");
+ krbTicketFlags = slapi_entry_attr_get_int(data->target, "krbTicketFlags");
- pwd.data = (char *)newPasswd;
- pwd.length = strlen(newPasswd);
+ pwd.data = (char *)data->password;
+ pwd.length = strlen(data->password);
be = ber_alloc_t( LBER_USE_DER );
@@ -793,25 +783,396 @@ done:
return ret;
}
+/* searches the directory and finds the policy closest to the DN */
+/* return 0 on success, -1 on error or if no policy is found */
+static int ipapwd_getPolicy(const char *dn, Slapi_Entry *target, Slapi_Entry **e)
+{
+ const char *krbPwdPolicyReference;
+ const char *pdn;
+ const Slapi_DN *psdn;
+ Slapi_Backend *be;
+ Slapi_PBlock *pb;
+ char *attrs[] = { "krbMaxPwdLife", "krbMinPwdLife",
+ "krbPwdMinDiffChars", "krbPwdMinLength",
+ "krbPwdHistoryLength", NULL};
+ Slapi_Entry **es = NULL;
+ Slapi_Entry *pe = NULL;
+ char **edn;
+ int ret, res, dist, rdnc, scope, i;
+ Slapi_DN *sdn;
+
+ sdn = slapi_sdn_new_dn_byref(dn);
+
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
+ "ipapwd_getPolicy: Searching policy for [%s]\n", dn);
+
+ krbPwdPolicyReference = slapi_entry_attr_get_charptr(target, "krbPwdPolicyReference");
+ if (krbPwdPolicyReference) {
+ pdn = krbPwdPolicyReference;
+ scope = LDAP_SCOPE_BASE;
+ } else {
+ /* Find ancestor base DN */
+ be = slapi_be_select(sdn);
+ psdn = slapi_be_getsuffix(be, 0);
+ pdn = slapi_sdn_get_dn(psdn);
+ scope = LDAP_SCOPE_SUBTREE;
+ }
+
+ *e = NULL;
+
+ pb = slapi_pblock_new();
+ slapi_search_internal_set_pb (pb,
+ pdn, scope,
+ "(objectClass=krbPwdPolicy)",
+ attrs, 0,
+ NULL, /* Controls */
+ NULL, /* UniqueID */
+ ipapwd_plugin_id,
+ 0); /* Flags */
+
+ /* do search the tree */
+ ret = slapi_search_internal_pb(pb);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
+ if (ret == -1 || res != LDAP_SUCCESS) {
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
+ "ipapwd_getPolicy: Couldn't find policy, err (%d)\n",
+ res?res:ret);
+ slapi_free_search_results_internal(pb);
+ slapi_sdn_free(&sdn);
+ return -1;
+ }
+
+ /* get entries */
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &es);
+ if (!es) {
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
+ "ipapwd_getPolicy: No entries ?!");
+ slapi_free_search_results_internal(pb);
+ slapi_sdn_free(&sdn);
+ return -1;
+ }
+
+ /* count entries */
+ for (i = 0; es[i]; i++) /* count */ ;
+
+ /* if there is only one, return that */
+ if (i == 1) {
+ *e = slapi_entry_dup(es[0]);
+
+ slapi_free_search_results_internal(pb);
+ slapi_sdn_free(&sdn);
+ return 0;
+ }
+
+ /* count number of RDNs in DN */
+ edn = ldap_explode_dn(dn, 0);
+ if (!edn) {
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
+ "ipapwd_getPolicy: ldap_explode_dn(dn) failed ?!");
+ slapi_free_search_results_internal(pb);
+ slapi_sdn_free(&sdn);
+ return -1;
+ }
+ for (rdnc = 0; edn[rdnc]; rdnc++) /* count */ ;
+ ldap_value_free(edn);
+
+ pe = NULL;
+ dist = -1;
+
+ /* find closest entry */
+ for (i = 0; es[i]; i++) {
+ const Slapi_DN *esdn;
+
+ esdn = slapi_entry_get_sdn_const(es[i]);
+ if (0 == slapi_sdn_compare(esdn, sdn)) {
+ pe = es[i];
+ dist = 0;
+ break;
+ }
+ if (slapi_sdn_issuffix(sdn, esdn)) {
+ const char *dn1;
+ char **e1;
+ int c1;
+
+ dn1 = slapi_sdn_get_dn(esdn);
+ if (!dn1) continue;
+ e1 = ldap_explode_dn(dn1, 0);
+ if (!e1) continue;
+ for (c1 = 0; e1[c1]; c1++) /* count */ ;
+ ldap_value_free(e1);
+ if ((dist == -1) ||
+ ((rdnc - c1) < dist)) {
+ dist = rdnc - c1;
+ pe = es[i];
+ }
+ }
+ if (dist == 0) break; /* found closest */
+ }
+
+ if (pe == NULL) {
+ slapi_free_search_results_internal(pb);
+ slapi_sdn_free(&sdn);
+ return -1;
+ }
+
+ *e = slapi_entry_dup(pe);
+
+ slapi_free_search_results_internal(pb);
+ slapi_sdn_free(&sdn);
+ return 0;
+}
+
+#define IPAPWD_POLICY_MASK 0x0FF
+#define IPAPWD_POLICY_ERROR 0x100
+#define IPAPWD_POLICY_OK 0
+
+/* 90 days default pwd max lifetime */
+#define IPAPWD_DEFAULT_PWDLIFE (90 * 24 *3600)
+#define IPAPWD_DEFAULT_MINLEN 8
+
+/* check password strenght and history */
+static int ipapwd_CheckPolicy(struct ipapwd_data *data)
+{
+ const char *krbPrincipalExpiration;
+ const char *krbLastPwdChange;
+ int krbMaxPwdLife = 0;
+ int krbPwdMinLength = 0;
+ int krbPwdMinDiffChars = 0;
+ int krbMinPwdLife = 0;
+ int pwdCharLen = 0;
+ Slapi_Entry *policy = NULL;
+ struct tm tm;
+ int ret;
+
+ /* check account is not expired */
+ krbPrincipalExpiration = slapi_entry_attr_get_charptr(data->target, "krbPrincipalExpiration");
+ if (krbPrincipalExpiration) {
+ /* if expiration date set check it */
+ memset(&tm, 0, sizeof(struct tm));
+ ret = sscanf(krbPrincipalExpiration,
+ "%04u%02u%02u%02u%02u%02u",
+ &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
+ &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
+
+ if (ret == 6) {
+ tm.tm_year -= 1900;
+ tm.tm_mon -= 1;
+
+ if (data->timeNow > timegm(&tm)) {
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "Account Expired");
+ return IPAPWD_POLICY_ERROR | LDAP_PWPOLICY_PWDMODNOTALLOWED;
+ }
+ }
+ /* FIXME: else error out ? */
+ }
+
+ if (data->adminChange) {
+ /* we must skip policy checks (Admin change) but
+ * force a password change on the next login */
+
+ data->expireTime = data->timeNow;
+
+ } else {
+ krbLastPwdChange = slapi_entry_attr_get_charptr(data->target, "krbLastPwdChange");
+ /* if no previous change, it means this is probably a new account
+ * or imported, log and just ignore */
+ if (krbLastPwdChange) {
+
+ memset(&tm, 0, sizeof(struct tm));
+ ret = sscanf(krbLastPwdChange,
+ "%04u%02u%02u%02u%02u%02u",
+ &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
+ &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
+
+ if (ret == 6) {
+ tm.tm_year -= 1900;
+ tm.tm_mon -= 1;
+ data->lastPwChange = timegm(&tm);
+ }
+ /* FIXME: *else* report an error ? */
+ } else {
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "Warning: Last Password Change Time is not available");
+ }
+ }
+
+ /* find the entry with the password policy */
+ ret = ipapwd_getPolicy(data->dn, data->target, &policy);
+ if (ret) {
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "No password policy");
+
+ krbMaxPwdLife = IPAPWD_DEFAULT_PWDLIFE;
+ krbPwdMinLength = IPAPWD_DEFAULT_MINLEN;
+ goto no_policy;
+ }
+
+ /* Check min age */
+ krbMinPwdLife = slapi_entry_attr_get_int(policy, "krbMinPwdLife");
+ /* if no default then treat it as no limit */
+ if (krbMinPwdLife != 0) {
+
+ if (data->timeNow < data->lastPwChange + krbMinPwdLife) {
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
+ "ipapwd_checkPassword: Too soon to change password\n");
+ slapi_entry_free(policy);
+ return IPAPWD_POLICY_ERROR | LDAP_PWPOLICY_PWDTOOYOUNG;
+ }
+ }
+
+ /* Retrieve min length */
+ krbPwdMinLength = slapi_entry_attr_get_int(policy, "krbPwdMinLength");
+ if (krbPwdMinLength == 0) {
+ /* if no default then set a minimum of 8 */
+ krbPwdMinLength = 8;
+ }
+
+ /* check complexity */
+ /* FIXME: this code is partially based on Directory Server code,
+ * the plan is to merge this code later making it available
+ * trough a pulic DS API for slapi plugins */
+ krbPwdMinDiffChars = slapi_entry_attr_get_int(policy, "krbPwdMinDiffChars");
+ if (krbPwdMinDiffChars != 0) {
+ int num_digits = 0;
+ int num_alphas = 0;
+ int num_uppers = 0;
+ int num_lowers = 0;
+ int num_specials = 0;
+ int num_8bit = 0;
+ int num_repeated = 0;
+ int max_repeated = 0;
+ int num_categories = 0;
+ char *p, *pwd;
+
+ pwd = strdup(data->password);
+
+ /* check character types */
+ p = pwd;
+ while ( p && *p )
+ {
+ if ( ldap_utf8isdigit( p ) ) {
+ num_digits++;
+ } else if ( ldap_utf8isalpha( p ) ) {
+ num_alphas++;
+ if ( slapi_utf8isLower( (unsigned char *)p ) ) {
+ num_lowers++;
+ } else {
+ num_uppers++;
+ }
+ } else {
+ /* check if this is an 8-bit char */
+ if ( *p & 128 ) {
+ num_8bit++;
+ } else {
+ num_specials++;
+ }
+ }
+
+ /* check for repeating characters. If this is the
+ first char of the password, no need to check */
+ if ( pwd != p ) {
+ int len = ldap_utf8len( p );
+ char *prev_p = ldap_utf8prev( p );
+
+ if ( len == ldap_utf8len( prev_p ) )
+ {
+ if ( memcmp( p, prev_p, len ) == 0 )
+ {
+ num_repeated++;
+ if ( max_repeated < num_repeated ) {
+ max_repeated = num_repeated;
+ }
+ } else {
+ num_repeated = 0;
+ }
+ } else {
+ num_repeated = 0;
+ }
+ }
+
+ p = ldap_utf8next( p );
+ }
+
+ free(pwd);
+ p = pwd = NULL;
+
+ /* tally up the number of character categories */
+ if ( num_digits > 0 )
+ ++num_categories;
+ if ( num_uppers > 0 )
+ ++num_categories;
+ if ( num_lowers > 0 )
+ ++num_categories;
+ if ( num_specials > 0 )
+ ++num_categories;
+ if ( num_8bit > 0 )
+ ++num_categories;
+
+ /* FIXME: the kerberos plicy schema does not define separated threshold values,
+ * so just treat anything as a category, we will fix this when we merge
+ * with DS policies */
+
+ if (max_repeated > 0)
+ --num_categories;
+
+ if (num_categories < krbPwdMinDiffChars) {
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
+ "ipapwd_checkPassword: Password not complex enough\n");
+ slapi_entry_free(policy);
+ return IPAPWD_POLICY_ERROR | LDAP_PWPOLICY_INVALIDPWDSYNTAX;
+ }
+ }
+
+ /* TODO: Check password history */
+
+ /* Calculate max age */
+ krbMaxPwdLife = slapi_entry_attr_get_int(policy, "krbMaxPwdLife");
+ if (krbMaxPwdLife <= 0) {
+ /* set default expiration date of 90 days */
+ krbMaxPwdLife = IPAPWD_DEFAULT_PWDLIFE;
+ }
+
+ slapi_entry_free(policy);
+
+no_policy:
+
+ /* check min lenght */
+ pwdCharLen = ldap_utf8characters(data->password);
+
+ if (pwdCharLen < krbPwdMinLength) {
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
+ "ipapwd_checkPassword: Password too short\n");
+ return IPAPWD_POLICY_ERROR | LDAP_PWPOLICY_PWDTOOSHORT;
+ }
+
+ if (data->expireTime == 0) {
+ data->expireTime = data->timeNow + krbMaxPwdLife;
+ }
+
+ return IPAPWD_POLICY_OK;
+}
+
+
/* Searches the dn in directory,
* If found : fills in slapi_entry structure and returns 0
* If NOT found : returns the search result as LDAP_NO_SUCH_OBJECT
*/
-static int
-ipapwd_getEntry( const char *dn, Slapi_Entry **e2 ) {
- int search_result = 0;
- Slapi_DN *sdn;
+static int ipapwd_getEntry(const char *dn, Slapi_Entry **e2)
+{
+ Slapi_DN *sdn;
+ int search_result = 0;
+
slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "=> ipapwd_getEntry\n");
sdn = slapi_sdn_new_dn_byref(dn);
if ((search_result = slapi_search_internal_get_entry( sdn, NULL, e2,
ipapwd_plugin_id)) != LDAP_SUCCESS ){
- slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "ipapwd_getEntry: No such entry-(%s), err (%d)\n",
- dn, search_result);
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
+ "ipapwd_getEntry: No such entry-(%s), err (%d)\n",
+ dn, search_result);
}
slapi_sdn_free( &sdn );
- slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "<= ipapwd_getEntry: %d\n", search_result);
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
+ "<= ipapwd_getEntry: %d\n", search_result);
return search_result;
}
@@ -822,35 +1183,44 @@ ipapwd_getEntry( const char *dn, Slapi_Entry **e2 ) {
static int ipapwd_apply_mods(const char *dn, Slapi_Mods *mods)
{
Slapi_PBlock *pb;
- int ret=0;
+ int ret;
slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "=> ipapwd_apply_mods\n");
- if (mods && (slapi_mods_get_num_mods(mods) > 0))
- {
- pb = slapi_pblock_new();
- slapi_modify_internal_set_pb (pb, dn,
- slapi_mods_get_ldapmods_byref(mods),
- NULL, /* Controls */
- NULL, /* UniqueID */
- ipapwd_plugin_id, /* PluginID */
- 0); /* Flags */
+ if (!mods || (slapi_mods_get_num_mods(mods) == 0)) {
+ return -1;
+ }
- ret = slapi_modify_internal_pb (pb);
+ pb = slapi_pblock_new();
+ slapi_modify_internal_set_pb (pb, dn,
+ slapi_mods_get_ldapmods_byref(mods),
+ NULL, /* Controls */
+ NULL, /* UniqueID */
+ ipapwd_plugin_id, /* PluginID */
+ 0); /* Flags */
- slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
-
- if (ret != LDAP_SUCCESS){
- slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "WARNING: modify error %d on entry '%s'\n",
+ ret = slapi_modify_internal_pb (pb);
+ if (ret) {
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
+ "WARNING: modify error %d on entry '%s'\n",
ret, dn);
- }
+ } else {
+
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
+
+ if (ret != LDAP_SUCCESS){
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
+ "WARNING: modify error %d on entry '%s'\n",
+ ret, dn);
+ } else {
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop",
+ "<= ipapwd_apply_mods: Successful\n");
+ }
+ }
slapi_pblock_destroy(pb);
- }
-
- slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "<= ipapwd_apply_mods: %d\n", ret);
-
- return ret;
+
+ return ret;
}
/* ascii hex output of bytes in "in"
@@ -867,14 +1237,13 @@ static void hexbuf(char *out, const uint8_t *in)
}
}
-/* Modify the userPassword attribute field of the entry */
-static int ipapwd_userpassword(Slapi_Entry *targetEntry, const char *newPasswd)
+/* Modify the Password attributes of the entry */
+static int ipapwd_SetPassword(struct ipapwd_data *data)
{
char *dn = NULL;
int ret = 0, i = 0;
Slapi_Mods *smods;
Slapi_Value **svals;
- time_t curtime;
struct tm utctime;
char timestr[16];
krb5_context krbctx;
@@ -890,13 +1259,12 @@ static int ipapwd_userpassword(Slapi_Entry *targetEntry, const char *newPasswd)
return LDAP_OPERATIONS_ERROR;
}
- slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "=> ipapwd_userpassword\n");
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "=> ipapwd_SetPassword\n");
smods = slapi_mods_new();
- dn = slapi_entry_get_ndn( targetEntry );
/* generate kerberos keys to be put into krbPrincipalKey */
- svals = encrypt_encode_key(krbctx, targetEntry, newPasswd);
+ svals = encrypt_encode_key(krbctx, data);
if (!svals) {
slapi_log_error(SLAPI_LOG_FATAL, "ipa_pwd_extop", "key encryption/encoding failed\n");
krb5_free_context(krbctx);
@@ -908,32 +1276,49 @@ static int ipapwd_userpassword(Slapi_Entry *targetEntry, const char *newPasswd)
slapi_mods_add_mod_values(smods, LDAP_MOD_REPLACE, "krbPrincipalKey", svals);
/* change Last Password Change field with the current date */
- curtime = time(NULL);
- if (!gmtime_r(&curtime, &utctime)) {
+ if (!gmtime_r(&(data->timeNow), &utctime)) {
slapi_log_error(SLAPI_LOG_FATAL, "ipa_pwd_extop", "failed to retrieve current date (buggy gmtime_r ?)\n");
+ free(svals);
return LDAP_OPERATIONS_ERROR;
}
if (utctime.tm_year > 8099 || utctime.tm_mon > 11 || utctime.tm_mday > 31 ||
utctime.tm_hour > 23 || utctime.tm_min > 59 || utctime.tm_sec > 59) {
slapi_log_error(SLAPI_LOG_FATAL, "ipa_pwd_extop", "retrieved a bad date (buggy gmtime_r ?)\n");
+ free(svals);
return LDAP_OPERATIONS_ERROR;
}
-
snprintf(timestr, 16, "%04d%02d%02d%02d%02d%02dZ", utctime.tm_year+1900, utctime.tm_mon+1,
utctime.tm_mday, utctime.tm_hour, utctime.tm_min, utctime.tm_sec);
-
slapi_mods_add_string(smods, LDAP_MOD_REPLACE, "krbLastPwdChange", timestr);
- /* TODO: krbPasswordExpiration, (krbMaxTicketLife, krbMaxRenewableAge, krbTicketFlags ?) */
+
+ /* set Password Expiration date */
+ if (!gmtime_r(&(data->expireTime), &utctime)) {
+ slapi_log_error(SLAPI_LOG_FATAL, "ipa_pwd_extop", "failed to retrieve current date (buggy gmtime_r ?)\n");
+ free(svals);
+ return LDAP_OPERATIONS_ERROR;
+ }
+ if (utctime.tm_year > 8099 || utctime.tm_mon > 11 || utctime.tm_mday > 31 ||
+ utctime.tm_hour > 23 || utctime.tm_min > 59 || utctime.tm_sec > 59) {
+ slapi_log_error(SLAPI_LOG_FATAL, "ipa_pwd_extop", "retrieved a bad date (buggy gmtime_r ?)\n");
+ free(svals);
+ return LDAP_OPERATIONS_ERROR;
+ }
+ snprintf(timestr, 16, "%04d%02d%02d%02d%02d%02dZ", utctime.tm_year+1900, utctime.tm_mon+1,
+ utctime.tm_mday, utctime.tm_hour, utctime.tm_min, utctime.tm_sec);
+ slapi_mods_add_string(smods, LDAP_MOD_REPLACE, "krbPasswordExpiration", timestr);
sambaSamAccount = slapi_value_new_string("sambaSamAccount");
- if (slapi_entry_attr_has_syntax_value(targetEntry, "objectClass", sambaSamAccount)) {
+ if (slapi_entry_attr_has_syntax_value(data->target, "objectClass", sambaSamAccount)) {
/* TODO: retrieve if we want to store the LM hash or not */
ntlm_flags = KTF_LM_HASH | KTF_NT_HASH;
}
slapi_value_free(&sambaSamAccount);
if (ntlm_flags) {
- if (encode_ntlm_keys((char *)newPasswd, ntlm_flags, &ntlm) != 0) {
+ char *password = strdup(data->password);
+ if (encode_ntlm_keys(password, ntlm_flags, &ntlm) != 0) {
+ free(svals);
+ free(password);
return LDAP_OPERATIONS_ERROR;
}
if (ntlm_flags & KTF_LM_HASH) {
@@ -946,19 +1331,20 @@ static int ipapwd_userpassword(Slapi_Entry *targetEntry, const char *newPasswd)
nt[32] = '\0';
slapi_mods_add_string(smods, LDAP_MOD_REPLACE, "sambaNTPassword", nt);
}
+ free(password);
}
- /* TODO !!!
+ /* FIXME:
* instead of replace we should use a delete/add so that we are
* completely sure nobody else modified the entry meanwhile and
* fail if that's the case */
/* commit changes */
- ret = ipapwd_apply_mods(dn, smods);
+ ret = ipapwd_apply_mods(data->dn, smods);
slapi_mods_free(&smods);
- slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "<= ipapwd_userpassword: %d\n", ret);
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "<= ipapwd_SetPassword: %d\n", ret);
for (i = 0; svals[i]; i++) {
slapi_value_free(&svals[i]);
@@ -1012,7 +1398,7 @@ static int ipapwd_generate_basic_passwd( int passlen, char **genpasswd )
/* Password Modify Extended operation plugin function */
int
-ipapwd_extop( Slapi_PBlock *pb )
+ipapwd_extop(Slapi_PBlock *pb)
{
char *oid = NULL;
char *bindDN = NULL;
@@ -1027,9 +1413,9 @@ ipapwd_extop( Slapi_PBlock *pb )
struct berval *extop_value = NULL;
BerElement *ber = NULL;
Slapi_Entry *targetEntry=NULL;
- /* Slapi_DN sdn; */
+ struct ipapwd_data pwdata;
- slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "=> ipa_pwd_extop\n");
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "=> ipapwd_extop\n");
/* Before going any further, we'll make sure that the right extended operation plugin
* has been called: i.e., the OID shipped whithin the extended operation request must
@@ -1259,48 +1645,83 @@ parse_req_done:
the bind operation (or used sasl or client cert auth or OS creds) */
slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "oldPasswd provided, but we will ignore it");
}
-
- /* Now we're ready to make actual password change */
- ret = ipapwd_userpassword(targetEntry, newPasswd);
- if (ret != LDAP_SUCCESS) {
- /* Failed to modify the password, e.g. because insufficient access allowed */
- errMesg = "Failed to update password\n";
- rc = ret;
+ pwdata.target = targetEntry;
+ pwdata.dn = dn;
+ pwdata.password = newPasswd;
+ pwdata.timeNow = time(NULL);
+ pwdata.lastPwChange = 0;
+ pwdata.expireTime = 0;
+
+ pwdata.adminChange = 1;
+ /* if it is a regular password change */
+ if (0 == strcmp(dn, bindDN)) {
+ pwdata.adminChange = 0;
+ } else {
+ char **bindexp;
+ bindexp = ldap_explode_dn(bindDN, 0);
+ if (bindexp) {
+ if ((strncasecmp(bindexp[0], "krbprincipalname=kadmin/changepw@", 33) == 0) &&
+ (strcasecmp(&(bindexp[0][33]), ipa_realm) == 0)) {
+ pwdata.adminChange = 0;
+ }
+ ldap_value_free(bindexp);
+ }
+ }
+
+ /* check the policy */
+ ret = ipapwd_CheckPolicy(&pwdata);
+ if (ret) {
+ errMesg = "Password Fails to meet minimum strength criteria";
+ slapi_pwpolicy_make_response_control(pb, -1, -1, ret & 0x0F);
+ rc = LDAP_CONSTRAINT_VIOLATION;
goto free_and_return;
}
- slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "<= ipa_pwd_extop: %d\n", rc);
+ /* Now we're ready to set the kerberos key material */
+ ret = ipapwd_SetPassword(&pwdata);
+ if (ret != LDAP_SUCCESS) {
+ /* Failed to modify the password, e.g. because insufficient access allowed */
+ errMesg = "Failed to update password\n";
+ if (ret > 0) {
+ rc = ret;
+ } else {
+ rc = LDAP_OPERATIONS_ERROR;
+ }
+ goto free_and_return;
+ }
+
+ slapi_log_error(SLAPI_LOG_TRACE, "ipa_pwd_extop", "<= ipapwd_extop: %d\n", rc);
/* Free anything that we allocated above */
- free_and_return:
+free_and_return:
slapi_ch_free_string(&oldPasswd);
slapi_ch_free_string(&newPasswd);
/* Either this is the same pointer that we allocated and set above,
* or whoever used it should have freed it and allocated a new
* value that we need to free here */
- slapi_pblock_get( pb, SLAPI_ORIGINAL_TARGET, &dn );
+ slapi_pblock_get(pb, SLAPI_ORIGINAL_TARGET, &dn);
slapi_ch_free_string(&dn);
- slapi_pblock_set( pb, SLAPI_ORIGINAL_TARGET, NULL );
+ slapi_pblock_set(pb, SLAPI_ORIGINAL_TARGET, NULL);
slapi_ch_free_string(&authmethod);
- if ( targetEntry != NULL ){
- slapi_entry_free (targetEntry);
+ if (targetEntry != NULL) {
+ slapi_entry_free(targetEntry);
}
- if ( ber != NULL ){
+ if (ber != NULL) {
ber_free(ber, 1);
ber = NULL;
}
- slapi_log_error( SLAPI_LOG_PLUGIN, "ipa_pwd_extop",
- errMesg ? errMesg : "success" );
- slapi_send_ldap_result( pb, rc, NULL, errMesg, 0, NULL );
+ slapi_log_error(SLAPI_LOG_PLUGIN, "ipa_pwd_extop",
+ errMesg ? errMesg : "success");
+ slapi_send_ldap_result(pb, rc, NULL, errMesg, 0, NULL);
- return( SLAPI_PLUGIN_EXTENDED_SENT_RESULT );
+ return SLAPI_PLUGIN_EXTENDED_SENT_RESULT;
-}/* ipa_pwd_extop */
+} /* ipapwd_extop */
static char *ipapwd_oid_list[] = {
@@ -1310,7 +1731,7 @@ static char *ipapwd_oid_list[] = {
static char *ipapwd_name_list[] = {
- "ipa_pwd_extop",
+ "ipapwd_extop",
NULL
};
@@ -1351,7 +1772,11 @@ int ipapwd_start( Slapi_PBlock *pb )
krberr = krb5_init_context(&krbctx);
if (krberr) {
- slapi_log_error(SLAPI_LOG_FATAL, "ipa_pwd_extop", "krb5_init_context failed\n");
+ slapi_log_error(SLAPI_LOG_FATAL, "ipapwd_start", "krb5_init_context failed\n");
+ return LDAP_OPERATIONS_ERROR;
+ }
+ if (krb5_get_default_realm(krbctx, &ipa_realm)) {
+ krb5_free_context(krbctx);
return LDAP_OPERATIONS_ERROR;
}
From 3e715a04cf95de0add2c37d6cd5985c43de47dab Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Wed, 14 Nov 2007 10:49:03 -0500
Subject: [PATCH 18/60] Add an editors group. This is used to generally grant
access for users to edit other users (the Edit link won't appear otherwise).
Additional delegation is need to grant permission to individual attributes.
Update the failed login page to indicate that it is a permission issue. Don't
allow access to policy at all for non-admins. By default users can only edit
themselves.
---
.../ipagui/subcontrollers/delegation.py | 10 ++---
.../ipa-gui/ipagui/subcontrollers/group.py | 4 +-
.../ipagui/subcontrollers/ipapolicy.py | 7 +--
.../ipa-gui/ipagui/subcontrollers/policy.py | 2 +-
.../ipa-gui/ipagui/subcontrollers/user.py | 13 +++++-
.../ipa-gui/ipagui/templates/groupshow.kid | 6 ++-
.../ipa-gui/ipagui/templates/loginfailed.kid | 43 +++++++------------
.../ipa-gui/ipagui/templates/master.kid | 10 +++--
.../ipa-gui/ipagui/templates/usershow.kid | 6 ++-
.../ipa-install/share/bootstrap-template.ldif | 10 +++++
10 files changed, 63 insertions(+), 48 deletions(-)
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py b/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
index d7149265e..142d34430 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
@@ -35,7 +35,7 @@ class DelegationController(IPAController):
raise turbogears.redirect("/delegate/list")
@expose("ipagui.templates.delegatenew")
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def new(self):
"""Display delegate page"""
client = self.get_ipaclient()
@@ -46,7 +46,7 @@ class DelegationController(IPAController):
return dict(form=delegate_form, delegate=delegate)
@expose()
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def create(self, **kw):
"""Creates a new delegation"""
self.restrict_post()
@@ -107,7 +107,7 @@ class DelegationController(IPAController):
raise turbogears.redirect('/delegate/list')
@expose("ipagui.templates.delegateedit")
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def edit(self, acistr, tg_errors=None):
"""Display delegate page"""
if tg_errors:
@@ -134,7 +134,7 @@ class DelegationController(IPAController):
@expose()
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def update(self, **kw):
"""Display delegate page"""
self.restrict_post()
@@ -230,7 +230,7 @@ class DelegationController(IPAController):
fields=ipagui.forms.delegate.DelegateFields())
@expose()
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def delete(self, acistr):
"""Display delegate page"""
self.restrict_post()
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/group.py b/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
index b412b6d15..0df2d3c8c 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/group.py
@@ -168,7 +168,7 @@ class GroupController(IPAController):
@expose("ipagui.templates.groupedit")
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def edit(self, cn, tg_errors=None):
"""Displays the edit group form"""
if tg_errors:
@@ -214,7 +214,7 @@ class GroupController(IPAController):
raise turbogears.redirect('/group/show', uid=cn)
@expose()
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def update(self, **kw):
"""Updates an existing group"""
self.restrict_post()
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/ipapolicy.py b/ipa-server/ipa-gui/ipagui/subcontrollers/ipapolicy.py
index a1c1a9f03..5d9024275 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/ipapolicy.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/ipapolicy.py
@@ -26,11 +26,12 @@ ipapolicy_edit_form = ipagui.forms.ipapolicy.IPAPolicyForm()
class IPAPolicyController(IPAController):
@expose()
+ @identity.require(identity.in_group("admins"))
def index(self):
raise turbogears.redirect("/ipapolicy/show")
@expose("ipagui.templates.ipapolicyshow")
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def show(self, tg_errors=None):
"""Displays the one policy page"""
@@ -45,7 +46,7 @@ class IPAPolicyController(IPAController):
return dict(ipapolicy=ipapolicy,fields=ipagui.forms.ipapolicy.IPAPolicyFields())
@expose("ipagui.templates.ipapolicyedit")
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def edit(self, tg_errors=None):
"""Displays the edit IPA policy form"""
if tg_errors:
@@ -68,7 +69,7 @@ class IPAPolicyController(IPAController):
@expose()
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def update(self, **kw):
"""Display delegate page"""
self.restrict_post()
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/policy.py b/ipa-server/ipa-gui/ipagui/subcontrollers/policy.py
index a9fd3271f..1f2e45876 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/policy.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/policy.py
@@ -23,7 +23,7 @@ log = logging.getLogger(__name__)
class PolicyController(IPAController):
@expose("ipagui.templates.policyindex")
- @identity.require(identity.not_anonymous())
+ @identity.require(identity.in_group("admins"))
def index(self, tg_errors=None):
"""Displays the one policy page"""
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
index a527c0983..bf77b113f 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
@@ -96,7 +96,7 @@ class UserController(IPAController):
raise turbogears.redirect("/user/list")
@expose("ipagui.templates.usernew")
- @identity.require(identity.in_group("admins"))
+ @identity.require(identity.in_any_group("admins","editors"))
def new(self, tg_errors=None):
"""Displays the new user form"""
if tg_errors:
@@ -106,7 +106,7 @@ class UserController(IPAController):
return dict(form=user_new_form, user={})
@expose()
- @identity.require(identity.in_group("admins"))
+ @identity.require(identity.in_any_group("admins","editors"))
def create(self, **kw):
"""Creates a new user"""
self.restrict_post()
@@ -377,6 +377,15 @@ class UserController(IPAController):
kw = self.fix_incoming_fields(kw, 'pager', 'pagers')
kw = self.fix_incoming_fields(kw, 'homephone', 'homephones')
+ # admins and editors can update anybody. A user can only update
+ # themselves. We need this check because it is very easy to guess
+ # the edit URI.
+ if ((not 'admins' in turbogears.identity.current.groups and
+ not 'editors' in turbogears.identity.current.groups) and
+ (kw.get('uid') != turbogears.identity.current.display_name)):
+ turbogears.flash("You do not have permission to update this user.")
+ raise turbogears.redirect('/user/show', uid=kw.get('uid'))
+
# Decode the group data, in case we need to round trip
user_groups_dicts = loads(b64decode(kw.get('user_groups_data')))
diff --git a/ipa-server/ipa-gui/ipagui/templates/groupshow.kid b/ipa-server/ipa-gui/ipagui/templates/groupshow.kid
index f0d1ddfbb..a58220344 100644
--- a/ipa-server/ipa-gui/ipagui/templates/groupshow.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/groupshow.kid
@@ -12,7 +12,8 @@ edit_url = tg.url('/group/edit', cn=group.get('cn')[0])
View Group
-
@@ -84,7 +85,8 @@ edit_url = tg.url('/group/edit', cn=group.get('cn')[0])
-
diff --git a/ipa-server/ipa-gui/ipagui/templates/loginfailed.kid b/ipa-server/ipa-gui/ipagui/templates/loginfailed.kid
index 84896be5c..b31db82a7 100644
--- a/ipa-server/ipa-gui/ipagui/templates/loginfailed.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/loginfailed.kid
@@ -1,35 +1,24 @@
-
-
-
+
+
-
- Login Failure
+
+Permission Denied
-
+
From 02e5a6599bf6c39b05b4b5ea8859f35942ce2347 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Tue, 13 Nov 2007 17:51:29 -0500
Subject: [PATCH 21/60] Forgot to include FQDN in the substitition list
---
ipa-server/ipaserver/httpinstance.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ipa-server/ipaserver/httpinstance.py b/ipa-server/ipaserver/httpinstance.py
index 0433025b2..b505d73a8 100644
--- a/ipa-server/ipaserver/httpinstance.py
+++ b/ipa-server/ipaserver/httpinstance.py
@@ -56,7 +56,7 @@ class HTTPInstance(service.Service):
service.Service.__init__(self, "httpd")
def create_instance(self, realm, fqdn):
- self.sub_dict = { "REALM" : realm }
+ self.sub_dict = { "REALM" : realm, "FQDN": fqdn }
self.fqdn = fqdn
self.realm = realm
From abdd34407361389c13bf4b8af6c476a34e243677 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Wed, 14 Nov 2007 14:11:29 -0500
Subject: [PATCH 22/60] Remove reference to a bogus system and make the error
message more generic
---
ipa-server/xmlrpc-server/unauthorized.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ipa-server/xmlrpc-server/unauthorized.html b/ipa-server/xmlrpc-server/unauthorized.html
index 98e037e58..23a8d5c7d 100644
--- a/ipa-server/xmlrpc-server/unauthorized.html
+++ b/ipa-server/xmlrpc-server/unauthorized.html
@@ -7,7 +7,7 @@ Unable to verify your Kerberos credentials. Please make sure
that you have valid Kerberos tickets (obtainable via kinit), and that you
have configured your
browser correctly . If you are still unable to access
-the idm wiki, please contact the helpdesk on for additional assistance.
+the IPA Web interface, please contact the helpdesk on for additional assistance.
From 4d96b37de1d6ebd173909a839ecf19386932d9a5 Mon Sep 17 00:00:00 2001
From: Karl MacMillan
Date: Thu, 15 Nov 2007 11:08:03 -0500
Subject: [PATCH 23/60] Initialize memberof patch from Pete Rowley.
---
ipa-server/ipa-install/share/Makefile.am | 1 +
ipa-server/ipaserver/dsinstance.py | 16 +++++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/ipa-server/ipa-install/share/Makefile.am b/ipa-server/ipa-install/share/Makefile.am
index b103d5670..b187b5df0 100644
--- a/ipa-server/ipa-install/share/Makefile.am
+++ b/ipa-server/ipa-install/share/Makefile.am
@@ -22,6 +22,7 @@ app_DATA = \
referint-conf.ldif \
dna-posix.ldif \
master-entry.ldif \
+ memberof-task.ldif \
$(NULL)
EXTRA_DIST = \
diff --git a/ipa-server/ipaserver/dsinstance.py b/ipa-server/ipaserver/dsinstance.py
index 9a539470e..0cab17440 100644
--- a/ipa-server/ipaserver/dsinstance.py
+++ b/ipa-server/ipaserver/dsinstance.py
@@ -35,6 +35,9 @@ 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)
+ text = fd.read()
+ print text
+
def realm_to_suffix(realm_name):
s = realm_name.split(".")
terms = ["dc=" + x.lower() for x in s]
@@ -78,7 +81,7 @@ class DsInstance(service.Service):
self.dm_password = dm_password
self.__setup_sub_dict()
- self.start_creation(11, "Configuring directory server:")
+ self.start_creation(15, "Configuring directory server:")
self.__create_ds_user()
self.__create_instance()
self.__add_default_schemas()
@@ -97,6 +100,7 @@ class DsInstance(service.Service):
self.__config_uidgid_gen_first_master()
self.__add_default_layout()
self.__add_master_entry_first_master()
+ self.__init_memberof()
self.step("configuring directoy to start on boot")
@@ -177,6 +181,16 @@ class DsInstance(service.Service):
logging.critical("Failed to load memberof-conf.ldif: %s" % str(e))
memberof_fd.close()
+ def __init_memberof(self):
+ self.step("initializing group membership")
+ memberof_txt = template_file(SHARE_DIR + "memberof-task.ldif", self.sub_dict)
+ memberof_fd = write_tmp_file(memberof_txt)
+ try:
+ ldap_mod(memberof_fd, "cn=Directory Manager", self.dm_password)
+ except subprocess.CalledProcessError, e:
+ logging.critical("Failed to load memberof-conf.ldif: %s" % str(e))
+ memberof_fd.close()
+
def __add_referint_module(self):
self.step("enabling referential integrity plugin")
referint_txt = template_file(SHARE_DIR + "referint-conf.ldif", self.sub_dict)
From bfcc044db22f1be48f180c25283b6858999e1642 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Thu, 15 Nov 2007 10:27:59 -0500
Subject: [PATCH 24/60] If unable to connect to the XML-RPC server print a more
useful error msg.
---
ipa-admintools/ipa-adddelegation | 8 ++++++--
ipa-admintools/ipa-addgroup | 8 ++++++--
ipa-admintools/ipa-adduser | 8 ++++++--
ipa-admintools/ipa-deldelegation | 13 +++++++++++++
ipa-admintools/ipa-delgroup | 8 ++++++--
ipa-admintools/ipa-deluser | 8 ++++++--
ipa-admintools/ipa-findgroup | 6 +++++-
ipa-admintools/ipa-finduser | 6 +++++-
ipa-admintools/ipa-groupmod | 8 ++++++--
ipa-admintools/ipa-listdelegation | 14 ++++++++++++--
ipa-admintools/ipa-moddelegation | 8 ++++++--
ipa-admintools/ipa-passwd | 13 +++++++++++++
ipa-admintools/ipa-usermod | 8 ++++++--
13 files changed, 96 insertions(+), 20 deletions(-)
diff --git a/ipa-admintools/ipa-adddelegation b/ipa-admintools/ipa-adddelegation
index 3ac053e57..53bd43ce2 100644
--- a/ipa-admintools/ipa-adddelegation
+++ b/ipa-admintools/ipa-adddelegation
@@ -31,6 +31,7 @@ import xmlrpclib
import kerberos
import krbV
import ldap
+import errno
def usage():
print "ipa-adddelgation [-a|--attributes attr1,attr2,..,attrn] [-s|--source STRING] [-t|--target STRING] name"
@@ -113,8 +114,11 @@ def main():
aci_entry.setValue('aci', new_aci.export_to_string())
client.update_entry(aci_entry)
- except xmlrpclib.Fault, f:
- print f.faultString
+ except xmlrpclib.Fault, fault:
+ if fault.faultCode == errno.ECONNREFUSED:
+ print "The IPA XML-RPC service is not responding."
+ else:
+ print fault.faultString
return 1
except kerberos.GSSError, e:
print "Could not initialize GSSAPI: %s/%s" % (e[0][0][0], e[0][1][0])
diff --git a/ipa-admintools/ipa-addgroup b/ipa-admintools/ipa-addgroup
index 97dfd5f7b..15d42a91e 100644
--- a/ipa-admintools/ipa-addgroup
+++ b/ipa-admintools/ipa-addgroup
@@ -30,6 +30,7 @@ import ipa.ipaerror
import xmlrpclib
import kerberos
import ldap
+import errno
def usage():
print "ipa-addgroup [-d|--description STRING] group"
@@ -95,8 +96,11 @@ def main():
client = ipaclient.IPAClient()
client.add_group(group)
print cn + " successfully added"
- except xmlrpclib.Fault, f:
- print f.faultString
+ except xmlrpclib.Fault, fault:
+ if fault.faultCode == errno.ECONNREFUSED:
+ print "The IPA XML-RPC service is not responding."
+ else:
+ print fault.faultString
return 1
except kerberos.GSSError, e:
print "Could not initialize GSSAPI: %s/%s" % (e[0][0][0], e[0][1][0])
diff --git a/ipa-admintools/ipa-adduser b/ipa-admintools/ipa-adduser
index d82de8955..bb97a0d67 100644
--- a/ipa-admintools/ipa-adduser
+++ b/ipa-admintools/ipa-adduser
@@ -31,6 +31,7 @@ import kerberos
import krbV
import ldap
import getpass
+import errno
def usage():
print "ipa-adduser [-c|--gecos STRING] [-d|--directory STRING] [-f|--firstname STRING] [-l|--lastname STRING] user"
@@ -210,8 +211,11 @@ def main():
try:
client = ipaclient.IPAClient()
client.add_user(user)
- except xmlrpclib.Fault, f:
- print f.faultString
+ except xmlrpclib.Fault, fault:
+ if fault.faultCode == errno.ECONNREFUSED:
+ print "The IPA XML-RPC service is not responding."
+ else:
+ print fault.faultString
return 1
except kerberos.GSSError, e:
print "Could not initialize GSSAPI: %s/%s" % (e[0][0][0], e[0][1][0])
diff --git a/ipa-admintools/ipa-deldelegation b/ipa-admintools/ipa-deldelegation
index 93e39548a..7ad17c38b 100644
--- a/ipa-admintools/ipa-deldelegation
+++ b/ipa-admintools/ipa-deldelegation
@@ -26,6 +26,7 @@ import ipa.config
import xmlrpclib
import kerberos
import copy
+import errno
import ipa.aci
from ipa import ipaerror
@@ -85,12 +86,24 @@ def main():
aci_entry.setValue('aci', new_aci_str_list)
client.update_entry(aci_entry)
+ except xmlrpclib.Fault, fault:
+ if fault.faultCode == errno.ECONNREFUSED:
+ print "The IPA XML-RPC service is not responding."
+ else:
+ print fault.faultString
+ return 1
except (SyntaxError, ipaerror.IPAError), e:
print "Delegation deletion failed: " + str(e)
return 1
except kerberos.GSSError, e:
print "Could not initialize GSSAPI: %s/%s" % (e[0][0][0], e[0][1][0])
return 1
+ except xmlrpclib.ProtocolError, e:
+ print "Unable to connect to IPA server: %s" % (e.errmsg)
+ return 1
+ except ipa.ipaerror.IPAError, e:
+ print "%s" % (e.message)
+ return 1
return 0
diff --git a/ipa-admintools/ipa-delgroup b/ipa-admintools/ipa-delgroup
index 08ea73771..b4f946065 100644
--- a/ipa-admintools/ipa-delgroup
+++ b/ipa-admintools/ipa-delgroup
@@ -23,6 +23,7 @@ from optparse import OptionParser
import ipa
import ipa.ipaclient as ipaclient
import ipa.config
+import errno
import xmlrpclib
import kerberos
@@ -54,8 +55,11 @@ def main():
print args[1] + " successfully deleted"
else:
print args[1] + " " + ret
- except xmlrpclib.Fault, f:
- print f.faultString
+ except xmlrpclib.Fault, fault:
+ if fault.faultCode == errno.ECONNREFUSED:
+ print "The IPA XML-RPC service is not responding."
+ else:
+ print fault.faultString
return 1
except kerberos.GSSError, e:
print "Could not initialize GSSAPI: %s/%s" % (e[0][0][0], e[0][1][0])
diff --git a/ipa-admintools/ipa-deluser b/ipa-admintools/ipa-deluser
index d14961c84..3112420aa 100644
--- a/ipa-admintools/ipa-deluser
+++ b/ipa-admintools/ipa-deluser
@@ -23,6 +23,7 @@ from optparse import OptionParser
import ipa
import ipa.ipaclient as ipaclient
import ipa.config
+import errno
import xmlrpclib
import kerberos
@@ -61,8 +62,11 @@ def main():
print args[1] + " successfully %s" % msg
else:
print args[1] + " " + ret
- except xmlrpclib.Fault, f:
- print f.faultString
+ except xmlrpclib.Fault, fault:
+ if fault.faultCode == errno.ECONNREFUSED:
+ print "The IPA XML-RPC service is not responding."
+ else:
+ print fault.faultString
return 1
except kerberos.GSSError, e:
print "Could not initialize GSSAPI: %s/%s" % (e[0][0][0], e[0][1][0])
diff --git a/ipa-admintools/ipa-findgroup b/ipa-admintools/ipa-findgroup
index a876a0505..6953d4fd3 100644
--- a/ipa-admintools/ipa-findgroup
+++ b/ipa-admintools/ipa-findgroup
@@ -23,6 +23,7 @@ from optparse import OptionParser
import ipa.ipaclient as ipaclient
import ipa.config
+import errno
import sys
import xmlrpclib
import kerberos
@@ -87,7 +88,10 @@ def main():
print
except xmlrpclib.Fault, fault:
- print fault.faultString
+ if fault.faultCode == errno.ECONNREFUSED:
+ print "The IPA XML-RPC service is not responding."
+ else:
+ print fault.faultString
return 1
except kerberos.GSSError, e:
print "Could not initialize GSSAPI: %s/%s" % (e[0][0][0], e[0][1][0])
diff --git a/ipa-admintools/ipa-finduser b/ipa-admintools/ipa-finduser
index 3396ce45d..a6f052f1d 100644
--- a/ipa-admintools/ipa-finduser
+++ b/ipa-admintools/ipa-finduser
@@ -25,6 +25,7 @@ import ipa.config
import ipa.ipautil as ipautil
import base64
+import errno
import sys
import xmlrpclib
import kerberos
@@ -106,7 +107,10 @@ def main():
print
except xmlrpclib.Fault, fault:
- print fault.faultString
+ if fault.faultCode == errno.ECONNREFUSED:
+ print "The IPA XML-RPC service is not responding."
+ else:
+ print fault.faultString
return 1
except kerberos.GSSError, e:
print "Could not initialize GSSAPI: %s/%s" % (e[0][0][0], e[0][1][0])
diff --git a/ipa-admintools/ipa-groupmod b/ipa-admintools/ipa-groupmod
index 9145d19da..1e07e609f 100644
--- a/ipa-admintools/ipa-groupmod
+++ b/ipa-admintools/ipa-groupmod
@@ -29,6 +29,7 @@ import ipa.ipaerror
import xmlrpclib
import kerberos
import ldap
+import errno
def usage():
print "ipa-groupmod [-a|--add] [-r|--remove] user group"
@@ -140,8 +141,11 @@ def main():
client.update_group(group)
print args[1] + " successfully updated"
- except xmlrpclib.Fault, f:
- print f.faultString
+ except xmlrpclib.Fault, fault:
+ if fault.faultCode == errno.ECONNREFUSED:
+ print "The IPA XML-RPC service is not responding."
+ else:
+ print fault.faultString
return 1
except kerberos.GSSError, e:
print "Could not initialize GSSAPI: %s/%s" % (e[0][0][0], e[0][1][0])
diff --git a/ipa-admintools/ipa-listdelegation b/ipa-admintools/ipa-listdelegation
index 4c059c4a9..6999e5f83 100644
--- a/ipa-admintools/ipa-listdelegation
+++ b/ipa-admintools/ipa-listdelegation
@@ -26,6 +26,7 @@ import ipa.config
import operator
import xmlrpclib
import kerberos
+import errno
import ipa.aci
from ipa import ipaerror
@@ -52,12 +53,21 @@ def main():
client = ipaclient.IPAClient()
try:
aci_entry = client.get_aci_entry(aci_fields)
- except ipaerror.IPAError, e:
- print("Delegation list failed: " + str(e))
+ except xmlrpclib.Fault, fault:
+ if fault.faultCode == errno.ECONNREFUSED:
+ print "The IPA XML-RPC service is not responding."
+ else:
+ print fault.faultString
return 1
except kerberos.GSSError, e:
print "Could not initialize GSSAPI: %s/%s" % (e[0][0][0], e[0][1][0])
return 1
+ except xmlrpclib.ProtocolError, e:
+ print "Unable to connect to IPA server: %s" % (e.errmsg)
+ return 1
+ except ipaerror.IPAError, e:
+ print("Delegation list failed: " + str(e))
+ return 1
aci_str_list = aci_entry.getValues('aci')
if aci_str_list is None:
diff --git a/ipa-admintools/ipa-moddelegation b/ipa-admintools/ipa-moddelegation
index 03b0dc4a8..103c0586d 100644
--- a/ipa-admintools/ipa-moddelegation
+++ b/ipa-admintools/ipa-moddelegation
@@ -32,6 +32,7 @@ import kerberos
import krbV
import ldap
import copy
+import errno
aci_fields = ['*', 'aci']
@@ -142,8 +143,11 @@ def main():
aci_entry.setValue('aci', new_aci_str_list)
client.update_entry(aci_entry)
- except xmlrpclib.Fault, f:
- print f.faultString
+ except xmlrpclib.Fault, fault:
+ if fault.faultCode == errno.ECONNREFUSED:
+ print "The IPA XML-RPC service is not responding."
+ else:
+ print fault.faultString
return 1
except kerberos.GSSError, e:
print "Could not initialize GSSAPI: %s/%s" % (e[0][0][0], e[0][1][0])
diff --git a/ipa-admintools/ipa-passwd b/ipa-admintools/ipa-passwd
index 59d30e2e4..93cb5f72c 100644
--- a/ipa-admintools/ipa-passwd
+++ b/ipa-admintools/ipa-passwd
@@ -29,6 +29,7 @@ import kerberos
import krbV
import ldap
import getpass
+import errno
def usage():
print "ipa-passwd [user]"
@@ -98,6 +99,18 @@ def main():
try:
client = ipaclient.IPAClient()
client.modifyPassword(principal, None, password)
+ except xmlrpclib.Fault, fault:
+ if fault.faultCode == errno.ECONNREFUSED:
+ print "The IPA XML-RPC service is not responding."
+ else:
+ print fault.faultString
+ return 1
+ except kerberos.GSSError, e:
+ print "Could not initialize GSSAPI: %s/%s" % (e[0][0][0], e[0][1][0])
+ return 1
+ except xmlrpclib.ProtocolError, e:
+ print "Unable to connect to IPA server: %s" % (e.errmsg)
+ return 1
except ipa.ipaerror.IPAError, e:
print "%s" % (e.message)
return 1
diff --git a/ipa-admintools/ipa-usermod b/ipa-admintools/ipa-usermod
index 50e86661d..4623d7448 100644
--- a/ipa-admintools/ipa-usermod
+++ b/ipa-admintools/ipa-usermod
@@ -29,6 +29,7 @@ import ipa.config
import xmlrpclib
import kerberos
import ldap
+import errno
def usage():
print "ipa-usermod [-c|--gecos STRING] [-d|--directory STRING] [-f|--firstname STRING] [-l|--lastname STRING] [-s|--shell STRING] [--add attribute=value] [--del attribute] [--set attribute=value] user"
@@ -231,8 +232,11 @@ def main():
try:
client.update_user(user)
- except xmlrpclib.Fault, f:
- print f.faultString
+ except xmlrpclib.Fault, fault:
+ if fault.faultCode == errno.ECONNREFUSED:
+ print "The IPA XML-RPC service is not responding."
+ else:
+ print fault.faultString
return 1
except kerberos.GSSError, e:
print "Could not initialize GSSAPI: %s/%s" % (e[0][0][0], e[0][1][0])
From 6f268a185c86e44d0ffa06160b422a07a396c5d1 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Thu, 15 Nov 2007 10:57:26 -0500
Subject: [PATCH 25/60] Broke invididual Requires and BuildRequires onto
separate lines and reordered them Added python-tgexpandingformwidget as a
dependency Require at least fedora-ds-base 1.1
---
ipa-server/freeipa-server.spec | 39 ++++++++++++++++++++++++++-----
ipa-server/freeipa-server.spec.in | 39 ++++++++++++++++++++++++++-----
2 files changed, 66 insertions(+), 12 deletions(-)
diff --git a/ipa-server/freeipa-server.spec b/ipa-server/freeipa-server.spec
index 918e17c3b..847daa005 100755
--- a/ipa-server/freeipa-server.spec
+++ b/ipa-server/freeipa-server.spec
@@ -1,6 +1,6 @@
Name: freeipa-server
Version: 0.4.1
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: FreeIPA authentication server
Group: System Environment/Base
@@ -9,10 +9,33 @@ URL: http://www.freeipa.org
Source0: %{name}-%{version}.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-BuildRequires: fedora-ds-base-devel openldap-devel krb5-devel nss-devel mozldap-devel openssl-devel
+BuildRequires: fedora-ds-base-devel >= 1.1
+BuildRequires: mozldap-devel
+BuildRequires: openssl-devel
+BuildRequires: openldap-devel
+BuildRequires: krb5-devel
+BuildRequires: nss-devel
-Requires: python fedora-ds-base krb5-server krb5-server-ldap nss-tools openldap-clients httpd mod_python mod_auth_kerb python-ldap freeipa-python ntp cyrus-sasl-gssapi nss TurboGears python-krbV acl freeipa-admintools
+Requires: freeipa-python
+Requires: freeipa-admintools
+Requires: fedora-ds-base >= 1.1
+Requires: openldap-clients
+Requires: nss
+Requires: nss-tools
+Requires: krb5-server
+Requires: krb5-server-ldap
+Requires: cyrus-sasl-gssapi
+Requires: ntp
+Requires: httpd
+Requires: mod_python
+Requires: mod_auth_kerb
Requires: mod_nss >= 1.0.7-2
+Requires: python-ldap
+Requires: python
+Requires: python-krbV
+Requires: TurboGears
+Requires: python-tgexpandingformwidget
+Requires: acl
Requires: freeradius >= 1.1.7
%define httpd_conf /etc/httpd/conf.d
@@ -61,7 +84,13 @@ rm -rf %{buildroot}
%changelog
-* Thu Nov 1 2007 Karl MacMillan - 0.4.1-1
+* Thu Nov 15 2007 Rob Crittenden - 0.4.1-2
+- Broke invididual Requires and BuildRequires onto separate lines and
+ reordered them
+- Added python-tgexpandingformwidget as a dependency
+- Require at least fedora-ds-base 1.1
+
+* Thu Nov 1 2007 Karl MacMillan - 0.4.1-1
- Version bump for release
* Wed Oct 31 2007 Karl MacMillan - 0.4.0-6
@@ -98,5 +127,3 @@ rm -rf %{buildroot}
* Fri Jul 27 2007 Karl MacMillan - 0.1.0-1
- Initial rpm version
-
-
diff --git a/ipa-server/freeipa-server.spec.in b/ipa-server/freeipa-server.spec.in
index d40aaf32a..6c8afcb67 100644
--- a/ipa-server/freeipa-server.spec.in
+++ b/ipa-server/freeipa-server.spec.in
@@ -1,6 +1,6 @@
Name: freeipa-server
Version: VERSION
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: FreeIPA authentication server
Group: System Environment/Base
@@ -9,10 +9,33 @@ URL: http://www.freeipa.org
Source0: %{name}-%{version}.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-BuildRequires: fedora-ds-base-devel openldap-devel krb5-devel nss-devel mozldap-devel openssl-devel
+BuildRequires: fedora-ds-base-devel >= 1.1
+BuildRequires: mozldap-devel
+BuildRequires: openssl-devel
+BuildRequires: openldap-devel
+BuildRequires: krb5-devel
+BuildRequires: nss-devel
-Requires: python fedora-ds-base krb5-server krb5-server-ldap nss-tools openldap-clients httpd mod_python mod_auth_kerb python-ldap freeipa-python ntp cyrus-sasl-gssapi nss TurboGears python-krbV acl freeipa-admintools rpm
+Requires: freeipa-python
+Requires: freeipa-admintools
+Requires: fedora-ds-base >= 1.1
+Requires: openldap-clients
+Requires: nss
+Requires: nss-tools
+Requires: krb5-server
+Requires: krb5-server-ldap
+Requires: cyrus-sasl-gssapi
+Requires: ntp
+Requires: httpd
+Requires: mod_python
+Requires: mod_auth_kerb
Requires: mod_nss >= 1.0.7-2
+Requires: python-ldap
+Requires: python
+Requires: python-krbV
+Requires: TurboGears
+Requires: python-tgexpandingformwidget
+Requires: acl
Requires: freeradius >= 1.1.7
%define httpd_conf /etc/httpd/conf.d
@@ -61,7 +84,13 @@ rm -rf %{buildroot}
%changelog
-* Thu Nov 1 2007 Karl MacMillan - 0.4.1-1
+* Thu Nov 15 2007 Rob Crittenden - 0.4.1-2
+- Broke invididual Requires and BuildRequires onto separate lines and
+ reordered them
+- Added python-tgexpandingformwidget as a dependency
+- Require at least fedora-ds-base 1.1
+
+* Thu Nov 1 2007 Karl MacMillan - 0.4.1-1
- Version bump for release
* Wed Oct 31 2007 Karl MacMillan - 0.4.0-6
@@ -98,5 +127,3 @@ rm -rf %{buildroot}
* Fri Jul 27 2007 Karl MacMillan - 0.1.0-1
- Initial rpm version
-
-
From 949b4a0bf7ed8ce466617b9623e833cd26a46c13 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Thu, 15 Nov 2007 11:09:17 -0500
Subject: [PATCH 26/60] Check for existance of of the target file in
update_file. It used to silently fail if the file it was to update didn't
exist.
---
ipa-server/ipaserver/httpinstance.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/ipa-server/ipaserver/httpinstance.py b/ipa-server/ipaserver/httpinstance.py
index b505d73a8..60d33eedc 100644
--- a/ipa-server/ipaserver/httpinstance.py
+++ b/ipa-server/ipaserver/httpinstance.py
@@ -50,6 +50,10 @@ def update_file(filename, orig, subst):
else:
sys.stdout.write(p.sub(subst, line))
fileinput.close()
+ return 0
+ else:
+ print "File %s doesn't exist." % filename
+ return 1
class HTTPInstance(service.Service):
def __init__(self):
@@ -137,4 +141,5 @@ class HTTPInstance(service.Service):
def __set_mod_nss_port(self):
self.step("Setting mod_nss port to 443")
- update_file(NSS_CONF, '8443', '443')
+ if update_file(NSS_CONF, '8443', '443') != 0:
+ print "Updating %s failed." % NSS_CONF
From 816b3e2ea54392ae826429be955fdaedf53f11b2 Mon Sep 17 00:00:00 2001
From: Karl MacMillan
Date: Thu, 15 Nov 2007 12:45:44 -0500
Subject: [PATCH 27/60] Add memberof-task.ldif.
---
ipa-server/ipa-install/share/memberof-task.ldif | 7 +++++++
1 file changed, 7 insertions(+)
create mode 100644 ipa-server/ipa-install/share/memberof-task.ldif
diff --git a/ipa-server/ipa-install/share/memberof-task.ldif b/ipa-server/ipa-install/share/memberof-task.ldif
new file mode 100644
index 000000000..fefabba88
--- /dev/null
+++ b/ipa-server/ipa-install/share/memberof-task.ldif
@@ -0,0 +1,7 @@
+dn: cn=IPA install, cn=memberof task, cn=tasks, cn=config
+changetype: add
+objectClass: top
+objectClass: extensibleObject
+cn: IPA install
+basedn: $SUFFIX
+filter: (objectclass=*)
From 3e24df161b6f3b4946cf702aa780008069161406 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Thu, 15 Nov 2007 13:13:35 -0500
Subject: [PATCH 28/60] Replace references to Person and People with User and
Users
---
ipa-server/ipa-gui/ipagui/subcontrollers/user.py | 6 +++---
ipa-server/ipa-gui/ipagui/templates/master.kid | 4 ++--
ipa-server/ipa-gui/ipagui/templates/useredit.kid | 4 ++--
ipa-server/ipa-gui/ipagui/templates/usereditform.kid | 8 ++++----
ipa-server/ipa-gui/ipagui/templates/userlayout.kid | 4 ++--
ipa-server/ipa-gui/ipagui/templates/userlist.kid | 8 ++++----
ipa-server/ipa-gui/ipagui/templates/usernew.kid | 4 ++--
ipa-server/ipa-gui/ipagui/templates/usernewform.kid | 4 ++--
ipa-server/ipa-gui/ipagui/templates/usershow.kid | 8 ++++----
9 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
index 290ad25cb..7d266f0d5 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
@@ -183,7 +183,7 @@ class UserController(IPAController):
rv = client.add_user(new_user)
except ipaerror.exception_for(ipaerror.LDAP_DUPLICATE):
- turbogears.flash("Person with login '%s' already exists" %
+ turbogears.flash("User with login '%s' already exists" %
kw.get('uid'))
return dict(form=user_new_form, user=kw,
tg_template='ipagui.templates.usernew')
@@ -219,7 +219,7 @@ class UserController(IPAController):
try:
client.modifyPassword(user_dict['krbprincipalname'], "", kw.get('userpassword'))
except ipaerror.IPAError, e:
- message = "Person successfully created. "
+ message = "User successfully created. "
message += "There was an error setting the password. "
turbogears.flash(message)
return dict(form=user_edit_form, user=user_dict,
@@ -242,7 +242,7 @@ class UserController(IPAController):
failed_adds = dnadds
if len(failed_adds) > 0:
- message = "Person successfully created. "
+ message = "User successfully created. "
message += "There was an error adding groups. "
message += "Failures have been preserved in the add/remove lists."
turbogears.flash(message)
diff --git a/ipa-server/ipa-gui/ipagui/templates/master.kid b/ipa-server/ipa-gui/ipagui/templates/master.kid
index 6b97c73fd..12e54fa1d 100644
--- a/ipa-server/ipa-gui/ipagui/templates/master.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/master.kid
@@ -70,8 +70,8 @@
- Edit Person
+ Edit User
+ value="Update User"/>
@@ -847,11 +847,11 @@ from ipagui.helpers import ipahelper
+ value="Update User"/>
diff --git a/ipa-server/ipa-gui/ipagui/templates/userlayout.kid b/ipa-server/ipa-gui/ipagui/templates/userlayout.kid
index bbeb81399..c4e8104e6 100644
--- a/ipa-server/ipa-gui/ipagui/templates/userlayout.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/userlayout.kid
@@ -15,8 +15,8 @@
diff --git a/ipa-server/ipa-gui/ipagui/templates/userlist.kid b/ipa-server/ipa-gui/ipagui/templates/userlist.kid
index fdeeb3169..9ca3753d0 100644
--- a/ipa-server/ipa-gui/ipagui/templates/userlist.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/userlist.kid
@@ -3,15 +3,15 @@
py:extends="'userlayout.kid'">
-Find People
+Find Users
- Find People
+ Find Users
+
+
+ :
+
+
+
+
+
+
diff --git a/ipa-server/ipa-gui/ipagui/templates/grouplist.kid b/ipa-server/ipa-gui/ipagui/templates/grouplist.kid
index 9f9bc4840..9489b3744 100644
--- a/ipa-server/ipa-gui/ipagui/templates/grouplist.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/grouplist.kid
@@ -20,7 +20,7 @@
${len(groups)} results returned:
-
+
@@ -32,7 +32,15 @@
-
+
+
+ ${group.cn}
+
+
+ ${group.description}
+
+
+
${group.cn}
diff --git a/ipa-server/ipa-gui/ipagui/templates/groupshow.kid b/ipa-server/ipa-gui/ipagui/templates/groupshow.kid
index b2f37bf52..8713742d5 100644
--- a/ipa-server/ipa-gui/ipagui/templates/groupshow.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/groupshow.kid
@@ -11,6 +11,7 @@ cn = group.get('cn')
if isinstance(cn, list):
cn = cn[0]
edit_url = tg.url('/group/edit', cn=cn)
+from ipagui.helpers import userhelper
?>
View Group
@@ -42,6 +43,12 @@ edit_url = tg.url('/group/edit', cn=cn)
${group.get("gidnumber")}
+
+
+ :
+
+ ${userhelper.account_status_display(group.get("nsAccountLock"))}
+
diff --git a/ipa-server/ipa-gui/ipagui/templates/usereditform.kid b/ipa-server/ipa-gui/ipagui/templates/usereditform.kid
index c95b36e39..88b778d8c 100644
--- a/ipa-server/ipa-gui/ipagui/templates/usereditform.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/usereditform.kid
@@ -787,7 +787,7 @@ from ipagui.helpers import ipahelper
group_dn = group.get('dn')
group_dn_esc = ipahelper.javascript_string_escape(group_dn)
- group_name = group.get('cn')[0]
+ group_name = group.get('cn')
group_descr = "[group]"
group_type = "group"
diff --git a/ipa-server/ipa-install/share/bootstrap-template.ldif b/ipa-server/ipa-install/share/bootstrap-template.ldif
index f443b6cb9..257f865be 100644
--- a/ipa-server/ipa-install/share/bootstrap-template.ldif
+++ b/ipa-server/ipa-install/share/bootstrap-template.ldif
@@ -116,3 +116,42 @@ ipaDefaultLoginShell: /bin/sh
ipaDefaultPrimaryGroup: ipausers
ipaMaxUsernameLength: 8
ipaPwdExpAdvNotify: 4
+
+dn: cn=account inactivation,cn=accounts,$SUFFIX
+description: Lock accounts based on group membership
+objectClass: top
+objectClass: ldapsubentry
+objectClass: cosSuperDefinition
+objectClass: cosClassicDefinition
+cosTemplateDn: cn=cosTemplates,cn=accounts,$SUFFIX
+cosAttribute: nsAccountLock operational
+cosAttribute: pager
+cosSpecifier: memberOf
+cn: Account Inactivation
+
+dn: cn=cosTemplates,cn=accounts,$SUFFIX
+objectclass: top
+objectclass: nsContainer
+cn: cosTemplates
+
+dn: cn="cn=inactivated,cn=account inactivation,cn=accounts,$SUFFIX", cn=cosTemplates,cn=accounts,$SUFFIX
+objectClass: top
+objectClass: cosTemplate
+objectClass: extensibleobject
+nsAccountLock: true
+cosPriority: 1
+
+dn: cn=inactivated,cn=account inactivation,cn=accounts,$SUFFIX
+objectclass: top
+objectclass: groupofuniquenames
+
+dn: cn="cn=activated,cn=account inactivation,cn=accounts,$SUFFIX", cn=cosTemplates,cn=accounts,$SUFFIX
+objectClass: top
+objectClass: cosTemplate
+objectClass: extensibleobject
+nsAccountLock: false
+cosPriority: 0
+
+dn: cn=Activated,cn=Account Inactivation,cn=accounts,$SUFFIX
+objectclass: top
+objectclass: groupofuniquenames
diff --git a/ipa-server/ipaserver/dsinstance.py b/ipa-server/ipaserver/dsinstance.py
index d1e8f3abc..3cf80f46a 100644
--- a/ipa-server/ipaserver/dsinstance.py
+++ b/ipa-server/ipaserver/dsinstance.py
@@ -119,7 +119,7 @@ class DsInstance(service.Service):
def __setup_sub_dict(self):
server_root = find_server_root()
self.sub_dict = dict(FQHN=self.host_name, SERVERID=self.serverid,
- PASSWORD=self.dm_password, SUFFIX=self.suffix,
+ PASSWORD=self.dm_password, SUFFIX=self.suffix.lower(),
REALM=self.realm_name, USER=self.ds_user,
SERVER_ROOT=server_root)
diff --git a/ipa-server/xmlrpc-server/funcs.py b/ipa-server/xmlrpc-server/funcs.py
index 85d22993a..5c9f0cf6b 100644
--- a/ipa-server/xmlrpc-server/funcs.py
+++ b/ipa-server/xmlrpc-server/funcs.py
@@ -36,6 +36,7 @@ import string
from types import *
import os
import re
+import logging
try:
from threading import Lock
@@ -49,6 +50,11 @@ ACIContainer = "cn=accounts"
DefaultUserContainer = "cn=users,cn=accounts"
DefaultGroupContainer = "cn=groups,cn=accounts"
+# FIXME: need to check the ipadebug option in ipa.conf
+logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s %(levelname)s %(message)s',
+ stream=sys.stderr)
+
#
# Apache runs in multi-process mode so each process will have its own
# connection. This could theoretically drive the total number of connections
@@ -674,26 +680,80 @@ class IPAServer:
else:
raise
- def mark_user_deleted (self, uid, opts=None):
- """Mark a user as inactive in LDAP. We aren't actually deleting
- users here, just making it so they can't log in, etc."""
- user = self.get_user_by_uid(uid, ['dn', 'uid', 'nsAccountlock'], opts)
+ def mark_entry_active (self, dn, opts=None):
+ """Mark an entry as active in LDAP."""
- # Are we doing an add or replace operation?
- if user.has_key('nsaccountlock'):
- if user['nsaccountlock'] == "true":
- return "already marked as deleted"
- has_key = True
- else:
- has_key = False
+ # This can be tricky. The entry itself can be marked inactive
+ # by being in the inactivated group. It can also be inactivated by
+ # being the member of an inactive group.
+ #
+ # First we try to remove the entry from the inactivated group. Then
+ # if it is still inactive we have to add it to the activated group
+ # which will override the group membership.
+
+ logging.debug("IPA: activating entry %s" % dn)
+
+ res = ""
+ # First, check the entry status
+ entry = self.get_entry_by_dn(dn, ['dn', 'nsAccountlock'], opts)
+
+ if entry.get('nsaccountlock', 'false') == "false":
+ logging.debug("IPA: already active")
+ raise ipaerror.gen_exception(ipaerror.LDAP_EMPTY_MODLIST)
+
+ group = self.get_entry_by_cn("inactivated", None, opts)
+ res = self.remove_member_from_group(entry.get('dn'), group.get('dn'), opts)
+
+ # Now they aren't a member of inactivated directly, what is the status
+ # now?
+ entry = self.get_entry_by_dn(dn, ['dn', 'nsAccountlock'], opts)
+
+ if entry.get('nsaccountlock', 'false') == "false":
+ # great, we're done
+ logging.debug("IPA: removing from inactivated did it.")
+ return res
+
+ # So still inactive, add them to activated
+ group = self.get_entry_by_cn("activated", None, opts)
+ res = self.add_member_to_group(dn, group.get('dn'), opts)
+ logging.debug("IPA: added to activated.")
- conn = self.getConnection(opts)
- try:
- res = conn.inactivateEntry(user['dn'], has_key)
- finally:
- self.releaseConnection(conn)
return res
+ def mark_entry_inactive (self, dn, opts=None):
+ """Mark an entry as inactive in LDAP."""
+
+ logging.debug("IPA: inactivating entry %s" % dn)
+
+ entry = self.get_entry_by_dn(dn, ['dn', 'nsAccountlock', 'memberOf'], opts)
+
+ if entry.get('nsaccountlock', 'false') == "true":
+ logging.debug("IPA: already marked as inactive")
+ raise ipaerror.gen_exception(ipaerror.LDAP_EMPTY_MODLIST)
+
+ # First see if they are in the activated group as this will override
+ # the our inactivation.
+ group = self.get_entry_by_cn("activated", None, opts)
+ self.remove_member_from_group(dn, group.get('dn'), opts)
+
+ # Now add them to inactivated
+ group = self.get_entry_by_cn("inactivated", None, opts)
+ res = self.add_member_to_group(dn, group.get('dn'), opts)
+
+ return res
+
+ def mark_user_active(self, uid, opts=None):
+ """Mark a user as active"""
+
+ user = self.get_user_by_uid(uid, ['dn', 'uid'], opts)
+ return self.mark_entry_active(user.get('dn'))
+
+ def mark_user_inactive(self, uid, opts=None):
+ """Mark a user as inactive"""
+
+ user = self.get_user_by_uid(uid, ['dn', 'uid'], opts)
+ return self.mark_entry_inactive(user.get('dn'))
+
def delete_user (self, uid, opts=None):
"""Delete a user. Not to be confused with inactivate_user. This
makes the entry go away completely.
@@ -1215,6 +1275,18 @@ class IPAServer:
return entries
+ def mark_group_active(self, cn, opts=None):
+ """Mark a group as active"""
+
+ group = self.get_entry_by_cn(cn, ['dn', 'cn'], opts)
+ return self.mark_entry_active(group.get('dn'))
+
+ def mark_group_inactive(self, cn, opts=None):
+ """Mark a group as inactive"""
+
+ group = self.get_entry_by_cn(cn, ['dn', 'uid'], opts)
+ return self.mark_entry_inactive(group.get('dn'))
+
# Configuration support
def get_ipa_config(self, opts=None):
"""Retrieve the IPA configuration"""
diff --git a/ipa-server/xmlrpc-server/ipaxmlrpc.py b/ipa-server/xmlrpc-server/ipaxmlrpc.py
index 23bdcec1e..789233c9f 100644
--- a/ipa-server/xmlrpc-server/ipaxmlrpc.py
+++ b/ipa-server/xmlrpc-server/ipaxmlrpc.py
@@ -332,7 +332,10 @@ def handler(req, profiling=False):
h.register_function(f.find_users)
h.register_function(f.update_user)
h.register_function(f.delete_user)
- h.register_function(f.mark_user_deleted)
+ h.register_function(f.mark_user_active)
+ h.register_function(f.mark_user_inactive)
+ h.register_function(f.mark_group_active)
+ h.register_function(f.mark_group_inactive)
h.register_function(f.modifyPassword)
h.register_function(f.get_groups_by_member)
h.register_function(f.add_group)
From bf743087d25e170091dc507fa087d012b64b1468 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Wed, 21 Nov 2007 00:29:03 -0500
Subject: [PATCH 47/60] Fix indentation error that occured in merge
---
ipa-python/ipaclient.py | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/ipa-python/ipaclient.py b/ipa-python/ipaclient.py
index 0eeb2f36f..cda8ceb93 100644
--- a/ipa-python/ipaclient.py
+++ b/ipa-python/ipaclient.py
@@ -342,17 +342,17 @@ class IPAClient:
return entries
- def mark_group_active(self,cn):
- """Set a group as active by cn."""
-
- result = self.transport.mark_group_active(cn)
- return result
-
- def mark_group_inactive(self,cn):
- """Set a group as inactive by cn."""
-
- result = self.transport.mark_group_inactive(cn)
- return result
+ def mark_group_active(self,cn):
+ """Set a group as active by cn."""
+
+ result = self.transport.mark_group_active(cn)
+ return result
+
+ def mark_group_inactive(self,cn):
+ """Set a group as inactive by cn."""
+
+ result = self.transport.mark_group_inactive(cn)
+ return result
# Configuration
From d3d89f754b0cb08efa3632d2c0f841b3cbab4188 Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Wed, 21 Nov 2007 00:27:50 -0500
Subject: [PATCH 48/60] Use same tzinfo as the time parser to avoid TypeError
from being thrown
---
ipa-server/ipa-gui/ipagui/helpers/userhelper.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ipa-server/ipa-gui/ipagui/helpers/userhelper.py b/ipa-server/ipa-gui/ipagui/helpers/userhelper.py
index e1ade3a2c..52d37c9e4 100644
--- a/ipa-server/ipa-gui/ipagui/helpers/userhelper.py
+++ b/ipa-server/ipa-gui/ipagui/helpers/userhelper.py
@@ -13,7 +13,7 @@ def password_expires_in(datestr):
if not expdate:
return sys.maxint
- delta = expdate - datetime.datetime.now()
+ delta = expdate - datetime.datetime.now(ipautil.GeneralizedTimeZone())
return delta.days
def password_is_expired(days):
From bec524485a90b4611c6507331290d4c3a53bd99a Mon Sep 17 00:00:00 2001
From: Simo Sorce
Date: Tue, 20 Nov 2007 17:41:26 -0500
Subject: [PATCH 49/60] Fix subtle errors in kpasswd
---
ipa-server/ipa-kpasswd/ipa_kpasswd.c | 98 +++++++++++++++++++++-------
1 file changed, 73 insertions(+), 25 deletions(-)
diff --git a/ipa-server/ipa-kpasswd/ipa_kpasswd.c b/ipa-server/ipa-kpasswd/ipa_kpasswd.c
index 1570e017e..b0020c04f 100644
--- a/ipa-server/ipa-kpasswd/ipa_kpasswd.c
+++ b/ipa-server/ipa-kpasswd/ipa_kpasswd.c
@@ -28,26 +28,54 @@
#define TMP_TEMPLATE "/tmp/kpasswd.XXXXXX"
#define KPASSWD_PORT 464
+/* blacklist entries are released only BLCAKLIST_TIMEOUT seconds
+ * after the children performing the noperation has finished.
+ * this is to avoid races */
+
+#define BLACKLIST_TIMEOUT 5
+
struct blacklist {
struct blacklist *next;
char *address;
pid_t pid;
+ time_t expire;
};
static struct blacklist *global_blacklist = NULL;
int check_blacklist(char *address)
{
- struct blacklist *bl;
+ struct blacklist *bl, *prev_bl;
+ time_t now = time(NULL);
if (!global_blacklist) {
return 0;
}
- for (bl = global_blacklist; bl; bl = bl->next) {
+ prev_bl = NULL;
+ bl = global_blacklist;
+ while (bl) {
+ if (bl->expire && (bl->expire < now)) {
+ if (prev_bl) {
+ prev_bl->next = bl->next;
+ free(bl->address);
+ free(bl);
+ bl = prev_bl->next;
+ } else {
+ global_blacklist = bl->next;
+ free(bl->address);
+ free(bl);
+ bl = global_blacklist;
+ }
+ continue;
+ }
+
if (strcmp(address, bl->address) == 0) {
return 1;
}
+
+ prev_bl = bl;
+ bl = bl->next;
}
return 0;
@@ -62,6 +90,7 @@ int add_blacklist(pid_t pid, char *address)
bl->next = NULL;
bl->pid = pid;
+ bl->expire = 0;
bl->address = strdup(address);
if (!bl->address) {
free(bl);
@@ -83,26 +112,18 @@ int add_blacklist(pid_t pid, char *address)
int remove_blacklist(pid_t pid)
{
- struct blacklist *bl, *pbl;
+ struct blacklist *bl;
if (!global_blacklist) {
return -1;
}
- pbl = NULL;
bl = global_blacklist;
while (bl) {
if (pid == bl->pid) {
- if (pbl == NULL) {
- global_blacklist = bl->next;
- } else {
- pbl->next = bl->next;
- }
- free(bl->address);
- free(bl);
+ bl->expire = time(NULL) + BLACKLIST_TIMEOUT;
return 0;
}
- pbl = bl;
bl = bl->next;
}
return -1;
@@ -944,6 +965,7 @@ pid_t handle_conn(int fd, int type)
{
int mfd, tcp;
pid_t pid;
+ char addrto6[INET6_ADDRSTRLEN+1];
char address[INET6_ADDRSTRLEN+1];
uint8_t request[1500];
ssize_t reqlen;
@@ -966,17 +988,38 @@ pid_t handle_conn(int fd, int type)
return -1;
}
} else {
- mfd = fd;
+ /* read first to empty the buffer on udp connections */
+ reqlen = recvfrom(fd, request, sizeof(request), 0,
+ (struct sockaddr *)&from, &fromlen);
+ if (reqlen <= 0) {
+ syslog(LOG_ERR, "Error receiving request (%d) %s",
+ errno, strerror(errno));
+ return -1;
+ }
+
}
(void) getnameinfo((struct sockaddr *)&from, fromlen,
- address, INET6_ADDRSTRLEN+1,
+ addrto6, INET6_ADDRSTRLEN+1,
NULL, 0, NI_NUMERICHOST);
if (debug > 0) {
- syslog(LOG_ERR, "Connection from %s", address);
+ syslog(LOG_ERR, "Connection from %s", addrto6);
}
+ if (strchr(addrto6, ':') == NULL) {
+ char *prefix6 = "::ffff:";
+ /* this is an IPv4 formatted addr
+ * convert to IPv6 mapped addr */
+ memcpy(address, prefix6, 7);
+ memcpy(&address[7], addrto6, INET6_ADDRSTRLEN-7);
+ } else {
+ /* regular IPv6 address, copy as is */
+ memcpy(address, addrto6, INET6_ADDRSTRLEN);
+ }
+ /* make sure we have termination */
+ address[INET6_ADDRSTRLEN] = '\0';
+
/* Check blacklist for requests from the same IP until operations
* are finished on the active client.
* the password change may be slow and pam_krb5 sends up to 3 UDP
@@ -991,15 +1034,17 @@ pid_t handle_conn(int fd, int type)
return 0;
}
- reqlen = recvfrom(mfd, request, sizeof(request), 0,
- (struct sockaddr *)&from, &fromlen);
- if (reqlen <= 0) {
- syslog(LOG_ERR, "Error receiving request (%d) %s",
- errno, strerror(errno));
- if (tcp) close(mfd);
- return -1;
+ /* now read data if it was a TCP connection */
+ if (tcp) {
+ reqlen = recvfrom(mfd, request, sizeof(request), 0,
+ (struct sockaddr *)&from, &fromlen);
+ if (reqlen <= 0) {
+ syslog(LOG_ERR, "Error receiving request (%d) %s",
+ errno, strerror(errno));
+ close(mfd);
+ return -1;
+ }
}
-
#if 1
/* handle kerberos and ldap operations in childrens */
pid = fork();
@@ -1017,6 +1062,7 @@ pid_t handle_conn(int fd, int type)
#endif
/* children */
+ if (debug > 0) syslog(LOG_ERR, "Servicing %s", address);
/* TCP packets prepend the lenght as a 32bit network order field,
* this information seem to be just redundant, so let's simply
@@ -1031,13 +1077,13 @@ pid_t handle_conn(int fd, int type)
if (tcp) {
sendret = sendto(mfd, reply, replen, 0, NULL, 0);
} else {
- sendret = sendto(mfd, reply, replen, 0, (struct sockaddr *)&from, fromlen);
+ sendret = sendto(fd, reply, replen, 0, (struct sockaddr *)&from, fromlen);
}
if (sendret == -1) {
syslog(LOG_ERR, "Error sending reply (%d)", errno);
}
}
- close(mfd);
+ if (tcp) close(mfd);
exit(0);
}
@@ -1189,6 +1235,8 @@ int main(int argc, char *argv[])
/* check for children exiting */
cid = waitpid(-1, &cstatus, WNOHANG);
if (cid != -1 && cid != 0) {
+ if (debug > 0)
+ syslog(LOG_ERR, "pid %d completed operations!\n", cid);
remove_blacklist(cid);
}
}
From 3580d0affb26498011a7a5ff1389cd1b6e534634 Mon Sep 17 00:00:00 2001
From: Simo Sorce
Date: Tue, 20 Nov 2007 10:22:43 -0500
Subject: [PATCH 50/60] Use groupOfNames and member, not groupOfUniqueNames and
uniqueMember
---
.../ipa-install/share/bootstrap-template.ldif | 8 ++---
.../ipa-memberof/ipa-memberof.c | 2 +-
ipa-server/xmlrpc-server/funcs.py | 32 +++++++++----------
3 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/ipa-server/ipa-install/share/bootstrap-template.ldif b/ipa-server/ipa-install/share/bootstrap-template.ldif
index 257f865be..c83976cba 100644
--- a/ipa-server/ipa-install/share/bootstrap-template.ldif
+++ b/ipa-server/ipa-install/share/bootstrap-template.ldif
@@ -77,17 +77,17 @@ gecos: Administrator
dn: cn=admins,cn=groups,cn=accounts,$SUFFIX
changetype: add
objectClass: top
-objectClass: groupofuniquenames
+objectClass: groupofnames
objectClass: posixGroup
cn: admins
description: Account administrators group
gidNumber: 1001
-uniqueMember: uid=admin,cn=sysaccounts,cn=etc,$SUFFIX
+member: uid=admin,cn=sysaccounts,cn=etc,$SUFFIX
dn: cn=ipausers,cn=groups,cn=accounts,$SUFFIX
changetype: add
objectClass: top
-objectClass: groupofuniquenames
+objectClass: groupofnames
objectClass: posixGroup
gidNumber: 1002
description: Default group for all users
@@ -96,7 +96,7 @@ cn: ipausers
dn: cn=editors,cn=groups,cn=accounts,$SUFFIX
changetype: add
objectClass: top
-objectClass: groupofuniquenames
+objectClass: groupofnames
objectClass: posixGroup
gidNumber: 1003
description: Limited admins who can edit other users
diff --git a/ipa-server/ipa-slapi-plugins/ipa-memberof/ipa-memberof.c b/ipa-server/ipa-slapi-plugins/ipa-memberof/ipa-memberof.c
index b23a04ae6..706b81325 100644
--- a/ipa-server/ipa-slapi-plugins/ipa-memberof/ipa-memberof.c
+++ b/ipa-server/ipa-slapi-plugins/ipa-memberof/ipa-memberof.c
@@ -70,7 +70,7 @@
#include "string.h"
#include "nspr.h"
-#define IPA_GROUP_ATTR "uniquemember"
+#define IPA_GROUP_ATTR "member"
#define IPA_MEMBEROF_ATTR "memberof"
#define IPA_GROUP_ATTR_IS_DN 1
#define IPA_GROUP_ATTR_TYPE "uid"
diff --git a/ipa-server/xmlrpc-server/funcs.py b/ipa-server/xmlrpc-server/funcs.py
index 5c9f0cf6b..db7413dbe 100644
--- a/ipa-server/xmlrpc-server/funcs.py
+++ b/ipa-server/xmlrpc-server/funcs.py
@@ -811,7 +811,7 @@ class IPAServer:
"""
member_dn = self.__safe_filter(member_dn)
- filter = "(&(objectClass=posixGroup)(uniqueMember=%s))" % member_dn
+ filter = "(&(objectClass=posixGroup)(member=%s))" % member_dn
try:
return self.__get_list(self.basedn, filter, sattrs, opts)
@@ -834,7 +834,7 @@ class IPAServer:
entry = ipaserver.ipaldap.Entry(dn)
# some required objectclasses
- entry.setValues('objectClass', 'top', 'groupofuniquenames', 'posixGroup',
+ entry.setValues('objectClass', 'top', 'groupofnames', 'posixGroup',
'inetUser')
# No need to explicitly set gidNumber. The dna_plugin will do this
@@ -940,12 +940,12 @@ class IPAServer:
# check to make sure member_dn exists
member_entry = self.__get_base_entry(member_dn, "(objectClass=*)", ['dn','uid'], opts)
- if new_group.get('uniquemember') is not None:
- if ((isinstance(new_group.get('uniquemember'), str)) or (isinstance(new_group.get('uniquemember'), unicode))):
- new_group['uniquemember'] = [new_group['uniquemember']]
- new_group['uniquemember'].append(member_dn)
+ if new_group.get('member') is not None:
+ if ((isinstance(new_group.get('member'), str)) or (isinstance(new_group.get('member'), unicode))):
+ new_group['member'] = [new_group['member']]
+ new_group['member'].append(member_dn)
else:
- new_group['uniquemember'] = member_dn
+ new_group['member'] = member_dn
try:
ret = self.__update_entry(old_group, new_group, opts)
@@ -984,11 +984,11 @@ class IPAServer:
raise ipaerror.gen_exception(ipaerror.LDAP_NOT_FOUND)
new_group = copy.deepcopy(old_group)
- if new_group.get('uniquemember') is not None:
- if ((isinstance(new_group.get('uniquemember'), str)) or (isinstance(new_group.get('uniquemember'), unicode))):
- new_group['uniquemember'] = [new_group['uniquemember']]
+ if new_group.get('member') is not None:
+ if ((isinstance(new_group.get('member'), str)) or (isinstance(new_group.get('member'), unicode))):
+ new_group['member'] = [new_group['member']]
try:
- new_group['uniquemember'].remove(member_dn)
+ new_group['member'].remove(member_dn)
except ValueError:
# member is not in the group
# FIXME: raise more specific error?
@@ -1221,12 +1221,12 @@ class IPAServer:
if group_dn is None:
raise ipaerror.gen_exception(ipaerror.LDAP_NOT_FOUND)
- if new_group.get('uniquemember') is not None:
- if ((isinstance(new_group.get('uniquemember'), str)) or (isinstance(new_group.get('uniquemember'), unicode))):
- new_group['uniquemember'] = [new_group['uniquemember']]
- new_group['uniquemember'].append(group_dn['dn'])
+ if new_group.get('member') is not None:
+ if ((isinstance(new_group.get('member'), str)) or (isinstance(new_group.get('member'), unicode))):
+ new_group['member'] = [new_group['member']]
+ new_group['member'].append(group_dn['dn'])
else:
- new_group['uniquemember'] = group_dn['dn']
+ new_group['member'] = group_dn['dn']
try:
ret = self.__update_entry(old_group, new_group, opts)
From b456d8424a89b157eb9b1438ed0c3590221cee70 Mon Sep 17 00:00:00 2001
From: Simo Sorce
Date: Wed, 21 Nov 2007 16:07:07 -0500
Subject: [PATCH 51/60] more s/unique// wrt groups members/objectclasses
---
ipa-server/ipa-install/share/bootstrap-template.ldif | 4 ++--
ipa-server/ipa-install/share/default-aci.ldif | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/ipa-server/ipa-install/share/bootstrap-template.ldif b/ipa-server/ipa-install/share/bootstrap-template.ldif
index c83976cba..dc403b637 100644
--- a/ipa-server/ipa-install/share/bootstrap-template.ldif
+++ b/ipa-server/ipa-install/share/bootstrap-template.ldif
@@ -143,7 +143,7 @@ cosPriority: 1
dn: cn=inactivated,cn=account inactivation,cn=accounts,$SUFFIX
objectclass: top
-objectclass: groupofuniquenames
+objectclass: groupofnames
dn: cn="cn=activated,cn=account inactivation,cn=accounts,$SUFFIX", cn=cosTemplates,cn=accounts,$SUFFIX
objectClass: top
@@ -154,4 +154,4 @@ cosPriority: 0
dn: cn=Activated,cn=Account Inactivation,cn=accounts,$SUFFIX
objectclass: top
-objectclass: groupofuniquenames
+objectclass: groupofnames
diff --git a/ipa-server/ipa-install/share/default-aci.ldif b/ipa-server/ipa-install/share/default-aci.ldif
index f5988f2e7..4a5befbec 100644
--- a/ipa-server/ipa-install/share/default-aci.ldif
+++ b/ipa-server/ipa-install/share/default-aci.ldif
@@ -7,7 +7,7 @@ aci: (targetattr=*)(version 3.0; acl "Admin can manage any entry"; allow (all) u
aci: (targetattr="krbPrincipalName || krbUPEnabled || krbPrincipalKey || krbMKey || krbTicketPolicyReference || krbPrincipalExpiration || krbPasswordExpiration || krbPwdPolicyReference || krbPrincipalType || krbPwdHistory || krbLastPwdChange || krbPrincipalAliases || krbExtraData")(version 3.0; acl "KDC System Account"; allow (read, search, compare) userdn="ldap:///uid=kdc,cn=sysaccounts,cn=etc,$SUFFIX";)
aci: (targetattr="krbLastSuccessfulAuth || krbLastFailedAuth || krbLoginFailedCount")(version 3.0; acl "KDC System Account"; allow (read, search, compare, write) userdn="ldap:///uid=kdc,cn=sysaccounts,cn=etc,$SUFFIX";)
aci: (targetattr="userPassword || krbPrincipalKey ||sambaLMPassword || sambaNTPassword || krbPasswordExpiration || krbPwdHistory || krbLastPwdChange")(version 3.0; acl "Kpasswd access to passowrd hashes for passowrd changes"; allow (read, write) userdn="ldap:///krbprincipalname=kadmin/changepw@$REALM,cn=$REALM,cn=kerberos,$SUFFIX";)
-aci: (targetfilter="(|(objectClass=person)(objectClass=krbPrincipalAux)(objectClass=posixAccount)(objectClass=groupOfUniqueNames)(objectClass=posixGroup))")(targetattr="*")(version 3.0; acl "Account Admins can manage Users and Groups"; allow (add,delete,read,write) groupdn="ldap:///cn=admins,cn=groups,cn=accounts,$SUFFIX";)
+aci: (targetfilter="(|(objectClass=person)(objectClass=krbPrincipalAux)(objectClass=posixAccount)(objectClass=groupOfNames)(objectClass=posixGroup))")(targetattr="*")(version 3.0; acl "Account Admins can manage Users and Groups"; allow (add,delete,read,write) groupdn="ldap:///cn=admins,cn=groups,cn=accounts,$SUFFIX";)
aci: (targetattr = "givenName || sn || cn || displayName || initials || loginShell || homePhone || mobile || pager || facsimileTelephoneNumber || telephoneNumber || street || roomNumber || l || st || postalCode || manager || description || carLicense || labeledURI || inetUserHTTPURL || seeAlso || userPassword")(version 3.0;acl "Self service";allow (write) userdn="ldap:///self";)
dn: cn=ipaConfig,cn=etc,$SUFFIX
From c373ed5c5ccbee64c956a9a682a1427387498d8d Mon Sep 17 00:00:00 2001
From: Karl MacMillan
Date: Wed, 21 Nov 2007 18:01:32 -0500
Subject: [PATCH 52/60] Initial replication setup.
This add replication setup through two new commands: ipa-replica-prepare
and ipa-replica-install. The procedure is to run ipa-replica-prepare
on an existing master. This will collect information about the realm
and the current master and create a file storing all of the information.
After copying that file to the new replica, ipa-replica-install is
run (with -r to create a read-only replica).
This version of the patch also includes fixes for the sasl mappings
on the replicas.
Remaining features:
- ssl for replication.
- automatic configuration of mesh topology for
master (or a simpler way to replicate multiple
masters.
- tool for view / configuring current replication.
---
ipa-python/ipautil.py | 2 +-
ipa-server/freeipa-server.spec | 2 +
ipa-server/freeipa-server.spec.in | 2 +
ipa-server/ipa-install/Makefile.am | 2 +
ipa-server/ipa-install/ipa-replica-install | 142 ++++++++++++++
ipa-server/ipa-install/ipa-replica-prepare | 114 ++++++++++++
ipa-server/ipa-install/ipa-server-install | 159 ++--------------
ipa-server/ipa-install/share/kerberos.ldif | 18 --
ipa-server/ipaserver/Makefile.am | 2 +
ipa-server/ipaserver/dsinstance.py | 104 ++++++++---
ipa-server/ipaserver/installutils.py | 108 +++++++++++
ipa-server/ipaserver/ipaldap.py | 101 ++++++++--
ipa-server/ipaserver/krbinstance.py | 203 +++++++++++++++------
ipa-server/ipaserver/radiusinstance.py | 3 +-
14 files changed, 707 insertions(+), 255 deletions(-)
create mode 100644 ipa-server/ipa-install/ipa-replica-install
create mode 100644 ipa-server/ipa-install/ipa-replica-prepare
create mode 100644 ipa-server/ipaserver/installutils.py
diff --git a/ipa-python/ipautil.py b/ipa-python/ipautil.py
index e7f594191..cd8eac16c 100644
--- a/ipa-python/ipautil.py
+++ b/ipa-python/ipautil.py
@@ -25,6 +25,7 @@ import logging
import subprocess
import os
import stat
+import socket
from string import lower
import re
@@ -36,7 +37,6 @@ def realm_to_suffix(realm_name):
terms = ["dc=" + x.lower() for x in s]
return ",".join(terms)
-
def template_str(txt, vars):
return string.Template(txt).substitute(vars)
diff --git a/ipa-server/freeipa-server.spec b/ipa-server/freeipa-server.spec
index 80b77bc99..93a3bae18 100755
--- a/ipa-server/freeipa-server.spec
+++ b/ipa-server/freeipa-server.spec
@@ -71,6 +71,8 @@ rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%{_sbindir}/ipa-server-install
+%{_sbindir}/ipa-replica-install
+%{_sbindir}/ipa-replica-prepare
%{_sbindir}/ipa_kpasswd
%{_sbindir}/ipa-webgui
%attr(755,root,root) %{_initrddir}/ipa-kpasswd
diff --git a/ipa-server/freeipa-server.spec.in b/ipa-server/freeipa-server.spec.in
index f7db08d7a..d50cd4e91 100644
--- a/ipa-server/freeipa-server.spec.in
+++ b/ipa-server/freeipa-server.spec.in
@@ -71,6 +71,8 @@ rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%{_sbindir}/ipa-server-install
+%{_sbindir}/ipa-replica-install
+%{_sbindir}/ipa-replica-prepare
%{_sbindir}/ipa_kpasswd
%{_sbindir}/ipa-webgui
%attr(755,root,root) %{_initrddir}/ipa-kpasswd
diff --git a/ipa-server/ipa-install/Makefile.am b/ipa-server/ipa-install/Makefile.am
index 9ecf7e20d..4765cfb54 100644
--- a/ipa-server/ipa-install/Makefile.am
+++ b/ipa-server/ipa-install/Makefile.am
@@ -6,6 +6,8 @@ SUBDIRS = \
sbin_SCRIPTS = \
ipa-server-install \
+ ipa-replica-install \
+ ipa-replica-prepare \
$(NULL)
appdir = $(IPA_DATA_DIR)
diff --git a/ipa-server/ipa-install/ipa-replica-install b/ipa-server/ipa-install/ipa-replica-install
new file mode 100644
index 000000000..706dc323d
--- /dev/null
+++ b/ipa-server/ipa-install/ipa-replica-install
@@ -0,0 +1,142 @@
+#! /usr/bin/python -E
+# Authors: Karl MacMillan
+#
+# Copyright (C) 2007 Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; version 2 or later
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+import sys
+sys.path.append("/usr/share/ipa")
+
+import tempfile
+from ConfigParser import SafeConfigParser
+
+from ipa import ipautil
+
+from ipaserver import dsinstance, replication, installutils, krbinstance, service
+from ipaserver import httpinstance, webguiinstance, radiusinstance, ntpinstance
+
+class ReplicaConfig:
+ def __init__(self):
+ self.realm_name = ""
+ self.master_host_name = ""
+ self.dirman_password = ""
+ self.ds_user = ""
+ self.host_name = ""
+ self.repl_password = ""
+ self.dir = ""
+
+def parse_options():
+ from optparse import OptionParser
+ parser = OptionParser()
+ parser.add_option("-r", "--read-only", dest="master", action="store_false",
+ default=True, help="create read-only replica - default is master")
+
+ options, args = parser.parse_args()
+
+ if len(args) != 1:
+ parser.error("you must provide a file generated by ipa-replica-prepare")
+
+ return options, args[0]
+
+def get_dirman_password():
+ return installutils.read_password("Directory Manager (existing master)")
+
+def expand_info(filename):
+ top_dir = tempfile.mkdtemp("ipa")
+ dir = top_dir + "/realm_info"
+ ipautil.run(["tar", "xfz", filename, "-C", top_dir])
+
+ return top_dir, dir
+
+def read_info(dir, rconfig):
+ filename = dir + "/realm_info"
+ fd = open(filename)
+ config = SafeConfigParser()
+ config.readfp(fd)
+
+ rconfig.realm_name = config.get("realm", "realm_name")
+ rconfig.master_host_name = config.get("realm", "master_host_name")
+ rconfig.ds_user = config.get("realm", "ds_user")
+
+def get_host_name():
+ hostname = installutils.get_fqdn()
+ try:
+ installutils.verify_fqdn(hostname)
+ except RuntimeError, e:
+ logging.error(str(e))
+ sys.exit(1)
+
+ return hostname
+
+def install_ds(config):
+ dsinstance.check_existing_installation()
+ dsinstance.check_ports()
+
+ ds = dsinstance.DsInstance()
+ ds.create_instance(config.ds_user, config.realm_name, config.host_name, config.dirman_password)
+
+def install_krb(config):
+ krb = krbinstance.KrbInstance()
+ ldappwd_filename = config.dir + "/ldappwd"
+ krb.create_replica(config.ds_user, config.realm_name, config.host_name,
+ config.dirman_password, ldappwd_filename)
+
+def install_http(config):
+ http = httpinstance.HTTPInstance()
+ http.create_instance(config.realm_name, config.host_name)
+
+def main():
+ options, filename = parse_options()
+ top_dir, dir = expand_info(filename)
+
+ config = ReplicaConfig()
+ read_info(dir, config)
+ config.host_name = get_host_name()
+ config.repl_password = "box"
+ config.dir = dir
+
+ # get the directory manager password
+ config.dirman_password = get_dirman_password()
+
+ install_ds(config)
+
+ repl = replication.ReplicationManager(config.host_name, config.dirman_password)
+ repl.setup_replication(config.master_host_name, config.realm_name, options.master)
+
+ install_krb(config)
+ install_http(config)
+
+ # Create a Web Gui instance
+ webgui = webguiinstance.WebGuiInstance()
+ webgui.create_instance()
+
+ # Create a radius instance
+ radius = radiusinstance.RadiusInstance()
+ # FIXME: ldap_server should be derived, not hardcoded to localhost, also should it be a URL?
+ radius.create_instance(config.realm_name, config.host_name, 'localhost')
+
+ # Configure ntpd
+ ntp = ntpinstance.NTPInstance()
+ ntp.create_instance()
+
+
+ service.restart("dirsrv")
+ service.restart("krb5kdc")
+
+main()
+
+
diff --git a/ipa-server/ipa-install/ipa-replica-prepare b/ipa-server/ipa-install/ipa-replica-prepare
new file mode 100644
index 000000000..705c731d8
--- /dev/null
+++ b/ipa-server/ipa-install/ipa-replica-prepare
@@ -0,0 +1,114 @@
+#! /usr/bin/python -E
+# Authors: Karl MacMillan
+#
+# Copyright (C) 2007 Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; version 2 or later
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+import sys
+sys.path.append("/usr/share/ipa")
+
+import logging, tempfile, shutil, os, pwd
+from ConfigParser import SafeConfigParser
+import krbV
+
+from ipa import ipautil
+from ipaserver import dsinstance
+from ipaserver import installutils
+
+certutil = "/usr/bin/certutil"
+
+def get_host_name():
+ hostname = installutils.get_fqdn()
+ try:
+ installutils.verify_fqdn(hostname)
+ except RuntimeError, e:
+ logging.error(str(e))
+ sys.exit(1)
+
+ return hostname
+
+def get_realm_name():
+ c = krbV.default_context()
+ return c.default_realm
+
+def check_ipa_configuration(realm_name):
+ config_dir = dsinstance.config_dirname(realm_name)
+ if not ipautil.dir_exists(config_dir):
+ logging.error("could not find directory instance: %s" % config_dir)
+ sys.exit(1)
+
+def create_certdb(ds_dir, dir):
+ # copy the passwd, noise, and pin files
+ shutil.copyfile(ds_dir + "/pwdfile.txt", dir + "/pwdfile.txt")
+ shutil.copyfile(ds_dir + "/noise.txt", dir + "/noise.txt")
+ shutil.copyfile(ds_dir + "/pin.txt", dir + "/pin.txt")
+
+ # create a new cert db
+ ipautil.run([certutil, "-N", "-d", dir, "-f", dir + "/pwdfile.txt"])
+
+ # Add the CA cert
+ ipautil.run([certutil, "-A", "-d", dir, "-n", "CA certificate", "-t", "CT,CT", "-a", "-i",
+ ds_dir + "/cacert.asc"])
+
+def get_ds_user(ds_dir):
+ uid = os.stat(ds_dir).st_uid
+ user = pwd.getpwuid(uid)[0]
+
+ return user
+
+def copy_files(realm_name, dir):
+ shutil.copy("/var/kerberos/krb5kdc/ldappwd", dir + "/ldappwd")
+
+
+def save_config(dir, realm_name, host_name, ds_user):
+ config = SafeConfigParser()
+ config.add_section("realm")
+ config.set("realm", "realm_name", realm_name)
+ config.set("realm", "master_host_name", host_name)
+ config.set("realm", "ds_user", ds_user)
+ fd = open(dir + "/realm_info", "w")
+ config.write(fd)
+
+
+def main():
+ realm_name = get_realm_name()
+ host_name = get_host_name()
+ ds_dir = dsinstance.config_dirname(realm_name)
+ ds_user = get_ds_user(ds_dir)
+
+ check_ipa_configuration(realm_name)
+
+ top_dir = tempfile.mkdtemp("ipa")
+ dir = top_dir + "/realm_info"
+ os.mkdir(dir, 0700)
+
+ create_certdb(ds_dir, dir)
+
+ copy_files(realm_name, dir)
+
+ save_config(dir, realm_name, host_name, ds_user)
+
+ ipautil.run(["/bin/tar", "cfz", "replica-info-" + realm_name, "-C", top_dir, "realm_info"])
+
+ shutil.rmtree(dir)
+
+main()
+
+
+
+
+
diff --git a/ipa-server/ipa-install/ipa-server-install b/ipa-server/ipa-install/ipa-server-install
index 2de687fd7..b957e522f 100644
--- a/ipa-server/ipa-install/ipa-server-install
+++ b/ipa-server/ipa-install/ipa-server-install
@@ -34,7 +34,6 @@ import socket
import errno
import logging
import pwd
-import getpass
import subprocess
import signal
import shutil
@@ -51,8 +50,9 @@ import ipaserver.radiusinstance
import ipaserver.webguiinstance
from ipaserver import service
+from ipaserver.installutils import *
-from ipa.ipautil import run
+from ipa.ipautil import *
def parse_options():
parser = OptionParser(version=VERSION)
@@ -86,39 +86,6 @@ def parse_options():
return options
-def logging_setup(options):
- # Always log everything (i.e., DEBUG) to the log
- # file.
- logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s %(levelname)s %(message)s',
- filename='ipaserver-install.log',
- filemode='w')
-
- console = logging.StreamHandler()
- # If the debug option is set, also log debug messages to the console
- if options.debug:
- console.setLevel(logging.DEBUG)
- else:
- # Otherwise, log critical and error messages
- console.setLevel(logging.ERROR)
- formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
- console.setFormatter(formatter)
- logging.getLogger('').addHandler(console)
-
-def erase_ds_instance_data(serverid):
- try:
- shutil.rmtree("/etc/dirsrv/slapd-%s" % serverid)
- except:
- pass
- try:
- shutil.rmtree("/var/lib/dirsrv/slapd-%s" % serverid)
- except:
- pass
- try:
- shutil.rmtree("/var/lock/dirsrv/slapd-%s" % serverid)
- except:
- pass
-
def signal_handler(signum, frame):
global ds
print "\nCleaning up..."
@@ -126,59 +93,9 @@ def signal_handler(signum, frame):
print "Removing configuration for %s instance" % ds.serverid
ds.stop()
if ds.serverid:
- erase_ds_instance_data (ds.serverid)
+ ipaserver.dsinstance.erase_ds_instance_data (ds.serverid)
sys.exit(1)
-def check_existing_installation():
- dirs = glob.glob("/etc/dirsrv/slapd-*")
- if not dirs:
- return
- print ""
- print "An existing Directory Server has been detected."
- yesno = raw_input("Do you wish to remove it and create a new one? [no]: ")
- if not yesno or yesno.lower()[0] != "y":
- sys.exit(1)
-
- try:
- run(["/sbin/service", "dirsrv", "stop"])
- except:
- pass
- for d in dirs:
- serverid = os.path.basename(d).split("slapd-", 1)[1]
- 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:
- fqdn = socket.getfqdn()
- except:
- try:
- fqdn = socket.gethostname()
- except:
- fqdn = ""
- return fqdn
-
-def verify_fqdn(host_name):
- is_ok = True
- if len(host_name.split(".")) < 2 or host_name == "localhost.localdomain":
- print "Invalid hostname: " + host_name
- print "This host name can't be used as a hostname for an IPA Server"
- is_ok = False
- return is_ok
-
def read_host_name(host_default):
host_ok = False
host_name = ""
@@ -198,7 +115,9 @@ def read_host_name(host_default):
host_name = host_default
else:
host_name = host_input
- if not verify_fqdn(host_name):
+ try:
+ verify_fqdn(host_name)
+ except:
host_name = ""
continue
else:
@@ -256,36 +175,6 @@ def read_ip_address(host_name):
return ip
-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"
@@ -333,23 +222,6 @@ def read_realm_name(domain_name):
realm_name = upper_dom
return realm_name
-def read_password(user):
- correct = False
- pwd = ""
- while not correct:
- pwd = getpass.getpass(user + " password: ")
- if not pwd:
- continue
- pwd_confirm = getpass.getpass("Password (confirm): ")
- if pwd != pwd_confirm:
- print "Password mismatch!"
- print ""
- else:
- correct = True
- #TODO: check validity/length
- print ""
- return pwd
-
def read_dm_password():
print "Certain directory server operations require an administrative user."
print "This user is referred to as the Directory Manager and has full access"
@@ -392,6 +264,8 @@ def main():
global ds
ds = None
+ options = parse_options()
+
if os.getegid() != 0:
print "Must be root to setup server"
return
@@ -399,17 +273,17 @@ def main():
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGINT, signal_handler)
+ standard_logging_setup("ipaserver-install.log", options.debug)
+
print "=============================================================================="
print "This program will setup the FreeIPA Server."
print ""
print "To accept the default shown in brackets, press the Enter key."
print ""
- check_existing_installation()
- check_ports()
+ ipaserver.dsinstance.check_existing_installation()
+ ipaserver.dsinstance.check_ports()
- options = parse_options()
- logging_setup(options)
ds_user = ""
realm_name = ""
@@ -439,10 +313,13 @@ def main():
host_default = get_fqdn()
if options.unattended:
- if not verify_fqdn(host_default):
+ try:
+ verify_fqdn(host_default)
+ except RuntimeError, e:
+ logging.error(str(e) + "\n")
return "-Fatal Error-"
- else:
- host_name = host_default
+
+ host_name = host_default
else:
host_name = read_host_name(host_default)
diff --git a/ipa-server/ipa-install/share/kerberos.ldif b/ipa-server/ipa-install/share/kerberos.ldif
index d55f39ce4..75057aa3a 100644
--- a/ipa-server/ipa-install/share/kerberos.ldif
+++ b/ipa-server/ipa-install/share/kerberos.ldif
@@ -14,22 +14,4 @@ objectClass: top
cn: kerberos
aci: (targetattr="*")(version 3.0; acl "KDC System Account"; allow (all) userdn= "ldap:///uid=kdc,cn=sysaccounts,cn=etc,$SUFFIX";)
-#sasl mapping
-dn: cn=Full Principal,cn=mapping,cn=sasl,cn=config
-changetype: add
-objectclass: top
-objectclass: nsSaslMapping
-cn: Full Principal
-nsSaslMapRegexString: \(.*\)@\(.*\)
-nsSaslMapBaseDNTemplate: $SUFFIX
-nsSaslMapFilterTemplate: (krbPrincipalName=\1@\2)
-
-dn: cn=Name Only,cn=mapping,cn=sasl,cn=config
-changetype: add
-objectclass: top
-objectclass: nsSaslMapping
-cn: Name Only
-nsSaslMapRegexString: \(.*\)
-nsSaslMapBaseDNTemplate: $SUFFIX
-nsSaslMapFilterTemplate: (krbPrincipalName=\1@$REALM)
diff --git a/ipa-server/ipaserver/Makefile.am b/ipa-server/ipaserver/Makefile.am
index 25b856878..c2d164b96 100644
--- a/ipa-server/ipaserver/Makefile.am
+++ b/ipa-server/ipaserver/Makefile.am
@@ -12,6 +12,8 @@ app_PYTHON = \
radiusinstance.py \
webguiinstance.py \
service.py \
+ installutils.py \
+ replication.py \
$(NULL)
EXTRA_DIST = \
diff --git a/ipa-server/ipaserver/dsinstance.py b/ipa-server/ipaserver/dsinstance.py
index 3cf80f46a..79a57182f 100644
--- a/ipa-server/ipaserver/dsinstance.py
+++ b/ipa-server/ipaserver/dsinstance.py
@@ -24,10 +24,14 @@ import tempfile
import shutil
import logging
import pwd
+import glob
+import sys
from ipa.ipautil import *
import service
+import installutils
+
SERVER_ROOT_64 = "/usr/lib64/dirsrv"
SERVER_ROOT_32 = "/usr/lib/dirsrv"
@@ -35,9 +39,6 @@ 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)
- text = fd.read()
- print text
-
def realm_to_suffix(realm_name):
s = realm_name.split(".")
terms = ["dc=" + x.lower() for x in s]
@@ -49,6 +50,61 @@ def find_server_root():
else:
return SERVER_ROOT_32
+def realm_to_serverid(realm_name):
+ return "-".join(realm_name.split("."))
+
+def config_dirname(realm_name):
+ return "/etc/dirsrv/slapd-" + realm_to_serverid(realm_name) + "/"
+
+def schema_dirname(realm_name):
+ return config_dirname(realm_name) + "/schema/"
+
+def erase_ds_instance_data(serverid):
+ try:
+ shutil.rmtree("/etc/dirsrv/slapd-%s" % serverid)
+ except:
+ pass
+ try:
+ shutil.rmtree("/var/lib/dirsrv/slapd-%s" % serverid)
+ except:
+ pass
+ try:
+ shutil.rmtree("/var/lock/dirsrv/slapd-%s" % serverid)
+ except:
+ pass
+
+def check_existing_installation():
+ dirs = glob.glob("/etc/dirsrv/slapd-*")
+ if not dirs:
+ return
+ print ""
+ print "An existing Directory Server has been detected."
+ yesno = raw_input("Do you wish to remove it and create a new one? [no]: ")
+ if not yesno or yesno.lower()[0] != "y":
+ sys.exit(1)
+
+ try:
+ run(["/sbin/service", "dirsrv", "stop"])
+ except:
+ pass
+ for d in dirs:
+ serverid = os.path.basename(d).split("slapd-", 1)[1]
+ if serverid:
+ erase_ds_instance_data(serverid)
+
+def check_ports():
+ ds_unsecure = installutils.port_available(389)
+ ds_secure = installutils.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)
+
+
INF_TEMPLATE = """
[General]
FullMachineName= $FQHN
@@ -72,20 +128,25 @@ class DsInstance(service.Service):
self.dm_password = None
self.sub_dict = None
- def create_instance(self, ds_user, realm_name, host_name, dm_password):
+ def create_instance(self, ds_user, realm_name, host_name, dm_password, ro_replica=False):
self.ds_user = ds_user
self.realm_name = realm_name.upper()
- self.serverid = "-".join(self.realm_name.split("."))
+ self.serverid = realm_to_serverid(self.realm_name)
self.suffix = realm_to_suffix(self.realm_name)
self.host_name = host_name
self.dm_password = dm_password
self.__setup_sub_dict()
+
+ if ro_replica:
+ self.start_creation(15, "Configuring directory server:")
+ else:
+ self.start_creation(15, "Configuring directory server:")
- self.start_creation(15, "Configuring directory server:")
self.__create_ds_user()
self.__create_instance()
self.__add_default_schemas()
- self.__add_memberof_module()
+ if not ro_replica:
+ self.__add_memberof_module()
self.__add_referint_module()
self.__add_dna_module()
self.__create_indeces()
@@ -97,10 +158,11 @@ class DsInstance(service.Service):
except:
# TODO: roll back here?
logging.critical("Failed to restart the ds instance")
- self.__config_uidgid_gen_first_master()
self.__add_default_layout()
- self.__add_master_entry_first_master()
- self.__init_memberof()
+ if not ro_replica:
+ self.__config_uidgid_gen_first_master()
+ self.__add_master_entry_first_master()
+ self.__init_memberof()
self.step("configuring directoy to start on boot")
@@ -108,14 +170,6 @@ class DsInstance(service.Service):
self.done_creation()
- def config_dirname(self):
- if not self.serverid:
- raise RuntimeError("serverid not set")
- return "/etc/dirsrv/slapd-" + self.serverid + "/"
-
- def schema_dirname(self):
- return self.config_dirname() + "/schema/"
-
def __setup_sub_dict(self):
server_root = find_server_root()
self.sub_dict = dict(FQHN=self.host_name, SERVERID=self.serverid,
@@ -165,13 +219,13 @@ class DsInstance(service.Service):
def __add_default_schemas(self):
self.step("adding default schema")
shutil.copyfile(SHARE_DIR + "60kerberos.ldif",
- self.schema_dirname() + "60kerberos.ldif")
+ schema_dirname(self.realm_name) + "60kerberos.ldif")
shutil.copyfile(SHARE_DIR + "60samba.ldif",
- self.schema_dirname() + "60samba.ldif")
+ schema_dirname(self.realm_name) + "60samba.ldif")
shutil.copyfile(SHARE_DIR + "60radius.ldif",
- self.schema_dirname() + "60radius.ldif")
+ schema_dirname(self.realm_name) + "60radius.ldif")
shutil.copyfile(SHARE_DIR + "60ipaconfig.ldif",
- self.schema_dirname() + "60ipaconfig.ldif")
+ schema_dirname(self.realm_name) + "60ipaconfig.ldif")
def __add_memberof_module(self):
self.step("enabling memboerof plugin")
@@ -235,7 +289,7 @@ class DsInstance(service.Service):
def __enable_ssl(self):
self.step("configuring ssl for ds instance")
- dirname = self.config_dirname()
+ dirname = config_dirname(self.realm_name)
args = ["/usr/share/ipa/ipa-server-setupssl", self.dm_password,
dirname, self.host_name]
try:
@@ -273,7 +327,7 @@ class DsInstance(service.Service):
def __certmap_conf(self):
self.step("configuring certmap.conf")
- dirname = self.config_dirname()
+ dirname = config_dirname(self.realm_name)
certmap_conf = template_file(SHARE_DIR+"certmap.conf.template", self.sub_dict)
certmap_fd = open(dirname+"certmap.conf", "w+")
certmap_fd.write(certmap_conf)
@@ -281,7 +335,7 @@ class DsInstance(service.Service):
def change_admin_password(self, password):
logging.debug("Changing admin password")
- dirname = self.config_dirname()
+ dirname = config_dirname(self.realm_name)
if dir_exists("/usr/lib64/mozldap"):
app = "/usr/lib64/mozldap/ldappasswd"
else:
diff --git a/ipa-server/ipaserver/installutils.py b/ipa-server/ipaserver/installutils.py
new file mode 100644
index 000000000..a403e8154
--- /dev/null
+++ b/ipa-server/ipaserver/installutils.py
@@ -0,0 +1,108 @@
+# Authors: Simo Sorce
+#
+# Copyright (C) 2007 Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; version 2 or later
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+import logging
+import socket
+import errno
+import getpass
+
+def get_fqdn():
+ fqdn = ""
+ try:
+ fqdn = socket.getfqdn()
+ except:
+ try:
+ fqdn = socket.gethostname()
+ except:
+ fqdn = ""
+ return fqdn
+
+def verify_fqdn(host_name):
+ if len(host_name.split(".")) < 2 or host_name == "localhost.localdomain":
+ raise RuntimeError("Invalid hostname: " + host_name)
+
+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 standard_logging_setup(log_filename, debug=False):
+ # Always log everything (i.e., DEBUG) to the log
+ # file.
+ logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s %(levelname)s %(message)s',
+ filename=log_filename,
+ filemode='w')
+
+ console = logging.StreamHandler()
+ # If the debug option is set, also log debug messages to the console
+ if debug:
+ console.setLevel(logging.DEBUG)
+ else:
+ # Otherwise, log critical and error messages
+ console.setLevel(logging.ERROR)
+ formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
+ console.setFormatter(formatter)
+ logging.getLogger('').addHandler(console)
+
+def read_password(user):
+ correct = False
+ pwd = ""
+ while not correct:
+ pwd = getpass.getpass(user + " password: ")
+ if not pwd:
+ continue
+ if len(pwd) < 8:
+ print "Password must be at least 8 characters long"
+ continue
+ pwd_confirm = getpass.getpass("Password (confirm): ")
+ if pwd != pwd_confirm:
+ print "Password mismatch!"
+ print ""
+ else:
+ correct = True
+ print ""
+ return pwd
+
+
diff --git a/ipa-server/ipaserver/ipaldap.py b/ipa-server/ipaserver/ipaldap.py
index d319869dc..ef8becec5 100644
--- a/ipa-server/ipaserver/ipaldap.py
+++ b/ipa-server/ipaserver/ipaldap.py
@@ -176,25 +176,90 @@ def wrapper(f,name):
return f(*args, **kargs)
return inner
+class LDIFConn(ldif.LDIFParser):
+ def __init__(
+ self,
+ input_file,
+ ignored_attr_types=None,max_entries=0,process_url_schemes=None
+ ):
+ """
+ See LDIFParser.__init__()
+
+ Additional Parameters:
+ all_records
+ List instance for storing parsed records
+ """
+ self.dndict = {} # maps dn to Entry
+ self.dnlist = [] # contains entries in order read
+ myfile = input_file
+ if isinstance(input_file,str) or isinstance(input_file,unicode):
+ myfile = open(input_file, "r")
+ ldif.LDIFParser.__init__(self,myfile,ignored_attr_types,max_entries,process_url_schemes)
+ self.parse()
+ if isinstance(input_file,str) or isinstance(input_file,unicode):
+ myfile.close()
+
+ def handle(self,dn,entry):
+ """
+ Append single record to dictionary of all records.
+ """
+ if not dn:
+ dn = ''
+ newentry = Entry((dn, entry))
+ self.dndict[IPAdmin.normalizeDN(dn)] = newentry
+ self.dnlist.append(newentry)
+
+ def get(self,dn):
+ ndn = IPAdmin.normalizeDN(dn)
+ return self.dndict.get(ndn, Entry(None))
+
class IPAdmin(SimpleLDAPObject):
CFGSUFFIX = "o=NetscapeRoot"
DEFAULT_USER_ID = "nobody"
+
+ def getDseAttr(self,attrname):
+ conffile = self.confdir + '/dse.ldif'
+ dseldif = LDIFConn(conffile)
+ cnconfig = dseldif.get("cn=config")
+ if cnconfig:
+ return cnconfig.getValue(attrname)
+ return None
def __initPart2(self):
if self.binddn and len(self.binddn) and not hasattr(self,'sroot'):
try:
ent = self.getEntry('cn=config', ldap.SCOPE_BASE, '(objectclass=*)',
- [ 'nsslapd-instancedir', 'nsslapd-errorlog' ])
- instdir = ent.getValue('nsslapd-instancedir')
- self.sroot, self.inst = re.match(r'(.*)[\/]slapd-(\w+)$', instdir).groups()
+ [ 'nsslapd-instancedir', 'nsslapd-errorlog',
+ 'nsslapd-certdir', 'nsslapd-schemadir' ])
self.errlog = ent.getValue('nsslapd-errorlog')
- except (ldap.INSUFFICIENT_ACCESS, ldap.CONNECT_ERROR,
- ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND)):
+ self.confdir = None
+ if self.isLocal:
+ self.confdir = ent.getValue('nsslapd-certdir')
+ if not self.confdir or not os.access(self.confdir + '/dse.ldif', os.R_OK):
+ self.confdir = ent.getValue('nsslapd-schemadir')
+ if self.confdir:
+ self.confdir = os.path.dirname(self.confdir)
+ instdir = ent.getValue('nsslapd-instancedir')
+ if not instdir:
+ # get instance name from errorlog
+ self.inst = re.match(r'(.*)[\/]slapd-([\w-]+)/errors', self.errlog).group(2)
+ if self.confdir:
+ instdir = self.getDseAttr('nsslapd-instancedir')
+ else:
+ if self.isLocal:
+ print instdir
+ self.sroot, self.inst = re.match(r'(.*)[\/]slapd-([\w-]+)$', instdir).groups()
+ instdir = re.match(r'(.*/slapd-.*)/errors', self.errlog).group(1)
+ #self.sroot, self.inst = re.match(r'(.*)[\/]slapd-([\w-]+)$', instdir).groups()
+ ent = self.getEntry('cn=config,cn=ldbm database,cn=plugins,cn=config',
+ ldap.SCOPE_BASE, '(objectclass=*)',
+ [ 'nsslapd-directory' ])
+ self.dbdir = os.path.dirname(ent.getValue('nsslapd-directory'))
+ except (ldap.INSUFFICIENT_ACCESS, ldap.CONNECT_ERROR):
pass # usually means
-# print "ignored exception"
except ldap.LDAPError, e:
print "caught exception ", e
- raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR, None, e)
+ raise
def __localinit__(self):
"""If a CA certificate is provided then it is assumed that we are
@@ -209,7 +274,7 @@ class IPAdmin(SimpleLDAPObject):
else:
SimpleLDAPObject.__init__(self,'ldap://%s:%d' % (self.host,self.port))
- def __init__(self,host,port,cacert,bindcert,bindkey,proxydn=None,debug=None):
+ def __init__(self,host,port=389,cacert=None,bindcert=None,bindkey=None,proxydn=None,debug=None):
"""We just set our instance variables and wrap the methods - the real
work is done in __localinit__ and __initPart2 - these are separated
out this way so that we can call them from places other than
@@ -223,7 +288,7 @@ class IPAdmin(SimpleLDAPObject):
ldap.set_option(ldap.OPT_X_TLS_KEYFILE,bindkey)
self.__wrapmethods()
- self.port = port or 389
+ self.port = port
self.host = host
self.cacert = cacert
self.bindcert = bindcert
@@ -272,6 +337,12 @@ class IPAdmin(SimpleLDAPObject):
self.principal = principal
self.proxydn = None
+ def do_simple_bind(self, binddn="cn=directory manager", bindpw=""):
+ self.binddn = binddn
+ self.bindpwd = bindpw
+ self.simple_bind_s(binddn, bindpw)
+ self.__initPart2()
+
def getEntry(self,*args):
"""This wraps the search function. It is common to just get one entry"""
@@ -283,8 +354,9 @@ class IPAdmin(SimpleLDAPObject):
try:
res = self.search(*args)
type, obj = self.result(res)
-
- # res = self.search_ext(args[0], args[1], filterstr=args[2], attrlist=args[3], serverctrls=sctrl)
+ except ldap.NO_SUCH_OBJECT:
+ raise ipaerror.gen_exception(ipaerror.LDAP_NOT_FOUND,
+ "no such entry for " + str(args))
except ldap.LDAPError, e:
raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR, None, e)
@@ -538,7 +610,7 @@ class IPAdmin(SimpleLDAPObject):
print "Export task %s for file %s completed successfully" % (cn,file)
return rc
- def waitForEntry(self, dn, timeout=7200, attr='', quiet=False):
+ def waitForEntry(self, dn, timeout=7200, attr='', quiet=True):
scope = ldap.SCOPE_BASE
filter = "(objectclass=*)"
attrlist = []
@@ -560,7 +632,8 @@ class IPAdmin(SimpleLDAPObject):
entry = self.getEntry(dn, scope, filter, attrlist)
except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
pass # found entry, but no attr
- except ldap.NO_SUCH_OBJECT: pass # no entry yet
+ except ldap.NO_SUCH_OBJECT:
+ pass # no entry yet
except ldap.LDAPError, e: # badness
print "\nError reading entry", dn, e
break
@@ -574,7 +647,7 @@ class IPAdmin(SimpleLDAPObject):
print "\nwaitForEntry timeout for %s for %s" % (self,dn)
elif entry and not quiet:
print "\nThe waited for entry is:", entry
- else:
+ elif not entry:
print "\nError: could not read entry %s from %s" % (dn,self)
return entry
diff --git a/ipa-server/ipaserver/krbinstance.py b/ipa-server/ipaserver/krbinstance.py
index 827c98153..aca9e2613 100644
--- a/ipa-server/ipaserver/krbinstance.py
+++ b/ipa-server/ipaserver/krbinstance.py
@@ -32,16 +32,21 @@ import os
import pwd
import socket
import time
+import shutil
import service
from ipa.ipautil import *
+from ipa import ipaerror
+
+import ipaldap
import ldap
from ldap import LDAPError
from ldap import ldapobject
-from pyasn1.type import univ
+from pyasn1.type import univ, namedtype
import pyasn1.codec.ber.encoder
+import pyasn1.codec.ber.decoder
import struct
import base64
@@ -88,18 +93,26 @@ class KrbInstance(service.Service):
self.kdc_password = None
self.sub_dict = None
- def create_instance(self, ds_user, realm_name, host_name, admin_password, master_password):
+ def __common_setup(self, ds_user, realm_name, host_name, admin_password):
self.ds_user = ds_user
- self.fqdn = host_name
- self.ip = socket.gethostbyname(host_name)
+ self.fqdn = host_name
self.realm = realm_name.upper()
self.host = host_name.split(".")[0]
- self.domain = host_to_domain(host_name)
- self.admin_password = admin_password
- self.master_password = master_password
-
+ self.ip = socket.gethostbyname(host_name)
+ self.domain = host_to_domain(host_name)
self.suffix = realm_to_suffix(self.realm)
self.kdc_password = generate_kdc_password()
+ self.admin_password = admin_password
+
+ self.__setup_sub_dict()
+
+ # get a connection to the DS
+ try:
+ self.conn = ipaldap.IPAdmin(self.fqdn)
+ self.conn.do_simple_bind(bindpw=self.admin_password)
+ except ipaerror.exception_for(ipaerror.LDAP_DATABASE_ERROR), e:
+ logging.critical("Could not connect to DS")
+ raise e
try:
self.stop()
@@ -107,22 +120,7 @@ class KrbInstance(service.Service):
# It could have been not running
pass
- self.start_creation(10, "Configuring Kerberos KDC")
-
- self.__configure_kdc_account_password()
-
- self.__setup_sub_dict()
-
- self.__configure_ldap()
-
- self.__create_instance()
-
- self.__create_ds_keytab()
-
- self.__export_kadmin_changepw_keytab()
-
- self.__add_pwd_extop_module()
-
+ def __common_post_setup(self):
try:
self.step("starting the KDC")
self.start()
@@ -138,8 +136,48 @@ class KrbInstance(service.Service):
self.step("starting ipa-kpasswd")
service.start("ipa-kpasswd")
+
+ def create_instance(self, ds_user, realm_name, host_name, admin_password, master_password):
+ self.master_password = master_password
+
+ self.__common_setup(ds_user, realm_name, host_name, admin_password)
+
+ self.start_creation(11, "Configuring Kerberos KDC")
+
+ self.__configure_kdc_account_password()
+ self.__configure_sasl_mappings()
+ self.__add_krb_entries()
+ self.__create_instance()
+ self.__create_ds_keytab()
+ self.__export_kadmin_changepw_keytab()
+ self.__add_pwd_extop_module()
+
+ self.__common_post_setup()
+
self.done_creation()
+
+ def create_replica(self, ds_user, realm_name, host_name, admin_password, ldap_passwd_filename):
+
+ self.__common_setup(ds_user, realm_name, host_name, admin_password)
+
+ self.start_creation(9, "Configuring Kerberos KDC")
+ self.__copy_ldap_passwd(ldap_passwd_filename)
+ self.__configure_sasl_mappings()
+ self.__write_stash_from_ds()
+ self.__create_instance(replica=True)
+ self.__create_ds_keytab()
+ self.__export_kadmin_changepw_keytab()
+
+ self.__common_post_setup()
+
+ self.done_creation()
+
+
+ def __copy_ldap_passwd(self, filename):
+ shutil.copy(filename, "/var/kerberos/krb5kdc/ldappwd")
+
+
def __configure_kdc_account_password(self):
self.step("setting KDC account password")
hexpwd = ''
@@ -158,23 +196,60 @@ class KrbInstance(service.Service):
HOST=self.host,
REALM=self.realm)
- def __configure_ldap(self):
- self.step("adding kerberos configuration to the directory")
+ def __configure_sasl_mappings(self):
+ self.step("adding sasl mappings to the directory")
# we need to remove any existing SASL mappings in the directory as otherwise they
# they may conflict. There is no way to define the order they are used in atm.
- try:
- lo = ldapobject.SimpleLDAPObject("ldap://127.0.0.1/")
- lo.bind("cn=Directory Manager", self.admin_password)
- msgid = lo.search("cn=mapping,cn=sasl,cn=config", ldap.SCOPE_ONELEVEL, "(objectclass=nsSaslMapping)")
- res = lo.result(msgid)
- for r in res[1]:
- mid = lo.delete(r[0])
- delres = lo.result(mid)
- lo.unbind()
- except LDAPError, e:
- logging.critical("Error during SASL mapping removal: %s" % str(e))
- #TODO: test that the ldif is ok with any random charcter we may use in the password
+ # FIXME: for some reason IPAdmin dies here, so we switch
+ # it out for a regular ldapobject.
+ conn = self.conn
+ self.conn = ldapobject.SimpleLDAPObject("ldap://127.0.0.1/")
+ self.conn.bind("cn=directory manager", self.admin_password)
+ try:
+ msgid = self.conn.search("cn=mapping,cn=sasl,cn=config", ldap.SCOPE_ONELEVEL, "(objectclass=nsSaslMapping)")
+ res = self.conn.result(msgid)
+ for r in res[1]:
+ mid = self.conn.delete_s(r[0])
+ #except LDAPError, e:
+ # logging.critical("Error during SASL mapping removal: %s" % str(e))
+ except Exception, e:
+ print type(e)
+ print dir(e)
+ raise e
+
+ self.conn = conn
+
+ entry = ipaldap.Entry("cn=Full Principal,cn=mapping,cn=sasl,cn=config")
+ entry.setValues("objectclass", "top", "nsSaslMapping")
+ entry.setValues("cn", "Full Principal")
+ entry.setValues("nsSaslMapRegexString", '\(.*\)@\(.*\)')
+ entry.setValues("nsSaslMapBaseDNTemplate", self.suffix)
+ entry.setValues("nsSaslMapFilterTemplate", '(krbPrincipalName=\\1@\\2)')
+
+ try:
+ self.conn.add_s(entry)
+ except ldap.ALREADY_EXISTS:
+ logging.critical("failed to add Full Principal Sasl mapping")
+ raise e
+
+ entry = ipaldap.Entry("cn=Name Only,cn=mapping,cn=sasl,cn=config")
+ entry.setValues("objectclass", "top", "nsSaslMapping")
+ entry.setValues("cn", "Name Only")
+ entry.setValues("nsSaslMapRegexString", '\(.*\)')
+ entry.setValues("nsSaslMapBaseDNTemplate", self.suffix)
+ entry.setValues("nsSaslMapFilterTemplate", '(krbPrincipalName=\\1@%s)' % self.realm)
+
+ try:
+ self.conn.add_s(entry)
+ except ldap.ALREADY_EXISTS:
+ logging.critical("failed to add Name Only Sasl mapping")
+ raise e
+
+ def __add_krb_entries(self):
+ self.step("adding kerberos entries to the DS")
+
+ #TODO: test that the ldif is ok with any random charcter we may use in the password
kerberos_txt = template_file(SHARE_DIR + "kerberos.ldif", self.sub_dict)
kerberos_fd = write_tmp_file(kerberos_txt)
try:
@@ -192,7 +267,7 @@ class KrbInstance(service.Service):
logging.critical("Failed to load default-aci.ldif: %s" % str(e))
aci_fd.close()
- def __create_instance(self):
+ def __create_instance(self, replica=False):
self.step("configuring KDC")
kdc_conf = template_file(SHARE_DIR+"kdc.conf.template", self.sub_dict)
kdc_fd = open("/var/kerberos/krb5kdc/kdc.conf", "w+")
@@ -220,12 +295,34 @@ class KrbInstance(service.Service):
krb_fd.write(krb_realm)
krb_fd.close()
- #populate the directory with the realm structure
- 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"]
+ if not replica:
+ #populate the directory with the realm structure
+ 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:
+ print "Failed to populate the realm structure in kerberos", e
+
+ def __write_stash_from_ds(self):
+ self.step("writing stash file from DS")
try:
- run(args)
- except subprocess.CalledProcessError, e:
- print "Failed to populate the realm structure in kerberos", e
+ entry = self.conn.getEntry("cn=%s, cn=kerberos, %s" % (self.realm, self.suffix), ldap.SCOPE_SUBTREE)
+ except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND), e:
+ logging.critical("Could not find master key in DS")
+ raise e
+
+ krbMKey = pyasn1.codec.ber.decoder.decode(entry.krbmkey)
+ keytype = int(krbMKey[0][1][0])
+ keydata = str(krbMKey[0][1][1])
+
+ format = '=hi%ss' % len(keydata)
+ s = struct.pack(format, keytype, len(keydata), keydata)
+ try:
+ fd = open("/var/kerberos/krb5kdc/.k5."+self.realm, "w")
+ fd.write(s)
+ except os.error, e:
+ logging.critical("failed to write stash file")
+ raise e
#add the password extop module
def __add_pwd_extop_module(self):
@@ -255,18 +352,14 @@ class KrbInstance(service.Service):
krbMKey.setComponentByPosition(1, MasterKey)
asn1key = pyasn1.codec.ber.encoder.encode(krbMKey)
- #put the attribute in the Directory
- mod_txt = "dn: cn="+self.realm+",cn=kerberos,"+self.suffix+"\n"
- mod_txt += "changetype: modify\n"
- mod_txt += "add: krbMKey\n"
- mod_txt += "krbMKey:: "+base64.encodestring(asn1key)+"\n"
- mod_txt += "\n"
- mod_fd = write_tmp_file(mod_txt)
+ entry = ipaldap.Entry("cn="+self.realm+",cn=kerberos,"+self.suffix)
+ dn = "cn="+self.realm+",cn=kerberos,"+self.suffix
+ mod = [(ldap.MOD_ADD, 'krbMKey', str(asn1key))]
try:
- ldap_mod(mod_fd, "cn=Directory Manager", self.admin_password)
- except subprocess.CalledProcessError, e:
- logging.critical("Failed to load Master Key: %s" % str(e))
- mod_fd.close()
+ self.conn.modify_s(dn, mod)
+ except ldap.TYPE_OR_VALUE_EXISTS, e:
+ logging.critical("failed to add master key to kerberos database\n")
+ raise e
def __create_ds_keytab(self):
self.step("creating a keytab for the directory")
diff --git a/ipa-server/ipaserver/radiusinstance.py b/ipa-server/ipaserver/radiusinstance.py
index 2aee09b33..72cfe6cb6 100644
--- a/ipa-server/ipaserver/radiusinstance.py
+++ b/ipa-server/ipaserver/radiusinstance.py
@@ -25,6 +25,7 @@ import shutil
import logging
import pwd
import time
+import sys
from ipa.ipautil import *
import service
@@ -149,7 +150,7 @@ class RadiusInstance(service.Service):
retry += 1
if retry > 15:
print "Error timed out waiting for kadmin to finish operations\n"
- os.exit()
+ sys.exit(1)
try:
pent = pwd.getpwnam(RADIUS_USER)
From 7ce4df70388ebfa34eed8ac05effb72593e06cd8 Mon Sep 17 00:00:00 2001
From: Karl MacMillan
Date: Wed, 21 Nov 2007 18:04:13 -0500
Subject: [PATCH 53/60] Added replication.py
---
ipa-server/ipaserver/replication.py | 316 ++++++++++++++++++++++++++++
1 file changed, 316 insertions(+)
create mode 100644 ipa-server/ipaserver/replication.py
diff --git a/ipa-server/ipaserver/replication.py b/ipa-server/ipaserver/replication.py
new file mode 100644
index 000000000..580ec27bf
--- /dev/null
+++ b/ipa-server/ipaserver/replication.py
@@ -0,0 +1,316 @@
+# Authors: Karl MacMillan
+#
+# Copyright (C) 2007 Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; version 2 or later
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+import time, logging
+
+import ipaldap, ldap, dsinstance
+from ipa import ipaerror
+
+DIRMAN_CN = "cn=directory manager"
+PORT = 389
+TIMEOUT = 120
+
+class ReplicationManager:
+ """Manage replicatin agreements between DS servers"""
+ def __init__(self, hostname, dirman_passwd):
+ self.hostname = hostname
+ self.dirman_passwd = dirman_passwd
+ self.conn = ipaldap.IPAdmin(hostname)
+ self.conn.do_simple_bind(bindpw=dirman_passwd)
+
+ self.repl_man_passwd = dirman_passwd
+
+ # these are likely constant, but you could change them
+ # at runtime if you really want
+ self.repl_man_dn = "cn=replication manager,cn=config"
+ self.repl_man_cn = "replication manager"
+ self.suffix = ""
+
+ def find_replication_dns(self, conn):
+ filt = "(objectlcass=nsds5ReplicationAgreement)"
+ try:
+ ents = conn.search_s("cn=mapping tree,cn-config", ldap.SCOPE_SUBTREE, filt, ["cn"])
+ except ldap.NO_SUCH_OBJECT:
+ return []
+ return [ent.dn for ent in ents]
+
+ def add_replication_manager(self, conn, passwd=None):
+ """
+ Create a pseudo user to use for replication. If no password
+ is provided the directory manager password will be used.
+ """
+
+ if passwd:
+ self.repl_man_passwd = passwd
+
+ ent = ipaldap.Entry(self.repl_man_dn)
+ ent.setValues("objectclass", "top", "person")
+ ent.setValues("cn", self.repl_man_cn)
+ ent.setValues("userpassword", self.repl_man_passwd)
+ ent.setValues("sn", "replication manager pseudo user")
+
+ try:
+ conn.add_s(ent)
+ except ldap.ALREADY_EXISTS:
+ # should we set the password here?
+ pass
+
+ def delete_replication_manager(self, conn, dn="cn=replication manager,cn=config"):
+ try:
+ conn.delete_s(dn)
+ except ldap.NO_SUCH_OBJECT:
+ pass
+
+ def get_replica_type(self, master):
+ if master:
+ return "3"
+ else:
+ return "2"
+
+ def replica_dn(self):
+ return 'cn=replica, cn="%s", cn=mapping tree, cn=config' % self.suffix
+
+
+ def local_replica_config(self, conn, master, replica_id):
+ dn = self.replica_dn()
+
+ try:
+ conn.getEntry(dn, ldap.SCOPE_BASE)
+ # replication is already configured
+ return
+ except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
+ pass
+
+ replica_type = self.get_replica_type(master)
+
+ entry = ipaldap.Entry(dn)
+ entry.setValues('objectclass', "top", "nsds5replica", "extensibleobject")
+ entry.setValues('cn', "replica")
+ entry.setValues('nsds5replicaroot', self.suffix)
+ entry.setValues('nsds5replicaid', str(replica_id))
+ entry.setValues('nsds5replicatype', replica_type)
+ entry.setValues('nsds5flags', "1")
+ entry.setValues('nsds5replicabinddn', [self.repl_man_dn])
+ entry.setValues('nsds5replicalegacyconsumer', "off")
+
+ conn.add_s(entry)
+
+ def setup_changelog(self, conn):
+ dn = "cn=changelog5, cn=config"
+ dirpath = conn.dbdir + "/cldb"
+ entry = ipaldap.Entry(dn)
+ entry.setValues('objectclass', "top", "extensibleobject")
+ entry.setValues('cn', "changelog5")
+ entry.setValues('nsslapd-changelogdir', dirpath)
+ try:
+ conn.add_s(entry)
+ except ldap.ALREADY_EXISTS:
+ return
+
+ def setup_chaining_backend(self, conn):
+ chaindn = "cn=chaining database, cn=plugins, cn=config"
+ benamebase = "chaindb"
+ urls = [self.to_ldap_url(conn)]
+ cn = ""
+ benum = 1
+ done = False
+ while not done:
+ try:
+ cn = benamebase + str(benum) # e.g. localdb1
+ dn = "cn=" + cn + ", " + chaindn
+ entry = ipaldap.Entry(dn)
+ entry.setValues('objectclass', 'top', 'extensibleObject', 'nsBackendInstance')
+ entry.setValues('cn', cn)
+ entry.setValues('nsslapd-suffix', self.suffix)
+ entry.setValues('nsfarmserverurl', urls)
+ entry.setValues('nsmultiplexorbinddn', self.repl_man_dn)
+ entry.setValues('nsmultiplexorcredentials', self.repl_man_passwd)
+
+ self.conn.add_s(entry)
+ done = True
+ except ldap.ALREADY_EXISTS:
+ benum += 1
+ except ldap.LDAPError, e:
+ print "Could not add backend entry " + dn, e
+ raise
+
+ return cn
+
+ def to_ldap_url(self, conn):
+ return "ldap://%s:%d/" % (conn.host, conn.port)
+
+ def setup_chaining_farm(self, conn):
+ try:
+ conn.modify_s(self.suffix, [(ldap.MOD_ADD, 'aci',
+ [ "(targetattr = \"*\")(version 3.0; acl \"Proxied authorization for database links\"; allow (proxy) userdn = \"ldap:///%s\";)" % self.repl_man_dn ])])
+ except ldap.TYPE_OR_VALUE_EXISTS:
+ logging.debug("proxy aci already exists in suffix %s on %s" % (self.suffix, conn.host))
+
+ def get_mapping_tree_entry(self):
+ try:
+ entry = self.conn.getEntry("cn=mapping tree,cn=config", ldap.SCOPE_ONELEVEL,
+ "(cn=\"%s\")" % (self.suffix))
+ except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND), e:
+ logging.debug("failed to find mappting tree entry for %s" % self.suffix)
+ raise e
+
+ return entry
+
+
+ def enable_chain_on_update(self, bename):
+ mtent = self.get_mapping_tree_entry()
+ dn = mtent.dn
+
+ plgent = self.conn.getEntry("cn=Multimaster Replication Plugin,cn=plugins,cn=config",
+ ldap.SCOPE_BASE, "(objectclass=*)", ['nsslapd-pluginPath'])
+ path = plgent.getValue('nsslapd-pluginPath')
+
+ mod = [(ldap.MOD_REPLACE, 'nsslapd-state', 'backend'),
+ (ldap.MOD_ADD, 'nsslapd-backend', bename),
+ (ldap.MOD_ADD, 'nsslapd-distribution-plugin', path),
+ (ldap.MOD_ADD, 'nsslapd-distribution-funct', 'repl_chain_on_update')]
+
+ try:
+ self.conn.modify_s(dn, mod)
+ except ldap.TYPE_OR_VALUE_EXISTS:
+ logging.debug("chainOnUpdate already enabled for %s" % self.suffix)
+
+
+ def setup_chain_on_update(self, other_conn):
+ chainbe = self.setup_chaining_backend(other_conn)
+ self.enable_chain_on_update(chainbe)
+
+
+ def agreement_dn(self, conn):
+ cn = "meTo%s%d" % (conn.host, PORT)
+ dn = "cn=%s, %s" % (cn, self.replica_dn())
+
+ return (cn, dn)
+
+
+ def setup_agreement(self, a, b):
+ cn, dn = self.agreement_dn(b)
+ try:
+ a.getEntry(dn, ldap.SCOPE_BASE)
+ return
+ except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
+ pass
+
+ entry = ipaldap.Entry(dn)
+ entry.setValues('objectclass', "top", "nsds5replicationagreement")
+ entry.setValues('cn', cn)
+ entry.setValues('nsds5replicahost', b.host)
+ entry.setValues('nsds5replicaport', str(PORT))
+ entry.setValues('nsds5replicatimeout', str(TIMEOUT))
+ entry.setValues('nsds5replicabinddn', self.repl_man_dn)
+ entry.setValues('nsds5replicacredentials', self.repl_man_passwd)
+ entry.setValues('nsds5replicabindmethod', 'simple')
+ entry.setValues('nsds5replicaroot', self.suffix)
+ entry.setValues('nsds5replicaupdateschedule', '0000-2359 0123456')
+ entry.setValues('description', "me to %s%d" % (b.host, PORT))
+
+ a.add_s(entry)
+
+ entry = a.waitForEntry(entry)
+
+
+ def check_repl_init(self, conn, agmtdn):
+ done = False
+ hasError = 0
+ attrlist = ['cn', 'nsds5BeginReplicaRefresh', 'nsds5replicaUpdateInProgress',
+ 'nsds5ReplicaLastInitStatus', 'nsds5ReplicaLastInitStart',
+ 'nsds5ReplicaLastInitEnd']
+ entry = conn.getEntry(agmtdn, ldap.SCOPE_BASE, "(objectclass=*)", attrlist)
+ if not entry:
+ print "Error reading status from agreement", agmtdn
+ hasError = 1
+ else:
+ refresh = entry.nsds5BeginReplicaRefresh
+ inprogress = entry.nsds5replicaUpdateInProgress
+ status = entry.nsds5ReplicaLastInitStatus
+ if not refresh: # done - check status
+ if not status:
+ print "No status yet"
+ elif status.find("replica busy") > -1:
+ print "Update failed - replica busy - status", status
+ done = True
+ hasError = 2
+ elif status.find("Total update succeeded") > -1:
+ print "Update succeeded"
+ done = True
+ elif inprogress.lower() == 'true':
+ print "Update in progress yet not in progress"
+ else:
+ print "Update failed: status", status
+ hasError = 1
+ done = True
+ else:
+ print "Update in progress"
+
+ return done, hasError
+
+
+ def wait_for_repl_init(self, conn, agmtdn):
+ done = False
+ haserror = 0
+ while not done and not haserror:
+ time.sleep(1) # give it a few seconds to get going
+ done, haserror = self.check_repl_init(conn, agmtdn)
+ return haserror
+
+ def start_replication(self, other_conn):
+ print "starting replication"
+ cn, dn = self.agreement_dn(self.conn)
+
+ mod = [(ldap.MOD_ADD, 'nsds5BeginReplicaRefresh', 'start')]
+ other_conn.modify_s(dn, mod)
+
+ return self.wait_for_repl_init(other_conn, dn)
+
+
+ def basic_replication_setup(self, conn, master, replica_id):
+ self.add_replication_manager(conn)
+ self.local_replica_config(conn, master, replica_id)
+ if master:
+ self.setup_changelog(conn)
+
+ def setup_replication(self, other_hostname, realm_name, master=True):
+ """
+ NOTES:
+ - the directory manager password needs to be the same on
+ both directories.
+ """
+ other_conn = ipaldap.IPAdmin(other_hostname)
+ other_conn.do_simple_bind(bindpw=self.dirman_passwd)
+ self.suffix = ipaldap.IPAdmin.normalizeDN(dsinstance.realm_to_suffix(realm_name))
+
+ self.basic_replication_setup(self.conn, master, 1)
+ self.basic_replication_setup(other_conn, True, 2)
+
+ self.setup_agreement(other_conn, self.conn)
+ if master:
+ self.setup_agreement(self.conn, other_conn)
+ else:
+ self.setup_chaining_farm(other_conn)
+ self.setup_chain_on_update(other_conn)
+
+ return self.start_replication(other_conn)
+
+
+
From 67cddce4d47791ad357ed5551ab58e16dbf87e0c Mon Sep 17 00:00:00 2001
From: Karl MacMillan
Date: Wed, 21 Nov 2007 18:09:24 -0500
Subject: [PATCH 54/60] Generate master password from Simo.
---
ipa-python/ipautil.py | 12 ++++++++++++
ipa-server/ipa-install/ipa-server-install | 13 +------------
ipa-server/ipaserver/krbinstance.py | 13 +------------
ipa-server/xmlrpc-server/funcs.py | 6 +++---
4 files changed, 17 insertions(+), 27 deletions(-)
diff --git a/ipa-python/ipautil.py b/ipa-python/ipautil.py
index cd8eac16c..df9231884 100644
--- a/ipa-python/ipautil.py
+++ b/ipa-python/ipautil.py
@@ -23,6 +23,8 @@ import string
import tempfile
import logging
import subprocess
+from random import Random
+from time import gmtime
import os
import stat
import socket
@@ -331,3 +333,13 @@ def parse_generalized_time(timestr):
except ValueError:
return None
+
+def ipa_generate_password():
+ rndpwd = ''
+ r = Random()
+ r.seed(gmtime())
+ for x in range(12):
+# rndpwd += chr(r.randint(32,126))
+ rndpwd += chr(r.randint(65,90)) #stricter set for testing
+ return rndpwd
+
diff --git a/ipa-server/ipa-install/ipa-server-install b/ipa-server/ipa-install/ipa-server-install
index b957e522f..a33a3e892 100644
--- a/ipa-server/ipa-install/ipa-server-install
+++ b/ipa-server/ipa-install/ipa-server-install
@@ -232,17 +232,6 @@ def read_dm_password():
dm_password = read_password("Directory Manager")
return dm_password
-def read_master_password():
- print "The Kerberos database is usually encrypted using a master password."
- print "Please store this password offline in a secure place."
- print "It may be necessary in a recovery situation or to install a replica."
- print "Without the master password the encrypted material can't be used by the KDC."
- print "If the master password is lost all kerberos related secrets will also be lost."
- print ""
- #TODO: provide the option of generating a random password
- master_password = read_password("Kerberos master")
- return master_password
-
def read_admin_password():
print "The IPA server requires an administrative user, named 'admin'."
print "This user is a regular system account used for IPA server administration."
@@ -381,7 +370,7 @@ def main():
dm_password = options.dm_password
if not options.master_password:
- master_password = read_master_password()
+ master_password = ipa_generate_password()
else:
master_password = options.master_password
diff --git a/ipa-server/ipaserver/krbinstance.py b/ipa-server/ipaserver/krbinstance.py
index aca9e2613..84d677162 100644
--- a/ipa-server/ipaserver/krbinstance.py
+++ b/ipa-server/ipaserver/krbinstance.py
@@ -26,8 +26,6 @@ import logging
import fileinput
import re
import sys
-from random import Random
-from time import gmtime
import os
import pwd
import socket
@@ -54,15 +52,6 @@ def host_to_domain(fqdn):
s = fqdn.split(".")
return ".".join(s[1:])
-def generate_kdc_password():
- rndpwd = ''
- r = Random()
- r.seed(gmtime())
- for x in range(12):
-# rndpwd += chr(r.randint(32,126))
- rndpwd += chr(r.randint(65,90)) #stricter set for testing
- return rndpwd
-
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)
@@ -101,7 +90,7 @@ class KrbInstance(service.Service):
self.ip = socket.gethostbyname(host_name)
self.domain = host_to_domain(host_name)
self.suffix = realm_to_suffix(self.realm)
- self.kdc_password = generate_kdc_password()
+ self.kdc_password = ipa_generate_password()
self.admin_password = admin_password
self.__setup_sub_dict()
diff --git a/ipa-server/xmlrpc-server/funcs.py b/ipa-server/xmlrpc-server/funcs.py
index db7413dbe..17555afb7 100644
--- a/ipa-server/xmlrpc-server/funcs.py
+++ b/ipa-server/xmlrpc-server/funcs.py
@@ -51,9 +51,9 @@ DefaultUserContainer = "cn=users,cn=accounts"
DefaultGroupContainer = "cn=groups,cn=accounts"
# FIXME: need to check the ipadebug option in ipa.conf
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s %(levelname)s %(message)s',
- stream=sys.stderr)
+#logging.basicConfig(level=logging.DEBUG,
+# format='%(asctime)s %(levelname)s %(message)s',
+# stream=sys.stderr)
#
# Apache runs in multi-process mode so each process will have its own
From b202b6cc31c6f036305bd7389201c6aa57dcc5fe Mon Sep 17 00:00:00 2001
From: Karl MacMillan
Date: Wed, 21 Nov 2007 23:09:13 -0500
Subject: [PATCH 55/60] Bump the version numbers for release. Also remove
specific version check on freeradius. Packages aren't available and the
freeradius support isn't ready anyway.
---
Makefile | 16 ++++++++--------
ipa-admintools/freeipa-admintools.spec | 2 +-
ipa-client/configure.ac | 6 +++---
ipa-client/freeipa-client.spec | 2 +-
ipa-python/freeipa-python.spec | 2 +-
ipa-python/setup.py | 2 +-
ipa-server/configure.ac | 6 +++---
ipa-server/freeipa-server.spec | 6 +++---
ipa-server/freeipa-server.spec.in | 4 ++--
9 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/Makefile b/Makefile
index cf919fda9..ac8528f65 100644
--- a/Makefile
+++ b/Makefile
@@ -8,29 +8,29 @@ RPMBUILD ?= $(PWD)/rpmbuild
# updating this you should run the version-update
# target.
SERV_MAJOR=0
-SERV_MINOR=4
-SERV_RELEASE=1
+SERV_MINOR=5
+SERV_RELEASE=0
SERV_VERSION=$(SERV_MAJOR).$(SERV_MINOR).$(SERV_RELEASE)
SERV_TARBALL_PREFIX=$(PRJ_PREFIX)-server-$(SERV_VERSION)
SERV_TARBALL=$(SERV_TARBALL_PREFIX).tgz
ADMIN_MAJOR=0
-ADMIN_MINOR=4
-ADMIN_RELEASE=1
+ADMIN_MINOR=5
+ADMIN_RELEASE=0
ADMIN_VERSION=$(ADMIN_MAJOR).$(ADMIN_MINOR).$(ADMIN_RELEASE)
ADMIN_TARBALL_PREFIX=$(PRJ_PREFIX)-admintools-$(ADMIN_VERSION)
ADMIN_TARBALL=$(ADMIN_TARBALL_PREFIX).tgz
PYTHON_MAJOR=0
-PYTHON_MINOR=4
-PYTHON_RELEASE=1
+PYTHON_MINOR=5
+PYTHON_RELEASE=0
PYTHON_VERSION=$(PYTHON_MAJOR).$(PYTHON_MINOR).$(PYTHON_RELEASE)
PYTHON_TARBALL_PREFIX=$(PRJ_PREFIX)-python-$(PYTHON_VERSION)
PYTHON_TARBALL=$(PYTHON_TARBALL_PREFIX).tgz
CLI_MAJOR=0
-CLI_MINOR=3
-CLI_RELEASE=1
+CLI_MINOR=5
+CLI_RELEASE=0
CLI_VERSION=$(CLI_MAJOR).$(CLI_MINOR).$(CLI_RELEASE)
CLI_TARBALL_PREFIX=$(PRJ_PREFIX)-client-$(CLI_VERSION)
CLI_TARBALL=$(CLI_TARBALL_PREFIX).tgz
diff --git a/ipa-admintools/freeipa-admintools.spec b/ipa-admintools/freeipa-admintools.spec
index 6fd423a0b..ad7e20194 100755
--- a/ipa-admintools/freeipa-admintools.spec
+++ b/ipa-admintools/freeipa-admintools.spec
@@ -1,5 +1,5 @@
Name: freeipa-admintools
-Version: 0.4.1
+Version: 0.5.0
Release: 1%{?dist}
Summary: FreeIPA authentication server
diff --git a/ipa-client/configure.ac b/ipa-client/configure.ac
index 5cd416da7..9d060d9a8 100644
--- a/ipa-client/configure.ac
+++ b/ipa-client/configure.ac
@@ -1,6 +1,6 @@
AC_PREREQ(2.59c)
-AC_INIT([freeipa-client],
- [0.3.1],
+AC_INIT([ipa-client],
+ [0.5.0],
[https://hosted.fedoraproject.org/projects/freeipa/newticket])
AC_CONFIG_SRCDIR([ipaclient/__init__.py])
@@ -47,7 +47,7 @@ AC_CONFIG_FILES([
AC_OUTPUT
echo "
- FreeIPA client $VERSION
+ IPA client $VERSION
========================
prefix: ${prefix}
diff --git a/ipa-client/freeipa-client.spec b/ipa-client/freeipa-client.spec
index f4a51f47a..c972d967a 100755
--- a/ipa-client/freeipa-client.spec
+++ b/ipa-client/freeipa-client.spec
@@ -1,5 +1,5 @@
Name: freeipa-client
-Version: 0.3.1
+Version: 0.5.0
Release: 1%{?dist}
Summary: FreeIPA client
diff --git a/ipa-python/freeipa-python.spec b/ipa-python/freeipa-python.spec
index a84fb0fe2..2c1420f91 100755
--- a/ipa-python/freeipa-python.spec
+++ b/ipa-python/freeipa-python.spec
@@ -1,5 +1,5 @@
Name: freeipa-python
-Version: 0.4.1
+Version: 0.5.0
Release: 1%{?dist}
Summary: FreeIPA authentication server
diff --git a/ipa-python/setup.py b/ipa-python/setup.py
index defd49cbd..3a5a6f4eb 100644
--- a/ipa-python/setup.py
+++ b/ipa-python/setup.py
@@ -35,7 +35,7 @@ def setup_package():
try:
setup(
name = "freeipa-python",
- version = "0.4.1",
+ version = "0.5.0",
license = "GPL",
author = "Karl MacMillan, et.al.",
author_email = "kmacmillan@redhat.com",
diff --git a/ipa-server/configure.ac b/ipa-server/configure.ac
index e07c04c85..3cd44fef2 100644
--- a/ipa-server/configure.ac
+++ b/ipa-server/configure.ac
@@ -1,6 +1,6 @@
AC_PREREQ(2.59c)
-AC_INIT([freeipa-server],
- [0.4],
+AC_INIT([ipa-server],
+ [0.5],
[https://hosted.fedoraproject.org/projects/freeipa/newticket])
AC_CONFIG_SRCDIR([ipaserver/ipaldap.py])
@@ -234,7 +234,7 @@ AC_CONFIG_FILES([
AC_OUTPUT
echo "
- FreeIPA Server $VERSION
+ IPA Server $VERSION
========================
prefix: ${prefix}
diff --git a/ipa-server/freeipa-server.spec b/ipa-server/freeipa-server.spec
index 93a3bae18..07ef1447a 100755
--- a/ipa-server/freeipa-server.spec
+++ b/ipa-server/freeipa-server.spec
@@ -1,6 +1,6 @@
Name: freeipa-server
-Version: 0.4.1
-Release: 2%{?dist}
+Version: 0.5.0
+Release: 1%{?dist}
Summary: FreeIPA authentication server
Group: System Environment/Base
@@ -36,7 +36,7 @@ Requires: python-krbV
Requires: TurboGears
Requires: python-tgexpandingformwidget
Requires: acl
-Requires: freeradius >= 1.1.7
+Requires: freeradius
Requires: pyasn1
%define httpd_conf /etc/httpd/conf.d
diff --git a/ipa-server/freeipa-server.spec.in b/ipa-server/freeipa-server.spec.in
index d50cd4e91..62a4a3fc4 100644
--- a/ipa-server/freeipa-server.spec.in
+++ b/ipa-server/freeipa-server.spec.in
@@ -1,6 +1,6 @@
Name: freeipa-server
Version: VERSION
-Release: 2%{?dist}
+Release: 1%{?dist}
Summary: FreeIPA authentication server
Group: System Environment/Base
@@ -36,7 +36,7 @@ Requires: python-krbV
Requires: TurboGears
Requires: python-tgexpandingformwidget
Requires: acl
-Requires: freeradius >= 1.1.7
+Requires: freeradius
Requires: pyasn1
%define httpd_conf /etc/httpd/conf.d
From 9038bf71dd76d845746e0ea3e94bca9f52f60c03 Mon Sep 17 00:00:00 2001
From: Karl MacMillan
Date: Wed, 21 Nov 2007 23:28:06 -0500
Subject: [PATCH 56/60] Move packages to ipa from freeipa.
---
Makefile | 42 +++++++++----------
...pa-admintools.spec => ipa-admintools.spec} | 11 +++--
...intools.spec.in => ipa-admintools.spec.in} | 11 +++--
.../{freeipa-client.spec => ipa-client.spec} | 11 +++--
...eipa-client.spec.in => ipa-client.spec.in} | 11 +++--
.../{freeipa-python.spec => ipa-python.spec} | 9 ++--
...eipa-python.spec.in => ipa-python.spec.in} | 9 ++--
.../{freeipa-server.spec => ipa-server.spec} | 13 +++---
...eipa-server.spec.in => ipa-server.spec.in} | 13 +++---
9 files changed, 77 insertions(+), 53 deletions(-)
rename ipa-admintools/{freeipa-admintools.spec => ipa-admintools.spec} (82%)
rename ipa-admintools/{freeipa-admintools.spec.in => ipa-admintools.spec.in} (82%)
rename ipa-client/{freeipa-client.spec => ipa-client.spec} (78%)
rename ipa-client/{freeipa-client.spec.in => ipa-client.spec.in} (78%)
rename ipa-python/{freeipa-python.spec => ipa-python.spec} (87%)
rename ipa-python/{freeipa-python.spec.in => ipa-python.spec.in} (87%)
rename ipa-server/{freeipa-server.spec => ipa-server.spec} (92%)
rename ipa-server/{freeipa-server.spec.in => ipa-server.spec.in} (92%)
diff --git a/Makefile b/Makefile
index ac8528f65..ca2ecbc75 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
SUBDIRS=ipa-server ipa-admintools ipa-python ipa-client
-PRJ_PREFIX=freeipa
+PRJ_PREFIX=ipa
RPMBUILD ?= $(PWD)/rpmbuild
@@ -65,56 +65,56 @@ test:
done
version-update:
- sed s/VERSION/$(SERV_VERSION)/ ipa-server/freeipa-server.spec.in \
- > ipa-server/freeipa-server.spec
+ sed s/VERSION/$(SERV_VERSION)/ ipa-server/ipa-server.spec.in \
+ > ipa-server/ipa-server.spec
- sed s/VERSION/$(ADMIN_VERSION)/ ipa-admintools/freeipa-admintools.spec.in \
- > ipa-admintools/freeipa-admintools.spec
+ sed s/VERSION/$(ADMIN_VERSION)/ ipa-admintools/ipa-admintools.spec.in \
+ > ipa-admintools/ipa-admintools.spec
- sed s/VERSION/$(PYTHON_VERSION)/ ipa-python/freeipa-python.spec.in \
- > ipa-python/freeipa-python.spec
+ sed s/VERSION/$(PYTHON_VERSION)/ ipa-python/ipa-python.spec.in \
+ > ipa-python/ipa-python.spec
- sed s/VERSION/$(CLI_VERSION)/ ipa-client/freeipa-client.spec.in \
- > ipa-client/freeipa-client.spec
+ sed s/VERSION/$(CLI_VERSION)/ ipa-client/ipa-client.spec.in \
+ > ipa-client/ipa-client.spec
archive:
-mkdir -p dist
- hg archive -t files dist/freeipa
+ hg archive -t files dist/ipa
local-archive:
- -mkdir -p dist/freeipa
+ -mkdir -p dist/ipa
@for subdir in $(SUBDIRS); do \
- cp -pr $$subdir dist/freeipa/.; \
+ cp -pr $$subdir dist/ipa/.; \
done
archive-cleanup:
- rm -fr dist/freeipa
+ rm -fr dist/ipa
tarballs:
-mkdir -p dist/sources
# ipa-server
- mv dist/freeipa/ipa-server dist/$(SERV_TARBALL_PREFIX)
+ mv dist/ipa/ipa-server dist/$(SERV_TARBALL_PREFIX)
rm -f dist/sources/$(SERV_TARBALL)
cd dist/$(SERV_TARBALL_PREFIX); ./autogen.sh; make distclean
cd dist; tar cfz sources/$(SERV_TARBALL) $(SERV_TARBALL_PREFIX)
rm -fr dist/$(SERV_TARBALL_PREFIX)
# ipa-admintools
- mv dist/freeipa/ipa-admintools dist/$(ADMIN_TARBALL_PREFIX)
+ mv dist/ipa/ipa-admintools dist/$(ADMIN_TARBALL_PREFIX)
rm -f dist/sources/$(ADMIN_TARBALL)
cd dist; tar cfz sources/$(ADMIN_TARBALL) $(ADMIN_TARBALL_PREFIX)
rm -fr dist/$(ADMIN_TARBALL_PREFIX)
# ipa-python
- mv dist/freeipa/ipa-python dist/$(PYTHON_TARBALL_PREFIX)
+ mv dist/ipa/ipa-python dist/$(PYTHON_TARBALL_PREFIX)
rm -f dist/sources/$(PYTHON_TARBALL)
cd dist; tar cfz sources/$(PYTHON_TARBALL) $(PYTHON_TARBALL_PREFIX)
rm -fr dist/$(PYTHON_TARBALL_PREFIX)
# ipa-client
- mv dist/freeipa/ipa-client dist/$(CLI_TARBALL_PREFIX)
+ mv dist/ipa/ipa-client dist/$(CLI_TARBALL_PREFIX)
rm -f dist/sources/$(CLI_TARBALL)
cd dist/$(CLI_TARBALL_PREFIX); ./autogen.sh; make distclean
cd dist; tar cfz sources/$(CLI_TARBALL) $(CLI_TARBALL_PREFIX)
@@ -133,25 +133,25 @@ rpmdistdir:
rpm-ipa-server:
cp dist/sources/$(SERV_TARBALL) $(RPMBUILD)/SOURCES/.
- rpmbuild --define "_topdir $(RPMBUILD)" -ba ipa-server/freeipa-server.spec
+ rpmbuild --define "_topdir $(RPMBUILD)" -ba ipa-server/ipa-server.spec
cp rpmbuild/RPMS/*/$(PRJ_PREFIX)-server-$(SERV_VERSION)-*.rpm dist/rpms/
cp rpmbuild/SRPMS/$(PRJ_PREFIX)-server-$(SERV_VERSION)-*.src.rpm dist/srpms/
rpm-ipa-admin:
cp dist/sources/$(ADMIN_TARBALL) $(RPMBUILD)/SOURCES/.
- rpmbuild --define "_topdir $(RPMBUILD)" -ba ipa-admintools/freeipa-admintools.spec
+ rpmbuild --define "_topdir $(RPMBUILD)" -ba ipa-admintools/ipa-admintools.spec
cp rpmbuild/RPMS/noarch/$(PRJ_PREFIX)-admintools-$(ADMIN_VERSION)-*.rpm dist/rpms/
cp rpmbuild/SRPMS/$(PRJ_PREFIX)-admintools-$(ADMIN_VERSION)-*.src.rpm dist/srpms/
rpm-ipa-python:
cp dist/sources/$(PYTHON_TARBALL) $(RPMBUILD)/SOURCES/.
- rpmbuild --define "_topdir $(RPMBUILD)" -ba ipa-python/freeipa-python.spec
+ rpmbuild --define "_topdir $(RPMBUILD)" -ba ipa-python/ipa-python.spec
cp rpmbuild/RPMS/noarch/$(PRJ_PREFIX)-python-$(PYTHON_VERSION)-*.rpm dist/rpms/
cp rpmbuild/SRPMS/$(PRJ_PREFIX)-python-$(PYTHON_VERSION)-*.src.rpm dist/srpms/
rpm-ipa-client:
cp dist/sources/$(CLI_TARBALL) $(RPMBUILD)/SOURCES/.
- rpmbuild --define "_topdir $(RPMBUILD)" -ba ipa-client/freeipa-client.spec
+ rpmbuild --define "_topdir $(RPMBUILD)" -ba ipa-client/ipa-client.spec
cp rpmbuild/RPMS/*/$(PRJ_PREFIX)-client-$(CLI_VERSION)-*.rpm dist/rpms/
cp rpmbuild/SRPMS/$(PRJ_PREFIX)-client-$(CLI_VERSION)-*.src.rpm dist/srpms/
diff --git a/ipa-admintools/freeipa-admintools.spec b/ipa-admintools/ipa-admintools.spec
similarity index 82%
rename from ipa-admintools/freeipa-admintools.spec
rename to ipa-admintools/ipa-admintools.spec
index ad7e20194..24c83e6cd 100755
--- a/ipa-admintools/freeipa-admintools.spec
+++ b/ipa-admintools/ipa-admintools.spec
@@ -1,7 +1,7 @@
-Name: freeipa-admintools
+Name: ipa-admintools
Version: 0.5.0
Release: 1%{?dist}
-Summary: FreeIPA authentication server
+Summary: IPA authentication server
Group: System Environment/Base
License: GPL
@@ -10,10 +10,10 @@ Source0: %{name}-%{version}.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
-Requires: python python-krbV freeipa-python
+Requires: python python-krbV ipa-python
%description
-FreeIPA is a server for identity, policy, and audit.
+IPA is a server for identity, policy, and audit.
%prep
%setup -q
@@ -35,6 +35,9 @@ rm -rf %{buildroot}
%{_mandir}/man1/*
%changelog
+* Wed Nov 21 2007 Karl MacMillan - 0.5.0-1
+- Version bump for release and rpm name change
+
* Thu Nov 1 2007 Karl MacMillan - 0.4.1-1
- Version bump for release
diff --git a/ipa-admintools/freeipa-admintools.spec.in b/ipa-admintools/ipa-admintools.spec.in
similarity index 82%
rename from ipa-admintools/freeipa-admintools.spec.in
rename to ipa-admintools/ipa-admintools.spec.in
index ec731a645..4b444882e 100755
--- a/ipa-admintools/freeipa-admintools.spec.in
+++ b/ipa-admintools/ipa-admintools.spec.in
@@ -1,7 +1,7 @@
-Name: freeipa-admintools
+Name: ipa-admintools
Version: VERSION
Release: 1%{?dist}
-Summary: FreeIPA authentication server
+Summary: IPA authentication server
Group: System Environment/Base
License: GPL
@@ -10,10 +10,10 @@ Source0: %{name}-%{version}.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
-Requires: python python-krbV freeipa-python
+Requires: python python-krbV ipa-python
%description
-FreeIPA is a server for identity, policy, and audit.
+IPA is a server for identity, policy, and audit.
%prep
%setup -q
@@ -35,6 +35,9 @@ rm -rf %{buildroot}
%{_mandir}/man1/*
%changelog
+* Wed Nov 21 2007 Karl MacMillan - 0.5.0-1
+- Version bump for release and rpm name change
+
* Thu Nov 1 2007 Karl MacMillan - 0.4.1-1
- Version bump for release
diff --git a/ipa-client/freeipa-client.spec b/ipa-client/ipa-client.spec
similarity index 78%
rename from ipa-client/freeipa-client.spec
rename to ipa-client/ipa-client.spec
index c972d967a..c184600bb 100755
--- a/ipa-client/freeipa-client.spec
+++ b/ipa-client/ipa-client.spec
@@ -1,7 +1,7 @@
-Name: freeipa-client
+Name: ipa-client
Version: 0.5.0
Release: 1%{?dist}
-Summary: FreeIPA client
+Summary: IPA client
Group: System Environment/Base
License: GPL
@@ -9,10 +9,10 @@ URL: http://www.freeipa.org
Source0: %{name}-%{version}.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Requires: python python-ldap python-krbV freeipa-python
+Requires: python python-ldap python-krbV ipa-python
%description
-FreeIPA is a server for identity, policy, and audit.
+IPA is a server for identity, policy, and audit.
The client package provide install and configuration scripts for clients.
%prep
@@ -41,6 +41,9 @@ rm -rf %{buildroot}
%{_usr}/share/ipa/*
%changelog
+* Wed Nov 21 2007 Karl MacMillan - 0.5.0-1
+- Version bump for release and rpm name change
+
* Thu Nov 1 2007 Karl MacMillan - 0.3.1-1
- Version bump for release
diff --git a/ipa-client/freeipa-client.spec.in b/ipa-client/ipa-client.spec.in
similarity index 78%
rename from ipa-client/freeipa-client.spec.in
rename to ipa-client/ipa-client.spec.in
index f4a7997f8..5dbd90f3f 100644
--- a/ipa-client/freeipa-client.spec.in
+++ b/ipa-client/ipa-client.spec.in
@@ -1,7 +1,7 @@
-Name: freeipa-client
+Name: ipa-client
Version: VERSION
Release: 1%{?dist}
-Summary: FreeIPA client
+Summary: IPA client
Group: System Environment/Base
License: GPL
@@ -9,10 +9,10 @@ URL: http://www.freeipa.org
Source0: %{name}-%{version}.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Requires: python python-ldap python-krbV freeipa-python
+Requires: python python-ldap python-krbV ipa-python
%description
-FreeIPA is a server for identity, policy, and audit.
+IPA is a server for identity, policy, and audit.
The client package provide install and configuration scripts for clients.
%prep
@@ -41,6 +41,9 @@ rm -rf %{buildroot}
%{_usr}/share/ipa/*
%changelog
+* Wed Nov 21 2007 Karl MacMillan - 0.5.0-1
+- Version bump for release and rpm name change
+
* Thu Nov 1 2007 Karl MacMillan - 0.3.1-1
- Version bump for release
diff --git a/ipa-python/freeipa-python.spec b/ipa-python/ipa-python.spec
similarity index 87%
rename from ipa-python/freeipa-python.spec
rename to ipa-python/ipa-python.spec
index 2c1420f91..2837a2832 100755
--- a/ipa-python/freeipa-python.spec
+++ b/ipa-python/ipa-python.spec
@@ -1,7 +1,7 @@
-Name: freeipa-python
+Name: ipa-python
Version: 0.5.0
Release: 1%{?dist}
-Summary: FreeIPA authentication server
+Summary: Ipa authentication server
Group: System Environment/Base
License: GPL
@@ -17,7 +17,7 @@ Requires: PyKerberos
%define pkgpythondir %{python_sitelib}/ipa
%description
-FreeIPA is a server for identity, policy, and audit.
+Ipa is a server for identity, policy, and audit.
%prep
%setup -q
@@ -38,6 +38,9 @@ rm -rf %{buildroot}
%config(noreplace) %{_sysconfdir}/ipa/ipa.conf
%changelog
+* Wed Nov 21 2007 Karl MacMillan - 0.5.0-1
+- Version bump for release and rename of rpm
+
* Thu Nov 1 2007 Karl MacMillan - 0.4.1-1
- Version bump for release
diff --git a/ipa-python/freeipa-python.spec.in b/ipa-python/ipa-python.spec.in
similarity index 87%
rename from ipa-python/freeipa-python.spec.in
rename to ipa-python/ipa-python.spec.in
index 0c46098ce..bd8ac0da6 100755
--- a/ipa-python/freeipa-python.spec.in
+++ b/ipa-python/ipa-python.spec.in
@@ -1,7 +1,7 @@
-Name: freeipa-python
+Name: ipa-python
Version: VERSION
Release: 1%{?dist}
-Summary: FreeIPA authentication server
+Summary: Ipa authentication server
Group: System Environment/Base
License: GPL
@@ -17,7 +17,7 @@ Requires: PyKerberos
%define pkgpythondir %{python_sitelib}/ipa
%description
-FreeIPA is a server for identity, policy, and audit.
+Ipa is a server for identity, policy, and audit.
%prep
%setup -q
@@ -38,6 +38,9 @@ rm -rf %{buildroot}
%config(noreplace) %{_sysconfdir}/ipa/ipa.conf
%changelog
+* Wed Nov 21 2007 Karl MacMillan - 0.5.0-1
+- Version bump for release and rename of rpm
+
* Thu Nov 1 2007 Karl MacMillan - 0.4.1-1
- Version bump for release
diff --git a/ipa-server/freeipa-server.spec b/ipa-server/ipa-server.spec
similarity index 92%
rename from ipa-server/freeipa-server.spec
rename to ipa-server/ipa-server.spec
index 07ef1447a..7b78e06ab 100755
--- a/ipa-server/freeipa-server.spec
+++ b/ipa-server/ipa-server.spec
@@ -1,7 +1,7 @@
-Name: freeipa-server
+Name: ipa-server
Version: 0.5.0
Release: 1%{?dist}
-Summary: FreeIPA authentication server
+Summary: Ipa authentication server
Group: System Environment/Base
License: GPL
@@ -16,8 +16,8 @@ BuildRequires: openldap-devel
BuildRequires: krb5-devel
BuildRequires: nss-devel
-Requires: freeipa-python
-Requires: freeipa-admintools
+Requires: ipa-python
+Requires: ipa-admintools
Requires: fedora-ds-base >= 1.1
Requires: openldap-clients
Requires: nss
@@ -43,7 +43,7 @@ Requires: pyasn1
%define plugin_dir %{_libdir}/dirsrv/plugins
%description
-FreeIPA is a server for identity, policy, and audit.
+Ipa is a server for identity, policy, and audit.
%prep
%setup -q
@@ -87,6 +87,9 @@ rm -rf %{buildroot}
%changelog
+* Wed Nov 21 2007 Karl MacMillan - 0.5.0-1
+- Version bump for relase and rpm name change
+
* Thu Nov 15 2007 Rob Crittenden - 0.4.1-2
- Broke invididual Requires and BuildRequires onto separate lines and
reordered them
diff --git a/ipa-server/freeipa-server.spec.in b/ipa-server/ipa-server.spec.in
similarity index 92%
rename from ipa-server/freeipa-server.spec.in
rename to ipa-server/ipa-server.spec.in
index 62a4a3fc4..d28ffa70e 100644
--- a/ipa-server/freeipa-server.spec.in
+++ b/ipa-server/ipa-server.spec.in
@@ -1,7 +1,7 @@
-Name: freeipa-server
+Name: ipa-server
Version: VERSION
Release: 1%{?dist}
-Summary: FreeIPA authentication server
+Summary: Ipa authentication server
Group: System Environment/Base
License: GPL
@@ -16,8 +16,8 @@ BuildRequires: openldap-devel
BuildRequires: krb5-devel
BuildRequires: nss-devel
-Requires: freeipa-python
-Requires: freeipa-admintools
+Requires: ipa-python
+Requires: ipa-admintools
Requires: fedora-ds-base >= 1.1
Requires: openldap-clients
Requires: nss
@@ -43,7 +43,7 @@ Requires: pyasn1
%define plugin_dir %{_libdir}/dirsrv/plugins
%description
-FreeIPA is a server for identity, policy, and audit.
+Ipa is a server for identity, policy, and audit.
%prep
%setup -q
@@ -87,6 +87,9 @@ rm -rf %{buildroot}
%changelog
+* Wed Nov 21 2007 Karl MacMillan - 0.5.0-1
+- Version bump for relase and rpm name change
+
* Thu Nov 15 2007 Rob Crittenden - 0.4.1-2
- Broke invididual Requires and BuildRequires onto separate lines and
reordered them
From edc7af1446af451ea5ed44420cceb05059a7b973 Mon Sep 17 00:00:00 2001
From: Karl MacMillan
Date: Wed, 21 Nov 2007 23:28:25 -0500
Subject: [PATCH 57/60] Add xml-rpc interface for getting keytabs.
Warning: this lacks any sort of authorization.
---
ipa-admintools/Makefile | 1 +
ipa-admintools/ipa-getkeytab | 83 +++++
ipa-python/ipaclient.py | 7 +
ipa-python/rpcclient.py | 24 ++
ipa-server/Makefile.am | 1 +
ipa-server/configure.ac | 1 +
.../ipa-install/share/bootstrap-template.ldif | 9 +-
ipa-server/ipa-install/share/default-aci.ldif | 5 +
ipa-server/ipa-keytab-util/Makefile.am | 22 ++
ipa-server/ipa-keytab-util/ipa-keytab-util.c | 304 ++++++++++++++++++
ipa-server/ipaserver/krbinstance.py | 2 +
ipa-server/xmlrpc-server/funcs.py | 67 ++++
ipa-server/xmlrpc-server/ipaxmlrpc.py | 2 +
13 files changed, 524 insertions(+), 4 deletions(-)
create mode 100644 ipa-admintools/ipa-getkeytab
create mode 100644 ipa-server/ipa-keytab-util/Makefile.am
create mode 100644 ipa-server/ipa-keytab-util/ipa-keytab-util.c
diff --git a/ipa-admintools/Makefile b/ipa-admintools/Makefile
index 9d63db082..f4ee40a63 100644
--- a/ipa-admintools/Makefile
+++ b/ipa-admintools/Makefile
@@ -21,6 +21,7 @@ install:
install -m 755 ipa-deldelegation $(SBINDIR)
install -m 755 ipa-listdelegation $(SBINDIR)
install -m 755 ipa-moddelegation $(SBINDIR)
+ install -m 755 ipa-getkeytab $(SBINDIR)
@for subdir in $(SUBDIRS); do \
(cd $$subdir && $(MAKE) $@) || exit 1; \
diff --git a/ipa-admintools/ipa-getkeytab b/ipa-admintools/ipa-getkeytab
new file mode 100644
index 000000000..5ecb7e4a6
--- /dev/null
+++ b/ipa-admintools/ipa-getkeytab
@@ -0,0 +1,83 @@
+#! /usr/bin/python -E
+# Authors: Karl MacMillan
+#
+# Copyright (C) 2007 Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; version 2 only
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+import sys
+from optparse import OptionParser
+import ipa
+import ipa.user
+import ipa.ipaclient as ipaclient
+import ipa.ipavalidate as ipavalidate
+import ipa.config
+
+import base64
+
+import xmlrpclib
+import kerberos
+import krbV
+import ldap
+import getpass
+import errno
+
+def usage():
+ print "ipa-getkeytab [-a] principal filename"
+ sys.exit(1)
+
+def parse_options():
+ parser = OptionParser()
+ parser.add_option("-a", "--add", dest="add_princ", action="store_true",
+ help="add the principal")
+
+ args = ipa.config.init_config(sys.argv)
+ options, args = parser.parse_args(args)
+
+ return options, args
+
+def main():
+ # The following fields are required
+ princ_name = ""
+
+ options, args = parse_options()
+
+ if len(args) != 3:
+ usage()
+ princ_name = args[1]
+ file_name = args[2]
+
+ client = ipaclient.IPAClient()
+
+ try:
+ if options.add_princ:
+ client.add_service_principal(princ_name)
+
+ princs = client.get_keytab(princ_name)
+
+ if princs is None:
+ print "could not generate keytab"
+ sys.exit(1)
+
+ fd = open(file_name, "w")
+ fd.write(princs)
+
+ except Exception, e:
+ print str(e)
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/ipa-python/ipaclient.py b/ipa-python/ipaclient.py
index cda8ceb93..c551f0435 100644
--- a/ipa-python/ipaclient.py
+++ b/ipa-python/ipaclient.py
@@ -381,3 +381,10 @@ class IPAClient:
"""
result = self.transport.update_password_policy(policy.origDataDict(), policy.toDict())
return result
+
+ def add_service_principal(self, princ_name):
+ return self.transport.add_service_principal(princ_name)
+
+ def get_keytab(self, princ_name):
+ return self.transport.get_keytab(princ_name)
+
diff --git a/ipa-python/rpcclient.py b/ipa-python/rpcclient.py
index d4c3dcc8e..d7ff97405 100644
--- a/ipa-python/rpcclient.py
+++ b/ipa-python/rpcclient.py
@@ -690,3 +690,27 @@ class RPCClient:
raise xmlrpclib.Fault(value, msg)
return ipautil.unwrap_binary_data(result)
+
+ def add_service_principal(self, princ_name):
+ server = self.setup_server()
+
+ try:
+ result = server.add_service_principal(princ_name)
+ except xmlrpclib.Fault, fault:
+ raise ipaerror.gen_exception(fault.faultCode, fault.faultString)
+ except socket.error, (value, msg):
+ raise xmlrpclib.Fault(value, msg)
+
+ return ipautil.unwrap_binary_data(result)
+
+ def get_keytab(self, princ_name):
+ server = self.setup_server()
+
+ try:
+ result = server.get_keytab(princ_name)
+ except xmlrpclib.Fault, fault:
+ raise ipaerror.gen_exception(fault.faultCode, fault.faultString)
+ except socket.error, (value, msg):
+ raise xmlrpclib.Fault(value, msg)
+
+ return ipautil.unwrap_binary_data(result)
diff --git a/ipa-server/Makefile.am b/ipa-server/Makefile.am
index b5da3f566..9638cdab6 100644
--- a/ipa-server/Makefile.am
+++ b/ipa-server/Makefile.am
@@ -11,6 +11,7 @@ SUBDIRS = \
ipaserver \
ipa-slapi-plugins \
xmlrpc-server \
+ ipa-keytab-util \
$(NULL)
EXTRA_DIST = \
diff --git a/ipa-server/configure.ac b/ipa-server/configure.ac
index 3cd44fef2..1e62a2f82 100644
--- a/ipa-server/configure.ac
+++ b/ipa-server/configure.ac
@@ -229,6 +229,7 @@ AC_CONFIG_FILES([
ipa-slapi-plugins/ipa-pwd-extop/Makefile
xmlrpc-server/Makefile
xmlrpc-server/test/Makefile
+ ipa-keytab-util/Makefile
])
AC_OUTPUT
diff --git a/ipa-server/ipa-install/share/bootstrap-template.ldif b/ipa-server/ipa-install/share/bootstrap-template.ldif
index dc403b637..5efec3c44 100644
--- a/ipa-server/ipa-install/share/bootstrap-template.ldif
+++ b/ipa-server/ipa-install/share/bootstrap-template.ldif
@@ -28,10 +28,11 @@ objectClass: top
objectClass: nsContainer
cn: groups
-#dn: cn=computers,cn=accounts,$SUFFIX
-#objectClass: top
-#objectClass: nsContainer
-#cn: computers
+dn: cn=services,cn=accounts,$SUFFIX
+changetype: add
+objectClass: top
+objectClass: nsContainer
+cn: services
dn: cn=etc,$SUFFIX
changetype: add
diff --git a/ipa-server/ipa-install/share/default-aci.ldif b/ipa-server/ipa-install/share/default-aci.ldif
index 4a5befbec..f6f165629 100644
--- a/ipa-server/ipa-install/share/default-aci.ldif
+++ b/ipa-server/ipa-install/share/default-aci.ldif
@@ -19,3 +19,8 @@ dn: cn=accounts,$SUFFIX
changetype: modify
add: aci
aci: (targetattr = "krbMaxPwdLife || krbMinPwdLife || krbPwdMinDiffChars || krbPwdMinLength || krbPwdHistoryLength")(version 3.0;acl "Admins can write password policy"; allow (write) groupdn="ldap:///cn=admins,cn=groups,cn=accounts,$SUFFIX";)
+
+dn: cn=services,cn=accounts,$SUFFIX
+changetype: modify
+add: aci
+aci: (targetattr="krbPrincipalName || krbUPEnabled || krbPrincipalKey || krbMKey || krbTicketPolicyReference || krbPrincipalExpiration || krbPasswordExpiration || krbPwdPolicyReference || krbPrincipalType || krbPwdHistory || krbLastPwdChange || krbPrincipalAliases || krbExtraData")(version 3.0; acl "KDC System Account"; allow (read, search, compare,write) userdn="ldap:///uid=kdc,cn=sysaccounts,cn=etc,$SUFFIX";)
diff --git a/ipa-server/ipa-keytab-util/Makefile.am b/ipa-server/ipa-keytab-util/Makefile.am
new file mode 100644
index 000000000..f0680e598
--- /dev/null
+++ b/ipa-server/ipa-keytab-util/Makefile.am
@@ -0,0 +1,22 @@
+NULL =
+
+sbin_PROGRAMS = \
+ ipa-keytab-util \
+ $(NULL)
+
+ipa_keytab_util_SOURCES = \
+ ipa-keytab-util.c \
+ $(NULL)
+
+ipa_keytab_util_LDADD = \
+ -lcap \
+ $(NULL)
+
+MAINTAINERCLEANFILES = \
+ *~ \
+ Makefile.in
+
+install-exec-hook:
+ -chown root:apache $(DESTDIR)$(sbindir)/ipa-keytab-util
+ -chmod o-rwxs $(DESTDIR)$(sbindir)/ipa-keytab-util
+ -chmod ug+s $(DESTDIR)$(sbindir)/ipa-keytab-util
diff --git a/ipa-server/ipa-keytab-util/ipa-keytab-util.c b/ipa-server/ipa-keytab-util/ipa-keytab-util.c
new file mode 100644
index 000000000..d080d0cd5
--- /dev/null
+++ b/ipa-server/ipa-keytab-util/ipa-keytab-util.c
@@ -0,0 +1,304 @@
+/*
+ * Authors:
+ * Karl MacMillan
+ *
+ * Copyright (C) 2007 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define _GNU_SOURCE /* for asprintf */
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define KADMIN_PATH "/usr/kerberos/sbin/kadmin.local"
+
+struct options
+{
+ char *princ_name;
+ char *realm;
+ int kstdin, kstdout, kstderr;
+};
+
+void *xmalloc(size_t size)
+{
+ void *foo = malloc(size);
+ if (!foo) {
+ fprintf(stderr, "malloc error of size %jd\n", size);
+ exit(1);
+ }
+ memset(foo, 0, size);
+
+ return foo;
+}
+
+void usage(void)
+{
+ printf("ipa-keytab-util princ-name realm-name\n");
+}
+
+struct options *process_args(int argc, char **argv)
+{
+ struct options* opts;
+
+ opts = xmalloc(sizeof(struct options));
+
+ if (argc != 3) {
+ usage();
+ exit(1);
+ }
+
+ opts->princ_name = argv[1];
+ opts->realm = argv[2];
+
+ return opts;
+}
+
+void drop_caps(void)
+{
+ cap_t caps;
+ int ret;
+
+ if (geteuid() != 0)
+ return;
+ if (getuid() != 0)
+ return;
+
+ caps = cap_init();
+ if (!caps) {
+ perror("error initializing caps");
+ exit(1);
+ }
+ ret = cap_clear(caps);
+ if (ret != 0) {
+ perror("could not clear capps");
+ exit(1);
+ }
+
+ ret = cap_set_proc(caps);
+ if (ret != 0) {
+ perror("could not drop caps");
+ exit(1);
+ }
+
+ cap_free(caps);
+}
+
+pid_t exec_kadmin_local(struct options *opts)
+{
+ int stdin_pipes[2];
+ int stdout_pipes[2];
+ int stderr_pipes[2];
+ int ret;
+ pid_t chpid;
+ char *princ;
+
+ /* create a pair of pipes for stdin / stdout
+ of the child process.
+ */
+
+ if (pipe(stdin_pipes) == -1) {
+ perror("creating stdin");
+ exit(1);
+ }
+
+ if (pipe(stdout_pipes) == -1) {
+ perror("creating stdin");
+ exit(1);
+ }
+
+ if (pipe(stderr_pipes) == -1) {
+ perror("creating stdin");
+ exit(1);
+ }
+
+ chpid = fork();
+ if (chpid == -1) {
+ perror("fork");
+ exit(1);
+ }
+
+ /* CHILD */
+ if (chpid == 0) {
+ /* stdin */
+ close(stdin_pipes[1]);
+ dup2(stdin_pipes[0], 0);
+
+ /* stdout */
+ close(stdout_pipes[0]);
+ dup2(stdout_pipes[1], 1);
+
+ /* stderr */
+ close(stderr_pipes[0]);
+ dup2(stdout_pipes[1], 2);
+
+ /* now exec kadmin.local */
+
+ ret = asprintf(&princ, "admin@%s", opts->realm);
+ if (!princ) {
+ perror("creating bind princ");
+ exit(1);
+ }
+ ret = execl(KADMIN_PATH, "kadmin.local", "-p", princ, NULL);
+ free(princ);
+ if (ret == -1) {
+ perror("exec");
+ exit(1);
+ }
+ } else {
+ close(stdin_pipes[0]);
+ close(stdout_pipes[1]);
+ close(stderr_pipes[1]);
+
+ opts->kstdin = stdin_pipes[1];
+ opts->kstdout = stdout_pipes[0];
+ opts->kstderr = stdout_pipes[0];
+ }
+
+ return chpid;
+}
+
+void write_to_kadmin(struct options *opts, char *buf, int len)
+{
+ int ret;
+
+ ret = write(opts->kstdin, buf, len);
+ if (ret != len) {
+ perror("write");
+ fprintf(stderr, "write is short %d:%d\n", len, ret);
+ exit(1);
+ }
+ fsync(opts->kstdin);
+}
+
+char *get_temp_filename(void)
+{
+ char *fname;
+ /* ok - we have to use mktemp here even w/ the race
+ * because kadmin.local barfs if the file exists. The
+ * risk is pretty low and we will try to protect the files
+ * with selinux.
+ *
+ * TODO: generate these files in a safer place than /tmp
+ */
+ fname = strdup("/tmp/ipa-keytab-util-XXXXXX");
+ if (!fname) {
+ fprintf(stderr, "could not allocate temporary file name");
+ exit(1);
+ }
+ fname = mktemp(fname);
+
+ return fname;
+}
+
+char *create_keytab(struct options *opts)
+{
+ char *buf, *fname;
+ int ret;
+
+ fname = get_temp_filename();
+
+ ret = asprintf(&buf, "ktadd -k %s %s\n", fname, opts->princ_name);
+ if (ret == -1) {
+ perror("asprintf");
+ exit(1);
+ }
+
+ write_to_kadmin(opts, buf, ret);
+
+ free(buf);
+
+ write_to_kadmin(opts, "quit\n", sizeof("quit\n"));
+
+ return fname;
+}
+
+void read_keytab(char *fname)
+{
+ FILE *fd;
+ char *data;
+ long flen, ret;
+
+ fd = fopen(fname, "r");
+ if (!fd) {
+ fprintf(stderr, "could not open file %s: ", fname);
+ perror(NULL);
+ exit(1);
+ }
+
+ fseek(fd, 0, SEEK_END);
+ flen = ftell(fd);
+ rewind(fd);
+
+ data = xmalloc(flen);
+
+ /* TODO: handle short reads */
+ ret = fread(data, 1, flen, fd);
+ if (ret != flen) {
+ fprintf(stderr, "short read");
+ exit(1);
+ }
+
+ fclose(fd);
+
+ /* write to stdout */
+ ret = fwrite(data, 1, flen, stdout);
+ if (ret != flen) {
+ fprintf(stderr, "short write");
+ exit(1);
+ }
+}
+
+void remove_keytab(char *filename)
+{
+ unlink(filename);
+}
+
+/* TODO: add significantly better authorization */
+int main(int argc, char **argv)
+{
+ struct options *opts;
+ pid_t chpid;
+ int status, ret;
+ char *fname;
+
+ opts = process_args(argc, argv);
+
+ /* must really be root */
+ setuid(0);
+
+ drop_caps();
+
+
+ chpid = exec_kadmin_local(opts);
+ fname = create_keytab(opts);
+
+ ret = waitpid(-1, &status, 0);
+ if (WEXITSTATUS(status)) {
+ fprintf(stderr, "error creating keytab\n");
+ exit(1);
+ }
+
+ read_keytab(fname);
+ remove_keytab(fname);
+
+ return 0;
+}
diff --git a/ipa-server/ipaserver/krbinstance.py b/ipa-server/ipaserver/krbinstance.py
index 84d677162..c83002f73 100644
--- a/ipa-server/ipaserver/krbinstance.py
+++ b/ipa-server/ipaserver/krbinstance.py
@@ -165,6 +165,7 @@ class KrbInstance(service.Service):
def __copy_ldap_passwd(self, filename):
shutil.copy(filename, "/var/kerberos/krb5kdc/ldappwd")
+ os.chmod("/var/kerberos/krb5kdc/ldappwd", 0600)
def __configure_kdc_account_password(self):
@@ -175,6 +176,7 @@ class KrbInstance(service.Service):
pwd_fd = open("/var/kerberos/krb5kdc/ldappwd", "w")
pwd_fd.write("uid=kdc,cn=sysaccounts,cn=etc,"+self.suffix+"#{HEX}"+hexpwd+"\n")
pwd_fd.close()
+ os.chmod("/var/kerberos/krb5kdc/ldappwd", 0600)
def __setup_sub_dict(self):
self.sub_dict = dict(FQDN=self.fqdn,
diff --git a/ipa-server/xmlrpc-server/funcs.py b/ipa-server/xmlrpc-server/funcs.py
index 17555afb7..ef196a0a5 100644
--- a/ipa-server/xmlrpc-server/funcs.py
+++ b/ipa-server/xmlrpc-server/funcs.py
@@ -37,6 +37,7 @@ from types import *
import os
import re
import logging
+import subprocess
try:
from threading import Lock
@@ -49,6 +50,7 @@ _LDAPPool = None
ACIContainer = "cn=accounts"
DefaultUserContainer = "cn=users,cn=accounts"
DefaultGroupContainer = "cn=groups,cn=accounts"
+DefaultServiceContainer = "cn=services,cn=accounts"
# FIXME: need to check the ipadebug option in ipa.conf
#logging.basicConfig(level=logging.DEBUG,
@@ -1287,6 +1289,71 @@ class IPAServer:
group = self.get_entry_by_cn(cn, ['dn', 'uid'], opts)
return self.mark_entry_inactive(group.get('dn'))
+ def __is_service_unique(self, name, opts):
+ """Return 1 if the uid is unique in the tree, 0 otherwise."""
+ name = self.__safe_filter(name)
+ filter = "(&(krbprincipalname=%s)(objectclass=krbPrincipal))" % name
+
+ try:
+ entry = self.__get_sub_entry(self.basedn, filter, ['dn','krbprincipalname'], opts)
+ return 0
+ except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
+ return 1
+
+ def add_service_principal(self, name, opts=None):
+ service_container = DefaultServiceContainer
+
+ princ_name = name + "@" + self.realm
+
+ conn = self.getConnection(opts)
+ if self.__is_service_unique(name, opts) == 0:
+ raise ipaerror.gen_exception(ipaerror.LDAP_DUPLICATE)
+
+ dn = "krbprincipalname=%s,%s,%s" % (ldap.dn.escape_dn_chars(princ_name),
+ service_container,self.basedn)
+ entry = ipaserver.ipaldap.Entry(dn)
+
+ entry.setValues('objectclass', 'krbPrincipal', 'krbPrincipalAux', 'krbTicketPolicyAux')
+ entry.setValues('krbprincipalname', princ_name)
+
+ try:
+ res = conn.addEntry(entry)
+ finally:
+ self.releaseConnection(conn)
+ return res
+
+
+ def get_keytab(self, name, opts=None):
+ """get a keytab"""
+
+ princ_name = name + "@" + self.realm
+
+ conn = self.getConnection(opts)
+
+ if conn.principal != "admin@" + self.realm:
+ raise ipaerror.gen_exception(ipaerror.CONNECTION_GSSAPI_CREDENTIALS)
+
+ try:
+ try:
+ princs = conn.getList(self.basedn, self.scope, "krbprincipalname=" + princ_name, None)
+ except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
+ return None
+ finally:
+ self.releaseConnection(conn)
+
+
+ # This is ugly - call out to a C wrapper around kadmin.local
+ p = subprocess.Popen(["/usr/sbin/ipa-keytab-util", princ_name, self.realm],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout,stderr = p.communicate()
+
+ if p.returncode != 0:
+ return None
+
+ return stdout
+
+
+
# Configuration support
def get_ipa_config(self, opts=None):
"""Retrieve the IPA configuration"""
diff --git a/ipa-server/xmlrpc-server/ipaxmlrpc.py b/ipa-server/xmlrpc-server/ipaxmlrpc.py
index 789233c9f..c6f0ec2ce 100644
--- a/ipa-server/xmlrpc-server/ipaxmlrpc.py
+++ b/ipa-server/xmlrpc-server/ipaxmlrpc.py
@@ -359,6 +359,8 @@ def handler(req, profiling=False):
h.register_function(f.update_ipa_config)
h.register_function(f.get_password_policy)
h.register_function(f.update_password_policy)
+ h.register_function(f.add_service_principal)
+ h.register_function(f.get_keytab)
h.handle_request(req)
finally:
pass
From 61258a645cc6a7d1acbf1b715de7a16cdd389279 Mon Sep 17 00:00:00 2001
From: Karl MacMillan
Date: Wed, 21 Nov 2007 23:31:18 -0500
Subject: [PATCH 58/60] Add ipa-keytab-util to spec.
---
ipa-server/ipa-server.spec | 1 +
ipa-server/ipa-server.spec.in | 1 +
2 files changed, 2 insertions(+)
diff --git a/ipa-server/ipa-server.spec b/ipa-server/ipa-server.spec
index 7b78e06ab..4d84c8af4 100755
--- a/ipa-server/ipa-server.spec
+++ b/ipa-server/ipa-server.spec
@@ -75,6 +75,7 @@ rm -rf %{buildroot}
%{_sbindir}/ipa-replica-prepare
%{_sbindir}/ipa_kpasswd
%{_sbindir}/ipa-webgui
+%{_sbindir}/ipa-keytab-util
%attr(755,root,root) %{_initrddir}/ipa-kpasswd
%attr(755,root,root) %{_initrddir}/ipa-webgui
diff --git a/ipa-server/ipa-server.spec.in b/ipa-server/ipa-server.spec.in
index d28ffa70e..03e8d7473 100644
--- a/ipa-server/ipa-server.spec.in
+++ b/ipa-server/ipa-server.spec.in
@@ -75,6 +75,7 @@ rm -rf %{buildroot}
%{_sbindir}/ipa-replica-prepare
%{_sbindir}/ipa_kpasswd
%{_sbindir}/ipa-webgui
+%{_sbindir}/ipa-keytab-util
%attr(755,root,root) %{_initrddir}/ipa-kpasswd
%attr(755,root,root) %{_initrddir}/ipa-webgui
From a174d6d6e6dfaeafdd2c01d347acce6af3eb5b12 Mon Sep 17 00:00:00 2001
From: Karl MacMillan
Date: Wed, 21 Nov 2007 23:45:41 -0500
Subject: [PATCH 59/60] Fix mode on ipa-keytab-util.
---
ipa-server/ipa-server.spec | 3 ++-
ipa-server/ipa-server.spec.in | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/ipa-server/ipa-server.spec b/ipa-server/ipa-server.spec
index 4d84c8af4..81cf7d3d2 100755
--- a/ipa-server/ipa-server.spec
+++ b/ipa-server/ipa-server.spec
@@ -75,7 +75,7 @@ rm -rf %{buildroot}
%{_sbindir}/ipa-replica-prepare
%{_sbindir}/ipa_kpasswd
%{_sbindir}/ipa-webgui
-%{_sbindir}/ipa-keytab-util
+%attr(4750,root,apache) %{_sbindir}/ipa-keytab-util
%attr(755,root,root) %{_initrddir}/ipa-kpasswd
%attr(755,root,root) %{_initrddir}/ipa-webgui
@@ -89,6 +89,7 @@ rm -rf %{buildroot}
%changelog
* Wed Nov 21 2007 Karl MacMillan - 0.5.0-1
+- Preverse mode on ipa-keytab-util
- Version bump for relase and rpm name change
* Thu Nov 15 2007 Rob Crittenden - 0.4.1-2
diff --git a/ipa-server/ipa-server.spec.in b/ipa-server/ipa-server.spec.in
index 03e8d7473..cfe9b8d79 100644
--- a/ipa-server/ipa-server.spec.in
+++ b/ipa-server/ipa-server.spec.in
@@ -75,7 +75,7 @@ rm -rf %{buildroot}
%{_sbindir}/ipa-replica-prepare
%{_sbindir}/ipa_kpasswd
%{_sbindir}/ipa-webgui
-%{_sbindir}/ipa-keytab-util
+%attr(4750,root,apache) %{_sbindir}/ipa-keytab-util
%attr(755,root,root) %{_initrddir}/ipa-kpasswd
%attr(755,root,root) %{_initrddir}/ipa-webgui
@@ -89,6 +89,7 @@ rm -rf %{buildroot}
%changelog
* Wed Nov 21 2007 Karl MacMillan - 0.5.0-1
+- Preverse mode on ipa-keytab-util
- Version bump for relase and rpm name change
* Thu Nov 15 2007 Rob Crittenden - 0.4.1-2
From 2e7f629d913d775cfb285ede166d7a0f977782fe Mon Sep 17 00:00:00 2001
From: Rob Crittenden
Date: Mon, 26 Nov 2007 20:34:59 -0500
Subject: [PATCH 60/60] Remove unnecessary attribute left over from testing
---
ipa-server/ipa-install/share/bootstrap-template.ldif | 1 -
1 file changed, 1 deletion(-)
diff --git a/ipa-server/ipa-install/share/bootstrap-template.ldif b/ipa-server/ipa-install/share/bootstrap-template.ldif
index 5efec3c44..4fedd6af4 100644
--- a/ipa-server/ipa-install/share/bootstrap-template.ldif
+++ b/ipa-server/ipa-install/share/bootstrap-template.ldif
@@ -126,7 +126,6 @@ objectClass: cosSuperDefinition
objectClass: cosClassicDefinition
cosTemplateDn: cn=cosTemplates,cn=accounts,$SUFFIX
cosAttribute: nsAccountLock operational
-cosAttribute: pager
cosSpecifier: memberOf
cn: Account Inactivation