rpms/denyhosts/devel denyhosts.init, 1.6, 1.7 denyhosts.spec, 1.44, 1.45
Jason Tibbitts (tibbs)
fedora-extras-commits at redhat.com
Fri Aug 24 19:12:03 UTC 2007
Author: tibbs
Update of /cvs/extras/rpms/denyhosts/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32553
Modified Files:
denyhosts.init denyhosts.spec
Log Message:
* Thu Aug 23 2007 Jason L Tibbitts III <tibbs at math.uh.edu> - 2.6-7
- Init file tweaks including patch from Jonathan Underwood
(bug 188536).
- Attempt to add LSB-compliant comment block.
Index: denyhosts.init
===================================================================
RCS file: /cvs/extras/rpms/denyhosts/devel/denyhosts.init,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- denyhosts.init 30 Mar 2006 16:36:17 -0000 1.6
+++ denyhosts.init 24 Aug 2007 19:11:30 -0000 1.7
@@ -1,6 +1,8 @@
#!/bin/bash
#
-# denyhosts This shell script enables the denyhosts cron job
+# denyhosts This shell script starts the denyhosts daemon OR enables the
+# denyhosts cron job depending upon whether DAEMON = yes in
+# /etc/sysconfig/denyhosts
#
# Author: Seth Vidal <skvidal at phy.duke.edu> (original script)
# Jason Tibbitts <tibbs at math.uh.edu> (denyhost changes)
@@ -11,6 +13,11 @@
# processname denyhosts
# config: /etc/denyhosts.cfg
#
+### BEGIN INIT INFO
+# Provides: denyhosts
+# Required-Start: $syslog
+# Short-Description: Enable execution of denyhosts, an SSH log watcher
+### END INIT INFO
# source function library
. /etc/rc.d/init.d/functions
@@ -20,77 +27,132 @@
HOSTNAME=$(hostname)
export HOSTNAME
-CONTROL=/usr/bin/denyhosts-control
CRONLOCK=/var/lock/subsys/denyhosts.init
LOCKFILE=/var/lock/subsys/denyhosts
+
+DHOSTS=/usr/bin/denyhosts.py
+DOPTS="--daemon --config=/etc/denyhosts.conf"
+
RETVAL=0
+# Determine whether or not denyhosts is to be run as a daemon or periodically
+# by cron
[ -f /etc/sysconfig/denyhosts ] && . /etc/sysconfig/denyhosts
+
+# cron service functions
c_start() {
- echo -n $"Enabling denyhosts: "
- touch "$CRONLOCK" && success || failure
- RETVAL=$?
- echo
+ echo -n $"Enabling denyhosts cron service: "
+ touch "$CRONLOCK" && success || failure
+ RETVAL=$?
+ echo
}
c_stop() {
- echo -n $"Disabling denyhosts: "
- rm -f "$CRONLOCK" && success || failure
- RETVAL=$?
- echo
+ echo -n $"Disabling denyhosts cron service: "
+ rm -f "$CRONLOCK" && success || failure
+ RETVAL=$?
+ echo
}
c_restart() {
- c_stop
- c_start
+ c_stop
+ c_start
}
c_condrestart() {
- [ -f "$CRONLOCK" ] && c_restart
+ [ -f "$CRONLOCK" ] && c_restart
}
c_status() {
- if [ -f $CRONLOCK ]; then
- echo $"Denyhosts is enabled."
- RETVAL=0
- else
- echo $"Denyhosts is disabled."
- RETVAL=3
- fi
-}
-
-d_condrestart() { $CONTROL condrestart; RETVAL=$?; }
-d_restart() { $CONTROL restart; RETVAL=$?; }
-d_start() { $CONTROL start; RETVAL=$?; }
-d_status() { $CONTROL status; RETVAL=$?; }
-d_stop() { $CONTROL stop; RETVAL=$?; }
-
-condrestart() { if [ $DAEMON = "yes" ]; then d_condrestart; else c_restart; fi }
-restart() { if [ $DAEMON = "yes" ]; then d_restart; else c_restart; fi }
-start() { if [ $DAEMON = "yes" ]; then d_start; else c_start; fi }
-status() { if [ $DAEMON = "yes" ]; then d_status; else c_status; fi }
-stop() { if [ $DAEMON = "yes" ]; then d_stop; else c_stop; fi }
+ if [ -f $CRONLOCK ]; then
+ echo $"denyhosts cron service is enabled."
+ RETVAL=0
+ else
+ echo $"denyhosts cron service is disabled."
+ RETVAL=3
+ fi
+}
+
+# daemon service functions
+d_start() {
+ echo -n $"Starting denyhosts: "
+ daemon $DHOSTS $DOPTS
+ RETVAL=$?
+ echo
+ [ $RETVAL -eq 0 ] && touch $LOCKFILE
+}
+
+d_stop() {
+ echo -n $"Stopping denyhosts: "
+
+ # Some magic here since older versions stored the PID in the lockfile
+ # instead of using a separate PID file
+ # So if the lockfile has nonzero length, we use it as the PID file
+ if [ -n $LOCKFILE ]; then
+ killproc -p $LOCKFILE $DHOSTS
+ RETVAL=$?
+ else
+ killproc $DHOSTS
+ RETVAL=$?
+ fi
+ echo
+ [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
+}
+
+d_restart() {
+ d_stop
+ d_start
+}
+
+d_condrestart() {
+ [ -f $LOCKFILE ] && d_restart
+}
+
+d_status() {
+ status $DHOSTS
+ RETVAL=$?
+}
case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart|force-reload)
- restart
- ;;
- reload)
- ;;
- condrestart)
- condrestart
- ;;
- status)
- status
+ start)
+ if [ $DAEMON = "yes" ]; then
+ d_start;
+ else
+ c_start;
+ fi
+ ;;
+ stop)
+ if [ $DAEMON = "yes" ]; then
+ d_stop;
+ else
+ c_stop;
+ fi
+ ;;
+ restart|force-reload)
+ if [ $DAEMON = "yes" ]; then
+ d_restart;
+ else
+ c_restart;
+ fi
+ ;;
+ reload)
+ ;;
+ condrestart)
+ if [ $DAEMON = "yes" ]; then
+ d_condrestart;
+ else
+ c_restart;
+ fi
+ ;;
+ status)
+ if [ $DAEMON = "yes" ]; then
+ d_status;
+ else
+ c_status;
+ fi
;;
- *)
+ *)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
exit 1
esac
Index: denyhosts.spec
===================================================================
RCS file: /cvs/extras/rpms/denyhosts/devel/denyhosts.spec,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- denyhosts.spec 20 Aug 2007 19:33:27 -0000 1.44
+++ denyhosts.spec 24 Aug 2007 19:11:30 -0000 1.45
@@ -1,6 +1,6 @@
Name: denyhosts
Version: 2.6
-Release: 6%{?dist}
+Release: 7%{?dist}
Summary: A script to help thwart ssh server attacks
Group: Applications/System
@@ -151,6 +151,11 @@
%changelog
+* Thu Aug 23 2007 Jason L Tibbitts III <tibbs at math.uh.edu> - 2.6-7
+- Init file tweaks including patch from Jonathan Underwood
+ (bug 188536).
+- Attempt to add LSB-compliant comment block.
+
* Mon Aug 20 2007 Jason L Tibbitts III <tibbs at math.uh.edu> - 2.6-6
- Update license tag.
More information about the scm-commits
mailing list