From 042fb11fa107718a831d468d16188e02f6ae3712 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Fri, 18 Jan 2008 16:20:36 -0500 Subject: Fix issues reported by rpmlint. - Removing shebangs (#!) from a bunch of python libraries - Don't use a variable name in init scripts for the lock file - Keep the init script name consistent with the binary name, so renamed ipa-kpasswd.init to ipa_kpasswd.init - Add status option to the init scripts - Move most python scripts out of /usr/share/ipa and into the python site-packages directories (ipaserver and ipaclient) - Remove unnecessary sys.path.append("/usr/share/ipa") - Fix the license string in the spec files - Rename ipa-webgui to ipa_webgui everywhere - Fix a couple of issues reported by pychecker in ipa-python --- ipa-server/ipa-gui/Makefile.am | 12 ++-- ipa-server/ipa-gui/ipa-webgui | 110 ------------------------------------- ipa-server/ipa-gui/ipa-webgui.cfg | 105 ----------------------------------- ipa-server/ipa-gui/ipa-webgui.init | 73 ------------------------ ipa-server/ipa-gui/ipa_webgui | 110 +++++++++++++++++++++++++++++++++++++ ipa-server/ipa-gui/ipa_webgui.cfg | 105 +++++++++++++++++++++++++++++++++++ ipa-server/ipa-gui/ipa_webgui.init | 79 ++++++++++++++++++++++++++ 7 files changed, 300 insertions(+), 294 deletions(-) delete mode 100644 ipa-server/ipa-gui/ipa-webgui delete mode 100644 ipa-server/ipa-gui/ipa-webgui.cfg delete mode 100644 ipa-server/ipa-gui/ipa-webgui.init create mode 100644 ipa-server/ipa-gui/ipa_webgui create mode 100644 ipa-server/ipa-gui/ipa_webgui.cfg create mode 100644 ipa-server/ipa-gui/ipa_webgui.init (limited to 'ipa-server/ipa-gui') diff --git a/ipa-server/ipa-gui/Makefile.am b/ipa-server/ipa-gui/Makefile.am index 35f9ff9fd..c09a5c141 100644 --- a/ipa-server/ipa-gui/Makefile.am +++ b/ipa-server/ipa-gui/Makefile.am @@ -6,19 +6,19 @@ SUBDIRS = \ $(NULL) sbin_SCRIPTS = \ - ipa-webgui \ + ipa_webgui \ $(NULL) appdir = $(IPA_DATA_DIR) app_DATA = \ - ipa-webgui.cfg \ + ipa_webgui.cfg \ $(NULL) EXTRA_DIST = \ README.txt \ $(sbin_SCRIPTS) \ $(app_DATA) \ - ipa-webgui.init \ + ipa_webgui.init \ dev.cfg \ sample-prod.cfg \ setup.py \ @@ -32,13 +32,13 @@ MAINTAINERCLEANFILES = \ initdir=$(sysconfdir)/rc.d/init.d -install-data-hook: ipa-webgui.init +install-data-hook: ipa_webgui.init if test '!' -d $(DESTDIR)$(initdir); then \ $(mkinstalldirs) $(DESTDIR)$(initdir); \ chmod 755 $(DESTDIR)$(initdir); \ fi - $(INSTALL_SCRIPT) $(srcdir)/ipa-webgui.init $(DESTDIR)$(initdir)/ipa-webgui + $(INSTALL_SCRIPT) $(srcdir)/ipa_webgui.init $(DESTDIR)$(initdir)/ipa_webgui uninstall-hook: - rm -f $(DESTDIR)$(initdir)/ipa-webgui + rm -f $(DESTDIR)$(initdir)/ipa_webgui diff --git a/ipa-server/ipa-gui/ipa-webgui b/ipa-server/ipa-gui/ipa-webgui deleted file mode 100644 index a18c2db81..000000000 --- a/ipa-server/ipa-gui/ipa-webgui +++ /dev/null @@ -1,110 +0,0 @@ -#! /usr/bin/python -E -# -# 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 os, sys - -def daemonize(): - # fork once so the parent can exit - try: - pid = os.fork() - except OSError, e: - raise Exception, "%s [%d]" % (e.strerror, e.errno) - - if pid != 0: - os._exit(0) - - # become session leader - os.setsid() - - # fork again to reparent to init - try: - pid = os.fork() - except OSError, e: - raise Exception, "%s [%d]" % (e.strerror, e.errno) - - if pid != 0: - os._exit(0) - - os.chdir("/") - os.umask(0) - - import resource - maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1] - if (maxfd == resource.RLIM_INFINITY): - maxfd = 1024 - - # close all file descriptors - for fd in range(0, maxfd): - try: - os.close(fd) - except OSError: - pass - - # stdin - os.open("/dev/null", os.O_RDWR) - # stdout - os.open("/dev/null", os.O_RDWR) - # stderr - os.open("/dev/null", os.O_RDWR) - -def main(): - # To make development easier, we detect if we are in the development - # environment to load a different configuration and avoid becoming - # a daemon - devel = False - if os.path.exists(os.path.join(os.path.dirname(__file__), "Makefile.am")): - devel = True - - if not devel: - try: - daemonize() - except Exception, e: - sys.stderr.write("error becoming daemon: " + str(e)) - sys.exit(1) - - sys.path.append("/usr/share/ipa/") - - # this must be after sys.path is changed to work correctly - import pkg_resources - pkg_resources.require("TurboGears") - pkg_resources.require("ipa_gui") - - - from turbogears import update_config, start_server - import cherrypy - cherrypy.lowercase_api = True - - # Load the config - look for a local file first for development - # and then the system config file - if devel: - update_config(configfile="dev.cfg", - modulename="ipagui.config") - else: - update_config(configfile="/usr/share/ipa/ipa-webgui.cfg", - modulename="ipagui.config.app") - - from ipagui.controllers import Root - - start_server(Root()) - -try: - main() -except Exception, e: - print "failed to start web gui: %s" % str(e) - sys.exit(1) diff --git a/ipa-server/ipa-gui/ipa-webgui.cfg b/ipa-server/ipa-gui/ipa-webgui.cfg deleted file mode 100644 index 35b0b4f58..000000000 --- a/ipa-server/ipa-gui/ipa-webgui.cfg +++ /dev/null @@ -1,105 +0,0 @@ -[global] -# DATABASE - -# no database for ipa-webgui since everything is stored in LDAP - -# IDENTITY - -# Our our sqlobject-derived proxy provider -identity.provider='proxyprovider' - -# the first thing checked on any request. We want to short-circuit this -# as early as possible -identity.source = 'visit' - -# Turn on identity and visit (visit is required for identity) -identity.on=True -identity.failure_url="/loginfailed" -visit.on=True -visit.manager='proxyvisit' - -# SERVER - -server.environment="production" -autoreload.package="ipagui" -autoreload.on = False - -# Sets the number of threads the server uses -server.thread_pool = 10 - -# if this is part of a larger site, you can set the path -# to the TurboGears instance here -# server.webpath="" - -# Set to True if you are deploying your App behind a proxy -# e.g. Apache using mod_proxy -# base_url_filter.on = False - -# Set to True if your proxy adds the x_forwarded_host header -# base_url_filter.use_x_forwarded_host = True - -# If your proxy does not add the x_forwarded_host header, set -# the following to the *public* host url. -# (Note: This will be overridden by the use_x_forwarded_host option -# if it is set to True and the proxy adds the header correctly. -# base_url_filter.base_url = "http://www.example.com" - -# Set to True if you'd like to abort execution if a controller gets an -# unexpected parameter. False by default -# tg.strict_parameters = False - -# LOGGING -# Logging configuration generally follows the style of the standard -# Python logging module configuration. Note that when specifying -# log format messages, you need to use *() for formatting variables. -# Deployment independent log configuration is in ipagui/config/log.cfg -[logging] - -[[formatters]] -[[[message_only]]] -format='*(message)s' - -[[[full_content]]] -format='*(asctime)s *(name)s *(levelname)s *(message)s' - -[[handlers]] -[[[debug_out]]] -# Rotate weekly on Sunday. Keep 4 backups of the log -class='TimedRotatingFileHandler' -level='DEBUG' -args="('/var/log/ipa_error.log', 'w6', 1, 4)" -formatter='full_content' - -[[[access_out]]] -# For example only if one wants to duplicate the access log in TurboGears -# Rotate weekly on Sunday. Keep 4 backups of the log -#class='TimedRotatingFileHandler' -#level='INFO' -#args="('/var/log/ipa_error.log', 'w6', 1, 4)" -#formatter='message_only' -# By default log access to stdout which will go to /dev/null in production -class='StreamHandler' -level='INFO' -args='(sys.stdout,)' -formatter='message_only' - -[[[error_out]]] -class='StreamHandler' -level='ERROR' -args='(sys.stdout,)' - -[[loggers]] -[[[ipagui]]] -level='DEBUG' -qualname='ipagui' -handlers=['debug_out'] - -[[[allinfo]]] -level='INFO' -handlers=['debug_out'] - -[[[access]]] -level='INFO' -qualname='turbogears.access' -handlers=['access_out'] -propagate=0 diff --git a/ipa-server/ipa-gui/ipa-webgui.init b/ipa-server/ipa-gui/ipa-webgui.init deleted file mode 100644 index 4e53edde2..000000000 --- a/ipa-server/ipa-gui/ipa-webgui.init +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -# -# ipa-webgui This starts and stops ipa-webgui -# -# chkconfig: - 36 64 -# description: ipa-webgui IPA Web User Interface -# processname: /usr/sbin/ipa-webgui -# configdir: /etc/sysconfig/ipa-webgui -# - -# Source function library. -if [ -f /etc/rc.d/init.d/functions ] ; then -. /etc/rc.d/init.d/functions -fi -# Source networking configuration. -if [ -f /etc/sysconfig/network ] ; then -. /etc/sysconfig/network -fi - -# Check that networking is up. -if [ "${NETWORKING}" = "no" ] -then - echo "Networking is down" - exit 0 -fi - -NAME="ipa-webgui" -PROG="/usr/sbin/ipa-webgui" -RUNAS="apache" - -start() { - echo -n $"Starting $NAME: " - daemon --user $RUNAS $PROG - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$NAME || \ - RETVAL=1 - return $RETVAL -} - -stop() { - echo -n $"Shutting down $NAME: " - killproc $NAME - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$NAME - return $RETVAL -} - -restart() { - stop - start -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - restart - ;; - condrestart) - [ -f /var/lock/subsys/$NAME ] && restart || : - ;; - *) - echo $"Usage: $0 {start|stop|restart|condrestart}" - exit 2 -esac - -exit $? diff --git a/ipa-server/ipa-gui/ipa_webgui b/ipa-server/ipa-gui/ipa_webgui new file mode 100644 index 000000000..c496d7cc9 --- /dev/null +++ b/ipa-server/ipa-gui/ipa_webgui @@ -0,0 +1,110 @@ +#! /usr/bin/python -E +# +# 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 os, sys + +def daemonize(): + # fork once so the parent can exit + try: + pid = os.fork() + except OSError, e: + raise Exception, "%s [%d]" % (e.strerror, e.errno) + + if pid != 0: + os._exit(0) + + # become session leader + os.setsid() + + # fork again to reparent to init + try: + pid = os.fork() + except OSError, e: + raise Exception, "%s [%d]" % (e.strerror, e.errno) + + if pid != 0: + os._exit(0) + + os.chdir("/") + os.umask(0) + + import resource + maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1] + if (maxfd == resource.RLIM_INFINITY): + maxfd = 1024 + + # close all file descriptors + for fd in range(0, maxfd): + try: + os.close(fd) + except OSError: + pass + + # stdin + os.open("/dev/null", os.O_RDWR) + # stdout + os.open("/dev/null", os.O_RDWR) + # stderr + os.open("/dev/null", os.O_RDWR) + +def main(): + # To make development easier, we detect if we are in the development + # environment to load a different configuration and avoid becoming + # a daemon + devel = False + if os.path.exists(os.path.join(os.path.dirname(__file__), "Makefile.am")): + devel = True + + if not devel: + try: + daemonize() + except Exception, e: + sys.stderr.write("error becoming daemon: " + str(e)) + sys.exit(1) + + sys.path.append("/usr/share/ipa/") + + # this must be after sys.path is changed to work correctly + import pkg_resources + pkg_resources.require("TurboGears") + pkg_resources.require("ipa_gui") + + + from turbogears import update_config, start_server + import cherrypy + cherrypy.lowercase_api = True + + # Load the config - look for a local file first for development + # and then the system config file + if devel: + update_config(configfile="dev.cfg", + modulename="ipagui.config") + else: + update_config(configfile="/usr/share/ipa/ipa_webgui.cfg", + modulename="ipagui.config.app") + + from ipagui.controllers import Root + + start_server(Root()) + +try: + main() +except Exception, e: + print "failed to start web gui: %s" % str(e) + sys.exit(1) diff --git a/ipa-server/ipa-gui/ipa_webgui.cfg b/ipa-server/ipa-gui/ipa_webgui.cfg new file mode 100644 index 000000000..838ac32d2 --- /dev/null +++ b/ipa-server/ipa-gui/ipa_webgui.cfg @@ -0,0 +1,105 @@ +[global] +# DATABASE + +# no database for ipa_webgui since everything is stored in LDAP + +# IDENTITY + +# Our our sqlobject-derived proxy provider +identity.provider='proxyprovider' + +# the first thing checked on any request. We want to short-circuit this +# as early as possible +identity.source = 'visit' + +# Turn on identity and visit (visit is required for identity) +identity.on=True +identity.failure_url="/loginfailed" +visit.on=True +visit.manager='proxyvisit' + +# SERVER + +server.environment="production" +autoreload.package="ipagui" +autoreload.on = False + +# Sets the number of threads the server uses +server.thread_pool = 10 + +# if this is part of a larger site, you can set the path +# to the TurboGears instance here +# server.webpath="" + +# Set to True if you are deploying your App behind a proxy +# e.g. Apache using mod_proxy +# base_url_filter.on = False + +# Set to True if your proxy adds the x_forwarded_host header +# base_url_filter.use_x_forwarded_host = True + +# If your proxy does not add the x_forwarded_host header, set +# the following to the *public* host url. +# (Note: This will be overridden by the use_x_forwarded_host option +# if it is set to True and the proxy adds the header correctly. +# base_url_filter.base_url = "http://www.example.com" + +# Set to True if you'd like to abort execution if a controller gets an +# unexpected parameter. False by default +# tg.strict_parameters = False + +# LOGGING +# Logging configuration generally follows the style of the standard +# Python logging module configuration. Note that when specifying +# log format messages, you need to use *() for formatting variables. +# Deployment independent log configuration is in ipagui/config/log.cfg +[logging] + +[[formatters]] +[[[message_only]]] +format='*(message)s' + +[[[full_content]]] +format='*(asctime)s *(name)s *(levelname)s *(message)s' + +[[handlers]] +[[[debug_out]]] +# Rotate weekly on Sunday. Keep 4 backups of the log +class='TimedRotatingFileHandler' +level='DEBUG' +args="('/var/log/ipa_error.log', 'w6', 1, 4)" +formatter='full_content' + +[[[access_out]]] +# For example only if one wants to duplicate the access log in TurboGears +# Rotate weekly on Sunday. Keep 4 backups of the log +#class='TimedRotatingFileHandler' +#level='INFO' +#args="('/var/log/ipa_error.log', 'w6', 1, 4)" +#formatter='message_only' +# By default log access to stdout which will go to /dev/null in production +class='StreamHandler' +level='INFO' +args='(sys.stdout,)' +formatter='message_only' + +[[[error_out]]] +class='StreamHandler' +level='ERROR' +args='(sys.stdout,)' + +[[loggers]] +[[[ipagui]]] +level='DEBUG' +qualname='ipagui' +handlers=['debug_out'] + +[[[allinfo]]] +level='INFO' +handlers=['debug_out'] + +[[[access]]] +level='INFO' +qualname='turbogears.access' +handlers=['access_out'] +propagate=0 diff --git a/ipa-server/ipa-gui/ipa_webgui.init b/ipa-server/ipa-gui/ipa_webgui.init new file mode 100644 index 000000000..e603f9f2a --- /dev/null +++ b/ipa-server/ipa-gui/ipa_webgui.init @@ -0,0 +1,79 @@ +#!/bin/sh +# +# ipa_webgui This starts and stops ipa_webgui +# +# chkconfig: - 36 64 +# description: ipa_webgui IPA Web User Interface +# processname: /usr/sbin/ipa_webgui +# configdir: /etc/sysconfig/ipa_webgui +# + +# Source function library. +if [ -f /etc/rc.d/init.d/functions ] ; then +. /etc/rc.d/init.d/functions +fi +# Source networking configuration. +if [ -f /etc/sysconfig/network ] ; then +. /etc/sysconfig/network +fi + +# Check that networking is up. +if [ "${NETWORKING}" = "no" ] +then + echo "Networking is down" + exit 0 +fi + +NAME="ipa_webgui" +PROG="/usr/sbin/ipa_webgui" +RUNAS="apache" + +start() { + echo -n $"Starting $NAME: " + daemon --user $RUNAS $PROG + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ipa_webgui || \ + RETVAL=1 + return $RETVAL +} + +stop() { + echo -n $"Shutting down $NAME: " + killproc $NAME + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ipa_webgui + return $RETVAL +} + +restart() { + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status $PROG + ;; + restart) + restart + ;; + condrestart) + [ -f /var/lock/subsys/ipa_webgui ] && restart || : + ;; + reload) + exit 3 + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart}" + exit 2 +esac + +exit $? -- cgit