summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorniallo <niallo@openbsd.org>2006-01-29 17:50:08 +0000
committerniallo <niallo@openbsd.org>2006-01-29 17:50:08 +0000
commit683614894037ab48ae91df3828bf20eda6473144 (patch)
tree92329ac1541ace4c896176f955f0bddcbb0f6c9f
parentethernet -> Ethernet (diff)
downloadwireguard-openbsd-683614894037ab48ae91df3828bf20eda6473144.tar.xz
wireguard-openbsd-683614894037ab48ae91df3828bf20eda6473144.zip
- fix a bug where co -l would fail with "permission denied" if the working
file was read-only. ok joris@
-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);