4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 * Print an NT Security Descriptor (SD) and its sub-components.
31 #include <sys/types.h>
32 #include <sys/errno.h>
34 #include <sys/cmn_err.h>
36 #include <sys/sunddi.h>
38 #include <sys/vnode.h>
40 #include <sys/byteorder.h>
51 #include <sys/fs/smbfs_ioctl.h>
53 #include <netsmb/smb_lib.h>
54 #include <netsmb/smbfs_acl.h>
56 #include "smbfs_ntacl.h"
59 fprint_sid(FILE *fp
, i_ntsid_t
*sid
)
61 static char sidbuf
[256];
64 fprintf(fp
, "(null)\n");
68 if (smbfs_sid2str(sid
, sidbuf
, sizeof (sidbuf
), NULL
) < 0)
69 fprintf(fp
, "(error)\n");
71 fprintf(fp
, "%s\n", sidbuf
);
75 fprint_ntace(FILE *fp
, i_ntace_t
*ace
)
78 fprintf(fp
, " (null)\n");
82 /* ACEs are always printed in a list, so indent by 2. */
83 fprintf(fp
, " ace_type=%d ace_flags=0x%x ace_rights=0x%x\n",
84 ace
->ace_hdr
.ace_type
, ace
->ace_hdr
.ace_flags
,
85 ace
->ace_v2
.ace_rights
);
86 /* Show the SID as a "continuation" line. */
87 fprintf(fp
, " ace_sid: ");
88 fprint_sid(fp
, ace
->ace_v2
.ace_sid
);
92 fprint_ntacl(FILE *fp
, i_ntacl_t
*acl
)
97 fprintf(fp
, "(null)\n");
101 fprintf(fp
, "acl_rev=%d acl_acecount=%d\n",
102 acl
->acl_revision
, acl
->acl_acecount
);
103 for (i
= 0; i
< acl
->acl_acecount
; i
++)
104 fprint_ntace(fp
, acl
->acl_acevec
[i
]);
108 smbfs_acl_print_sd(FILE *fp
, i_ntsd_t
*sd
)
111 fprintf(fp
, "sd_rev=%d, flags=0x%x\n",
112 sd
->sd_revision
, sd
->sd_flags
);
113 fprintf(fp
, "owner: ");
114 fprint_sid(fp
, sd
->sd_owner
);
115 fprintf(fp
, "group: ");
116 fprint_sid(fp
, sd
->sd_group
);
117 fprintf(fp
, "sacl: ");
118 fprint_ntacl(fp
, sd
->sd_sacl
);
119 fprintf(fp
, "dacl: ");
120 fprint_ntacl(fp
, sd
->sd_dacl
);