2 Unix SMB/CIFS implementation.
3 test suite for unixinfo rpc operations
5 Copyright (C) Volker Lendecke 2005
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "torture/rpc/torture_rpc.h"
23 #include "librpc/gen_ndr/ndr_unixinfo_c.h"
24 #include "libcli/security/security.h"
27 test the SidToUid interface
29 static bool test_sidtouid(struct torture_context
*tctx
, struct dcerpc_pipe
*p
)
31 struct unixinfo_SidToUid r
;
34 struct dcerpc_binding_handle
*b
= p
->binding_handle
;
36 sid
= dom_sid_parse_talloc(tctx
, "S-1-5-32-1234-5432");
40 torture_assert_ntstatus_ok(tctx
, dcerpc_unixinfo_SidToUid_r(b
, tctx
, &r
),
42 if (NT_STATUS_EQUAL(NT_STATUS_NONE_MAPPED
, r
.out
.result
)) {
43 } else torture_assert_ntstatus_ok(tctx
, r
.out
.result
, "SidToUid failed");
49 test the UidToSid interface
51 static bool test_uidtosid(struct torture_context
*tctx
, struct dcerpc_pipe
*p
)
53 struct unixinfo_UidToSid r
;
55 struct dcerpc_binding_handle
*b
= p
->binding_handle
;
60 torture_assert_ntstatus_ok(tctx
, dcerpc_unixinfo_UidToSid_r(b
, tctx
, &r
),
62 torture_assert_ntstatus_ok(tctx
, r
.out
.result
, "UidToSid failed");
66 static bool test_getpwuid(struct torture_context
*tctx
,
67 struct dcerpc_pipe
*p
)
70 uint32_t num_uids
= ARRAY_SIZE(uids
);
72 struct unixinfo_GetPWUid r
;
73 struct dcerpc_binding_handle
*b
= p
->binding_handle
;
75 for (i
=0; i
<num_uids
; i
++) {
79 r
.in
.count
= &num_uids
;
81 r
.out
.count
= &num_uids
;
82 r
.out
.infos
= talloc_array(tctx
, struct unixinfo_GetPWUidInfo
, num_uids
);
84 torture_assert_ntstatus_ok(tctx
, dcerpc_unixinfo_GetPWUid_r(b
, tctx
, &r
),
87 torture_assert_ntstatus_ok(tctx
, r
.out
.result
, "GetPWUid failed");
93 test the SidToGid interface
95 static bool test_sidtogid(struct torture_context
*tctx
, struct dcerpc_pipe
*p
)
97 struct unixinfo_SidToGid r
;
100 struct dcerpc_binding_handle
*b
= p
->binding_handle
;
102 sid
= dom_sid_parse_talloc(tctx
, "S-1-5-32-1234-5432");
106 torture_assert_ntstatus_ok(tctx
, dcerpc_unixinfo_SidToGid_r(b
, tctx
, &r
),
108 if (NT_STATUS_EQUAL(NT_STATUS_NONE_MAPPED
, r
.out
.result
)) {
109 } else torture_assert_ntstatus_ok(tctx
, r
.out
.result
, "SidToGid failed");
115 test the GidToSid interface
117 static bool test_gidtosid(struct torture_context
*tctx
, struct dcerpc_pipe
*p
)
119 struct unixinfo_GidToSid r
;
121 struct dcerpc_binding_handle
*b
= p
->binding_handle
;
126 torture_assert_ntstatus_ok(tctx
, dcerpc_unixinfo_GidToSid_r(b
, tctx
, &r
),
128 torture_assert_ntstatus_ok(tctx
, r
.out
.result
, "GidToSid failed");
133 struct torture_suite
*torture_rpc_unixinfo(TALLOC_CTX
*mem_ctx
)
135 struct torture_suite
*suite
;
136 struct torture_rpc_tcase
*tcase
;
138 suite
= torture_suite_create(mem_ctx
, "unixinfo");
139 tcase
= torture_suite_add_rpc_iface_tcase(suite
, "unixinfo",
140 &ndr_table_unixinfo
);
142 torture_rpc_tcase_add_test(tcase
, "sidtouid", test_sidtouid
);
143 torture_rpc_tcase_add_test(tcase
, "uidtosid", test_uidtosid
);
144 torture_rpc_tcase_add_test(tcase
, "getpwuid", test_getpwuid
);
145 torture_rpc_tcase_add_test(tcase
, "sidtogid", test_sidtogid
);
146 torture_rpc_tcase_add_test(tcase
, "gidtosid", test_gidtosid
);