summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-12-05 01:41:21 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-12-05 01:41:24 -0800
commite602c69beda645740b1f4a2b5da8e03655a28b57 (patch)
treea7765249cf96431be8ce9fb13490e039132792bf
parent64fd835d84ce2ca8f86178b65885479cee68fe8e (diff)
storage/posix: prevent chmod() from getting called on symlinksv3.0.7qa1
Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 881 (GlusterFS daemon hangs on replication of symlink (3.0.4)) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=881
-rw-r--r--xlators/storage/posix/src/posix.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 1d3b179..0000973 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -31,6 +31,7 @@
#include <libgen.h>
#include <pthread.h>
#include <ftw.h>
+#include <sys/stat.h>
#ifndef GF_BSD_HOST_OS
#include <alloca.h>
@@ -575,13 +576,33 @@ posix_do_chmod (xlator_t *this,
const char *path,
struct stat *stbuf)
{
- int32_t ret = -1;
+ int32_t ret = -1;
+ struct stat stat;
+ int is_symlink = 0;
+
+ ret = sys_lstat (path, &stat);
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "%s (%s)", path, strerror (errno));
+ goto out;
+ }
+
+ if (S_ISLNK (stat.st_mode))
+ is_symlink = 1;
ret = lchmod (path, stbuf->st_mode);
if ((ret == -1) && (errno == ENOSYS)) {
+ /* in Linux symlinks are always in mode 0777 and no
+ such call as lchmod exists.
+ */
+ if (is_symlink) {
+ ret = 0;
+ goto out;
+ }
ret = chmod (path, stbuf->st_mode);
}
+out:
return ret;
}