2 Unix SMB/Netbios implementation.
5 Copyright (C) Tim Potter 2000
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 "sec_ctx_utils.h"
24 int main(int argc
, char **argv
)
26 extern struct current_user current_user
;
27 uid_t initial_uid
= current_user
.uid
;
28 gid_t initial_gid
= current_user
.gid
;
34 /* Check initial id */
36 if (initial_uid
!= 0 || initial_gid
!= 0) {
37 printf("FAIL: current_user not initialised to root\n");
41 /* Push a context and check current user is updated */
43 if (!push_sec_ctx()) {
44 printf("FAIL: push_sec_ctx\n");
48 set_sec_ctx(1, 2, 0, NULL
);
50 if (current_user
.uid
!= 1 || current_user
.gid
!= 2) {
51 printf("FAIL: current_user id not updated after push\n");
55 if (current_user
.ngroups
!= 0 || current_user
.groups
) {
56 printf("FAIL: current_user groups not updated after push\n");
62 get_random_grouplist(&ngroups
, &groups
);
64 if (!push_sec_ctx()) {
65 printf("FAIL: push_sec_ctx\n");
69 set_sec_ctx(2, 3, ngroups
, groups
);
71 if (current_user
.uid
!= 2 || current_user
.gid
!= 3) {
72 printf("FAIL: current_user id not updated after second "
77 if (current_user
.ngroups
!= ngroups
||
78 (memcmp(current_user
.groups
, groups
,
79 sizeof(gid_t
) * ngroups
) != 0)) {
80 printf("FAIL: current_user groups not updated\n");
84 /* Pop them both off */
87 printf("FAIL: pop_sec_ctx\n");
91 if (current_user
.uid
!= 1 || current_user
.gid
!= 2) {
92 printf("FAIL: current_user not updaded pop\n");
97 printf("FAIL: pop_sec_ctx\n");
101 /* Check initial state was returned */
103 if (current_user
.uid
!= initial_uid
||
104 current_user
.gid
!= initial_gid
) {
105 printf("FAIL: current_user not updaded pop\n");
109 /* Everything's cool */