diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/client/client.c | 12 | ||||
-rw-r--r-- | source3/libsmb/clirap.c | 52 | ||||
-rw-r--r-- | source3/nmbd/nmbd_synclists.c | 9 | ||||
-rw-r--r-- | source3/smbwrapper/smbw_dir.c | 11 | ||||
-rw-r--r-- | source3/utils/torture.c | 6 |
5 files changed, 65 insertions, 25 deletions
diff --git a/source3/client/client.c b/source3/client/client.c index 5995f1a243..1a1abaf732 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -1533,7 +1533,8 @@ static void cmd_lcd(void) /**************************************************************************** list a share name ****************************************************************************/ -static void browse_fn(const char *name, uint32 m, const char *comment) +static void browse_fn(const char *name, uint32 m, + const char *comment, void *state) { fstring typestr; @@ -1566,7 +1567,7 @@ static BOOL browse_host(BOOL sort) printf("\n\tSharename Type Comment\n"); printf("\t--------- ---- -------\n"); - if((ret = cli_RNetShareEnum(cli, browse_fn)) == -1) + if((ret = cli_RNetShareEnum(cli, browse_fn, NULL)) == -1) printf("Error returning browse list: %s\n", cli_errstr(cli)); return (ret != -1); @@ -1575,7 +1576,8 @@ static BOOL browse_host(BOOL sort) /**************************************************************************** list a server name ****************************************************************************/ -static void server_fn(const char *name, uint32 m, const char *comment) +static void server_fn(const char *name, uint32 m, + const char *comment, void *state) { printf("\t%-16.16s %s\n", name, comment); } @@ -1590,12 +1592,12 @@ static BOOL list_servers(char *wk_grp) printf("\n\tServer Comment\n"); printf("\t--------- -------\n"); - cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL, server_fn); + cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL, server_fn, NULL); printf("\n\tWorkgroup Master\n"); printf("\t--------- -------\n"); - cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_DOMAIN_ENUM, server_fn); + cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_DOMAIN_ENUM, server_fn, NULL); return True; } diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 085b1c35bb..cd261eac59 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -137,7 +137,7 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) /**************************************************************************** call a NetShareEnum - try and browse available connections on a host ****************************************************************************/ -int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *)) +int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *, void *), void *state) { char *rparam = NULL; char *rdata = NULL; @@ -184,7 +184,7 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co char *cmnt = comment_offset?(rdata+comment_offset-converter):""; dos_to_unix(sname,True); dos_to_unix(cmnt,True); - fn(sname, type, cmnt); + fn(sname, type, cmnt, state); } } else { DEBUG(4,("NetShareEnum res=%d\n", res)); @@ -210,7 +210,8 @@ The callback function takes 3 arguments: the machine name, the server type and the comment. ****************************************************************************/ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, - void (*fn)(const char *, uint32, const char *)) + void (*fn)(const char *, uint32, const char *, void *), + void *state) { char *rparam = NULL; char *rdata = NULL; @@ -219,16 +220,38 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, pstring param; int uLevel = 1; int count = -1; + + /* + * First, check that the stype is reasonable ... + */ + + if (stype&0x80000000 && stype&0x7FFFFFFF) { + + /* Set an error here ... */ + + return False; + + } /* send a SMBtrans command with api NetServerEnum */ p = param; SSVAL(p,0,0x68); /* api number */ p += 2; - pstrcpy(p,"WrLehDz"); + if (!(stype&0x80000000)) + pstrcpy(p,"WrLehDz"); + else + pstrcpy(p,"WrLehDO"); p = skip_string(p,1); - pstrcpy(p,"B16BBDz"); - + if (!(stype&0x80000000)) { + pstrcpy(p,"B16BBDz"); + uLevel = 1; + } + else { + pstrcpy(p,"B16"); + uLevel = 0; + } + p = skip_string(p,1); SSVAL(p,0,uLevel); SSVAL(p,2,CLI_BUFFER_SIZE); @@ -255,7 +278,9 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, count=SVAL(rparam,4); p = rdata; - for (i = 0;i < count;i++, p += 26) { + + if (!(stype&0x80000000)) { + for (i = 0;i < count;i++, p += 26) { char *sname = p; int comment_offset = (IVAL(p,22) & 0xFFFF)-converter; char *cmnt = comment_offset?(rdata+comment_offset):""; @@ -265,7 +290,18 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, dos_to_unix(sname, True); dos_to_unix(cmnt, True); - fn(sname, stype, cmnt); + fn(sname, stype, cmnt, state); + } + } + else { + for (i = 0; i < count; i++, p+= 16) { + char *sname = p; + + dos_to_unix(sname, True); + + fn(sname, stype, NULL, state); + + } } } } diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c index 7d10250325..bc731a9ceb 100644 --- a/source3/nmbd/nmbd_synclists.c +++ b/source3/nmbd/nmbd_synclists.c @@ -51,7 +51,8 @@ static FILE *fp; This is the NetServerEnum callback. Note sname and comment are in UNIX codepage format. ******************************************************************/ -static void callback(const char *sname, uint32 stype, const char *comment) +static void callback(const char *sname, uint32 stype, + const char *comment, void *state) { fprintf(fp,"\"%s\" %08X \"%s\"\n", sname, stype, comment); } @@ -108,8 +109,8 @@ static void sync_child(char *name, int nm_type, /* Fetch a workgroup list. */ cli_NetServerEnum(&cli, unix_workgroup, - local_type|SV_TYPE_DOMAIN_ENUM, - callback); + local_type|SV_TYPE_DOMAIN_ENUM, + callback, NULL); /* Now fetch a server list. */ if (servers) { @@ -117,7 +118,7 @@ static void sync_child(char *name, int nm_type, dos_to_unix(unix_workgroup, True); cli_NetServerEnum(&cli, unix_workgroup, local?SV_TYPE_LOCAL_LIST_ONLY:SV_TYPE_ALL, - callback); + callback, NULL); } cli_shutdown(&cli); diff --git a/source3/smbwrapper/smbw_dir.c b/source3/smbwrapper/smbw_dir.c index cc0e2ec748..a30f3dde75 100644 --- a/source3/smbwrapper/smbw_dir.c +++ b/source3/smbwrapper/smbw_dir.c @@ -100,7 +100,8 @@ static void smbw_dir_add(struct file_info *finfo, const char *mask) /***************************************************** add a entry to a directory listing *******************************************************/ -static void smbw_share_add(const char *share, uint32 type, const char *comment) +static void smbw_share_add(const char *share, uint32 type, + const char *comment, void *state) { struct file_info finfo; @@ -119,7 +120,7 @@ static void smbw_share_add(const char *share, uint32 type, const char *comment) add a server to a directory listing *******************************************************/ static void smbw_server_add(const char *name, uint32 type, - const char *comment) + const char *comment, void *state) { struct file_info finfo; @@ -204,7 +205,7 @@ int smbw_dir_open(const char *fname) smbw_server_add(".",0,""); smbw_server_add("..",0,""); cli_NetServerEnum(&srv->cli, srv->server_name, SV_TYPE_DOMAIN_ENUM, - smbw_server_add); + smbw_server_add, NULL); *p = '#'; } else if ((p=strstr(srv->server_name,"#1D"))) { DEBUG(4,("doing NetServerEnum\n")); @@ -212,13 +213,13 @@ int smbw_dir_open(const char *fname) smbw_server_add(".",0,""); smbw_server_add("..",0,""); cli_NetServerEnum(&srv->cli, srv->server_name, SV_TYPE_ALL, - smbw_server_add); + smbw_server_add, NULL); *p = '#'; } else if (strcmp(srv->cli.dev,"IPC") == 0) { DEBUG(4,("doing NetShareEnum\n")); smbw_share_add(".",0,""); smbw_share_add("..",0,""); - if (cli_RNetShareEnum(&srv->cli, smbw_share_add) < 0) { + if (cli_RNetShareEnum(&srv->cli, smbw_share_add, NULL) < 0) { errno = smbw_errno(&srv->cli); goto failed; } diff --git a/source3/utils/torture.c b/source3/utils/torture.c index cd348f67fd..fc917702d3 100644 --- a/source3/utils/torture.c +++ b/source3/utils/torture.c @@ -1690,7 +1690,7 @@ static void run_randomipc(int dummy) static void browse_callback(const char *sname, uint32 stype, - const char *comment) + const char *comment, void *state) { printf("\t%20.20s %08x %s\n", sname, stype, comment); } @@ -1714,12 +1714,12 @@ static void run_browsetest(int dummy) printf("domain list:\n"); cli_NetServerEnum(&cli, cli.server_domain, SV_TYPE_DOMAIN_ENUM, - browse_callback); + browse_callback, NULL); printf("machine list:\n"); cli_NetServerEnum(&cli, cli.server_domain, SV_TYPE_ALL, - browse_callback); + browse_callback, NULL); close_connection(&cli); |