summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org.ua>2012-05-27 12:11:59 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2012-05-27 12:33:30 (GMT)
commit83d7377354504cf3d92a5bdf9cade07554c6b66e (patch) (side-by-side diff)
tree01d602910d6314edbd5568600e7dfb5b1b215bfa /src
parent5fc301baf79e9cc19b1bc8e7a5940e060611e349 (diff)
downloadwydawca-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.
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/backup.c4
-rw-r--r--src/cmdline.opt4
-rw-r--r--src/config.c204
-rw-r--r--src/directive.c34
-rw-r--r--src/diskio.c32
-rw-r--r--src/tcpwrap.c12
-rw-r--r--src/wydawca.c7
-rw-r--r--src/wydawca.h10
8 files changed, 216 insertions, 91 deletions
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 control. Default is \"yes\"."),
- grecs_type_bool, &tcpwrap_enable },
+ grecs_type_bool, GRECS_DFLT, &tcpwrap_enable },
{ "daemon", N_("name"),
N_("Set daemon name for TCP wrapper lookups. Default is program name."),
- grecs_type_string, &tcpwrap_daemon },
+ grecs_type_string, GRECS_DFLT, &tcpwrap_daemon },
{ "allow-table", N_("file"),
N_("Use file for positive client address access control "
"(default: /etc/hosts.allow)."),
- grecs_type_string, &hosts_allow_table },
+ grecs_type_string, GRECS_DFLT, &hosts_allow_table },
{ "deny-table", N_("file"),
N_("Use file for negative client address access control "
"(default: /etc/hosts.deny)."),
- grecs_type_string, &hosts_deny_table },
+ grecs_type_string, GRECS_DFLT, &hosts_deny_table },
{ "allow-syslog-priority", N_("prio"),
N_("Log host allows at this syslog priority."),
- grecs_type_string, &allow_severity, 0, cb_syslog_priority },
+ grecs_type_string, GRECS_DFLT, &allow_severity, 0, cb_syslog_priority },
{ "deny-syslog-priority", N_("prio"),
N_("Log host denies at this syslog priority."),
- grecs_type_string, &deny_severity, 0, cb_syslog_priority },
+ grecs_type_string, GRECS_DFLT, &deny_severity, 0, cb_syslog_priority },
{ NULL }
};
diff --git a/src/wydawca.c b/src/wydawca.c
index 12f04de..69fb898 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -1,5 +1,5 @@
/* wydawca - automatic release submission daemon
- 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
@@ -50,6 +50,9 @@ struct grecs_sockaddr listen_sockaddr;
unsigned wydawca_stat[MAX_STAT];
+unsigned min_directive_version = MIN_DIRECTIVE_VERSION;
+unsigned max_directive_version = MAX_DIRECTIVE_VERSION;
+
void
initstats ()
{
@@ -342,7 +345,7 @@ main (int argc, char **argv)
argv += optind;
argc -= optind;
- p = gpgme_check_version ("1.2.0");
+ p = gpgme_check_version ("1.1.0");
if (!p)
{
logmsg (LOG_CRIT, _("GPGMe version check failed"));
diff --git a/src/wydawca.h b/src/wydawca.h
index 7ff4412..5de1f3e 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -1,5 +1,5 @@
/* wydawca - automatic release submission daemon
- Copyright (C) 2007-2011 Sergey Poznyakoff
+ Copyright (C) 2007-2012 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -57,7 +57,7 @@
/* The range of directive versions we accept (major * 100 + minor) */
#define MIN_DIRECTIVE_VERSION 101
-#define MAX_DIRECTIVE_VERSION 101
+#define MAX_DIRECTIVE_VERSION 102
/* Default modes for mkdir and creat commands: rely on the umask value */
#define MKDIR_PERMISSIONS 0777
@@ -177,6 +177,7 @@ struct file_triplet
{
char *name; /* Triplet base name */
struct file_info file[FILE_TYPE_COUNT]; /* Components */
+ unsigned version; /* Protocol version */
const struct spool *spool; /* Owning spool */
char *relative_dir; /* Directory relative to spool->dest_dir */
char **directive; /* Decoded directive pairs (key: value\0) */
@@ -368,6 +369,9 @@ extern char *wydawca_gpg_homedir;
extern char *default_check_script;
extern char *temp_homedir;
+extern unsigned min_directive_version;
+extern unsigned max_directive_version;
+
#define UPDATE_STATS(what) \
do \
{ \
@@ -450,6 +454,8 @@ int directive_parse (struct file_triplet *trp);
int directive_get_value (struct file_triplet *trp, const char *key,
const char **pval);
int directive_pack_version (const char *val, unsigned *pversion);
+int directive_unpack_version (unsigned version, char **pbuf, size_t *psize);
+
int directive_version_in_range_p (struct file_triplet *trp,
unsigned from, unsigned to);
int verify_directive_format (struct file_triplet *trp);

Return to:

Send suggestions and report system problems to the System administrator.