From: martijn Date: Fri, 7 Sep 2018 07:44:15 +0000 (+0000) Subject: Rename dne in copy_file to exists to be more consistent with the other X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5f1a7403aa232acc60228e32aa7e77b74e92e51c;p=openbsd Rename dne in copy_file to exists to be more consistent with the other copy_* functions. OK stsp@ --- diff --git a/bin/cp/cp.c b/bin/cp/cp.c index 7df43582f5a..23f4245d59b 100644 --- a/bin/cp/cp.c +++ b/bin/cp/cp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cp.c,v 1.48 2018/09/07 07:17:14 martijn Exp $ */ +/* $OpenBSD: cp.c,v 1.49 2018/09/07 07:44:15 martijn Exp $ */ /* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */ /* @@ -434,7 +434,7 @@ copy(char *argv[], enum op type, int fts_options) !fts_dne(curr))) == 1) rval = 1; } else - if ((cval = copy_file(curr, fts_dne(curr))) == 1) + if ((cval = copy_file(curr, !fts_dne(curr))) == 1) rval = 1; if (!cval && vflag) (void)fprintf(stdout, "%s -> %s\n", @@ -447,7 +447,7 @@ copy(char *argv[], enum op type, int fts_options) !fts_dne(curr))) == 1) rval = 1; } else - if ((cval = copy_file(curr, fts_dne(curr))) == 1) + if ((cval = copy_file(curr, !fts_dne(curr))) == 1) rval = 1; if (!cval && vflag) (void)fprintf(stdout, "%s -> %s\n", @@ -458,7 +458,7 @@ copy(char *argv[], enum op type, int fts_options) warnc(EOPNOTSUPP, "%s", curr->fts_path); break; default: - if ((cval = copy_file(curr, fts_dne(curr))) == 1) + if ((cval = copy_file(curr, !fts_dne(curr))) == 1) rval = 1; if (!cval && vflag) (void)fprintf(stdout, "%s -> %s\n", diff --git a/bin/cp/utils.c b/bin/cp/utils.c index 1b431f4944e..fd2af24ba1e 100644 --- a/bin/cp/utils.c +++ b/bin/cp/utils.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utils.c,v 1.43 2018/09/07 07:17:14 martijn Exp $ */ +/* $OpenBSD: utils.c,v 1.44 2018/09/07 07:44:15 martijn Exp $ */ /* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */ /*- @@ -50,7 +50,7 @@ int copy_overwrite(void); int -copy_file(FTSENT *entp, int dne) +copy_file(FTSENT *entp, int exists) { static char *buf; static char *zeroes; @@ -82,7 +82,7 @@ copy_file(FTSENT *entp, int dne) * In -f (force) mode, we always unlink the destination first * if it exists. Note that -i and -f are mutually exclusive. */ - if (!dne && fflag) + if (exists && fflag) (void)unlink(to.p_path); /* @@ -92,7 +92,7 @@ copy_file(FTSENT *entp, int dne) * other choice is 666 or'ed with the execute bits on the from file * modified by the umask.) */ - if (!dne && !fflag) { + if (exists && !fflag) { if (!copy_overwrite()) { (void)close(from_fd); return 2; @@ -174,7 +174,7 @@ copy_file(FTSENT *entp, int dne) */ #define RETAINBITS \ (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) - if (!pflag && dne && + if (!pflag && !exists && fs->st_mode & (S_ISUID | S_ISGID) && fs->st_uid == myuid) { if (fstat(to_fd, &to_stat)) { warn("%s", to.p_path);