r492: BUG 483: patch from Michel Gravey <michel.gravey@optogone.com> to fix password...
[Samba/gebeck_regimport.git] / source3 / rpcclient / display_sec.c
blob2a93c915f1ae15a7f72e8b86133f88857f8c9d1e
1 /*
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.
22 #include "includes.h"
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="";
32 typestr[0] = 0;
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);
59 return typestr;
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)
75 fstring sid_str;
77 printf("\tACE\n\t\ttype: ");
78 switch (ace->type) {
79 case SEC_ACE_TYPE_ACCESS_ALLOWED:
80 printf("ACCESS ALLOWED");
81 break;
82 case SEC_ACE_TYPE_ACCESS_DENIED:
83 printf("ACCESS DENIED");
84 break;
85 case SEC_ACE_TYPE_SYSTEM_AUDIT:
86 printf("SYSTEM AUDIT");
87 break;
88 case SEC_ACE_TYPE_SYSTEM_ALARM:
89 printf("SYSTEM ALARM");
90 break;
91 default:
92 printf("????");
93 break;
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)
106 int i;
108 printf("\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
109 sec_acl->num_aces, sec_acl->revision);
110 printf("\t---\n");
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)
123 fstring sid_str;
125 if (sec->sacl) {
126 printf("SACL\n");
127 display_sec_acl(sec->sacl);
130 if (sec->dacl) {
131 printf("DACL\n");
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);
140 if (sec->grp_sid) {
141 sid_to_string(sid_str, sec->grp_sid);
142 printf("\tParent SID:\t%s\n", sid_str);