summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2007-09-17 15:34:22 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:30:50 -0500
commit4dc265d6a0fe799006ac5be79114a145b3a114c5 (patch)
tree9a437504252d6b73f736bcdb8ef7875f64a412c6 /source3
parent1130482add933d6a3e0b7f13717e0ae72588c6a2 (diff)
downloadsamba-4dc265d6a0fe799006ac5be79114a145b3a114c5.tar.gz
samba-4dc265d6a0fe799006ac5be79114a145b3a114c5.tar.bz2
samba-4dc265d6a0fe799006ac5be79114a145b3a114c5.zip
r25198: Change net_rpc_join_ok() to return NTSTATUS for better
error propagation. Michael (This used to be commit 5a16da2185f07d1f48fabd93a7a6b8f2d6b91089)
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/net_ads.c8
-rw-r--r--source3/utils/net_rpc_join.c31
2 files changed, 25 insertions, 14 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 5646a0c8a8..4a43306666 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -1600,8 +1600,12 @@ int net_ads_join(int argc, const char **argv)
/* Verify that everything is ok */
- if ( net_rpc_join_ok(short_domain_name, ads->config.ldap_server_name, &ads->ldap.ip) != 0 ) {
- d_fprintf(stderr, "Failed to verify membership in domain!\n");
+ nt_status = net_rpc_join_ok(short_domain_name,
+ ads->config.ldap_server_name, &ads->ldap.ip);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ d_fprintf(stderr,
+ "Failed to verify membership in domain: %s!\n",
+ nt_errstr(nt_status));
goto fail;
}
diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c
index 571d8016b9..b32fa27284 100644
--- a/source3/utils/net_rpc_join.c
+++ b/source3/utils/net_rpc_join.c
@@ -40,7 +40,8 @@
* @return A shell status integer (0 for success)
*
**/
-int net_rpc_join_ok(const char *domain, const char *server, struct in_addr *ip )
+NTSTATUS net_rpc_join_ok(const char *domain, const char *server,
+ struct in_addr *ip)
{
enum security_types sec;
unsigned int conn_flags = NET_FLAGS_PDC;
@@ -66,7 +67,7 @@ int net_rpc_join_ok(const char *domain, const char *server, struct in_addr *ip )
/* Connect to remote machine */
ntret = net_make_ipc_connection_ex(domain, server, ip, conn_flags, &cli);
if (!NT_STATUS_IS_OK(ntret)) {
- return -1;
+ return ntret;
}
/* Setup the creds as though we're going to do schannel... */
@@ -78,13 +79,13 @@ int net_rpc_join_ok(const char *domain, const char *server, struct in_addr *ip )
if (!netlogon_pipe) {
if (NT_STATUS_EQUAL(ntret, NT_STATUS_INVALID_NETWORK_RESPONSE)) {
cli_shutdown(cli);
- return 0;
+ return NT_STATUS_OK;
} else {
DEBUG(0,("net_rpc_join_ok: failed to get schannel session "
"key from server %s for domain %s. Error was %s\n",
cli->desthost, domain, nt_errstr(ntret) ));
cli_shutdown(cli);
- return -1;
+ return ntret;
}
}
@@ -92,7 +93,7 @@ int net_rpc_join_ok(const char *domain, const char *server, struct in_addr *ip )
if (!lp_client_schannel()) {
cli_shutdown(cli);
/* We're good... */
- return 0;
+ return ntret;
}
pipe_hnd = cli_rpc_pipe_open_schannel_with_key(cli, PI_NETLOGON,
@@ -103,12 +104,14 @@ int net_rpc_join_ok(const char *domain, const char *server, struct in_addr *ip )
DEBUG(0,("net_rpc_join_ok: failed to open schannel session "
"on netlogon pipe to server %s for domain %s. Error was %s\n",
cli->desthost, domain, nt_errstr(ntret) ));
- cli_shutdown(cli);
- return -1;
+ /*
+ * Note: here, we have:
+ * (pipe_hnd != NULL) if and only if NT_STATUS_IS_OK(ntret)
+ */
}
cli_shutdown(cli);
- return 0;
+ return ntret;
}
/**
@@ -422,8 +425,9 @@ int net_rpc_join_newstyle(int argc, const char **argv)
}
/* double-check, connection from scratch */
- retval = net_rpc_join_ok(domain, cli->desthost, &cli->dest_ip);
-
+ result = net_rpc_join_ok(domain, cli->desthost, &cli->dest_ip);
+ retval = NT_STATUS_IS_OK(result) ? 0 : -1;
+
done:
/* Display success or failure */
@@ -452,10 +456,13 @@ done:
int net_rpc_testjoin(int argc, const char **argv)
{
char *domain = smb_xstrdup(opt_target_workgroup);
+ NTSTATUS nt_status;
/* Display success or failure */
- if (net_rpc_join_ok(domain, NULL, NULL) != 0) {
- fprintf(stderr,"Join to domain '%s' is not valid\n",domain);
+ nt_status = net_rpc_join_ok(domain, NULL, NULL);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ fprintf(stderr,"Join to domain '%s' is not valid: %s\n",
+ nt_errstr(nt_status), domain);
free(domain);
return -1;
}