From 8234484dba123ad8001657def8fb57133f9610bf Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Thu, 23 Apr 2020 21:14:49 +0300 Subject: Rewrite the testsuite. Use gpg2 to create the keys, and sign files as necessary. * NEWS: Update. * doc/wydawca.texi: Update. * configure.ac: Detect the presence of GPG version 2. * src/cmdline.opt (--single-process): Remove. * src/config.c: Remove the "single-process" statement. * src/triplet.c (triplet_enqueue): Fix eventual NULL dereference. (wy_triplet_wait): Update the WY_STAT_INCOMPLETE_TRIPLETS counter. * src/wydawca.c (single_process_option): Remove global. * src/wydawca.h (single_process): Remove global. * tests/.gitignore: Update. * tests/Makefile.am: Update. * tests/atlocal.in: Rewrite. * tests/chargen.c: New auxiliary tool * tests/dist/file: Remove. * tests/dist/file.directive.asc: Remove. * tests/dist/file.sig: Remove. * tests/dist/file12f.directive.asc: Remove. * tests/dist/file12t.directive.asc: Reemove. * tests/dist/rmsymlink.directive.asc: Remove. * tests/dist/symlink.directive.asc: Remove. * tests/etc/notify.cfin: Rename to tests/etc/notify.cf * tests/etc/Makefile.am: Update. * tests/etc/dbgen.sh: New file. * tests/etc/keygen.sh: New file. * tests/etc/project: New file. * tests/etc/pubring.asc: Remove. * tests/etc/secring.asc: Remove. * tests/etc/wydawca.cfin: Remove. * tests/*.at: Rewrite. --- NEWS | 13 ++- configure.ac | 24 +++- doc/wydawca.texi | 58 ++++------ src/cmdline.opt | 12 +- src/config.c | 7 +- src/triplet.c | 10 +- src/wydawca.c | 4 - src/wydawca.h | 1 - tests/.gitignore | 1 + tests/Makefile.am | 32 +++--- tests/atlocal.in | 150 +++++++++++++++++------- tests/chargen.c | 79 +++++++++++++ tests/check-fail.at | 41 ++++--- tests/check-notify.at | 107 +++++++++-------- tests/check-ok.at | 34 +++--- tests/dist/file | 1 - tests/dist/file.directive.asc | 14 --- tests/dist/file.sig | 7 -- tests/dist/file12f.directive.asc | 15 --- tests/dist/file12t.directive.asc | 15 --- tests/dist/rmsymlink.directive.asc | 14 --- tests/dist/symlink.directive.asc | 14 --- tests/dry_run00.at | 52 +++++++++ tests/dry_run01.at | 83 +++++++++++++ tests/dry_run02.at | 51 ++++++++ tests/etc/.gitignore | 3 +- tests/etc/Makefile.am | 30 +++-- tests/etc/dbgen.sh | 93 +++++++++++++++ tests/etc/keygen.sh | 59 ++++++++++ tests/etc/notify.cf | 221 +++++++++++++++++++++++++++++++++++ tests/etc/notify.cfin | 230 ------------------------------------- tests/etc/project | 4 + tests/etc/pubring.asc | 30 ----- tests/etc/secring.asc | 31 ----- tests/etc/wydawca.cfin | 98 ---------------- tests/inotify-ok.at | 39 ++++--- tests/inotify-rmsymlink.at | 56 +++++---- tests/inotify-symlink.at | 59 +++++----- tests/inotify-unatt00.at | 39 ++++--- tests/inotify-unatt01.at | 43 ++++--- tests/mailnotify.at | 92 +++++++++++++++ tests/mailstats.at | 111 ++++++++++++------ tests/notify-upl.at | 95 --------------- tests/rmsymlink00.at | 46 +++++--- tests/symlink00.at | 47 ++++---- tests/symlink01.at | 55 +++++---- tests/testsuite.at | 59 +++++++--- tests/unp-idle.at | 29 ++++- tests/unp00.at | 70 +++++++---- tests/unp01.at | 66 +++++------ tests/unp02.at | 73 ++++++++++++ tests/upl11.at | 57 --------- tests/upl12f.at | 61 ---------- tests/upl12t.at | 58 ---------- tests/upload-dry.at | 69 ----------- tests/upload.at | 50 -------- tests/upload00.at | 54 +++++++++ tests/upload01.at | 91 +++++++++++++++ 58 files changed, 1693 insertions(+), 1364 deletions(-) create mode 100644 tests/chargen.c delete mode 100644 tests/dist/file delete mode 100644 tests/dist/file.directive.asc delete mode 100644 tests/dist/file.sig delete mode 100644 tests/dist/file12f.directive.asc delete mode 100644 tests/dist/file12t.directive.asc delete mode 100644 tests/dist/rmsymlink.directive.asc delete mode 100644 tests/dist/symlink.directive.asc create mode 100644 tests/dry_run00.at create mode 100644 tests/dry_run01.at create mode 100644 tests/dry_run02.at create mode 100644 tests/etc/dbgen.sh create mode 100644 tests/etc/keygen.sh create mode 100644 tests/etc/notify.cf delete mode 100644 tests/etc/notify.cfin create mode 100644 tests/etc/project delete mode 100644 tests/etc/pubring.asc delete mode 100644 tests/etc/secring.asc delete mode 100644 tests/etc/wydawca.cfin create mode 100644 tests/mailnotify.at delete mode 100644 tests/notify-upl.at create mode 100644 tests/unp02.at delete mode 100644 tests/upl11.at delete mode 100644 tests/upl12f.at delete mode 100644 tests/upl12t.at delete mode 100644 tests/upload-dry.at delete mode 100644 tests/upload.at create mode 100644 tests/upload00.at create mode 100644 tests/upload01.at diff --git a/NEWS b/NEWS index f37bfd6..eaa80ba 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -Wydawca NEWS -- history of user-visible changes. 2020-04-20 +Wydawca NEWS -- history of user-visible changes. 2020-04-23 See the end of file for copying conditions. Please send Wydawca bug reports to . @@ -46,12 +46,23 @@ spool simultaneously lock files were used. This version does not allow for such usage. Only one copy of wydawca can be running. Therefore spool locking has been discontinued. +* Command line usage + +** The --single-process option removed + +** The -d (--debug) option requires argument + +The argument is a decimal number specifying the desired debug level. +Thus, instead of -ddd, use -d3 (or --debug=3). + * Configuration changes ** The wakeup-interval statement removed ** The locking statement removed +** The single-process statement removed + ** max-connections statement This new statement configures the maximum number of upload diff --git a/configure.ac b/configure.ac index 0e1366b..865d206 100644 --- a/configure.ac +++ b/configure.ac @@ -110,7 +110,7 @@ AH_BOTTOM( #endif ]) LDADD=$saved_LDADD - + # ********************** # TCP wrappers # ********************** @@ -176,10 +176,24 @@ AM_MISSING_PROG([AUTOM4TE], [autom4te]) # Initialize documentation helpers. IMPRIMATUR_INIT(, [frenchspacing]) -AC_PATH_PROG(GPG, gpg, '') -if test -n "$GPG"; then - AC_SUBST(WYDAWCA_GPGFILES, '$(GPGFILES)') -fi +# ********************** +# GPG v2 (for the testsuite) +# ********************** +AC_ARG_VAR([GPG],[Name of the gpg version 2 binary]) +AC_MSG_CHECKING([for the GPG v2 binary]) +uGPG=$GPG +unset GPG +for prog in $uGPG gpg2 gpg +do + ver=$($prog --version 2>/dev/null | head -n 1) + case $ver in + "gpg (GnuPG) 2."*) + GPG=$prog + break;; + esac +done +AC_MSG_RESULT([${GPG:-none}${GPG:+, $ver}]) +AM_CONDITIONAL([COND_GPG2],[test -n "$GPG"]) AC_CONFIG_FILES([Makefile doc/Makefile diff --git a/doc/wydawca.texi b/doc/wydawca.texi index 64a6e36..b05e8b0 100644 --- a/doc/wydawca.texi +++ b/doc/wydawca.texi @@ -444,16 +444,13 @@ $ wydawca --spool=ftp --spool=test --source=/home/ftp/test-upload @anchor{debug} @xopindex{debug, described} @sopindex{d, described} - The @option{--debug} (@option{-d}) option tells the program to increase its -debugging level by 1. The @dfn{debugging level} determines amount -of information the program reports when it runs. Default level is 0, -which means that only errors and other critical conditions are -reported. Raising it may be necessary when debugging new configurations. Each -@option{-d} option raises the level by one, so you can say -@command{wydawca -dd} to obtain level 2, for example. The maximum -debugging level (currently it is 4) prints an impractically big -amount of information, and is useful mainly for @command{wydawca} -developers. + The @option{--debug} (@option{-d}) option tells the program to set its +debugging level to the given integer value. @dfn{Debugging level} +determines the amount of information the program reports when it +runs. Default level is 0, which means that only errors and other +critical conditions are reported. Raising it may be necessary when +debugging new configurations. @samp{Wydawca} version @value{version} +implements 4 distinct debuggin levels. @anchor{dry-run} @xopindex{dry-run, described} @@ -463,9 +460,11 @@ developers. modifications to the disk contents, and to print a verbose description of any actions it would have taken. It sets the debugging level to 1 and directs the diagnostics output to the standard error, as if -@option{--debug --stderr} options were given. You can raise -debugging level further by supplying additional @option{--debug} -options. The @option{--dry-run} option is useful when testing new +@option{--debug=1 --stderr} options were given. You can further +control the debugging level by supplying additional @option{--debug} +options @emph{after} the @option{--dry-run} option. + +The @option{--dry-run} option is useful when testing new configurations, for example: @smallexample @@ -498,10 +497,11 @@ reports them on its error output and exits with a non-zero status. other inconsistencies. If no errors were detected, the program exits with code 0. Otherwise, the exit code is 78. - Using this option together with @option{-d} (@option{--debug}), + Using this option together with @option{-d1} (@option{--debug=1}), causes @command{wydawca} to produce a dump of the configuration parse -tree. Using the @option{-d} option twice prefixes each statement in -the dump with the file location where it appeared. +tree. Setting a higher debugging level (e.g. @option{-d2} option) will +additionally prefix each statement in the dump with the file location +where it appeared. @sopindex{E, introduced} @xopindex{no-preprocessor, introduced} @@ -980,15 +980,6 @@ If @var{bool} is @samp{yes}, run in foreground. @xref{invocation, foreground}. @end deffn -@deffn {Config} single-process bool -Configure single process mode. Normally @command{wydawca} -spawns subprocesses for handling incoming connections and spool jobs. -This is disabled if @var{bool} is @samp{yes} (a so-called -@dfn{single-processs mode}). This mode is designed for debugging -purposes. Do not use it in production environments, because it -severely impairs performance. -@end deffn - @deffn {Config} umask value Set the default umask. The @var{value} argument must be an octal number. @end deffn @@ -3328,10 +3319,6 @@ daemon @var{arg:@i{boolean}}; # @xref{general, foreground}. foreground @var{arg:@i{boolean}}; -# @r{Do not spawn subprocesses.} -# @xref{general, single-process}. -single-process @var{arg:@i{boolean}}; - # @r{Set pid file name.} # @xref{general, pidfile}. pidfile @var{file:@i{string}}; @@ -3655,9 +3642,9 @@ Run in daemon mode. @xref{starting,, daemon}. @opsummary{debug} @sopindex{d, summary} -@item --debug -@itemx -d -Increase debugging level by 1. +@item --debug=@var{n} +@itemx -d @var{n} +Set the debugging level to @var{n}. @xref{debug, The @option{--debug} option}. @@ -3683,7 +3670,7 @@ Dump lexical analyzer traces. This is useful for debugging @item --dry-run @itemx -n @dfn{Dry-run mode}: do nothing, print almost everything. This option -implies @option{--debug --stderr}. +implies @option{--debug=1 --stderr}. @xref{dry-run, The dry-run mode}. @@ -3741,11 +3728,6 @@ Disable preprocessor. @pxref{Preprocessor}. @item --preprocessor=@var{command} Use @var{command} instead of the default preprocessor. @pxref{Preprocessor}. -@opsummary{single-process} -@item --single-process -Serialize job invocations by not forking subprocesses for each job. -@emph{Do not use this option in production environment}. - @opsummary{source} @sopindex{s, summary} @item --source=@var{name} diff --git a/src/cmdline.opt b/src/cmdline.opt index fae3cb1..a23335d 100644 --- a/src/cmdline.opt +++ b/src/cmdline.opt @@ -96,12 +96,6 @@ BEGIN foreground_option = 1; END -OPTION(single-process,,, - []) -BEGIN - single_process_option = 1; -END - OPTION(config-file,c,FILE, []) BEGIN @@ -180,10 +174,10 @@ END GROUP(Debugging) -OPTION(debug,d,, - []) +OPTION(debug,d,[], + []) BEGIN - wy_debug_level++; + wy_debug_level = atoi(optarg); END OPTION(dump-grammar-trace,,, diff --git a/src/config.c b/src/config.c index 9d78ed3..6b99801 100644 --- a/src/config.c +++ b/src/config.c @@ -1390,9 +1390,6 @@ static struct grecs_keyword wydawca_kw[] = { { "foreground", NULL, N_("Start in foreground even in daemon mode"), grecs_type_bool, GRECS_DFLT, &foreground }, - { "single-process", NULL, - N_("Do not spawn subprocesses"), - grecs_type_bool, GRECS_DFLT, &single_process }, { "pidfile", N_("file"), N_("Set pid file name"), grecs_type_string, GRECS_CONST, &pidfile}, @@ -1727,7 +1724,7 @@ config_finish(struct grecs_node *tree) if (file_sweep_time <= 0) { file_sweep_time = DEFAULT_FILE_SWEEP_TIME; wy_log(LOG_NOTICE, - _("file-sweep-time too low; reverting to the default %ds"), - file_sweep_time); + _("file-sweep-time too low; reverting to the default %lus"), + (unsigned long)file_sweep_time); } } diff --git a/src/triplet.c b/src/triplet.c index bde3c14..980c906 100644 --- a/src/triplet.c +++ b/src/triplet.c @@ -355,9 +355,10 @@ void triplet_enqueue(struct wy_triplet *trp) { pthread_t tid; - struct spool *spool = trp->spool; + struct spool *spool; if (!trp) return; + spool = trp->spool; timer_start(WY_TIMER_SPOOL); timer_start(spool->timer_id); if (spool_open_dictionaries(spool) == 0) { @@ -511,12 +512,19 @@ wy_thr_cleaner(void *ptr) void wy_triplet_wait(void) { + size_t n; + triplet_list_lock(&triplet_running_list); while (triplet_running_list.head) { pthread_cond_wait(&triplet_running_list.cond, &triplet_running_list.mutex); } triplet_list_unlock(&triplet_running_list); + + pthread_mutex_lock(&triplet_table_mutex); + n = grecs_symtab_count(triplet_table); + pthread_mutex_unlock(&triplet_table_mutex); + *wy_get_stat_slot(WY_STAT_INCOMPLETE_TRIPLETS) += n; } static pthread_key_t key; diff --git a/src/wydawca.c b/src/wydawca.c index 01ef56c..5771feb 100644 --- a/src/wydawca.c +++ b/src/wydawca.c @@ -44,10 +44,8 @@ int wy_mode_option = -1; int preprocess_only = 0; int foreground_option = -1; -int single_process_option = -1; int foreground; -int single_process; time_t wakeup_interval; struct grecs_list *all_spool_aliases; char *wy_gpg_homedir; @@ -417,8 +415,6 @@ main(int argc, char **argv) wy_mode = wy_mode_option; if (foreground_option >= 0) foreground = foreground_option; - if (single_process_option >= 0) - single_process = single_process_option; if (wy_log_to_stderr == -1) { switch (wy_mode) { diff --git a/src/wydawca.h b/src/wydawca.h index 90a886e..b3ece49 100644 --- a/src/wydawca.h +++ b/src/wydawca.h @@ -330,7 +330,6 @@ enum { extern int wy_mode; extern int foreground; -extern int single_process; extern struct grecs_sockaddr listen_sockaddr; extern size_t max_connections; extern time_t idle_timeout; diff --git a/tests/.gitignore b/tests/.gitignore index e5a908e..6a471f2 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -10,3 +10,4 @@ cwdrepl wyasync wyclt wyinit +chargen diff --git a/tests/Makefile.am b/tests/Makefile.am index fb971d5..8374916 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with Wydawca. If not, see . -EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 dist +EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 DISTCLEANFILES = atconfig $(check_SCRIPTS) MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) SUBDIRS = etc @@ -40,31 +40,33 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac ## ------------ ## TESTSUITE_AT = \ + testsuite.at\ backup00.at\ backup01.at\ backup02.at\ backup03.at\ + dry_run00.at\ + dry_run01.at\ + dry_run02.at\ + upload00.at\ + upload01.at\ + upload02.at\ + symlink00.at\ + symlink01.at\ + rmsymlink00.at\ + mailnotify.at\ + mailstats.at\ + check-ok.at\ check-fail.at\ check-notify.at\ - check-ok.at\ inotify-ok.at\ - inotify-rmsymlink.at\ inotify-symlink.at\ + inotify-rmsymlink.at\ inotify-unatt00.at\ inotify-unatt01.at\ - notify-upl.at\ - mailstats.at\ - rmsymlink00.at\ - symlink00.at\ - symlink01.at\ - testsuite.at\ - upload.at\ - upload-dry.at\ - upl11.at\ - upl12f.at\ - upl12t.at\ unp00.at\ unp01.at\ + unp02.at\ unp-idle.at\ version.at @@ -89,7 +91,7 @@ check-local: atconfig atlocal $(TESTSUITE) #installcheck-local: # $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin -check_PROGRAMS = bkupname cwdrepl wyinit wyasync wyclt +check_PROGRAMS = bkupname cwdrepl wyinit wyasync wyclt chargen AM_CPPFLAGS = \ @GRECS_INCLUDES@ \ -I$(top_srcdir)/include\ diff --git a/tests/atlocal.in b/tests/atlocal.in index 6102995..0d7c732 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -8,66 +8,130 @@ XFAILFILE=$abs_builddir/.badversion trap "test -r $XFAILFILE && cat $XFAILFILE; exit $?" 1 2 13 15 -WY_CONFSRC=@abs_top_srcdir@/tests/etc -WY_DISTDIR=@abs_top_srcdir@/tests/dist -WY_SRC=@abs_top_builddir@/tests/source -WY_DST=dest WY_TESTDIR=@abs_top_builddir@/tests +WY_CONFSRC=@abs_top_srcdir@/tests/etc +WY_CONFDST=$WY_TESTDIR/etc +WY_PROJECTDB=$WY_CONFSRC/project WY_MAILUTILS=@WY_MAILUTILS@ WY_INOTIFY=@WY_INOTIFY@ -MKDIR_P="@MKDIR_P@" +WY_MODDIR=@abs_top_builddir@/modules/mailutils -if test -w /; then - WY_FORCE=--force -else - WY_FORCE= -fi +GPG="@GPG@ --quiet --no-permission-warning --batch " +GNUPGHOME=$WY_CONFDST/gnupg +export GNUPGHOME ulimit -c unlimited -wydawca_expandmeta() { - sed -e "s/@USER@/$USER/g" \ - -e "s,@CWD@,$PWD,g" \ - -e "s,@WY_SRC@,$WY_SRC,g" \ - -e "s,@WY_DST@,$WY_DST,g" \ - -e "s,@WY_CONFSRC@,$WY_CONFSRC,g" \ - -e "s,@WY_TESTDIR@,$WY_TESTDIR,g" \ - -e "s,@WY_MODDIR@,@abs_top_builddir@/modules/mailutils,g" $1 > $2 -} +# ##################################### +# Utility functions +# ##################################### -wydawca_config() { - wydawca_expandmeta $WY_CONFSRC/${1}in $1 - wyinit $1 +# wy_project_lookup PROJECT WHAT +wy_project_lookup() { + test $# -eq 2 || echo >&2 "wy_project_lookup: bad number of arguments" + local n + case $2 in + PROJECT_NAME) n=1;; + REAL_NAME) n=2;; + EMAIL) n=3;; + COMMENT) n=4;; + esac + grep "^$1:" $WY_PROJECTDB | cut -d: -f$n } + +# wy_create_directive [-v X.Y] [-u USER] FILENAME PROJECT [DIRECTIVE: VALUE ...] +wy_create_directive() { + local version user + while [ $# -ne 0 ] + do + case $1 in + -v) version=$2 + shift 2;; + -u) user=$2 + shift 2;; + --) shift + break;; + *) break + esac + done -wydawca_upload() { - dir=source/$1 - shift - file=$1 - shift - cp "$WY_DISTDIR/$file" "$dir" - cp "$WY_DISTDIR/$file.sig" "$dir" - if test -n "$1"; then - cp "$WY_DISTDIR/$1" "$dir/$file.directive.asc" - else - cp "$WY_DISTDIR/$file.directive.asc" "$dir" + : ${version:=1.2} + + local filename="$1.directive" project=$2 + shift 2 + if [ $(( $# % 2 )) -ne 0 ]; then + echo >&2 "wy_create_directive: odd number of arguments" + exit 1 fi + (echo "version: $version" + echo "directory: $project" + while [ $# -gt 0 ] + do + echo "$1 $2" + shift 2 + done) > $filename + rm -f $filename.asc + : ${user:=$(wy_project_lookup $project REAL_NAME)} + rm -f $filename.asc + $GPG --clearsign -u "$user" -o $filename.asc $filename + rm $filename } -wydawca_cmp() { - p=$1 - shift - for file in $@ +# wy_genfile [-u USER] [-l SIZE] PROJECT NAME +wy_genfile() { + local length user + while [ $# -ne 0 ] do - cmp "$WY_DISTDIR/$file" "$WY_DST/$p/$file" || exit 1 + case $1 in + -l) length="-l $2" + shift 2;; + -u) user=$2 + shift 2;; + --) shift + break;; + *) break + esac done + + local project=$1 filename=$2 + chargen $length > $filename + + : ${user:=$(wy_project_lookup $project REAL_NAME)} + rm -f $filename.sig + $GPG -ba -o $filename.sig $filename } -wydawca_cmparc() { - p=$1 - shift - for file in $@ +# wy_create_upload [-u USER] [-l SIZE] PROJECT NAME [DIRECTIVE: VALUE...] +wy_create_upload() { + local length_option user_option + while [ $# -ne 0 ] do - cmp "$WY_DISTDIR/$file" "$WY_DST/$p/archive/$file" || exit 1 + case $1 in + -l) + length_option="$1 $2" + shift 2;; + -u) + user_option="$1 $2" + shift 2;; + --) shift + break;; + *) break + esac done + local project=$1 filename=$2 + shift 2 + wy_genfile $length_option $user_option $project $filename + wy_create_directive $user_option $filename $project\ + filename: $(basename $filename)\ + "$@" +} + +wy_config_head() { + cat < +#include +#include +#include +#include +#include + +int +main(int argc, char **argv) +{ + int c; + int start = 0; + int mod = UCHAR_MAX; + size_t i, len = 4096; + int printable = 0; + char *p; + + while ((c = getopt(argc, argv, "cl:ps:")) != EOF) { + switch (c) { + case 'c': + start = optarg[0]; + break; + case 'p': + printable = 1; + break; + case 's': + start = atoi(optarg) % UCHAR_MAX; + break; + case 'l': + errno = 0; + len = strtoul(optarg, &p, 10); + if (*p) { + fprintf(stderr, "bad length (near %s)", p); + exit(1); + } else if (errno) { + perror("bad length"); + exit(1); + } + break; + default: + exit(2); + } + } + + if (printable && !isprint(start)) + do { + start = (start + 1) % mod; + } while (printable && !isprint(start)); + + for (i = 0; i < len; i++) { + putchar(start); + do { + start = (start + 1) % mod; + } while (printable && !isprint(start)); + } + return 0; +} diff --git a/tests/check-fail.at b/tests/check-fail.at index 268ca47..4c4b1c9 100644 --- a/tests/check-fail.at +++ b/tests/check-fail.at @@ -16,15 +16,28 @@ AT_SETUP([Verification test failure]) AT_KEYWORDS([uploads check-test check-fail]) - -AT_DATA([experr], +AT_CHECK_UPLOAD([ +spool test { + url ftp://wydawca.test; + source "$PWD/upload"; + destination "$PWD/dest"; + check-script "exit 1"; +} +], +[wy_create_upload conversion upload/conversion-1.1.tar +cp -a upload orig +set -e +wydawca --no-preproc -c wydawca.cf 2>err +cat err | cwdrepl >&2 +], +[0], +[], [wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) started -wydawca: [[NOTICE]] file.directive.asc: VERSION: 1.1 -wydawca: [[NOTICE]] file.directive.asc: COMMENT: Gnupload for Wydawca testsuite -wydawca: [[ERR]] spool check script for file@ckfail returned 1 -wydawca: [[NOTICE]] removing ./source/fail/file -wydawca: [[NOTICE]] removing ./source/fail/file.sig -wydawca: [[NOTICE]] removing ./source/fail/file.directive.asc +wydawca: [[NOTICE]] conversion-1.1.tar.directive.asc: VERSION: 1.2 +wydawca: [[ERR]] spool check script for conversion-1.1.tar@test returned 1 +wydawca: [[NOTICE]] removing ./upload/conversion-1.1.tar +wydawca: [[NOTICE]] removing ./upload/conversion-1.1.tar.sig +wydawca: [[NOTICE]] removing ./upload/conversion-1.1.tar.directive.asc wydawca: [[INFO]] errors: 1 wydawca: [[INFO]] warnings: 0 wydawca: [[INFO]] bad signatures: 0 @@ -41,16 +54,6 @@ wydawca: [[INFO]] symlinks removed: 0 wydawca: [[INFO]] check failures: 1 wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) finished ]) +AT_CLEANUP -AT_CHECK([ -wydawca_config wydawca.cf -wydawca_upload fail file - -wydawca $WY_FORCE --no-preproc -c wydawca.cf 2>err -cat err | cwdrepl >&2 -], -[0], -[], -[experr]) -AT_CLEANUP diff --git a/tests/check-notify.at b/tests/check-notify.at index 298ebd0..63a00a4 100644 --- a/tests/check-notify.at +++ b/tests/check-notify.at @@ -17,14 +17,67 @@ AT_SETUP([Verification test failure notification]) AT_KEYWORDS([uploads check-test check-fail check-fail-notify notify]) -AT_DATA([experr], +AT_CHECK_UPLOAD([ +module-prepend-load-path "$WY_MODDIR"; +module mailutils mod_mailutils.la; +module-init mailutils { + admin-address "root@localhost"; + from-address "wydawca-noreply@localhost"; + mailer "| $WY_TESTDIR/nullmail -o $PWD/mail.out -F \${sender} \${rcpt}"; +} + +#include "$WY_CONFSRC/notify.cf" + +spool test { + url ftp://wydawca.test; + source "$PWD/upload"; + destination "$PWD/dest"; + check-script <err +cat err | cwdrepl >&2 +cat mail.out | cwdrepl +], +[0], +[From wydawca-noreply@localhost +From: wydawca-noreply@localhost +To: "Wydawca tester for the Conversion project" +Subject: conversion-1.1.tar rejected + +Your upload of conversion-1.1.tar has been rejected by the distribution +verification procedure with the following diagnostics: + +WYDAWCA_SPOOL=test +WYDAWCA_SOURCE=./upload +WYDAWCA_DEST=./dest +WYDAWCA_URL=ftp://wydawca.test +WYDAWCA_TRIPLET_BASE=conversion-1.1.tar +WYDAWCA_DIST_FILE=conversion-1.1.tar + +Please fix the tarball and resubmit. + +Regards, +Wydawca +The Project Submission Robot +], [wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) started -wydawca: [[NOTICE]] file.directive.asc: VERSION: 1.1 -wydawca: [[NOTICE]] file.directive.asc: COMMENT: Gnupload for Wydawca testsuite -wydawca: [[ERR]] spool check script for file@ckfail returned 1 -wydawca: [[NOTICE]] removing ./source/fail/file -wydawca: [[NOTICE]] removing ./source/fail/file.sig -wydawca: [[NOTICE]] removing ./source/fail/file.directive.asc +wydawca: [[NOTICE]] conversion-1.1.tar.directive.asc: VERSION: 1.2 +wydawca: [[ERR]] spool check script for conversion-1.1.tar@test returned 1 +wydawca: [[NOTICE]] removing ./upload/conversion-1.1.tar +wydawca: [[NOTICE]] removing ./upload/conversion-1.1.tar.sig +wydawca: [[NOTICE]] removing ./upload/conversion-1.1.tar.directive.asc wydawca: [[INFO]] errors: 1 wydawca: [[INFO]] warnings: 0 wydawca: [[INFO]] bad signatures: 0 @@ -41,44 +94,6 @@ wydawca: [[INFO]] symlinks removed: 0 wydawca: [[INFO]] check failures: 1 wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) finished ]) +AT_CLEANUP -AT_DATA([expout], -[From wydawca-noreply@localhost -From: wydawca-noreply@localhost -To: "Wydawca Test User" -Subject: file rejected - -Your upload of file has been rejected by the distribution -verification procedure with the following diagnostics: - -WYDAWCA_SPOOL=ckfail -WYDAWCA_SOURCE=./source/fail -WYDAWCA_DEST=./dest -WYDAWCA_URL=ftp://wydawca.ckfail -WYDAWCA_TRIPLET_BASE=file -WYDAWCA_DIST_FILE=file - -Please fix the tarball and resubmit. - -Regards, -Wydawca -The Project Submission Robot -]) - -AT_CHECK([ -AT_MAILUTILS_PREREQ -wydawca_config wydawca.cf -mv wydawca.cf simple.cf -wydawca_config notify.cf -cat notify.cf simple.cf >> wydawca.cf - -wydawca_upload fail file -wydawca $WY_FORCE --no-preproc -c wydawca.cf 2>err || exit $? -cat err | cwdrepl >&2 -cat mail.out | cwdrepl -], -[0], -[expout], -[experr]) -AT_CLEANUP diff --git a/tests/check-ok.at b/tests/check-ok.at index 11ee9a1..a7090da 100644 --- a/tests/check-ok.at +++ b/tests/check-ok.at @@ -16,11 +16,25 @@ AT_SETUP([Verification test success]) AT_KEYWORDS([uploads check-test check-success check-ok]) - -AT_DATA([experr], +AT_CHECK_UPLOAD([ +spool test { + url ftp://wydawca.test; + source "$PWD/upload"; + destination "$PWD/dest"; + check-script "exit 0"; +} +], +[wy_create_upload conversion upload/conversion-1.1.tar +cp -a upload orig +set -e +wydawca --no-preproc -c wydawca.cf +cmp orig/conversion-1.1.tar dest/conversion/conversion-1.1.tar +cmp orig/conversion-1.1.tar.sig dest/conversion/conversion-1.1.tar.sig +], +[0], +[], [wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) started -wydawca: [[NOTICE]] file.directive.asc: VERSION: 1.1 -wydawca: [[NOTICE]] file.directive.asc: COMMENT: Gnupload for Wydawca testsuite +wydawca: [[NOTICE]] conversion-1.1.tar.directive.asc: VERSION: 1.2 wydawca: [[INFO]] errors: 0 wydawca: [[INFO]] warnings: 0 wydawca: [[INFO]] bad signatures: 0 @@ -37,16 +51,6 @@ wydawca: [[INFO]] symlinks removed: 0 wydawca: [[INFO]] check failures: 0 wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) finished ]) +AT_CLEANUP -AT_CHECK([ -wydawca_config wydawca.cf -wydawca_upload ok file -wydawca $WY_FORCE --no-preproc -c wydawca.cf 2>err|| exit $? -cat err | cwdrepl >&2 -wydawca_cmp proj file file.sig -], -[0], -[], -[experr]) -AT_CLEANUP diff --git a/tests/dist/file b/tests/dist/file deleted file mode 100644 index 2635c5c..0000000 --- a/tests/dist/file +++ /dev/null @@ -1 +0,0 @@ -This is a test file for Wydawca testsuite. diff --git a/tests/dist/file.directive.asc b/tests/dist/file.directive.asc deleted file mode 100644 index 0f40f6f..0000000 --- a/tests/dist/file.directive.asc +++ /dev/null @@ -1,14 +0,0 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -version: 1.1 -directory: proj -comment: Gnupload for Wydawca testsuite -filename: file ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.7 (GNU/Linux) - -iD8DBQFJnExlCZA3/2YT9iMRAgm7AJ9SLO/vihu3PeAwyRQsJp85NVC9swCdE+FQ -SF9/JnHygja6qb5KRZEleuw= -=RjYY ------END PGP SIGNATURE----- diff --git a/tests/dist/file.sig b/tests/dist/file.sig deleted file mode 100644 index 31cdef1..0000000 --- a/tests/dist/file.sig +++ /dev/null @@ -1,7 +0,0 @@ ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.7 (GNU/Linux) - -iD8DBQBJnExlCZA3/2YT9iMRAjDIAKCSt2MbRo8g9P9y/u9WZp1tGlVShwCeI7K+ -3G2UCTc/xlj200mHP2+B84M= -=UO+/ ------END PGP SIGNATURE----- diff --git a/tests/dist/file12f.directive.asc b/tests/dist/file12f.directive.asc deleted file mode 100644 index 11b206d..0000000 --- a/tests/dist/file12f.directive.asc +++ /dev/null @@ -1,15 +0,0 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -version: 1.2 -directory: proj -comment: Gnupload for Wydawca testsuite -filename: file -replace: false ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.9 (GNU/Linux) - -iEYEARECAAYFAk/B+FwACgkQCZA3/2YT9iN1CQCgh9sbdy1zz6o6jTJRGXAbjClq -jvoAn3wcsnvIzx2vZchPMSfpJ3ZaPV1f -=g4s4 ------END PGP SIGNATURE----- diff --git a/tests/dist/file12t.directive.asc b/tests/dist/file12t.directive.asc deleted file mode 100644 index 921ca1e..0000000 --- a/tests/dist/file12t.directive.asc +++ /dev/null @@ -1,15 +0,0 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -version: 1.2 -directory: proj -comment: Gnupload for Wydawca testsuite -filename: file -replace: true ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.9 (GNU/Linux) - -iEYEARECAAYFAk/B+GAACgkQCZA3/2YT9iMwzgCgzIWjeAwRlI0aLgUAo8XafrId -qLsAoIQp2r63b+WxDdvwDrvXBwtQJq1x -=t6tj ------END PGP SIGNATURE----- diff --git a/tests/dist/rmsymlink.directive.asc b/tests/dist/rmsymlink.directive.asc deleted file mode 100644 index e6a520e..0000000 --- a/tests/dist/rmsymlink.directive.asc +++ /dev/null @@ -1,14 +0,0 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -version: 1.2 -directory: proj -comment: remove symlink -rmsymlink: file-latest ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1 - -iEYEARECAAYFAl6UodIACgkQCZA3/2YT9iNb7wCgjHrB9xDfdndQISqF+SwQbeJi -PVAAoKlzBCycNslZ4bo7h36Nenfv3k9u -=CTgS ------END PGP SIGNATURE----- diff --git a/tests/dist/symlink.directive.asc b/tests/dist/symlink.directive.asc deleted file mode 100644 index 4654f48..0000000 --- a/tests/dist/symlink.directive.asc +++ /dev/null @@ -1,14 +0,0 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -version: 1.2 -directory: proj -comment: create a symlink -symlink: file file-latest ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1 - -iEYEARECAAYFAl6UhygACgkQCZA3/2YT9iOH3wCgvJmS3Q5FcLQvhwZisDzNCQGS -klQAn3KHpEHp1YjBV3U2tvSAcGhYUwd5 -=vx2j ------END PGP SIGNATURE----- diff --git a/tests/dry_run00.at b/tests/dry_run00.at new file mode 100644 index 0000000..b8202fd --- /dev/null +++ b/tests/dry_run00.at @@ -0,0 +1,52 @@ +# Check dry-run uploads -*- Autotest -*- +# Copyright (C) 2009-2012, 2017, 2019-2020 Sergey Poznyakoff +# +# Wydawca is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Wydawca 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. +# +# You should have received a copy of the GNU General Public License +# along with Wydawca. If not, see . +AT_SETUP([Dry-run upload]) +AT_KEYWORDS([upload upload-single upload-success dry-run]) +AT_CHECK_UPLOAD([ +spool test { + url ftp://wydawca.test; + source "$PWD/upload"; + destination "$PWD/dest"; +} +], +[wy_create_upload conversion upload/conversion-1.1.tar \ + comment: "Dry-run upload" +set -e +wydawca --no-preproc --dry-run --debug=0 -c wydawca.cf +], +[0], +[], +[wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) started +wydawca: [[NOTICE]] conversion-1.1.tar.directive.asc: VERSION: 1.2 +wydawca: [[NOTICE]] conversion-1.1.tar.directive.asc: COMMENT: Dry-run upload +wydawca: [[INFO]] errors: 0 +wydawca: [[INFO]] warnings: 0 +wydawca: [[INFO]] bad signatures: 0 +wydawca: [[INFO]] access violation attempts: 0 +wydawca: [[INFO]] complete triplets: 1 +wydawca: [[INFO]] incomplete triplets: 0 +wydawca: [[INFO]] bad triplets: 0 +wydawca: [[INFO]] expired triplets: 0 +wydawca: [[INFO]] triplet successes: 1 +wydawca: [[INFO]] files uploaded: 2 +wydawca: [[INFO]] files archived: 0 +wydawca: [[INFO]] symlinks created: 0 +wydawca: [[INFO]] symlinks removed: 0 +wydawca: [[INFO]] check failures: 0 +wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) finished +]) +AT_CLEANUP + diff --git a/tests/dry_run01.at b/tests/dry_run01.at new file mode 100644 index 0000000..387a9da --- /dev/null +++ b/tests/dry_run01.at @@ -0,0 +1,83 @@ +# Check dry-run uploads -*- Autotest -*- +# Copyright (C) 2009-2012, 2017, 2019-2020 Sergey Poznyakoff +# +# Wydawca is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Wydawca 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. +# +# You should have received a copy of the GNU General Public License +# along with Wydawca. If not, see . +AT_SETUP([Failed upload]) +AT_KEYWORDS([upload upload-single upload-failure dry-run]) +AT_CHECK_UPLOAD([ +spool test { + url ftp://wydawca.test; + source "$PWD/upload"; + destination "$PWD/dest"; +} +], +[wy_create_upload -u forese@example.com conversion upload/conversion-1.1.tar \ + comment: "Dry-run upload" +set -e +wydawca --no-preproc --dry-run --debug=0 -c wydawca.cf 2>err + +# FIXME: The incomplete triplets count can be set to 1 if the directive +# file is seen first. In this case it is parsed early, found to be signed +# by wrong person (which also raises the bad signatures and access violation +# attempts counts) and the corresponding triplet is removed. Then, the +# archive and signature files are read and combined into a single inclomplete +# triplet. Incomplete because the directive part has already been dismissed. +# This triplet is detected at the end of the run. +# +# If, on the other hand, the archive and signature were read first and the +# directive file last, then the completed triplet would be thrown out and +# incomplete triplet count would remain 0. +# +# Ways out: +# 1. Detain the triplet in table until it is completed and only then +# verify the signature. This will always produce the second case. +# However, it implies parsing the signature file early. Actually, +# that's the way wydawca operates now. However, although it seemed +# a nice idea at the time, now I incline to the second solution. +# 2. Verify the triplet as soon as the directive file is read. Parse +# the directive only if the signature passes verification. Otherwise, +# drop it. This is pretty similar to how wydawca operates now, except +# that the directive file would be parsed only if verified. That seems +# to be an advantage, since that's what the signature is for, in the +# first place. Secondly, that would allow to use right GPGME function +# for extracting the file content, instead of feedling with it manually. +# The drawback is that processing of badly signed directives would +# sometimes produce false incomplete triplets. The only fix is to defer +# triplet processing to the end of directory scan, which implies a +# memory usage overhead. +sed -e 's/incomplete triplets: 1/incomplete triplets: 0/' err >&2 +], +[0], +[], +[wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) started +wydawca: [[ERR]] No public key +wydawca: [[ERR]] invalid signature for conversion-1.1.tar +wydawca: [[INFO]] errors: 2 +wydawca: [[INFO]] warnings: 0 +wydawca: [[INFO]] bad signatures: 1 +wydawca: [[INFO]] access violation attempts: 1 +wydawca: [[INFO]] complete triplets: 0 +wydawca: [[INFO]] incomplete triplets: 0 +wydawca: [[INFO]] bad triplets: 0 +wydawca: [[INFO]] expired triplets: 0 +wydawca: [[INFO]] triplet successes: 0 +wydawca: [[INFO]] files uploaded: 0 +wydawca: [[INFO]] files archived: 0 +wydawca: [[INFO]] symlinks created: 0 +wydawca: [[INFO]] symlinks removed: 0 +wydawca: [[INFO]] check failures: 0 +wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) finished +]) +AT_CLEANUP + diff --git a/tests/dry_run02.at b/tests/dry_run02.at new file mode 100644 index 0000000..7dcf8f2 --- /dev/null +++ b/tests/dry_run02.at @@ -0,0 +1,51 @@ +# Check dry-run uploads -*- Autotest -*- +# Copyright (C) 2009-2012, 2017, 2019-2020 Sergey Poznyakoff +# +# Wydawca is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Wydawca 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. +# +# You should have received a copy of the GNU General Public License +# along with Wydawca. If not, see . +AT_SETUP([Incomplete triplet]) +AT_KEYWORDS([upload upload-single upload-inclomplete dry-run]) +AT_CHECK_UPLOAD([ +spool test { + url ftp://wydawca.test; + source "$PWD/upload"; + destination "$PWD/dest"; +} +], +[wy_create_upload conversion upload/conversion-1.1.tar \ + comment: "Dry-run upload" +rm upload/conversion-1.1.tar.sig +wydawca --no-preproc --dry-run --debug=0 -c wydawca.cf +], +[0], +[], +[wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) started +wydawca: [[NOTICE]] conversion-1.1.tar.directive.asc: VERSION: 1.2 +wydawca: [[INFO]] errors: 0 +wydawca: [[INFO]] warnings: 0 +wydawca: [[INFO]] bad signatures: 0 +wydawca: [[INFO]] access violation attempts: 0 +wydawca: [[INFO]] complete triplets: 0 +wydawca: [[INFO]] incomplete triplets: 1 +wydawca: [[INFO]] bad triplets: 0 +wydawca: [[INFO]] expired triplets: 0 +wydawca: [[INFO]] triplet successes: 0 +wydawca: [[INFO]] files uploaded: 0 +wydawca: [[INFO]] files archived: 0 +wydawca: [[INFO]] symlinks created: 0 +wydawca: [[INFO]] symlinks removed: 0 +wydawca: [[INFO]] check failures: 0 +wydawca: [[NOTICE]] AT_PACKAGE_TARNAME (AT_PACKAGE_NAME AT_PACKAGE_VERSION) finished +]) +AT_CLEANUP + diff --git a/tests/etc/.gitignore b/tests/etc/.gitignore index 9176bae..75b8e00 100644 --- a/tests/etc/.gitignore +++ b/tests/etc/.gitignore @@ -1,3 +1,2 @@ -*.gpg -random_seed +gnupg *.cf diff --git a/tests/etc/Makefile.am b/tests/etc/Makefile.am index 2f572d1..72edb5d 100644 --- a/tests/etc/Makefile.am +++ b/tests/etc/Makefile.am @@ -14,19 +14,25 @@ # You should have received a copy of the GNU General Public License # along with Wydawca. If not, see . -GPGFILES = secring.gpg pubring.gpg -noinst_DATA = @WYDAWCA_GPGFILES@ - EXTRA_DIST = \ - pubring.asc\ - secring.asc\ - wydawca.cfin\ - notify.cfin\ + dbgen.sh\ + keygen.sh\ + project\ + notify.cf\ mailstats.cfin -GPG_FLAGS = --quiet --no-permission-warning --homedir . -pubring.gpg secring.gpg: $(srcdir)/pubring.asc $(srcdir)/secring.asc - $(GPG) $(GPG_FLAGS) --import < $(srcdir)/pubring.asc - $(GPG) $(GPG_FLAGS) --allow-secret-key-import --import < $(srcdir)/secring.asc +if COND_GPG2 +noinst_DATA = gnupg database.cf +endif + +gnupg: keygen.sh Makefile.am + $(AM_V_GEN)$(SHELL) $(srcdir)/keygen.sh --gpg $(GPG) --homedir gnupg $(srcdir)/project + +database.cf: dbgen.sh Makefile.am + $(AM_V_GEN)$(SHELL) $(srcdir)/dbgen.sh -o $@ \ + --gpg $(GPG) --homedir gnupg $(srcdir)/project + +DISTCLEANFILES=database.cf +distclean-am: clean-am distclean-generic + rm -rf gnupg -DISTCLEANFILES = *.gpg *.gpg~ random_seed diff --git a/tests/etc/dbgen.sh b/tests/etc/dbgen.sh new file mode 100644 index 0000000..fa2db73 --- /dev/null +++ b/tests/etc/dbgen.sh @@ -0,0 +1,93 @@ +#!/bin/sh +# Usage: dbgen.sh [--gpg GPG] [--homedir DIR] INFILE + +GNUPGHOME=gnupg +export GNUPGHOME + +while [ $# -ne 0 ] +do + case $1 in + --gpg) + GPG=$2 + shift 2 + ;; + --homedir) + GNUPGHOME=$2 + shift 2 + ;; + --output) + output=$2 + shift 2 + ;; + --output=*) + output=${1##--output=} + shift + ;; + -o) + output=$2 + shift 2 + ;; + -o*) + output=${1##-o} + shift + ;; + --) + shift + ;; + --*) + echo >&2 "$0: unrecognized option $1" + exit 1 + ;; + *) break + esac +done + +if [ $# -eq 1 ]; then + projects_db=$1 +else + echo >&2 "$0: exactly one argument must be given" + exit 1 +fi + +if [ -n "$output" ]; then + exec >$output +fi + +cat <<\EOF +dictionary project-owner { + type builtin; + query "${project}"; + params ("/exact", +EOF + +oIFS=$IFS +IFS=":" +while read project realname email comment +do + IFS=$oIFS + echo " \"$project\", \"$email\", \"$realname\"," + IFS=":" +done < $projects_db | sed -e '$s/,$/);/' +IFS=$oIFS + +echo "}" + +cat <<\EOF +dictionary project-uploader { + type builtin; + query "${project}"; + params ("/exact", +EOF + +IFS=":" +while read project realname email comment +do + IFS=$oIFS + user=${email%%@*} + echo " \"$project\", \"$user\", \"$comment\", \"$email\"," + ${GPG:-gpg2} --quiet --no-permission-warning --batch \ + --export --armor "$realname" | + sed -r -e 's/.*/"&\\n"/' -e '$s/$/,/' + IFS=":" +done < $projects_db | sed -e '$s/,$/);/' +echo "}" diff --git a/tests/etc/keygen.sh b/tests/etc/keygen.sh new file mode 100644 index 0000000..76099c3 --- /dev/null +++ b/tests/etc/keygen.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# Usage: keygen.sh [--gpg GPG] --homedir DIR [INFILE] + +unset GNUPGHOME +while [ $# -ne 0 ] +do + case $1 in + --gpg) + GPG=$2 + shift 2 + ;; + --homedir) + GNUPGHOME=$2 + shift 2 + ;; + --) + shift + ;; + --*) + echo >&2 "$0: unrecognized option $1" + exit 1 + ;; + *) break + esac +done + +if [ $# -eq 1 ]; then + exec <$1 +fi + +: ${GNUPGHOME:?the --homedir option must be given} +if [ -d $GNUPGHOME ]; then + rm -rf $GNUPGHOME/* +else + mkdir $GNUPGHOME +fi +export GNUPGHOME + +oIFS=$IFS +IFS=':' +while read project realname email comment +do + IFS=$oIFS + cat <. + +# Notify the user about successful uploads +notify-event { + event success; + module mailutils; + module-config { + recipient user; + message <. +Otherwise, let us know so we could undertake appropriate measures. + +Regards, +Wydawca +The Project Submission Robot +EOT; + } +} + +# Notify the user (submitter), if the directive signature does not match +# his record. +# It may be a good idea not to notify users about such events, just to +# stay on a safe side. Notifying project admins (see below) should be quite +# enough. +notify-event { + event bad-directive-signature; + module mailutils; + module-config { + recipient user; + message <. - -module-prepend-load-path "@WY_MODDIR@"; -module mailutils mod_mailutils.la; -module-init mailutils { - admin-address "root@localhost"; - from-address "wydawca-noreply@localhost"; - - mailer "| @WY_TESTDIR@/nullmail -o @CWD@/mail.out -F ${sender} ${rcpt}"; -} - -# Notify the user about successful uploads -notify-event { - event success; - module mailutils; - module-config { - recipient user; - message <. -Otherwise, let us know so we could undertake appropriate measures. - -Regards, -Wydawca -The Project Submission Robot -EOT; - } -} - -# Notify the user (submitter), if the directive signature does not match -# his record. -# It may be a good idea not to notify users about such events, just to -# stay on a safe side. Notifying project admins (see below) should be quite -# enough. -notify-event { - event bad-directive-signature; - module mailutils; - module-config { - recipient user; - message <. - -pidfile @CWD@/wydawca.pid; -statistics all; - -umask 022; - -dictionary project-owner { - type builtin; - query "${project}"; - params ("/exact", - "proj", "proj-owner@localhost", "Project Admin"); -} -dictionary project-uploader { - type builtin; - query "${project}"; - params ("/exact", - "proj", "gray", "Wydawca Test User", "gray@localhost", -"-----BEGIN PGP PUBLIC KEY BLOCK-----\n" -"Version: GnuPG v1.4.7 (GNU/Linux)\n" -"\n" -"mQGhBEmZcTERBAD9sD9d3xhVHURwbLcHUHIK6LGSHAlFzKv4MSOk+6nJhdvbQfIV\n" -"YAe6VZ8fTX8EX7f0Vw53or1mlBOZpMNeEHp/IejFwnT3pAF3xiHTwbmwJg+0RuKo\n" -"dwfN0vO9xECj3/ZsBvSYbYty8Vmy2e8osrNdXAXd+8Z3xJ3reAWOujGj9wCg1qg5\n" -"1LJgEIbPdZm0Iv43Pvdzbi8EAMlW6oZuBFuQXf0e2NceZKrZvGjFDWLgIgHv