summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/librpc/idl/wkssvc.idl8
-rw-r--r--source4/rpc_server/wkssvc/dcesrv_wkssvc.c8
-rw-r--r--source4/torture/rpc/wkssvc.c100
3 files changed, 111 insertions, 5 deletions
diff --git a/source4/librpc/idl/wkssvc.idl b/source4/librpc/idl/wkssvc.idl
index deb2b54fc0..9a0f2974f5 100644
--- a/source4/librpc/idl/wkssvc.idl
+++ b/source4/librpc/idl/wkssvc.idl
@@ -586,7 +586,13 @@ import "srvsvc.idl", "lsa.idl";
/*****************************/
/* Function 0x1d */
- WERROR WKSSVC_NETRSETPRIMARYCOMPUTERNAME ();
+ WERROR wkssvc_NetrSetPrimaryComputername(
+ [in] [string,charset(UTF16)] uint16 *server_name,
+ [in] [string,charset(UTF16)] uint16 *primary_name,
+ [in] [string,charset(UTF16)] uint16 *Account,
+ [in] wkssvc_PasswordBuffer *EncryptedPassword,
+ [in] uint32 Reserved
+ );
/*****************************/
/* Function 0x1e */
diff --git a/source4/rpc_server/wkssvc/dcesrv_wkssvc.c b/source4/rpc_server/wkssvc/dcesrv_wkssvc.c
index 5ea0cc73b7..59cb99ec10 100644
--- a/source4/rpc_server/wkssvc/dcesrv_wkssvc.c
+++ b/source4/rpc_server/wkssvc/dcesrv_wkssvc.c
@@ -392,11 +392,11 @@ static WERROR dcesrv_wkssvc_NetrRemoveAlternateComputerName(struct dcesrv_call_s
}
-/*
- WKSSVC_NETRSETPRIMARYCOMPUTERNAME
+/*
+ wkssvc_NetrSetPrimaryComputername
*/
-static WERROR dcesrv_WKSSVC_NETRSETPRIMARYCOMPUTERNAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct WKSSVC_NETRSETPRIMARYCOMPUTERNAME *r)
+static WERROR dcesrv_wkssvc_NetrSetPrimaryComputername(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct wkssvc_NetrSetPrimaryComputername *r)
{
DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
}
diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c
index 499477cc12..f50705d216 100644
--- a/source4/torture/rpc/wkssvc.c
+++ b/source4/torture/rpc/wkssvc.c
@@ -717,6 +717,102 @@ static bool test_NetrRemoveAlternateComputerName(struct torture_context *tctx,
return true;
}
+static bool test_NetrSetPrimaryComputername_name(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ const char *name)
+{
+ NTSTATUS status;
+ struct wkssvc_NetrSetPrimaryComputername r;
+
+ r.in.server_name = dcerpc_server_name(p);
+ r.in.primary_name = name;
+ r.in.Account = NULL;
+ r.in.EncryptedPassword = NULL;
+ r.in.Reserved = 0;
+
+ status = dcerpc_wkssvc_NetrSetPrimaryComputername(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status,
+ "NetrSetPrimaryComputername failed");
+ torture_assert_werr_ok(tctx, r.out.result,
+ "NetrSetPrimaryComputername failed");
+ return true;
+}
+
+
+static bool test_NetrSetPrimaryComputername(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ /*
+ add alternate,
+ check if there
+ store old primary
+ set new primary (alternate)
+ check if there
+ later: check if del is possible
+ set primary back to origin
+ check if there
+ del alternate
+ */
+
+ const char **names_o = NULL, **names = NULL;
+ int num_names_o = 0, num_names = 0;
+
+ torture_comment(tctx, "testing NetrSetPrimaryComputername\n");
+
+ if (!test_NetrAddAlternateComputerName(tctx, p)) {
+ return false;
+ }
+
+ if (!test_NetrEnumerateComputerNames_level(tctx, p,
+ NetPrimaryComputerName,
+ &names_o, &num_names_o))
+ {
+ return false;
+ }
+
+ if (num_names_o != 1) {
+ return false;
+ }
+
+ if (!test_NetrSetPrimaryComputername_name(tctx, p,
+ SMBTORTURE_ALTERNATE_NAME))
+ {
+ return false;
+ }
+
+ if (!test_NetrEnumerateComputerNames_level(tctx, p,
+ NetPrimaryComputerName,
+ &names, &num_names))
+ {
+ return false;
+ }
+
+ if (num_names != 1) {
+ return false;
+ }
+
+ if (!strequal(names[0], SMBTORTURE_ALTERNATE_NAME)) {
+ torture_comment(tctx,
+ "name mismatch (%s != %s) after NetrSetPrimaryComputername!\n",
+ names[0], SMBTORTURE_ALTERNATE_NAME);
+ /*return false */;
+ }
+
+ if (!test_NetrSetPrimaryComputername_name(tctx, p,
+ names_o[0]))
+ {
+ return false;
+ }
+
+ if (!test_NetrRemoveAlternateComputerName(tctx, p)) {
+ return false;
+ }
+
+
+ return true;
+}
+
+
static bool test_NetrWorkstationStatisticsGet(struct torture_context *tctx,
struct dcerpc_pipe *p)
{
@@ -774,6 +870,7 @@ struct torture_suite *torture_rpc_wkssvc(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite;
struct torture_rpc_tcase *tcase;
+ struct torture_test *test;
suite = torture_suite_create(mem_ctx, "WKSSVC");
tcase = torture_suite_add_rpc_iface_tcase(suite, "wkssvc",
@@ -815,6 +912,9 @@ struct torture_suite *torture_rpc_wkssvc(TALLOC_CTX *mem_ctx)
test_NetrRemoveAlternateComputerName);
torture_rpc_tcase_add_test(tcase, "NetrAddAlternateComputerName",
test_NetrAddAlternateComputerName);
+ test = torture_rpc_tcase_add_test(tcase, "NetrSetPrimaryComputername",
+ test_NetrSetPrimaryComputername);
+ test->dangerous = true;
torture_rpc_tcase_add_test(tcase, "NetrEnumerateComputerNames",
test_NetrEnumerateComputerNames);