summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Eremin <a.eremin@nexenta.com>2013-03-28 00:04:59 +0400
committerGordon Ross <gwr@nexenta.com>2013-03-28 13:58:54 -0400
commit6cdb72227544a5f07e7428e591c2ed84825f4d1f (patch)
tree9184ce361ad0d78fa644a5e1b653088fef8062a0
parente068a72acd1b6e428098d1af72dee9e6ef7c9b12 (diff)
downloadillumos-joyent-6cdb72227544a5f07e7428e591c2ed84825f4d1f.tar.gz
3619 cp -p clobbers permissions/ownership following symbolic links
Reviewed by: Garrett D'Amore <garrett@damore.org> Reviewed by: Richard Lowe <richlowe@richlowe.net> Approved by: Gordon Ross <gwr@nexenta.com>
-rw-r--r--usr/src/cmd/mv/mv.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/usr/src/cmd/mv/mv.c b/usr/src/cmd/mv/mv.c
index dc978c618f..21623afd09 100644
--- a/usr/src/cmd/mv/mv.c
+++ b/usr/src/cmd/mv/mv.c
@@ -20,6 +20,10 @@
*/
/*
+ * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ */
+
+/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -1348,7 +1352,8 @@ chg_time(char *to, struct stat ss)
times[0] = ss.st_atim;
times[1] = ss.st_mtim;
- rc = utimensat(AT_FDCWD, to, times, 0);
+ rc = utimensat(AT_FDCWD, to, times,
+ ISLNK(s1) ? AT_SYMLINK_NOFOLLOW : 0);
#ifdef XPG4
if ((pflg || mve) && rc != 0) {
(void) fprintf(stderr,
@@ -1383,6 +1388,11 @@ static int
chg_mode(char *target, uid_t uid, gid_t gid, mode_t mode)
{
int clearflg = 0; /* controls message printed upon chown() error */
+ struct stat st;
+
+ /* Don't change mode if target is symlink */
+ if (lstat(target, &st) == 0 && ISLNK(st))
+ return (0);
if (chown(target, uid, gid) != 0) {
#ifdef XPG4