From fb7575877289f437012013ff386acf9d4277192d Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Thu, 23 Jun 2011 11:43:14 +0000 Subject: set set*id bits only if the target did not exist and -p was not used; from netbsd, prompted by Jesus Sanchez. ok miller@ --- bin/cp/utils.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bin/cp') 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; -- cgit v1.2.3