From owner-freebsd-current Sun Jan 19 03:43:23 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id DAA28079 for current-outgoing; Sun, 19 Jan 1997 03:43:23 -0800 (PST) Received: from grackle.grondar.za (grackle.grondar.za [196.7.18.131]) by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id DAA28074; Sun, 19 Jan 1997 03:43:11 -0800 (PST) Received: from grackle.grondar.za (localhost [127.0.0.1]) by grackle.grondar.za (8.8.4/8.8.4) with ESMTP id NAA01005; Sun, 19 Jan 1997 13:43:03 +0200 (SAT) Message-Id: <199701191143.NAA01005@grackle.grondar.za> To: peter@freebsd.org cc: current@freebsd.org Subject: Static binaries and dlopen(3) with a new crypt(3) lib. X-Face: "=q0"STs_81w9y4&#}>]hpQ-VBL.1^,QB{9u[05?&^k1*y#*OpIkS7b?V0Rs8qg]`Z}LBTa JT}q{S+z%%SR{~1@;Ybho~Ck.)PC/#3$lceQZ`O Date: Sun, 19 Jan 1997 13:42:58 +0200 From: Mark Murray Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk ------- =_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 #include 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--