dbTalk Databases Forums  

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

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [pgsql-hackers-win32] [BUGS] More SSL questions.. in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tom Lane
 
Posts: n/a

Default Re: [pgsql-hackers-win32] [BUGS] More SSL questions.. - 01-04-2005 , 05:27 PM






Andrew Dunstan <andrew (AT) dunslane (DOT) net> writes:
Quote:
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.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


Reply With Quote
  #2  
Old   
John R Pierce
 
Posts: n/a

Default Re: [pgsql-hackers-win32] [BUGS] More SSL questions.. - 01-04-2005 , 06:07 PM






Tom Lane wrote:
Quote:
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.
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)...



---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #3  
Old   
Tom Lane
 
Posts: n/a

Default Re: [pgsql-hackers-win32] [BUGS] More SSL questions.. - 01-04-2005 , 06:15 PM



John R Pierce <pierce (AT) hogranch (DOT) com> writes:
Quote:
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)...
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.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)


Reply With Quote
  #4  
Old   
John R Pierce
 
Posts: n/a

Default Re: [pgsql-hackers-win32] [BUGS] More SSL questions.. - 01-04-2005 , 06:23 PM




Quote:
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.
libpq could be called from a service, such as inetinfo (IIS)...


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
  #5  
Old   
John R Pierce
 
Posts: n/a

Default Re: [pgsql-hackers-win32] [BUGS] More SSL questions.. - 01-04-2005 , 06:23 PM



Quote:
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)...
this is also set on XP Pro, except for the 'SYSTEM' services, its "C:\Documents
and Settings\LocalServices"

On Win2000 Server, its the same, except the default profiles are
\winnt\profiles\%username%


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
  #6  
Old   
Matthew T. O'Connor
 
Posts: n/a

Default Re: [pgsql-hackers-win32] [BUGS] More SSL questions.. - 01-04-2005 , 07:13 PM



Tom Lane wrote:

Quote:
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.

Right but I think the point is that the environment variable HOME does
not exist on windows. At least I have never seen it. I think it does
exist inside CYGWIN (perhaps in mingw also?) might the use of the HOME
variable be related to the Cygwin port?

The standard env variables relevant to this conversation are the two I
mentioned before (HOMEDRIVE, HOMEPATH) and the one mentioned above
(USERPROFILE) which seems to be equivalent to HOMEDRIVE and HOMEPATH
concatenated together.

Matthew


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #7  
Old   
Andrew Dunstan
 
Posts: n/a

Default Re: [pgsql-hackers-win32] [BUGS] More SSL questions.. - 01-04-2005 , 11:21 PM





Matthew T. O'Connor wrote:

Quote:
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).

Er, I don't think so. MSDN says:

CSIDL_PROFILE (0x0028)
Version 5.0. The user's profile folder. A typical path is
C:\Documents and Settings\username. Applications should not create files
or folders at this level; they should put their data under the locations
referred to by CSIDL_APPDATA or CSIDL_LOCAL_APPDATA.

I think CSIDL_APPDDATA is probably the way to go, but one of the heavy
Windows hitters will know better than I do.

cheers

andrew




---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


Reply With Quote
  #8  
Old   
Joshua D. Drake
 
Posts: n/a

Default Re: [pgsql-hackers-win32] [BUGS] More SSL questions.. - 01-04-2005 , 11:22 PM



This is a multi-part message in MIME format.
--------------010704010306050300030205
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Tom Lane wrote:
Quote:
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?
Yes, from the shell it would be:

%HOMEDRIVE%
%HOMEPATH%

I believe.

Sincerely,

Joshua D. Drake



What would be a
Quote:
reasonable equivalent to ~/.postgresql/ ?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org

--
Command Prompt, Inc., home of PostgreSQL Replication, and plPHP.
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - jd (AT) commandprompt (DOT) com - http://www.commandprompt.com
Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL

--------------010704010306050300030205
Content-Type: text/x-vcard; charset=utf-8;
name="jd.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="jd.vcf"

begin:vcard
fn:Joshua D. Drake
nrake;Joshua D.
org:Command Prompt, Inc.
adr:;;PO Box 215;Cascade Locks;Oregon;97014;USA
email;internet:jd (AT) commandprompt (DOT) com
title:Consultant
tel;work:503-667-4564
tel;fax:503-210-0334
note:Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl.
x-mozilla-html:FALSE
url:http://www.commandprompt.com/
version:2.1
end:vcard


--------------010704010306050300030205
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

--------------010704010306050300030205--


Reply With Quote
  #9  
Old   
Magnus Hagander
 
Posts: n/a

Default Re: [pgsql-hackers-win32] [BUGS] More SSL questions.. - 01-05-2005 , 02:54 AM



Quote:
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.
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
9x.

(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.
http://msdn.microsoft.com/library/de.../en-us/shellcc
/platform/shell/reference/functions/shgetspecialfolderpath.asp


Tom also wrote:

Quote:
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.

Quote:
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.=20

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/"
*/
ZeroMemory(tmppath,sizeof(tmppath));
if (!SHGetSpecialFolderPath(NULL, tmppath, CSIDL_APPDATA,
FALSE)) {
return FALSE;
strcat(tmppath,"/.postgresql/");
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.

//Magnus

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #10  
Old   
Tom Lane
 
Posts: n/a

Default Re: [pgsql-hackers-win32] [BUGS] More SSL questions.. - 01-05-2005 , 12:52 PM



"Magnus Hagander" <mha (AT) sollentuna (DOT) net> writes:
Quote:
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.
We are using $USERPROFILE, not $HOME, on Windows, but I think Magnus is
right: we shouldn't be doing that at all. If I don't hear any
objections soon, I'm going to replace get_home_path() with code that
uses getpwuid (on Unix) or SHGetSpecialFolderPath (on Windows).

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.