2 Unix SMB/CIFS implementation.
4 Get NT ACLs from UNIX files.
6 Copyright (C) Tim Potter <tpot@samba.org> 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "system/filesys.h"
25 #include "libcli/security/security.h"
26 #include "librpc/gen_ndr/ndr_xattr.h"
28 #if HAVE_XATTR_SUPPORT
30 /* eww - crappy dependencies */
32 NTSTATUS samdb_privilege_setup(struct security_token *token)
34 token->privilege_mask = 0;
38 static void ntacl_print_debug_helper(struct ndr_print *ndr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3)
45 vasprintf(&s, format, ap);
48 for (i=0;i<ndr->depth;i++) {
56 static NTSTATUS get_ntacl(char *filename, struct xattr_NTACL **ntacl,
65 *ntacl = talloc(NULL, struct xattr_NTACL);
67 size = getxattr(filename, XATTR_NTACL_NAME, NULL, 0);
70 fprintf(stderr, "get_ntacl: %s\n", strerror(errno));
71 return NT_STATUS_INTERNAL_ERROR;
74 blob.data = talloc_size(*ntacl, size);
75 blob.length = getxattr(filename, XATTR_NTACL_NAME, blob.data, size);
77 if (blob.length < 0) {
78 fprintf(stderr, "get_ntacl: %s\n", strerror(errno));
79 return NT_STATUS_INTERNAL_ERROR;
82 ndr = ndr_pull_init_blob(&blob, NULL);
84 result = ndr_pull_xattr_NTACL(ndr, NDR_SCALARS|NDR_BUFFERS, *ntacl);
86 if (NT_STATUS_IS_OK(result)) {
87 pr = talloc(*ntacl, struct ndr_print);
88 pr->print = ntacl_print_debug_helper;
92 ndr_print_xattr_NTACL(pr, filename, *ntacl);
98 static void print_ntacl(struct xattr_NTACL *ntacl)
102 int main(int argc, char *argv[])
104 struct xattr_NTACL *ntacl;
108 fprintf(stderr, "Usage: getntacl FILENAME\n");
113 get_ntacl(argv[1], &ntacl, &ntacl_len);
122 int main(int argc, char *argv[])
124 printf("getntacl: not compiled with xattr support!\n");