summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-12-26 18:11:44 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-12-26 18:11:44 +0000
commit1184d8dc2fe2130236aefe4c423bd50de659925a (patch)
tree27b9b05114b5db17d27b937118bc3fdf0b9ede14 /bin
parent630d3a6df4996a666561afc039a4b7bb3c0e2a4c (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')
-rw-r--r--bin/cp/extern.h3
-rw-r--r--bin/cp/utils.c18
-rw-r--r--bin/mv/cp.c21
3 files changed, 6 insertions, 36 deletions
diff --git a/bin/cp/extern.h b/bin/cp/extern.h
index 91d40d57da6..42b94317c98 100644
--- a/bin/cp/extern.h
+++ b/bin/cp/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.14 2015/01/16 06:39:31 deraadt Exp $ */
+/* $OpenBSD: extern.h,v 1.15 2015/12/26 18:11:43 guenther Exp $ */
/* $NetBSD: extern.h,v 1.3 1995/03/21 09:02:16 cgd Exp $ */
/*-
@@ -50,6 +50,5 @@ int copy_file(FTSENT *, int);
int copy_link(FTSENT *, int);
int copy_special(struct stat *, int);
int setfile(struct stat *, int);
-int setlink(struct stat *);
void usage(void);
__END_DECLS
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index 980244ae679..6a3c5178647 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utils.c,v 1.38 2015/11/16 21:35:58 tedu Exp $ */
+/* $OpenBSD: utils.c,v 1.39 2015/12/26 18:11:43 guenther Exp $ */
/* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */
/*-
@@ -217,7 +217,7 @@ copy_link(FTSENT *p, int exists)
warn("symlink: %s", name);
return (1);
}
- return (pflag ? setlink(p->fts_statp) : 0);
+ return (pflag ? setfile(p->fts_statp, -1) : 0);
}
int
@@ -303,20 +303,6 @@ setfile(struct stat *fs, int fd)
}
-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);
-}
-
-
void
usage(void)
{
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);
-}