diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-05-27 15:11:59 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-05-27 15:33:30 +0300 |
commit | 83d7377354504cf3d92a5bdf9cade07554c6b66e (patch) | |
tree | 01d602910d6314edbd5568600e7dfb5b1b215bfa | |
parent | 5fc301baf79e9cc19b1bc8e7a5940e060611e349 (diff) | |
download | wydawca-83d7377354504cf3d92a5bdf9cade07554c6b66e.tar.gz wydawca-83d7377354504cf3d92a5bdf9cade07554c6b66e.tar.bz2 |
Implement upload directives version 1.2
* NEWS: Update.
* README: Update.
* doc/wydawca.texi: Document changes.
* src/cmdline.opt: Update copyright years.
* src/config.c: Update for new grecs version.
New keywords: min-version and max-version.
* src/directive.c (directive_unpack_version): New function.
(directive_version_in_range_p): Set trp->version and print it.
(directive) <replace_dir>: New directive.
(directive_table): New directive "replace".
(verify_directive_format): Use globals min_directive_version
and max_directive_version.
(process_directives): Handle replace_dir
* src/diskio.c (dir_move_file): Use the "replace"
directive to act on existing files.
* src/wydawca.c (min_directive_version)
(max_directive_version): New globals.
(main): Loosen gpgme requirement: version 1.1.0 is Ok.
* src/wydawca.h (MAX_DIRECTIVE_VERSION): Set to 102
(file_triplet) <version>: New member.
(min_directive_version)
(max_directive_version): New globals.
(directive_unpack_version): New proto.
* tests/upl11.at: New file.
* tests/upl12f.at: New file.
* tests/upl12t.at: New file.
* tests/Makefile.am (TESTSUITE_AT): Add new files.
* tests/atlocal.in (wydawca_upload): Change invocation. All uses updated.
(wydawca_cmparc): New function.
* tests/check-fail.at: Update.
* tests/check-notify.at: Update.
* tests/check-ok.at: Update.
* tests/dist/file12f.directive.asc: New file.
* tests/dist/file12t.directive.asc: New file.
* tests/etc/wydawca.rcin (test): Define "archive" clause.
* tests/mailstats.at: Update.
* tests/notify-upl.at: Update.
* tests/testsuite.at: Include new files.
* tests/upload-dry.at: Update.
* tests/upload.at: Update.
-rw-r--r-- | NEWS | 8 | ||||
-rw-r--r-- | README | 12 | ||||
-rw-r--r-- | doc/wydawca.texi | 78 | ||||
-rw-r--r-- | src/backup.c | 4 | ||||
-rw-r--r-- | src/cmdline.opt | 4 | ||||
-rw-r--r-- | src/config.c | 204 | ||||
-rw-r--r-- | src/directive.c | 34 | ||||
-rw-r--r-- | src/diskio.c | 32 | ||||
-rw-r--r-- | src/tcpwrap.c | 12 | ||||
-rw-r--r-- | src/wydawca.c | 7 | ||||
-rw-r--r-- | src/wydawca.h | 10 | ||||
-rw-r--r-- | tests/Makefile.am | 5 | ||||
-rw-r--r-- | tests/atlocal.in | 23 | ||||
-rw-r--r-- | tests/check-fail.at | 5 | ||||
-rw-r--r-- | tests/check-notify.at | 5 | ||||
-rw-r--r-- | tests/check-ok.at | 5 | ||||
-rw-r--r-- | tests/dist/file12f.directive.asc | 15 | ||||
-rw-r--r-- | tests/dist/file12t.directive.asc | 15 | ||||
-rw-r--r-- | tests/etc/wydawca.rcin | 6 | ||||
-rw-r--r-- | tests/mailstats.at | 5 | ||||
-rw-r--r-- | tests/notify-upl.at | 5 | ||||
-rw-r--r-- | tests/testsuite.at | 5 | ||||
-rw-r--r-- | tests/upl11.at | 63 | ||||
-rw-r--r-- | tests/upl12f.at | 66 | ||||
-rw-r--r-- | tests/upl12t.at | 63 | ||||
-rw-r--r-- | tests/upload-dry.at | 5 | ||||
-rw-r--r-- | tests/upload.at | 5 |
27 files changed, 573 insertions, 128 deletions
@@ -1,5 +1,5 @@ -Wydawca NEWS -- history of user-visible changes. 2011-06-27 -Copyright (C) 2007-2011 Sergey Poznyakoff +Wydawca NEWS -- history of user-visible changes. 2012-05-27 +Copyright (C) 2007-2012 Sergey Poznyakoff See the end of file for copying conditions. Please send Wydawca bug reports to <bug-wydawca@gnu.org.ua>. @@ -7,6 +7,8 @@ Please send Wydawca bug reports to <bug-wydawca@gnu.org.ua>. Version 2.1.90 (Git) +* Implements upload protocol version 1.2 + * Input file locations include start and end columns. @@ -156,7 +158,7 @@ Version 1.0, 2008-08-23 ---------------------------------------------------------------------- Copyright information: -Copyright (C) 2007, 2008, 2009 Sergey Poznyakoff +Copyright (C) 2007-2012 Sergey Poznyakoff Permission is granted to anyone to make or distribute verbatim copies of this document as received, in any medium, provided that the @@ -1,5 +1,5 @@ Wydawca README -Copyright (C) 2007-2008, 2010-2011 Sergey Poznyakoff +Copyright (C) 2007-2008, 2010-2012 Sergey Poznyakoff See the end of file for copying conditions. * Introduction @@ -9,7 +9,7 @@ automatic upload procedure specified in: http://www.gnu.org/prep/maintain/html_node/Automated-Upload-Procedure.html -and supports version 1.1 of the directive file. +and supports versions 1.1 and 1.2 of the directive file. * Installation @@ -22,9 +22,9 @@ Configure and make: See the file INSTALL for the description of ./configure and its generic options. The options and variables specific to Wydawca are described below: - ---enable-sendfile - Attempt to use sendfile(2) when possible + + --with-tcp-wrappers compile with TCP wrappers support (default) + --without-preprocessor do not use external preprocessor * Documentation @@ -37,7 +37,7 @@ Send bug reports to <bug-wydawca@gnu.org.ua>. * Copyright information: -Copyright (C) 2007, 2008 Sergey Poznyakoff +Copyright (C) 2007, 2008, 2010-2012 Sergey Poznyakoff Permission is granted to anyone to make or distribute verbatim copies of this document as received, in any medium, provided that the diff --git a/doc/wydawca.texi b/doc/wydawca.texi index 1bdea48..1d47cf5 100644 --- a/doc/wydawca.texi +++ b/doc/wydawca.texi @@ -31,7 +31,7 @@ Published by the Free Software Foundation, 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA -Copyright @copyright{} 2007, 2009-2011 Sergey Poznyakoff +Copyright @copyright{} 2007, 2009-2012 Sergey Poznyakoff Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or @@ -97,6 +97,7 @@ How to Configure @command{wydawca}. * Syntax:: Configuration file syntax. * general:: +* versions:: * user privileges:: * daemon:: * tcp-wrapper:: @@ -196,17 +197,27 @@ handle any number of @samp{source/destination} pairs (called notification mechanism, allowing both package maintainers and site administrators to be immediately notified about any occurring problems. - @command{Wydawca} supports version 1.1 of directory file, as -described in + @command{Wydawca} supports upload directive versions 1.1@footnote{ @ifnothtml -@ref{FTP Upload Directive File - v1.1, +@xref{FTP Upload Directive File - v1.1, Standalone directives, Standalone directives, maintain, Information for maintainers of GNU software}. @end ifnothtml @ifhtml -@uref{http://www.gnu.org/prep/maintain/html_node/FTP-Upload-Directive-File-_002d-v1_002e1.html, +See @uref{http://www.gnu.org/prep/maintain/html_node/FTP-Upload-Directive-File-_002d-v1_002e1.html, +Standalone directives}. +@end ifhtml +} and 1.2@footnote{ +@ifnothtml +@xref{FTP Upload Directive File - v1.2, +Standalone directives, Standalone directives, +maintain, Information for maintainers of GNU software}. +@end ifnothtml +@ifhtml +See @uref{http://www.gnu.org/prep/maintain/html_node/FTP-Upload-Directive-File-_002d-v1_002e2.html, Standalone directives}. @end ifhtml +}. The program is written entirely in @acronym{C}, is highly effective and consumes little resources. @@ -482,6 +493,7 @@ directives any time by running @command{wydawca --config-help}. @menu * Syntax:: Configuration file syntax. * general:: +* versions:: * user privileges:: * daemon:: * tcp-wrapper:: @@ -950,6 +962,60 @@ outgoing messages are looked up in this directory. @xref{statreports, gpg-sign}, and @ref{event notification, gpg-sign}. @end deffn +@node versions +@section Upload Directive Versions +At the time of this writing, FSF has published three versions of the +upload directives, numbered 1.0 through 1.2. The version 1.0 is +considered obsolete and was withdrawn in 2006. The only difference +between versions 1.1 and 1.2 is in handling of files that existed +prior to upload. The version 1.1 implied automatic archivation of the +existing files and their replacement with the newly uploaded versions. +The version 1.2 introduces a new keyword (@samp{replace}) for that +purpose, which determines its further actions. + +For a detailed information about version 1.1, see +@ifnothtml +@xref{FTP Upload Directive File - v1.1, +Standalone directives, Standalone directives, +maintain, Information for maintainers of GNU software}. +@end ifnothtml +@ifhtml +@uref{http://www.gnu.org/prep/maintain/html_node/FTP-Upload-Directive-File-_002d-v1_002e1.html, +Standalone directives}. +@end ifhtml + +The version 1.2 and its differences from 1.1 are discussed in +@ifnothtml +@xref{FTP Upload Directive File - v1.2, +Standalone directives, Standalone directives, +maintain, Information for maintainers of GNU software}. +@end ifnothtml +@ifhtml +@uref{http://www.gnu.org/prep/maintain/html_node/FTP-Upload-Directive-File-_002d-v1_002e2.html, +Standalone directives}. +@end ifhtml + +By default, @command{wydawca} supports both versions. The supported range of +versions can be abridged using the following configuration statements: + +@deffn {Config} min-version vn +Sets minimal allowed directive file version. The @var{vn} argument +must have the form @samp{@var{major}.@var{minor}} and can not be less +than @samp{1.1}. +@end deffn + +@deffn {Config} max-version vn +Sets maximal allowed directive file version. +@end deffn + +For example, the following statements configure @command{wydawca} to +accept only directive files of version 1.2: + +@example +min-version 1.2; +max-version 1.2; +@end example + @node user privileges @section User Privileges @@ -1748,7 +1814,7 @@ Always make numbered backups. @itemx existing @kwindex nil@r{, backup method} @kwindex existing@r{, backup method} -Make numbered backups of files that already have them, simple backups. +Make numbered backups of files that already have them, and simple backups of the others. @item never diff --git a/src/backup.c b/src/backup.c index 312375d..c5c55de 100644 --- a/src/backup.c +++ b/src/backup.c @@ -1,5 +1,5 @@ /* wydawca - automatic release submission daemon - Copyright (C) 2011 Sergey Poznyakoff + Copyright (C) 2011, 2012 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 @@ -54,7 +54,7 @@ get_backup_suffix (char const *file, enum backup_type type) char *lastsuf = NULL; size_t lastsuflen = 0; size_t lastsufsize = 0; - int carry; + int carry = 0; char *newsuf; char *q; diff --git a/src/cmdline.opt b/src/cmdline.opt index c6f8741..c9554b8 100644 --- a/src/cmdline.opt +++ b/src/cmdline.opt @@ -1,5 +1,5 @@ /* wydawca - automatic release submission daemon -*- c -*- - Copyright (C) 2007, 2009-2011 Sergey Poznyakoff + Copyright (C) 2007, 2009-2012 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 @@ -44,7 +44,7 @@ OPTIONS_BEGIN("wydawca", [<wydawca synchronizes files from a set of upload directories with the corresponding distribution sites>], [<UID [UID...]>], [<gnu>], - [<copyright_year=2011>], + [<copyright_year=2007-2012>], [<copyright_holder=Sergey Poznyakoff>]) GROUP(Selecting program mode) diff --git a/src/config.c b/src/config.c index 11a448e..66d5fb7 100644 --- a/src/config.c +++ b/src/config.c @@ -1,5 +1,5 @@ /* wydawca - automatic release submission daemon - Copyright (C) 2007-2011 Sergey Poznyakoff + Copyright (C) 2007-2012 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 @@ -293,7 +293,7 @@ cb_email_address (enum grecs_callback_command cmd, grecs_value_t *value, void *cb_data) { - int rc; + int rc = 1; mu_address_t addr = NULL; switch (value->type) @@ -619,20 +619,27 @@ cb_sql (enum grecs_callback_command cmd, static struct grecs_keyword sql_kw[] = { { "config-file", N_("file"), N_("Read MySQL configuration from <file>"), - grecs_type_string, NULL, offsetof(struct sqlconn, config_file) }, + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct sqlconn, config_file) }, { "config-group", N_("name"), N_("Read the named group from the SQL configuration file"), - grecs_type_string, NULL, offsetof(struct sqlconn, config_group) }, + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct sqlconn, config_group) }, { "host", N_("host"), N_("Set SQL server hostname or IP address"), - grecs_type_string, NULL, 0, cb_sql_host }, + grecs_type_string, GRECS_DFLT, + NULL, 0, cb_sql_host }, { "database", N_("dbname"), N_("Set database name"), - grecs_type_string, NULL, offsetof(struct sqlconn, database), }, + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct sqlconn, database), }, { "user", N_("name"), N_("Set SQL user name"), - grecs_type_string, NULL, offsetof(struct sqlconn, user) }, + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct sqlconn, user) }, { "password", N_("arg"), N_("Set SQL user password"), - grecs_type_string, NULL, offsetof(struct sqlconn, password) }, + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct sqlconn, password) }, { "ssl-ca", N_("file"), N_("File name of the Certificate Authority (CA) certificate"), - grecs_type_string, NULL, offsetof(struct sqlconn, cacert) }, + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct sqlconn, cacert) }, { NULL } }; @@ -701,11 +708,14 @@ static struct grecs_keyword syslog_kw[] = { N_("Set syslog facility. Arg is one of the following: user, daemon, " "auth, authpriv, mail, cron, local0 through local7 (case-insensitive), " "or a facility number."), - grecs_type_string, &log_facility, 0, cb_syslog_facility }, + grecs_type_string, GRECS_DFLT, + &log_facility, 0, cb_syslog_facility }, { "tag", N_("string"), N_("Tag syslog messages with this string"), - grecs_type_string, &syslog_tag }, + grecs_type_string, GRECS_DFLT, + &syslog_tag }, { "print-priority", N_("arg"), N_("Prefix each message with its priority"), - grecs_type_bool, &syslog_include_prio }, + grecs_type_bool, GRECS_DFLT, + &syslog_include_prio }, { NULL }, }; @@ -759,9 +769,11 @@ cb_backup (enum grecs_callback_command cmd, static struct grecs_keyword archive_kw[] = { { "name", N_("file-or-dir"), N_("Name of archive file or directory"), - grecs_type_string, NULL, offsetof(struct archive_descr, name) }, + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct archive_descr, name) }, { "backup", N_("type"), N_("Define backup type"), - grecs_type_string, NULL, offsetof(struct archive_descr, backup_type), + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct archive_descr, backup_type), cb_backup }, { NULL } }; @@ -835,13 +847,13 @@ cb_archive (enum grecs_callback_command cmd, static struct grecs_keyword mail_statistics_kw[] = { { "message", N_("text"), N_("Message text"), - grecs_type_string, &admin_stat_message }, + grecs_type_string, GRECS_DFLT, &admin_stat_message }, { "statistics", N_("items"), N_("Send mail if one or more of these items are set"), - grecs_type_string, &mail_admin_mask, 0, cb_statistics }, + grecs_type_string, GRECS_DFLT, &mail_admin_mask, 0, cb_statistics }, { "gpg-sign", N_("key"), N_("Sign message with this key"), - grecs_type_string, &admin_stat_sign_key }, + grecs_type_string, GRECS_DFLT, &admin_stat_sign_key }, { NULL } }; @@ -879,16 +891,20 @@ cb_recipient (enum grecs_callback_command cmd, static struct grecs_keyword notify_event_kw[] = { { "event", N_("ev-id"), N_("Event on which to notify"), - grecs_type_string, NULL, offsetof(struct notification, ev), cb_event }, + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct notification, ev), cb_event }, { "recipient", N_("who"), N_("Notify this recipient"), - grecs_type_string, NULL, offsetof(struct notification, tgt), + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct notification, tgt), cb_recipient }, { "message", N_("text-or-id"), N_("Text of the notification or identifier of a defined message template"), - grecs_type_string, NULL, offsetof(struct notification, msg) }, + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct notification, msg) }, { "gpg-sign", N_("key"), N_("Sign message with this key"), - grecs_type_string, NULL, offsetof(struct notification, sign_keys) }, + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct notification, sign_keys) }, { NULL } }; @@ -1011,13 +1027,15 @@ cb_dictionary_params (enum grecs_callback_command cmd, static struct grecs_keyword dictionary_kw[] = { { "type", N_("type"), N_("Dictionary type"), - grecs_type_string, NULL, offsetof(struct dictionary, type), + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct dictionary, type), cb_dictionary_type }, { "query", N_("string"), N_("Query template"), - grecs_type_string, NULL, offsetof(struct dictionary, query) }, + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct dictionary, query) }, { "params", N_("arg"), N_("Set dictionary parameters"), - grecs_type_string|GRECS_LIST, NULL, 0, - cb_dictionary_params }, + grecs_type_string, GRECS_LIST, + NULL, 0, cb_dictionary_params }, { NULL } }; @@ -1124,28 +1142,37 @@ cb_url (enum grecs_callback_command cmd, static struct grecs_keyword spool_kw[] = { { "url", N_("arg"), N_("URL corresponding to this spool"), - grecs_type_string, NULL, offsetof(struct spool, url) }, + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct spool, url) }, { "alias", N_("arg"), N_("Aliases"), - grecs_type_string|GRECS_LIST, NULL, offsetof(struct spool, aliases) }, + grecs_type_string, GRECS_LIST, + NULL, offsetof(struct spool, aliases) }, { "source", N_("dir"), N_("Source directory"), - grecs_type_string, NULL, offsetof(struct spool, source_dir) }, + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct spool, source_dir) }, { "destination", N_("dir"), N_("Destination directory"), - grecs_type_string, NULL, offsetof(struct spool, dest_url), + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct spool, dest_url), cb_url }, { "file-sweep-time", N_("interval"), N_("Define file sweep time"), - grecs_type_string, NULL, offsetof(struct spool, file_sweep_time), + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct spool, file_sweep_time), cb_interval }, { "dictionary", N_("ident"), N_("Define data dictionary"), - grecs_type_section, NULL, offsetof(struct spool, dictionary), + grecs_type_section, GRECS_DFLT, + NULL, offsetof(struct spool, dictionary), cb_dictionary, NULL, dictionary_kw }, { "archive", N_("type: string"), N_("Set up archivation"), - grecs_type_section, NULL, offsetof(struct spool, archive), + grecs_type_section, GRECS_DFLT, + NULL, offsetof(struct spool, archive), cb_archive, NULL, archive_kw }, { "notify-event", NULL, N_("Configure notification"), - grecs_type_section, NULL, offsetof(struct spool, notification), + grecs_type_section, GRECS_DFLT, + NULL, offsetof(struct spool, notification), cb_notify_event, NULL, notify_event_kw }, { "check-script", NULL, N_("A /bin/sh script to verify the tarball"), - grecs_type_string, NULL, offsetof(struct spool, check_script) }, + grecs_type_string, GRECS_DFLT, + NULL, offsetof(struct spool, check_script) }, { NULL } }; @@ -1315,13 +1342,13 @@ cb_supp_groups (enum grecs_callback_command cmd, static struct grecs_keyword locking_kw[] = { { "enable", NULL, N_("Enable or disable locking"), - grecs_type_bool, &enable_locking }, + grecs_type_bool, GRECS_DFLT, &enable_locking }, { "directory", N_("dir"), N_("Set directory for lock files"), - grecs_type_string, &lockdir }, + grecs_type_string, GRECS_DFLT, &lockdir }, { "expire-time", N_("interval"), N_("Define lock expiration interval"), - grecs_type_string, &lock_expire_time, 0, cb_interval }, + grecs_type_string, GRECS_DFLT, &lock_expire_time, 0, cb_interval }, { "timeout", N_("interval"), N_("Locking timeout"), - grecs_type_string, &lock_timeout, 0, cb_interval }, + grecs_type_string, GRECS_DFLT, &lock_timeout, 0, cb_interval }, { NULL } }; @@ -1345,98 +1372,139 @@ cb_locking (enum grecs_callback_command cmd, } return 0; } + +static int +cb_upload_version (enum grecs_callback_command cmd, + grecs_locus_t *locus, + void *varptr, + grecs_value_t *value, + void *cb_data) +{ + unsigned *pversion = varptr, n; + + if (assert_string_arg (locus, cmd, value)) + return 1; + if (directive_pack_version (value->v.string, &n)) + { + grecs_error (&value->locus, 0, _("invalid version number")); + return 0; + } + + if (n < MIN_DIRECTIVE_VERSION) + { + grecs_error (&value->locus, 0, _("version number too low")); + return 0; + } + + if (n > MAX_DIRECTIVE_VERSION) + { + grecs_error (&value->locus, 0, _("version number too high")); + return 0; + } + *pversion = n; + return 0; +} static struct grecs_keyword wydawca_kw[] = { { "daemon", NULL, N_("Enable daemon mode"), - grecs_type_bool, &daemon_mode }, + grecs_type_bool, GRECS_DFLT, &daemon_mode }, { "foreground", NULL, N_("Start in foreground even in daemon mode"), - grecs_type_bool, &foreground }, + grecs_type_bool, GRECS_DFLT, &foreground }, { "single-process", NULL, N_("Do not spawn subprocesses"), - grecs_type_bool, &single_process }, + grecs_type_bool, GRECS_DFLT, &single_process }, { "wakeup-interval", N_("time"), N_("Set wake-up interval"), - grecs_type_string, &wakeup_interval, 0, cb_interval }, + grecs_type_string, GRECS_DFLT, &wakeup_interval, 0, cb_interval }, { "pidfile", N_("file"), N_("Set pid file name"), - grecs_type_string, &pidfile }, + grecs_type_string, GRECS_DFLT, &pidfile }, { "user", N_("name"), N_("Run with UID and GID of this user"), - grecs_type_string, NULL, 0, cb_user }, + grecs_type_string, GRECS_DFLT, NULL, 0, cb_user }, { "group", NULL, N_("Retain these supplementary groups"), - grecs_type_string|GRECS_LIST, NULL, 0, cb_supp_groups }, - + grecs_type_string, GRECS_LIST, NULL, 0, cb_supp_groups }, + + { "min-version", N_("major.minor"), + N_("Set minimal allowed directive file version"), + grecs_type_string, GRECS_DFLT, + &min_directive_version, 0, cb_upload_version }, + { "max-version", N_("major.minor"), + N_("Set maximal allowed directive file version"), + grecs_type_string, GRECS_DFLT, + &max_directive_version, 0, cb_upload_version }, + { "locking", NULL, N_("Configure locking"), - grecs_type_section, NULL, 0, + grecs_type_section, GRECS_DFLT, NULL, 0, cb_locking, NULL, locking_kw }, { "listen", N_("socket"), N_("Listen on this address"), - grecs_type_sockaddr, &listen_sockaddr, }, + grecs_type_sockaddr, GRECS_DFLT, &listen_sockaddr, }, #ifdef WITH_LIBWRAP { "tcp-wrapper", NULL, N_("Configure TCP wrappers"), - grecs_type_section, NULL, 0, + grecs_type_section, GRECS_DFLT, NULL, 0, NULL, NULL, tcpwrapper_kw }, #endif { "mailer", N_("url"), N_("Set mailer URL"), - grecs_type_string, &mailer, 0, cb_mailer }, + grecs_type_string, GRECS_DFLT, &mailer, 0, cb_mailer }, { "admin-address", N_("email"), N_("Set admin email address"), - grecs_type_string, &admin_address, 0, cb_email_address }, + grecs_type_string, GRECS_DFLT, &admin_address, 0, cb_email_address }, { "from-address", N_("email"), N_("Set sender email address"), - grecs_type_string, &from_address, 0, cb_email_address }, + grecs_type_string, GRECS_DFLT, &from_address, 0, cb_email_address }, /* FIXME: Must be a built-in type? */ { "file-sweep-time", N_("interval"), N_("Define file sweep time"), - grecs_type_string, &file_sweep_time, 0, cb_interval }, + grecs_type_string, GRECS_DFLT, &file_sweep_time, 0, cb_interval }, { "tar-program", N_("prog"), N_("Set tar invocation command line"), - grecs_type_string, &tar_command_name, 0, cb_absolute_name }, + grecs_type_string, GRECS_DFLT, &tar_command_name, 0, cb_absolute_name }, { "umask", N_("mask: octal"), N_("Set umask"), - grecs_type_string, NULL, 0, cb_set_umask }, + grecs_type_string, GRECS_DFLT, NULL, 0, cb_set_umask }, { "archive-signatures", NULL, N_("Control implicit signature archivation"), - grecs_type_bool, &archive_signatures }, + grecs_type_bool, GRECS_DFLT, &archive_signatures }, { "statistics", N_("items"), N_("Print these stats at the end of run"), - grecs_type_string, &print_stats, 0, cb_statistics }, + grecs_type_string, GRECS_DFLT, &print_stats, 0, cb_statistics }, { "sql", N_("id: string"), N_("Define SQL database"), - grecs_type_section, NULL, 0, cb_sql, NULL, sql_kw }, + grecs_type_section, GRECS_DFLT, NULL, 0, cb_sql, NULL, sql_kw }, { "syslog", NULL, N_("Configure syslog logging"), - grecs_type_section, NULL, 0, NULL, NULL, syslog_kw }, + grecs_type_section, GRECS_DFLT, NULL, 0, NULL, NULL, syslog_kw }, { "define-message", N_("ident: string> <text: string"), N_("Define message text"), - grecs_type_string, NULL, 0, cb_define_message }, + grecs_type_string, GRECS_DFLT, NULL, 0, cb_define_message }, { "archive", N_("type: string"), N_("Set up archivation"), - grecs_type_section, &default_archive_descr, 0, + grecs_type_section, GRECS_DFLT, &default_archive_descr, 0, cb_archive, NULL, archive_kw }, { "mail-statistics", NULL, N_("Send statistics"), - grecs_type_section, NULL, 0, NULL, NULL, mail_statistics_kw }, + grecs_type_section, GRECS_DFLT, NULL, 0, NULL, NULL, mail_statistics_kw }, { "notify-event", NULL, N_("Configure notification"), - grecs_type_section, &default_notification, 0, + grecs_type_section, GRECS_DFLT, &default_notification, 0, cb_notify_event, NULL, notify_event_kw }, { "dictionary", N_("ident"), N_("Define data dictionary"), - grecs_type_section, default_dictionary, 0, + grecs_type_section, GRECS_DFLT, default_dictionary, 0, cb_dictionary, NULL, dictionary_kw }, { "check-script", NULL, N_("A /bin/sh script to verify tarballs"), - grecs_type_string, &default_check_script }, + grecs_type_string, GRECS_DFLT, &default_check_script }, { "spool", N_("tag: string"), N_("Define distribution spool"), - grecs_type_section, NULL, 0, + grecs_type_section, GRECS_DFLT, NULL, 0, cb_spool, NULL, spool_kw }, { "all-spools", NULL, N_("Service names that request scanning all spools"), - grecs_type_string|GRECS_LIST, &all_spool_aliases }, + grecs_type_string, GRECS_LIST, &all_spool_aliases }, { "gpg-homedir", NULL, N_("GPG home directory"), - grecs_type_string, &wydawca_gpg_homedir }, + grecs_type_string, GRECS_DFLT, &wydawca_gpg_homedir }, { NULL } }; diff --git a/src/directive.c b/src/directive.c index 119b221..8893675 100644 --- a/src/directive.c +++ b/src/directive.c @@ -1,5 +1,5 @@ /* wydawca - automatic release submission daemon - Copyright (C) 2007-2008, 2010-2011 Sergey Poznyakoff + Copyright (C) 2007-2008, 2010-2012 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 @@ -162,6 +162,13 @@ directive_pack_version (const char *val, unsigned *pversion) return 0; } +int +directive_unpack_version (unsigned version, char **pbuf, size_t *psize) +{ + return grecs_asprintf (pbuf, psize, "%u.%u", + version / 100, version % 100); +} + /* Return true if the directory file version of the triplet TRP is within the inclusive range FROM and TO (packed) */ int @@ -177,14 +184,18 @@ directive_version_in_range_p (struct file_triplet *trp, trp->file[file_directive].name); return 0; } - + if (directive_pack_version (val, &version)) { logmsg (LOG_ERR, _("%s: unparsable version: %s"), trp->file[file_directive].name, val); return 0; } - + logmsg (LOG_NOTICE, _("%s: VERSION: %s"), + trp->file[file_directive].name, val); + + trp->version = version; + if (from <= version && version <= to) return 1; @@ -202,7 +213,8 @@ enum directive filename_dir, rmsymlink_dir, archive_dir, - symlink_dir + symlink_dir, + replace_dir }; struct directive_table @@ -219,6 +231,7 @@ static struct directive_table directive_table[] = { { "symlink", symlink_dir }, { "rmsymlink", rmsymlink_dir }, { "archive", archive_dir }, + { "replace", replace_dir }, { NULL } }; @@ -240,8 +253,8 @@ verify_directive_format (struct file_triplet *trp) int n, dnum; const char *key; - if (!directive_version_in_range_p (trp, MIN_DIRECTIVE_VERSION, - MAX_DIRECTIVE_VERSION)) + if (!directive_version_in_range_p (trp, min_directive_version, + max_directive_version)) return 1; dnum = 0; @@ -674,6 +687,15 @@ process_directives (struct file_triplet *trp) case rmsymlink_dir: if (rmsymlink_file (trp, val)) return 1; + + case replace_dir: + if (trp->version < 102) + { + rc = 1; + logmsg (LOG_ERR, + _("\"replace\" directive is invalid for version %d"), + trp->version); + } } } diff --git a/src/diskio.c b/src/diskio.c index 2e61d49..bab5cb8 100644 --- a/src/diskio.c +++ b/src/diskio.c @@ -1,5 +1,5 @@ /* wydawca - automatic release submission daemon - Copyright (C) 2007-2011 Sergey Poznyakoff + Copyright (C) 2007-2012 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 @@ -398,6 +398,19 @@ do_archive_file (const char *dst_file, const char *dst_dir, const char *file, return 0; } +static int +replace_allowed_p (struct file_triplet *trp) +{ + const char *val; + + if (trp->version < 102) + return 1; + + if (directive_get_value (trp, "replace", &val)) + return 1; + return strcmp (val, "true") == 0; +} + /* Move the part FILE_ID of the triplet TRP between the directories in TRP->SPOOL. TRP->RELATIVE_DIR gives relative directory (i.e. the directory part of the file name) for backup purposes. @@ -420,8 +433,21 @@ dir_move_file (struct file_triplet *trp, enum file_type file_id) dst_dir); if (access (dst_file, F_OK) == 0) - rc = do_archive_file (dst_file, dst_dir, trp->file[file_id].name, - &spool->archive, trp->relative_dir); + { + if (replace_allowed_p (trp)) + rc = do_archive_file (dst_file, dst_dir, trp->file[file_id].name, + &spool->archive, trp->relative_dir); + else + { + logmsg (LOG_ERR, + _("refusing to upload %s because it already exists " + "and replace is not allowed"), + trp->file[file_id].name); + free (dst_file); + free (dst_dir); + return 1; + } + } if (!dry_run_mode && rc == 0) rc = do_move_file (trp->file[file_id].name, dst_file); diff --git a/src/tcpwrap.c b/src/tcpwrap.c index 8ece4c8..3c29f31 100644 --- a/src/tcpwrap.c +++ b/src/tcpwrap.c @@ -44,24 +44,24 @@ cb_syslog_priority (enum grecs_callback_command cmd, struct grecs_keyword tcpwrapper_kw[] = { { "enable", NULL, N_("Enable TCP wrapper access con |