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 2 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, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "sec_ctx_utils.h"
25 int main(int argc
, char **argv
)
27 extern struct current_user current_user
;
28 uid_t initial_uid
= current_user
.uid
;
29 gid_t initial_gid
= current_user
.gid
;
35 /* Check initial id */
37 if (initial_uid
!= 0 || initial_gid
!= 0) {
38 printf("FAIL: current_user not initialised to root\n");
42 /* Push a context and check current user is updated */
44 if (!push_sec_ctx()) {
45 printf("FAIL: push_sec_ctx\n");
49 set_sec_ctx(1, 2, 0, NULL
);
51 if (current_user
.uid
!= 1 || current_user
.gid
!= 2) {
52 printf("FAIL: current_user id not updated after push\n");
56 if (current_user
.ngroups
!= 0 || current_user
.groups
) {
57 printf("FAIL: current_user groups not updated after push\n");
63 get_random_grouplist(&ngroups
, &groups
);
65 if (!push_sec_ctx()) {
66 printf("FAIL: push_sec_ctx\n");
70 set_sec_ctx(2, 3, ngroups
, groups
);
72 if (current_user
.uid
!= 2 || current_user
.gid
!= 3) {
73 printf("FAIL: current_user id not updated after second "
78 if (current_user
.ngroups
!= ngroups
||
79 (memcmp(current_user
.groups
, groups
,
80 sizeof(gid_t
) * ngroups
) != 0)) {
81 printf("FAIL: current_user groups not updated\n");
85 /* Pop them both off */
88 printf("FAIL: pop_sec_ctx\n");
92 if (current_user
.uid
!= 1 || current_user
.gid
!= 2) {
93 printf("FAIL: current_user not updaded pop\n");
98 printf("FAIL: pop_sec_ctx\n");
102 /* Check initial state was returned */
104 if (current_user
.uid
!= initial_uid
||
105 current_user
.gid
!= initial_gid
) {
106 printf("FAIL: current_user not updaded pop\n");
110 /* Everything's cool */