Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Jan 1997 13:42:58 +0200
From:      Mark Murray <mark@grondar.za>
To:        peter@freebsd.org
Cc:        current@freebsd.org
Subject:   Static binaries and dlopen(3) with a new crypt(3) lib.
Message-ID:  <199701191143.NAA01005@grackle.grondar.za>

next in thread | raw e-mail | index | archive | help
------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <980.853673992.1@grackle.grondar.za>

Hi Folks

To get the latest incarnation of crypt(3) to work in a decent way,
I have decided on a new course of action.

Brandon Gillespie has rewritten parts of the code to make it
extensible, and I like what he has done quite a bit. He has extended
PHK's $1$xxxx$ MD5 salt to a more general model where the salt is
now $n$xxxxx$, and n represents the encryption (actually hash)
type. So far we have 1=MD5, 2=SHS, and a salt that does not begin
with either defaults to DES.

Now, the rub; I would like to make the DES module available by
dlopen(3) et al so we do not have to ship a whole separate library.
Right now, we have libscrypt and libdescrypt, with libcrypt being
a symlink to whichever is required.

I would like both of lib{s|des}crypt to disappear, and libcrypt to
reappear with an optional module (say, des_module.so), which is
used only if found, and which can be made a part of the secure
dist.

Questions:

1) Peter did some mods to crt0 that seemed to hint that this would
work even for static binaries. I cannot duplicate his success. I
have a bit of test code (see enclosure) which I link like this:

$ cc -Wall -Wl,-Bstatic -o main main.c

It works if I leave out the -Wl,-Bstatic bit (to make it all
dynamic).  Any clues?

2) We have no precedent in the tree AFAIK for "optionally linked"
libraries and modules. Does anybody have any religion about this,
or can I just go ahead and invent? One of the problems - libraries
have this nice, automatic way of looking at version numbers (.so.N.M),
whereas in dlopen(3), one must supply a name (hardcoded?).

M

-- 
Mark Murray                PGP key fingerprint = 80 36 6E 40 83 D6 8A 36
This .sig is umop ap!sdn.                        BC 06 EA 0E 7A F2 CE CE


------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <980.853673992.2@grackle.grondar.za>
Content-Description: main.c

#include <stdio.h>
#include <dlfcn.h>

void myprint(char *string)
{
	puts("Linked in\n");
	puts(string);
}

int main(int argc, char *argv[])
{
	void *handle;
	void (* mydlprint)(char *) = NULL;
	void myprint(char *);

	myprint("Normal call\n");

	handle = dlopen("/home/mark/work/dlopen/libmydlprint.so.2.0", RTLD_LAZY);
	if (handle) {
		printf("Success - dlopen returned: %p\n", handle);
		mydlprint = dlsym(handle, "_mydlprint");
		if (mydlprint) {
			printf("Success - dlsym returned: %p\n", mydlprint);
			(*mydlprint)("Dynamic call\n");
		}
		else printf("Failure - dlsym returned NULL: %s\n", dlerror());
		dlclose(handle);
		return 0;
	}
	printf("Failure - dlopen returned NULL: %s\n", dlerror());
	return 1;
}

------- =_aaaaaaaaaa0--



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