From 302d310c82cf55ca178c13a9947eaea9c543a2ea Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Mon, 31 Aug 2009 23:59:24 +0000 Subject: 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 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 --- libglusterfsclient/src/libglusterfsclient.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'libglusterfsclient/src/libglusterfsclient.c') diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index f1a5136a4..7e503feeb 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; -- cgit