summaryrefslogtreecommitdiff
path: root/source3/smbwrapper/smbw.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-10-04 11:25:06 +0000
committerAndrew Tridgell <tridge@samba.org>1998-10-04 11:25:06 +0000
commit1970c92c0a56672308314d39718f994302c95c95 (patch)
treec86bf6108aac78b6d8d6c7581d2809f1a7063668 /source3/smbwrapper/smbw.c
parentf2c43ee03933b10cd815af233910d3a0c756f219 (diff)
downloadsamba-1970c92c0a56672308314d39718f994302c95c95.tar.gz
samba-1970c92c0a56672308314d39718f994302c95c95.tar.bz2
samba-1970c92c0a56672308314d39718f994302c95c95.zip
support NetServerEnum in smbwrapper. You can now do a ls in /smb/ and
it will list all servers in your workgroup. You can set your workgroup with the SMBW_WORKGROUP environment variable. (This used to be commit 64699810e2d94e8648a0a3341b1cc826d4e8bfd9)
Diffstat (limited to 'source3/smbwrapper/smbw.c')
-rw-r--r--source3/smbwrapper/smbw.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/source3/smbwrapper/smbw.c b/source3/smbwrapper/smbw.c
index 054b694c41..650d0a08f5 100644
--- a/source3/smbwrapper/smbw.c
+++ b/source3/smbwrapper/smbw.c
@@ -207,7 +207,7 @@ char *smbw_parse_path(const char *fname, char *server, char *share, char *path)
{
static pstring s;
char *p, *p2;
- int len;
+ int len = strlen(SMBW_PREFIX)-1;
*server = *share = *path = 0;
@@ -221,9 +221,12 @@ char *smbw_parse_path(const char *fname, char *server, char *share, char *path)
DEBUG(5,("cleaned %s (fname=%s cwd=%s)\n",
s, fname, smb_cwd));
- if (strncmp(s,SMBW_PREFIX,strlen(SMBW_PREFIX))) return s;
+ if (strncmp(s,SMBW_PREFIX,len) ||
+ (s[len] != '/' && s[len] != 0)) return s;
+
+ p = s + len;
+ if (*p == '/') p++;
- p = s + strlen(SMBW_PREFIX);
p2 = strchr(p,'/');
if (p2) {
@@ -239,6 +242,11 @@ char *smbw_parse_path(const char *fname, char *server, char *share, char *path)
p = p2;
if (!p) {
+ if (len == 0) {
+ char *workgroup = getenv("SMBW_WORKGROUP");
+ if (!workgroup) workgroup = lp_workgroup();
+ slprintf(server,sizeof(fstring)-1, "%s#1D", workgroup);
+ }
fstrcpy(share,"IPC$");
pstrcpy(path,"");
goto ok;
@@ -336,6 +344,8 @@ struct smbw_server *smbw_server(char *server, char *share)
char *password;
char *workgroup;
struct nmb_name called, calling;
+ char *p, *server_n = server;
+ fstring group;
ZERO_STRUCT(c);
@@ -364,8 +374,21 @@ struct smbw_server *smbw_server(char *server, char *share)
make_nmb_name(&called , server, 0x20, "");
again:
+ if ((p=strchr(server_n,'#'))) {
+ struct in_addr ip;
+ fstrcpy(group, server_n);
+ p = strchr(group,'#');
+ *p = 0;
+ if (!find_master(group, &ip)) {
+ errno = ENOENT;
+ return NULL;
+ }
+ fstrcpy(group, inet_ntoa(ip));
+ server_n = group;
+ }
+
/* have to open a new connection */
- if (!cli_initialise(&c) || !cli_connect(&c, server, NULL)) {
+ if (!cli_initialise(&c) || !cli_connect(&c, server_n, NULL)) {
errno = ENOENT;
return NULL;
}