Преглед изворни кода

- add patch for creating pid file - better handle pid file - use fakesyslog for logging

Ralf S. Engelschall пре 24 година
родитељ
комит
f6d01b5e77
3 измењених фајлова са 104 додато и 53 уклоњено
  1. 25 0
      qpopper/qpopper.patch
  2. 70 50
      qpopper/qpopper.spec
  3. 9 3
      qpopper/rc.qpopper

+ 25 - 0
qpopper/qpopper.patch

@@ -0,0 +1,25 @@
+--- popper/main.c.orig	Wed Apr  4 02:23:26 2001
++++ popper/main.c	Fri Dec 28 11:18:39 2001
+@@ -472,6 +472,22 @@
+ 
+ #endif /* not _DEBUG */
+ 
++#ifdef PIDFILE
++    /*
++     * Write PID file. -- RSE
++     */
++    {
++        pid_t pid;
++        FILE *fp;
++
++        pid = getpid();
++        if ((fp = fopen(PIDFILE, "w")) == NULL)
++            err_dump(HERE, "Can't write pidfile '%s'", PIDFILE);
++        fprintf(fp, "%ld\n", (long)pid);
++        fclose(fp);
++    }
++#endif
++
+     /*
+      * Set up the socket on which we listen
+      */

+ 70 - 50
qpopper/qpopper.spec

@@ -33,11 +33,13 @@ Distribution: OpenPKG [REL]
 Group:        Mail
 License:      GPL
 Version:      4.0.3
-Release:      20011201
+Release:      20011228
 
 #   list of sources
 Source0:      ftp://ftp.qualcomm.com/eudora/servers/unix/popper/qpopper%{version}.tar.gz
-Source1:      rc.qpopper
+Source1:      fakesyslog.tar.gz
+Source2:      rc.qpopper
+Patch0:       qpopper.patch
 
 #   build information
 Prefix:       %{l_prefix}
@@ -51,47 +53,75 @@ AutoReqProv:  no
     Qualcom Popper is a POP3 Daemon.
 
 %prep
-    %setup0 -q -n qpopper%{version}
+    %setup0 -q -c -a 0
+    %setup1 -q -T -D -a 1
+    cd qpopper%{version}
+    %patch0 -p0
 
 %build
-    CC="%{l_cc}" \
-    CFLAGS="%{l_cflags -O}" \
-    ./configure \
-        --prefix=%{l_prefix} \
-        --sbindir=%{l_prefix}/sbin \
-        --disable-bulldb \
-        --enable-servermode \
-        --enable-standalone \
-        --enable-log-login \
-        --with-pam=qpopper \
-        --enable-home-dir-mail=.mail/inbox \
-        --with-log-facility=LOG_LOCAL5 \
-        --enable-nonauth-file=%{l_prefix}/etc/qpopper/users.deny \
-        --with-openssl=%{l_prefix} \
-        --disable-nls
-    %{l_rpmtool} subst \
-        's;\(MAIL_COMMAND[^"]*"\)[^"]*;\1%{l_prefix}/sbin/sendmail;' \
-        -- config.h
-    %{l_make} %{l_mflags -O}
+    #   build faked syslog(3) library
+    fakesyslogdir="`pwd`/fakesyslog"
+    ( cd fakesyslog
+      CC="%{l_cc}" \
+      CFLAGS="%{l_cflags -O}" \
+      ./configure \
+          --with-logfile=%{l_prefix}/var/qpopper/qpopper.log
+      %{l_make} %{l_mflags} 
+    )
+
+    #   build qpopper
+    ( cd qpopper%{version}
+      CC="%{l_cc}" \
+      CFLAGS="%{l_cflags -O}" \
+      OS_DEFS="-DPIDFILE=\\\"%{l_prefix}/var/qpopper/qpopper.pid\\\"" \
+      LIBS="-L$fakesyslogdir -lfakesyslog" \
+      ./configure \
+          --prefix=%{l_prefix} \
+          --sbindir=%{l_prefix}/sbin \
+          --disable-bulldb \
+          --enable-servermode \
+          --enable-standalone \
+          --enable-log-login \
+          --with-pam=qpopper \
+          --enable-home-dir-mail=.mail/inbox \
+          --with-log-facility=LOG_MAIL \
+          --enable-nonauth-file=%{l_prefix}/etc/qpopper/users.deny \
+          --with-openssl=%{l_prefix} \
+          --disable-nls
+      %{l_rpmtool} subst \
+          's;\(MAIL_COMMAND[^"]*"\)[^"]*;\1%{l_prefix}/sbin/sendmail;' \
+          -- config.h
+      %{l_make} %{l_mflags -O}
+    )
 
 %install
     rm -rf $RPM_BUILD_ROOT
+
+    #   create installation area
     %{l_shtool} mkdir -f -p -m 755 \
         $RPM_BUILD_ROOT%{l_prefix}/sbin \
         $RPM_BUILD_ROOT%{l_prefix}/man/man8 \
-        $RPM_BUILD_ROOT%{l_prefix}/etc/qpopper
-    %{l_shtool} install -c -m 644 \
-        samples/qpopper.config $RPM_BUILD_ROOT%{l_prefix}/etc/qpopper/
-    %{l_shtool} install -c -s -m 755 \
-        popper/popper $RPM_BUILD_ROOT%{l_prefix}/sbin/qpopper
-    %{l_shtool} install -c -m 644 \
-        man/popper.8 $RPM_BUILD_ROOT%{l_prefix}/man/man8/qpopper.8
+        $RPM_BUILD_ROOT%{l_prefix}/etc/qpopper \
+        $RPM_BUILD_ROOT%{l_prefix}/var/qpopper
+
+    #   install qpopper
+    ( cd qpopper%{version}
+      %{l_shtool} install -c -m 644 \
+          samples/qpopper.config $RPM_BUILD_ROOT%{l_prefix}/etc/qpopper/
+      %{l_shtool} install -c -s -m 755 \
+          popper/popper $RPM_BUILD_ROOT%{l_prefix}/sbin/qpopper
+      %{l_shtool} install -c -m 644 \
+          man/popper.8 $RPM_BUILD_ROOT%{l_prefix}/man/man8/qpopper.8
+    )
+
+    #   add more stuff
     %{l_shtool} install -c -m 644 \
         /dev/null $RPM_BUILD_ROOT%{l_prefix}/etc/qpopper/users.deny
     %{l_shtool} mkdir -f -p -m 755 \
         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
     %{l_shtool} install -c -m 755 -e "s;@l_prefix@;%{l_prefix};g" \
         %{SOURCE rc.qpopper} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
+
     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
 
 %files -f files
@@ -101,31 +131,21 @@ AutoReqProv:  no
 
 %post
     #   add PAM configuration entry
-    check=`grep '^#<OpenPKG pkg=qpopper>' /etc/pam.conf`
-    if [ ".$check" = . ]; then
-        ( echo "#<OpenPKG pkg=qpopper>"
-          case "%{l_target}" in
-              *-freebsd* ) 
-                  echo "qpopper auth required pam_unix.so try_first_pass"
-                  ;;
-              *-linux* ) 
-                  echo "qpopper auth required /lib/security/pam_unix.so shadow nodelay"
-                  ;;
-              *-solaris* ) 
-                  echo "qpopper auth required /usr/lib/security/pam_unix.so try_first_pass"
-                  ;;
+    if [ -f /etc/pam.conf ]; then
+        ( case "%{l_target}" in
+              *-freebsd* ) echo "qpopper auth required pam_unix.so try_first_pass"                   ;;
+              *-linux*   ) echo "qpopper auth required /lib/security/pam_unix.so shadow nodelay"     ;;
+              *-solaris* ) echo "qpopper auth required /usr/lib/security/pam_unix.so try_first_pass" ;;
           esac
-          echo "#</OpenPKG>"
-        ) >>/etc/pam.conf
+        ) |\
+        $RPM_INSTALL_PREFIX/sbin/rpmtool config \
+            -a -s -i "$RPM_INSTALL_PREFIX:qpopper" /etc/pam.conf
     fi
 
 %preun
     #   remove PAM configuration entry
-    check=`grep '^#<OpenPKG pkg=qpopper>' /etc/pam.conf`
-    if [ ".$check" != . ]; then
-        cp /etc/pam.conf /etc/pam.conf.tmp && \
-        sed -e '/^#<OpenPKG pkg=qpopper>/,/^#<\/OpenPKG>/d' \
-        </etc/pam.conf.tmp >/etc/pam.conf && \
-        rm -f /etc/pam.conf.tmp
+    if [ -f /etc/pam.conf ]; then
+        $RPM_INSTALL_PREFIX/sbin/rpmtool config \
+            -r -s -i "$RPM_INSTALL_PREFIX:qpopper" /etc/pam.conf
     fi
 

+ 9 - 3
qpopper/rc.qpopper

@@ -12,11 +12,17 @@
 
 %stop -p 200 -u root
     opServiceEnabled qpopper || exit 0
-    kill -TERM `cat @l_prefix@/var/qpopper/qpopper.pid`
+    if [ -f @l_prefix@/var/qpopper/qpopper.pid ]; then
+        kill -TERM `cat @l_prefix@/var/qpopper/qpopper.pid`
+        rm -f @l_prefix@/var/qpopper/qpopper.pid >/dev/null 2>&1 || true
+    fi
 
 %restart -u root
     opServiceEnabled qpopper || exit 0
-    kill -TERM `cat @l_prefix@/var/qpopper/qpopper.pid`
-    sleep 2
+    if [ -f @l_prefix@/var/qpopper/qpopper.pid ]; then
+        kill -TERM `cat @l_prefix@/var/qpopper/qpopper.pid`
+        rm -f @l_prefix@/var/qpopper/qpopper.pid >/dev/null 2>&1 || true
+        sleep 2
+    fi
     @l_prefix@/sbin/qpopper -f @l_prefix@/etc/qpopper/qpopper.config