Skip to content

Commit

Permalink
1.0.32: modernize Makefile/spec file; add test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
dklayer committed Mar 15, 2012
1 parent 8036492 commit 4e0ca18
Show file tree
Hide file tree
Showing 8 changed files with 287 additions and 167 deletions.
10 changes: 10 additions & 0 deletions .gitignore
@@ -0,0 +1,10 @@
/Makefile.local
/fi-apps-common
/BUILD
/RPMS
/SRPMS
/*.gz
/aftpd.spec
/aftpd/
/autoloads.out
/build.tmp
146 changes: 146 additions & 0 deletions Makefile
@@ -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 changes: 26 additions & 17 deletions aftpd.spec → aftpd.spec.in
@@ -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

Expand All @@ -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 change: 1 addition & 0 deletions config.cl
Expand Up @@ -137,5 +137,6 @@
(".Z" . #("/bin/compress" "-c"))))

(defparameter *debug* nil)
(defparameter *test* nil)

;; End of configuration variables.
59 changes: 34 additions & 25 deletions ftpd.cl
@@ -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
Expand All @@ -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))))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand All @@ -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))

Expand Down Expand Up @@ -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
)))


0 comments on commit 4e0ca18

Please sign in to comment.