summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-09-01 00:00:44 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-08 03:22:42 -0700
commit342100dac9d0e01039b8cd8a0da4426b70d27060 (patch)
tree717926a1e378ee7b33e6d62066a436b5192c9ab7
parent6cd8070af4c83cca9f3f7685a2a04bcb95059dd1 (diff)
libglusterfsclient: fix to the way symbolic links are handled in glusterfs_glh_realpath.
- don't assume the content returned by readlink while constructing realpath of a symbolic link to contain vmp as part of the path. This is necessary in case of symbolic links which contain relative paths as targets. Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 233 (Crash in Apache running on booster when a client tries to access a symbolic link) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=233
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index 69be41516..50ca6a5a7 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -6728,8 +6728,8 @@ glusterfs_glh_realpath (glusterfs_handle_t handle, const char *path,
int dest_offset = 0;
char *rpath_limit = 0;
int ret = 0, num_links = 0;
- struct vmp_entry *entry = NULL;
- char *vpath = NULL;
+ char *vpath = NULL, *tmppath = NULL;
+ char absolute_path[PATH_MAX];
GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, ctx, out);
GF_VALIDATE_ABSOLUTE_PATH_OR_GOTO (LIBGF_XL_NAME, path, out);
@@ -6836,11 +6836,12 @@ glusterfs_glh_realpath (glusterfs_handle_t handle, const char *path,
}
if (S_ISLNK (stbuf.st_mode)) {
- buf = alloca (path_max);
+ buf = calloc (1, path_max);
if (++num_links > MAXSYMLINKS)
{
errno = ELOOP;
+ FREE (buf);
goto err;
}
@@ -6853,13 +6854,23 @@ glusterfs_glh_realpath (glusterfs_handle_t handle, const char *path,
"glusterfs_readlink returned %d"
" for path (%s):(%s)",
ret, rpath, strerror (errno));
+ FREE (buf);
goto err;
}
buf[ret] = '\0';
- entry = libgf_vmp_search_entry (buf);
- vpath = libgf_vmp_virtual_path (entry, buf);
- glusterfs_glh_realpath (handle, vpath, rpath);
+ if (buf[0] != '/') {
+ tmppath = strdup (path);
+ tmppath = dirname (tmppath);
+ sprintf (absolute_path, "%s/%s",
+ tmppath, buf);
+ FREE (buf);
+ buf = libgf_resolve_path_light ((char *)absolute_path);
+ FREE (tmppath);
+ }
+
+ glusterfs_glh_realpath (handle, buf, rpath);
+ FREE (buf);
goto out;
} else if (!S_ISDIR (stbuf.st_mode) && *end != '\0') {
errno = ENOTDIR;