From 744241c82cd762a5877e599898e6c13adc9b4fe3 Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Fri, 20 Sep 2019 17:24:42 +0900 Subject: [PATCH] Skip chmod operation about symbolic link when copy the file attribute. Change-Id: I3bd470e897004af30402b1d4c643f6552e85a875 Signed-off-by: Yunmi Ha --- src/common/gum-file.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/common/gum-file.c b/src/common/gum-file.c index 77b08d3..6b3f71e 100755 --- a/src/common/gum-file.c +++ b/src/common/gum-file.c @@ -172,12 +172,17 @@ _copy_file_attributes ( ssize_t attrs_size = 0; struct stat from_stat; - if (stat (from_path, &from_stat) < 0 || - chmod (to_path, from_stat.st_mode) < 0 || - lchown (to_path, from_stat.st_uid, from_stat.st_gid) < 0) { + if (lstat (from_path, &from_stat) < 0) return FALSE; + + if (!S_ISLNK(from_stat.st_mode)) { + if (chmod(to_path, from_stat.st_mode) < 0) + return FALSE; } + if (lchown(to_path, from_stat.st_uid, from_stat.st_gid) < 0) + return FALSE; + /* copy extended attributes */ #if defined(HAVE_LLISTXATTR) && \ defined(HAVE_LGETXATTR) && \ -- 2.7.4