diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2008-06-10 20:30:18 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2008-06-10 20:30:18 +0000 |
commit | 553d8a18c295273a72b19fbe92a9567c017ec055 (patch) | |
tree | cfe4924c62451837463ed582cda1acb1f8cb0333 /usr.bin/cvs/checkout.c | |
parent | 3594b1e4ab8ba4fad0740eb82aa8e520b2723fa4 (diff) |
properly inherit file permissions.
reported & tested by phessler@
input otto@ deraadt@
ok tobias@
Diffstat (limited to 'usr.bin/cvs/checkout.c')
-rw-r--r-- | usr.bin/cvs/checkout.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c index 13574b4f511..d4b9fd99f49 100644 --- a/usr.bin/cvs/checkout.c +++ b/usr.bin/cvs/checkout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: checkout.c,v 1.147 2008/06/10 01:00:34 joris Exp $ */ +/* $OpenBSD: checkout.c,v 1.148 2008/06/10 20:30:17 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -430,6 +430,7 @@ checkout_repository(const char *repobase, const char *wdbase) void cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags) { + mode_t mode; int cf_kflag, exists, fd; time_t rcstime; CVSENTRIES *ent; @@ -475,7 +476,10 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags) cvs_merge_file(cf, (cvs_join_rev1 == NULL)); } - if (fchmod(cf->fd, 0644) == -1) + mode = cf->file_rcs->rf_mode; + mode |= S_IWUSR; + + if (fchmod(cf->fd, mode) == -1) fatal("cvs_checkout_file: fchmod: %s", strerror(errno)); if ((exists == 0) && (cf->file_ent == NULL) && @@ -570,6 +574,16 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags) fd = rcs_rev_write_stmp(cf->file_rcs, rnum, template, 0); + + mode = cf->file_rcs->rf_mode; + mode |= S_IWUSR; + + if (fchmod(fd, mode) == -1) { + cvs_log(LP_ERR, + "failed to set mode for %s", + cf->file_path); + } + tosend = template; } |