Potential problem in commit f777d773878 and 4f7f7b03758 - Mailing list pgsql-hackers

From Dilip Kumar
Subject Potential problem in commit f777d773878 and 4f7f7b03758
Date
Msg-id CAFiTN-uKNzAro4tVwtJhF1UqcygfJ+R+RL=b-_ZMYE3LdHoGhA@mail.gmail.com
Whole thread Raw
Responses Re: Potential problem in commit f777d773878 and 4f7f7b03758
Re: Potential problem in commit f777d773878 and 4f7f7b03758
List pgsql-hackers
Simple test to reproduce:

Change the module path for any extension as below, like I have done
for amcheck and then copy the .so file at $libdir/test/ folder.
module_pathname = '$libdir/test/amcheck'

While creating the extension it fail to load the file because, after
commit f777d773878 we remove the $libdir from the path[1] and later in
expand_dynamic_library_name() since there is a '/' in remaining path
we will call full = substitute_path_macro(name, "$libdir",
pkglib_path); to generate the full path by substituting the "$libdir"
macro[2].  But we have already removed $libdir from the filename, so
there will be no substitution and it will just search the
'test/amcheck' path, which was not intended.

IMHO the fix should be that we need to preserve the original name as
well, and in the else case we should pass the original name which is
'$libdir/test/amcheck' in this case so that macro substitution can
work properly?

[1]
+       if (strncmp(filename, "$libdir/", 8) == 0)
+               filename += 8;

[2]
if (!have_slash)
{
full = find_in_path(name, Dynamic_library_path,
"dynamic_library_path", "$libdir", pkglib_path);
if (full)
return full;
}
else
{
full = substitute_path_macro(name, "$libdir", pkglib_path);
if (pg_file_exists(full))
return full;
pfree(full



-- 
Regards,
Dilip Kumar
Google



pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: Remove unneeded cast in heap_xlog_lock.
Next
From: Heikki Linnakangas
Date:
Subject: Re: A few patches to clarify snapshot management