commit d2dba00e899acb952556f56202248830932cdd45 Author: Jay Larson Date: Wed May 30 09:28:11 2018 -0500 First check in diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..26c29e7 --- /dev/null +++ b/Makefile @@ -0,0 +1,165 @@ +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation here: +# (http://www.gnu.org/licenses/gpl-2.0.html) +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# Some, but not all of variables are required. The following list +# describes the required variables: +# +# * URL: The main website of the upstream project +# * REPO: The location of the package on the source pacakge +# server. This might be one of core, main, dev, or +# perhaps others. +# * BRIEF: Short description, should be 50 chars or less +# * SNAPVER: This is the package version. When a package is +# changed, but no changes are made to the source code +# this value should be increased. This would include +# things like usher being modified, changes to default +# configuration files, file permissions, etc. +# * ARCHIVE: The default commands that set this variable should +# work in most cases, but in some cases it may need +# to be modified. This variable should contain the +# path to the source of the package (./SRC/filename) +# * TYPE: This is probably not really needed due to the +# ability of gnu tar to figure it out on its own. +# Should probably be removed at some point. +# * SRCDIR: This is the name of the source directory after the +# package source is extracted. The default command +# should in most cases set this automatically. +# * PATCHDIR: This directory should be ./SRC/patches and is +# required, whether or not patches are used. +# * VERSION: This should be set automatically based on the +# version string in the source directory and SNAPVER. +# The default command here should work in many cases, +# but certain packages may need to use a different +# method. +# +# Variables that aren't required: +# +# * ARCH: This should be populated for packages which contain +# compiled binaries. If it is not populated the ARCH +# will be set to 'noarch'. +# * DEPENDS: If any other packages are required for this package +# to function then they need to be listed here, +# preferably in alphabetical order. +# * BUILDDEPS: Any package beyond packages from the core repo +# need to be listed here. The idea is that we +# can automate building and testing packages +# from clean core systems. The core repo is +# intended to include only the base minimum +# packages which provide a functional system. +# * SRCPKG: By default this is populated automatically with +# the name of the package (current directory). If +# the source package is used to generate multiple +# packages then this variable should contain the +# name of the git repo that tracks the source. +# * DESC: This is to be used to provide a longer description +# of the package. + +export ARCH = x86_64 +export DEPENDS = e2fsprogs,glibc,krb5,openssl +export BUILDDEPS = +export SRCPKG = cyrus-sasl +export URL = https://www.cyrusimap.org/sasl/ +REPO = main +BRIEF = Cyrus implementation of SASL +DESC = Cyrus SASL is an implementation of SASL that makes it easy for \ +application developers to integrate authentication mechanisms into their \ +application in a generic way. +SNAPVER = 0 + +ARCHIVE := $(PWD)/SRC/$(shell ls SRC|egrep '(bz2|gz|tar|xz)$$'|tail -1) +TYPE := $(shell file -ib $(ARCHIVE)|cut -d';' -f1|tr -d '\n') +SRCDIR := $(shell tar -tf $(ARCHIVE)|head -1|sed 's/\/.*//') +PATCHDIR := $(PWD)/SRC/patches +export VERSION := $(shell echo $(SRCDIR)|egrep -o '\-[0-9].*'| \ + sed 's/^-//')-$(SNAPVER) + +include /usr/share/snap/Makefile.snaplinux + +DEV := $(PWD)/$(PACKAGE)-dev +DEVROOT := $(DEV)/ROOT + +$(SRCDIR)/configure: $(ARCHIVE) + @if [ '$(TYPE)' == 'application/x-bzip2' ]; then \ + tar -jxf $(ARCHIVE); \ + elif [ '$(TYPE)' == 'application/x-gzip' ]; then \ + tar -zxf $(ARCHIVE); \ + elif [ '$(TYPE)' == 'application/x-tar' ]; then \ + tar -xf $(ARCHIVE); \ + elif [ '$(TYPE)' == 'application/x-xz' ]; then \ + tar -xf $(ARCHIVE); \ + else \ + echo 'Unable to determine archive type'; \ + exit 1; \ + fi + @touch $(SRCDIR)/configure + +$(SRCDIR)/config.log: $(SRCDIR)/configure + @cd $(SRCDIR) && \ + for patch in `find $(PATCHDIR) -name \*.patch|sort`; do \ + patch --verbose -Np1 -i $$patch; \ + done + @cd $(SRCDIR); \ + ./configure \ + --prefix=/usr \ + --enable-auth-sasldb \ + --with-dbpath=/var/lib/sasl/sasldb2 \ + --with-saslauthd=/var/run/saslauthd \ + --build=x86_64-snap-linux-gnu \ + --host=x86_64-snap-linux-gnu \ + --target=x86_64-snap-linux-gnu + +# binfile should be replaced with a file generated by the +# make process. It won't really break anything if not +# set to a valid file, but the source make process will +# be re-executed even if it isn't necessary + +$(SRCDIR)/lib/.libs/libsasl2.so: $(SRCDIR)/config.log + @cd $(SRCDIR) && make -j1 + +$(ROOT): $(SRCDIR)/lib/.libs/libsasl2.so + @if [ -d $(ROOT) ]; then \ + touch $(ROOT); \ + else \ + mkdir -v $(ROOT); \ + fi + + @cd $(SRCDIR) && make install DESTDIR=$(ROOT) && \ + install -v -d -m 0755 $(ROOT)/etc/init.d && \ + install -v -d -m 0755 $(ROOT)/usr/share/doc/cyrus-sasl && \ + install -v -d -m 0700 $(ROOT)/var/lib/sasl && \ + install -v -m 0755 $(SNAPDIR)/saslauthd.init \ + $(ROOT)/etc/init.d/saslauthd && \ + install -v -m 0644 doc/*.html $(ROOT)/usr/share/doc/cyrus-sasl && \ + install -v -m 0644 doc/*.txt $(ROOT)/usr/share/doc/cyrus-sasl && \ + install -v -m 0644 doc/*.fig $(ROOT)/usr/share/doc/cyrus-sasl && \ + install -v -m 0644 doc/ONEWS $(ROOT)/usr/share/doc/cyrus-sasl && \ + install -v -m 0644 doc/TODO $(ROOT)/usr/share/doc/cyrus-sasl && \ + install -v -d $(DEV)/SNAP && \ + install -v -d $(DEVROOT) && \ + for file in `find $(ROOT)| \ + egrep 'pkgconfig\/|\.a$$|\.h$$|\.la$$|\.pc$$'`; do \ + path=`dirname $$file|sed "s[$(ROOT)[$(DEVROOT)["`; \ + mkdir -p $$path; \ + mv $$file $$path; \ + done + find $(ROOT) -type d -empty -delete && \ + cd $(DEV) && make -f ../Makefile.$(PACKAGE)-dev && mv *.snap ../ + +test: $(ROOT) + @cd $(SRCDIR) && make check + +clean: + @rm -rvf $(ROOT) \ + $(DEV) \ + $(SNAPINFO) \ + $(MANIFEST) \ + $(FILES) \ + $(SRCDIR) + diff --git a/Makefile.cyrus-sasl-dev b/Makefile.cyrus-sasl-dev new file mode 100644 index 0000000..49bb67d --- /dev/null +++ b/Makefile.cyrus-sasl-dev @@ -0,0 +1,16 @@ +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation here: +# (http://www.gnu.org/licenses/gpl-2.0.html) +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +DEPENDS = cyrus-sasl +REPO = dev +BRIEF = Development files for cyrus-sasl +DESC = Development files for cyrus-sasl + +include /usr/share/snap/Makefile.snaplinux diff --git a/SNAP/README b/SNAP/README new file mode 100644 index 0000000..cb756b1 --- /dev/null +++ b/SNAP/README @@ -0,0 +1,5 @@ +This is the directory where the manifest, snapinfo, +and files.tar.gz files will be created. It is also +where the usher file should be placed if it is +required by the package. Any other files that need +to be included could also be placed here. diff --git a/SNAP/saslauthd.init b/SNAP/saslauthd.init new file mode 100755 index 0000000..86eeb08 --- /dev/null +++ b/SNAP/saslauthd.init @@ -0,0 +1,403 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: saslauthd +# Required-Start: $local_fs $remote_fs +# Required-Stop: $local_fs $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 1 +# Short-Description: saslauthd startup script +# Description: This script starts the saslauthd daemon. It is +# configured using the file /etc/default/saslauthd. +### END INIT INFO + +# Author: Fabian Fagerholm + +# Do NOT "set -e" + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +# Global variables +DAEMON=/usr/sbin/saslauthd +DEFAULT_FILES=`find /etc/default -regex '/etc/default/saslauthd[_a-zA-Z0-9\-]*$' -print | sort` + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# Function that starts all saslauthd instances +# Parameters: none +# Return value: none +do_startall() +{ + for instance in $DEFAULT_FILES + do + start_instance $instance + done +} + +# Function that stops all saslauthd instances +# Parameters: none +# Return value: none +do_stopall() +{ + for instance in $DEFAULT_FILES + do + stop_instance $instance + done +} + +# Function that sends a SIGHUP to all saslauthd instances +# Parameters: none +# Return value: none +do_reloadall() +{ + for instance in $DEFAULT_FILES + do + reload_instance $instance + done +} + +# Function that sends a SIG0 to all saslauthd instances +# Parameters: none +# Return value: none +do_checkall() +{ + for instance in $DEFAULT_FILES + do + check_instance $instance + done +} + +# Function that starts a single saslauthd instance +# Parameters: +# $1 = path of default file for this instance +# Return value: +# 0 on success (does not mean the instance started) +# 1 on failure +start_instance() +{ + # Load defaults file for this instance. + . $1 + + # If the daemon is not enabled, give the user a warning and stop. + if [ "$START" != "yes" ]; then + log_warning_msg "To enable $NAME, edit $1 and set START=yes" + return 0 + fi + + # If the short name of this instance is undefined, warn the user + # but choose a default name. + if [ -z "$NAME" ]; then + log_warning_msg "Short name (NAME) undefined in $1, using default" + NAME=default + fi + + log_daemon_msg "Starting $DESC" "$NAME" + + # Set OPTIONS to a default value, as noted in the defaults file + if [ -z "$OPTIONS" ]; then + log_warning_msg "Options (OPTIONS) undefined in $1, using default (-c -m /var/run/saslauthd)" + OPTIONS="-c -m /var/run/saslauthd" + fi + + # Determine run directory and pid file location by looking + # for an -m option. + RUN_DIR=`echo "$OPTIONS" | xargs -n 1 echo | sed -n '/^-m$/{n;p}'` + if [ -z "$RUN_DIR" ]; then + # No run directory defined in defaults file, fail. + log_failure_msg "No run directory defined for $NAME (did you forget to set OPTIONS=\"-c -m /var/run/saslauthd\" in the defaults file?), not starting" + return 1 + fi + PIDFILE=$RUN_DIR/saslauthd.pid + + # If no mechanisms are defined, fail. + if [ -z "$MECHANISMS" ]; then + log_failure_msg "No mechanisms defined in $1, not starting $NAME" + return 1 + fi + + # If there are mechanism options defined, prepare them for use with + # the -O flag. + if [ -n "$MECH_OPTIONS" ]; then + MECH_OPTIONS="-O $MECH_OPTIONS" + fi + + # If there is a threads option defined, prepare it for use with + # the -n flag. + if [ -n "$THREADS" ]; then + THREAD_OPTIONS="-n $THREADS" + fi + + # Construct argument string. + DAEMON_ARGS="-a $MECHANISMS $MECH_OPTIONS $OPTIONS $THREAD_OPTIONS" + + # If there is a statoverride for the run directory, then pull + # permission and ownership information from it and create the directory. + # Otherwise, we create the directory with default permissions and + # ownership (root:sasl, 710). + if dpkg-statoverride --list $RUN_DIR > /dev/null; then + createdir `dpkg-statoverride --list $RUN_DIR` + else + createdir root sasl 710 $RUN_DIR + fi + + # Start the daemon, phase 1: see if it is already running. + start-stop-daemon --start --quiet --pidfile $PIDFILE --name $NAME \ + --exec $DAEMON --test > /dev/null + if [ "$?" != "0" ]; then + log_progress_msg "(already running)" + log_end_msg 0 + return 0 + fi + + # Start the daemon, phase 2: it was not running, so actually start it now. + start-stop-daemon --start --quiet --pidfile $PIDFILE --name $NAME \ + --exec $DAEMON -- $DAEMON_ARGS + if [ "$?" -ne "0" ]; then + log_end_msg 1 + return 1 + fi + + # Started successfully. + log_end_msg 0 + return 0 +} + +# Function that stops a single saslauthd instance +# Parameters: +# $1 = path of default file for this instance +# Return value: +# 0 on success (daemon was stopped) +# 1 if the daemon was already stopped +# 2 if the daemon could not be stopped +stop_instance() +{ + # Load defaults file for this instance. + . $1 + + # If the short name of this instance is undefined, warn the user + # but choose a default name. + if [ -z "$NAME" ]; then + log_warning_msg "Short name (NAME) undefined in $1, using default" + NAME=default + fi + + # Set OPTIONS to a default value, as noted in the defaults file + if [ -z "$OPTIONS" ]; then + log_warning_msg "Options (OPTIONS) undefined in $1, using default (-c -m /var/run/saslauthd)" + OPTIONS="-c -m /var/run/saslauthd" + fi + + # Determine run directory and pid file location by looking + # for an -m option. + RUN_DIR=`echo "$OPTIONS" | xargs -n 1 echo | sed -n '/^-m$/{n;p}'` + if [ -z "$RUN_DIR" ]; then + # No run directory defined in defaults file, fail. + log_failure_msg "No run directory defined for $NAME (did you forget to set OPTIONS=\"-c -m /var/run/saslauthd\" in the defaults file?), not starting" + return 2 + fi + PIDFILE=$RUN_DIR/saslauthd.pid + + log_daemon_msg "Stopping $DESC" "$NAME" + + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \ + --pidfile $PIDFILE --exec $DAEMON + + if [ "$?" -eq "2" ]; then + # Failed to stop. + log_end_msg 1 + return 2 + fi + + if [ "$?" -eq "1" ]; then + # Already stopped. + log_progress_msg "(not running)" + fi + + # Many daemons don't delete their pidfiles when they exit. + rm -f $PIDFILE + + # Stopped successfully. + log_end_msg 0 + return $RETVAL +} + +# Function that sends a SIGHUP to a single saslauthd instance +# Parameters: +# $1 = path of default file for this instance +# Return value: +# 0 on success (does not mean the daemon was reloaded) +# other values on failure +reload_instance() +{ + # Load defaults file for this instance. + . $1 + + # If the short name of this instance is undefined, warn the user + # but choose a default name. + if [ -z "$NAME" ]; then + log_warning_msg "Short name (NAME) undefined in $1, using default" + NAME=default + fi + + # Set OPTIONS to a default value, as noted in the defaults file + if [ -z "$OPTIONS" ]; then + log_warning_msg "Options (OPTIONS) undefined in $1, using default (-c -m /var/run/saslauthd)" + OPTIONS="-c -m /var/run/saslauthd" + fi + + # Determine run directory and pid file location by looking + # for an -m option. + RUN_DIR=`echo "$OPTIONS" | xargs -n 1 echo | sed -n '/^-m$/{n;p}'` + if [ -z "$RUN_DIR" ]; then + # No run directory defined in defaults file, fail. + log_failure_msg "No run directory defined for $NAME (did you forget to set OPTIONS=\"-c -m /var/run/saslauthd\" in the defaults file?), not starting" + return 2 + fi + PIDFILE=$RUN_DIR/saslauthd.pid + + log_daemon_msg "Reloading $DESC" "$NAME" + + # Reload the daemon. First, see if it is already running. + start-stop-daemon --start --quiet --pidfile $PIDFILE \ + --exec $DAEMON --test > /dev/null + + if [ "$?" -eq "0" ]; then + # Not running, signal this and stop. + log_progress_msg "(not running)" + log_end_msg 0 + return 0 + fi + + start-stop-daemon --stop --signal 1 \ + --pidfile $PIDFILE --exec $DAEMON + log_end_msg $? +} + +# Function that sends a SIG0 to a single saslauthd instance +# Parameters: +# $1 = path of default file for this instance +# Return value: +# 0 on success (does not mean the daemon was reloaded) +# other values on failure +check_instance() +{ + # Load defaults file for this instance. + . $1 + + # If the short name of this instance is undefined, warn the user + # but choose a default name. + if [ -z "$NAME" ]; then + log_warning_msg "Short name (NAME) undefined in $1, using default" + NAME=default + fi + + # Determine run directory and pid file location by looking + # for an -m option. + RUN_DIR=`echo "$OPTIONS" | xargs -n 1 echo | sed -n '/^-m$/{n;p}'` + if [ -z "$RUN_DIR" ]; then + # No run directory defined in defaults file, fail. + log_failure_msg "No run directory defined for $NAME, cannot check" + return 2 + fi + PIDFILE=$RUN_DIR/saslauthd.pid + + log_daemon_msg "Checking $DESC" "$NAME" + + # Reload the daemon. First, see if it is already running. + start-stop-daemon --start --quiet --pidfile $PIDFILE \ + --exec $DAEMON --test > /dev/null + + if [ "$?" -eq "0" ]; then + # Not running, signal this and stop. + log_progress_msg "(not running)" + log_end_msg 3 + return 3 + fi + + log_progress_msg "(running)" + log_end_msg $? + return 0 +} + +# Function that creates a directory with the specified +# ownership and permissions +# Parameters: +# $1 = user +# $2 = group +# $3 = permissions (octal) +# $4 = path to directory +# Return value: none +createdir() +{ + # In the future, use -P/-Z to have SE Linux enhancement + install -d --group="$2" --mode="$3" --owner="$1" "$4" + [ -x /sbin/restorecon ] && /sbin/restorecon "$4" +} + +# Action switch +case "$1" in + start) + do_startall + ;; + stop) + do_stopall + ;; + reload|force-reload) + do_reloadall + ;; + restart) + do_stopall + do_startall + ;; + status) + do_checkall + exit $? + ;; + start-instance) + if [ -f /etc/default/$2 ]; then + start_instance /etc/default/$2 + else + log_failure_msg "Instance $2 does not exist." + fi + ;; + stop-instance) + if [ -f /etc/default/$2 ]; then + stop_instance /etc/default/$2 + else + log_failure_msg "Instance $2 does not exist." + fi + ;; + reload-instance|force-reload-instance) + if [ -f /etc/default/$2 ]; then + reload_instance /etc/default/$2 + else + log_failure_msg "Instance $2 does not exist." + fi + ;; + restart-instance) + if [ -f /etc/default/$2 ]; then + stop_instance /etc/default/$2 + start_instance /etc/default/$2 + else + log_failure_msg "Instance $2 does not exist." + fi + ;; + *) + SCRIPTNAME=$0 + echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 + echo " or {start-instance|stop-instance|restart-instance|" >&2 + echo " reload-instance|force-reload-instance} " \ + "" >&2 + exit 3 + ;; +esac + +: diff --git a/SRC/cyrus-sasl-2.1.25.tar.gz b/SRC/cyrus-sasl-2.1.25.tar.gz new file mode 100644 index 0000000..c3174fe Binary files /dev/null and b/SRC/cyrus-sasl-2.1.25.tar.gz differ diff --git a/SRC/cyrus-sasl-2.1.25.tar.gz.sig b/SRC/cyrus-sasl-2.1.25.tar.gz.sig new file mode 100644 index 0000000..680bdf6 Binary files /dev/null and b/SRC/cyrus-sasl-2.1.25.tar.gz.sig differ diff --git a/SRC/patches/README b/SRC/patches/README new file mode 100644 index 0000000..976577a --- /dev/null +++ b/SRC/patches/README @@ -0,0 +1,3 @@ +Place any patch files here and preface each with a +number indicating the order of execution. Patch +files are expected to use a .patch extension.