aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/wydawca.texi2
-rw-r--r--src/config.c42
-rw-r--r--src/triplet.c6
-rw-r--r--src/verify.c24
-rw-r--r--src/wydawca.c2
-rw-r--r--src/wydawca.h10
-rw-r--r--tests/cwdrepl.c2
7 files changed, 48 insertions, 40 deletions
diff --git a/doc/wydawca.texi b/doc/wydawca.texi
index 721e026..64a6e36 100644
--- a/doc/wydawca.texi
+++ b/doc/wydawca.texi
@@ -996,7 +996,7 @@ Set the default umask. The @var{value} argument must be an octal number.
@deffn {Config} file-sweep-time time
Consider triplet expired if its oldest file was created more than
@var{time} seconds ago. @xref{time interval specification}, for the
-syntax of @var{time}.
+syntax of @var{time}. Default is 300 seconds.
This parameter may also be set for each spool
individually. @xref{spool, file-sweep-time}.
diff --git a/src/config.c b/src/config.c
index 3be3a00..9d78ed3 100644
--- a/src/config.c
+++ b/src/config.c
@@ -359,8 +359,8 @@ static struct keyword stat_tab[] = {
};
static int
-parse_single_statmask(grecs_locus_t * locus, const grecs_value_t * val,
- unsigned long *pmask, int *invert)
+parse_single_statmask(grecs_locus_t *locus, const grecs_value_t *val,
+ unsigned long *pmask)
{
const char *arg;
int x;
@@ -374,12 +374,10 @@ parse_single_statmask(grecs_locus_t * locus, const grecs_value_t * val,
arg = val->v.string;
if (strcmp(arg, "all") == 0) {
- *pmask = WY_STAT_MASK_ALL;
- *invert = 1;
+ *pmask |= WY_STAT_MASK_ALL;
return 0;
} else if (strcmp(arg, "none") == 0) {
- *pmask = WY_STAT_MASK_NONE;
- *invert = 0;
+ *pmask &= ~WY_STAT_MASK_ALL;
return 0;
}
@@ -387,48 +385,37 @@ parse_single_statmask(grecs_locus_t * locus, const grecs_value_t * val,
grecs_error(&val->locus, 0, _("unknown statistics type: %s"), arg);
return 1;
}
- *pmask = WY_STAT_MASK(x);
+ *pmask |= WY_STAT_MASK(x);
return 0;
}
static int
-parse_statmask(grecs_locus_t * loc, grecs_value_t * val,
- unsigned long *pmask)
+parse_statmask(grecs_locus_t *loc, grecs_value_t *val, unsigned long *pmask)
{
int err = 0;
- int invert = 0;
- unsigned long mask = 0;
+ unsigned long mask = *pmask;
int i;
struct grecs_list_entry *ep;
switch (val->type) {
case GRECS_TYPE_STRING:
- err = parse_single_statmask(loc, val, &mask, &invert);
+ err = parse_single_statmask(loc, val, &mask);
break;
case GRECS_TYPE_ARRAY:
for (i = 0; i < val->v.arg.c; i++) {
- unsigned long x;
- if (parse_single_statmask(loc, val->v.arg.v[i], &x, &invert))
+ if (parse_single_statmask(loc, val->v.arg.v[i], &mask)) {
err = 1;
- else if (invert)
- mask &= ~x;
- else
- mask |= x;
+ }
}
break;
case GRECS_TYPE_LIST:
for (ep = val->v.list->head; ep; ep = ep->next) {
const grecs_value_t *vp = ep->data;
- unsigned long x;
- if (parse_single_statmask(loc, vp, &x, &invert))
+ if (parse_single_statmask(loc, vp, &mask))
err = 1;
- else if (invert)
- mask &= ~x;
- else
- mask |= x;
}
break;
}
@@ -1736,4 +1723,11 @@ config_finish(struct grecs_node *tree)
err = 0;
if (for_each_spool(create_spool_dirs, &err) || err)
exit(EX_CONFIG);
+
+ 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);
+ }
}
diff --git a/src/triplet.c b/src/triplet.c
index 2ad4e1d..bde3c14 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -276,6 +276,7 @@ register_file(struct file_info *finfo, struct spool *spool)
triplet_list_lock(&triplet_pending_list);
if (install) {
+ ret->directive_verified = DIRECTIVE_UNCHECKED;
ret->spool = spool;
ret->acc = grecs_txtacc_create();
} else if (ret->list)
@@ -325,7 +326,7 @@ static enum triplet_state
check_triplet_state(struct wy_triplet *trp)
{
if (trp->file[file_directive].name) {
- if (verify_directive_file(trp))
+ if (verify_directive_file(trp) != DIRECTIVE_GOOD)
return triplet_bad;
if (trp->file[file_dist].name == 0 &&
@@ -479,9 +480,6 @@ triplet_expired_p(struct wy_triplet *trp)
now = time(NULL);
ttl = trp->spool->file_sweep_time;
- if (ttl == 0)
- return 0;
-
for (i = 0; i < FILE_TYPE_COUNT; i++) {
if (trp->file[i].name && (now - trp->file[i].sb.st_mtime) >= ttl) {
wy_debug(1, (_("file %s expired"), trp->file[i].name));
diff --git a/src/verify.c b/src/verify.c
index ebdc399..39626f3 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -177,23 +177,23 @@ uploader_find_frp(struct wy_user *list, const char *fpr)
return list;
}
-int
-verify_directive_file(struct wy_triplet *trp)
+static int
+real_verify_directive_file(struct wy_triplet *trp)
{
if (!trp->file[file_directive].name)
- return 1;
+ return DIRECTIVE_UNCHECKED;
if (fill_project_name(trp))
- return 1;
+ return DIRECTIVE_BAD;
if (!wy_triplet_get_uploaders(trp))
- return 1;
+ return DIRECTIVE_BAD;
if (verify_directive_signature(trp)) {
/*FIXME: Update stats */
wy_log(LOG_ERR, _("invalid signature for %s"),
trp->name ? trp->name : "[unknown]");
- return 1;
+ return DIRECTIVE_BAD;
} else
wy_debug(1, (_("%s: directive file signature OK"), trp->name));
@@ -204,7 +204,15 @@ verify_directive_file(struct wy_triplet *trp)
}
if (verify_directive_format(trp))
- return 1;
+ return DIRECTIVE_BAD;
- return 0;
+ return DIRECTIVE_GOOD;
+}
+
+int
+verify_directive_file(struct wy_triplet *trp)
+{
+ if (trp->directive_verified == DIRECTIVE_UNCHECKED)
+ trp->directive_verified = real_verify_directive_file(trp);
+ return trp->directive_verified;
}
diff --git a/src/wydawca.c b/src/wydawca.c
index 58f87ce..01ef56c 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -33,7 +33,7 @@ int wy_log_facility = LOG_LOCAL1;
char *wy_syslog_tag = "wydawca";
int syslog_include_prio; /* syslog messages include priority */
unsigned long print_stats; /* Print final statistics output */
-time_t file_sweep_time = 0;
+time_t file_sweep_time = DEFAULT_FILE_SWEEP_TIME;
char *tar_command_name = "tar";
int archive_signatures = 1; /* Archive sig files by default */
diff --git a/src/wydawca.h b/src/wydawca.h
index 467daa0..90a886e 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -60,7 +60,7 @@
#define SP(s) ((s) ? (s) : "NONE")
-#define WYDAWCA_EX_AGAIN 1
+#define DEFAULT_FILE_SWEEP_TIME 300
/* The range of directive versions we accept (major * 100 + minor) */
#define MIN_DIRECTIVE_VERSION 101
@@ -171,11 +171,19 @@ struct file_info {
struct stat sb;
};
+/* Values for the triplet directive_verified member */
+enum {
+ DIRECTIVE_UNCHECKED = -1,
+ DIRECTIVE_GOOD = 0,
+ DIRECTIVE_BAD = 1
+};
+
/* File triplet */
struct wy_triplet {
char *name; /* Triplet base name */
struct file_info file[FILE_TYPE_COUNT]; /* Components */
unsigned version; /* Protocol version */
+ int directive_verified; /* Directive file verification result */
struct spool *spool; /* Owning spool */
char *relative_dir; /* Directory relative to spool->dest_dir */
char **directive; /* Decoded directive pairs (key: value\0) */
diff --git a/tests/cwdrepl.c b/tests/cwdrepl.c
index 9394520..85ee4ad 100644
--- a/tests/cwdrepl.c
+++ b/tests/cwdrepl.c
@@ -40,7 +40,7 @@ LICENSE
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program. If not, see <http://www.gnu.org/licenses/>. */
+ with this program. If not, see <http://www.gnu.org/licenses/>.
HISTORY

Return to:

Send suggestions and report system problems to the System administrator.