diff options
author | Niall O'Higgins <niallo@cvs.openbsd.org> | 2006-03-27 21:56:33 +0000 |
---|---|---|
committer | Niall O'Higgins <niallo@cvs.openbsd.org> | 2006-03-27 21:56:33 +0000 |
commit | 1f65e9054589858f7ce4ca2f2e730a1254c6261a (patch) | |
tree | a85e05e55aef01a8d20f33afdfbc26461adbc0b3 /usr.bin/rcs/co.c | |
parent | 636cc176844d7cb4cc798ddfb37c732892469de4 (diff) |
- properly implement GNU file modes. basically, checkout will inherit
permissions from rcs file and initial checkin will inherit permissions from
working file.
problem spotted by uwe@
ok ray@ xsa@
Diffstat (limited to 'usr.bin/rcs/co.c')
-rw-r--r-- | usr.bin/rcs/co.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/usr.bin/rcs/co.c b/usr.bin/rcs/co.c index 20d2f9c4242..446bf08e6b2 100644 --- a/usr.bin/rcs/co.c +++ b/usr.bin/rcs/co.c @@ -1,4 +1,4 @@ -/* $OpenBSD: co.c,v 1.66 2006/03/24 05:14:48 ray Exp $ */ +/* $OpenBSD: co.c,v 1.67 2006/03/27 21:56:32 niallo Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -316,6 +316,14 @@ checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int flags, */ bp = rcs_kwexp_buf(bp, file, frev); + /* + * File inherits permissions from its ,v file + */ + if (stat(file->rf_path, &st) == -1) + fatal("could not stat rcsfile"); + + mode = st.st_mode; + if (flags & CO_LOCK) { if ((lockname != NULL) && (rcs_lock_add(file, lockname, frev) < 0)) { @@ -323,7 +331,10 @@ checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int flags, return (-1); } - mode = 0644; + /* Strip all write bits from mode */ + mode = st.st_mode & + (S_IXUSR|S_IXGRP|S_IXOTH|S_IRUSR|S_IRGRP|S_IROTH); + mode |= S_IWUSR; if ((verbose == 1) && !(flags & NEWFILE)) printf(" (locked)"); } else if (flags & CO_UNLOCK) { @@ -332,7 +343,9 @@ checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int flags, return (-1); } - mode = 0444; + /* Strip all write bits from mode */ + mode = st.st_mode & + (S_IXUSR|S_IXGRP|S_IXOTH|S_IRUSR|S_IRGRP|S_IROTH); if ((verbose == 1) && !(flags & NEWFILE)) printf(" (unlocked)"); } |