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 char *libd = dyn_BINDIR;
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")) {
86 u = fgets_slash(line, sizeof(line)-1, x_stdin);
87 smbw_setshared("USER", u);
90 if (!smbw_getshared("PASSWORD")) {
91 p = getpass("Password: ");
92 smbw_setshared("PASSWORD", p);
95 smbw_setenv("PS1", "smbsh$ ");
99 slprintf(line,sizeof(line)-1,"PWD_%d", (int)getpid());
101 smbw_setshared(line, wd);
103 slprintf(line,sizeof(line)-1,"%s/smbwrapper.so", libd);
104 smbw_setenv("LD_PRELOAD", line);
106 slprintf(line,sizeof(line)-1,"%s/smbwrapper.32.so", libd);
108 if (file_exist(line, NULL)) {
109 slprintf(line,sizeof(line)-1,"%s/smbwrapper.32.so:DEFAULT", libd);
110 smbw_setenv("_RLD_LIST", line);
111 slprintf(line,sizeof(line)-1,"%s/smbwrapper.so:DEFAULT", libd);
112 smbw_setenv("_RLDN32_LIST", line);
114 slprintf(line,sizeof(line)-1,"%s/smbwrapper.so:DEFAULT", libd);
115 smbw_setenv("_RLD_LIST", line);
119 char *shellpath = getenv("SHELL");
121 execl(shellpath,"smbsh",NULL);
123 execl("/bin/sh","smbsh",NULL);
125 printf("launch failed!\n");