summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/smbwrapper/README36
-rw-r--r--source/smbwrapper/shared.c3
-rw-r--r--source/smbwrapper/smbsh.c57
-rw-r--r--source/smbwrapper/smbw.c6
4 files changed, 72 insertions, 30 deletions
diff --git a/source/smbwrapper/README b/source/smbwrapper/README
index 18cfc240563..8d5c376f825 100644
--- a/source/smbwrapper/README
+++ b/source/smbwrapper/README
@@ -25,42 +25,40 @@ To use it you need to do this:
You will be asked for a username and password. After that you will be
returned to a shell prompt. It is actually a subshell running with
-smbwrapper enabled. You can confirm this by checking if the SMBW_USER
-environment variable is defined.
+smbwrapper enabled.
Now try to access /smb/SERVER for some SMB server name and see what
-happens. If you set SMBW_WORKGROUP to your workgroup or have workgroup
-set in yoru smb.conf then listing /smb/ should list all SMB servers in
-your workgroup.
+happens. If you use the -W option to set your workgroup or have
+workgroup set in your smb.conf then listing /smb/ should list all SMB
+servers in your workgroup.
-ENVIRONMENT VARIABLES
----------------------
+OPTIONS
+-------
-SMBW_USER
- This is usually set by smbsh but you can set it manually. It
- specifies the username you will connect to servers with.
+-U username
+ specify the username and optional password (as user%password)
-SMBW_PASSWORD
- This is usually set by smbsh but you can set it manually. It
- specifies the password used to connect to smb servers.
-
-SMBW_DEBUG
+-d debug level
This is an integer that controls the internal debug level of smbw. It
defaults to 0, which means no debug info.
-SMBW_LOGFILE
+-l logfile
The place where smbw debug logs are put. If this is not set then
stderr is used.
-SMBW_PREFIX
+-P prefix
The root of the SMB filesystem. This defaults to /smb/ but you can
set it to any name you like.
-SMBW_WORKGROUP
+-W workgroup
This is the workgroup used for browsing (ie. listing machines in the
/smb/ directory). It defaults to the one set in smb.conf.
+-R resolve order
+ This allows you to override the setting of the name resolve order
+ from smb.conf
+
ATTRIBUTE MAPPING
-----------------
@@ -92,3 +90,5 @@ things that I know don't work:
If you want to help with the development of this code then join the
samba-technical mailing list.
+
+
diff --git a/source/smbwrapper/shared.c b/source/smbwrapper/shared.c
index 4637248dcec..0e83c3704d0 100644
--- a/source/smbwrapper/shared.c
+++ b/source/smbwrapper/shared.c
@@ -35,13 +35,14 @@ void smbw_setup_shared(void)
int fd;
pstring s, name;
- slprintf(s,sizeof(s)-1, "%s/msg.XXXXXX",tmpdir());
+ slprintf(s,sizeof(s)-1, "%s/smbw.XXXXXX",tmpdir());
fstrcpy(name,(char *)mktemp(s));
/* note zero permissions! don't change this */
fd = open(name,O_RDWR|O_CREAT|O_TRUNC|O_EXCL,0);
if (fd == -1) goto failed;
+ unlink(name);
shared_fd = set_maxfiles(SMBW_MAX_OPEN);
diff --git a/source/smbwrapper/smbsh.c b/source/smbwrapper/smbsh.c
index 0489bb2b637..ed0ab5290f9 100644
--- a/source/smbwrapper/smbsh.c
+++ b/source/smbwrapper/smbsh.c
@@ -21,26 +21,61 @@
#include "includes.h"
+static void smbsh_usage(void)
+{
+ printf("smbsh [options]\n\n");
+ printf(" -W workgroup\n");
+ printf(" -U username\n");
+ printf(" -P prefix\n");
+ printf(" -R resolve order\n");
+ printf(" -d debug level\n");
+ printf(" -l logfile\n");
+ exit(0);
+}
+
int main(int argc, char *argv[])
{
char *p, *u;
char *libd = BINDIR;
pstring line;
extern FILE *dbf;
+ int opt;
+ extern char *optarg;
+ extern int optind;
smbw_setup_shared();
- p = getenv("SMBW_DEBUG");
- if (p) smbw_setshared("DEBUG", p);
-
- p = getenv("SMBW_WORKGROUP");
- if (p) smbw_setshared("WORKGROUP", p);
-
- p = getenv("SMBW_USER");
- if (p) smbw_setshared("USER", p);
-
- p = getenv("SMBW_PASSWORD");
- if (p) smbw_setshared("PASSWORD", p);
+ while ((opt = getopt(argc, argv, "W:U:R:d:P:l:h")) != EOF) {
+ switch (opt) {
+ case 'W':
+ smbw_setshared("WORKGROUP", optarg);
+ break;
+ case 'l':
+ smbw_setshared("LOGFILE", optarg);
+ break;
+ case 'P':
+ smbw_setshared("PREFIX", optarg);
+ break;
+ case 'd':
+ smbw_setshared("DEBUG", optarg);
+ break;
+ case 'U':
+ p = strchr(optarg,'%');
+ if (p) {
+ *p=0;
+ smbw_setshared("PASSWORD",p+1);
+ }
+ smbw_setshared("USER", optarg);
+ break;
+ case 'R':
+ smbw_setshared("RESOLVE_ORDER",optarg);
+ break;
+
+ case 'h':
+ default:
+ smbsh_usage();
+ }
+ }
charset_initialise();
diff --git a/source/smbwrapper/smbw.c b/source/smbwrapper/smbw.c
index 7ddc46ca9b0..45285180768 100644
--- a/source/smbwrapper/smbw.c
+++ b/source/smbwrapper/smbw.c
@@ -85,6 +85,10 @@ void smbw_init(void)
DEBUGLEVEL = atoi(p);
}
+ if ((p=smbw_getshared("RESOLVE_ORDER"))) {
+ lp_set_name_resolve_order(p);
+ }
+
if ((p=smbw_getshared("PREFIX"))) {
slprintf(smbw_prefix,sizeof(fstring)-1, "/%s/", p);
string_sub(smbw_prefix,"//", "/");
@@ -102,6 +106,8 @@ void smbw_init(void)
set_maxfiles(SMBW_MAX_OPEN);
+ BlockSignals(True,SIGPIPE);
+
errno = eno;
}