2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Andrew Tridgell 1992-1999
5 Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
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 "rpcclient.h"
25 /****************************************************************************
26 convert a security permissions into a string
27 ****************************************************************************/
28 char *get_sec_mask_str(uint32 type
)
30 static fstring typestr
="";
34 if (type
& GENERIC_ALL_ACCESS
)
35 fstrcat(typestr
, "Generic all access ");
36 if (type
& GENERIC_EXECUTE_ACCESS
)
37 fstrcat(typestr
, "Generic execute access ");
38 if (type
& GENERIC_WRITE_ACCESS
)
39 fstrcat(typestr
, "Generic write access ");
40 if (type
& GENERIC_READ_ACCESS
)
41 fstrcat(typestr
, "Generic read access ");
42 if (type
& MAXIMUM_ALLOWED_ACCESS
)
43 fstrcat(typestr
, "MAXIMUM_ALLOWED_ACCESS ");
44 if (type
& SYSTEM_SECURITY_ACCESS
)
45 fstrcat(typestr
, "SYSTEM_SECURITY_ACCESS ");
46 if (type
& SYNCHRONIZE_ACCESS
)
47 fstrcat(typestr
, "SYNCHRONIZE_ACCESS ");
48 if (type
& WRITE_OWNER_ACCESS
)
49 fstrcat(typestr
, "WRITE_OWNER_ACCESS ");
50 if (type
& WRITE_DAC_ACCESS
)
51 fstrcat(typestr
, "WRITE_DAC_ACCESS ");
52 if (type
& READ_CONTROL_ACCESS
)
53 fstrcat(typestr
, "READ_CONTROL_ACCESS ");
54 if (type
& DELETE_ACCESS
)
55 fstrcat(typestr
, "DELETE_ACCESS ");
57 printf("\t\tSpecific bits: 0x%lx\n", type
&SPECIFIC_RIGHTS_MASK
);
62 /****************************************************************************
63 display sec_access structure
64 ****************************************************************************/
65 void display_sec_access(SEC_ACCESS
*info
)
67 printf("\t\tPermissions: 0x%x: %s\n", info
->mask
, get_sec_mask_str(info
->mask
));
70 /****************************************************************************
71 display sec_ace structure
72 ****************************************************************************/
73 void display_sec_ace(SEC_ACE
*ace
)
77 printf("\tACE\n\t\ttype: ");
79 case SEC_ACE_TYPE_ACCESS_ALLOWED
:
80 printf("ACCESS ALLOWED");
82 case SEC_ACE_TYPE_ACCESS_DENIED
:
83 printf("ACCESS DENIED");
85 case SEC_ACE_TYPE_SYSTEM_AUDIT
:
86 printf("SYSTEM AUDIT");
88 case SEC_ACE_TYPE_SYSTEM_ALARM
:
89 printf("SYSTEM ALARM");
95 printf(" (%d) flags: %d\n", ace
->type
, ace
->flags
);
96 display_sec_access(&ace
->info
);
97 sid_to_string(sid_str
, &ace
->trustee
);
98 printf("\t\tSID: %s\n\n", sid_str
);
101 /****************************************************************************
102 display sec_acl structure
103 ****************************************************************************/
104 void display_sec_acl(SEC_ACL
*sec_acl
)
108 printf("\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
109 sec_acl
->num_aces
, sec_acl
->revision
);
112 if (sec_acl
->size
!= 0 && sec_acl
->num_aces
!= 0)
113 for (i
= 0; i
< sec_acl
->num_aces
; i
++)
114 display_sec_ace(&sec_acl
->ace
[i
]);
118 /****************************************************************************
119 display sec_desc structure
120 ****************************************************************************/
121 void display_sec_desc(SEC_DESC
*sec
)
127 display_sec_acl(sec
->sacl
);
132 display_sec_acl(sec
->dacl
);
135 if (sec
->owner_sid
) {
136 sid_to_string(sid_str
, sec
->owner_sid
);
137 printf("\tOwner SID:\t%s\n", sid_str
);
141 sid_to_string(sid_str
, sec
->grp_sid
);
142 printf("\tParent SID:\t%s\n", sid_str
);