On Sunday, September 09, 2012 1:37 PM Amit Kapila wrote:
On Friday, September 07, 2012 11:19 PM Tom Lane wrote:
Heikki Linnakangas <hlinn...@iki.fi> writes:
>>> Would socketpair(2) be simpler?

>>I've not done anything yet about the potential security issues
>>associated with untrusted libpq connection strings.  I think this
>>is still at the proof-of-concept stage; in particular, it's probably
>> time to see if we can make it work on Windows before we worry more
>>about that.

> I have started working on this patch to make it work on Windows. The 3
main things to make it work are:

> 1. Windows equivalent for socketpair - This as suggested previously in
this thread earlier code of pgpipe can suffice 
> the need. Infact I have checked on net as well, most implementations are
similar to pgpipe implementation. So I 
> prefered to use the existing code which was removed. 

> 2. Windows equivalent for fork-execv - This part can be done by
CreateProcess,it can be similar to internal_forkexec 
> except for path where it uses shared memory to pass parameters, I am
trying to directly pass parameters to 
> CreateProcess.

  Directly passing parameters doesn't suffice for all parameters, as for
socket we need to duplicate the socket using WSADuplicateSocket() which
returns little big structure which is better to be passed via shared memory.

> 3. Windows equivalent for waitpid - Actually there can be 2 ways to
accomplish this
>      a. use waitforsingleobject with process handle, but in some places it
is mentioned it might not work for all 
>          windows versions. Can someone pls confirm about. I shall try on
my PC to test the same.
>      b. use existing infrastructure of waitpid, however it is not for
single process and it might need some changes to 
>         make it work for single process or may be we can use it directly.
However currently it is in postmaster.c, so 
>        it need to be moved so that we can access it from fe-connect.c in
libpq as well.
>      c. suggest if you know of other ways to handle it or which from above
2 would be better?

     I have used method - a (waitforsingleobject) and it worked fine.

With the above implementation, it is working on Windows. Now the work left
is as follows:
1. Refactoring of code
2. Error handling in paths
3. Check if anything is missing and implement for same.
4. Test the patch for Windows.

Any comments/suggestions?

With Regards,
Amit Kapila

Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to