summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-08-31 23:59:24 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-08 03:23:22 -0700
commit302d310c82cf55ca178c13a9947eaea9c543a2ea (patch)
treef90ef24f08777f21c13a736a55862c154632d4ea /libglusterfsclient
parentf87b1481699bcfab8fd7b8768a9afa4cba85ad33 (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
Diffstat (limited to 'libglusterfsclient')
-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 f1a5136a48b..7e503feeb50 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -6734,8 +6734,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);
@@ -6842,11 +6842,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;
}
@@ -6859,13 +6860,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;