On 2012-04-29 3:09 PM, Tethys wrote:
Paul Vixie writes:
did you know that if there's a corrupt .mh_sequences file,
"rcvstore" won't run?
Sadly, yes I do :-( Given that all of my mail is stored in folders
on arrival using rcvstore, it's a pain in the arse when a broken
.mh_sequences prevents that from happening...
well in 2003 i finally fixed the underlying lock logic error that caused
it. i know i've sent these for incorporation but i've not checked to see
if they made it in.
diff -u -r work/nmh-1.0.4/sbr/context_read.c
work.save/nmh-1.0.4/sbr/context_read.c
--- work/nmh-1.0.4/sbr/context_read.c Fri Apr 30 18:08:34 1999
+++ work.save/nmh-1.0.4/sbr/context_read.c Mon Apr 21 04:49:58 2003
@@ -104,8 +104,8 @@
if (!(cp = getenv ("MHCONTEXT")) || *cp == '\0')
cp = context;
ctxpath = getcpy (m_maildir (cp));
- if ((ib = fopen (ctxpath, "r"))) {
+ if ((ib = lkfopen (ctxpath, "r"))) {
readconfig ((struct node **) 0, ib, cp, 1);
- fclose (ib);
+ lkfclose (ib, ctxpath);
}
}
Binary files work/nmh-1.0.4/sbr/context_read.o and
work.save/nmh-1.0.4/sbr/context_read.o differ
diff -u -r work/nmh-1.0.4/sbr/context_save.c
work.save/nmh-1.0.4/sbr/context_save.c
--- work/nmh-1.0.4/sbr/context_save.c Fri Apr 30 18:08:34 1999
+++ work.save/nmh-1.0.4/sbr/context_save.c Mon Apr 21 04:48:25 2003
@@ -37,12 +37,12 @@
sigaddset (&set, SIGTERM);
SIGPROCMASK (SIG_BLOCK, &set, &oset);
- if (!(out = fopen (ctxpath, "w")))
+ if (!(out = lkfopen (ctxpath, "w")))
adios (ctxpath, "unable to write");
for (np = m_defs; np; np = np->n_next)
if (np->n_context)
fprintf (out, "%s: %s\n", np->n_name, np->n_field);
- fclose (out);
+ lkfclose (out, ctxpath);
SIGPROCMASK (SIG_SETMASK, &oset, &set); /* reset the signal mask */
Binary files work/nmh-1.0.4/sbr/context_save.o and
work.save/nmh-1.0.4/sbr/context_save.o differ
Binary files work/nmh-1.0.4/sbr/libmh.a and work.save/nmh-1.0.4/sbr/libmh.a
differ
diff -u -r work/nmh-1.0.4/sbr/lock_file.c work.save/nmh-1.0.4/sbr/lock_file.c
--- work/nmh-1.0.4/sbr/lock_file.c Sun Sep 12 13:50:12 1999
+++ work.save/nmh-1.0.4/sbr/lock_file.c Thu Apr 24 20:04:50 2003
@@ -177,10 +177,22 @@
if (strcmp (mode, "r") == 0)
access = O_RDONLY;
- else
+ else if (strcmp (mode, "r+") == 0)
access = O_RDWR;
+ else if (strcmp (mode, "w") == 0)
+ access = O_WRONLY | O_CREAT | O_TRUNC;
+ else if (strcmp (mode, "w+") == 0)
+ access = O_RDWR | O_CREAT | O_TRUNC;
+ else if (strcmp (mode, "a") == 0)
+ access = O_WRONLY | O_CREAT | O_APPEND;
+ else if (strcmp (mode, "a+") == 0)
+ access = O_RDWR | O_CREAT | O_APPEND;
+ else {
+ errno = EINVAL;
+ return NULL;
+ }
- if ((fd = lkopen (file, access, 0)) == -1)
+ if ((fd = lkopen (file, access, 0666)) == -1)
return NULL;
if ((fp = fdopen (fd, mode)) == NULL) {
@@ -286,7 +298,8 @@
# endif
# ifdef FLOCK_LOCKING
- if (flock (fd, LOCK_EX | LOCK_NB) != -1)
+ if (flock (fd, (((access & 03) == O_RDONLY) ? LOCK_SH : LOCK_EX)
+ | LOCK_NB) != -1)
return fd;
# endif
--- work/nmh-1.0.4/sbr/seq_read.c Fri Apr 30 18:08:34 1999
+++ work.save/nmh-1.0.4/sbr/seq_read.c Sun Apr 20 17:53:50 2003
@@ -18,7 +18,7 @@
/*
* Get the sequence information for this folder from
- * .mh_sequence (or equivalent specified in .mh_profile)
+ * .mh_sequences (or equivalent specified in .mh_profile)
* or context file (for private sequences).
*/
@@ -73,7 +73,7 @@
/* get filename of sequence file */
snprintf (seqfile, sizeof(seqfile), "%s/%s", mp->foldpath, mh_seq);
- if ((fp = fopen (seqfile, "r")) == NULL)
+ if ((fp = lkfopen (seqfile, "r")) == NULL)
return;
/* Use m_getfld to scan sequence file */
@@ -111,7 +111,7 @@
break; /* break from for loop */
}
- fclose (fp);
+ lkfclose (fp, seqfile);
}
Binary files work/nmh-1.0.4/sbr/seq_read.o and
work.save/nmh-1.0.4/sbr/seq_read.o differ
diff -u -r work/nmh-1.0.4/sbr/seq_save.c work.save/nmh-1.0.4/sbr/seq_save.c
--- work/nmh-1.0.4/sbr/seq_save.c Fri Apr 30 18:08:34 1999
+++ work.save/nmh-1.0.4/sbr/seq_save.c Sun Apr 20 17:53:50 2003
@@ -76,9 +76,9 @@
* If that fails (probably because folder is
* readonly), then make sequence private.
*/
- if ((fp = fopen (seqfile, "w")) == NULL
+ if ((fp = lkfopen (seqfile, "w")) == NULL
&& (unlink (seqfile) == -1 ||
- (fp = fopen (seqfile, "w")) == NULL)) {
+ (fp = lkfopen (seqfile, "w")) == NULL)) {
admonish (attr, "unable to write");
goto priv;
}
@@ -96,7 +96,7 @@
}
if (fp) {
- fclose (fp);
+ lkfclose (fp, seqfile);
SIGPROCMASK (SIG_SETMASK, &oset, &set); /* reset signal mask */
} else {
/*
_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers