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 * This is the smbfs/lsacl command.
29 * (just for testing - not installed)
32 #include <sys/types.h>
33 #include <sys/errno.h>
36 #include <sys/acl_impl.h>
45 #include <netsmb/smbfs_acl.h>
47 extern acl_t
*acl_alloc(acl_type_t
);
52 uint32_t selector
= DACL_SECURITY_INFORMATION
|
53 OWNER_SECURITY_INFORMATION
|
54 GROUP_SECURITY_INFORMATION
;
61 fprintf(stderr
, "Usage: %s [-v] file ...\n", progname
);
66 main(int argc
, char **argv
)
72 while ((c
= getopt(argc
, argv
, "v")) != -1) {
80 fprintf(stderr
, "%s: bad option: %c\n",
89 for (; optind
< argc
; optind
++)
104 fd
= open(file
, O_RDONLY
, 0);
110 /* First, get the SD in internal form. */
111 error
= smbfs_acl_getsd(fd
, selector
, &sd
);
115 fprintf(stderr
, "%s: getsd, %s\n",
116 progname
, strerror(error
));
122 * Print it first in Windows form. This way,
123 * if any of the conversion has problems,
124 * one can try mapping each SID by hand, i.e.:
125 * idmap show sid:S-1-xxx-yyy-zzz
127 printf("CIFS security data:\n");
128 smbfs_acl_print_sd(stdout
, sd
);
133 * Convert the internal SD to a ZFS ACL.
135 acl
= acl_alloc(ACE_T
);
136 error
= smbfs_acl_sd2zfs(sd
, acl
, &uid
, &gid
);
138 fprintf(stderr
, "%s: sd2zfs, %s\n",
139 progname
, strerror(error
));
142 smbfs_acl_free_sd(sd
);
145 * Print it as a ZFS-style ACL (ACE_T)
147 printf("Solaris security data:\n");
148 if (uid
== (uid_t
)-1)
149 printf("owner: -1\n");
151 printf("owner: %u\n", uid
);
152 if (gid
== (gid_t
)-1)
153 printf("group: -1\n");
155 printf("group: %u\n", gid
);
156 acl_printacl(acl
, 80, 1);