summaryrefslogtreecommitdiff
path: root/source3/libsmb/libsmbclient.c
diff options
context:
space:
mode:
authorDerrell Lipman <derrell@samba.org>2005-04-19 19:23:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:56:40 -0500
commit1d08b9013a67184b0ecfe8b013926128719b68a6 (patch)
tree48b05c1be341c1f5183abb7673435e1b0634058a /source3/libsmb/libsmbclient.c
parent67e9fb7c7c61a337da7efb887e401dfaa828b7b5 (diff)
downloadsamba-1d08b9013a67184b0ecfe8b013926128719b68a6.tar.gz
samba-1d08b9013a67184b0ecfe8b013926128719b68a6.tar.bz2
samba-1d08b9013a67184b0ecfe8b013926128719b68a6.zip
r6392: - Fixes bug 2564: when smbc_opendir() was called with a file rather than
a directory, the errno returned could end up as ENOENT rather than ENOTDIR. - Fixes some compiler warnings which showed up on IRIX, as reported by James Peach. (This used to be commit 615a62b21f8d2f7f97bde2f166ddd6849d39b95c)
Diffstat (limited to 'source3/libsmb/libsmbclient.c')
-rw-r--r--source3/libsmb/libsmbclient.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c
index 3e8e604ab1..791427f249 100644
--- a/source3/libsmb/libsmbclient.c
+++ b/source3/libsmb/libsmbclient.c
@@ -646,13 +646,10 @@ SMBCSRV *smbc_server(SMBCCTX *context,
* Force use of port 139 for first try if share is $IPC, empty, or
* null, so browse lists can work
*/
- if (share == NULL || *share == '\0' || strcmp(share, "IPC$") == 0)
- {
+ if (share == NULL || *share == '\0' || strcmp(share, "IPC$") == 0) {
port_try_first = 139;
port_try_next = 445;
- }
- else
- {
+ } else {
port_try_first = 445;
port_try_next = 139;
}
@@ -1905,6 +1902,8 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname)
fstring server, share, user, password, options;
pstring workgroup;
pstring path;
+ uint16 mode;
+ char *p;
SMBCSRV *srv = NULL;
SMBCFILE *dir = NULL;
struct in_addr rem_ip;
@@ -2197,6 +2196,7 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname)
/* Now, list the files ... */
+ p = path + strlen(path);
pstrcat(path, "\\*");
if (cli_list(&srv->cli, path, aDIR | aSYSTEM | aHIDDEN, dir_list_fn,
@@ -2207,6 +2207,27 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname)
SAFE_FREE(dir);
}
errno = smbc_errno(context, &srv->cli);
+
+ if (errno == EINVAL) {
+ /*
+ * See if they asked to opendir something
+ * other than a directory. If so, the
+ * converted error value we got would have
+ * been EINVAL rather than ENOTDIR.
+ */
+ *p = '\0'; /* restore original path */
+
+ if (smbc_getatr(context, srv, path,
+ &mode, NULL,
+ NULL, NULL, NULL,
+ NULL) &&
+ ! IS_DOS_DIR(mode)) {
+
+ /* It is. Correct the error value */
+ errno = ENOTDIR;
+ }
+ }
+
return NULL;
}