Jelajahi Sumber

Initial packaging of TFTP server & client (still has a few problems)

Ralf S. Engelschall 23 tahun lalu
induk
melakukan
8eb4805625
3 mengubah file dengan 152 tambahan dan 0 penghapusan
  1. 28 0
      tftp/rc.tftp
  2. 91 0
      tftp/tftp.spec
  3. 33 0
      tftp/tftpd.remap

+ 28 - 0
tftp/rc.tftp

@@ -0,0 +1,28 @@
+#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
+##
+##  rc.tftp-hpa -- Run-Commands for TFTP Daemon
+##
+
+%config
+    tftp_enable="yes"
+    tftp_listen=""
+    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
+    fi
+
+%stop -p 200 -u root
+    if opServiceEnabled tftp; then
+        @l_prefix@/sbin/rndc stop
+    fi
+

+ 91 - 0
tftp/tftp.spec

@@ -0,0 +1,91 @@
+##
+##  tftp.spec -- OpenPKG RPM Specification
+##  Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
+##  Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
+##  Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.com>
+##
+##  Permission to use, copy, modify, and distribute this software for
+##  any purpose with or without fee is hereby granted, provided that
+##  the above copyright notice and this permission notice appear in all
+##  copies.
+##
+##  THIS SOFTWARE IS PROVIDED AS IS'' AND ANY EXPRESSED OR IMPLIED
+##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+##  SUCH DAMAGE.
+##
+
+#   package information
+Name:         tftp
+Summary:      TFTP Client and Server
+URL:          http://www.kernel.org/pub/software/network/tftp/
+Vendor:       John Doe
+Packager:     The OpenPKG Project
+Distribution: OpenPKG [EVAL]
+Group:        Networtk
+License:      GPL
+Version:      0.31
+Release:      20021024
+
+#   list of sources
+Source0:      http://www.kernel.org/pub/software/network/tftp/tftp-hpa-%{version}.tar.gz
+
+#   build information
+Prefix:       %{l_prefix}
+BuildRoot:    %{l_buildroot}
+BuildPreReq:  OpenPKG, openpkg >= 20020206, make
+PreReq:       OpenPKG, openpkg >= 20020206
+AutoReq:      no
+AutoReqProv:  no
+
+%description
+    This is a portable client and server for the Trivial File Transfer Protocol (TFTP).
+
+%prep
+    %setup -q -n tftp-hpa-%{version}
+
+%build
+    CC="%{l_cc}" \
+    CFLAGS="%{l_cflags -O}" \
+    CPPFLAGS="%{l_cppflags}" \
+    LDFLAGS="%{l_ldflags}" \
+    ./configure \
+        --prefix=%{l_prefix} \
+        --without-tcpwrappers \
+        --without-readline
+    %{l_make} %{l_mflags -O}
+
+%install
+    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
+    %{l_make} %{l_mflags} install INSTALLROOT=$RPM_BUILD_ROOT
+    %{l_shtool} install -c -m 644 \
+        -e 's;@l_prefix@;%{l_prefix};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
+    mv $RPM_BUILD_ROOT%{l_prefix}/sbin/in.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}
+
+%files -f files
+
+%clean
+    rm -rf $RPM_BUILD_ROOT
+

+ 33 - 0
tftp/tftpd.remap

@@ -0,0 +1,33 @@
+#
+# tftpd.remap -- TFTP Daemon Path Remapping
+#
+# This file has three fields: operation, regex, remapping
+#
+# The operation is a combination of the following letters:
+#
+# r - rewrite the matched string with the remapping pattern
+# i - case-insensitive matching
+# g - repeat until no match (used with "r")
+# e - exit (with success) if we match this pattern, do not process
+#     subsequent rules
+# s - start over from the first rule if we match this pattern
+# a - abort (refuse the request) if we match this rule
+# G - this rule applies to TFTP GET requests only
+# P - this rule applies to TFTP PUT requests only
+#
+# The regex is a regular expression in the style of egrep(1).
+#
+# The remapping is a pattern, all characters are verbatim except \
+# \0 copies the full string that matched the regex
+# \1..\9 copies the 9 first (..) expressions in the regex
+# \\ is an escaped \
+#
+# "#" begins a comment, unless \-escaped
+#
+ri	^[a-z]:					# Remove "drive letters"
+rg	\\		/			# Convert backslashes to slashes
+rg	\#		@			# Convert hash marks to @ signs
+rg	/../		/..no../		# Convert /../ to /..no../
+e	^incoming/				# These are always ok
+r	^[^/]		@l_prefix@/pub/\0	# Convert non-absolute files
+a	^\.					# Reject requests for hidden files