svn commit: samba r25198 - in branches: SAMBA_3_2/source/utils
SAMBA_3_2_0/source/utils
obnox at samba.org
obnox at samba.org
Mon Sep 17 15:34:22 GMT 2007
Author: obnox
Date: 2007-09-17 15:34:22 +0000 (Mon, 17 Sep 2007)
New Revision: 25198
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25198
Log:
Change net_rpc_join_ok() to return NTSTATUS for better
error propagation.
Michael
Modified:
branches/SAMBA_3_2/source/utils/net_ads.c
branches/SAMBA_3_2/source/utils/net_rpc_join.c
branches/SAMBA_3_2_0/source/utils/net_ads.c
branches/SAMBA_3_2_0/source/utils/net_rpc_join.c
Changeset:
Modified: branches/SAMBA_3_2/source/utils/net_ads.c
===================================================================
--- branches/SAMBA_3_2/source/utils/net_ads.c 2007-09-17 15:11:20 UTC (rev 25197)
+++ branches/SAMBA_3_2/source/utils/net_ads.c 2007-09-17 15:34:22 UTC (rev 25198)
@@ -1600,8 +1600,12 @@
/* 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;
}
Modified: branches/SAMBA_3_2/source/utils/net_rpc_join.c
===================================================================
--- branches/SAMBA_3_2/source/utils/net_rpc_join.c 2007-09-17 15:11:20 UTC (rev 25197)
+++ branches/SAMBA_3_2/source/utils/net_rpc_join.c 2007-09-17 15:34:22 UTC (rev 25198)
@@ -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 @@
/* 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 @@
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 @@
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 @@
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 @@
}
/* 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 @@
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;
}
Modified: branches/SAMBA_3_2_0/source/utils/net_ads.c
===================================================================
--- branches/SAMBA_3_2_0/source/utils/net_ads.c 2007-09-17 15:11:20 UTC (rev 25197)
+++ branches/SAMBA_3_2_0/source/utils/net_ads.c 2007-09-17 15:34:22 UTC (rev 25198)
@@ -1600,8 +1600,12 @@
/* 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;
}
Modified: branches/SAMBA_3_2_0/source/utils/net_rpc_join.c
===================================================================
--- branches/SAMBA_3_2_0/source/utils/net_rpc_join.c 2007-09-17 15:11:20 UTC (rev 25197)
+++ branches/SAMBA_3_2_0/source/utils/net_rpc_join.c 2007-09-17 15:34:22 UTC (rev 25198)
@@ -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 @@
/* 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 @@
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 @@
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 @@
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 @@
}
/* 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 @@
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;
}
More information about the samba-cvs
mailing list