2 * authbind.c - main invoker program
4 * authbind is Copyright (C) 1998 Ian Jackson
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 static const char *rcsid="$Id$";
30 # define "/usr/local/lib/authbind/libauthbind.so." MAJOR_VER
33 #define PRELOAD_VAR "LD_PRELOAD"
34 #define AUTHBINDLIB_VAR "AUTHBIND_LIB"
36 int main(int argc, char *const *argv) {
37 const char *expreload, *authbindlib, *preload;
40 if (argc<2 || argv[1][0]=='-') {
41 fprintf(stderr,"authbind: usage: authbind program arg arg ...\n %s\n",rcsid);
45 authbindlib= getenv(AUTHBINDLIB_VAR);
46 if (!authbindlib) authbindlib= LIBAUTHBIND;
48 if ((expreload= getenv(PRELOAD_VAR))) {
49 newpreload= malloc(strlen(expreload)+strlen(authbindlib)+2);
50 strcpy(newpreload,expreload);
51 strcat(newpreload,":");
52 strcat(newpreload,authbindlib);
57 if (setenv(PRELOAD_VAR,preload,1)) { perror("authbind: setenv"); exit(-1); }
59 execvp(argv[1],argv+1);
60 perror(argv[1]); exit(-1);