2 Unix SMB/CIFS implementation.
3 SMB wrapper functions - frontend
4 Copyright (C) Andrew Tridgell 1998
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 of the License, or
9 (at your option) any later version.
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
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 static void smbsh_usage(void)
25 printf("smbsh [options]\n\n");
26 printf(" -W workgroup\n");
27 printf(" -U username\n");
28 printf(" -P prefix\n");
29 printf(" -R resolve order\n");
30 printf(" -d debug level\n");
31 printf(" -l logfile\n");
32 printf(" -L libdir\n");
36 int main(int argc
, char *argv
[])
39 const char *libd
= dyn_LIBDIR
;
48 while ((opt
= getopt(argc
, argv
, "W:U:R:d:P:l:hL:")) != EOF
) {
54 smbw_setshared("WORKGROUP", optarg
);
57 smbw_setshared("LOGFILE", optarg
);
60 smbw_setshared("PREFIX", optarg
);
63 smbw_setshared("DEBUG", optarg
);
66 p
= strchr_m(optarg
,'%');
69 smbw_setshared("PASSWORD",p
+1);
71 smbw_setshared("USER", optarg
);
74 smbw_setshared("RESOLVE_ORDER",optarg
);
84 if (!smbw_getshared("USER")) {
87 u
= fgets_slash(line
, sizeof(line
)-1, x_stdin
);
88 smbw_setshared("USER", u
);
91 if (!smbw_getshared("PASSWORD")) {
92 p
= getpass("Password: ");
93 smbw_setshared("PASSWORD", p
);
96 setenv("PS1", "smbsh$ ", 1);
100 slprintf(line
,sizeof(line
)-1,"PWD_%d", (int)getpid());
102 smbw_setshared(line
, wd
);
104 slprintf(line
,sizeof(line
)-1,"%s/smbwrapper.so", libd
);
105 setenv("LD_PRELOAD", line
, 1);
107 slprintf(line
,sizeof(line
)-1,"%s/smbwrapper.32.so", libd
);
109 if (file_exist(line
, NULL
)) {
110 slprintf(line
,sizeof(line
)-1,"%s/smbwrapper.32.so:DEFAULT", libd
);
111 setenv("_RLD_LIST", line
, 1);
112 slprintf(line
,sizeof(line
)-1,"%s/smbwrapper.so:DEFAULT", libd
);
113 setenv("_RLDN32_LIST", line
, 1);
115 slprintf(line
,sizeof(line
)-1,"%s/smbwrapper.so:DEFAULT", libd
);
116 setenv("_RLD_LIST", line
, 1);
120 char *shellpath
= getenv("SHELL");
122 execl(shellpath
,"smbsh",NULL
);
124 execl("/bin/sh","smbsh",NULL
);
126 printf("launch failed!\n");