dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libsmbfs / smb / acl_print.c
blob62e8b846f1a68acc15072566170189d5923386ea
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
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>
33 #include <sys/cred.h>
34 #include <sys/cmn_err.h>
35 #include <sys/kmem.h>
36 #include <sys/sunddi.h>
37 #include <sys/acl.h>
38 #include <sys/vnode.h>
39 #include <sys/vfs.h>
40 #include <sys/byteorder.h>
42 #include <errno.h>
43 #include <stdio.h>
44 #include <string.h>
45 #include <strings.h>
46 #include <unistd.h>
48 #include <umem.h>
49 #include <idmap.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"
58 static void
59 fprint_sid(FILE *fp, i_ntsid_t *sid)
61 static char sidbuf[256];
63 if (sid == NULL) {
64 fprintf(fp, "(null)\n");
65 return;
68 if (smbfs_sid2str(sid, sidbuf, sizeof (sidbuf), NULL) < 0)
69 fprintf(fp, "(error)\n");
70 else
71 fprintf(fp, "%s\n", sidbuf);
74 static void
75 fprint_ntace(FILE *fp, i_ntace_t *ace)
77 if (ace == NULL) {
78 fprintf(fp, " (null)\n");
79 return;
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);
91 static void
92 fprint_ntacl(FILE *fp, i_ntacl_t *acl)
94 int i;
96 if (acl == NULL) {
97 fprintf(fp, "(null)\n");
98 return;
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]);
107 void
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);