summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2006-04-10 19:49:46 +0000
committerJoris Vink <joris@cvs.openbsd.org>2006-04-10 19:49:46 +0000
commitb8f6fc4b89fd368bfa5f6fdededf178314a8cd96 (patch)
treee3b39b4d25287d25b768a1d6e090c21ac4958e9f /usr.bin
parenta3ec948694ddf8e8758f8275087e78b48874e655 (diff)
make sure we add the correct name mkstemp(3) creates for us
to the worklist of temporary files. this way we definatly don't leave any files behind in /tmp. tested & okay niallo@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/buf.c8
-rw-r--r--usr.bin/cvs/worklist.h6
-rw-r--r--usr.bin/rcs/ci.c6
-rw-r--r--usr.bin/rcs/rcsdiff.c10
4 files changed, 14 insertions, 16 deletions
diff --git a/usr.bin/cvs/buf.c b/usr.bin/cvs/buf.c
index 096feb2c670..e6734ddc567 100644
--- a/usr.bin/cvs/buf.c
+++ b/usr.bin/cvs/buf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.c,v 1.44 2006/04/10 19:03:10 niallo Exp $ */
+/* $OpenBSD: buf.c,v 1.45 2006/04/10 19:49:44 joris Exp $ */
/*
* Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -29,6 +29,7 @@
#include "buf.h"
#include "log.h"
#include "xmalloc.h"
+#include "worklist.h"
#define BUF_INCR 128
@@ -375,10 +376,15 @@ cvs_buf_write_stmp(BUF *b, char *template, mode_t mode)
if ((fd = mkstemp(template)) == -1)
fatal("mkstemp: `%s': %s", template, strerror(errno));
+#if defined(RCSPROG)
+ cvs_worklist_add(template, &rcs_temp_files);
+#endif
+
if (cvs_buf_write_fd(b, fd) == -1) {
(void)unlink(template);
fatal("cvs_buf_write_stmp: cvs_buf_write_fd: `%s'", template);
}
+
if (fchmod(fd, mode) < 0)
cvs_log(LP_ERRNO, "permissions not set on temporary file %s",
template);
diff --git a/usr.bin/cvs/worklist.h b/usr.bin/cvs/worklist.h
index e73a14f59c4..8e0dee01674 100644
--- a/usr.bin/cvs/worklist.h
+++ b/usr.bin/cvs/worklist.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: worklist.h,v 1.3 2006/03/15 18:24:43 deraadt Exp $ */
+/* $OpenBSD: worklist.h,v 1.4 2006/04/10 19:49:44 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -40,4 +40,8 @@ void cvs_worklist_clean(struct cvs_wklhead *, void (*cb)(struct cvs_worklist *))
void cvs_worklist_unlink(struct cvs_worklist *);
+#if defined(RCSPROG)
+extern struct cvs_wklhead rcs_temp_files;
+#endif
+
#endif
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c
index 04ed168af9a..ec7ccaa1ee9 100644
--- a/usr.bin/rcs/ci.c
+++ b/usr.bin/rcs/ci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ci.c,v 1.137 2006/04/09 19:22:23 niallo Exp $ */
+/* $OpenBSD: ci.c,v 1.138 2006/04/10 19:49:44 joris Exp $ */
/*
* Copyright (c) 2005, 2006 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
@@ -327,8 +327,6 @@ checkin_diff_file(struct checkin_params *pb)
strlcpy(path1, rcs_tmpdir, sizeof(path1));
strlcat(path1, "/diff1.XXXXXXXXXX", sizeof(path1));
-
- cvs_worklist_add(path1, &rcs_temp_files);
cvs_buf_write_stmp(b1, path1, 0600);
cvs_buf_free(b1);
@@ -336,8 +334,6 @@ checkin_diff_file(struct checkin_params *pb)
strlcpy(path2, rcs_tmpdir, sizeof(path2));
strlcat(path2, "/diff2.XXXXXXXXXX", sizeof(path2));
-
- cvs_worklist_add(path2, &rcs_temp_files);
cvs_buf_write_stmp(b2, path2, 0600);
cvs_buf_free(b2);
diff --git a/usr.bin/rcs/rcsdiff.c b/usr.bin/rcs/rcsdiff.c
index 0a1c60d6120..8178280ee2c 100644
--- a/usr.bin/rcs/rcsdiff.c
+++ b/usr.bin/rcs/rcsdiff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsdiff.c,v 1.44 2006/04/10 08:08:00 xsa Exp $ */
+/* $OpenBSD: rcsdiff.c,v 1.45 2006/04/10 19:49:45 joris Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -208,8 +208,6 @@ rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename)
strlcpy(path1, rcs_tmpdir, sizeof(path1));
strlcat(path1, "/diff1.XXXXXXXXXX", sizeof(path1));
-
- cvs_worklist_add(path1, &rcs_temp_files);
cvs_buf_write_stmp(b1, path1, 0600);
cvs_buf_free(b1);
@@ -220,8 +218,6 @@ rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename)
strlcpy(path2, rcs_tmpdir, sizeof(path2));
strlcat(path2, "/diff2.XXXXXXXXXX", sizeof(path2));
-
- cvs_worklist_add(path2, &rcs_temp_files);
cvs_buf_write_stmp(b2, path2, 0600);
cvs_buf_free(b2);
@@ -289,8 +285,6 @@ rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2)
strlcpy(path1, rcs_tmpdir, sizeof(path1));
strlcat(path1, "/diff1.XXXXXXXXXX", sizeof(path1));
-
- cvs_worklist_add(path1, &rcs_temp_files);
cvs_buf_write_stmp(b1, path1, 0600);
cvs_buf_free(b1);
@@ -301,8 +295,6 @@ rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2)
strlcpy(path2, rcs_tmpdir, sizeof(path2));
strlcat(path2, "/diff2.XXXXXXXXXX", sizeof(path2));
-
- cvs_worklist_add(path2, &rcs_temp_files);
cvs_buf_write_stmp(b2, path2, 0600);
cvs_buf_free(b2);