Patches for FreeBSD/ELF

From: cr(at)jcmax(dot)com (Cyrus Rahman)
To: pgsql-hackers(at)postgresql(dot)org
Subject: Patches for FreeBSD/ELF
Date: 1998-11-13 07:00:39
Message-ID: 9811130700.AA03183@corona.jcmax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The following set of patches will enable the dynamically loaded modules
in PostgreSQL 6.4 to work properly.

These patches are actually the concatenated patches I've collected as a
tentative update to the FreeBSD port collection. Those patches unrelated to
the ELF modules are from the previous port of postgresql. The help of anyone
familiar enough with postgresql to inspect them and provide me with
suggestions for improvements would be welcomed.

With the patches in place, the regression tests pass (except for minor
textual differences in the depiction of -0.0, and some precision loss
in floating point numbers). The tests in the plpgsql directory also run
successfully. PL/Tcl works sometimes, but as often as not the backend
dies mysteriously - but in any case, not until after the dynamically loaded
modules are successfully loaded.

Cyrus

--- pl/tcl/Makefile.orig Fri Nov 13 00:08:57 1998
+++ pl/tcl/Makefile Fri Nov 13 00:14:50 1998
@@ -44,8 +44,16 @@
# they should work if the shared build of tcl was successful
# on this system.
#
-%$(TCL_SHLIB_SUFFIX): %.o
- $(TCL_SHLIB_LD) -o $@ $< $(TCL_SHLIB_LD_LIBS) $(TCL_LIB_SPEC) $(TCL_LIBS)
+# XXX - This rule is already present - and this technique won't work anyway,
+# since the twice-eval'd value of TCL_SHLIB_LD in FreeBSD ELF:
+#
+# TCL_SHLIB_LD=ld -shared -x -soname $@
+#
+# will lose the trailing '$@', setting the soname to '-o' below and
+# generally messing things up.
+#
+#%$(TCL_SHLIB_SUFFIX): %.o
+# $(TCL_SHLIB_LD) -o $@ $< $(TCL_SHLIB_LD_LIBS) $(TCL_LIB_SPEC) $(TCL_LIBS)


#
--- makefiles/Makefile.freebsd.orig Mon Nov 2 00:30:04 1998
+++ makefiles/Makefile.freebsd Tue Nov 10 19:28:17 1998
@@ -1,13 +1,17 @@
+ifdef ELF_SYSTEM
+LDFLAGS+= -export-dynamic
+endif
+
%.so: %.o
+ifdef ELF_SYSTEM
+ $(LD) -x -shared -o $@ $<
+else
$(LD) -x -r -o $<.obj $<
@echo building shared object $@
@rm -f $(at)(dot)pic
@${AR} cq $(at)(dot)pic `lorder $<.obj | tsort`
${RANLIB} $(at)(dot)pic
@rm -f $@
-ifdef ELF_SYSTEM
- $(LD) -x -Bshareable -o $@ $(at)(dot)pic
-else
$(LD) -x -Bshareable -Bforcearchive -o $@ $(at)(dot)pic
endif

--- backend/port/dynloader/freebsd.c.orig Mon Oct 26 23:41:29 1998
+++ backend/port/dynloader/freebsd.c Thu Nov 12 23:39:36 1998
@@ -83,11 +83,13 @@
void *vp;
char buf[BUFSIZ];

+#ifndef __ELF__
if (*name != '_')
{
sprintf(buf, "_%s", name);
name = buf;
}
+#endif
if ((vp = dlsym(handle, (char *) name)) == (void *) NULL)
sprintf(error_message, "dlsym (%s) failed", name);
return vp;
--- template/freebsd.orig Sat Nov 7 05:45:29 1998
+++ template/freebsd Sat Nov 7 05:52:31 1998
@@ -1,9 +1,9 @@
AROPT:cq
SHARED_LIB:-fpic -DPIC
-CFLAGS:-O2 -m486 -pipe
+CFLAGS:-pipe -O2
SRCH_INC:
SRCH_LIB:
-USE_LOCALE:no
+USE_LOCALE:yes
DLSUFFIX:.so
YFLAGS:-d
YACC:bison -y
--- bin/pg_passwd/pg_passwd.c.orig Sat Jan 31 19:09:26 1998
+++ bin/pg_passwd/pg_passwd.c Sat Jan 31 19:15:43 1998
@@ -23,12 +23,16 @@

#endif

+#ifndef _POSIX_SOURCE
+# define _PASSWORD_LEN 128 /* max length, not containing NULL */
+#endif
+
char *comname;
void usage(FILE *stream);
void read_pwd_file(char *filename);
void write_pwd_file(char *filename, char *bkname);
-void encrypt_pwd(char key[9], char salt[3], char passwd[14]);
-int check_pwd(char key[9], char passwd[14]);
+void encrypt_pwd(char key[9], char salt[3], char passwd[_PASSWORD_LEN+1]);
+int check_pwd(char key[9], char passwd[_PASSWORD_LEN+1]);
void prompt_for_username(char *username);
void prompt_for_password(char *prompt, char *password);

@@ -148,7 +152,7 @@

if (q != NULL)
*(q++) = '\0';
- if (strlen(p) != 13)
+ if (strlen(p) > _PASSWORD_LEN)
{
fprintf(stderr, "WARNING: %s: line %d: illegal password length.\n",
filename, npwds + 1);
@@ -208,7 +212,7 @@
}

void
-encrypt_pwd(char key[9], char salt[3], char passwd[14])
+encrypt_pwd(char key[9], char salt[3], char passwd[_PASSWORD_LEN+1])
{
int n;

@@ -242,9 +246,9 @@
}

int
-check_pwd(char key[9], char passwd[14])
+check_pwd(char key[9], char passwd[_PASSWORD_LEN+1])
{
- char shouldbe[14];
+ char shouldbe[_PASSWORD_LEN+1];
char salt[3];

salt[0] = passwd[0];
@@ -252,7 +256,7 @@
salt[2] = '\0';
encrypt_pwd(key, salt, shouldbe);

- return strncmp(shouldbe, passwd, 13) == 0 ? 1 : 0;
+ return strncmp(shouldbe, passwd, _PASSWORD_LEN) == 0 ? 1 : 0;
}

void
@@ -326,7 +330,7 @@
char salt[3];
char key[9],
key2[9];
- char e_passwd[14];
+ char e_passwd[_PASSWORD_LEN+1];
int i;

comname = argv[0];
--- interfaces/libpgtcl/Makefile.in.orig Sun Oct 18 20:00:41 1998
+++ interfaces/libpgtcl/Makefile.in Sat Nov 7 05:12:43 1998
@@ -27,7 +27,7 @@

OBJS= pgtcl.o pgtclCmds.o pgtclId.o

-SHLIB_LINK= -L../libpq -lpq
+SHLIB_LINK= -L../libpq -lpq -lcrypt

# Shared library stuff, also default 'all' target
include $(SRCDIR)/Makefile.shlib

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter T Mount 1998-11-13 08:12:20 Re: [HACKERS] More CORBA and PostgreSQL
Previous Message Thomas G. Lockhart 1998-11-13 06:52:50 Re: [HACKERS] CASE construct