![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
I think CSIDL_APPDDATA is probably the way to go, but one of the heavy Windows hitters will know better than I do. |
#2
| |||
| |||
|
|
Andrew Dunstan <andrew (AT) dunslane (DOT) net> writes: I think CSIDL_APPDDATA is probably the way to go, but one of the heavy Windows hitters will know better than I do. 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. |
#3
| |||
| |||
|
|
Tom Lane wrote: Seems like we should be consistent about this --- either we trust $HOME or we don't. more fun. I just checked the environment of the postmaster service on a win2000 Pro system (using www.sysinternals.com's excellent Process Explorer tool, btw). HOME is not set. USERPROFILE is set to "C:\Documents and Settings\postgres"... For services that are running as 'NT AUTHORITY\SYSTEM', the profile is "C:\Documents and Settings\Default User" (and the USERDOMAIN and USERNAME aren't set at all)... |
#4
| |||
| |||
|
|
Actually, the server doesn't depend on home directories in any way shape or form. The places that we are concerned about are on the client side, either in libpq or in psql. So what we have to think about is the environment that libpq might see. |
#5
| |||
| |||
|
|
win2000 Pro system (using www.sysinternals.com's excellent Process Explorer tool, btw). HOME is not set. USERPROFILE is set to "C:\Documents and Settings\postgres"... For services that are running as 'NT AUTHORITY\SYSTEM', the profile is "C:\Documents and Settings\Default User" (and the USERDOMAIN and USERNAME aren't set at all)... |
#6
| |||
| |||
|
|
John R Pierce <pierce (AT) hogranch (DOT) com> writes: more fun. I just checked the environment of the postmaster service on a win2000 Pro system (using www.sysinternals.com's excellent Process Explorer tool, btw). HOME is not set. USERPROFILE is set to "C:\Documents and Settings\postgres"... Actually, the server doesn't depend on home directories in any way shape or form. The places that we are concerned about are on the client side, either in libpq or in psql. So what we have to think about is the environment that libpq might see. |
#7
| |||
| |||
|
|
Tom Lane wrote: 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: http://msdn.microsoft.com/library/de...folderpath.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). |
#8
| |||
| |||
|
|
I wrote: win32 hackers, anyone know why it's like this? Looking through the code, it seems that it's because someone thought that breaking SSL would be easier than replacing the pqGetpwuid() calls that are used to find out the user's home directory. Does Windows even have a concept of home directory? |
|
reasonable equivalent to ~/.postgresql/ ? regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org |
rake;Joshua D.
#9
| |||
| |||
|
|
OK ... are you supposed to find it out by looking at the environment=20 vars, or is there another API defined? I am planning to consolidate the platform dependency into a function=20 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,=20 I'll take care=20 of the rest. =20=20 =20 I can't do the coding, but I took a quick look at msdn and I=20 think this is relevant: =20 http://msdn.microsoft.com/library/de...3D/library/en- us/shellcc/platform/shell/reference/functions/shgetfolderpath.asp =20 HRESULT SHGetFolderPath(=20=20=20=20=20=20 HWND /hwndOwner/, int /nFolder/, HANDLE /hToken/, DWORD /dwFlags/, LPTSTR /pszPath/ ); =20 =20 Also, for nFolder, it looks like the we want to use a value=20 of CSIDL_PROFILE (0x0028).=20 =20 Hope that helps someone out there. |
|
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 |
|
Seems like we should be consistent about this --- either we trust $HOME or we don't. |
#10
| |||
| |||
|
|
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. |
![]() |
| Thread Tools | |
| Display Modes | |
| |