2 Unix SMB/Netbios implementation.
4 SMB wrapper functions - frontend
5 Copyright (C) Andrew Tridgell 1998
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 static void smbsh_usage(void)
26 printf("smbsh [options]\n\n");
27 printf(" -W workgroup\n");
28 printf(" -U username\n");
29 printf(" -P prefix\n");
30 printf(" -R resolve order\n");
31 printf(" -d debug level\n");
32 printf(" -l logfile\n");
33 printf(" -L libdir\n");
37 int main(int argc, char *argv[])
51 while ((opt = getopt(argc, argv, "W:U:R:d:P:l:hL:")) != EOF) {
57 smbw_setshared("WORKGROUP", optarg);
60 smbw_setshared("LOGFILE", optarg);
63 smbw_setshared("PREFIX", optarg);
66 smbw_setshared("DEBUG", optarg);
69 p = strchr(optarg,'%');
72 smbw_setshared("PASSWORD",p+1);
74 smbw_setshared("USER", optarg);
77 smbw_setshared("RESOLVE_ORDER",optarg);
87 if (!smbw_getshared("USER")) {
89 u = fgets_slash(line, sizeof(line)-1, stdin);
90 smbw_setshared("USER", u);
93 if (!smbw_getshared("PASSWORD")) {
94 p = getpass("Password: ");
95 smbw_setshared("PASSWORD", p);
98 smbw_setenv("PS1", "smbsh$ ");
102 slprintf(line,sizeof(line)-1,"PWD_%d", (int)getpid());
104 smbw_setshared(line, wd);
106 slprintf(line,sizeof(line)-1,"%s/smbwrapper.so", libd);
107 smbw_setenv("LD_PRELOAD", line);
109 slprintf(line,sizeof(line)-1,"%s/smbwrapper.32.so", libd);
111 if (file_exist(line, NULL)) {
112 slprintf(line,sizeof(line)-1,"%s/smbwrapper.32.so:DEFAULT", libd);
113 smbw_setenv("_RLD_LIST", line);
114 slprintf(line,sizeof(line)-1,"%s/smbwrapper.so:DEFAULT", libd);
115 smbw_setenv("_RLDN32_LIST", line);
117 slprintf(line,sizeof(line)-1,"%s/smbwrapper.so:DEFAULT", libd);
118 smbw_setenv("_RLD_LIST", line);
122 char *shellpath = getenv("SHELL");
124 execl(shellpath,"smbsh",NULL);
126 execl("/bin/sh","smbsh",NULL);
128 printf("launch failed!\n");