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");
36 int main(int argc, char *argv[])
47 while ((opt = getopt(argc, argv, "W:U:R:d:P:l:h")) != EOF) {
50 smbw_setshared("WORKGROUP", optarg);
53 smbw_setshared("LOGFILE", optarg);
56 smbw_setshared("PREFIX", optarg);
59 smbw_setshared("DEBUG", optarg);
62 p = strchr(optarg,'%');
65 smbw_setshared("PASSWORD",p+1);
67 smbw_setshared("USER", optarg);
70 smbw_setshared("RESOLVE_ORDER",optarg);
81 if (!smbw_getshared("USER")) {
83 u = fgets_slash(line, sizeof(line)-1, stdin);
84 smbw_setshared("USER", u);
87 if (!smbw_getshared("PASSWORD")) {
88 p = getpass("Password: ");
89 smbw_setshared("PASSWORD", p);
92 smbw_setenv("PS1", "smbsh$ ");
96 slprintf(line,sizeof(line)-1,"PWD_%d", (int)getpid());
98 smbw_setshared(line, wd);
100 slprintf(line,sizeof(line)-1,"%s/smbwrapper.so", libd);
101 smbw_setenv("LD_PRELOAD", line);
103 slprintf(line,sizeof(line)-1,"%s/smbwrapper.32.so", libd);
105 if (file_exist(line, NULL)) {
106 slprintf(line,sizeof(line)-1,"%s/smbwrapper.32.so:DEFAULT", libd);
107 smbw_setenv("_RLD_LIST", line);
108 slprintf(line,sizeof(line)-1,"%s/smbwrapper.so:DEFAULT", libd);
109 smbw_setenv("_RLDN32_LIST", line);
111 slprintf(line,sizeof(line)-1,"%s/smbwrapper.so:DEFAULT", libd);
112 smbw_setenv("_RLD_LIST", line);
116 char *shellpath = getenv("SHELL");
118 execl(shellpath,"smbsh",NULL);
120 execl("/bin/sh","smbsh",NULL);
122 printf("launch failed!\n");