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 /src/config.c | |
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.
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 204 |
1 files changed, 136 insertions, 68 deletions
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 } }; |