summaryrefslogtreecommitdiff
path: root/usr.bin/cvs/buf.c
diff options
context:
space:
mode:
authorNiall O'Higgins <niallo@cvs.openbsd.org>2006-01-29 17:50:09 +0000
committerNiall O'Higgins <niallo@cvs.openbsd.org>2006-01-29 17:50:09 +0000
commit5f9aa2572a32293c66ef879e535021e2930fccd6 (patch)
tree2155412e597b39953441397f9086b58bfc7ac00f /usr.bin/cvs/buf.c
parenta577c147289ac444c719bc33f51fd81f01568ed3 (diff)
- fix a bug where co -l would fail with "permission denied" if the working
file was read-only. ok joris@
Diffstat (limited to 'usr.bin/cvs/buf.c')
-rw-r--r--usr.bin/cvs/buf.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/cvs/buf.c b/usr.bin/cvs/buf.c
index 5120fc90ca8..b0a3a8614b3 100644
--- a/usr.bin/cvs/buf.c
+++ b/usr.bin/cvs/buf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.c,v 1.31 2006/01/16 21:02:36 niallo Exp $ */
+/* $OpenBSD: buf.c,v 1.32 2006/01/29 17:50:08 niallo Exp $ */
/*
* Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -375,9 +375,13 @@ int
cvs_buf_write(BUF *b, const char *path, mode_t mode)
{
int fd;
-
- if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)) == -1)
- fatal("open: `%s': %s", path, strerror(errno));
+ open:
+ if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)) == -1) {
+ if ((errno == EACCES) && (unlink(path) != -1))
+ goto open;
+ else
+ fatal("open: `%s': %s", path, strerror(errno));
+ }
if (cvs_buf_write_fd(b, fd) == -1) {
(void)unlink(path);