summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-01-02 16:11:59 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:08:11 -0500
commitfa010c96766fb97e5c4f02f485a5ea774ac07d63 (patch)
tree8124d2b681685f549e27a872d51152871de60d30 /source4
parent7b4c02bf05c9c9508ce15cf0843dad1a354a5547 (diff)
downloadsamba-fa010c96766fb97e5c4f02f485a5ea774ac07d63.tar.gz
samba-fa010c96766fb97e5c4f02f485a5ea774ac07d63.tar.bz2
samba-fa010c96766fb97e5c4f02f485a5ea774ac07d63.zip
r4483: - rename same structs, enums and uninons of the dssetup pipe
to match the style we are using in other pipes - first fillin local vars and only set the out parameter on success - for the server code only to the samdb lookup when it's needed NOTE: the DsRoleGetPrimaryDomainInformation() code with DS_ROLE_MEMBER_SERVER is not tested yet, does someone has a w2k3 member server to test with? metze (This used to be commit e6d1136497f501fe0687bfb34a155db6a9d87bde)
Diffstat (limited to 'source4')
-rw-r--r--source4/librpc/idl/dssetup.idl78
-rw-r--r--source4/rpc_server/dssetup/dcesrv_dssetup.c209
-rw-r--r--source4/torture/rpc/dssetup.c24
3 files changed, 195 insertions, 116 deletions
diff --git a/source4/librpc/idl/dssetup.idl b/source4/librpc/idl/dssetup.idl
index 243eff96e7..d62dee0527 100644
--- a/source4/librpc/idl/dssetup.idl
+++ b/source4/librpc/idl/dssetup.idl
@@ -22,7 +22,12 @@
DS_ROLE_MEMBER_SERVER = 3,
DS_ROLE_BACKUP_DC = 4,
DS_ROLE_PRIMARY_DC = 5
- } ds_Role;
+ } dssetup_DsRole;
+
+ const uint32 DS_ROLE_PRIMARY_DS_RUNNING = 0x00000001;
+ const uint32 DS_ROLE_PRIMARY_DS_MIXED_MODE = 0x00000002;
+ const uint32 DS_ROLE_UPGRADE_IN_PROGRESS = 0x00000004;
+ const uint32 DS_ROLE_PRIMARY_DOMAIN_GUID_PRESENT = 0x01000000;
typedef struct {
uint16 role;
@@ -31,49 +36,50 @@
unistr *dns_domain;
unistr *forest;
GUID domain_guid;
- } ds_DomainBasicInformation;
+ } dssetup_DsRolePrimaryDomInfoBasic;
typedef enum {
- DS_NOT_UPGRADING = 0,
- DS_UPGRADING = 1
- } ds_UpgradeStatus;
+ DS_ROLE_NOT_UPGRADING = 0,
+ DS_ROLE_UPGRADING = 1
+ } dssetup_DsUpgrade;
typedef enum {
- DS_PREVIOUS_UNKNOWN = 0,
- DS_PREVIOUS_PRIMARY = 1,
- DS_PREVIOUS_BACKUP = 2
- } ds_PreviousStatus;
+ DS_ROLE_PREVIOUS_UNKNOWN = 0,
+ DS_ROLE_PREVIOUS_PRIMARY = 1,
+ DS_ROLE_PREVIOUS_BACKUP = 2
+ } dssetup_DsPrevious;
typedef struct {
uint32 upgrading;
uint16 previous_role;
- } ds_DomainUpgradeStatus;
+ } dssetup_DsRoleUpgradeStatus;
typedef enum {
- DS_STATUS_IDLE = 0,
- DS_STATUS_ACTIVE = 1,
- DS_STATUS_NEEDS_REBOOT = 2
- } ds_Status;
+ DS_ROLE_OP_IDLE = 0,
+ DS_ROLE_OP_ACTIVE = 1,
+ DS_ROLE_OP_NEEDS_REBOOT = 2
+ } dssetup_DsRoleOp;
typedef struct {
uint16 status;
- } ds_RoleOpStatus;
-
+ } dssetup_DsRoleOpStatus;
+
typedef enum {
- DS_BASIC_INFORMATION = 1,
- DS_UPGRADE_STATUS = 2,
- DS_ROLE_OP_STATUS = 3
- } ds_InformationLevel;
+ DS_ROLE_BASIC_INFORMATION = 1,
+ DS_ROLE_UPGRADE_STATUS = 2,
+ DS_ROLE_OP_STATUS = 3
+ } dssetup_DsRoleInfoLevel;
typedef union {
- [case(DS_BASIC_INFORMATION)] ds_DomainBasicInformation basic;
- [case(DS_UPGRADE_STATUS)] ds_DomainUpgradeStatus upgrade;
- [case(DS_ROLE_OP_STATUS)] ds_RoleOpStatus status;
- } ds_DomainInformation;
+ [case(DS_ROLE_BASIC_INFORMATION)] dssetup_DsRolePrimaryDomInfoBasic basic;
+ [case(DS_ROLE_UPGRADE_STATUS)] dssetup_DsRoleUpgradeStatus upgrade;
+ [case(DS_ROLE_OP_STATUS)] dssetup_DsRoleOpStatus opstatus;
+ [default] ;
+ } dssetup_DsRoleInfo;
- WERROR ds_RolerGetPrimaryDomainInformation(
+ WERROR dssetup_DsRoleGetPrimaryDomainInformation(
[in] uint16 level,
- [out,switch_is(level)] ds_DomainInformation *info
+ [out,switch_is(level)] dssetup_DsRoleInfo *info
);
/*
@@ -81,14 +87,14 @@
These stubs are left here only as a way of documenting the names
of the calls in case they ever turn up on the wire.
*/
- WERROR ds_RolerDnsNameToFlatName();
- WERROR ds_RolerDcAsDc();
- WERROR ds_RolerDcAsReplica();
- WERROR ds_RolerDemoteDc();
- WERROR ds_RolerGetDcOperationProgress();
- WERROR ds_RolerGetDcOperationResults();
- WERROR ds_RolerCancel();
- WERROR ds_RolerServerSaveStateForUpgrade();
- WERROR ds_RolerUpgradeDownlevelServer();
- WERROR ds_RolerAbortDownlevelServerUpgrade();
+ WERROR dssetup_DsRoleDnsNameToFlatName();
+ WERROR dssetup_DsRoleDcAsDc();
+ WERROR dssetup_DsRoleDcAsReplica();
+ WERROR dssetup_DsRoleDemoteDc();
+ WERROR dssetup_DsRoleGetDcOperationProgress();
+ WERROR dssetup_DsRoleGetDcOperationResults();
+ WERROR dssetup_DsRoleCancel();
+ WERROR dssetup_DsRoleServerSaveStateForUpgrade();
+ WERROR dssetup_DsRoleUpgradeDownlevelServer();
+ WERROR dssetup_DsRoleAbortDownlevelServerUpgrade();
}
diff --git a/source4/rpc_server/dssetup/dcesrv_dssetup.c b/source4/rpc_server/dssetup/dcesrv_dssetup.c
index cde2b4d69a..9277298f66 100644
--- a/source4/rpc_server/dssetup/dcesrv_dssetup.c
+++ b/source4/rpc_server/dssetup/dcesrv_dssetup.c
@@ -27,60 +27,125 @@
/*
- ds_RolerGetPrimaryDomainInformation
+ dssetup_DsRoleGetPrimaryDomainInformation
*/
-static WERROR ds_RolerGetPrimaryDomainInformation(struct dcesrv_call_state *dce_call,
- TALLOC_CTX *mem_ctx,
- struct ds_RolerGetPrimaryDomainInformation *r)
+static WERROR dssetup_DsRoleGetPrimaryDomainInformation(struct dcesrv_call_state *dce_call,
+ TALLOC_CTX *mem_ctx,
+ struct dssetup_DsRoleGetPrimaryDomainInformation *r)
{
- WERROR err = WERR_OK;
- void *sam_ctx;
- const char * const attrs[] = { "dnsDomain", "objectGUID", "name", NULL };
- int ret;
- struct ldb_message **res;
-
- sam_ctx = samdb_connect(mem_ctx);
- if (sam_ctx == NULL) {
- return WERR_SERVER_UNAVAILABLE;
- }
+ ZERO_STRUCT(r->out);
- ret = samdb_search(sam_ctx, mem_ctx, NULL, &res, attrs,
- "(&(objectClass=domainDNS)(!(objectClass=builtinDomain)))");
- if (ret != 1) {
- return WERR_SERVER_UNAVAILABLE;
+ switch (r->in.level) {
+ case DS_ROLE_BASIC_INFORMATION:
+ {
+ void *sam_ctx;
+ const char * const attrs[] = { "dnsDomain", "objectGUID", "name", NULL };
+ int ret;
+ struct ldb_message **res;
+ union dssetup_DsRoleInfo *info;
+ enum dssetup_DsRole role = DS_ROLE_STANDALONE_SERVER;
+ uint32 flags = 0;
+ const char *domain = NULL;
+ const char *dns_domain = NULL;
+ const char *forest = NULL;
+ struct GUID domain_guid;
+
+ ZERO_STRUCT(domain_guid);
+
+ info = talloc_p(mem_ctx, union dssetup_DsRoleInfo);
+ W_ERROR_HAVE_NO_MEMORY(info);
+
+ /* TODO: we need to find out what we should return as standalone server */
+
+ switch (lp_server_role()) {
+ case ROLE_STANDALONE:
+ role = DS_ROLE_STANDALONE_SERVER;
+ break;
+ case ROLE_DOMAIN_MEMBER:
+ role = DS_ROLE_MEMBER_SERVER;
+ break;
+ case ROLE_DOMAIN_BDC:
+ role = DS_ROLE_BACKUP_DC;
+ break;
+ case ROLE_DOMAIN_PDC:
+ role = DS_ROLE_PRIMARY_DC;
+ break;
+ }
+
+ switch (lp_server_role()) {
+ case ROLE_STANDALONE:
+ domain = talloc_strdup(mem_ctx, lp_workgroup());
+ W_ERROR_HAVE_NO_MEMORY(domain);
+ break;
+ case ROLE_DOMAIN_MEMBER:
+ domain = talloc_strdup(mem_ctx, lp_workgroup());
+ W_ERROR_HAVE_NO_MEMORY(domain);
+ /* TODO: what is with dns_domain and forest and guid? */
+ break;
+ case ROLE_DOMAIN_BDC:
+ case ROLE_DOMAIN_PDC:
+ sam_ctx = samdb_connect(mem_ctx);
+ if (!sam_ctx) {
+ return WERR_SERVER_UNAVAILABLE;
+ }
+
+ ret = samdb_search(sam_ctx, mem_ctx, NULL, &res, attrs,
+ "(&(objectClass=domainDNS)(!(objectClass=builtinDomain)))");
+ if (ret != 1) {
+ return WERR_SERVER_UNAVAILABLE;
+ }
+
+ flags = 0;
+ flags |= DS_ROLE_PRIMARY_DS_RUNNING;
+ flags |= DS_ROLE_PRIMARY_DS_MIXED_MODE;
+ flags |= DS_ROLE_PRIMARY_DOMAIN_GUID_PRESENT;
+ domain = samdb_result_string(res[0], "name", NULL);
+ dns_domain = samdb_result_string(res[0], "dnsDomain", NULL);
+ forest = samdb_result_string(res[0], "dnsDomain", NULL);
+ domain_guid = samdb_result_guid(res[0], "objectGUID");
+ break;
+ }
+
+ info->basic.role = role;
+ info->basic.flags = flags;
+ info->basic.domain = domain;
+ info->basic.dns_domain = dns_domain;
+ info->basic.forest = forest;
+ info->basic.domain_guid = domain_guid;
+
+ r->out.info = info;
+ return WERR_OK;
}
+ case DS_ROLE_UPGRADE_STATUS:
+ {
+ union dssetup_DsRoleInfo *info;
- r->out.info = talloc_p(mem_ctx, union ds_DomainInformation);
- if (r->out.info == NULL) {
- return WERR_NOMEM;
- }
+ info = talloc_p(mem_ctx, union dssetup_DsRoleInfo);
+ W_ERROR_HAVE_NO_MEMORY(info);
- switch (r->in.level) {
- case DS_BASIC_INFORMATION:
- /* incorrect, but needed for the moment */
- r->out.info->basic.role = DS_ROLE_MEMBER_SERVER;
- r->out.info->basic.flags = 0x01000003;
- r->out.info->basic.domain = samdb_result_string(res[0], "name", NULL);
- r->out.info->basic.dns_domain = samdb_result_string(res[0], "dnsDomain", NULL);
- r->out.info->basic.forest = samdb_result_string(res[0], "dnsDomain", NULL);
- r->out.info->basic.domain_guid = samdb_result_guid(res[0], "objectGUID");
- break;
-
- case DS_UPGRADE_STATUS:
- r->out.info->upgrade.upgrading = DS_NOT_UPGRADING;
- r->out.info->upgrade.previous_role = DS_PREVIOUS_UNKNOWN;
- break;
+ info->upgrade.upgrading = DS_ROLE_NOT_UPGRADING;
+ info->upgrade.previous_role = DS_ROLE_PREVIOUS_UNKNOWN;
+ r->out.info = info;
+ return WERR_OK;
+ }
case DS_ROLE_OP_STATUS:
- r->out.info->status.status = DS_STATUS_IDLE;
- break;
+ {
+ union dssetup_DsRoleInfo *info;
+
+ info = talloc_p(mem_ctx, union dssetup_DsRoleInfo);
+ W_ERROR_HAVE_NO_MEMORY(info);
+ info->opstatus.status = DS_ROLE_OP_IDLE;
+
+ r->out.info = info;
+ return WERR_OK;
+ }
default:
- err = WERR_INVALID_PARAM;
- break;
+ return WERR_INVALID_PARAM;
}
- return err;
+ return WERR_INVALID_PARAM;
}
@@ -92,100 +157,100 @@ not try and fill these in with anything else
******************************************/
/*
- ds_RolerDnsNameToFlatName
+ dssetup_DsRoleDnsNameToFlatName
*/
-static WERROR ds_RolerDnsNameToFlatName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct ds_RolerDnsNameToFlatName *r)
+static WERROR dssetup_DsRoleDnsNameToFlatName(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct dssetup_DsRoleDnsNameToFlatName *r)
{
DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
}
/*
- ds_RolerDcAsDc
+ dssetup_DsRoleDcAsDc
*/
-static WERROR ds_RolerDcAsDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct ds_RolerDcAsDc *r)
+static WERROR dssetup_DsRoleDcAsDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct dssetup_DsRoleDcAsDc *r)
{
DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
}
/*
- ds_RolerDcAsReplica
+ dssetup_DsRoleDcAsReplica
*/
-static WERROR ds_RolerDcAsReplica(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct ds_RolerDcAsReplica *r)
+static WERROR dssetup_DsRoleDcAsReplica(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct dssetup_DsRoleDcAsReplica *r)
{
DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
}
/*
- ds_RolerDemoteDc
+ dssetup_DsRoleDemoteDc
*/
-static WERROR ds_RolerDemoteDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct ds_RolerDemoteDc *r)
+static WERROR dssetup_DsRoleDemoteDc(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct dssetup_DsRoleDemoteDc *r)
{
DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
}
/*
- ds_RolerGetDcOperationProgress
+ dssetup_DsRoleGetDcOperationProgress
*/
-static WERROR ds_RolerGetDcOperationProgress(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct ds_RolerGetDcOperationProgress *r)
+static WERROR dssetup_DsRoleGetDcOperationProgress(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct dssetup_DsRoleGetDcOperationProgress *r)
{
DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
}
/*
- ds_RolerGetDcOperationResults
+ dssetup_DsRoleGetDcOperationResults
*/
-static WERROR ds_RolerGetDcOperationResults(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct ds_RolerGetDcOperationResults *r)
+static WERROR dssetup_DsRoleGetDcOperationResults(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct dssetup_DsRoleGetDcOperationResults *r)
{
DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
}
/*
- ds_RolerCancel
+ dssetup_DsRoleCancel
*/
-static WERROR ds_RolerCancel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct ds_RolerCancel *r)
+static WERROR dssetup_DsRoleCancel(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct dssetup_DsRoleCancel *r)
{
DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
}
/*
- ds_RolerServerSaveStateForUpgrade
+ dssetup_DsRoleServerSaveStateForUpgrade
*/
-static WERROR ds_RolerServerSaveStateForUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct ds_RolerServerSaveStateForUpgrade *r)
+static WERROR dssetup_DsRoleServerSaveStateForUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct dssetup_DsRoleServerSaveStateForUpgrade *r)
{
DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
}
/*
- ds_RolerUpgradeDownlevelServer
+ dssetup_DsRoleUpgradeDownlevelServer
*/
-static WERROR ds_RolerUpgradeDownlevelServer(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct ds_RolerUpgradeDownlevelServer *r)
+static WERROR dssetup_DsRoleUpgradeDownlevelServer(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct dssetup_DsRoleUpgradeDownlevelServer *r)
{
DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
}
/*
- ds_RolerAbortDownlevelServerUpgrade
+ dssetup_DsRoleAbortDownlevelServerUpgrade
*/
-static WERROR ds_RolerAbortDownlevelServerUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct ds_RolerAbortDownlevelServerUpgrade *r)
+static WERROR dssetup_DsRoleAbortDownlevelServerUpgrade(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct dssetup_DsRoleAbortDownlevelServerUpgrade *r)
{
DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
}
diff --git a/source4/torture/rpc/dssetup.c b/source4/torture/rpc/dssetup.c
index 7e63243e8a..eb9dc83df6 100644
--- a/source4/torture/rpc/dssetup.c
+++ b/source4/torture/rpc/dssetup.c
@@ -24,22 +24,30 @@
#include "librpc/gen_ndr/ndr_dssetup.h"
-static BOOL test_RolerGetPrimaryDomainInformation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
+static BOOL test_DsRoleGetPrimaryDomainInformation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
{
- struct ds_RolerGetPrimaryDomainInformation r;
+ struct dssetup_DsRoleGetPrimaryDomainInformation r;
NTSTATUS status;
BOOL ret = True;
int i;
- printf("\ntesting RolerGetPrimaryDomainInformation\n");
+ printf("\ntesting DsRoleGetPrimaryDomainInformation\n");
- for (i=DS_BASIC_INFORMATION;i<=DS_ROLE_OP_STATUS;i++) {
+ for (i=DS_ROLE_BASIC_INFORMATION; i <= DS_ROLE_OP_STATUS; i++) {
r.in.level = i;
- status = dcerpc_ds_RolerGetPrimaryDomainInformation(p, mem_ctx, &r);
+ status = dcerpc_dssetup_DsRoleGetPrimaryDomainInformation(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
- printf("RolerGetPrimaryDomainInformation level %d failed - %s\n",
- i, nt_errstr(status));
+ const char *errstr = nt_errstr(status);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
+ errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
+ }
+ printf("dcerpc_dssetup_DsRoleGetPrimaryDomainInformation level %d failed - %s\n",
+ i, errstr);
+ ret = False;
+ } else if (!W_ERROR_IS_OK(r.out.result)) {
+ printf("DsRoleGetPrimaryDomainInformation level %d failed - %s\n",
+ i, win_errstr(r.out.result));
ret = False;
}
}
@@ -64,7 +72,7 @@ BOOL torture_rpc_dssetup(void)
return False;
}
- ret &= test_RolerGetPrimaryDomainInformation(p, mem_ctx);
+ ret &= test_DsRoleGetPrimaryDomainInformation(p, mem_ctx);
talloc_destroy(mem_ctx);