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/rcs.c | |
parent | 3594b1e4ab8ba4fad0740eb82aa8e520b2723fa4 (diff) |
properly inherit file permissions.
reported & tested by phessler@
input otto@ deraadt@
ok tobias@
Diffstat (limited to 'usr.bin/cvs/rcs.c')
-rw-r--r-- | usr.bin/cvs/rcs.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index 024dba9e019..0fcc3b4ddc4 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.268 2008/06/10 16:05:04 joris Exp $ */ +/* $OpenBSD: rcs.c,v 1.269 2008/06/10 20:30:17 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -244,6 +244,7 @@ rcs_open(const char *path, int fd, int flags, ...) mode_t fmode; RCSFILE *rfp; va_list vap; + struct stat st; struct rcs_delta *rdp; struct rcs_lock *lkr; @@ -255,6 +256,10 @@ rcs_open(const char *path, int fd, int flags, ...) mode = va_arg(vap, int); va_end(vap); fmode = (mode_t)mode; + } else { + if (fstat(fd, &st) == -1) + fatal("rcs_open: %s: fstat: %s", path, strerror(errno)); + fmode = st.st_mode; } fmode &= ~cvs_umask; @@ -498,6 +503,7 @@ rcs_write(RCSFILE *rfp) } fputs("@\n", fp); } + if (fchmod(fd, rfp->rf_mode) == -1) { saved_errno = errno; (void)unlink(fn); |