]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4-torture: add rpc test for ChangeServiceConfigW
authorGünther Deschner <gd@samba.org>
Thu, 5 Mar 2020 21:45:48 +0000 (22:45 +0100)
committerKarolin Seeger <kseeger@samba.org>
Wed, 18 Mar 2020 10:29:10 +0000 (10:29 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14313

Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 0825324bc75d2ab10164a1f137be782d84c822b8)

selftest/knownfail
source4/torture/rpc/svcctl.c

index c9ef0851172cb36f77d062c5722ee75d87b6400f..20441c078b46e6e796059f04542d268d9494e5f1 100644 (file)
 ^samba3.rpc.eventlog.eventlog.GetNumRecords\(ad_dc\)
 ^samba3.rpc.eventlog.eventlog.OpenEventLog\(ad_dc\)
 ^samba3.rap.basic.netsessiongetinfo\(ad_dc\)
+# not implemented
+^samba3.rpc.svcctl.svcctl.ChangeServiceConfigW\(ad_dc\)
+^samba3.rpc.svcctl.svcctl.ChangeServiceConfigW\(nt4_dc\)
 #
 # This makes less sense when not running against an AD DC
 #
index ebb2bc6ad0e49305f0c1b6daea505bed5547e097..bd16ed4627d356b642ea58ce5cf4b3fb6ccf96ae 100644 (file)
@@ -3,7 +3,7 @@
    test suite for svcctl rpc operations
 
    Copyright (C) Jelmer Vernooij 2004
-   Copyright (C) Guenther Deschner 2008,2009
+   Copyright (C) Guenther Deschner 2008,2009,2020
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -623,6 +623,80 @@ static bool test_SCManager(struct torture_context *tctx,
        return true;
 }
 
+static bool test_ChangeServiceConfigW(struct torture_context *tctx,
+                                     struct dcerpc_pipe *p)
+{
+       struct svcctl_ChangeServiceConfigW r;
+       struct svcctl_QueryServiceConfigW q;
+       struct policy_handle h, s;
+       NTSTATUS status;
+       struct dcerpc_binding_handle *b = p->binding_handle;
+       struct QUERY_SERVICE_CONFIG query;
+       bool ok;
+
+       uint32_t offered = 0;
+       uint32_t needed = 0;
+
+       ok = test_OpenSCManager(b, tctx, &h);
+       if (!ok) {
+               return false;
+       }
+
+       ok = test_OpenService(b, tctx, &h, TORTURE_DEFAULT_SERVICE, &s);
+       if (!ok) {
+               return false;
+       }
+
+       q.in.handle = &s;
+       q.in.offered = offered;
+       q.out.query = &query;
+       q.out.needed = &needed;
+
+       status = dcerpc_svcctl_QueryServiceConfigW_r(b, tctx, &q);
+       torture_assert_ntstatus_ok(tctx, status, "QueryServiceConfigW failed!");
+
+       if (W_ERROR_EQUAL(q.out.result, WERR_INSUFFICIENT_BUFFER)) {
+               q.in.offered = needed;
+               status = dcerpc_svcctl_QueryServiceConfigW_r(b, tctx, &q);
+               torture_assert_ntstatus_ok(tctx, status, "QueryServiceConfigW failed!");
+       }
+       torture_assert_werr_ok(tctx, q.out.result, "QueryServiceConfigW failed!");
+
+       r.in.handle = &s;
+       r.in.type               = query.service_type;
+       r.in.start_type         = query.start_type;
+       r.in.error_control      = query.error_control;
+
+       /*
+        * according to MS-SCMR 3.1.4.11 NULL params are supposed to leave the
+        * existing values intact.
+        */
+
+       r.in.binary_path        = NULL;
+       r.in.load_order_group   = NULL;
+       r.in.dependencies       = NULL;
+       r.in.service_start_name = NULL;
+       r.in.password           = NULL;
+       r.in.display_name       = NULL;
+       r.out.tag_id            = NULL;
+
+       status = dcerpc_svcctl_ChangeServiceConfigW_r(b, tctx, &r);
+       torture_assert_ntstatus_ok(tctx, status, "ChangeServiceConfigW failed!");
+       torture_assert_werr_ok(tctx, r.out.result, "ChangeServiceConfigW failed!");
+
+       ok = test_CloseServiceHandle(b, tctx, &s);
+       if (!ok) {
+               return false;
+       }
+
+       ok = test_CloseServiceHandle(b, tctx, &h);
+       if (!ok) {
+               return false;
+       }
+
+       return true;
+}
+
 struct torture_suite *torture_rpc_svcctl(TALLOC_CTX *mem_ctx)
 {
        struct torture_suite *suite = torture_suite_create(mem_ctx, "svcctl");
@@ -652,6 +726,8 @@ struct torture_suite *torture_rpc_svcctl(TALLOC_CTX *mem_ctx)
                                   test_StartServiceW);
        torture_rpc_tcase_add_test(tcase, "ControlService",
                                   test_ControlService);
+       torture_rpc_tcase_add_test(tcase, "ChangeServiceConfigW",
+                                  test_ChangeServiceConfigW);
 
        return suite;
 }