Add a new daemon - ipa_configd ipa_configd is a daemon which runs as root and watches for modifications to configuration in the directory and apply those modifications to the system configuration. e.g. a firstboot form in the UI will ask the user various questions, write the answers to the directory and ipa_configd will set everything up according to those answers by e.g. configuring the kerberos server with the supplied realm name. Signed-off-by: Mark McLoughlin diff -r c2c3e59fcbdf ipa-server/Makefile.am --- a/ipa-server/Makefile.am Tue Jan 22 08:06:52 2008 +0000 +++ b/ipa-server/Makefile.am Tue Jan 22 08:21:26 2008 +0000 @@ -5,6 +5,7 @@ NULL = NULL = SUBDIRS = \ + ipa-configd \ ipa-gui \ ipa-install \ ipa-kpasswd \ diff -r c2c3e59fcbdf ipa-server/configure.ac --- a/ipa-server/configure.ac Tue Jan 22 08:06:52 2008 +0000 +++ b/ipa-server/configure.ac Tue Jan 22 08:21:26 2008 +0000 @@ -213,6 +213,8 @@ AC_SUBST(LDFLAGS) AC_CONFIG_FILES([ Makefile + ipa-configd/Makefile + ipa-configd/ipaconfigd/Makefile ipa-gui/Makefile ipa-gui/ipagui/Makefile ipa-gui/ipagui/config/Makefile diff -r c2c3e59fcbdf ipa-server/ipa-configd/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ipa-server/ipa-configd/Makefile.am Tue Jan 22 08:21:26 2008 +0000 @@ -0,0 +1,15 @@ +SUBDIRS = ipaconfigd + +sbin_SCRIPTS = ipa_configd + +initdir = $(sysconfdir)/rc.d/init.d + +install-data-hook: ipa_configd.init + if test '!' -d $(DESTDIR)$(initdir); then \ + $(mkinstalldirs) $(DESTDIR)$(initdir); \ + chmod 755 $(DESTDIR)$(initdir); \ + fi + $(INSTALL_SCRIPT) $(srcdir)/ipa_configd.init $(DESTDIR)$(initdir)/ipa_configd + +uninstall-hook: + rm -f $(DESTDIR)$(initdir)/ipa_configd diff -r c2c3e59fcbdf ipa-server/ipa-configd/ipa_configd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ipa-server/ipa-configd/ipa_configd Tue Jan 22 08:21:26 2008 +0000 @@ -0,0 +1,24 @@ +#! /usr/bin/python -E +# +# 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 sys + +from ipaconfigd import main + +main.main(sys.argv[1:]) diff -r c2c3e59fcbdf ipa-server/ipa-configd/ipa_configd.init --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ipa-server/ipa-configd/ipa_configd.init Tue Jan 22 08:21:26 2008 +0000 @@ -0,0 +1,80 @@ +#!/bin/bash +# +# ipa_configd This shell script takes care of starting and stopping +# ipa_configd. +# +# chkconfig: - 98 02 +# description: ipa_configd is the IPA configuration daemon. It monitors +# the directory server for configuration changes and +# applies those changes to the system. + +# Source function library. +. /etc/rc.d/init.d/functions + +[ -f $ipaconfig ] || exit 0 + +start() { + echo -n $"Starting ipa_configd: " + daemon /usr/sbin/ipa_configd --pidfile /var/run/ipa_configd.pid 2>/dev/null + RETVAL=$? + echo + if [ $RETVAL -eq 0 ]; then + touch /var/lock/subsys/ipa_configd + if [ -x /usr/bin/logger ]; then + /usr/bin/logger -t ipa_configd "ipa_configd startup succeeded" + fi; + else + if [ -x /usr/bin/logger ]; then + /usr/bin/logger -t ipa_configd "ipa_configd startup failed" + fi; + fi + return $RETVAL +} + +stop() { + echo -n $"Shutting down ipa_configd: " + killproc /usr/sbin/ipa_configd + RETVAL=$? + echo + if [ $RETVAL -eq 0 ]; then + rm -f /var/lock/subsys/ipa_configd + if [ -x /usr/bin/logger ]; then + /usr/bin/logger -t ipa_configd "ipa_configd shutdown succeeded" + fi; + else + if [ -x /usr/bin/logger ]; then + /usr/bin/logger -t ipa_configd "ipa_configd shutdown failed" + fi; + fi + return $RETVAL +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + stop + start + RETVAL=$? + ;; + condrestart) + if [ -f /var/lock/subsys/ipa_configd ]; then + stop + start + RETVAL=$? + fi + ;; + status) + status ipa_configd + RETVAL=$? + ;; + *) + echo $"Usage: $0 {start|stop|restart|condrestart|status}" + exit 1 +esac + +exit $RETVAL diff -r c2c3e59fcbdf ipa-server/ipa-configd/ipaconfigd/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ipa-server/ipa-configd/ipaconfigd/Makefile.am Tue Jan 22 08:21:26 2008 +0000 @@ -0,0 +1,7 @@ +NULL = + +ipaconfigddir = $(pythondir)/ipaconfigd/ +ipaconfigd_PYTHON = \ + __init__.py \ + main.py \ + $(NULL) diff -r c2c3e59fcbdf ipa-server/ipa-configd/ipaconfigd/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ipa-server/ipa-configd/ipaconfigd/__init__.py Tue Jan 22 08:21:26 2008 +0000 @@ -0,0 +1,17 @@ +# +# 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 +# diff -r c2c3e59fcbdf ipa-server/ipa-configd/ipaconfigd/main.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ipa-server/ipa-configd/ipaconfigd/main.py Tue Jan 22 08:21:26 2008 +0000 @@ -0,0 +1,100 @@ +# +# 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 +# + +# +# FIXME: signal handling +# FIXME: use syslog +# + +import sys +import os +import os.path +import optparse +from config import * + +def daemonize(): + """Detach from the controlling terminal and run in the background.""" + pid = os.fork() + if pid != 0: # parent + os._exit(0) + + os.setsid() + + os.chdir("/") + os.umask(0022) + + fd = os.open("/dev/null", os.O_RDWR) + + os.dup2(fd, 0) + os.dup2(fd, 1) + os.dup2(fd, 2) + + os.close(fd) + +def write_pid_file(pidfile): + """Write the current process ID to @pidfile.""" + f = file(pidfile, "w") + f.write(str(os.getpid())) + f.close() + +def parse_args(args): + """Parse command line options in @args.""" + + parser = optparse.OptionParser(usage = "%prog\n"); + + group = optparse.OptionGroup(parser, "Daemon Options") + group.add_option ("--nofork", + action = "store_true", + dest = "nofork", + default = False, + help = "Do not fork and become a daemon process") + group.add_option ("--debug", + action = "store_true", + dest = "debug", + default = False, + help = "Print debugging messages to stderr. Implies --nofork") + group.add_option ("--pidfile", + dest = "pidfile", + help = "Store the daemon's process ID in the named file", + metavar = "PIDFILE") + parser.add_option_group(group) + + (options, args) = parser.parse_args(args) + + if len(args) != 0: + parser.print_usage() + sys.exit(1) + + return options + +def main (args): + options = parse_args(args) + + if not (options.debug or options.nofork): + daemonize() + + if options.pidfile: + write_pid_file(options.pidfile) + + try: + while True: + import time + time.sleep(10) + finally: + if options.pidfile and os.path.exists(options.pidfile): + os.remove(options.pidfile) diff -r c2c3e59fcbdf ipa-server/ipa-server.spec --- a/ipa-server/ipa-server.spec Tue Jan 22 08:06:52 2008 +0000 +++ b/ipa-server/ipa-server.spec Tue Jan 22 08:21:26 2008 +0000 @@ -72,20 +72,24 @@ rm -rf %{buildroot} %post if [ $1 = 1 ]; then + /sbin/chkconfig --add ipa_configd /sbin/chkconfig --add ipa_kpasswd /sbin/chkconfig --add ipa_webgui fi %preun if [ $1 = 0 ]; then + /sbin/chkconfig --del ipa_configd /sbin/chkconfig --del ipa_kpasswd /sbin/chkconfig --del ipa_webgui + /sbin/service ipa_configd stop >/dev/null 2>&1 || : /sbin/service ipa_kpasswd stop >/dev/null 2>&1 || : /sbin/service ipa_webgui stop >/dev/null 2>&1 || : fi %postun if [ "$1" -ge "1" ]; then + /sbin/service ipa_configd condrestart >/dev/null 2>&1 || : /sbin/service ipa_kpasswd condrestart >/dev/null 2>&1 || : /sbin/service ipa_webgui condrestart >/dev/null 2>&1 || : fi @@ -97,8 +101,10 @@ fi %{_sbindir}/ipa-replica-prepare %{_sbindir}/ipa-replica-manage %{_sbindir}/ipa-server-certinstall +%{_sbindir}/ipa_configd %{_sbindir}/ipa_kpasswd %{_sbindir}/ipa_webgui +%attr(755,root,root) %{_initrddir}/ipa_configd %attr(755,root,root) %{_initrddir}/ipa_kpasswd %attr(755,root,root) %{_initrddir}/ipa_webgui @@ -107,6 +113,9 @@ fi %dir %{python_sitelib}/ipaserver %{python_sitelib}/ipaserver/*.py* + +%dir %{python_sitelib}/ipaconfigd/ +%{python_sitelib}/ipaconfigd/*.py* %attr(755,root,root) %{plugin_dir}/libipa_pwd_extop.so %attr(755,root,root) %{plugin_dir}/libipa-memberof-plugin.so diff -r c2c3e59fcbdf ipa-server/ipa-server.spec.in --- a/ipa-server/ipa-server.spec.in Tue Jan 22 08:06:52 2008 +0000 +++ b/ipa-server/ipa-server.spec.in Tue Jan 22 08:21:26 2008 +0000 @@ -72,20 +72,24 @@ rm -rf %{buildroot} %post if [ $1 = 1 ]; then + /sbin/chkconfig --add ipa_configd /sbin/chkconfig --add ipa_kpasswd /sbin/chkconfig --add ipa_webgui fi %preun if [ $1 = 0 ]; then + /sbin/chkconfig --del ipa_configd /sbin/chkconfig --del ipa_kpasswd /sbin/chkconfig --del ipa_webgui + /sbin/service ipa_configd stop >/dev/null 2>&1 || : /sbin/service ipa_kpasswd stop >/dev/null 2>&1 || : /sbin/service ipa_webgui stop >/dev/null 2>&1 || : fi %postun if [ "$1" -ge "1" ]; then + /sbin/service ipa_configd condrestart >/dev/null 2>&1 || : /sbin/service ipa_kpasswd condrestart >/dev/null 2>&1 || : /sbin/service ipa_webgui condrestart >/dev/null 2>&1 || : fi @@ -97,8 +101,10 @@ fi %{_sbindir}/ipa-replica-prepare %{_sbindir}/ipa-replica-manage %{_sbindir}/ipa-server-certinstall +%{_sbindir}/ipa_configd %{_sbindir}/ipa_kpasswd %{_sbindir}/ipa_webgui +%attr(755,root,root) %{_initrddir}/ipa_configd %attr(755,root,root) %{_initrddir}/ipa_kpasswd %attr(755,root,root) %{_initrddir}/ipa_webgui @@ -107,6 +113,9 @@ fi %dir %{python_sitelib}/ipaserver %{python_sitelib}/ipaserver/*.py* + +%dir %{python_sitelib}/ipaconfigd/ +%{python_sitelib}/ipaconfigd/*.py* %attr(755,root,root) %{plugin_dir}/libipa_pwd_extop.so %attr(755,root,root) %{plugin_dir}/libipa-memberof-plugin.so