Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Mar 2005 21:59:24 +0100
From:      Peter Much <pmc@citylink.dinoex.sub.org>
To:        girgen@freebsd.FreeBSD.ORG
Cc:        freebsd-ports@freebsd.org
Subject:   postgresql tcl pgaccess kerberos
Message-ID:  <20050313205924.GA69260@gate.oper.dinoex.org>

next in thread | raw e-mail | index | archive | help

--GID0FwUMdk1T2AWN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

 am writing to You as the mainainer of the FreeBSD postgres port.
I ran into a couple of troubles getting this to run, and maybe You
are interested in my findings.

Actually I am installing postgres 7.4.5 (with Fbsd 5.3) and I do not
clearly see how far the proceedings have gone with version 8. That is, I
do not cvs-upgrade my ports collection all the time - in case of later
trobles with any port I need to quickly get into the exact build
environment form which it was built.

So, I will describe my troubles with the build of Version 7.4.5,
and You may verify if these problems have already been fixed on
Version 8 or not.

In short, everything runs except pgtcl and pgaccess.

pgaccess at first fails totally if connecting an interface that has
an hyphen in its DNS name. This does not need to concern You, it
comes from some horrible crap which the coders have built into
pgaccess - they use the hyphen as an internal field delimiter!
This can be fixed by changing the hyphen to a more suitable symbol
at maybe half a thousand occurrences - it is just boring, but
not a FreeBSD matter.

Next, pgaccess cannot connect with kerberos authentication. This
has a whole couple of reasons:
1. pgaccess tries to tcl-load the libpgtcl.so
   But the standard distribution of pgaccess searches this lib
   in /usr/lib, not in /usr/local/lib where it is installed by
   the postgresql port.
   One can change this: After its first invocation, pgaccess
   will create a config file in $HOME/.pgaccess. There the correct
   path should be put in for the PGLIB option.
   But it would be better if the portbuild would patch this so
   that it works just from the beginning.

   (Actually, in Your startscript for pgaccess, the correct
   PGLIB value is exported. This seems to be honored by pgaccess
   for the "package require" method but not for the "load $shlib"
   method. I am not sure about this, at least in
   $HOME/.pgaccess/pgaccess.cfg the wrong location gets recorded.
   And after correcting the following points, it works without
   a correction in this point.)

   If pgaccess cannot load libpgtcl.so, then it will fall back
   to internal tcl code (pgin.tcl) which does provide the same
   functionality. But this code has no support at all for kerberos.

2. libpgtcl.so is not built with kerberos support. Even if
   WITH_HEIMDAL_KRB5 is correctly set in /etc/make.conf, the
   Makefile in ports/databases/postgresql-tcltk does not care
   about this setting.

   The result is that pgtclsh cannot connect with kerberos auth.

   This can be fixed by copying the appropriate code from
   ports/databases/postgresql7/Makefile to postresql-tcltk/Makefile
   and rebuilding.

   Then pgtclsh will work correctly.

3. But now again pgaccess cannot load the libpgtcl.so
   This fails with a missing symbol krb5_cc_get_principal from
   libpq.so, and pgaccess again falls back to the interal code.

   The reason for this is that libpq.so is wrongly linked.
   In libpgtcl.so the name of libpq.so is explicitely mentioned,
   and so the tcl-loader can find it. But in libpq.so the names
   of the kerberos libraries (in /usr/lib) are NOT explicitely
   mentioned, and therefore tcl-loader will not find them.

   I found out that when linking shared libs, only the names
   of such dependency-libs will explicitely mentioned in the
   newly created lib, which are in a nonstandard location
   (like /usr/local/lib). The name of dependency-libs which
   are in /usr/lib will NOT be mentioned (maybe because the
   system loader knows them anyway when they are there).

   This seems to be good enough for the system loader, but not
   for the tcl-loader.

   I found out, that if I do link libpq.so and add the names
   of the kerberos libraries (-lkrb5 -lasn1 -lcrypto -lroken
   -lcrypt -lcom_err) explicitely to the commandline, then
   I get these references into the shared lib.

   And then pgaccess works.


I am attaching following files:
 - patch to get libpq compiled with the necessary references. (This
   should be done more nicely by using "krb5-config --libs krb5",
   or maybe somebody experienced with build environments knows
   about better ways.)
 - patch to get kerberos support into libpgtcl. (This is just copied
   from postgresql7 makefile to the postgresql-tcltk makefile.)
 - patch to get pgaccess work with interface names containing
   hyphens. I am quite sure I have not hit all the cockroaches,
   but maybe someone can use it as a starting.

PMc

--GID0FwUMdk1T2AWN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=pgaccess-hyphen
Content-Transfer-Encoding: quoted-printable

*** ports/databases/pgaccess/Makefile.orig	Sun Mar 13 21:14:31 2005
--- ports/databases/pgaccess/Makefile	Sun Mar 13 21:14:19 2005
***************
*** 27,32 ****
--- 27,35 ----
  post-patch:
  	@${REINPLACE_CMD} -e "s,/usr/bin,${PREFIX}/bin,g ; " ${WRKSRC}/lib/mainl=
ib.tcl
  	@${RM} ${WRKSRC}/lib/mainlib.tcl.bak
+ 	@${RM} ${WRKSRC}/lib/mainlib.tcl.orig
+ 	@${RM} ${WRKSRC}/lib/connections.tcl.orig
+ 	@${RM} ${WRKSRC}/pgaccess.tcl.orig
 =20
  do-build:
  .for targetfile in pgaccess.tcl pgmonitor

--GID0FwUMdk1T2AWN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=postgresql-tcltk-krb5support
Content-Transfer-Encoding: quoted-printable

*** ports/databases/postgresql-tcltk/Makefile.orig	Wed Feb  4 06:19:07 2004
--- ports/databases/postgresql-tcltk/Makefile	Sun Mar 13 04:19:48 2005
***************
*** 54,59 ****
--- 54,82 ----
  CATEGORIES+=3D	tk${TCLVERSION:S/.//}
  .endif
 =20
+ .include <bsd.port.pre.mk>
+=20
+ .if defined(WITH_HEIMDAL_KRB5)
+ WITH_KRB5=3D      yes
+ .if defined(HEIMDAL_HOME) && exists(${HEIMDAL_HOME}/lib/libgssapi.a)
+ CONFIGURE_ARGS+=3D        --with-krb5=3D${HEIMDAL_HOME}
+ KRB5CONF=3D       ${HEIMDAL_HOME}/bin/krb5-config
+ .elif ( defined(MAKE_KERBEROS5) || ${OSVERSION} > 500105 ) && exists(${DE=
STDIR}/usr/lib/libkrb5.a)
+ CONFIGURE_ARGS+=3D        --with-krb5=3D${DESTDIR}/usr
+ KRB5CONF=3D       ${DESTDIR}/usr/bin/krb5-config
+ .else
+ LIB_DEPENDS+=3D   krb5:${PORTSDIR}/security/heimdal
+ CONFIGURE_ARGS+=3D        --with-krb5=3D${LOCALBASE}
+ KRB5CONF=3D       ${LOCALBASE}/bin/krb5-config
+ .endif
+ .endif
+=20
+ .if defined(WITH_KRB5)
+ CONFIGURE_ARGS+=3D        --with-krb5=3D"`${KRB5CONF} --prefix krb5`"
+ LDFLAGS+=3D       `${KRB5CONF} --libs krb5`=20
+ CONFIGURE_ENV=3D  LDFLAGS=3D"${LDFLAGS}"
+ .endif
+=20
  pre-build:
  	cd ${WRKSRC}/src/port; ${GMAKE}
 =20
***************
*** 69,72 ****
  	@${SED} "s|%%PREFIX%%|${PREFIX}|g" < ${FILESDIR}/pkgIndex.tcl.in \
  		> ${PREFIX}/lib/tcl${TCLVERSION}/Pgtcl1.3/pkgIndex.tcl
 =20
! .include <bsd.port.mk>
--- 92,95 ----
  	@${SED} "s|%%PREFIX%%|${PREFIX}|g" < ${FILESDIR}/pkgIndex.tcl.in \
  		> ${PREFIX}/lib/tcl${TCLVERSION}/Pgtcl1.3/pkgIndex.tcl
 =20
! .include <bsd.port.post.mk>

--GID0FwUMdk1T2AWN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch-xa
Content-Transfer-Encoding: quoted-printable

--- src/interfaces/libpq/Makefile.orig	Sun Mar 13 19:58:28 2005
+++ src/interfaces/libpq/Makefile	Sun Mar 13 19:58:23 2005
@@ -32,7 +32,7 @@
 # Add libraries that libpq depends (or might depend) on into the
 # shared library link.  (The order in which you list them here doesn't
 # matter.)
-SHLIB_LINK +=3D $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto=
 -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS)) $(THREAD_LIBS)
+SHLIB_LINK +=3D $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto=
 -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS)) -L/usr/lib -lkrb5 -l=
asn1 -lcrypto -lroken -lcrypt -lcom_err $(THREAD_LIBS)
=20
=20
 all: all-lib

--GID0FwUMdk1T2AWN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch-xa
Content-Transfer-Encoding: quoted-printable

--- lib/mainlib.tcl.orig	Fri Feb 20 02:02:52 2004
+++ lib/mainlib.tcl	Sun Mar 13 01:18:24 2005
@@ -1755,7 +1755,7 @@
=20
     set temp [$Win(tree) selection get]
     if {$temp=3D=3D""} return "";
-    set PgAcVar(activetab) [lindex [split $temp -] 2]
+    set PgAcVar(activetab) [lindex [split $temp @] 2]
=20
     set temp [$Win(mclist) curselection]
=20
@@ -2036,7 +2036,7 @@
=20
         #addHost
=20
-        #$::Mainlib::Win(tree) insert end root __host__-$M \
+        #$::Mainlib::Win(tree) insert end root __host__@$M \
             #-text "$M" \
          	#-image [image create photo -data $::Mainlib::_base64(online:rx)]
 	#}
@@ -2081,7 +2081,7 @@
     foreach M $complist {
         #if {[string match "" $M]} {set M localhost}
=20
-        #$::Mainlib::Win(tree) insert end root __host__-$M \
+        #$::Mainlib::Win(tree) insert end root __host__@$M \
             #-text "$M" \
       	#-image [image create photo -data $::Mainlib::_base64(online:rx)]
=20
@@ -2122,11 +2122,11 @@
             $Win(tree) opentree __db__-sockets-$PgAcVar(currentdb,dbname)
         }
     } else {
-        if {[$Win(tree) exists __host__-$PgAcVar(currentdb,host)]} {
-            $Win(tree) opentree __host__-$PgAcVar(currentdb,host) 0
+        if {[$Win(tree) exists __host__@$PgAcVar(currentdb,host)]} {
+            $Win(tree) opentree __host__@$PgAcVar(currentdb,host) 0
         }
-        if {[$Win(tree) exists __db__-${PgAcVar(currentdb,host)}-$PgAcVar(=
currentdb,dbname)]} {
-            $Win(tree) opentree __db__-${PgAcVar(currentdb,host)}-$PgAcVar=
(currentdb,dbname)
+        if {[$Win(tree) exists __db__@${PgAcVar(currentdb,host)}@$PgAcVar(=
currentdb,dbname)]} {
+            $Win(tree) opentree __db__@${PgAcVar(currentdb,host)}@$PgAcVar=
(currentdb,dbname)
         }
     }
=20
@@ -2134,7 +2134,7 @@
     ## This is if there is an autoexec script in the scripts db
     ##
     if {([info exists PgAcVar(activetab)]) && (![string match "" $PgAcVar(=
activetab)])} {
-        set node ${PgAcVar(currentdb,host)}-${PgAcVar(currentdb,dbname)}-$=
PgAcVar(activetab)
+        set node ${PgAcVar(currentdb,host)}@${PgAcVar(currentdb,dbname)}@$=
PgAcVar(activetab)
         #$Win(tree) selection set $node
         #$Win(tree) selection see $node
         select 1 $node
@@ -2169,9 +2169,9 @@
 	    set img ::icon::system-16
 	}
=20
-	if {[$Win(tree) exists __host__-$host_]} {return}
+	if {[$Win(tree) exists __host__@$host_]} {return}
=20
-    $::Mainlib::Win(tree) insert end root __host__-$host_ \
+    $::Mainlib::Win(tree) insert end root __host__@$host_ \
         -text "$txt" \
       	-image $img
       	#-image [image create photo -data $::Mainlib::_base64(online:rx)]
@@ -2212,9 +2212,9 @@
=20
     if {[string match "" $host_]} {set host_ sockets}
=20
-    if {[$Win(tree) exists __db__-${host_}-${db_}]} {return}
+    if {[$Win(tree) exists __db__@${host_}@${db_}]} {return}
=20
-    if {![$Win(tree) exists __host__-$host_]} {
+    if {![$Win(tree) exists __host__@$host_]} {
 	if {[string match "sockets" $host_]} {
 	    addHostNode ""
         } else {
@@ -2223,7 +2223,7 @@
         }
     }
=20
-    $::Mainlib::Win(tree) insert end __host__-$host_ __db__-${host_}-${db_=
} \
+    $::Mainlib::Win(tree) insert end __host__@$host_ __db__@${host_}@${db_=
} \
         -text "$db_" \
         -image [image create photo -data $::Mainlib::_base64(si_sql)]
=20
@@ -2231,7 +2231,7 @@
         if {!($V < 7.3 \
           && [lsearch [list "Domains" "Casts" "Conversions"] $I]!=3D-1)} {
             $::Mainlib::Win(tree) insert end \
-               __db__-${host_}-${db_} ${host_}-${db_}-${I} \
+               __db__@${host_}@${db_} ${host_}@${db_}@${I} \
                -text [intlmsg $I] \
                -image $img($I) \
                -fill blue
@@ -2240,7 +2240,7 @@
=20
     foreach I $::PgAcVar(pgatablist) {
         $::Mainlib::Win(tree) insert end \
-           __db__-${host_}-${db_} ${host_}-${db_}-${I} \
+           __db__@${host_}@${db_} ${host_}@${db_}@${I} \
            -text [intlmsg $I] \
            -image $img($I) \
            -fill red
@@ -2266,7 +2266,7 @@
=20
     variable Win
=20
-    foreach {junk host db} [split $node -] break
+    foreach {junk host db} [split $node @] break
=20
     if {(![string match "__db__" $junk]) && (![string match "__host__" $ju=
nk])} {
 	set db $host
@@ -2334,11 +2334,11 @@
=20
     $Win(tree) selection set $node_
=20
-    foreach {comp db entry} [split $node_ -] {break}
+    foreach {comp db entry} [split $node_ @] {break}
=20
     switch -glob -- $node_ {
=20
-        __host__-* {
+        __host__@* {
             set host $db
             set db ""
             set entry ""
@@ -2358,7 +2358,7 @@
             setCursor DEFAULT
         }
=20
-        __db__-* {
+        __db__@* {
             set host $db
             set db $entry
             set entry ""
@@ -2626,12 +2626,12 @@
     variable Win
=20
     set node [$Win(tree) selection get]
-    if {([string match "" $node]) || ([string match "__host__-*" $node])} =
{return}
+    if {([string match "" $node]) || ([string match "__host__@*" $node])} =
{return}
=20
=20
-    foreach {H D E} [split $node -] break
+    foreach {H D E} [split $node @] break
=20
-	if {[string match "__db__-*" $node]} {
+	if {[string match "__db__@*" $node]} {
 		set H $D
 	    set D $E
 	}
@@ -2639,22 +2639,22 @@
     #catch {pg_disconnect $::CurrentDB}
=20
     catch {pg_disconnect [::Connections::getHandles $H $D]}
-    $Win(tree) delete [$Win(tree) nodes __db__-${H}-${D}]
-    $Win(tree) delete __db__-${H}-${D}
+    $Win(tree) delete [$Win(tree) nodes __db__@${H}@${D}]
+    $Win(tree) delete __db__@${H}@${D}
=20
     $Win(mclist) delete 0 end
 	$Win(mclist) configure \
 	    -columns [list 0 "" left]
=20
-    if {[llength [$Win(tree) nodes __host__-${H}]] =3D=3D 0} {
-	   $Win(tree) delete __host__-${H}
+    if {[llength [$Win(tree) nodes __host__@${H}]] =3D=3D 0} {
+	   $Win(tree) delete __host__@${H}
 	   set h [$Win(tree) nodes root]
 	   if {[llength $h] !=3D 0} {
 	       select 1 [lindex $h 0]
 		   select 1 [lindex [$Win(tree) nodes $h] 0]
 	   }
 	} else {
-	    select 1 [lindex [$Win(tree) nodes __host__-${H}] 0]
+	    select 1 [lindex [$Win(tree) nodes __host__@${H}] 0]
 	}
=20
 	#set i [::Connections::getIds $H $D]
--- lib/connections.tcl.orig	Mon Feb 16 22:16:45 2004
+++ lib/connections.tcl	Sun Mar 13 21:12:06 2005
@@ -665,15 +665,15 @@
         -text ""
=20
     # now open up the db and select the table node
-    set honode "__host__-$PgAcVar(currentdb,host)"
-    set dbnode "__db__-$PgAcVar(currentdb,host)-$PgAcVar(currentdb,dbname)"
+    set honode "__host__@$PgAcVar(currentdb,host)"
+    set dbnode "__db__@$PgAcVar(currentdb,host)@$PgAcVar(currentdb,dbname)"
     if {[$::Mainlib::Win(tree) exists $honode]} {
         $::Mainlib::Win(tree) opentree $honode 0
     }
     if {[$::Mainlib::Win(tree) exists $dbnode]} {
         $::Mainlib::Win(tree) opentree $dbnode 0
     }
-    ::Mainlib::select 1 "$Conn(host,$id_)-$Conn(dbname,$id_)-Tables"
+    ::Mainlib::select 1 "$Conn(host,$id_)@$Conn(dbname,$id_)@Tables"
=20
     return 1
=20
--- pgaccess.tcl.orig	Fri Feb 20 03:08:02 2004
+++ pgaccess.tcl	Sun Mar 13 21:07:22 2005
@@ -1035,14 +1035,14 @@
        ##
        if {[string match "" $thost]} {set thost sockets}
=20
-       if {(![string match "" $tdb]) && ([$::Mainlib::Win(tree) exists __d=
b__-${thost}-${tdb}])} {
+       if {(![string match "" $tdb]) && ([$::Mainlib::Win(tree) exists __d=
b__@${thost}@${tdb}])} {
=20
-            if {[$::Mainlib::Win(tree) exists __host__-$thost]} {
-                $::Mainlib::Win(tree) opentree __host__-$thost 0
+            if {[$::Mainlib::Win(tree) exists __host__@$thost]} {
+                $::Mainlib::Win(tree) opentree __host__@$thost 0
             }
-            if {[$::Mainlib::Win(tree) exists __db__-${thost}-$tdb]} {
-                $::Mainlib::Win(tree) opentree __db__-${thost}-$tdb
-                ::Mainlib::select 1 __db__-${thost}-$tdb
+            if {[$::Mainlib::Win(tree) exists __db__@${thost}@$tdb]} {
+                $::Mainlib::Win(tree) opentree __db__@${thost}@$tdb
+                ::Mainlib::select 1 __db__@${thost}@$tdb
             }
        }
=20
@@ -1191,20 +1191,20 @@
     if {[::Connections::openConn 0 $PgAcVar(PGACCESS_LOGIN) $PgAcVar(PGACC=
ESS_SMLOGIN)]} {
         set H $PgAcVar(opendb,host)
         set d $PgAcVar(opendb,dbname)
-        if {![$::Mainlib::Win(tree) exists __db__-${H}-${d}]} {
+        if {![$::Mainlib::Win(tree) exists __db__@${H}@${d}]} {
             ::Mainlib::addDbNode $H $d
         }
-        if {[$::Mainlib::Win(tree) exists __host__-$H]} {
-            $::Mainlib::Win(tree) opentree __host__-$H 0
+        if {[$::Mainlib::Win(tree) exists __host__@$H]} {
+            $::Mainlib::Win(tree) opentree __host__@$H 0
         }
-        if {[$::Mainlib::Win(tree) exists __db__-${H}-$d]} {
-            $::Mainlib::Win(tree) opentree __db__-${H}-$d
+        if {[$::Mainlib::Win(tree) exists __db__@${H}@$d]} {
+            $::Mainlib::Win(tree) opentree __db__@${H}@$d
         }
-        if {[$::Mainlib::Win(tree) exists __host__-$H]} {
-            ::Mainlib::select 1 __host__-$H
+        if {[$::Mainlib::Win(tree) exists __host__@$H]} {
+            ::Mainlib::select 1 __host__@$H
         }
-        if {[$::Mainlib::Win(tree) exists __db__-${H}-$d]} {
-            ::Mainlib::select 1 __db__-${H}-$d
+        if {[$::Mainlib::Win(tree) exists __db__@${H}@$d]} {
+            ::Mainlib::select 1 __db__@${H}@$d
         }
         # ::Mainlib::cmd_Tables
     } else {

--GID0FwUMdk1T2AWN--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050313205924.GA69260>