16711Sgwr /* 26711Sgwr * CDDL HEADER START 36711Sgwr * 46711Sgwr * The contents of this file are subject to the terms of the 56711Sgwr * Common Development and Distribution License (the "License"). 66711Sgwr * You may not use this file except in compliance with the License. 76711Sgwr * 86711Sgwr * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 96711Sgwr * or http://www.opensolaris.org/os/licensing. 106711Sgwr * See the License for the specific language governing permissions 116711Sgwr * and limitations under the License. 126711Sgwr * 136711Sgwr * When distributing Covered Code, include this CDDL HEADER in each 146711Sgwr * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 156711Sgwr * If applicable, add the following below this CDDL HEADER, with the 166711Sgwr * fields enclosed by brackets "[]" replaced with your own identifying 176711Sgwr * information: Portions Copyright [yyyy] [name of copyright owner] 186711Sgwr * 196711Sgwr * CDDL HEADER END 206711Sgwr */ 216711Sgwr 226711Sgwr /* 23*10023SGordon.Ross@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 246711Sgwr * Use is subject to license terms. 256711Sgwr */ 266711Sgwr 276711Sgwr /* 286711Sgwr * Print an NT Security Descriptor (SD) and its sub-components. 296711Sgwr */ 306711Sgwr 316711Sgwr #include <sys/types.h> 326711Sgwr #include <sys/errno.h> 336711Sgwr #include <sys/cred.h> 346711Sgwr #include <sys/cmn_err.h> 356711Sgwr #include <sys/kmem.h> 366711Sgwr #include <sys/sunddi.h> 376711Sgwr #include <sys/acl.h> 386711Sgwr #include <sys/vnode.h> 396711Sgwr #include <sys/vfs.h> 406711Sgwr #include <sys/byteorder.h> 416711Sgwr 426711Sgwr #include <errno.h> 436711Sgwr #include <stdio.h> 446711Sgwr #include <string.h> 456711Sgwr #include <strings.h> 466711Sgwr #include <unistd.h> 476711Sgwr 486711Sgwr #include <umem.h> 496711Sgwr #include <idmap.h> 506711Sgwr 516711Sgwr #include <sys/fs/smbfs_ioctl.h> 526711Sgwr 536711Sgwr #include <netsmb/smb_lib.h> 546711Sgwr #include <netsmb/smbfs_acl.h> 55*10023SGordon.Ross@Sun.COM 56*10023SGordon.Ross@Sun.COM #include "acl_nt.h" 576711Sgwr 586711Sgwr static void 596711Sgwr fprint_sid(FILE *fp, i_ntsid_t *sid) 606711Sgwr { 616711Sgwr static char sidbuf[256]; 626711Sgwr 636711Sgwr if (sid == NULL) { 646711Sgwr fprintf(fp, "(null)\n"); 656711Sgwr return; 666711Sgwr } 676711Sgwr 686711Sgwr if (smbfs_sid2str(sid, sidbuf, sizeof (sidbuf), NULL) < 0) 696711Sgwr fprintf(fp, "(error)\n"); 706711Sgwr else 716711Sgwr fprintf(fp, "%s\n", sidbuf); 726711Sgwr } 736711Sgwr 746711Sgwr static void 756711Sgwr fprint_ntace(FILE *fp, i_ntace_t *ace) 766711Sgwr { 776711Sgwr if (ace == NULL) { 786711Sgwr fprintf(fp, " (null)\n"); 796711Sgwr return; 806711Sgwr } 816711Sgwr 826711Sgwr /* ACEs are always printed in a list, so indent by 2. */ 836711Sgwr fprintf(fp, " ace_type=%d ace_flags=0x%x ace_rights=0x%x\n", 846711Sgwr ace->ace_type, ace->ace_flags, ace->ace_rights); 856711Sgwr /* Show the SID as a "continuation" line. */ 866711Sgwr fprintf(fp, " ace_sid: "); 876711Sgwr fprint_sid(fp, ace->ace_sid); 886711Sgwr } 896711Sgwr 906711Sgwr static void 916711Sgwr fprint_ntacl(FILE *fp, i_ntacl_t *acl) 926711Sgwr { 936711Sgwr int i; 946711Sgwr 956711Sgwr if (acl == NULL) { 966711Sgwr fprintf(fp, "(null)\n"); 976711Sgwr return; 986711Sgwr } 996711Sgwr 1006711Sgwr fprintf(fp, "acl_rev=%d acl_acecount=%d\n", 1016711Sgwr acl->acl_revision, acl->acl_acecount); 1026711Sgwr for (i = 0; i < acl->acl_acecount; i++) 1036711Sgwr fprint_ntace(fp, acl->acl_acevec[i]); 1046711Sgwr } 1056711Sgwr 1066711Sgwr void 1076711Sgwr smbfs_acl_print_sd(FILE *fp, i_ntsd_t *sd) 1086711Sgwr { 1096711Sgwr 1106711Sgwr fprintf(fp, "sd_rev=%d, flags=0x%x\n", 1116711Sgwr sd->sd_revision, sd->sd_flags); 1126711Sgwr fprintf(fp, "owner: "); 1136711Sgwr fprint_sid(fp, sd->sd_owner); 1146711Sgwr fprintf(fp, "group: "); 1156711Sgwr fprint_sid(fp, sd->sd_group); 1166711Sgwr fprintf(fp, "sacl: "); 1176711Sgwr fprint_ntacl(fp, sd->sd_sacl); 1186711Sgwr fprintf(fp, "dacl: "); 1196711Sgwr fprint_ntacl(fp, sd->sd_dacl); 1206711Sgwr } 121