summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2010-10-29 11:56:51 -0700
committerJeremy Allison <jra@samba.org>2010-10-29 19:40:16 +0000
commit14ff2e8de9bd8d0064762234555260f5eea643fe (patch)
treeabd73a321e4f9855c9fcaf729d7a9ef7f91112ab /source3/libsmb
parent606a447503defdeddc84ae03e06b392517c840c5 (diff)
downloadsamba-14ff2e8de9bd8d0064762234555260f5eea643fe.tar.gz
samba-14ff2e8de9bd8d0064762234555260f5eea643fe.tar.bz2
samba-14ff2e8de9bd8d0064762234555260f5eea643fe.zip
Fix bug #7700 - Improvement of return code of smbclient
Based on an initial patch from H Hasegawa <hasegawa.hiroyuki@fujixerox.co.jp>. Convert cli_list and associated functions to take calls that return NTSTATUS. Jeremy. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Fri Oct 29 19:40:16 UTC 2010 on sn-devel-104
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/clilist.c21
-rw-r--r--source3/libsmb/libsmb_dir.c21
2 files changed, 25 insertions, 17 deletions
diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c
index 280f876ba7..87c66672e1 100644
--- a/source3/libsmb/clilist.c
+++ b/source3/libsmb/clilist.c
@@ -469,7 +469,7 @@ static NTSTATUS cli_list_old_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
NTSTATUS cli_list_old(struct cli_state *cli, const char *mask,
uint16 attribute,
- void (*fn)(const char *, struct file_info *,
+ NTSTATUS (*fn)(const char *, struct file_info *,
const char *, void *), void *state)
{
TALLOC_CTX *frame = talloc_stackframe();
@@ -504,7 +504,10 @@ NTSTATUS cli_list_old(struct cli_state *cli, const char *mask,
}
num_finfo = talloc_array_length(finfo);
for (i=0; i<num_finfo; i++) {
- fn(cli->dfs_mountpoint, &finfo[i], mask, state);
+ status = fn(cli->dfs_mountpoint, &finfo[i], mask, state);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
}
fail:
TALLOC_FREE(frame);
@@ -795,7 +798,7 @@ static NTSTATUS cli_list_trans_recv(struct tevent_req *req,
NTSTATUS cli_list_trans(struct cli_state *cli, const char *mask,
uint16_t attribute, int info_level,
- void (*fn)(const char *mnt, struct file_info *finfo,
+ NTSTATUS (*fn)(const char *mnt, struct file_info *finfo,
const char *mask, void *private_data),
void *private_data)
{
@@ -830,7 +833,10 @@ NTSTATUS cli_list_trans(struct cli_state *cli, const char *mask,
}
num_finfo = talloc_array_length(finfo);
for (i=0; i<num_finfo; i++) {
- fn(cli->dfs_mountpoint, &finfo[i], mask, private_data);
+ status = fn(cli->dfs_mountpoint, &finfo[i], mask, private_data);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
}
fail:
TALLOC_FREE(frame);
@@ -911,7 +917,7 @@ NTSTATUS cli_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
}
NTSTATUS cli_list(struct cli_state *cli, const char *mask, uint16 attribute,
- void (*fn)(const char *, struct file_info *, const char *,
+ NTSTATUS (*fn)(const char *, struct file_info *, const char *,
void *), void *state)
{
TALLOC_CTX *frame = talloc_stackframe();
@@ -952,7 +958,10 @@ NTSTATUS cli_list(struct cli_state *cli, const char *mask, uint16 attribute,
}
for (i=0; i<num_finfo; i++) {
- fn(cli->dfs_mountpoint, &finfo[i], mask, state);
+ status = fn(cli->dfs_mountpoint, &finfo[i], mask, state);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
}
fail:
TALLOC_FREE(frame);
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index 9398f92612..fdaf949c08 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -147,9 +147,10 @@ list_unique_wg_fn(const char *name,
dirent_type = dir->dir_type;
if (add_dirent(dir, name, comment, dirent_type) < 0) {
-
/* An error occurred, what do we do? */
/* FIXME: Add some code here */
+ /* Change cli_NetServerEnum to take a fn
+ returning NTSTATUS... JRA. */
}
/* Point to the one just added */
@@ -227,14 +228,14 @@ list_fn(const char *name,
}
if (add_dirent(dir, name, comment, dirent_type) < 0) {
-
/* An error occurred, what do we do? */
/* FIXME: Add some code here */
-
+ /* Change cli_NetServerEnum to take a fn
+ returning NTSTATUS... JRA. */
}
}
-static void
+static NTSTATUS
dir_list_fn(const char *mnt,
struct file_info *finfo,
const char *mask,
@@ -243,13 +244,10 @@ dir_list_fn(const char *mnt,
if (add_dirent((SMBCFILE *)state, finfo->name, "",
(finfo->mode&aDIR?SMBC_DIR:SMBC_FILE)) < 0) {
-
- /* Handle an error ... */
-
- /* FIXME: Add some code ... */
-
+ SMBCFILE *dir = (SMBCFILE *)state;
+ return map_nt_error_from_unix(dir->dir_error);
}
-
+ return NT_STATUS_OK;
}
static int
@@ -1211,7 +1209,7 @@ SMBC_mkdir_ctx(SMBCCTX *context,
* Our list function simply checks to see if a directory is not empty
*/
-static void
+static NTSTATUS
rmdir_list_fn(const char *mnt,
struct file_info *finfo,
const char *mask,
@@ -1222,6 +1220,7 @@ rmdir_list_fn(const char *mnt,
bool *smbc_rmdir_dirempty = (bool *)state;
*smbc_rmdir_dirempty = false;
}
+ return NT_STATUS_OK;
}
/*