summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2011-06-23 11:43:14 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2011-06-23 11:43:14 +0000
commitfb7575877289f437012013ff386acf9d4277192d (patch)
tree62cee6dfa17faeedf0e14bd0d89d164c3009aa38
parent5a2b3c69e35c272e72dfbde6b832f8f92a716bc2 (diff)
set set*id bits only if the target did not exist and -p was not used;
from netbsd, prompted by Jesus Sanchez. ok miller@
-rw-r--r--bin/cp/utils.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index 4a28cd50b2e..d17f1b2b8ad 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utils.c,v 1.30 2009/10/27 23:59:21 deraadt Exp $ */
+/* $OpenBSD: utils.c,v 1.31 2011/06/23 11:43:13 otto Exp $ */
/* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */
/*-
@@ -178,7 +178,8 @@ copy_file(FTSENT *entp, int dne)
*/
#define RETAINBITS \
(S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
- else if (fs->st_mode & (S_ISUID | S_ISGID) && fs->st_uid == myuid) {
+ if (!pflag && dne &&
+ fs->st_mode & (S_ISUID | S_ISGID) && fs->st_uid == myuid) {
if (fstat(to_fd, &to_stat)) {
warn("%s", to.p_path);
rval = 1;