From 1cf7a3420e501f023b0289a47adf0d89e2d12d17 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 24 Sep 2004 01:20:30 +0000 Subject: r2576: Some userspace tools for getting and setting ntacls via the 'security.ntacl' extended attribute. (This used to be commit 5b88226f9002711baac73e66d04ecf92b7765809) --- source4/utils/getntacl.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 source4/utils/getntacl.c (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c new file mode 100644 index 0000000000..b17200aeb5 --- /dev/null +++ b/source4/utils/getntacl.c @@ -0,0 +1,116 @@ +/* + Unix SMB/CIFS implementation. + + Get NT ACLs from UNIX files. + + Copyright (C) Tim Potter 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include + +/* Display a security descriptor in "psec" format which is as follows. + + The first two lines describe the owner user and owner group of the + object. If either of these lines are blank then the respective + owner property is not set. The remaining lines list the individual + permissions or ACE entries, one per line. Each column describes a + different property of the ACE: + + Column Description + ------------------------------------------------------------------- + 1 ACE type (allow/deny etc) + 2 ACE flags + 3 ACE mask + 4 SID the ACE applies to + + Example: + + S-1-5-21-1067277791-1719175008-3000797951-500 + + 1 9 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-501 + 1 2 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-501 + 0 9 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-500 + 0 2 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-500 + 0 9 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-513 + 0 2 0x00020000 S-1-5-21-1067277791-1719175008-3000797951-513 + 0 2 0xe0000000 S-1-1-0 +*/ + +static void print_psec(TALLOC_CTX *mem_ctx, struct security_descriptor *sd) +{ + if (sd->owner_sid) + printf("%s\n", dom_sid_string(mem_ctx, sd->owner_sid)); + else + printf("\n"); + + if (sd->group_sid) + printf("%s\n", dom_sid_string(mem_ctx, sd->owner_sid)); + else + printf("\n"); + + /* Note: SACL not displayed */ + + if (sd->dacl) { + int i; + + for (i = 0; i < sd->dacl->num_aces; i++) { + struct security_ace *ace = &sd->dacl->aces[i]; + + printf("%d %d 0x%08x %s\n", ace->type, ace->flags, + ace->access_mask, + dom_sid_string(mem_ctx, &ace->trustee)); + } + + } +} + +int main(int argc, char **argv) +{ + TALLOC_CTX *mem_ctx; + ssize_t size; + char *data; + struct security_descriptor sd; + DATA_BLOB blob; + struct ndr_pull *ndr; + NTSTATUS result; + + mem_ctx = talloc_init("getntacl"); + + /* Fetch ACL data */ + + size = getxattr(argv[1], "security.ntacl", NULL, 0); + + if (size == -1) { + fprintf(stderr, "%s: %s\n", argv[1], strerror(errno)); + exit(1); + } + + data = talloc(mem_ctx, size); + + size = getxattr(argv[1], "security.ntacl", data, size); + + blob = data_blob_talloc(mem_ctx, data, size); + + ndr = ndr_pull_init_blob(&blob, mem_ctx); + + result = ndr_pull_security_descriptor( + ndr, NDR_SCALARS|NDR_BUFFERS, &sd); + + print_psec(data, &sd); + return 0; +} -- cgit From 00e05a0b8ba4c6b16a53d20fa5a8eef8fbd6263a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 24 Sep 2004 04:49:45 +0000 Subject: r2582: Merge checks for xattr and acl libraries from Samba3 so the {get,set}ntacl programs can build on non-xattr machines. (This used to be commit daad76207dbb4060c231a58c99970e837e1e858f) --- source4/utils/getntacl.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index b17200aeb5..0d6e86bf3b 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -21,7 +21,16 @@ */ #include "includes.h" -#include + +#ifdef HAVE_NO_ACLS + +int main(int argc, char **argv) +{ + printf("ACL support not compiled in."); + return 1; +} + +#else /* Display a security descriptor in "psec" format which is as follows. @@ -114,3 +123,5 @@ int main(int argc, char **argv) print_psec(data, &sd); return 0; } + +#endif /* HAVE_NO_ACLS */ -- cgit From e8010adffe44f1ad0d82c7b5c7d5fe2cf7d53afd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 5 Nov 2004 07:23:06 +0000 Subject: r3543: fixed some #include lines to make them more consistent, and fixed conditional compilation of xattr client code (This used to be commit 321fb06a627f4deae649ab014bc881721d37b3dd) --- source4/utils/getntacl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index 0d6e86bf3b..2a35c93387 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -22,7 +22,7 @@ #include "includes.h" -#ifdef HAVE_NO_ACLS +#if (!defined(HAVE_NO_ACLS) || !defined(HAVE_XATTR_SUPPORT)) int main(int argc, char **argv) { -- cgit From b875cdf5db045c26da503cde26ae5c3629e6014a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 5 Nov 2004 12:06:36 +0000 Subject: r3551: these utils need system/filesys.h (This used to be commit 1b945f9f4bcbb6afb3e531e92cd2e904c92c334e) --- source4/utils/getntacl.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index 2a35c93387..72fffd9ee8 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "system/filesys.h" #if (!defined(HAVE_NO_ACLS) || !defined(HAVE_XATTR_SUPPORT)) -- cgit From 8a5c9c28410ae0320356fe1686ad0ee7d1ec0e7b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 5 Nov 2004 12:10:28 +0000 Subject: r3552: fixed sense of ACL test (This used to be commit 630af28a0f812b5bafce3ffeb72ebd069b66adac) --- source4/utils/getntacl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index 72fffd9ee8..6045e72013 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -23,7 +23,7 @@ #include "includes.h" #include "system/filesys.h" -#if (!defined(HAVE_NO_ACLS) || !defined(HAVE_XATTR_SUPPORT)) +#if (defined(HAVE_NO_ACLS) || !defined(HAVE_XATTR_SUPPORT)) int main(int argc, char **argv) { -- cgit From 71db46ea665606384f2be1be708c74c97c9adfb2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Nov 2004 23:23:15 +0000 Subject: r3586: Fix some of the issues with the module init functions. Both subsystems and modules can now have init functions, which can be specified in .mk files (INIT_FUNCTION = ...) The build system will define : - SUBSYSTEM_init_static_modules that calls the init functions of all statically compiled modules. Failing to load will generate an error which is not fatal - BINARY_init_subsystems that calls the init functions (if defined) for the subsystems the binary depends on This removes the hack with the "static bool Initialised = " and the "lazy_init" functions (This used to be commit 7a8244761bfdfdfb48f8264d76951ebdfbf7bd8a) --- source4/utils/getntacl.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index 6045e72013..034224c66d 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -99,6 +99,8 @@ int main(int argc, char **argv) struct ndr_pull *ndr; NTSTATUS result; + static_init_getntacl; + mem_ctx = talloc_init("getntacl"); /* Fetch ACL data */ -- cgit From ddc10d4d37984246a6547e34a32d629c689c40d1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Jan 2005 03:06:58 +0000 Subject: r4549: got rid of a lot more uses of plain talloc(), instead using talloc_size() or talloc_array_p() where appropriate. also fixed a memory leak in pvfs_copy_file() (failed to free a memory context) (This used to be commit 89b74b53546e1570b11b3702f40bee58aed8c503) --- source4/utils/getntacl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index 034224c66d..762167a93a 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -112,7 +112,7 @@ int main(int argc, char **argv) exit(1); } - data = talloc(mem_ctx, size); + data = talloc_size(mem_ctx, size); size = getxattr(argv[1], "security.ntacl", data, size); -- cgit From 4d7e4c80580f9902339680cecee457460fe85218 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Jan 2005 04:07:33 +0000 Subject: r4794: - disabled the ntacl command line utilities until they are rewritten to use the same acl format as we use in pvfs (and hopefully use common code too) - removed a lot of old cruft from our autoconf tests. This may well break some builds, but then we can fix them properly instead of the "if solaris version 5.1.2" crap This was prompted by someone sending me solaris 10 patches that patched the configure script with if statements for several more versions of solaris to check for and do special stuff. That is just silly. (This used to be commit 1ea59d1146f041e9befbb435e901c6d7d497c52c) --- source4/utils/getntacl.c | 102 +---------------------------------------------- 1 file changed, 1 insertion(+), 101 deletions(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index 762167a93a..87cc280fcc 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -23,108 +23,8 @@ #include "includes.h" #include "system/filesys.h" -#if (defined(HAVE_NO_ACLS) || !defined(HAVE_XATTR_SUPPORT)) - int main(int argc, char **argv) { - printf("ACL support not compiled in."); + printf("This utility disabled until rewritten\n"); return 1; } - -#else - -/* Display a security descriptor in "psec" format which is as follows. - - The first two lines describe the owner user and owner group of the - object. If either of these lines are blank then the respective - owner property is not set. The remaining lines list the individual - permissions or ACE entries, one per line. Each column describes a - different property of the ACE: - - Column Description - ------------------------------------------------------------------- - 1 ACE type (allow/deny etc) - 2 ACE flags - 3 ACE mask - 4 SID the ACE applies to - - Example: - - S-1-5-21-1067277791-1719175008-3000797951-500 - - 1 9 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-501 - 1 2 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-501 - 0 9 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-500 - 0 2 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-500 - 0 9 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-513 - 0 2 0x00020000 S-1-5-21-1067277791-1719175008-3000797951-513 - 0 2 0xe0000000 S-1-1-0 -*/ - -static void print_psec(TALLOC_CTX *mem_ctx, struct security_descriptor *sd) -{ - if (sd->owner_sid) - printf("%s\n", dom_sid_string(mem_ctx, sd->owner_sid)); - else - printf("\n"); - - if (sd->group_sid) - printf("%s\n", dom_sid_string(mem_ctx, sd->owner_sid)); - else - printf("\n"); - - /* Note: SACL not displayed */ - - if (sd->dacl) { - int i; - - for (i = 0; i < sd->dacl->num_aces; i++) { - struct security_ace *ace = &sd->dacl->aces[i]; - - printf("%d %d 0x%08x %s\n", ace->type, ace->flags, - ace->access_mask, - dom_sid_string(mem_ctx, &ace->trustee)); - } - - } -} - -int main(int argc, char **argv) -{ - TALLOC_CTX *mem_ctx; - ssize_t size; - char *data; - struct security_descriptor sd; - DATA_BLOB blob; - struct ndr_pull *ndr; - NTSTATUS result; - - static_init_getntacl; - - mem_ctx = talloc_init("getntacl"); - - /* Fetch ACL data */ - - size = getxattr(argv[1], "security.ntacl", NULL, 0); - - if (size == -1) { - fprintf(stderr, "%s: %s\n", argv[1], strerror(errno)); - exit(1); - } - - data = talloc_size(mem_ctx, size); - - size = getxattr(argv[1], "security.ntacl", data, size); - - blob = data_blob_talloc(mem_ctx, data, size); - - ndr = ndr_pull_init_blob(&blob, mem_ctx); - - result = ndr_pull_security_descriptor( - ndr, NDR_SCALARS|NDR_BUFFERS, &sd); - - print_psec(data, &sd); - return 0; -} - -#endif /* HAVE_NO_ACLS */ -- cgit From 77255b7f9c5204c8ced541730562e028772b5d35 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 30 Apr 2005 08:38:32 +0000 Subject: r6527: Resurrect getntacl utility program. At the moment we only display the output of ndr_print_xattr_NTACL() to stdout. (This used to be commit b32c159c384c988385f13bbb16e610d825820e18) --- source4/utils/getntacl.c | 105 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 102 insertions(+), 3 deletions(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index 87cc280fcc..8d857d206a 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -3,7 +3,7 @@ Get NT ACLs from UNIX files. - Copyright (C) Tim Potter 2004 + Copyright (C) Tim Potter 2005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,9 +22,108 @@ #include "includes.h" #include "system/filesys.h" +#include "libcli/security/security.h" +#include "librpc/gen_ndr/ndr_xattr.h" -int main(int argc, char **argv) +#if HAVE_XATTR_SUPPORT + +/* eww - crappy dependencies */ + +NTSTATUS samdb_privilege_setup(struct security_token *token) +{ + token->privilege_mask = 0; + return NT_STATUS_OK; +} + +static void ntacl_print_debug_helper(struct ndr_print *ndr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3) { - printf("This utility disabled until rewritten\n"); + va_list ap; + char *s = NULL; + int i; + + va_start(ap, format); + vasprintf(&s, format, ap); + va_end(ap); + + for (i=0;idepth;i++) { + printf(" "); + } + + printf("%s\n", s); + free(s); +} + +static NTSTATUS get_ntacl(char *filename, struct xattr_NTACL **ntacl, + ssize_t *ntacl_len) +{ + DATA_BLOB blob; + ssize_t size; + NTSTATUS result; + struct ndr_pull *ndr; + struct ndr_print *pr; + + *ntacl = talloc(NULL, struct xattr_NTACL); + + size = getxattr(filename, XATTR_NTACL_NAME, NULL, 0); + + if (size < 0) { + fprintf(stderr, "get_ntacl: %s\n", strerror(errno)); + return NT_STATUS_INTERNAL_ERROR; + } + + blob.data = talloc_size(*ntacl, size); + blob.length = getxattr(filename, XATTR_NTACL_NAME, blob.data, size); + + if (blob.length < 0) { + fprintf(stderr, "get_ntacl: %s\n", strerror(errno)); + return NT_STATUS_INTERNAL_ERROR; + } + + ndr = ndr_pull_init_blob(&blob, NULL); + + result = ndr_pull_xattr_NTACL(ndr, NDR_SCALARS|NDR_BUFFERS, *ntacl); + + if (NT_STATUS_IS_OK(result)) { + pr = talloc(*ntacl, struct ndr_print); + pr->print = ntacl_print_debug_helper; + pr->depth = 0; + pr->flags = 0; + + ndr_print_xattr_NTACL(pr, filename, *ntacl); + } + + return result; +} + +static void print_ntacl(struct xattr_NTACL *ntacl) +{ +} + +int main(int argc, char *argv[]) +{ + struct xattr_NTACL *ntacl; + ssize_t ntacl_len; + + if (argc != 2) { + fprintf(stderr, "Usage: getntacl FILENAME\n"); + return 1; + } + + + get_ntacl(argv[1], &ntacl, &ntacl_len); + + print_ntacl(ntacl); + + return 0; +} + +#else + +int main(int argc, char *argv[]) +{ + printf("getntacl: not compiled with xattr support!\n"); return 1; + } + +#endif -- cgit From a0cb1b0a5f01148ae7a7aea5f87b3dbad7560d0d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 4 May 2005 11:02:18 +0000 Subject: r6612: fix the build metze (This used to be commit a1c7fe2578810d7c2b3c44e8271765468d0fcaee) --- source4/utils/getntacl.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index 8d857d206a..fe1d6adea0 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -27,14 +27,6 @@ #if HAVE_XATTR_SUPPORT -/* eww - crappy dependencies */ - -NTSTATUS samdb_privilege_setup(struct security_token *token) -{ - token->privilege_mask = 0; - return NT_STATUS_OK; -} - static void ntacl_print_debug_helper(struct ndr_print *ndr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3) { va_list ap; -- cgit From b11efd3e505c281bbf5b80aa5d0018134c99eb2d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 17 Jun 2005 06:13:47 +0000 Subject: r7674: Fix the printf() attribute suggestion by correctly prototyping, then declaring the static function. The attribute only works on the prototype, not the function. Andrew Bartlett (This used to be commit 4c254754d25e5aa8b203d2d67a39895ffef3f393) --- source4/utils/getntacl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index fe1d6adea0..c3b704d85e 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -27,7 +27,9 @@ #if HAVE_XATTR_SUPPORT -static void ntacl_print_debug_helper(struct ndr_print *ndr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3) +static void ntacl_print_debug_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); + +static void ntacl_print_debug_helper(struct ndr_print *ndr, const char *format, ...) { va_list ap; char *s = NULL; -- cgit From 3be75a4c6d4b9d86f1b85c75fb2f41c6c0eeec94 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 11 Aug 2005 13:12:45 +0000 Subject: r9240: - move struct security_token to the idl file, with this we can the ndr_pull/push/print functions for it in the ntacl-lsm module - fix compiler warnings in the ldap_encode_ndr_* code metze (This used to be commit 83d65d0d7ed9c240ad44aa2c881c1f07212bfda4) --- source4/utils/getntacl.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index c3b704d85e..942183de3e 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -22,7 +22,6 @@ #include "includes.h" #include "system/filesys.h" -#include "libcli/security/security.h" #include "librpc/gen_ndr/ndr_xattr.h" #if HAVE_XATTR_SUPPORT -- cgit From 64587cbf9eec5b44bd4b78c5e87d84d2ce7c344a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 2 Apr 2006 11:18:34 +0000 Subject: r14858: fix bugs noticed by the ibm code checker metze (This used to be commit 152e7e3d024cbc1ae60f8595507d39b647551a71) --- source4/utils/getntacl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index 942183de3e..98aec2804e 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -65,12 +65,12 @@ static NTSTATUS get_ntacl(char *filename, struct xattr_NTACL **ntacl, } blob.data = talloc_size(*ntacl, size); - blob.length = getxattr(filename, XATTR_NTACL_NAME, blob.data, size); - - if (blob.length < 0) { + size = getxattr(filename, XATTR_NTACL_NAME, blob.data, size); + if (size < 0) { fprintf(stderr, "get_ntacl: %s\n", strerror(errno)); return NT_STATUS_INTERNAL_ERROR; } + blob.length = size; ndr = ndr_pull_init_blob(&blob, NULL); -- cgit From ca62ddd8d901cce923d1cda958793054f80b1f57 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 5 Jun 2006 21:48:29 +0000 Subject: r16051: Move the XATTR compatability code into a new file, so I can use it for the getntacl utility. Andrew Bartlett (This used to be commit b1e0d4747b412929e1d4e24d6d9e504df3ddc824) --- source4/utils/getntacl.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index 98aec2804e..441f233a84 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -23,8 +23,7 @@ #include "includes.h" #include "system/filesys.h" #include "librpc/gen_ndr/ndr_xattr.h" - -#if HAVE_XATTR_SUPPORT +#include "lib/util/wrap_xattr.h" static void ntacl_print_debug_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); @@ -57,7 +56,7 @@ static NTSTATUS get_ntacl(char *filename, struct xattr_NTACL **ntacl, *ntacl = talloc(NULL, struct xattr_NTACL); - size = getxattr(filename, XATTR_NTACL_NAME, NULL, 0); + size = wrap_getxattr(filename, XATTR_NTACL_NAME, NULL, 0); if (size < 0) { fprintf(stderr, "get_ntacl: %s\n", strerror(errno)); @@ -65,7 +64,7 @@ static NTSTATUS get_ntacl(char *filename, struct xattr_NTACL **ntacl, } blob.data = talloc_size(*ntacl, size); - size = getxattr(filename, XATTR_NTACL_NAME, blob.data, size); + size = wrap_getxattr(filename, XATTR_NTACL_NAME, blob.data, size); if (size < 0) { fprintf(stderr, "get_ntacl: %s\n", strerror(errno)); return NT_STATUS_INTERNAL_ERROR; @@ -109,14 +108,3 @@ int main(int argc, char *argv[]) return 0; } - -#else - -int main(int argc, char *argv[]) -{ - printf("getntacl: not compiled with xattr support!\n"); - return 1; - -} - -#endif -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/utils/getntacl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index 441f233a84..ae5c130638 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From dccf3f99e45137b6cd18c1de1c79808ad67130d1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 13:27:14 +0000 Subject: r25027: Fix more warnings. (This used to be commit 5085c53fcfade614e83d21fc2c1a5bc43bb2a729) --- source4/utils/getntacl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index ae5c130638..c3f9332537 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -62,7 +62,7 @@ static NTSTATUS get_ntacl(char *filename, struct xattr_NTACL **ntacl, return NT_STATUS_INTERNAL_ERROR; } - blob.data = talloc_size(*ntacl, size); + blob.data = talloc_array(*ntacl, uint8_t, size); size = wrap_getxattr(filename, XATTR_NTACL_NAME, blob.data, size); if (size < 0) { fprintf(stderr, "get_ntacl: %s\n", strerror(errno)); -- cgit From f1374b02eab98fa63d484e39a14a934db4ee0dea Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 2 Nov 2007 08:49:23 +0100 Subject: r25790: - remove some nesting by using error and out logic - print in the print_* function ... metze (This used to be commit dbd7e8bcceeecaa650b164990f9874cf3308974e) --- source4/utils/getntacl.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index c3f9332537..18a889a030 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -44,16 +44,17 @@ static void ntacl_print_debug_helper(struct ndr_print *ndr, const char *format, free(s); } -static NTSTATUS get_ntacl(char *filename, struct xattr_NTACL **ntacl, +static NTSTATUS get_ntacl(TALLOC_CTX *mem_ctx, + char *filename, + struct xattr_NTACL **ntacl, ssize_t *ntacl_len) { DATA_BLOB blob; ssize_t size; NTSTATUS result; struct ndr_pull *ndr; - struct ndr_print *pr; - *ntacl = talloc(NULL, struct xattr_NTACL); + *ntacl = talloc(mem_ctx, struct xattr_NTACL); size = wrap_getxattr(filename, XATTR_NTACL_NAME, NULL, 0); @@ -74,24 +75,30 @@ static NTSTATUS get_ntacl(char *filename, struct xattr_NTACL **ntacl, result = ndr_pull_xattr_NTACL(ndr, NDR_SCALARS|NDR_BUFFERS, *ntacl); - if (NT_STATUS_IS_OK(result)) { - pr = talloc(*ntacl, struct ndr_print); - pr->print = ntacl_print_debug_helper; - pr->depth = 0; - pr->flags = 0; - - ndr_print_xattr_NTACL(pr, filename, *ntacl); + if (!NT_STATUS_IS_OK(result)) { + return result; } - return result; + return NT_STATUS_OK; } -static void print_ntacl(struct xattr_NTACL *ntacl) +static void print_ntacl(TALLOC_CTX *mem_ctx, + const char *fname, + struct xattr_NTACL *ntacl) { + struct ndr_print *pr; + + pr = talloc_zero(mem_ctx, struct ndr_print); + if (!pr) return; + pr->print = ntacl_print_debug_helper; + + ndr_print_xattr_NTACL(pr, fname, ntacl); + talloc_free(pr); } int main(int argc, char *argv[]) { + NTSTATUS status; struct xattr_NTACL *ntacl; ssize_t ntacl_len; @@ -100,10 +107,15 @@ int main(int argc, char *argv[]) return 1; } + status = get_ntacl(NULL, argv[1], &ntacl, &ntacl_len); + if (!NT_STATUS_IS_OK(status)) { + fprintf(stderr, "get_ntacl failed: %s\n", nt_errstr(status)); + return 1; + } - get_ntacl(argv[1], &ntacl, &ntacl_len); + print_ntacl(ntacl, argv[1], ntacl); - print_ntacl(ntacl); + talloc_free(ntacl); return 0; } -- cgit From 529763a9aa192a6785ba878aceeb1683c2510913 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2007 19:24:51 +0100 Subject: r25920: ndr: change NTSTAUS into enum ndr_err_code (samba4 callers) lib/messaging/ lib/registry/ lib/ldb-samba/ librpc/rpc/ auth/auth_winbind.c auth/gensec/ auth/kerberos/ dsdb/repl/ dsdb/samdb/ dsdb/schema/ torture/ cluster/ctdb/ kdc/ ntvfs/ipc/ torture/rap/ ntvfs/ utils/getntacl.c ntptr/ smb_server/ libcli/wrepl/ wrepl_server/ libcli/cldap/ libcli/dgram/ libcli/ldap/ libcli/raw/ libcli/nbt/ libnet/ winbind/ rpc_server/ metze (This used to be commit 6223c7fddc972687eb577e04fc1c8e0604c35435) --- source4/utils/getntacl.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index 18a889a030..382a020c40 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -51,7 +51,7 @@ static NTSTATUS get_ntacl(TALLOC_CTX *mem_ctx, { DATA_BLOB blob; ssize_t size; - NTSTATUS result; + enum ndr_err_code ndr_err; struct ndr_pull *ndr; *ntacl = talloc(mem_ctx, struct xattr_NTACL); @@ -73,10 +73,9 @@ static NTSTATUS get_ntacl(TALLOC_CTX *mem_ctx, ndr = ndr_pull_init_blob(&blob, NULL); - result = ndr_pull_xattr_NTACL(ndr, NDR_SCALARS|NDR_BUFFERS, *ntacl); - - if (!NT_STATUS_IS_OK(result)) { - return result; + ndr_err = ndr_pull_xattr_NTACL(ndr, NDR_SCALARS|NDR_BUFFERS, *ntacl); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return ndr_map_error2ntstatus(ndr_err); } return NT_STATUS_OK; -- cgit From d1e716cf4331bf09cfe15a6634bc5887aff81d20 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 13 Dec 2007 22:46:27 +0100 Subject: r26432: Require ndr_pull users to specify iconv_convenience. (This used to be commit 28b1d36551b75241c1cf9fca5d74f45a6dc884ab) --- source4/utils/getntacl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index 382a020c40..e1ab97b4d5 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -23,6 +23,7 @@ #include "system/filesys.h" #include "librpc/gen_ndr/ndr_xattr.h" #include "lib/util/wrap_xattr.h" +#include "param/param.h" static void ntacl_print_debug_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3); @@ -71,7 +72,7 @@ static NTSTATUS get_ntacl(TALLOC_CTX *mem_ctx, } blob.length = size; - ndr = ndr_pull_init_blob(&blob, NULL); + ndr = ndr_pull_init_blob(&blob, NULL, lp_iconv_convenience(global_loadparm)); ndr_err = ndr_pull_xattr_NTACL(ndr, NDR_SCALARS|NDR_BUFFERS, *ntacl); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { -- cgit From 84b476394713d4f2b84782c59dcc084a25af360f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 13 Dec 2007 23:23:25 +0100 Subject: r26441: Remove global_loadparm uses. (This used to be commit 32007c6277efa46341da7741b749a98633d71640) --- source4/utils/getntacl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/getntacl.c') diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c index e1ab97b4d5..132d689dcb 100644 --- a/source4/utils/getntacl.c +++ b/source4/utils/getntacl.c @@ -72,7 +72,7 @@ static NTSTATUS get_ntacl(TALLOC_CTX *mem_ctx, } blob.length = size; - ndr = ndr_pull_init_blob(&blob, NULL, lp_iconv_convenience(global_loadparm)); + ndr = ndr_pull_init_blob(&blob, NULL, NULL); ndr_err = ndr_pull_xattr_NTACL(ndr, NDR_SCALARS|NDR_BUFFERS, *ntacl); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { -- cgit