Home > Archive > Pgadmin > April 2005 > [PATCH] Connect to database using UNIX domain sockets









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author [PATCH] Connect to database using UNIX domain sockets
Dominique Quatravaux

2005-04-13, 11:24 am

Dear pgadmin hackers,

Enclosed is a small, nonintrusive patch that allows one to connect to
a database using the UNIX domain socket under Linux and BSD (a must
for secure, password-less operation). One simply leaves the "hostname"
field blank when filling in the database connection form.

Since this patch leverages the clever fallback mechanism already built
into libpq, I see no reason why it would break anything under Windows.

Thanks for your work on pgadmin. Regards, Dom

------------

--- pgadmin3-1.0.2/src/db/pgConn.cpp.ORIG 2005-04-13 12:49:43.000000000 +0200
+++ pgadmin3-1.0.2/src/db/pgConn.cpp 2005-04-13 14:38:50.000000000 +0200
@@ -44,6 +48,8 @@
wxLogInfo(wxT("Creating pgConn object"));
wxString msg, hostip;

+ hostip.Empty();
+
conv = &wxConvLibc;
needColQuoting = false;

@@ -54,6 +60,7 @@
majorVersion=0;
noticeArg=0;

+ if (! server.IsEmpty()) {
#ifdef __WXMSW__
struct in_addr ipaddr;
#else
@@ -78,13 +85,14 @@
}
else
hostip = server;
+ }

resolvedIP = TRUE;
wxLogInfo(wxT("Server name: %s (resolved to: %s)"), server.c_str(), hostip.c_str());

// Create the connection string
wxString connstr;
- if (!server.IsEmpty()) {
+ if (!hostip.IsEmpty()) {
connstr.Append(wxT(" hostaddr="));
connstr.Append(hostip);
}


--
Dominique QUATRAVAUX Ingénieur senior
01 44 42 00 08 IDEALX



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

http://www.postgresql.org/docs/faq

Dave Page

2005-04-14, 3:24 am

Hi Dom,

This patch could knock off a todo item with a little tweaking - interested in enhancing it a little?

Basically, the host parameter in the connection string can also be set to a path to the socket - if it starts with a / it's assumed that it is a path rather than a hostname.

http://www.postgresql.org/docs/8.0/...l#LIBPQ-CONNECT

It'd be great to see an updated patch :-)

Regards, Dave

> -----Original Message-----
> From: pgadmin-support-owner@postgresql.org
> [mailto:pgadmin-support-owner@postgresql.org] On Behalf Of
> Dominique Quatravaux
> Sent: 13 April 2005 17:02
> To: pgadmin-support@postgresql.org
> Subject: [pgadmin-support] [PATCH] Connect to database using
> UNIX domain sockets
>
> Dear pgadmin hackers,
>
> Enclosed is a small, nonintrusive patch that allows one to connect to
> a database using the UNIX domain socket under Linux and BSD (a must
> for secure, password-less operation). One simply leaves the "hostname"
> field blank when filling in the database connection form.
>
> Since this patch leverages the clever fallback mechanism already built
> into libpq, I see no reason why it would break anything under Windows.
>
> Thanks for your work on pgadmin. Regards, Dom
>
> ------------
>
> --- pgadmin3-1.0.2/src/db/pgConn.cpp.ORIG 2005-04-13
> 12:49:43.000000000 +0200
> +++ pgadmin3-1.0.2/src/db/pgConn.cpp 2005-04-13
> 14:38:50.000000000 +0200
> @@ -44,6 +48,8 @@
> wxLogInfo(wxT("Creating pgConn object"));
> wxString msg, hostip;
>
> + hostip.Empty();
> +
> conv = &wxConvLibc;
> needColQuoting = false;
>
> @@ -54,6 +60,7 @@
> majorVersion=0;
> noticeArg=0;
>
> + if (! server.IsEmpty()) {
> #ifdef __WXMSW__
> struct in_addr ipaddr;
> #else
> @@ -78,13 +85,14 @@
> }
> else
> hostip = server;
> + }
>
> resolvedIP = TRUE;
> wxLogInfo(wxT("Server name: %s (resolved to: %s)"),
> server.c_str(), hostip.c_str());
>
> // Create the connection string
> wxString connstr;
> - if (!server.IsEmpty()) {
> + if (!hostip.IsEmpty()) {
> connstr.Append(wxT(" hostaddr="));
> connstr.Append(hostip);
> }
>
>
> --
> Dominique QUATRAVAUX Ingénieur senior
> 01 44 42 00 08 IDEALX
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>


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

http://archives.postgresql.org

Dave Page

2005-04-14, 11:27 am

Thanks Dom, I've committed a patch for complete UDS support based on your work.

Regards, Dave.

> -----Original Message-----
> From: pgadmin-support-owner@postgresql.org
> [mailto:pgadmin-support-owner@postgresql.org] On Behalf Of
> Dominique Quatravaux
> Sent: 13 April 2005 17:02
> To: pgadmin-support@postgresql.org
> Subject: [pgadmin-support] [PATCH] Connect to database using
> UNIX domain sockets
>
> Dear pgadmin hackers,
>
> Enclosed is a small, nonintrusive patch that allows one to connect to
> a database using the UNIX domain socket under Linux and BSD (a must
> for secure, password-less operation). One simply leaves the "hostname"
> field blank when filling in the database connection form.
>
> Since this patch leverages the clever fallback mechanism already built
> into libpq, I see no reason why it would break anything under Windows.
>
> Thanks for your work on pgadmin. Regards, Dom
>
> ------------
>
> --- pgadmin3-1.0.2/src/db/pgConn.cpp.ORIG 2005-04-13
> 12:49:43.000000000 +0200
> +++ pgadmin3-1.0.2/src/db/pgConn.cpp 2005-04-13
> 14:38:50.000000000 +0200
> @@ -44,6 +48,8 @@
> wxLogInfo(wxT("Creating pgConn object"));
> wxString msg, hostip;
>
> + hostip.Empty();
> +
> conv = &wxConvLibc;
> needColQuoting = false;
>
> @@ -54,6 +60,7 @@
> majorVersion=0;
> noticeArg=0;
>
> + if (! server.IsEmpty()) {
> #ifdef __WXMSW__
> struct in_addr ipaddr;
> #else
> @@ -78,13 +85,14 @@
> }
> else
> hostip = server;
> + }
>
> resolvedIP = TRUE;
> wxLogInfo(wxT("Server name: %s (resolved to: %s)"),
> server.c_str(), hostip.c_str());
>
> // Create the connection string
> wxString connstr;
> - if (!server.IsEmpty()) {
> + if (!hostip.IsEmpty()) {
> connstr.Append(wxT(" hostaddr="));
> connstr.Append(hostip);
> }
>
>
> --
> Dominique QUATRAVAUX Ingénieur senior
> 01 44 42 00 08 IDEALX
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>


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

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com