summaryrefslogtreecommitdiff
path: root/source3/utils/net_rpc.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2013-07-15 13:28:34 +0200
committerAndreas Schneider <asn@samba.org>2013-08-05 10:30:01 +0200
commit05d9b4165af9e7f03d3fbeb64db4fc305fcec4df (patch)
treea86496018341a936d363b2dc703b59c25e9aab83 /source3/utils/net_rpc.c
parent3e4ded48bbeacdcd128f3c667cbdd12a3efca312 (diff)
downloadsamba-05d9b4165af9e7f03d3fbeb64db4fc305fcec4df.tar.gz
samba-05d9b4165af9e7f03d3fbeb64db4fc305fcec4df.tar.bz2
samba-05d9b4165af9e7f03d3fbeb64db4fc305fcec4df.zip
s3-net: avoid confusing output in net_rpc_oldjoin() if NET_FLAGS_EXPECT_FALLBACK is passed
"net rpc join" tries net_rpc_oldjoin() first and falls back to net_rpc_join_newstyle(). We should not print the join failed if just net_rpc_oldjoin() failed. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/utils/net_rpc.c')
-rw-r--r--source3/utils/net_rpc.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index ae8ebc0e72..e258ec617e 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -427,11 +427,16 @@ static int net_rpc_oldjoin(struct net_context *c, int argc, const char **argv)
return 0;
fail:
+ if (c->opt_flags & NET_FLAGS_EXPECT_FALLBACK) {
+ goto cleanup;
+ }
+
/* issue an overall failure message at the end. */
d_fprintf(stderr, _("Failed to join domain: %s\n"),
r && r->out.error_string ? r->out.error_string :
get_friendly_werror_msg(werr));
+cleanup:
TALLOC_FREE(mem_ctx);
return -1;
@@ -513,7 +518,7 @@ int net_rpc_testjoin(struct net_context *c, int argc, const char **argv)
*
**/
-int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
+static int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
{
struct libnet_JoinCtx *r = NULL;
TALLOC_CTX *mem_ctx;
@@ -623,6 +628,8 @@ fail:
int net_rpc_join(struct net_context *c, int argc, const char **argv)
{
+ int ret;
+
if (c->display_usage) {
d_printf("%s\n%s",
_("Usage:"),
@@ -650,8 +657,12 @@ int net_rpc_join(struct net_context *c, int argc, const char **argv)
return -1;
}
- if ((net_rpc_oldjoin(c, argc, argv) == 0))
+ c->opt_flags |= NET_FLAGS_EXPECT_FALLBACK;
+ ret = net_rpc_oldjoin(c, argc, argv);
+ c->opt_flags &= ~NET_FLAGS_EXPECT_FALLBACK;
+ if (ret == 0) {
return 0;
+ }
return net_rpc_join_newstyle(c, argc, argv);
}