diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2015-12-26 18:11:44 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2015-12-26 18:11:44 +0000 |
commit | 1184d8dc2fe2130236aefe4c423bd50de659925a (patch) | |
tree | 27b9b05114b5db17d27b937118bc3fdf0b9ede14 /bin/mv | |
parent | 630d3a6df4996a666561afc039a4b7bb3c0e2a4c (diff) |
Set the times, mode, and flags on symlinks when doing cp -p (or mv across
filesystems)
problem noted by Carsten Kunze (carsten.kunze (at) arcor.de)
Diffstat (limited to 'bin/mv')
-rw-r--r-- | bin/mv/cp.c | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/bin/mv/cp.c b/bin/mv/cp.c index eec87a04a94..aefc8bfd3c4 100644 --- a/bin/mv/cp.c +++ b/bin/mv/cp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cp.c,v 1.5 2015/11/17 19:11:11 tedu Exp $ */ +/* $OpenBSD: cp.c,v 1.6 2015/12/26 18:11:43 guenther Exp $ */ /* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */ /* @@ -79,7 +79,6 @@ static int copy_file(FTSENT *, int); static int copy_link(FTSENT *, int); static int copy_special(struct stat *, int); static int setfile(struct stat *, int); -static int setlink(struct stat *); extern char *__progname; @@ -387,7 +386,7 @@ copy(char *argv[], enum op type, int fts_options) } -/* $OpenBSD: cp.c,v 1.5 2015/11/17 19:11:11 tedu Exp $ */ +/* $OpenBSD: cp.c,v 1.6 2015/12/26 18:11:43 guenther Exp $ */ /* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */ /*- @@ -587,7 +586,7 @@ copy_link(FTSENT *p, int exists) warn("symlink: %s", linkname); return (1); } - return (setlink(p->fts_statp)); + return (setfile(p->fts_statp, -1)); } static int @@ -671,17 +670,3 @@ setfile(struct stat *fs, int fd) } return (rval); } - - -static int -setlink(struct stat *fs) -{ - - if (lchown(to.p_path, fs->st_uid, fs->st_gid)) { - if (errno != EPERM) { - warn("lchown: %s", to.p_path); - return (1); - } - } - return (0); -} |