2 * Unix SMB/CIFS implementation.
3 * Test dbwrap_watch API
4 * Copyright (C) Volker Lendecke 2017
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "torture/proto.h"
22 #include "lib/idmap_cache.h"
23 #include "librpc/gen_ndr/idmap.h"
24 #include "libcli/security/dom_sid.h"
26 bool run_local_idmap_cache1(int dummy
)
28 struct dom_sid sid
, found_sid
;
29 struct unixid xid
, found_xid
;
33 xid
= (struct unixid
) { .id
= 1234, .type
= ID_TYPE_UID
};
34 dom_sid_parse("S-1-5-21-2864185242-3846410404-2398417794-1235", &sid
);
35 idmap_cache_set_sid2unixid(&sid
, &xid
);
37 ret
= idmap_cache_find_sid2unixid(&sid
, &found_xid
, &expired
);
39 fprintf(stderr
, "idmap_cache_find_sid2unixid failed\n");
44 "idmap_cache_find_sid2unixid returned an expired "
48 if ((xid
.type
!= found_xid
.type
) || (xid
.id
!= found_xid
.id
)) {
50 "idmap_cache_find_sid2unixid returned wrong "
55 ret
= idmap_cache_find_xid2sid(&xid
, &found_sid
, &expired
);
57 fprintf(stderr
, "idmap_cache_find_xid2sid failed\n");
62 "idmap_cache_find_xid2sid returned an expired "
66 if (!dom_sid_equal(&sid
, &found_sid
)) {
68 "idmap_cache_find_xid2sid returned wrong sid\n");
72 xid
.type
= ID_TYPE_GID
;
74 ret
= idmap_cache_find_xid2sid(&xid
, &found_sid
, &expired
);
77 "idmap_cache_find_xid2sid found a GID where it "
82 idmap_cache_del_sid(&sid
);
84 xid
.type
= ID_TYPE_UID
;
85 ret
= idmap_cache_find_xid2sid(&xid
, &found_sid
, &expired
);
88 "idmap_cache_find_xid2sid found a UID where it "
94 * Test that negative mappings can also be cached
96 sid
= (struct dom_sid
) {0};
97 xid
= (struct unixid
) { .id
= 1234, .type
= ID_TYPE_UID
};
98 idmap_cache_set_sid2unixid(&sid
, &xid
);
100 ret
= idmap_cache_find_xid2sid(&xid
, &found_sid
, &expired
);
103 "idmap_cache_find_xid2sid failed to find "
104 "negative mapping\n");
109 "idmap_cache_find_xid2sid returned an expired "
113 if (!dom_sid_equal(&sid
, &found_sid
)) {
115 "idmap_cache_find_xid2sid returned wrong sid\n");