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", (unsigned long)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 void display_acl_type(uint16 type)
120 static fstring typestr="";
124 if (type & SEC_DESC_OWNER_DEFAULTED) /* 0x0001 */
125 fstrcat(typestr, "SEC_DESC_OWNER_DEFAULTED ");
126 if (type & SEC_DESC_GROUP_DEFAULTED) /* 0x0002 */
127 fstrcat(typestr, "SEC_DESC_GROUP_DEFAULTED ");
128 if (type & SEC_DESC_DACL_PRESENT) /* 0x0004 */
129 fstrcat(typestr, "SEC_DESC_DACL_PRESENT ");
130 if (type & SEC_DESC_DACL_DEFAULTED) /* 0x0008 */
131 fstrcat(typestr, "SEC_DESC_DACL_DEFAULTED ");
132 if (type & SEC_DESC_SACL_PRESENT) /* 0x0010 */
133 fstrcat(typestr, "SEC_DESC_SACL_PRESENT ");
134 if (type & SEC_DESC_SACL_DEFAULTED) /* 0x0020 */
135 fstrcat(typestr, "SEC_DESC_SACL_DEFAULTED ");
136 if (type & SEC_DESC_DACL_TRUSTED) /* 0x0040 */
137 fstrcat(typestr, "SEC_DESC_DACL_TRUSTED ");
138 if (type & SEC_DESC_SERVER_SECURITY) /* 0x0080 */
139 fstrcat(typestr, "SEC_DESC_SERVER_SECURITY ");
140 if (type & 0x0100) fstrcat(typestr, "0x0100 ");
141 if (type & 0x0200) fstrcat(typestr, "0x0200 ");
142 if (type & 0x0400) fstrcat(typestr, "0x0400 ");
143 if (type & 0x0800) fstrcat(typestr, "0x0800 ");
144 if (type & 0x1000) fstrcat(typestr, "0x1000 ");
145 if (type & 0x2000) fstrcat(typestr, "0x2000 ");
146 if (type & 0x4000) fstrcat(typestr, "0x4000 ");
147 if (type & SEC_DESC_SELF_RELATIVE) /* 0x8000 */
148 fstrcat(typestr, "SEC_DESC_SELF_RELATIVE ");
150 printf("type: 0x%04x: %s\n", type, typestr);
153 /****************************************************************************
154 display sec_desc structure
155 ****************************************************************************/
156 void display_sec_desc(SEC_DESC *sec)
165 printf("revision: %d\n", sec->revision);
166 display_acl_type(sec->type);
170 display_sec_acl(sec->sacl);
175 display_sec_acl(sec->dacl);
178 if (sec->owner_sid) {
179 sid_to_string(sid_str, sec->owner_sid);
180 printf("\tOwner SID:\t%s\n", sid_str);
184 sid_to_string(sid_str, sec->grp_sid);
185 printf("\tParent SID:\t%s\n", sid_str);