summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/utils/net.h1
-rw-r--r--source3/utils/net_proto.h1
-rw-r--r--source3/utils/net_rpc.c15
3 files changed, 14 insertions, 3 deletions
diff --git a/source3/utils/net.h b/source3/utils/net.h
index 2056d894d5..e97734ae34 100644
--- a/source3/utils/net.h
+++ b/source3/utils/net.h
@@ -182,6 +182,7 @@ enum netdom_domain_t { ND_TYPE_NT4, ND_TYPE_AD };
#define NET_FLAGS_SIGN 0x00000040 /* sign RPC connection */
#define NET_FLAGS_SEAL 0x00000080 /* seal RPC connection */
#define NET_FLAGS_TCP 0x00000100 /* use ncacn_ip_tcp */
+#define NET_FLAGS_EXPECT_FALLBACK 0x00000200 /* the caller will fallback */
/* net share operation modes */
#define NET_MODE_SHARE_MIGRATE 1
diff --git a/source3/utils/net_proto.h b/source3/utils/net_proto.h
index 1809ba9f12..25e9db2fdb 100644
--- a/source3/utils/net_proto.h
+++ b/source3/utils/net_proto.h
@@ -146,7 +146,6 @@ int run_rpc_command(struct net_context *c,
const char **argv);
int net_rpc_changetrustpw(struct net_context *c, int argc, const char **argv);
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);
int net_rpc_join(struct net_context *c, int argc, const char **argv);
NTSTATUS rpc_info_internals(struct net_context *c,
const struct dom_sid *domain_sid,
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);
}