Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

1.0.32: modernize Makefile/spec file; add test suite

  • Loading branch information...
commit 4e0ca18cac2f328230fbb8ae557812f91cdcede0 1 parent 8036492
dklayer dklayer authored
10 .gitignore
View
@@ -0,0 +1,10 @@
+/Makefile.local
+/fi-apps-common
+/BUILD
+/RPMS
+/SRPMS
+/*.gz
+/aftpd.spec
+/aftpd/
+/autoloads.out
+/build.tmp
146 Makefile
View
@@ -0,0 +1,146 @@
+# This software is Copyright (c) Franz Inc., 2001-2012.
+# Franz Inc. grants you the rights to distribute
+# and use this software as governed by the terms
+# of the Lisp Lesser GNU Public License
+# (http://opensource.franz.com/preamble.html),
+# known as the LLGPL.
+
+at_franz = $(shell if test -d /fi/cl/8.2/acl; then echo t; else echo nil; fi)
+
+Makefile_local = \
+ $(shell if test -f Makefile.local; then echo Makefile.local; fi)
+
+ifneq ($(Makefile_local),)
+include $(Makefile_local)
+endif
+
+platform ?= $(shell uname -s)
+ARCH ?= $(shell uname -i)
+
+ifeq ($(at_franz),t)
+LISPROOT ?= /fi/cl/8.2
+LISP ?= $(LISPROOT)/bin/$(shell if [ $(ARCH) = x86_64 ]; then echo mlisp-64; else echo mlisp; fi)
+endif
+
+LISP ?= mlisp
+
+ROOT ?= /
+prefix ?= $(ROOT)/usr
+libdir ?= $(prefix)/lib
+sbindir ?= $(prefix)/sbin
+
+version := $(shell grep defvar..ftpd-version ftpd.cl | sed -e 's,.*"\([0-9.]*\)".*,\1,')
+
+ifeq ($(FI_APPS_COMMON),t)
+release ?= $(shell . fi-apps-common/rpm-utils.sh && \
+ rpm_next_release_number \
+ /net/$(REPOHOST)$(REPOBASE)/$(ARCH)/aftpd-$(version)-*.$(ARCH).rpm)
+else
+release ?= 1
+endif
+
+installer-package := aftpd-$(version)-installer.tar.gz
+
+REDHAT73 := $(shell rpm -q redhat-release-7.3 >/dev/null && echo yes)
+SUSE92 := $(shell rpm -q suse-release-9.2 >/dev/null && echo yes)
+
+DOC_FILES = BUGS ChangeLog readme.txt binary-license.txt
+SOURCEFILES = $(DOC_FILES) \
+ config.cl ftpd.cl ipaddr.cl Makefile \
+ rfc0959.txt S99aftpd aftpd.init rc.aftpd.sh aftpd.logrotate
+
+ifeq ($(at_franz),t)
+ALL_EXTRA = repo_check
+endif
+
+all: $(ALL_EXTRA) clean aftpd/aftpd
+
+ifeq ($(at_franz),t)
+repo_check: FORCE
+ @if test ! -d fi-apps-common; then \
+ git clone git:/repo/git/fi-apps-common; \
+ fi
+endif
+
+
+aftpd/aftpd: FORCE
+ rm -f build.tmp
+ rm -fr aftpd
+ echo '(load "config.cl")' >> build.tmp
+ echo '(setq excl::*break-on-warnings* t)' >> build.tmp
+ echo '(compile-file "ftpd.cl")' >> build.tmp
+ echo '(load "ftpd.fasl")' >> build.tmp
+ echo '(build)' >> build.tmp
+ $(LISP) -batch -q -L build.tmp -kill
+
+install: FORCE
+ mkdir -p $(ROOT)/etc/init.d
+ cp -p aftpd.init $(ROOT)/etc/init.d/aftpd
+ rm -fr $(libdir)/aftpd.old
+ -mv $(libdir)/aftpd $(libdir)/aftpd.old
+ cp -r aftpd $(libdir)
+ rm -f $(sbindir)/aftpd
+ ln -s $(libdir)/aftpd/aftpd $(sbindir)/aftpd
+ mkdir -p $(ROOT)/etc
+ if [ ! -e $(ROOT)/etc/aftpd.cl ]; then \
+ cp config.cl $(ROOT)/etc/aftpd.cl; \
+ fi
+
+clean: FORCE
+ rm -fr aftpd *.fasl autoloads.out build.tmp
+# generated:
+ rm -f aftpd.spec
+ rm -fr BUILD BUILDROOT RPMS SRPMS SPECS
+
+tarball: all
+ tar zcf aftpd.tar.gz aftpd
+
+dist: tarball
+ tar zcf $(installer-package) \
+ aftp.tar.gz \
+ aftpd.init
+
+src-tarball: FORCE
+ rm -fr aftpd-$(version) aftpd-$(version).tar.gz
+ mkdir aftpd-$(version)
+ cp -p $(SOURCEFILES) aftpd-$(version)
+ if test -f Makefile.local; then \
+ cp Makefile.local aftpd-$(version); \
+ fi
+ tar zcf aftpd-$(version).tar.gz aftpd-$(version)
+ rm -fr aftpd-$(version)
+
+%.spec: %.spec.in ftpd.cl
+ sed -e "s/__VERSION__/$(version)/" < $< > $@
+
+rpm-setup: FORCE
+ mkdir -p BUILD RPMS SRPMS
+
+SIGN ?= --sign
+
+rpm: aftpd.spec src-tarball rpm-setup
+ rpmbuild $(SIGN) --define "_sourcedir $(CURDIR)" \
+ --define "_topdir $(CURDIR)" \
+ --define "_builddir $(CURDIR)/BUILD" \
+ --define "_rpmdir $(CURDIR)/RPMS" \
+ --define "_srcrpmdir $(CURDIR)/SRPMS" \
+ --define "release $(release)" \
+ --target $(ARCH) -ba aftpd.spec
+
+REMOVE_PREVIOUS_VERSIONS ?= no
+REPOHOST ?= fs1
+REPOBASE ?= /storage1/franz/common
+
+REPODIR=$(REPOBASE)/$(ARCH)
+
+install-repo:
+ifeq ($(REMOVE_PREVIOUS_VERSIONS),yes)
+ ssh root@$(REPOHOST) "rm -f $(REPODIR)/aftpd-*"
+endif
+ scp -p RPMS/$(ARCH)/aftpd-$(version)-*.rpm root@$(REPOHOST):$(REPODIR)
+ ssh root@$(REPOHOST) "createrepo -s sha -q --update $(REPODIR)"
+
+test: FORCE
+ ./test.sh
+
+FORCE:
43 aftpd.spec → aftpd.spec.in
View
@@ -1,48 +1,54 @@
Summary: Allegro FTP daemon
Name: aftpd
-Version: %{version}
+Version: __VERSION__
Release: %{release}
License: LLGPL
Group: System Environment/Daemons
-Provides: ftpserver
-#BuildRequires: allegrocl >= 7.0
+Prereq: chkconfig
+Prereq: service
Requires: logrotate
-Prereq: /sbin/chkconfig, /sbin/service
URL: http://opensource.franz.com/aftpd/
-Source0: %{name}-%{version}-src.tgz
+Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
+Provides: ftpserver
+
+# Don't attempt to make the debuginfo package
+%define debug_package %{nil}
%description
-Allegro FTPd is an FTP server for Linux/Solaris written in Allegro
+Allegro FTPd is an FTP server for Linux written in Allegro
Common Lisp. Because it is written in Common Lisp, one class of
security issues, related to buffer overflows, has been eliminated.
%prep
-%setup -q -n %{name}-%{version}-src
+%setup -q
%build
make
%install
-[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
-%makeinstall
+rm -rf $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT/etc/init.d
+mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
+mkdir -p $RPM_BUILD_ROOT/usr/{sbin,lib}
+mkdir -p $RPM_BUILD_ROOT/usr/share/doc/aftpd-__VERSION__
+make ROOT=$RPM_BUILD_ROOT install
# Need to re-make the aftpd symbolic link here so that rpm knows about it.
rm $RPM_BUILD_ROOT/%{_sbindir}/aftpd
ln -s %{_libdir}/aftpd/aftpd $RPM_BUILD_ROOT/%{_sbindir}/aftpd
-#
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
cp aftpd.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/aftpd
%clean
-[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
+rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
/etc/init.d/aftpd
-%{_sbindir}/aftpd
-%{_libdir}/aftpd/*
-%config(noreplace) %{_sysconfdir}/aftpd.cl
+/usr/lib/aftpd
+/usr/sbin/aftpd
+%config(noreplace) /etc/aftpd.cl
%config(noreplace) /etc/logrotate.d/aftpd
%doc BUGS ChangeLog readme.txt binary-license.txt
@@ -51,17 +57,20 @@ cp aftpd.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/aftpd
%preun
if [ $1 = 0 ]; then
- /sbin/service aftpd stop > /dev/null 2>&1
- /sbin/chkconfig --del aftpd
+ /sbin/service aftpd stop > /dev/null 2>&1
+ /sbin/chkconfig --del aftpd
fi
+exit 0
%postun
if [ "$1" != 0 ]; then
- /sbin/service aftpd condrestart 2>&1 > /dev/null
+ /sbin/service aftpd condrestart 2>&1 > /dev/null
fi
exit 0
%changelog
+* Thu Mar 15 2012 Kevin Layer <layer@franz.com>
+- Update Makefile and .spec file; use 9.0.beta
* Tue Feb 21 2006 Ahmon Dancy <dancy@dancy> - 1.0.28-1
- Initial build.
1  config.cl
View
@@ -137,5 +137,6 @@
(".Z" . #("/bin/compress" "-c"))))
(defparameter *debug* nil)
+(defparameter *test* nil)
;; End of configuration variables.
59 ftpd.cl
View
@@ -1,4 +1,4 @@
-;; This software is Copyright (c) Franz Inc., 2001-2009.
+;; This software is Copyright (c) Franz Inc., 2001-2012.
;; Franz Inc. grants you the rights to distribute
;; and use this software as governed by the terms
;; of the Lisp Lesser GNU Public License
@@ -7,7 +7,7 @@
(in-package :user)
-(defvar *ftpd-version* "1.0.31")
+(defvar *ftpd-version* "1.0.32")
(eval-when (compile)
(proclaim '(optimize (safety 1) (space 1) (speed 3) (debug 2))))
@@ -480,11 +480,11 @@
(ftp-log "Connection limit (~D) exceeded.~%" *maxusers*)
(return :quit))
- (if* (anonymous client)
- then
- (setf (anonymous client) pass)
- else
- (if (or (null pwent)
+ (if* *test*
+ thenret
+ elseif (anonymous client)
+ then (setf (anonymous client) pass)
+ else (if (or (null pwent)
(not (string= (pwent-passwd pwent)
(crypt pass (pwent-passwd pwent)))))
(return
@@ -517,24 +517,25 @@
:test #'string=)
(setf (restricted client) t))))
- ;; Set up
- (handler-case (setegid (pwent-gid pwent))
- (error (c)
- (ftp-log "Failed to setegid(~D): ~a~%" (pwent-gid pwent) c)
- (outline "421 Local configuration error.")
- (return :quit)))
+ (when (not *test*)
+ ;; Set up
+ (handler-case (setegid (pwent-gid pwent))
+ (error (c)
+ (ftp-log "Failed to setegid(~D): ~a~%" (pwent-gid pwent) c)
+ (outline "421 Local configuration error.")
+ (return :quit)))
- (handler-case (initgroups (user client) (pwent-gid pwent))
- (error (c)
- (ftp-log "Failed to initgroups (~a)~%" c)
- (outline "421 Local configuration error.")
- (return :quit)))
+ (handler-case (initgroups (user client) (pwent-gid pwent))
+ (error (c)
+ (ftp-log "Failed to initgroups (~a)~%" c)
+ (outline "421 Local configuration error.")
+ (return :quit)))
- (handler-case (seteuid (pwent-uid pwent))
- (error (c)
- (ftp-log "Failed to seteuid(~D): ~a~%" (pwent-uid pwent) c)
- (outline "421 Local configuration error.")
- (return :quit)))
+ (handler-case (seteuid (pwent-uid pwent))
+ (error (c)
+ (ftp-log "Failed to seteuid(~D): ~a~%" (pwent-uid pwent) c)
+ (outline "421 Local configuration error.")
+ (return :quit))))
(when (null (ftp-chdir (pwent-dir pwent)))
(ftp-log "Failed to chdir(~A)~%" (pwent-dir pwent))
@@ -1733,7 +1734,7 @@ Note: -p and -f override any setting in the config file.~%~%"
(defun main (&rest args)
(system:with-command-line-arguments
- ("df:p:" debug-mode configfile ftpport)
+ ("df:p:t" debug-mode configfile ftpport test-mode)
(rest :usage *usage*)
(declare (ignore image))
(when configfile
@@ -1744,6 +1745,12 @@ Note: -p and -f override any setting in the config file.~%~%"
(load-config-file)
(when debug-mode (setq *debug* t))
+ (when test-mode
+ (warn "~
+It is VERY DANGEROUS to run in test mode. ~
+Never run a server in test mode on a machine open to people you do not ~
+trust 100%! It gives them unfettered access to your files!")
+ (setq *debug* t *test* t))
(when ftpport (setq *ftpport* ftpport))
(when rest (usage))
@@ -1782,6 +1789,8 @@ Note: -p and -f override any setting in the config file.~%~%"
(setf files (append files '(:srecord :locale))) ;; add modules here
(setq files (cons "config.cl" files))
(compile-file-if-needed "ftpd.cl")
- (generate-executable "aftpd" files)))
+ (generate-executable "aftpd" files
+ :runtime :standard
+ )))
125 makefile
View
@@ -1,125 +0,0 @@
-# This software is Copyright (c) Franz Inc., 2001-2009.
-# Franz Inc. grants you the rights to distribute
-# and use this software as governed by the terms
-# of the Lisp Lesser GNU Public License
-# (http://opensource.franz.com/preamble.html),
-# known as the LLGPL.
-#
-# This makefile requires GNU make.
-
-platform = $(shell uname -s)
-
-preferred_lisp=/fi/cl/8.1/bin/mlisp
-alt_lisp0=/usr/local/acl81/mlisp
-alt_lisp1=/storage1/acl81/mlisp
-
-mlisp:=$(shell if test -x $(preferred_lisp); then \
- echo $(preferred_lisp); \
- elif test -x $(alt_lisp0); then \
- echo $(alt_lisp0); \
- elif test -x $(alt_lisp1); then \
- echo $(alt_lisp1); \
- else \
- echo mlisp; \
- fi)
-
-prefix ?= /usr/local
-sbindir ?= $(prefix)/sbin
-sysconfdir ?= /etc
-libdir ?= $(prefix)/lib
-DOCDIR = $(prefix)/share/doc/aftpd
-
-EXE = $(sbindir)/aftpd
-LIB = $(libdir)/aftpd
-
-version = $(shell grep defvar..ftpd-version ftpd.cl | sed -e 's,.*"\([0-9.]*\)".*,\1,')
-platform = $(shell uname -s)
-
-DOC_FILES = BUGS ChangeLog readme.txt binary-license.txt
-SOURCE_FILES = $(DOC_FILES) \
- config.cl ftpd.cl ipaddr.cl makefile \
- rfc0959.txt S99aftpd aftpd.init rc.aftpd.sh aftpd.logrotate
-
-default: FORCE
- rm -f build.tmp
- rm -fr aftpd
- echo '(load "config.cl")' >> build.tmp
- echo '(setq excl::*break-on-warnings* t)' >> build.tmp
- echo '(compile-file "ftpd.cl")' >> build.tmp
- echo '(load "ftpd.fasl")' >> build.tmp
- echo '(build)' >> build.tmp
- $(mlisp) -batch -q -L build.tmp -kill
-
-pre-dist: FORCE
- rm -fr aftpd-$(version)
- mkdir aftpd-$(version)
- cp -pr aftpd \
- makefile \
- S99aftpd \
- aftpd.init \
- rc.aftpd.sh \
- config.cl \
- $(DOC_FILES) \
- aftpd-$(version)
-
-linux solaris freebsd: clean default pre-dist
- gtar zcf aftpd-$@-$(version).tgz aftpd-$(version)
-
-src: FORCE
- mkdir aftpd-$(version)-src
- cp -p $(SOURCE_FILES) aftpd-$(version)-src
- gtar zcf aftpd-$(version)-src.tgz aftpd-$(version)-src
- rm -fr aftpd-$(version)-src
-
-clean: FORCE
- rm -fr aftpd *.fasl autoloads.out build.tmp
-
-install-common: FORCE
- rm -fr $(LIB) $(EXE)
- mkdir -p $(LIB) $(sbindir)
- cp -p aftpd/* $(LIB)
- ln -s $(LIB)/aftpd $(EXE)
- mkdir -p $(sysconfdir)
- if [ ! -f $(sysconfdir)/aftpd.cl ]; then cp config.cl $(sysconfdir)/aftpd.cl; fi
-
-install-doc: FORCE
- mkdir -p $(DOCDIR)
- cp -p $(DOC_FILES) $(DOCDIR)
-
-ifeq ($(platform),Linux)
-SUSE = $(shell if grep -qs SuSE /etc/issue; then echo yes; else echo no; fi)
-install: install-common
- mkdir -p $(RPM_BUILD_ROOT)/etc/init.d
-ifeq ($(SUSE),yes)
- cp -p aftpd.init.suse90 $(RPM_BUILD_ROOT)/etc/init.d/aftpd
-else
- cp -p aftpd.init $(RPM_BUILD_ROOT)/etc/init.d/aftpd
-endif
-endif
-
-ifeq ($(platform),SunOS)
-install: install-common
- cp -p S99aftpd /etc/rc2.d
-endif
-
-ifeq ($(platform),FreeBSD)
-install: install-common
- cp -p rc.aftpd.sh /usr/local/etc/rc.d/rc.aftpd.sh
-endif
-
-release ?= 1
-
-rpm: src
- mkdir -p BUILD RPMS SRPMS
- rpmbuild \
- --define "version $(version)" \
- --define "release $(release)" \
- --define "_sourcedir $(CURDIR)" \
- --define "_topdir $(CURDIR)" \
- --define "_builddir $(CURDIR)/BUILD" \
- --define "_rpmdir $(CURDIR)/RPMS" \
- --define "_srcrpmdir $(CURDIR)/SRPMS" \
- --sign \
- -bb aftpd.spec
-
-FORCE:
4 test.config
View
@@ -0,0 +1,4 @@
+
+(setq *pidsfile* "test/var/run/ftp.pids")
+(setq *logfile* "test/var/log/ftp")
+(setq *xferlog* "test/var/log/xferlog")
66 test.sh
View
@@ -0,0 +1,66 @@
+#! /bin/bash
+
+set -eu
+
+rm -fr test
+
+mkdir -p test/var/run
+mkdir -p test/var/log
+mkdir -p test/tmp1
+
+./aftpd/aftpd -t -d -f test.config -p 8888 &
+pid=$!
+trap "kill -HUP $pid" 0
+
+echo PID=$pid
+
+sleep 2
+
+curl="curl --user layer:xxx"
+url="ftp://quadra.franz.com:8888/"
+
+########################### test 1: copy to
+
+files=`echo /fi/import/unix/*.gz`
+for file in $files; do
+ $curl -T $file $url/acl/layer/fi-rpm-build/aftpd.i386/test/tmp1/
+done
+for file in test/tmp1/*.gz; do
+ echo Checking $file...
+ if ! cmp -s $file /fi/import/unix/$(basename $file); then
+ echo ERROR: bad: test/tmp/$(basename $file)
+ exit 1
+ fi
+done
+ls="/bin/ls -1"
+if test $($ls $files | wc -l) != $($ls test/tmp1/*.gz | wc -l); then
+ echo ERROR: counts are off from /fi/import/unix and test/tmp1/
+ exit 1
+fi
+
+########################### test 2: copy from
+
+mkdir test/tmp2
+
+files="$(echo $PWD/test/tmp1/*.gz)"
+for file in $files; do
+ $curl -o test/tmp2/$(basename $file) $url$file
+done
+for file in test/tmp2/*.gz; do
+ echo Checking $file...
+ if ! cmp -s $file test/tmp2/$(basename $file); then
+ echo ERROR: bad: test/tmp2/$(basename $file)
+ exit 1
+ fi
+done
+if test $($ls $files | wc -l) != $($ls test/tmp2/*.gz | wc -l); then
+ echo ERROR: counts are off from test/tmp1/ and test/tmp2/
+ exit 1
+fi
+
+###########################
+
+echo TESTS COMPLETED SUCCESSFULLY
+
+set -x
+rm -fr test
Please sign in to comment.
Something went wrong with that request. Please try again.