diff options
author | ian <ian> | 1998-08-29 21:22:23 +0000 |
---|---|---|
committer | ian <ian> | 1998-08-29 21:22:23 +0000 |
commit | 8ddfdffdd892f3ab3fb42c10ff5abd6653f7c166 (patch) | |
tree | 4047ede22ed795f86723d172dd430a03931e5f0f /authbind.c |
Initial checkin.
Diffstat (limited to 'authbind.c')
-rw-r--r-- | authbind.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/authbind.c b/authbind.c new file mode 100644 index 0000000..6d957ae --- /dev/null +++ b/authbind.c @@ -0,0 +1,38 @@ +/**/ + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <unistd.h> + +#define LD_PRELOAD "LD_PRELOAD" +#define AUTHBINDLIB "AUTHBIND_LIB" +#define LIBAUTHBIND "/usr/lib/authbind/libauthbind.so.0" + +int main(int argc, char *const *argv) { + const char *expreload, *authbindlib, *preload; + char *newpreload; + + authbindlib= getenv(AUTHBINDLIB); + if (!authbindlib) { + if (setenv(AUTHBINDLIB,LIBAUTHBIND,0)) { + perror("authbind: setenv " AUTHBINDLIB); + exit(-1); + } + authbindlib= LIBAUTHBIND; + } + + if ((expreload= getenv(LD_PRELOAD))) { + newpreload= malloc(strlen(expreload)+strlen(authbindlib)+2); + strcpy(newpreload,expreload); + strcat(newpreload,":"); + strcat(newpreload,authbindlib); + preload= newpreload; + } else { + preload= authbindlib; + } + if (setenv(LD_PRELOAD,preload,1)) { perror("authbind: setenv"); exit(-1); } + + execvp(argv[1],argv+1); + perror(argv[1]); exit(-1); +} |