diff -r e0bdc4c0c8c3 ipa-server/ipa-configd/ipaconfigd/Makefile.am --- a/ipa-server/ipa-configd/ipaconfigd/Makefile.am Fri Jan 25 12:10:04 2008 +0000 +++ b/ipa-server/ipa-configd/ipaconfigd/Makefile.am Fri Jan 25 12:21:31 2008 +0000 @@ -11,6 +11,7 @@ ipaconfigddir = $(pythondir)/ipaconf ipaconfigddir = $(pythondir)/ipaconfigd/ ipaconfigd_PYTHON = \ __init__.py \ + adminpasswd.py \ config.py \ ldapcache.py \ hostname.py \ diff -r e0bdc4c0c8c3 ipa-server/ipa-configd/ipaconfigd/adminpasswd.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ipa-server/ipa-configd/ipaconfigd/adminpasswd.py Fri Jan 25 12:21:31 2008 +0000 @@ -0,0 +1,48 @@ +# +# Copyright (C) 2008 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 ipaserver.dsinstance + +def dprint (fmt, *args): + print fmt % args + pass + +def handle_directory_change(cache, type, dn, prev_dn, attrs, prev_attrs): + dprint("Handling change to '%s'" % dn) + + if dn.lower() != "cn=config,dc=ipa": + return + + def non_empty_attr(attrs, key): + return attrs.has_key(key) and attrs[key] and attrs[key][0] + + if not (non_empty_attr(attrs, "ipaRealmName") and + non_empty_attr(attrs, "ipaAdminPassword")): + return + + realm = attrs["ipaRealmName"][0] + admin_password = attrs["ipaAdminPassword"][0] + + dprint("Got ipaRealmName '%s' and ipaAdminPassword '%s'" % (realm, admin_password)) + + ds = ipaserver.dsinstance.DsInstance() + + ds.suffix = ipaserver.dsinstance.realm_to_suffix(realm) + ds.dm_password = file("/var/cache/ipa/dm-passwd", "r").read().rstrip("\n") + + ds.change_admin_password(admin_password) diff -r e0bdc4c0c8c3 ipa-server/ipa-configd/ipaconfigd/main.py --- a/ipa-server/ipa-configd/ipaconfigd/main.py Fri Jan 25 12:10:04 2008 +0000 +++ b/ipa-server/ipa-configd/ipaconfigd/main.py Fri Jan 25 12:21:31 2008 +0000 @@ -26,6 +26,7 @@ import os.path import os.path import optparse import ldapcache +import adminpasswd import hostname import realm from config import * @@ -134,10 +135,12 @@ def main (args): cache.add_monitor(hostname.handle_directory_change) cache.add_monitor(realm.handle_directory_change) + cache.add_monitor(adminpasswd.handle_directory_change) while True: cache.run() + cache.remove_monitor(adminpasswd.handle_directory_change) cache.remove_monitor(realm.handle_directory_change) cache.remove_monitor(hostname.handle_directory_change)