From 2e99f0f8d31eb1e9ff518df17be30205752b17cd Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Mon, 19 Feb 2001 05:50:09 +0000 Subject: Opps, last one did not commit the correct changes ... Here they are. This now uses a lookup on <1D> and then does a name status query to the IP address returned to find the name of the server. Seems to work well against Samba, Win9X, WinNT and Win2K. (This used to be commit debb723194f903c7b3af61f93949df062985e218) --- source3/libsmb/libsmbclient.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'source3/libsmb/libsmbclient.c') diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c index 67d5b92100..1444e5883a 100644 --- a/source3/libsmb/libsmbclient.c +++ b/source3/libsmb/libsmbclient.c @@ -1471,7 +1471,7 @@ static void dir_list_fn(file_info *finfo, const char *mask, void *state) { - fprintf(stderr, "Finfo->name=%s, mask=%s\n", finfo->name, mask); + /* fprintf(stderr, "Finfo->name=%s, mask=%s, mode=%0X\n", finfo->name, mask, finfo->mode);*/ if (add_dirent((struct smbc_file *)state, finfo->name, "", (finfo->mode&aDIR?SMBC_DIR:SMBC_FILE)) < 0) { @@ -1561,14 +1561,30 @@ int smbc_opendir(const char *fname) /* We have server and share and path empty ... so list the workgroups */ - /* fprintf(stderr, "Workgroup is: %s\n", lp_workgroup()); */ - cli_get_backup_server(my_netbios_name, lp_workgroup(), server, sizeof(server)); + /*cli_get_backup_server(my_netbios_name, lp_workgroup(), server, sizeof(server));*/ + + if (!resolve_name(lp_workgroup(), &rem_ip, 0x1d)) { + + errno = EINVAL; /* Something wrong with smb.conf? */ + return -1; + + } smbc_file_table[slot]->dir_type = SMBC_WORKGROUP; - /* - * Get a connection to IPC$ on the server if we do not already have one - */ + /* find the name of the server ... */ + + if (!name_status_find(0, rem_ip, server)) { + + fprintf(stderr, "Could not get the name of local master browser ...\n"); + errno = EINVAL; + return -1; + + } + + /* + * Get a connection to IPC$ on the server if we do not already have one + */ srv = smbc_server(server, "IPC$", lp_workgroup(), user, password); @@ -1618,7 +1634,15 @@ int smbc_opendir(const char *fname) * Get the backup list ... */ - cli_get_backup_server(my_netbios_name, server, buserver, sizeof(buserver)); + /*cli_get_backup_server(my_netbios_name, server, buserver, sizeof(buserver)); */ + + if (!name_status_find(0, rem_ip, buserver)) { + + fprintf(stderr, "Could not get name of local master browser ...\n"); + errno = EPERM; /* FIXME, is this correct */ + return -1; + + } /* * Get a connection to IPC$ on the server if we do not already have one -- cgit