From df99e4bb3751560eb74a4a923c4d7510926f5d71 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 24 Sep 2004 12:41:00 +0000 Subject: r2597: A small program that takes SID strings on stdin and produces a marshalled lsa_SidArray on stdout. (This used to be commit d7d8a7ffc66cf6f78f11e8aed975d746c7a520a3) --- source4/utils/config.m4 | 2 ++ source4/utils/config.mk | 14 +++++++++ source4/utils/setnttoken.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 source4/utils/setnttoken.c (limited to 'source4/utils') diff --git a/source4/utils/config.m4 b/source4/utils/config.m4 index 74a31de1772..22cfe1131fe 100644 --- a/source4/utils/config.m4 +++ b/source4/utils/config.m4 @@ -8,3 +8,5 @@ SMB_INCLUDE_M4(utils/net/config.m4) SMB_BINARY_MK(getntacl, utils/config.mk) SMB_BINARY_MK(setntacl, utils/config.mk) + +SMB_BINARY_MK(setnttoken, utils/config.mk) diff --git a/source4/utils/config.mk b/source4/utils/config.mk index 0860e89ea3b..7a773ad6023 100644 --- a/source4/utils/config.mk +++ b/source4/utils/config.mk @@ -67,3 +67,17 @@ REQUIRED_SUBSYSTEMS = \ LIBRPC # End BINARY setntacl ################################# + +################################# +# Start BINARY setnttoken +[BINARY::setnttoken] +OBJ_FILES = \ + utils/setnttoken.o +REQUIRED_SUBSYSTEMS = \ + CONFIG \ + LIBCMDLINE \ + LIBBASIC \ + LIBSMB \ + LIBRPC +# End BINARY setnttoken +################################# diff --git a/source4/utils/setnttoken.c b/source4/utils/setnttoken.c new file mode 100644 index 00000000000..96adaf8286e --- /dev/null +++ b/source4/utils/setnttoken.c @@ -0,0 +1,77 @@ +/* + Unix SMB/CIFS implementation. + + Set NT ACLs on 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" + +#ifdef HAVE_NO_ACLS + +int main(int argc, char **argv) +{ + printf("ACL support not compiled in."); + return 1; +} + +#else + +int main(int argc, char **argv) +{ + char line[255]; + struct ndr_push *ndr; + struct lsa_SidArray sidarray; + NTSTATUS status; + + setup_logging("setnttoken", DEBUG_STDOUT); + + ndr = ndr_push_init(); + + sidarray.num_sids = 0; + sidarray.sids = NULL; + + while(fgets(line, sizeof(line), stdin)) { + struct dom_sid *sid = dom_sid_parse_talloc(ndr, line); + + if (!sid) { + fprintf(stderr, "Invalid sid: %s", line); + continue; + } + + sidarray.sids = talloc_realloc( + sidarray.sids, + (sidarray.num_sids + 1) * sizeof(struct lsa_SidPtr)); + + sidarray.sids[sidarray.num_sids].sid = + dom_sid_dup(ndr, sid); + + sidarray.num_sids++; + } + +/* NDR_PRINT_DEBUG(lsa_SidArray, &sidarray); */ + + status = ndr_push_lsa_SidArray( + ndr, NDR_SCALARS|NDR_BUFFERS, &sidarray); + + fwrite(ndr->data, 1, ndr->offset, stdout); + + return 0; +} + +#endif /* HAVE_NO_ACLS */ -- cgit