diff options
author | Jeremy Allison <jra@samba.org> | 2010-10-29 11:56:51 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2010-10-29 19:40:16 +0000 |
commit | 14ff2e8de9bd8d0064762234555260f5eea643fe (patch) | |
tree | abd73a321e4f9855c9fcaf729d7a9ef7f91112ab /source3/utils | |
parent | 606a447503defdeddc84ae03e06b392517c840c5 (diff) | |
download | samba-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/utils')
-rw-r--r-- | source3/utils/net_rpc.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index c60887c319..1b0e469afc 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -39,7 +39,7 @@ #include "../libcli/security/security.h" static int net_mode_share; -static bool sync_files(struct copy_clistate *cp_clistate, const char *mask); +static NTSTATUS sync_files(struct copy_clistate *cp_clistate, const char *mask); /** * @file net_rpc.c @@ -3347,7 +3347,7 @@ static int rpc_share_migrate_shares(struct net_context *c, int argc, * @param state arg-pointer * **/ -static void copy_fn(const char *mnt, struct file_info *f, +static NTSTATUS copy_fn(const char *mnt, struct file_info *f, const char *mask, void *state) { static NTSTATUS nt_status; @@ -3363,7 +3363,7 @@ static void copy_fn(const char *mnt, struct file_info *f, c = local_state->c; if (strequal(f->name, ".") || strequal(f->name, "..")) - return; + return NT_STATUS_OK; DEBUG(3,("got mask: %s, name: %s\n", mask, f->name)); @@ -3391,12 +3391,14 @@ static void copy_fn(const char *mnt, struct file_info *f, break; default: d_fprintf(stderr, _("Unsupported mode %d\n"), net_mode_share); - return; + return NT_STATUS_INTERNAL_ERROR; } - if (!NT_STATUS_IS_OK(nt_status)) + if (!NT_STATUS_IS_OK(nt_status)) { printf(_("could not handle dir %s: %s\n"), dir, nt_errstr(nt_status)); + return nt_status; + } /* search below that directory */ fstrcpy(new_mask, dir); @@ -3404,11 +3406,13 @@ static void copy_fn(const char *mnt, struct file_info *f, old_dir = local_state->cwd; local_state->cwd = dir; - if (!sync_files(local_state, new_mask)) + nt_status = sync_files(local_state, new_mask); + if (!NT_STATUS_IS_OK(nt_status)) { printf(_("could not handle files\n")); + } local_state->cwd = old_dir; - return; + return nt_status; } @@ -3434,13 +3438,13 @@ static void copy_fn(const char *mnt, struct file_info *f, default: d_fprintf(stderr, _("Unsupported file mode %d\n"), net_mode_share); - return; + return NT_STATUS_INTERNAL_ERROR; } if (!NT_STATUS_IS_OK(nt_status)) printf(_("could not handle file %s: %s\n"), filename, nt_errstr(nt_status)); - + return nt_status; } /** @@ -3452,7 +3456,7 @@ static void copy_fn(const char *mnt, struct file_info *f, * * @return Boolean result **/ -static bool sync_files(struct copy_clistate *cp_clistate, const char *mask) +static NTSTATUS sync_files(struct copy_clistate *cp_clistate, const char *mask) { struct cli_state *targetcli; char *targetpath = NULL; @@ -3465,7 +3469,7 @@ static bool sync_files(struct copy_clistate *cp_clistate, const char *mask) d_fprintf(stderr, _("cli_resolve_path %s failed with error: " "%s\n"), mask, cli_errstr(cp_clistate->cli_share_src)); - return false; + return cli_nt_error(cp_clistate->cli_share_src); } status = cli_list(targetcli, targetpath, cp_clistate->attribute, @@ -3473,10 +3477,9 @@ static bool sync_files(struct copy_clistate *cp_clistate, const char *mask) if (!NT_STATUS_IS_OK(status)) { d_fprintf(stderr, _("listing %s failed with error: %s\n"), mask, nt_errstr(status)); - return false; } - return true; + return status; } @@ -3633,10 +3636,10 @@ static NTSTATUS rpc_share_migrate_files_internals(struct net_context *c, goto done; } - if (!sync_files(&cp_clistate, mask)) { + nt_status = sync_files(&cp_clistate, mask); + if (!NT_STATUS_IS_OK(nt_status)) { d_fprintf(stderr, _("could not handle files for share: " "%s\n"), info502.name); - nt_status = NT_STATUS_UNSUCCESSFUL; goto done; } } |