changeset 17:8ebecad6530f stable-1-6

Add src/daemon* missing from source control. Switch to Mercurial source control.
author Carl Byington <carl@five-ten-sg.com>
date Fri, 21 Mar 2008 16:00:13 -0700
parents e57053cd7d20
children e1a028daceb9
files ChangeLog Makefile.am NEWS README configure.in sm-archive.rc sm-archive.rc.in sm-archive.spec.in src/context.cpp src/daemon.c src/daemon.h src/sm-archive.cpp src/test.cpp src/tokenizer.cpp xml/sm-archive.in
diffstat 15 files changed, 220 insertions(+), 141 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Mar 21 12:32:29 2008 +0000
+++ b/ChangeLog	Fri Mar 21 16:00:13 2008 -0700
@@ -1,4 +1,6 @@
-    $Id$
+1.6 2008-03-21
+    Add src/daemon* missing from source control.
+    Switch to Mercurial source control.
 
 1.5 2007-08-25
     GPL3. Add ability to remove original recipients when adding
--- a/Makefile.am	Fri Mar 21 12:32:29 2008 +0000
+++ b/Makefile.am	Fri Mar 21 16:00:13 2008 -0700
@@ -4,12 +4,12 @@
 hackdir = $(sysconfdir)/sm-archive
 hack_SCRIPTS = sm-archive
 hack_DATA = sm-archive.conf
+htmldir = ${datadir}/doc/@PACKAGE@-@VERSION@
+html_DATA = AUTHORS COPYING ChangeLog NEWS README
 CLEANFILES = sm-archive xml/sm-archive xml/Makefile
 EXTRA_DIST = sm-archive.rc $(hack_DATA) sm-archive.spec $(wildcard m4/*) $(wildcard xml/h*) $(wildcard xml/M*) $(wildcard xml/sm*)
 
-sm-archive: $(srcdir)/sm-archive.rc
-	   rm -f sm-archive
-	   echo "#!" $(BASH) >sm-archive
+sm-archive: sm-archive.rc
 	   cat $(srcdir)/sm-archive.rc     | \
 	       sed -e "s,SBINDIR,$(sbindir),g"  | \
 	       sed -e "s,SYSCONFDIR,$(sysconfdir),g" >>sm-archive
--- a/NEWS	Fri Mar 21 12:32:29 2008 +0000
+++ b/NEWS	Fri Mar 21 16:00:13 2008 -0700
@@ -1,5 +1,4 @@
-    $Id$
-
+1.6  2008-03-21 Add src/daemon* missing from source control.
 1.5  2007-08-24 GPL3. Can now remove original recipients.
 1.4  2007-02-07 more fixes for solaris
 1.3  2007-01-30 more fixes for solaris
--- a/README	Fri Mar 21 12:32:29 2008 +0000
+++ b/README	Fri Mar 21 16:00:13 2008 -0700
@@ -1,5 +1,3 @@
-    $Id$
-
 Try this:
 
     ./configure
@@ -10,3 +8,12 @@
 
 The last step sets up the linux runlevels for this package and starts
 the daemon.
+
+
+Starting with a mercurial working directory, try this:
+
+    make -f *cvs
+    ./configure >/dev/null
+    (cd xml; make; make distclean)
+    make distcheck
+
--- a/configure.in	Fri Mar 21 12:32:29 2008 +0000
+++ b/configure.in	Fri Mar 21 16:00:13 2008 -0700
@@ -1,5 +1,5 @@
 AC_PREREQ(2.59)
-AC_INIT(sm-archive,1.5,carl@five-ten-sg.com)
+AC_INIT(sm-archive,1.6,carl@five-ten-sg.com)
 AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADER([config.h])
 
@@ -7,6 +7,9 @@
 
 # Checks for programs.
 AC_PATH_PROGS(BASH, bash)
+if test "x$BASH" = x ; then
+    AC_MSG_ERROR([bash required for init script])
+fi
 AC_PROG_CXX
 AC_PROG_CC
 AC_PROG_CPP
@@ -17,7 +20,7 @@
 
 # Checks for header files.
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h sys/ioctl.h sys/socket.h syslog.h unistd.h])
+AC_CHECK_HEADERS([fcntl.h stdlib.h syslog.h unistd.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_HEADER_STDBOOL
@@ -26,7 +29,6 @@
 # Checks for library functions.
 AC_FUNC_FORK
 AC_FUNC_GETPGRP
-AC_HEADER_STDC
 AC_FUNC_STAT
 AC_CHECK_FUNCS([memset socket strchr strdup strncasecmp strtol daemon])
 
@@ -34,6 +36,7 @@
 ACX_PTHREAD
 
 AC_CONFIG_FILES([Makefile
+                 sm-archive.rc
                  sm-archive.spec
                  html/Makefile
                  info/Makefile
--- a/sm-archive.rc	Fri Mar 21 12:32:29 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-#  -- bash header installed by automake --
-#
-# sm-archive   This script controls the sm-archive milter daemon.
-#
-#
-# chkconfig: 2345 79 31
-# description: sm-archive allows adding recipients to mail passing thru this milter
-# processname: sm-archive
-# pidfile: /var/run/sm-archive.pid
-# Source function library.
-#
-. /etc/rc.d/init.d/functions
-
-# Source networking configuration.
-. /etc/sysconfig/network
-
-RETVAL=0
-# See how we were called.
-case "$1" in
-    start)
-        # Start daemons.
-        echo -n "Starting sm-archive-milter: "
-        if [ ! -f /var/lock/subsys/smarchive ]; then
-            cd SYSCONFDIR/sm-archive    # conf file is here
-            SBINDIR/smarchive -d 10 -p local:/var/run/sm-archive/sm-archive.sock
-            RETVAL=$?
-            pid=`pidof -s SBINDIR/smarchive`
-            if [ $pid ]
-            then
-                success "Starting sm-archive milter:"
-                touch /var/lock/subsys/smarchive
-                echo
-            else
-                failure "Starting sm-archive milter:"
-                echo
-            fi
-        else
-            echo -n "already running! "
-            failure "sm-archive milter already running!"
-            echo
-        fi
-
-        ;;
-    stop)
-        # Stop daemons.
-        echo -n "Shutting down sm-archive-milter: "
-        killproc smarchive
-        RETVAL=$?
-        echo
-        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/smarchive
-        ;;
-    restart|reload)
-        $0 stop
-        $0 start
-        RETVAL=$?
-        ;;
-    status)
-        status smarchive
-        RETVAL=$?
-        ;;
-    *)
-        echo "Usage: sm-archive {start|stop|restart|status}"
-        exit 1
-esac
-exit $RETVAL
-
-# $Id$
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sm-archive.rc.in	Fri Mar 21 16:00:13 2008 -0700
@@ -0,0 +1,65 @@
+#!@BASH@
+#
+# sm-archive   This script controls the sm-archive milter daemon.
+#
+#
+# chkconfig: 2345 79 31
+# description: sm-archive allows adding recipients to mail passing thru this milter
+# processname: sm-archive
+# pidfile: /var/run/sm-archive.pid
+# Source function library.
+#
+. /etc/rc.d/init.d/functions
+
+# Source networking configuration.
+. /etc/sysconfig/network
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+    start)
+        # Start daemons.
+        echo -n "Starting sm-archive-milter: "
+        if [ ! -f /var/lock/subsys/smarchive ]; then
+            cd SYSCONFDIR/sm-archive    # conf file is here
+            SBINDIR/smarchive -d 10 -p local:/var/run/sm-archive/sm-archive.sock
+            RETVAL=$?
+            pid=`pidof -s SBINDIR/smarchive`
+            if [ $pid ]
+            then
+                success "Starting sm-archive milter:"
+                touch /var/lock/subsys/smarchive
+                echo
+            else
+                failure "Starting sm-archive milter:"
+                echo
+            fi
+        else
+            echo -n "already running! "
+            failure "sm-archive milter already running!"
+            echo
+        fi
+
+        ;;
+    stop)
+        # Stop daemons.
+        echo -n "Shutting down sm-archive-milter: "
+        killproc smarchive
+        RETVAL=$?
+        echo
+        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/smarchive
+        ;;
+    restart|reload)
+        $0 stop
+        $0 start
+        RETVAL=$?
+        ;;
+    status)
+        status smarchive
+        RETVAL=$?
+        ;;
+    *)
+        echo "Usage: sm-archive {start|stop|restart|status}"
+        exit 1
+esac
+exit $RETVAL
--- a/sm-archive.spec.in	Fri Mar 21 12:32:29 2008 +0000
+++ b/sm-archive.spec.in	Fri Mar 21 16:00:13 2008 -0700
@@ -3,14 +3,12 @@
 Summary:            @PACKAGE@ Sendmail Milter
 Name:               @PACKAGE@
 Version:            @VERSION@
-Release:            %{?custom_release}%{!?custom_release:1}
-License:            GPL
+Release:            1%{?dist}
+License:            GPLv3+
 Group:              System Environment/Daemons
-Source:             http://www.five-ten-sg.com/@PACKAGE@/packages/@PACKAGE@-@VERSION@.tar.gz
-BuildRoot:          %{_tmppath}/%{name}-%{version}-buildroot
-URL:                http://www.five-ten-sg.com/@PACKAGE@/
-Vendor:             510 Software Group
-Packager:           510 Software Group
+Source:             http://www.five-ten-sg.com/%{name}/packages/%{name}-%{version}.tar.gz
+BuildRoot:          %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
+URL:                http://www.five-ten-sg.com/%{name}/
 AutoReqProv:        no
 
 Requires(pre):          /usr/sbin/useradd
@@ -25,80 +23,70 @@
 
 
 %description
-This milter adds recipient addresses to message passing thru it, based on a configuration file.
+This milter adds recipient addresses to messages passing thru it, based
+on a configuration file.
 
-The sm-archive milter reads a text configuration file (sm-archive.conf) on startup, and whenever the config file (or any of the referenced include files) is changed. The entire configuration file is case insensitive.
+The sm-archive milter reads a text configuration file
+(sm-archive.conf) on startup, and whenever the config file (or any of
+the referenced include files) is changed. The entire configuration
+file is case insensitive.
 
 
 %prep
-
-
-%setup
+%setup -q
 
 
 %build
-./configure --prefix=%{_prefix} \
-    --bindir=%{_bindir} --mandir=%{_mandir} \
-    --localstatedir=%{localstatedir} --libdir=%{_libdir} \
-    --datadir=%{_datadir} --includedir=%{_includedir} \
-    --sysconfdir=%{_sysconfdir}
-make
-
+%configure
+make %{?_smp_mflags}
 
 %install
-if [ "$RPM_BUILD_ROOT" = "/" -o -z "$RPM_BUILD_ROOT" ] ; then
-        echo sorry, you probably do not want me to delete the old buildroot at $RPM_BUILD_ROOT
-        exit 1
-fi
 rm -rf $RPM_BUILD_ROOT
-make prefix=$RPM_BUILD_ROOT%{_prefix} bindir=$RPM_BUILD_ROOT%{_bindir} \
-    mandir=$RPM_BUILD_ROOT%{_mandir} libdir=$RPM_BUILD_ROOT%{_libdir} \
-    localstatedir=$RPM_BUILD_ROOT%{localstatedir} \
-    datadir=$RPM_BUILD_ROOT%{_datadir} \
-    includedir=$RPM_BUILD_ROOT%{_includedir} \
-    sysconfdir=$RPM_BUILD_ROOT%{_sysconfdir} install
+make DESTDIR=$RPM_BUILD_ROOT install
 mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
-mkdir -p $RPM_BUILD_ROOT%{_datadir}/doc/@PACKAGE@-@VERSION@
 mv -f $RPM_BUILD_ROOT%{_sysconfdir}/sm-archive/sm-archive   $RPM_BUILD_ROOT/etc/rc.d/init.d
-mv AUTHORS COPYING ChangeLog NEWS README                    $RPM_BUILD_ROOT%{_datadir}/doc/@PACKAGE@-@VERSION@
-mkdir -p %{buildroot}/var/run/@PACKAGE@
+mkdir -p $RPM_BUILD_ROOT/var/run/%{name}
 
 
 %pre
-/usr/bin/getent passwd sm-archive >/dev/null ||
-  useradd -r -d /etc/sm-archive -M -c "sm-archive pseudo-user" -s /sbin/nologin sm-archive
+/usr/bin/getent passwd sm-archive >/dev/null || useradd -r -d /etc/sm-archive -M -c "sm-archive pseudo-user" -s /sbin/nologin sm-archive >/dev/null
 
 
 %post
-/sbin/chkconfig --add @PACKAGE@
-
-echo Remember to edit %{_sysconfdir}/@PACKAGE@/@PACKAGE@.conf and add the following line to your sendmail.mc:
+/sbin/chkconfig --add %{name}
+echo Remember to edit %{_sysconfdir}/%{name}/%{name}.conf and add the following line to your sendmail.mc:
 echo "INPUT_MAIL_FILTER(\`sm-archive', \`S=local:/var/run/sm-archive/sm-archive.sock, F=T, T=C:30s;S:5m;R:5m;E:5m')"
 echo
 
 
 %preun
-/sbin/service @PACKAGE@ stop || :
-/sbin/chkconfig --del @PACKAGE@
-userdel @PACKAGE@ || :
+[ $1 = 0 ] && /sbin/service %{name} stop || :
 
 
 %postun
+[ $1 = 0 ] && /sbin/chkconfig --del %{name}
+[ $1 = 0 ] && userdel %{name} || :
 
 
 %clean
+rm -rf $RPM_BUILD_ROOT
+
 
 %files
-%defattr(-,root,root)
+%defattr(-,root,root,-)
 %{_sbindir}/*
-%doc %{_mandir}/*
-%docdir %{_datadir}/doc/@PACKAGE@-@VERSION@
-%{_datadir}/doc/@PACKAGE@-@VERSION@
-%config(noreplace) %{_sysconfdir}/@PACKAGE@
-/etc/rc.d/init.d/@PACKAGE@
-%dir %attr(0750,@PACKAGE@,root) /var/run/@PACKAGE@
+%{_mandir}/man1/*
+%{_mandir}/man5/*
+%docdir %{_datadir}/doc/%{name}-%{version}
+%{_datadir}/doc/%{name}-%{version}
+%config(noreplace) %attr(0750,%{name},root) %{_sysconfdir}/%{name}
+/etc/rc.d/init.d/%{name}
+%dir %attr(0750,%{name},root) /var/run/%{name}
 
 
 %changelog
-* Fri Mar 10 2006 Carl Byington 1.0
+* Fri Mar 21 2008 Carl Byington <carl@five-ten-sg.com> - 1.6
+- changes for Fedora packaging guidelines
+
+* Fri Mar 10 2006 Carl Byington <carl@five-ten-sg.com> -1.0
 - use autoconf and http://www.fedora.us/docs/rpm-packaging-guidelines.html
--- a/src/context.cpp	Fri Mar 21 12:32:29 2008 +0000
+++ b/src/context.cpp	Fri Mar 21 16:00:13 2008 -0700
@@ -8,8 +8,6 @@
 
 #include "includes.h"
 
-static char* context_version="$Id$";
-
 char *token_envfrom;
 char *token_include;
 char *token_lbrace;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/daemon.c	Fri Mar 21 16:00:13 2008 -0700
@@ -0,0 +1,61 @@
+/*Add by Sergey Shapovalov */
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <errno.h>
+
+/* closeall() -- close all FDs >= a specified value */
+
+void closeall(int fd)
+{
+	int fdlimit = sysconf(_SC_OPEN_MAX);
+
+	while (fd < fdlimit)
+	  close(fd++);
+}
+
+/* daemon() - detach process from user and disappear into the background
+ * returns -1 on failure, but you can't do much except exit in that case
+ * since we may already have forked. This is based on the BSD version,
+ * so the caller is responsible for things like the umask, etc.
+ */
+
+/* believed to work on all Posix systems */
+
+int daemon(int nochdir, int noclose)
+{
+	switch (fork())
+	{
+		case 0:  break;
+		case -1: return -1;
+		default: _exit(0);			/* exit the original process */
+	}
+
+	if (setsid() < 0)				/* shoudn't fail */
+	  return -1;
+
+	/* dyke out this switch if you want to acquire a control tty in */
+	/* the future -- not normally advisable for daemons */
+
+	switch (fork())
+	{
+		case 0:  break;
+		case -1: return -1;
+		default: _exit(0);
+	}
+
+	if (!nochdir)
+	  chdir("/");
+
+	if (!noclose)
+	{
+		closeall(0);
+		open("/dev/null",O_RDWR);
+		dup(0); dup(0);
+	}
+
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/daemon.h	Fri Mar 21 16:00:13 2008 -0700
@@ -0,0 +1,23 @@
+/*
+ * File:   daemon.h
+ * Author: shasn
+ *
+ * Created on 22 Декабрь 2006 г., 15:28
+ */
+
+#ifndef _daemon_H
+#define _daemon_H
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+int daemon(int nochdir, int noclose);
+
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* _daemon_H */
+
--- a/src/sm-archive.cpp	Fri Mar 21 12:32:29 2008 +0000
+++ b/src/sm-archive.cpp	Fri Mar 21 16:00:13 2008 -0700
@@ -45,9 +45,6 @@
 	#include "daemon.c"
 #endif
 
-static const char* smarchive_version="$Id$";
-
-
 extern "C" {
 	#include <libmilter/mfapi.h>
 	sfsistat mlfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr);
--- a/src/test.cpp	Fri Mar 21 12:32:29 2008 +0000
+++ b/src/test.cpp	Fri Mar 21 16:00:13 2008 -0700
@@ -11,8 +11,6 @@
 #include <pthread.h>
 #include <set>
 
-static char* test_version="$Id$";
-
 using namespace std;
 
 struct ltstr {
--- a/src/tokenizer.cpp	Fri Mar 21 12:32:29 2008 +0000
+++ b/src/tokenizer.cpp	Fri Mar 21 16:00:13 2008 -0700
@@ -8,8 +8,6 @@
 
 #include "includes.h"
 
-static char* tokenizer_version="$Id$";
-
 const int maxlen = 1000;	// used for snprintf buffers
 
 enum state {s_init,
--- a/xml/sm-archive.in	Fri Mar 21 12:32:29 2008 +0000
+++ b/xml/sm-archive.in	Fri Mar 21 16:00:13 2008 -0700
@@ -8,11 +8,17 @@
         url="http://www.five-ten-sg.com/@PACKAGE@/">http://www.five-ten-sg.com/@PACKAGE@/</ulink>
         </para>
 
+        <para>A <ulink
+        url="http://www.selenic.com/mercurial/wiki/">Mercurial</ulink> source
+        code repository for this project is available at <ulink
+        url="http://hg.five-ten-sg.com/@PACKAGE@/">http://hg.five-ten-sg.com/@PACKAGE@/</ulink>.
+        </para>
+
     </partintro>
 
     <refentry id="@PACKAGE@.1">
         <refentryinfo>
-            <date>2007-08-25</date>
+            <date>2008-03-21</date>
         </refentryinfo>
 
         <refmeta>
@@ -161,9 +167,9 @@
         </refsect1>
 
         <refsect1 id='version.1'>
-            <title>CVS Version</title>
+            <title>Version</title>
             <para>
-                $Id$
+                @VERSION@
             </para>
         </refsect1>
     </refentry>
@@ -171,7 +177,7 @@
 
     <refentry id="@PACKAGE@.conf.5">
         <refentryinfo>
-            <date>2007-08-25</date>
+            <date>2008-03-21</date>
         </refentryinfo>
 
         <refmeta>
@@ -227,9 +233,9 @@
         </refsect1>
 
         <refsect1 id='version.5'>
-            <title>CVS Version</title>
+            <title>Version</title>
             <para>
-                $Id$
+                @VERSION@
             </para>
         </refsect1>