svn commit: samba r6527 - in branches/SAMBA_4_0/source/utils: .

tpot at samba.org tpot at samba.org
Sat Apr 30 08:38:32 GMT 2005


Author: tpot
Date: 2005-04-30 08:38:32 +0000 (Sat, 30 Apr 2005)
New Revision: 6527

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=6527

Log:
Resurrect getntacl utility program.  At the moment we only display the
output of ndr_print_xattr_NTACL() to stdout.

Modified:
   branches/SAMBA_4_0/source/utils/config.mk
   branches/SAMBA_4_0/source/utils/getntacl.c


Changeset:
Modified: branches/SAMBA_4_0/source/utils/config.mk
===================================================================
--- branches/SAMBA_4_0/source/utils/config.mk	2005-04-30 08:17:13 UTC (rev 6526)
+++ branches/SAMBA_4_0/source/utils/config.mk	2005-04-30 08:38:32 UTC (rev 6527)
@@ -83,3 +83,18 @@
 		LIB_SECURITY_NDR
 # End BINARY nmblookup
 #################################
+
+#################################
+# Start BINARY getnacl
+[BINARY::getntacl]
+OBJ_FILES = \
+		utils/getntacl.o
+REQUIRED_SUBSYSTEMS = \
+		CONFIG \
+		LIBBASIC \
+		LIBTALLOC \
+		NDR_XATTR \
+		LIB_SECURITY \
+		NDR_MISC
+# End BINARY getntacl
+#################################

Modified: branches/SAMBA_4_0/source/utils/getntacl.c
===================================================================
--- branches/SAMBA_4_0/source/utils/getntacl.c	2005-04-30 08:17:13 UTC (rev 6526)
+++ branches/SAMBA_4_0/source/utils/getntacl.c	2005-04-30 08:38:32 UTC (rev 6527)
@@ -3,7 +3,7 @@
 
    Get NT ACLs from UNIX files.
 
-   Copyright (C) Tim Potter <tpot at samba.org> 2004
+   Copyright (C) Tim Potter <tpot at samba.org> 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)
 {
-	printf("This utility disabled until rewritten\n");
+	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;
+	char *s = NULL;
+	int i;
+
+	va_start(ap, format);
+	vasprintf(&s, format, ap);
+	va_end(ap);
+
+	for (i=0;i<ndr->depth;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



More information about the samba-cvs mailing list