Просмотр исходного кода

- added PID file patch - fixed completely useless rc script - tagged config files as such - minor cosmetics

Christoph Schug 23 лет назад
Родитель
Сommit
c9ac0e5a62
3 измененных файлов с 54 добавлено и 22 удалено
  1. 15 14
      tftp/rc.tftp
  2. 25 0
      tftp/tftp.patch
  3. 14 8
      tftp/tftp.spec

+ 15 - 14
tftp/rc.tftp

@@ -5,24 +5,25 @@
 
 %config
     tftp_enable="yes"
-    tftp_listen=""
+    tftp_listen="127.0.0.1:69"
     tftp_flags=""
     tftp_rootdir="@l_prefix@/pub"
 
-%start -p 100 -u root
-    if opServiceEnabled tftp; then
-        opts="-l -u @l_nusr@ -m @l_prefix@/etc/tftp/tftpd.remap"
-        if [ ".$tftp_listen" != . ]; then
-            opts="$opts -a $tftp_listen"
-        fi
-        if [ ".$tftp_flags" != . ]; then
-            opts="$opts $tftp_flags"
-        fi
-        @l_prefix@/sbin/tftpd $opts -s $tftp_root $tftp_root
+%start -p 100 -u @l_susr@
+    opServiceEnabled tftp || exit 0
+    opts="-l -u @l_nusr@ -m @l_prefix@/etc/tftp/tftpd.remap"
+    if [ ".$tftp_listen" != . ]; then
+        opts="$opts -a $tftp_listen"
     fi
+    if [ ".$tftp_flags" != . ]; then
+        opts="$opts $tftp_flags"
+    fi
+    @l_prefix@/sbin/tftpd $opts -s $tftp_rootdir
 
-%stop -p 200 -u root
-    if opServiceEnabled tftp; then
-        @l_prefix@/sbin/rndc stop
+%stop -p 200 -u @l_susr@
+    opServiceEnabled tftp || exit 0
+    if [ -f @l_prefix@/var/tftp/tftpd.pid ]; then
+        kill -TERM `cat @l_prefix@/var/tftp/tftpd.pid`
+        rm -f @l_prefix@/var/tftp/tftpd.pid >/dev/null 2>&1 || true
     fi
 

+ 25 - 0
tftp/tftp.patch

@@ -0,0 +1,25 @@
+--- tftpd/tftpd.c.orig	2003-01-31 03:22:33.000000000 +0100
++++ tftpd/tftpd.c	2003-04-11 09:19:35.000000000 +0200
+@@ -477,6 +477,22 @@
+       setsid();
+ #endif
+ #endif
++#ifdef PID_FILE
++  /* Write PID file */
++  {
++    mode_t old_umask;
++    pid_t  pid;
++    FILE   *fp;
++
++    old_umask = umask((mode_t) 0022);
++    pid = getpid();
++    if ((fp = fopen(PID_FILE, "w")) == NULL)
++      syslog(LOG_ERR, "cannot write PID file '%s'", PID_FILE);
++    fprintf(fp, "%ld\n", (long)pid);
++    fclose(fp);
++    umask(old_umask);
++  }
++#endif
+     }
+   } else {
+     /* 0 is our socket descriptor */

+ 14 - 8
tftp/tftp.spec

@@ -33,12 +33,13 @@ Distribution: OpenPKG [PLUS]
 Group:        Networtk
 License:      GPL
 Version:      0.33
-Release:      20030204
+Release:      20030411
 
 #   list of sources
 Source0:      http://www.kernel.org/pub/software/network/tftp/tftp-hpa-%{version}.tar.gz
 Source1:      tftpd.remap
 Source2:      rc.tftp
+Patch0:       tftp.patch
 
 #   build information
 Prefix:       %{l_prefix}
@@ -49,14 +50,16 @@ AutoReq:      no
 AutoReqProv:  no
 
 %description
-    This is a portable client and server for the Trivial File Transfer Protocol (TFTP).
+    This is a portable client and server for the Trivial File Transfer
+    Protocol (TFTP).
 
 %prep
     %setup -q -n tftp-hpa-%{version}
+    %patch -p0
 
 %build
     CC="%{l_cc}" \
-    CFLAGS="%{l_cflags -O}" \
+    CFLAGS="%{l_cflags -O} -DPID_FILE='\"%{l_prefix}/var/tftp/tftpd.pid\"'" \
     CPPFLAGS="%{l_cppflags}" \
     LDFLAGS="%{l_ldflags}" \
     ./configure \
@@ -69,24 +72,27 @@ AutoReqProv:  no
     rm -rf $RPM_BUILD_ROOT
     %{l_shtool} mkdir -f -p -m 755 \
         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
-        $RPM_BUILD_ROOT%{l_prefix}/etc/tftp
+        $RPM_BUILD_ROOT%{l_prefix}/etc/tftp \
+        $RPM_BUILD_ROOT%{l_prefix}/var/tftp
     %{l_make} %{l_mflags} install \
         INSTALL="%{l_shtool} install -c" \
         INSTALLROOT=$RPM_BUILD_ROOT
-    %{l_shtool} install -c -m 644 \
+    %{l_shtool} install -c -m 755 \
         -e 's;@l_prefix@;%{l_prefix};g' \
+        -e 's;@l_susr@;%{l_susr};g' \
         -e 's;@l_nusr@;%{l_nusr};g' \
         %{SOURCE rc.tftp} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
     %{l_shtool} install -c -m 644 \
         -e 's;@l_prefix@;%{l_prefix};g' \
         %{SOURCE tftpd.remap} $RPM_BUILD_ROOT%{l_prefix}/etc/tftp/
     mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/in.tftpd.8 \
-       $RPM_BUILD_ROOT%{l_prefix}/man/man8/tftpd.8
+        $RPM_BUILD_ROOT%{l_prefix}/man/man8/tftpd.8
     mv $RPM_BUILD_ROOT%{l_prefix}/sbin/in.tftpd \
-       $RPM_BUILD_ROOT%{l_prefix}/sbin/tftpd
+        $RPM_BUILD_ROOT%{l_prefix}/sbin/tftpd
     strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
     strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
-    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
+    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} \
+        '%config   %{l_prefix}/etc/tftp/*'
 
 %files -f files