From 124beb45f857a83a4b7fca0480a56beae2753be7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 22 Jul 1996 12:00:39 +0000 Subject: fix up problems with "smbclient -L". It now uses a generic NetServerEnum with no workgroup attached if the workgroup is "WORKGROUP" (the default in the Makefile) and uses the specific NetServerEnum (with workgroup attached) otherwise. (This used to be commit 6fa3468c9ba50a4de39e3bdc1c976f363fb6a412) --- source3/client/client.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index 27837d08dc..1bd91d3d7a 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -3590,35 +3590,44 @@ static BOOL list_servers(char *wk_grp) char *rparam = NULL; char *rdata = NULL; int rdrcnt,rprcnt; - char *p; + char *p,*svtype_p; pstring param; int uLevel = 1; int count = 0; BOOL ok = False; + BOOL generic_request = False; + + + if (strequal(wk_grp,"WORKGROUP")) { + /* we won't specify a workgroup */ + generic_request = True; + } /* now send a SMBtrans command with api ServerEnum? */ p = param; SSVAL(p,0,0x68); /* api number */ p += 2; - strcpy(p,"WrLehDz"); + + strcpy(p,generic_request?"WrLehDO":"WrLehDz"); p = skip_string(p,1); strcpy(p,"B16BBDz"); -#if 0 - strcpy(p,getenv("XX_STR2")); -#endif p = skip_string(p,1); SSVAL(p,0,uLevel); SSVAL(p,2,0x2000); /* buf length */ p += 4; - SIVAL(p,0,SV_TYPE_ALL); - + svtype_p = p; p += 4; - strcpy(p, wk_grp); - p = skip_string(p,1); + if (!generic_request) { + strcpy(p, wk_grp); + p = skip_string(p,1); + } + + /* first ask for a list of servers in this workgroup */ + SIVAL(svtype_p,0,SV_TYPE_ALL); if (call_api(PTR_DIFF(p+4,param),0, 8,10000, @@ -3656,7 +3665,8 @@ static BOOL list_servers(char *wk_grp) if (rparam) {free(rparam); rparam = NULL;} if (rdata) {free(rdata); rdata = NULL;} - SIVAL(p,0,0x7fffffff); + /* now ask for a list of workgroups */ + SIVAL(svtype_p,0,SV_TYPE_DOMAIN_ENUM); if (call_api(PTR_DIFF(p+4,param),0, 8,10000, -- cgit