summaryrefslogtreecommitdiff
path: root/sysutils/safecat
diff options
context:
space:
mode:
authorPeter Pentchev <roam@FreeBSD.org>2000-12-27 11:06:43 +0000
committerPeter Pentchev <roam@FreeBSD.org>2000-12-27 11:06:43 +0000
commitadfb495a5b0778920b33c989c8431f94baba33de (patch)
treee7df18e9c183c949fa3a194c8fba54bf49224967 /sysutils/safecat
parentCorrect libsmpeg version number. (diff)
safecat is an implementation of D. J. Bernstein's maildir algorithm.
It can be used to write mail messages to a qmail-style maildir, or to write data to a "spool" directory reliably.
Notes
Notes: svn path=/head/; revision=36401
Diffstat (limited to 'sysutils/safecat')
-rw-r--r--sysutils/safecat/Makefile25
-rw-r--r--sysutils/safecat/distinfo1
-rw-r--r--sysutils/safecat/files/patch-aa37
-rw-r--r--sysutils/safecat/files/patch-ab10
-rw-r--r--sysutils/safecat/files/patch-ac45
-rw-r--r--sysutils/safecat/files/patch-ad89
-rw-r--r--sysutils/safecat/files/patch-ae9
-rw-r--r--sysutils/safecat/pkg-comment1
-rw-r--r--sysutils/safecat/pkg-descr20
-rw-r--r--sysutils/safecat/pkg-plist2
10 files changed, 239 insertions, 0 deletions
diff --git a/sysutils/safecat/Makefile b/sysutils/safecat/Makefile
new file mode 100644
index 000000000000..11d9d9be7c95
--- /dev/null
+++ b/sysutils/safecat/Makefile
@@ -0,0 +1,25 @@
+# New ports collection makefile for: safecat
+# Date created: 27 November 2000
+# Whom: roam@FreeBSD.org
+#
+# $FreeBSD$
+#
+
+PORTNAME= safecat
+PORTVERSION= 1.4
+CATEGORIES= sysutils mail
+MASTER_SITES= http://www.nb.net/~lbudney/linux/software/safecat/
+
+MAINTAINER= roam@FreeBSD.org
+
+MAN1= safecat.1 maildir.1
+
+do-configure:
+ ${PERL} -pi.fbsd -e "s,/usr/local,${PREFIX}," ${WRKSRC}/conf-root
+ ${PERL} -pi.fbsd -e "s,cc -O2,${CC} ${CFLAGS}," ${WRKSRC}/conf-cc
+ ${PERL} -pi.fbsd -e "s,cc -s,${CC} ${CFLAGS} ${STRIP}," ${WRKSRC}/conf-ld
+
+ALL_TARGET= it
+INSTALL_TARGET= setup check
+
+.include <bsd.port.mk>
diff --git a/sysutils/safecat/distinfo b/sysutils/safecat/distinfo
new file mode 100644
index 000000000000..02f192bcc8f3
--- /dev/null
+++ b/sysutils/safecat/distinfo
@@ -0,0 +1 @@
+MD5 (safecat-1.4.tar.gz) = c94e03c6918c4619c73c22297dced58e
diff --git a/sysutils/safecat/files/patch-aa b/sysutils/safecat/files/patch-aa
new file mode 100644
index 000000000000..bfd397a54164
--- /dev/null
+++ b/sysutils/safecat/files/patch-aa
@@ -0,0 +1,37 @@
+--- Makefile 2000/11/21 08:57:14 1.1.1.1
++++ Makefile 2000/11/21 09:44:08 1.2
+@@ -196,13 +196,17 @@
+ chmod 755 makelib
+
+ open.a: \
+-makelib open_read.o open_trunc.o open_append.o
+- ./makelib open.a open_read.o open_trunc.o open_append.o
++makelib open_read.o open_trunc.o open_append.o open_excl.o
++ ./makelib open.a open_read.o open_trunc.o open_append.o open_excl.o
+
+ open_append.o: \
+ compile open_append.c open.h
+ ./compile open_append.c
+
++open_excl.o: \
++compile open_excl.c open.h
++ ./compile open_excl.c
++
+ open_read.o: \
+ compile open_read.c open.h
+ ./compile open_read.c
+@@ -212,12 +216,12 @@
+ ./compile open_trunc.c
+
+ safecat: \
+-load safecat.o getln.a str.a stralloc.a strerr.a substdio.a alloc.o \
++load safecat.o getln.a str.a stralloc.a strerr.a substdio.a open.a alloc.o \
+ alloc_re.o byte_copy.o byte_cr.o envread.o error.o error_str.o fmt_ulong.o \
+ hostname.o sig.o stat_dir.o str_diffn.o str_len.o substdio_copy.o \
+ substdi.o substdio.o taia_fmtfrac.o taia_now.o taia_tai.o tempfile.o \
+ writefile.o
+- ./load safecat getln.a str.a stralloc.a strerr.a substdio.a \
++ ./load safecat getln.a str.a stralloc.a strerr.a substdio.a open.a \
+ alloc.o alloc_re.o byte_copy.o byte_cr.o envread.o error.o \
+ error_str.o fmt_ulong.o hostname.o sig.o stat_dir.o str_diffn.o \
+ str_len.o substdi.o substdio.o substdio_copy.o taia_fmtfrac.o \
diff --git a/sysutils/safecat/files/patch-ab b/sysutils/safecat/files/patch-ab
new file mode 100644
index 000000000000..f7f8aceb50bb
--- /dev/null
+++ b/sysutils/safecat/files/patch-ab
@@ -0,0 +1,10 @@
+--- TARGETS 2000/11/21 08:57:14 1.1.1.1
++++ TARGETS 2000/11/21 09:43:02 1.2
+@@ -33,6 +33,7 @@
+ makelib
+ open.a
+ open_append.o
++open_excl.o
+ open_read.o
+ open_trunc.o
+ safecat
diff --git a/sysutils/safecat/files/patch-ac b/sysutils/safecat/files/patch-ac
new file mode 100644
index 000000000000..d0d0609e0097
--- /dev/null
+++ b/sysutils/safecat/files/patch-ac
@@ -0,0 +1,45 @@
+--- safecat.1 2000/11/21 08:57:15 1.1.1.1
++++ safecat.1 2000/11/21 10:25:44 1.2
+@@ -80,9 +80,9 @@
+ and
+ .IR destdir ,
+ and exits unless both directories exist and are writable.
+-Second, it
+-.B stat()s
+-the name
++Second, it attempts to
++.B open()
++exclusively the file
+ .BR tempdir/\fItime.pid.host ,
+ where
+ .I time
+@@ -91,22 +91,21 @@
+ is the program's process ID,
+ and
+ .I host
+-is the host name.
++is the host name. The exclusive
++.B open()
++will fail if the file already exists.
+ Third, if
+-.B stat()
+-returned anything other than ENOENT,
++.B open()
++returned EEXIST (the file already exists),
+ the program sleeps for two seconds, updates
+ .IR time ,
+ and tries the
+-.B stat()
++.B open()
+ again, a limited number of times.
+ Fourth, the program
+-creates
+-.BR tempdir/\fItime.pid.host .
+-Fifth, the program
+ .I NFS-writes
+ the message to the file.
+-Sixth, the program
++Fifth, the program
+ .BR link() s
+ the file to
+ .BR destdir/\fItime.pid.host .
diff --git a/sysutils/safecat/files/patch-ad b/sysutils/safecat/files/patch-ad
new file mode 100644
index 000000000000..f754c680d260
--- /dev/null
+++ b/sysutils/safecat/files/patch-ad
@@ -0,0 +1,89 @@
+--- safecat.c 2000/11/21 08:57:15 1.1.1.1
++++ safecat.c 2000/11/21 10:25:22 1.2
+@@ -36,7 +36,6 @@
+ int outfd = 0;
+ stralloc dstpath = {0};
+ stralloc outfile = {0};
+- stralloc outpath = {0};
+ struct stat filestat;
+ unsigned int count = 0;
+
+@@ -57,43 +56,40 @@
+ stat_dir(tempdir);
+ stat_dir(destdir);
+
+- /* Step 2: Stat the temporary file. Wait for ENOENT as a response. */
++ /* Step 2: Create the temporary file. */
++ alarm(86400);
+ for(count=0;;count++) {
+ /* Get the temporary filename to use now for dumping data. */
+ mk_tempfile(&outfile);
+- if (!stralloc_cats(&outpath,tempdir)) die_nomem();
+- if (!stralloc_append(&outpath, "/")) die_nomem();
+- if (!stralloc_cat(&outpath,&outfile)) die_nomem();
+- if(stat(outfile.s,&filestat) == -1 && errno == ENOENT) {
++ if (!stralloc_cats(&tmppath,tempdir)) die_nomem();
++ if (!stralloc_append(&tmppath, "/")) die_nomem();
++ if (!stralloc_cat(&tmppath,&outfile)) die_nomem();
++
++ outfd = open_excl(tmppath.s);
++ if (outfd >= 0) {
++ /* file created successfully */
+ if (!stralloc_cats(&dstpath, destdir)) die_nomem();
+ if (!stralloc_append(&dstpath, "/")) die_nomem();
+ if (!stralloc_cat(&dstpath,&outfile)) die_nomem();
+-
+- if (!stralloc_cats(&tmppath, tempdir)) die_nomem();
+- if (!stralloc_append(&tmppath, "/")) die_nomem();
+- if (!stralloc_cat(&tmppath,&outfile)) die_nomem();
+ break;
+ }
++ if (errno != EEXIST) {
++ /* a "real" error occured, bail out */
++ strerr_die2x(111, "safecat: fatal: ","could not create temporary file");
++ }
+
+- /* Try up to 5 times, every 2 seconds. */
++ /* Step 3: try up to 5 times, every 2 seconds. */
+ if(count == 5) {
+- strerr_die2x(111, "safecat: fatal: ","could not stat temporary file");
++ strerr_die2x(111, "safecat: fatal: ","could not create temporary file");
+ }
+
+ /* Wait 2 seconds, and try again. */
+ stralloc_copys(&outfile,"");
+- stralloc_copys(&outpath,"");
++ stralloc_copys(&tmppath,"");
+ sleep(2);
+ }
+
+- /* Step 4: Create the file tempdir/time.pid.host */
+- alarm(86400);
+- outfd = open(tmppath.s,O_WRONLY | O_EXCL | O_CREAT,0644);
+- if(outfd == -1) {
+- strerr_die2sys(111,"safecat: fatal: ","couldn't create output file: ");
+- }
+-
+- /* Step 5: Copy stdin to the temp file. */
++ /* Step 4: Copy stdin to the temp file. */
+ writefile(outfd);
+
+ /* Close the file, checking the return value. */
+@@ -102,11 +98,16 @@
+ strerr_die2sys(111,"safecat: fatal: ","can't fsync/close output file: ");
+ }
+
+- /* Step 6: Link the temp file to its final destination. */
++ /* Step 5: Link the temp file to its final destination. */
+ if(link(tmppath.s,dstpath.s) == -1) {
+ strerr_die2sys(111,"safecat: fatal: ","can't link output file: ");
+ }
+ /* We've succeeded! Now, no matter what, we return "success" */
++
++ /* Kill the alarm() just in case the 24 hours expire at a most unfortunate
++ time - just after a successful completion (e.g. unlink() over NFS could
++ be slow) */
++ alarm(0);
+
+ /* Okay, delete the temporary file. */
+ unlink(tmppath.s);
diff --git a/sysutils/safecat/files/patch-ae b/sysutils/safecat/files/patch-ae
new file mode 100644
index 000000000000..4b42ba92e90c
--- /dev/null
+++ b/sysutils/safecat/files/patch-ae
@@ -0,0 +1,9 @@
+--- /dev/null Tue Nov 21 12:27:45 2000
++++ open_excl.c Tue Nov 21 11:17:15 2000
+@@ -0,0 +1,6 @@
++#include <sys/types.h>
++#include <fcntl.h>
++#include "open.h"
++
++int open_excl(fn) char *fn;
++{ return open(fn,O_WRONLY | O_EXCL | O_CREAT,0644); }
diff --git a/sysutils/safecat/pkg-comment b/sysutils/safecat/pkg-comment
new file mode 100644
index 000000000000..f4b34a2b6b4d
--- /dev/null
+++ b/sysutils/safecat/pkg-comment
@@ -0,0 +1 @@
+Safely write data to a directory using D. J. Bernstein's Maildir ideology
diff --git a/sysutils/safecat/pkg-descr b/sysutils/safecat/pkg-descr
new file mode 100644
index 000000000000..d2b8e0ff2115
--- /dev/null
+++ b/sysutils/safecat/pkg-descr
@@ -0,0 +1,20 @@
+From the safecat README:
+
+ safecat is an implementation of D. J. Bernstein's maildir algorithm.
+ It can be used to write mail messages to a qmail-style maildir, or to
+ write data to a "spool" directory reliably. There are no lockfiles with
+ safecat, and nothing is left to chance. If safecat returns a successful
+ exit status, then you can be (practically) 100% sure your data is
+ safely committed to disk. Further, if data is written to a directory
+ using safecat (or other implementations of the maildir algorithm),
+ then every file in that directory is guaranteed to be complete. If
+ safecat fails to write all of the data, there will be no file at all
+ in the destination directory.
+
+ Of course, you know that such a thing cannot be: between UNIX and
+ the different hardware options available, a 100% guarantee is not
+ possible. However, safecat takes every precaution possible in writing
+ your data.
+
+Author: Len Budney <lbudney@pobox.com>
+WWW: http://www.nb.net/~lbudney/linux/software/safecat.html
diff --git a/sysutils/safecat/pkg-plist b/sysutils/safecat/pkg-plist
new file mode 100644
index 000000000000..2f63b6454255
--- /dev/null
+++ b/sysutils/safecat/pkg-plist
@@ -0,0 +1,2 @@
+bin/safecat
+bin/maildir