diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2008-02-29 21:43:58 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2008-02-29 21:43:58 +0000 |
commit | 48a08d65744d3969e41e3c83231c81e8b663e9cd (patch) | |
tree | 7bebca6a3360fb05cd7b57ba247a1e29a6b37e4f /usr.bin | |
parent | b20e1ca6a1bb9fb8ba25ba94a50bdbf952e6714d (diff) |
handle file permissions and owners properly.
matches what gnu cvs does.
fixes the fact that we couldnt update group writable files.
problem report & diff testing by David Crawshaw.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/checkout.c | 13 | ||||
-rw-r--r-- | usr.bin/cvs/client.c | 4 | ||||
-rw-r--r-- | usr.bin/cvs/diff3.c | 6 |
3 files changed, 13 insertions, 10 deletions
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c index 3db000f713c..5e4fa7d2930 100644 --- a/usr.bin/cvs/checkout.c +++ b/usr.bin/cvs/checkout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: checkout.c,v 1.140 2008/02/27 22:34:04 joris Exp $ */ +/* $OpenBSD: checkout.c,v 1.141 2008/02/29 21:43:57 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -424,7 +424,7 @@ checkout_repository(const char *repobase, const char *wdbase) void cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags) { - int cf_kflag, oflags, exists, fd; + int cf_kflag, exists, fd; time_t rcstime; CVSENTRIES *ent; struct timeval tv[2]; @@ -450,16 +450,16 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags) } if (cvs_server_active == 0) { + (void)unlink(cf->file_path); + if (!(co_flags & CO_MERGE)) { - oflags = O_WRONLY | O_TRUNC; if (cf->fd != -1) { exists = 1; (void)close(cf->fd); - } else { - oflags |= O_CREAT; } - cf->fd = open(cf->file_path, oflags); + cf->fd = open(cf->file_path, + O_CREAT | O_WRONLY | O_TRUNC); if (cf->fd == -1) fatal("cvs_checkout_file: open: %s", strerror(errno)); @@ -538,6 +538,7 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags) } } else { if (co_flags & CO_MERGE) { + (void)unlink(cf->file_path); cvs_merge_file(cf, 1); tosend = cf->file_path; fd = cf->fd; diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c index 2f5a1b99d85..a2cdcc74fba 100644 --- a/usr.bin/cvs/client.c +++ b/usr.bin/cvs/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.107 2008/02/28 20:00:56 joris Exp $ */ +/* $OpenBSD: client.c,v 1.108 2008/02/29 21:43:57 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -751,6 +751,7 @@ cvs_client_updated(char *data) xfree(entry); + (void)unlink(fpath); if ((fd = open(fpath, O_CREAT | O_WRONLY | O_TRUNC)) == -1) fatal("cvs_client_updated: open: %s: %s", fpath, strerror(errno)); @@ -828,6 +829,7 @@ cvs_client_merged(char *data) cvs_ent_close(ent, ENT_SYNC); xfree(entry); + (void)unlink(fpath); if ((fd = open(fpath, O_CREAT | O_WRONLY | O_TRUNC)) == -1) fatal("cvs_client_merged: open: %s: %s", fpath, strerror(errno)); diff --git a/usr.bin/cvs/diff3.c b/usr.bin/cvs/diff3.c index 117d0fbc061..34f375eddcd 100644 --- a/usr.bin/cvs/diff3.c +++ b/usr.bin/cvs/diff3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff3.c,v 1.43 2008/02/28 20:35:27 joris Exp $ */ +/* $OpenBSD: diff3.c,v 1.44 2008/02/29 21:43:57 joris Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -72,7 +72,7 @@ static const char copyright[] = #ifndef lint static const char rcsid[] = - "$OpenBSD: diff3.c,v 1.43 2008/02/28 20:35:27 joris Exp $"; + "$OpenBSD: diff3.c,v 1.44 2008/02/29 21:43:57 joris Exp $"; #endif /* not lint */ #include <ctype.h> @@ -247,7 +247,7 @@ cvs_merge_file(struct cvs_file *cf, int verbose) } (void)close(cf->fd); - cf->fd = open(cf->file_path, O_WRONLY | O_TRUNC); + cf->fd = open(cf->file_path, O_CREAT | O_WRONLY | O_TRUNC); if (cf->fd == -1) { fatal("cvs_merge_file: failed to reopen fd for writing: %s", strerror(errno)); |