Skip site navigation (1) Skip section navigation (2)

Re: [pgsql-hackers-win32] More SSL questions..

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>,"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "T(dot)J(dot)" <tjtoocool(at)phreaker(dot)net>, <pgsql-bugs(at)postgresql(dot)org>,<pgsql-hackers-win32(at)postgresql(dot)org>
Subject: Re: [pgsql-hackers-win32] More SSL questions..
Date: 2005-01-05 08:53:14
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugspgsql-hackerspgsql-hackers-win32
> >OK ... are you supposed to find it out by looking at the environment 
> >vars, or is there another API defined?
> >
> >I am planning to consolidate the platform dependency into a function 
> >defined like
> >
> >	static bool pqGetHomeDirectory(char *buf, int bufsize)
> >	{
> >		-- Obtain pathname of user's home directory, store in
> >		-- buf[] (of size bufsize)
> >		-- Return TRUE if succeeded, FALSE if not
> >	}
> >
> >If someone can whip up and test a WIN32 version of this, 
> I'll take care 
> >of the rest.
> >  
> >
> I can't do the coding, but I took a quick look at msdn and I 
> think this is relevant:
> us/shellcc/platform/shell/reference/functions/shgetfolderpath.asp
> HRESULT SHGetFolderPath(      
>     HWND /hwndOwner/,
>     int /nFolder/,
>     HANDLE /hToken/,
>     DWORD /dwFlags/,
>     LPTSTR /pszPath/
> );
> Also, for nFolder, it looks like the we want to use a value 
> of CSIDL_PROFILE (0x0028). 
> Hope that helps someone out there.

No, we should use CSIDL_APPDATA. Two reasons:
1) Never put things in the root of the profile :P
2) CSIDL_APPDATA is supported on 9x (4.71 of the shell which,IIRC, is
Win95, as long as you have IE4 or newer install. And I doubt a lot of
people don't have that). Remember that our *client side code* support

(Then of course it should have "postgresql" (or ".postgresql" for
consiscency with *nix) appended to it)

Also, SHGetFolderPath() rqeuires Win2k. There is
SHGetSpecialFolderPath() for all versions.

Tom also wrote:

> Now that I look at it, there are several places that are depending on
> getenv("HOME") or getenv("USERPROFILE") (on Windows) as the meaning of
"home directory".  In particular ~/.pgpass is sought > there, and psql
also uses get_home_path in a lot of places.

> Seems like we should be consistent about this --- either we trust
$HOME or we don't.

Don't trust $HOME on win32. There is no such thing.It's set by Cygwin,
and it's set by the MingW shell, but it's not set by Windows. HOMEDRIVE,
HOMEPATH and HOMESHARE are set, but not HOME. 

You can trust USERPROFILE in NT based OSes. Not sure about 9x. Using the
API above is a much nicer way of doing it.

So, a quick implementation (not tested, but shouldn't be too hard) of
your functino would be:
static bool pqGetHomeDirectory(char *buf, int bufsize)
	char tmppath[MAX_PATH+16]; /* Add 16 chars for "/.postgresql/"
	if (!SHGetSpecialFolderPath(NULL, tmppath, CSIDL_APPDATA,
		return FALSE;
	if (strlen(tmppath) > bufsize)
		return FALSE; /* Better than returning a chopped-off
path */
	strcpy(buf, tmppath);
	return TRUE;

You're going to have to add #include <shlobj.h> to the file as well.



pgsql-hackers by date

Next:From: Alin VaidaDate: 2005-01-05 09:17:44
Subject: Re: [PATCHES] Final call for translation updates
Previous:From: Yann MichelDate: 2005-01-05 08:11:41
Subject: Re: query rewrite using materialized views

pgsql-bugs by date

Next:From: Magnus HaganderDate: 2005-01-05 08:59:50
Subject: Re: BUG #1372: Service won't start with tcpip_socket = true
Previous:From: Tom LaneDate: 2005-01-05 06:58:55
Subject: Re: BUG #1371: Short-circuit evaluation on PL/PgSQL

pgsql-hackers-win32 by date

Next:From: Andrew DunstanDate: 2005-01-05 12:47:18
Subject: Re: [BUGS] More SSL questions..
Previous:From: Matthew T. O'ConnorDate: 2005-01-05 01:09:08
Subject: Re: [pgsql-hackers-win32] More SSL questions..

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group