diff options
Diffstat (limited to 'source4/utils')
-rw-r--r-- | source4/utils/config.mk | 94 | ||||
-rw-r--r-- | source4/utils/getntacl.c | 121 | ||||
-rw-r--r-- | source4/utils/man/getntacl.1.xml | 45 | ||||
-rw-r--r-- | source4/utils/man/ntlm_auth.1.xml | 5 | ||||
-rw-r--r-- | source4/utils/net/config.mk | 28 | ||||
-rw-r--r-- | source4/utils/net/net.c | 219 | ||||
-rw-r--r-- | source4/utils/net/net.h | 39 | ||||
-rw-r--r-- | source4/utils/net/net_export_keytab.c | 110 | ||||
-rw-r--r-- | source4/utils/net/net_join.c | 104 | ||||
-rw-r--r-- | source4/utils/net/net_machinepw.c | 91 | ||||
-rw-r--r-- | source4/utils/net/net_password.c | 171 | ||||
-rw-r--r-- | source4/utils/net/net_time.c | 78 | ||||
-rw-r--r-- | source4/utils/net/net_user.c | 125 | ||||
-rw-r--r-- | source4/utils/net/net_vampire.c | 249 | ||||
-rw-r--r-- | source4/utils/ntlm_auth.c | 63 | ||||
-rw-r--r-- | source4/utils/oLschema2ldif.c | 121 | ||||
-rw-r--r-- | source4/utils/setntacl.c | 28 | ||||
-rw-r--r-- | source4/utils/setnttoken.c | 28 | ||||
-rw-r--r-- | source4/utils/testparm.c | 260 | ||||
-rwxr-xr-x | source4/utils/tests/test_samba_tool.sh (renamed from source4/utils/tests/test_net.sh) | 14 | ||||
-rw-r--r-- | source4/utils/wscript_build | 17 |
21 files changed, 157 insertions, 1853 deletions
diff --git a/source4/utils/config.mk b/source4/utils/config.mk deleted file mode 100644 index 5fa7e200f0..0000000000 --- a/source4/utils/config.mk +++ /dev/null @@ -1,94 +0,0 @@ -# utils subsystem - -################################# -# Start BINARY ntlm_auth -[BINARY::ntlm_auth] -INSTALLDIR = BINDIR -PRIVATE_DEPENDENCIES = \ - LIBSAMBA-HOSTCONFIG \ - LIBSAMBA-UTIL \ - LIBPOPT \ - POPT_SAMBA \ - POPT_CREDENTIALS \ - gensec \ - LIBCLI_RESOLVE \ - auth \ - ntlm_check \ - MESSAGING \ - LIBEVENTS -# End BINARY ntlm_auth -################################# - -ntlm_auth_OBJ_FILES = $(utilssrcdir)/ntlm_auth.o - -MANPAGES += $(utilssrcdir)/man/ntlm_auth.1 - -################################# -# Start BINARY getntacl -[BINARY::getntacl] -INSTALLDIR = BINDIR -PRIVATE_DEPENDENCIES = \ - LIBSAMBA-HOSTCONFIG \ - LIBSAMBA-UTIL \ - NDR_XATTR \ - WRAP_XATTR \ - LIBSAMBA-ERRORS - -getntacl_OBJ_FILES = $(utilssrcdir)/getntacl.o - -# End BINARY getntacl -################################# - -MANPAGES += $(utilssrcdir)/man/getntacl.1 - -################################# -# Start BINARY setntacl -[BINARY::setntacl] -# disabled until rewritten -#INSTALLDIR = BINDIR -# End BINARY setntacl -################################# - -setntacl_OBJ_FILES = $(utilssrcdir)/setntacl.o - -################################# -# Start BINARY setnttoken -[BINARY::setnttoken] -INSTALLDIR = BINDIR -PRIVATE_DEPENDENCIES = -# End BINARY setnttoken -################################# - -setnttoken_OBJ_FILES = $(utilssrcdir)/setnttoken.o - -################################# -# Start BINARY testparm -[BINARY::testparm] -INSTALLDIR = BINDIR -PRIVATE_DEPENDENCIES = \ - LIBSAMBA-HOSTCONFIG \ - LIBSAMBA-UTIL \ - LIBPOPT \ - samba_socket \ - POPT_SAMBA \ - LIBCLI_RESOLVE \ - CHARSET -# End BINARY testparm -################################# - -testparm_OBJ_FILES = $(utilssrcdir)/testparm.o - -################################################ -# Start BINARY oLschema2ldif -[BINARY::oLschema2ldif] -INSTALLDIR = BINDIR -PRIVATE_DEPENDENCIES = \ - LIBLDB_CMDLINE SAMDB -# End BINARY oLschema2ldif -################################################ - - -oLschema2ldif_OBJ_FILES = $(addprefix $(utilssrcdir)/, oLschema2ldif.o) - -MANPAGES += $(utilssrcdir)/man/oLschema2ldif.1 - diff --git a/source4/utils/getntacl.c b/source4/utils/getntacl.c deleted file mode 100644 index f26c87bd85..0000000000 --- a/source4/utils/getntacl.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Get NT ACLs from UNIX files. - - Copyright (C) Tim Potter <tpot@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 - 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, - 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, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" -#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); - -static void ntacl_print_debug_helper(struct ndr_print *ndr, const char *format, ...) -{ - 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(TALLOC_CTX *mem_ctx, - char *filename, - struct xattr_NTACL **ntacl, - ssize_t *ntacl_len) -{ - DATA_BLOB blob; - ssize_t size; - enum ndr_err_code ndr_err; - struct ndr_pull *ndr; - - *ntacl = talloc(mem_ctx, struct xattr_NTACL); - - size = wrap_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_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)); - return NT_STATUS_INTERNAL_ERROR; - } - blob.length = size; - - 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)) { - return ndr_map_error2ntstatus(ndr_err); - } - - return NT_STATUS_OK; -} - -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; - - if (argc != 2) { - fprintf(stderr, "Usage: getntacl FILENAME\n"); - 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; - } - - print_ntacl(ntacl, argv[1], ntacl); - - talloc_free(ntacl); - - return 0; -} diff --git a/source4/utils/man/getntacl.1.xml b/source4/utils/man/getntacl.1.xml deleted file mode 100644 index cbce5f2103..0000000000 --- a/source4/utils/man/getntacl.1.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!DOCTYPE refentry PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc"> -<refentry id="getntacl.1"> - -<refmeta> - <refentrytitle>getntacl</refentrytitle> - <manvolnum>1</manvolnum> -</refmeta> - - -<refnamediv> - <refname>getntacl</refname> - <refpurpose>Tool for displaying NT ACLs stored in extended attributes</refpurpose> -</refnamediv> - -<refsynopsisdiv> - <cmdsynopsis> - <command>getntacl</command> - <arg choice="req">filename</arg> - </cmdsynopsis> -</refsynopsisdiv> - -<refsect1> - <title>DESCRIPTION</title> - - <para>Retrieves the NT security ACL on the specified file, as -stored in the filesystems' extended attribute. </para> -</refsect1> - -<refsect1> - <title>VERSION</title> - - <para>This man page is correct for version 4.0 of the Samba suite.</para> -</refsect1> - -<refsect1> - <title>AUTHOR</title> - - <para>This utility is part of the <ulink url="http://www.samba.org/">Samba</ulink> suite, which is developed by the global <ulink url="http://www.samba.org/samba/team/">Samba Team</ulink>.</para> - - <para>This manpage was written by Jelmer Vernooij. </para> - -</refsect1> - -</refentry> diff --git a/source4/utils/man/ntlm_auth.1.xml b/source4/utils/man/ntlm_auth.1.xml index 1677500112..09a8961a91 100644 --- a/source4/utils/man/ntlm_auth.1.xml +++ b/source4/utils/man/ntlm_auth.1.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!DOCTYPE refentry PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc"> +<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> <refentry id="ntlm-auth.1"> <refmeta> @@ -203,9 +203,6 @@ </listitem> </varlistentry> - &popt.common.samba; - &stdarg.help; - </variablelist> </refsect1> diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk deleted file mode 100644 index ff8cb2c526..0000000000 --- a/source4/utils/net/config.mk +++ /dev/null @@ -1,28 +0,0 @@ -# $(utilssrcdir)/net subsystem - -################################# -# Start BINARY net -[BINARY::net] -INSTALLDIR = BINDIR -PRIVATE_DEPENDENCIES = \ - LIBSAMBA-HOSTCONFIG \ - LIBSAMBA-UTIL \ - LIBSAMBA-NET \ - LIBPOPT \ - POPT_SAMBA \ - POPT_CREDENTIALS -# End BINARY net -################################# - -net_OBJ_FILES = $(addprefix $(utilssrcdir)/net/, \ - net.o \ - net_machinepw.o \ - net_password.o \ - net_time.o \ - net_join.o \ - net_vampire.o \ - net_user.o \ - net_export_keytab.o) - - -$(eval $(call proto_header_template,$(utilssrcdir)/net/net_proto.h,$(net_OBJ_FILES:.o=.c))) diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c deleted file mode 100644 index a96c672dfd..0000000000 --- a/source4/utils/net/net.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - Samba Unix/Linux SMB client library - Distributed SMB/CIFS Server Management Utility - Copyright (C) 2001 Steve French (sfrench@us.ibm.com) - Copyright (C) 2001 Jim McDonough (jmcd@us.ibm.com) - Copyright (C) 2001 Andrew Tridgell (tridge@samba.org) - Copyright (C) 2001 Andrew Bartlett (abartlet@samba.org) - Copyright (C) 2004 Stefan Metzmacher (metze@samba.org) - - Largely rewritten by metze in August 2004 - - Originally written by Steve and Jim. Largely rewritten by tridge in - November 2001. - - Reworked again by abartlet in December 2001 - - 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 3 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, see <http://www.gnu.org/licenses/>. -*/ - -/*****************************************************/ -/* */ -/* Distributed SMB/CIFS Server Management Utility */ -/* */ -/* The intent was to make the syntax similar */ -/* to the NET utility (first developed in DOS */ -/* with additional interesting & useful functions */ -/* added in later SMB server network operating */ -/* systems). */ -/* */ -/*****************************************************/ - -#include "includes.h" -#include "utils/net/net.h" -#include "lib/cmdline/popt_common.h" -#include "lib/ldb/include/ldb.h" -#include "librpc/rpc/dcerpc.h" -#include "param/param.h" -#include "lib/events/events.h" -#include "auth/credentials/credentials.h" - -/* - run a function from a function table. If not found then - call the specified usage function -*/ -int net_run_function(struct net_context *ctx, - int argc, const char **argv, - const struct net_functable *functable, - int (*usage_fn)(struct net_context *ctx, int argc, const char **argv)) -{ - int i; - - if (argc == 0) { - return usage_fn(ctx, argc, argv); - - } else if (argc == 1 && strequal(argv[0], "help")) { - return net_help(ctx, functable); - } - - for (i=0; functable[i].name; i++) { - if (strcasecmp_m(argv[0], functable[i].name) == 0) - return functable[i].fn(ctx, argc-1, argv+1); - } - - d_printf("No command: %s\n", argv[0]); - return usage_fn(ctx, argc, argv); -} - -/* - run a usage function from a function table. If not found then fail -*/ -int net_run_usage(struct net_context *ctx, - int argc, const char **argv, - const struct net_functable *functable) -{ - int i; - - for (i=0; functable[i].name; i++) { - if (strcasecmp_m(argv[0], functable[i].name) == 0) - if (functable[i].usage) { - return functable[i].usage(ctx, argc-1, argv+1); - } - } - - d_printf("No usage information for command: %s\n", argv[0]); - - return 1; -} - - -/* main function table */ -static const struct net_functable net_functable[] = { - {"password", "change password\n", net_password, net_password_usage}, - {"time", "get remote server's time\n", net_time, net_time_usage}, - {"join", "join a domain\n", net_join, net_join_usage}, - {"samdump", "dump the sam of a domain\n", net_samdump, net_samdump_usage}, - {"export", "dump the sam of this domain\n", net_export, net_export_usage}, - {"vampire", "join and syncronise an AD domain onto the local server\n", net_vampire, net_vampire_usage}, - {"samsync", "synchronise into the local ldb the sam of an NT4 domain\n", net_samsync_ldb, net_samsync_ldb_usage}, - {"user", "manage user accounts\n", net_user, net_user_usage}, - {"machinepw", "Get a machine password out of our SAM\n", net_machinepw, net_machinepw_usage}, - {NULL, NULL, NULL, NULL} -}; - -int net_help(struct net_context *ctx, const struct net_functable *ftable) -{ - int i = 0; - const char *name = ftable[i].name; - const char *desc = ftable[i].desc; - - d_printf("Available commands:\n"); - while (name && desc) { - d_printf("\t%s\t\t%s", name, desc); - name = ftable[++i].name; - desc = ftable[i].desc; - } - - return 0; -} - -static int net_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("Usage:\n"); - d_printf("net <command> [options]\n"); - return 0; -} - -/**************************************************************************** - main program -****************************************************************************/ -static int binary_net(int argc, const char **argv) -{ - int opt,i; - int rc; - int argc_new; - const char **argv_new; - struct tevent_context *ev; - struct net_context *ctx = NULL; - poptContext pc; - struct poptOption long_options[] = { - POPT_AUTOHELP - POPT_COMMON_SAMBA - POPT_COMMON_CONNECTION - POPT_COMMON_CREDENTIALS - POPT_COMMON_VERSION - { NULL } - }; - - setlinebuf(stdout); - - pc = poptGetContext("net", argc, (const char **) argv, long_options, - POPT_CONTEXT_KEEP_FIRST); - - while((opt = poptGetNextOpt(pc)) != -1) { - switch (opt) { - default: - d_printf("Invalid option %s: %s\n", - poptBadOption(pc, 0), poptStrerror(opt)); - net_usage(ctx, argc, argv); - exit(1); - } - } - - argv_new = (const char **)poptGetArgs(pc); - - argc_new = argc; - for (i=0; i<argc; i++) { - if (argv_new[i] == NULL) { - argc_new = i; - break; - } - } - - if (argc_new < 2) { - return net_usage(ctx, argc, argv); - } - - dcerpc_init(cmdline_lp_ctx); - - ev = s4_event_context_init(NULL); - if (!ev) { - d_printf("Failed to create an event context\n"); - exit(1); - } - ctx = talloc(ev, struct net_context); - if (!ctx) { - d_printf("Failed to talloc a net_context\n"); - exit(1); - } - - ZERO_STRUCTP(ctx); - ctx->lp_ctx = cmdline_lp_ctx; - ctx->credentials = cmdline_credentials; - ctx->event_ctx = ev; - - rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); - - if (rc != 0) { - DEBUG(0,("return code = %d\n", rc)); - } - - talloc_free(ev); - return rc; -} - - int main(int argc, const char **argv) -{ - return binary_net(argc, argv); -} diff --git a/source4/utils/net/net.h b/source4/utils/net/net.h deleted file mode 100644 index 16223a15bb..0000000000 --- a/source4/utils/net/net.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - Samba Unix/Linux SMB client library - Distributed SMB/CIFS Server Management Utility - - Copyright (C) Stefan Metzmacher 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 3 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, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef _UTIL_NET_H -#define _UTIL_NET_H - -struct net_context { - struct cli_credentials *credentials; - struct loadparm_context *lp_ctx; - struct tevent_context *event_ctx; -}; - -struct net_functable { - const char *name; - const char *desc; - int (*fn)(struct net_context *ctx, int argc, const char **argv); - int (*usage)(struct net_context *ctx, int argc, const char **argv); -}; - -#include "utils/net/net_proto.h" - -#endif /* _UTIL_NET_H */ diff --git a/source4/utils/net/net_export_keytab.c b/source4/utils/net/net_export_keytab.c deleted file mode 100644 index 7f13278a9e..0000000000 --- a/source4/utils/net/net_export_keytab.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - Samba Unix/Linux SMB client library - Distributed SMB/CIFS Server Management Utility - - Copyright (C) 2004 Stefan Metzmacher <metze@samba.org> - Copyright (C) 2005 Andrew Bartlett <abartlet@samba.org> - - 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 3 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, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" -#include "utils/net/net.h" -#include "libnet/libnet.h" -#include "param/param.h" - -static int net_export_keytab_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net export keytab <keytab>\n"); - return 0; -} - -static int net_export_keytab_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("Dumps kerberos keys of the domain into a keytab.\n"); - return 0; -} - -static int net_export_keytab(struct net_context *ctx, int argc, const char **argv) -{ - NTSTATUS status; - struct libnet_context *libnetctx; - struct libnet_export_keytab r; - - switch (argc) { - case 0: - return net_export_keytab_usage(ctx, argc, argv); - break; - case 1: - r.in.keytab_name = argv[0]; - break; - } - - libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); - if (!libnetctx) { - return -1; - } - libnetctx->cred = ctx->credentials; - - r.out.error_string = NULL; - - status = libnet_export_keytab(libnetctx, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("libnet_export_keytab returned %s: %s\n", - nt_errstr(status), - r.out.error_string)); - return -1; - } - - talloc_free(libnetctx); - - return 0; -} - -/* main function table */ -static const struct net_functable net_export_functable[] = { - {"keytab", "dump keys into a keytab\n", net_export_keytab, net_export_keytab_usage}, - {NULL, NULL, NULL, NULL} -}; - -int net_export(struct net_context *ctx, int argc, const char **argv) -{ - int rc; - - switch (argc) { - case 0: - rc = net_export_usage(ctx, argc, argv); - return rc; - case 1: - default: - rc = net_run_function(ctx, argc, argv, net_export_functable, - net_export_usage); - return rc; - } - - return 0; -} - -int net_export_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net export keytab <keytab>\n"); - return 0; -} - -int net_export_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("Dumps the sam of the domain we are joined to.\n"); - return 0; -} - diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c deleted file mode 100644 index 316bc129f1..0000000000 --- a/source4/utils/net/net_join.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - Samba Unix/Linux SMB client library - Distributed SMB/CIFS Server Management Utility - - Copyright (C) 2004 Stefan Metzmacher <metze@samba.org> - Copyright (C) 2005 Andrew Bartlett <abartlet@samba.org> - - 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 3 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, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" -#include "utils/net/net.h" -#include "libnet/libnet.h" -#include "libcli/security/security.h" -#include "param/param.h" -#include "lib/events/events.h" - -int net_join(struct net_context *ctx, int argc, const char **argv) -{ - NTSTATUS status; - struct libnet_context *libnetctx; - struct libnet_Join *r; - char *tmp; - const char *domain_name; - enum netr_SchannelType secure_channel_type = SEC_CHAN_WKSTA; - - switch (argc) { - case 0: /* no args -> fail */ - return net_join_usage(ctx, argc, argv); - case 1: /* only DOMAIN */ - tmp = talloc_strdup(ctx, argv[0]); - break; - case 2: /* DOMAIN and role */ - tmp = talloc_strdup(ctx, argv[0]); - if (strcasecmp(argv[1], "BDC") == 0) { - secure_channel_type = SEC_CHAN_BDC; - } else if (strcasecmp(argv[1], "MEMBER") == 0) { - secure_channel_type = SEC_CHAN_WKSTA; - } else { - d_fprintf(stderr, "net_join: Invalid 2nd argument (%s) must be MEMBER or BDC\n", argv[1]); - return net_join_usage(ctx, argc, argv); - } - break; - default: /* too many args -> fail */ - return net_join_usage(ctx, argc, argv); - } - - domain_name = tmp; - - libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); - if (!libnetctx) { - return -1; - } - libnetctx->cred = ctx->credentials; - r = talloc(ctx, struct libnet_Join); - if (!r) { - return -1; - } - /* prepare parameters for the join */ - r->in.netbios_name = lp_netbios_name(ctx->lp_ctx); - r->in.domain_name = domain_name; - r->in.join_type = secure_channel_type; - r->in.level = LIBNET_JOIN_AUTOMATIC; - r->out.error_string = NULL; - - /* do the domain join */ - status = libnet_Join(libnetctx, r, r); - - if (!NT_STATUS_IS_OK(status)) { - d_fprintf(stderr, "Joining domain failed: %s\n", - r->out.error_string ? r->out.error_string : nt_errstr(status)); - talloc_free(r); - talloc_free(libnetctx); - return -1; - } - d_printf("Joined domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx, r->out.domain_sid)); - - talloc_free(libnetctx); - return 0; -} - -int net_join_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net join <domain> [BDC | MEMBER] [options]\n"); - return 0; -} - -int net_join_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("Joins domain as either member or backup domain controller.\n"); - return 0; -} - diff --git a/source4/utils/net/net_machinepw.c b/source4/utils/net/net_machinepw.c deleted file mode 100644 index 390eb8df0b..0000000000 --- a/source4/utils/net/net_machinepw.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - Samba Unix/Linux SMB client library - Distributed SMB/CIFS Server Management Utility - - Copyright (C) 2008 Volker Lendecke - - 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 3 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, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" -#include "lib/events/events.h" -#include "utils/net/net.h" -#include "libnet/libnet.h" -#include "libcli/security/security.h" -#include "param/secrets.h" -#include "param/param.h" -#include "lib/util/util_ldb.h" - -int net_machinepw_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net machinepw <accountname>\n"); - return -1; -} - -int net_machinepw(struct net_context *ctx, int argc, const char **argv) -{ - struct ldb_context *secrets; - TALLOC_CTX *mem_ctx; - struct tevent_context *ev; - struct ldb_message **msgs; - int num_records; - const char *attrs[] = { "secret", NULL }; - const char *secret; - - if (argc != 1) { - net_machinepw_usage(ctx, argc, argv); - return -1; - } - - mem_ctx = talloc_new(ctx); - if (mem_ctx == NULL) { - d_fprintf(stderr, "talloc_new failed\n"); - return -1; - } - - ev = event_context_init(mem_ctx); - if (ev == NULL) { - d_fprintf(stderr, "event_context_init failed\n"); - goto fail; - } - - secrets = secrets_db_connect(mem_ctx, ev, ctx->lp_ctx); - if (secrets == NULL) { - d_fprintf(stderr, "secrets_db_connect failed\n"); - goto fail; - } - - num_records = gendb_search(secrets, mem_ctx, NULL, &msgs, attrs, - "(&(objectclass=primaryDomain)" - "(samaccountname=%s))", argv[0]); - if (num_records != 1) { - d_fprintf(stderr, "gendb_search returned %d records, " - "expected 1\n", num_records); - goto fail; - } - - secret = ldb_msg_find_attr_as_string(msgs[0], "secret", NULL); - if (secret == NULL) { - d_fprintf(stderr, "machine account contains no secret\n"); - goto fail; - } - - printf("%s\n", secret); - talloc_free(mem_ctx); - return 0; - - fail: - talloc_free(mem_ctx); - return -1; -} diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c deleted file mode 100644 index 55f7c3c31d..0000000000 --- a/source4/utils/net/net_password.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - Samba Unix/Linux SMB client library - Distributed SMB/CIFS Server Management Utility - - Copyright (C) 2004 Stefan Metzmacher (metze@samba.org) - - 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 3 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, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" -#include "utils/net/net.h" -#include "libnet/libnet.h" -#include "system/filesys.h" -#include "lib/events/events.h" -#include "auth/credentials/credentials.h" - -/* - * Code for Changing and setting a password - */ - -static int net_password_change_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net_password_change_usage: TODO\n"); - return 0; -} - - -static int net_password_change(struct net_context *ctx, int argc, const char **argv) -{ - NTSTATUS status; - struct libnet_context *libnetctx; - union libnet_ChangePassword r; - char *password_prompt = NULL; - const char *new_password; - - if (argc > 0 && argv[0]) { - new_password = argv[0]; - } else { - password_prompt = talloc_asprintf(ctx, "Enter new password for account [%s\\%s]:", - cli_credentials_get_domain(ctx->credentials), - cli_credentials_get_username(ctx->credentials)); - new_password = getpass(password_prompt); - } - - libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); - if (!libnetctx) { - return -1; - } - libnetctx->cred = ctx->credentials; - - /* prepare password change */ - r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; - r.generic.in.account_name = cli_credentials_get_username(ctx->credentials); - r.generic.in.domain_name = cli_credentials_get_domain(ctx->credentials); - r.generic.in.oldpassword = cli_credentials_get_password(ctx->credentials); - r.generic.in.newpassword = new_password; - - /* do password change */ - status = libnet_ChangePassword(libnetctx, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("net_password_change: %s\n",r.generic.out.error_string)); - return -1; - } - - talloc_free(libnetctx); - - return 0; -} - - -static int net_password_set_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net_password_set_usage: TODO\n"); - return 0; -} - - -static int net_password_set(struct net_context *ctx, int argc, const char **argv) -{ - NTSTATUS status; - struct libnet_context *libnetctx; - union libnet_SetPassword r; - char *password_prompt = NULL; - char *p; - char *tmp; - const char *account_name; - const char *domain_name; - const char *new_password = NULL; - - switch (argc) { - case 0: /* no args -> fail */ - return net_password_set_usage(ctx, argc, argv); - case 1: /* only DOM\\user; prompt for password */ - tmp = talloc_strdup(ctx, argv[0]); - break; - case 2: /* DOM\\USER and password */ - tmp = talloc_strdup(ctx, argv[0]); - new_password = argv[1]; - break; - default: /* too mayn args -> fail */ - DEBUG(0,("net_password_set: too many args [%d]\n",argc)); - return net_password_usage(ctx, argc, argv); - } - - if ((p = strchr_m(tmp,'\\'))) { - *p = 0; - domain_name = tmp; - account_name = talloc_strdup(ctx, p+1); - } else { - account_name = tmp; - domain_name = cli_credentials_get_domain(ctx->credentials); - } - - if (!new_password) { - password_prompt = talloc_asprintf(ctx, "Enter new password for account [%s\\%s]:", - domain_name, account_name); - new_password = getpass(password_prompt); - } - - libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); - if (!libnetctx) { - return -1; - } - libnetctx->cred = ctx->credentials; - - /* prepare password change */ - r.generic.level = LIBNET_SET_PASSWORD_GENERIC; - r.generic.in.account_name = account_name; - r.generic.in.domain_name = domain_name; - r.generic.in.newpassword = new_password; - - /* do password change */ - status = libnet_SetPassword(libnetctx, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("net_password_set: %s\n",r.generic.out.error_string)); - return -1; - } - - talloc_free(libnetctx); - - return 0; -} - - -static const struct net_functable net_password_functable[] = { - {"change", "change password (old password required)\n", net_password_change, net_password_change_usage }, - {"set", "set password\n", net_password_set, net_password_set_usage }, - {NULL, NULL} -}; - -int net_password(struct net_context *ctx, int argc, const char **argv) -{ - return net_run_function(ctx, argc, argv, net_password_functable, net_password_usage); -} - -int net_password_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net password <command> [options]\n"); - return 0; -} diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c deleted file mode 100644 index 92e6e77481..0000000000 --- a/source4/utils/net/net_time.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - Samba Unix/Linux SMB client library - Distributed SMB/CIFS Server Management Utility - - Copyright (C) 2004 Stefan Metzmacher (metze@samba.org) - - 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 3 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, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" -#include "libnet/libnet.h" -#include "utils/net/net.h" -#include "system/time.h" -#include "lib/events/events.h" - -/* - * Code for getting the remote time - */ - -int net_time(struct net_context *ctx, int argc, const char **argv) -{ - NTSTATUS status; - struct libnet_context *libnetctx; - union libnet_RemoteTOD r; - const char *server_name; - struct tm *tm; - char timestr[64]; - - if (argc > 0 && argv[0]) { - server_name = argv[0]; - } else { - return net_time_usage(ctx, argc, argv); - } - - libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); - if (!libnetctx) { - return -1; - } - libnetctx->cred = ctx->credentials; - - /* prepare to get the time */ - r.generic.level = LIBNET_REMOTE_TOD_GENERIC; - r.generic.in.server_name = server_name; - - /* get the time */ - status = libnet_RemoteTOD(libnetctx, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("net_time: %s\n",r.generic.out.error_string)); - return -1; - } - - ZERO_STRUCT(timestr); - tm = localtime(&r.generic.out.time); - strftime(timestr, sizeof(timestr)-1, "%c %Z",tm); - - printf("%s\n",timestr); - - talloc_free(libnetctx); - - return 0; -} - -int net_time_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net time <server> [options]\n"); - return 0; -} diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c deleted file mode 100644 index c4b8ecb0c2..0000000000 --- a/source4/utils/net/net_user.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - Samba Unix/Linux SMB client library - Distributed SMB/CIFS Server Management Utility - - Copyright (C) Rafal Szczesniak <mimir@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 - 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, - 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, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" -#include "utils/net/net.h" -#include "libnet/libnet.h" -#include "lib/events/events.h" -#include "auth/credentials/credentials.h" - -static int net_user_add(struct net_context *ctx, int argc, const char **argv) -{ - NTSTATUS status; - struct libnet_context *lnet_ctx; - struct libnet_CreateUser r; - char *user_name; - - /* command line argument preparation */ - switch (argc) { - case 0: - return net_user_usage(ctx, argc, argv); - break; - case 1: - user_name = talloc_strdup(ctx, argv[0]); - break; - default: - return net_user_usage(ctx, argc, argv); - } - - /* libnet context init and its params */ - lnet_ctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); - if (!lnet_ctx) return -1; - - lnet_ctx->cred = ctx->credentials; - - /* calling CreateUser function */ - r.in.user_name = user_name; - r.in.domain_name = cli_credentials_get_domain(lnet_ctx->cred); - - status = libnet_CreateUser(lnet_ctx, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("Failed to add user account: %s\n", - r.out.error_string)); - return -1; - } - - talloc_free(lnet_ctx); - return 0; -} - -static int net_user_delete(struct net_context *ctx, int argc, const char **argv) -{ - NTSTATUS status; - struct libnet_context *lnet_ctx; - struct libnet_DeleteUser r; - char *user_name; - - /* command line argument preparation */ - switch (argc) { - case 0: - return net_user_usage(ctx, argc, argv); - break; - case 1: - user_name = talloc_strdup(ctx, argv[0]); - break; - default: - return net_user_usage(ctx, argc, argv); - } - - /* libnet context init and its params */ - lnet_ctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); - if (!lnet_ctx) return -1; - - lnet_ctx->cred = ctx->credentials; - - /* calling DeleteUser function */ - r.in.user_name = user_name; - r.in.domain_name = cli_credentials_get_domain(lnet_ctx->cred); - - status = libnet_DeleteUser(lnet_ctx, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("Failed to delete user account: %s\n", - r.out.error_string)); - return -1; - } - - talloc_free(lnet_ctx); - return 0; -} - - -static const struct net_functable net_user_functable[] = { - { "add", "create new user account\n", net_user_add, net_user_usage }, - { "delete", "delete an existing user account\n", net_user_delete, net_user_usage }, - { NULL, NULL } -}; - - -int net_user(struct net_context *ctx, int argc, const char **argv) -{ - return net_run_function(ctx, argc, argv, net_user_functable, net_user_usage); -} - - -int net_user_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net user <command> [options]\n"); - return 0; -} diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c deleted file mode 100644 index 799376767b..0000000000 --- a/source4/utils/net/net_vampire.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - Samba Unix/Linux SMB client library - Distributed SMB/CIFS Server Management Utility - - Copyright (C) 2004 Stefan Metzmacher <metze@samba.org> - Copyright (C) 2005 Andrew Bartlett <abartlet@samba.org> - - 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 3 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, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" -#include "utils/net/net.h" -#include "libnet/libnet.h" -#include "librpc/gen_ndr/samr.h" -#include "auth/auth.h" -#include "libcli/security/security.h" -#include "param/param.h" -#include "lib/events/events.h" - -static int net_samdump_keytab_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net samdump keytab <keytab>\n"); - return 0; -} - -static int net_samdump_keytab_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("Dumps kerberos keys of a domain into a keytab.\n"); - return 0; -} - -static int net_samdump_keytab(struct net_context *ctx, int argc, const char **argv) -{ - NTSTATUS status; - struct libnet_context *libnetctx; - struct libnet_SamDump_keytab r; - - switch (argc) { - case 0: - return net_samdump_keytab_usage(ctx, argc, argv); - break; - case 1: - r.in.keytab_name = argv[0]; - break; - } - - libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); - if (!libnetctx) { - return -1; - } - libnetctx->cred = ctx->credentials; - - r.out.error_string = NULL; - r.in.machine_account = NULL; - r.in.binding_string = NULL; - - status = libnet_SamDump_keytab(libnetctx, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("libnet_SamDump returned %s: %s\n", - nt_errstr(status), - r.out.error_string)); - return -1; - } - - talloc_free(libnetctx); - - return 0; -} - -/* main function table */ -static const struct net_functable net_samdump_functable[] = { - {"keytab", "dump keys into a keytab\n", net_samdump_keytab, net_samdump_keytab_usage}, - {NULL, NULL, NULL, NULL} -}; - -int net_samdump(struct net_context *ctx, int argc, const char **argv) -{ - NTSTATUS status; - struct libnet_context *libnetctx; - struct libnet_SamDump r; - int rc; - - switch (argc) { - case 0: - break; - case 1: - default: - rc = net_run_function(ctx, argc, argv, net_samdump_functable, - net_samdump_usage); - return rc; - } - - libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); - if (!libnetctx) { - return -1; - } - libnetctx->cred = ctx->credentials; - - r.out.error_string = NULL; - r.in.machine_account = NULL; - r.in.binding_string = NULL; - - status = libnet_SamDump(libnetctx, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("libnet_SamDump returned %s: %s\n", - nt_errstr(status), - r.out.error_string)); - return -1; - } - - talloc_free(libnetctx); - - return 0; -} - -int net_samdump_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net samdump\n"); - d_printf("net samdump keytab <keytab>\n"); - return 0; -} - -int net_samdump_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("Dumps the sam of the domain we are joined to.\n"); - return 0; -} - -int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv) -{ - NTSTATUS status; - struct libnet_context *libnetctx; - struct libnet_samsync_ldb r; - - libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); - if (!libnetctx) { - return -1; - } - libnetctx->cred = ctx->credentials; - - r.out.error_string = NULL; - r.in.machine_account = NULL; - r.in.binding_string = NULL; - - /* Needed to override the ACLs on ldb */ - r.in.session_info = system_session(libnetctx, ctx->lp_ctx); - - status = libnet_samsync_ldb(libnetctx, libnetctx, &r); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("libnet_samsync_ldb returned %s: %s\n", - nt_errstr(status), - r.out.error_string)); - return -1; - } - - talloc_free(libnetctx); - - return 0; -} - -int net_samsync_ldb_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net samsync\n"); - return 0; -} - -int net_samsync_ldb_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("Synchronise into the local ldb the SAM of a domain.\n"); - return 0; -} - -int net_vampire(struct net_context *ctx, int argc, const char **argv) -{ - NTSTATUS status; - struct libnet_context *libnetctx; - struct libnet_Vampire *r; - char *tmp, *targetdir = NULL; - const char *domain_name; - - switch (argc) { - case 0: /* no args -> fail */ - return net_vampire_usage(ctx, argc, argv); - case 1: /* only DOMAIN */ - tmp = talloc_strdup(ctx, argv[0]); - break; - case 2: /* domain and target dir */ - tmp = talloc_strdup(ctx, argv[0]); - targetdir = talloc_strdup(ctx, argv[1]); - break; - default: /* too many args -> fail */ - return net_vampire_usage(ctx, argc, argv); - } - - domain_name = tmp; - - libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); - if (!libnetctx) { - return -1; - } - libnetctx->cred = ctx->credentials; - r = talloc(ctx, struct libnet_Vampire); - if (!r) { - return -1; - } - /* prepare parameters for the vampire */ - r->in.netbios_name = lp_netbios_name(ctx->lp_ctx); - r->in.domain_name = domain_name; - r->in.targetdir = targetdir; - r->out.error_string = NULL; - - /* do the domain vampire */ - status = libnet_Vampire(libnetctx, r, r); - - if (!NT_STATUS_IS_OK(status)) { - d_fprintf(stderr, "Vampire of domain failed: %s\n", - r->out.error_string ? r->out.error_string : nt_errstr(status)); - talloc_free(r); - talloc_free(libnetctx); - return -1; - } - d_printf("Vampired domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx, r->out.domain_sid)); - - talloc_free(libnetctx); - return 0; -} - -int net_vampire_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net vampire <domain> [options]\n"); - return 0; -} - -int net_vampire_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("Join and synchronise a remote AD domain to the local server.\n"); - return 0; -} diff --git a/source4/utils/ntlm_auth.c b/source4/utils/ntlm_auth.c index 97a983c9cd..34f79715ff 100644 --- a/source4/utils/ntlm_auth.c +++ b/source4/utils/ntlm_auth.c @@ -24,7 +24,7 @@ #include "includes.h" #include "system/filesys.h" #include "lib/cmdline/popt_common.h" -#include "lib/ldb/include/ldb.h" +#include <ldb.h> #include "auth/credentials/credentials.h" #include "auth/gensec/gensec.h" #include "auth/auth.h" @@ -211,8 +211,8 @@ static NTSTATUS local_pw_check_specified(struct loadparm_context *lp_ctx, nt_status = ntlm_password_check(mem_ctx, - lp_lanman_auth(lp_ctx), - lp_ntlm_auth(lp_ctx), + lpcfg_lanman_auth(lp_ctx), + lpcfg_ntlm_auth(lp_ctx), MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT | MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT, challenge, @@ -225,10 +225,11 @@ static NTSTATUS local_pw_check_specified(struct loadparm_context *lp_ctx, if (NT_STATUS_IS_OK(nt_status)) { if (unix_name) { - asprintf(unix_name, - "%s%c%s", domain, - *lp_winbind_separator(lp_ctx), - username); + if (asprintf(unix_name, "%s%c%s", domain, + *lpcfg_winbind_separator(lp_ctx), + username) < 0) { + nt_status = NT_STATUS_NO_MEMORY; + } } } else { DEBUG(3, ("Login for user [%s]\\[%s]@[%s] failed due to [%s]\n", @@ -476,7 +477,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, /* setup the client side */ nt_status = gensec_client_start(NULL, &state->gensec_state, ev, - lp_gensec_settings(NULL, lp_ctx)); + lpcfg_gensec_settings(NULL, lp_ctx)); if (!NT_STATUS_IS_OK(nt_status)) { talloc_free(mem_ctx); exit(1); @@ -489,8 +490,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, const char *winbind_method[] = { "winbind", NULL }; struct auth_context *auth_context; - msg = messaging_client_init(state, lp_messaging_path(state, lp_ctx), - lp_iconv_convenience(lp_ctx), ev); + msg = messaging_client_init(state, lpcfg_messaging_path(state, lp_ctx), ev); if (!msg) { talloc_free(mem_ctx); exit(1); @@ -500,6 +500,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, ev, msg, lp_ctx, + NULL, &auth_context); if (!NT_STATUS_IS_OK(nt_status)) { @@ -508,7 +509,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, } if (!NT_STATUS_IS_OK(gensec_server_start(state, ev, - lp_gensec_settings(state, lp_ctx), + lpcfg_gensec_settings(state, lp_ctx), auth_context, &state->gensec_state))) { talloc_free(mem_ctx); exit(1); @@ -616,7 +617,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, for (i=0; i<session_info->security_token->num_sids; i++) { struct security_token *token = session_info->security_token; const char *sidstr = dom_sid_string(session_info, - token->sids[i]); + &token->sids[i]); grouplist = talloc_asprintf_append_buffer(grouplist, "%s,", sidstr); } @@ -646,12 +647,12 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, } if (strncmp(buf, "GF", 2) == 0) { - struct gensec_ntlmssp_state *gensec_ntlmssp_state; + struct ntlmssp_state *ntlmssp_state; uint32_t neg_flags; - gensec_ntlmssp_state = talloc_get_type(state->gensec_state->private_data, - struct gensec_ntlmssp_state); - neg_flags = gensec_ntlmssp_state->neg_flags; + ntlmssp_state = talloc_get_type(state->gensec_state->private_data, + struct ntlmssp_state); + neg_flags = ntlmssp_state->neg_flags; DEBUG(10, ("Requested negotiated feature flags\n")); mux_printf(mux_id, "GF 0x%08x\n", neg_flags); @@ -661,7 +662,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, nt_status = gensec_update(state->gensec_state, mem_ctx, in, &out); /* don't leak 'bad password'/'no such user' info to the network client */ - nt_status = auth_nt_status_squash(nt_status); + nt_status = nt_status_squash(nt_status); if (out.length) { out_base64 = base64_encode_data_blob(mem_ctx, out); @@ -701,13 +702,13 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, if (!NT_STATUS_IS_OK(nt_status)) { reply_code = "BH Failed to retrive session info"; reply_arg = nt_errstr(nt_status); - DEBUG(1, ("GENSEC failed to retreive the session info: %s\n", nt_errstr(nt_status))); + DEBUG(1, ("GENSEC failed to retrieve the session info: %s\n", nt_errstr(nt_status))); } else { reply_code = "AF"; reply_arg = talloc_asprintf(state->gensec_state, - "%s%s%s", session_info->server_info->domain_name, - lp_winbind_separator(lp_ctx), session_info->server_info->account_name); + "%s%s%s", session_info->info->domain_name, + lpcfg_winbind_separator(lp_ctx), session_info->info->account_name); talloc_free(session_info); } } else if (state->gensec_state->gensec_role == GENSEC_CLIENT) { @@ -759,7 +760,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod } else if (plaintext_password) { /* handle this request as plaintext */ if (!full_username) { - if (asprintf(&full_username, "%s%c%s", domain, *lp_winbind_separator(lp_ctx), username) == -1) { + if (asprintf(&full_username, "%s%c%s", domain, *lpcfg_winbind_separator(lp_ctx), username) < 0) { mux_printf(mux_id, "Error: Out of memory in asprintf!\n.\n"); return; } @@ -784,14 +785,14 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod SAFE_FREE(domain); if (!parse_ntlm_auth_domain_user(full_username, &username, &domain, - *lp_winbind_separator(lp_ctx))) { + *lpcfg_winbind_separator(lp_ctx))) { /* username might be 'tainted', don't print into our new-line deleimianted stream */ mux_printf(mux_id, "Error: Could not parse into domain and username\n"); } } if (!domain) { - domain = smb_xstrdup(lp_workgroup(lp_ctx)); + domain = smb_xstrdup(lpcfg_workgroup(lp_ctx)); } if (ntlm_server_1_lm_session_key) @@ -804,7 +805,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod local_pw_check_specified(lp_ctx, username, domain, - lp_netbios_name(lp_ctx), + lpcfg_netbios_name(lp_ctx), &challenge, &lm_response, &nt_response, @@ -932,7 +933,7 @@ static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mod } } -static void manage_squid_request(struct loadparm_context *lp_ctx, enum stdio_helper_mode helper_mode, +static void manage_squid_request(struct loadparm_context *lp_ctx, enum stdio_helper_mode helper_mode, stdio_helper_function fn, void **private2) { char *buf; @@ -1039,7 +1040,7 @@ static void manage_squid_request(struct loadparm_context *lp_ctx, enum stdio_hel talloc_free(buf); } -static void squid_stream(struct loadparm_context *lp_ctx, +static void squid_stream(struct loadparm_context *lp_ctx, enum stdio_helper_mode stdio_mode, stdio_helper_function fn) { /* initialize FDescs */ @@ -1132,7 +1133,7 @@ int main(int argc, const char **argv) gensec_init(cmdline_lp_ctx); if (opt_domain == NULL) { - opt_domain = lp_workgroup(cmdline_lp_ctx); + opt_domain = lpcfg_workgroup(cmdline_lp_ctx); } if (helper_protocol) { @@ -1159,7 +1160,7 @@ int main(int argc, const char **argv) } if (opt_workstation == NULL) { - opt_workstation = lp_netbios_name(cmdline_lp_ctx); + opt_workstation = lpcfg_netbios_name(cmdline_lp_ctx); } if (!opt_password) { @@ -1169,7 +1170,11 @@ int main(int argc, const char **argv) { char *user; - asprintf(&user, "%s%c%s", opt_domain, *lp_winbind_separator(cmdline_lp_ctx), opt_username); + if (asprintf(&user, "%s%c%s", opt_domain, + *lpcfg_winbind_separator(cmdline_lp_ctx), + opt_username) < 0) { + return 1; + } if (!check_plaintext_auth(user, opt_password, true)) { return 1; } diff --git a/source4/utils/oLschema2ldif.c b/source4/utils/oLschema2ldif.c index 701d221046..29ed3bd38e 100644 --- a/source4/utils/oLschema2ldif.c +++ b/source4/utils/oLschema2ldif.c @@ -35,6 +35,9 @@ #include "ldb.h" #include "tools/cmdline.h" #include "dsdb/samdb/samdb.h" +#include "../lib/crypto/sha256.h" +#include "../librpc/gen_ndr/ndr_misc.h" +#include "lib/cmdline/popt_common.h" #define SCHEMA_UNKNOWN 0 #define SCHEMA_NAME 1 @@ -336,6 +339,14 @@ static struct ldb_message *process_entry(TALLOC_CTX *mem_ctx, const char *entry) char *c, *s; int n; + SHA256_CTX sha256_context; + uint8_t digest[SHA256_DIGEST_LENGTH]; + + struct GUID guid; + + bool isAttribute = false; + bool single_valued = false; + ctx = talloc_new(mem_ctx); msg = ldb_msg_new(ctx); @@ -351,6 +362,7 @@ static struct ldb_message *process_entry(TALLOC_CTX *mem_ctx, const char *entry) if (strncmp(c, "attributetype", 13) == 0) { c += 13; MSG_ADD_STRING("objectClass", "attributeSchema"); + isAttribute = true; break; } goto failed; @@ -374,7 +386,22 @@ static struct ldb_message *process_entry(TALLOC_CTX *mem_ctx, const char *entry) /* get attributeID */ n = strcspn(c, " \t"); s = talloc_strndup(msg, c, n); - MSG_ADD_STRING("attributeID", s); + if (isAttribute) { + MSG_ADD_STRING("attributeID", s); + } else { + MSG_ADD_STRING("governsID", s); + } + + SHA256_Init(&sha256_context); + SHA256_Update(&sha256_context, (uint8_t*)s, strlen(s)); + SHA256_Final(digest, &sha256_context); + + memcpy(&guid, digest, sizeof(struct GUID)); + + if (dsdb_msg_add_guid(msg, &guid, "schemaIdGuid") != 0) { + goto failed; + } + c += n; c = skip_spaces(c); @@ -416,7 +443,7 @@ static struct ldb_message *process_entry(TALLOC_CTX *mem_ctx, const char *entry) break; case SCHEMA_SINGLE_VALUE: - MSG_ADD_STRING("isSingleValued", "TRUE"); + single_valued = true; break; case SCHEMA_EQUALITY: @@ -433,12 +460,23 @@ static struct ldb_message *process_entry(TALLOC_CTX *mem_ctx, const char *entry) case SCHEMA_SYNTAX: { - const struct dsdb_syntax *map = - find_syntax_map_by_standard_oid(token->value); + char *syntax_oid; + const struct dsdb_syntax *map; + char *oMSyntax; + + n = strcspn(token->value, "{"); + syntax_oid = talloc_strndup(ctx, token->value, n); + + map = find_syntax_map_by_standard_oid(syntax_oid); if (!map) { break; } + MSG_ADD_STRING("attributeSyntax", map->attributeSyntax_oid); + + oMSyntax = talloc_asprintf(msg, "%d", map->oMSyntax); + MSG_ADD_STRING("oMSyntax", oMSyntax); + break; } case SCHEMA_DESC: @@ -450,6 +488,12 @@ static struct ldb_message *process_entry(TALLOC_CTX *mem_ctx, const char *entry) } } + if (isAttribute) { + MSG_ADD_STRING("isSingleValued", single_valued ? "TRUE" : "FALSE"); + } else { + MSG_ADD_STRING("defaultObjectCategory", ldb_dn_get_linearized(msg->dn)); + } + talloc_steal(mem_ctx, msg); talloc_free(ctx); return msg; @@ -540,55 +584,86 @@ static struct schema_conv process_file(FILE *in, FILE *out) return ret; } +static struct options { + const char *basedn; + const char *input; + const char *output; +} options; + +static struct poptOption popt_options[] = { + POPT_AUTOHELP + { "basedn", 'b', POPT_ARG_STRING, &options.basedn, 0, "base DN", "DN" }, + { "input", 'I', POPT_ARG_STRING, &options.input, 0, + "inputfile of OpenLDAP style schema otherwise STDIN", "inputfile"}, + { "output", 'O', POPT_ARG_STRING, &options.output, 0, + "outputfile otherwise STDOUT", "outputfile"}, + POPT_COMMON_VERSION + { NULL } +}; + + static void usage(void) { - printf("Usage: oLschema2ldif -H NONE <options>\n"); + poptContext pc; + printf("Usage: oLschema2ldif <options>\n"); printf("\nConvert OpenLDAP schema to AD-like LDIF format\n\n"); - printf("Options:\n"); - printf(" -I inputfile inputfile of OpenLDAP style schema otherwise STDIN\n"); - printf(" -O outputfile outputfile otherwise STDOUT\n"); - printf(" -o options pass options like modules to activate\n"); - printf(" e.g: -o modules:timestamps\n"); - printf("\n"); printf("Converts records from an openLdap formatted schema to an ldif schema\n\n"); + pc = poptGetContext("oLschema2ldif", 0, NULL, popt_options, + POPT_CONTEXT_KEEP_FIRST); + poptPrintHelp(pc, stdout, 0); exit(1); } + int main(int argc, const char **argv) { TALLOC_CTX *ctx; struct schema_conv ret; - struct ldb_cmdline *options; FILE *in = stdin; FILE *out = stdout; + poptContext pc; + int opt; + ctx = talloc_new(NULL); ldb_ctx = ldb_init(ctx, NULL); setenv("LDB_URL", "NONE", 1); - options = ldb_cmdline_process(ldb_ctx, argc, argv, usage); - if (options->basedn == NULL) { - perror("Base DN not specified"); + pc = poptGetContext(argv[0], argc, argv, popt_options, + POPT_CONTEXT_KEEP_FIRST); + + while((opt = poptGetNextOpt(pc)) != -1) { + fprintf(stderr, "Invalid option %s: %s\n", + poptBadOption(pc, 0), poptStrerror(opt)); + usage(); + } + + if (options.basedn == NULL) { + printf("Base DN not specified\n"); + usage(); exit(1); } else { - basedn = ldb_dn_new(ctx, ldb_ctx, options->basedn); + basedn = ldb_dn_new(ctx, ldb_ctx, options.basedn); if ( ! ldb_dn_validate(basedn)) { - perror("Malformed Base DN"); + printf("Malformed Base DN\n"); + usage(); exit(1); } } - if (options->input) { - in = fopen(options->input, "r"); + if (options.input) { + in = fopen(options.input, "r"); if (!in) { - perror(options->input); + perror(options.input); + usage(); exit(1); } } - if (options->output) { - out = fopen(options->output, "w"); + if (options.output) { + out = fopen(options.output, "w"); if (!out) { - perror(options->output); + perror(options.output); + usage(); exit(1); } } diff --git a/source4/utils/setntacl.c b/source4/utils/setntacl.c deleted file mode 100644 index 3a008a4c37..0000000000 --- a/source4/utils/setntacl.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Set NT ACLs on UNIX files. - - Copyright (C) Tim Potter <tpot@samba.org> 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 3 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, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" - -int main(int argc, char **argv) -{ - printf("This utility disabled until rewritten\n"); - return 1; -} diff --git a/source4/utils/setnttoken.c b/source4/utils/setnttoken.c deleted file mode 100644 index 3a008a4c37..0000000000 --- a/source4/utils/setnttoken.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Set NT ACLs on UNIX files. - - Copyright (C) Tim Potter <tpot@samba.org> 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 3 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, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" - -int main(int argc, char **argv) -{ - printf("This utility disabled until rewritten\n"); - return 1; -} diff --git a/source4/utils/testparm.c b/source4/utils/testparm.c deleted file mode 100644 index c8e07973bc..0000000000 --- a/source4/utils/testparm.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Test validity of smb.conf - Copyright (C) Karl Auer 1993, 1994-1998 - - Extensively modified by Andrew Tridgell, 1995 - Converted to popt by Jelmer Vernooij (jelmer@nl.linux.org), 2002 - Updated for Samba4 by Andrew Bartlett <abartlet@samba.org> 2006 - - 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 3 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, see <http://www.gnu.org/licenses/>. -*/ - -/* - * Testbed for loadparm.c/params.c - * - * This module simply loads a specified configuration file and - * if successful, dumps it's contents to stdout. Note that the - * operation is performed with DEBUGLEVEL at 3. - * - * Useful for a quick 'syntax check' of a configuration file. - * - */ - -#include "includes.h" -#include "system/filesys.h" -#include "lib/cmdline/popt_common.h" -#include "lib/socket/socket.h" -#include "param/param.h" -#include "param/loadparm.h" - - -/*********************************************** - Here we do a set of 'hard coded' checks for bad - configuration settings. -************************************************/ - -static int do_global_checks(struct loadparm_context *lp_ctx) -{ - int ret = 0; - - if (!directory_exist(lp_lockdir(lp_ctx))) { - fprintf(stderr, "ERROR: lock directory %s does not exist\n", - lp_lockdir(lp_ctx)); - ret = 1; - } - - if (!directory_exist(lp_piddir(lp_ctx))) { - fprintf(stderr, "ERROR: pid directory %s does not exist\n", - lp_piddir(lp_ctx)); - ret = 1; - } - - if (strlen(lp_winbind_separator(lp_ctx)) != 1) { - fprintf(stderr,"ERROR: the 'winbind separator' parameter must be a single character.\n"); - ret = 1; - } - - if (*lp_winbind_separator(lp_ctx) == '+') { - fprintf(stderr,"'winbind separator = +' might cause problems with group membership.\n"); - } - - return ret; -} - - -static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, const char *caddr, bool silent_mode, - bool show_defaults, const char *section_name, const char *parameter_name) -{ - int ret = 0; - int s; - - for (s=0;s<lp_numservices(lp_ctx);s++) { - struct loadparm_service *service = lp_servicebynum(lp_ctx, s); - if (service != NULL) - if (strlen(lp_servicename(lp_servicebynum(lp_ctx, s))) > 12) { - fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" ); - fprintf(stderr, "These may not be accessible to some older clients.\n" ); - fprintf(stderr, "(Eg. Windows9x, WindowsMe, and not listed in smbclient in Samba 3.0.)\n" ); - break; - } - } - - for (s=0;s<lp_numservices(lp_ctx);s++) { - struct loadparm_service *service = lp_servicebynum(lp_ctx, s); - if (service != NULL) { - const char **deny_list = lp_hostsdeny(service, lp_default_service(lp_ctx)); - const char **allow_list = lp_hostsallow(service, lp_default_service(lp_ctx)); - int i; - if(deny_list) { - for (i=0; deny_list[i]; i++) { - char *hasstar = strchr_m(deny_list[i], '*'); - char *hasquery = strchr_m(deny_list[i], '?'); - if(hasstar || hasquery) { - fprintf(stderr,"Invalid character %c in hosts deny list (%s) for service %s.\n", - hasstar ? *hasstar : *hasquery, deny_list[i], lp_servicename(service) ); - } - } - } - - if(allow_list) { - for (i=0; allow_list[i]; i++) { - char *hasstar = strchr_m(allow_list[i], '*'); - char *hasquery = strchr_m(allow_list[i], '?'); - if(hasstar || hasquery) { - fprintf(stderr,"Invalid character %c in hosts allow list (%s) for service %s.\n", - hasstar ? *hasstar : *hasquery, allow_list[i], lp_servicename(service) ); - } - } - } - } - } - - - if (!cname) { - if (!silent_mode) { - fprintf(stderr,"Press enter to see a dump of your service definitions\n"); - fflush(stdout); - getc(stdin); - } - if (section_name != NULL || parameter_name != NULL) { - struct loadparm_service *service = NULL; - if (!section_name) { - section_name = GLOBAL_NAME; - service = NULL; - } else if ((!strwicmp(section_name, GLOBAL_NAME)) == 0 && - (service=lp_service(lp_ctx, section_name)) == NULL) { - fprintf(stderr,"Unknown section %s\n", - section_name); - return(1); - } - if (!parameter_name) { - lp_dump_one(stdout, show_defaults, service, lp_default_service(lp_ctx)); - } else { - ret = !lp_dump_a_parameter(lp_ctx, service, parameter_name, stdout); - } - } else { - lp_dump(lp_ctx, stdout, show_defaults, lp_numservices(lp_ctx)); - } - return(ret); - } - - if(cname && caddr){ - /* this is totally ugly, a real `quick' hack */ - for (s=0;s<lp_numservices(lp_ctx);s++) { - struct loadparm_service *service = lp_servicebynum(lp_ctx, s); - if (service != NULL) { - if (allow_access(NULL, lp_hostsdeny(NULL, lp_default_service(lp_ctx)), lp_hostsallow(NULL, lp_default_service(lp_ctx)), cname, caddr) - && allow_access(NULL, lp_hostsdeny(service, lp_default_service(lp_ctx)), lp_hostsallow(service, lp_default_service(lp_ctx)), cname, caddr)) { - fprintf(stderr,"Allow connection from %s (%s) to %s\n", - cname,caddr,lp_servicename(service)); - } else { - fprintf(stderr,"Deny connection from %s (%s) to %s\n", - cname,caddr,lp_servicename(service)); - } - } - } - } - - return ret; -} - - - int main(int argc, const char *argv[]) -{ - int ret = 0; - poptContext pc; -/* - static int show_all_parameters = 0; - static char *new_local_machine = NULL; -*/ - static const char *section_name = NULL; - static char *parameter_name = NULL; - static const char *cname; - static const char *caddr; - static int silent_mode = false; - static int show_defaults = false; /* This must be an 'int', - * as we take it as we pass - * it's address as an int - * pointer */ - struct loadparm_context *lp_ctx; - - struct poptOption long_options[] = { - POPT_AUTOHELP - {"suppress-prompt", 0, POPT_ARG_NONE, &silent_mode, true, "Suppress prompt for enter"}, - {"verbose", 'v', POPT_ARG_NONE, &show_defaults, true, "Show default options too"}, -/* - We need support for smb.conf macros before this will work again - {"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"}, -*/ -/* - These are harder to do with the new code structure - {"show-all-parameters", '\0', POPT_ARG_NONE, &show_all_parameters, 1, "Show the parameters, type, possible values" }, -*/ - {"section-name", '\0', POPT_ARG_STRING, §ion_name, 0, "Limit testparm to a named section" }, - {"parameter-name", '\0', POPT_ARG_STRING, ¶meter_name, 0, "Limit testparm to a named parameter" }, - {"client-name", '\0', POPT_ARG_STRING, &cname, 0, "Client DNS name for 'hosts allow' checking (should match reverse lookup)"}, - {"client-ip", '\0', POPT_ARG_STRING, &caddr, 0, "Client IP address for 'hosts allow' checking"}, - POPT_COMMON_SAMBA - POPT_COMMON_VERSION - { NULL } - }; - - setup_logging(NULL, DEBUG_STDERR); - - pc = poptGetContext(NULL, argc, argv, long_options, - POPT_CONTEXT_KEEP_FIRST); - poptSetOtherOptionHelp(pc, "[OPTION...] [host-name] [host-ip]"); - - while(poptGetNextOpt(pc) != -1); - -/* - if (show_all_parameters) { - show_parameter_list(); - exit(0); - } -*/ - - if ( cname && ! caddr ) { - printf ( "ERROR: For 'hosts allow' check you must specify both a DNS name and an IP address.\n" ); - return(1); - } -/* - We need support for smb.conf macros before this will work again - - if (new_local_machine) { - set_local_machine_name(new_local_machine, True); - } -*/ - - lp_ctx = cmdline_lp_ctx; - - /* We need this to force the output */ - lp_set_cmdline(lp_ctx, "log level", "2"); - - fprintf(stderr, "Loaded smb config files from %s\n", lp_configfile(lp_ctx)); - - if (!lp_load(lp_ctx, lp_configfile(lp_ctx))) { - fprintf(stderr,"Error loading services.\n"); - return(1); - } - - fprintf(stderr,"Loaded services file OK.\n"); - - ret = do_global_checks(lp_ctx); - ret |= do_share_checks(lp_ctx, cname, caddr, silent_mode, show_defaults, section_name, parameter_name); - - return(ret); -} - diff --git a/source4/utils/tests/test_net.sh b/source4/utils/tests/test_samba_tool.sh index eb598bf5e1..0fb4c2afa8 100755 --- a/source4/utils/tests/test_net.sh +++ b/source4/utils/tests/test_samba_tool.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Blackbox tests for net +# Blackbox tests for samba-tool SERVER=$1 USERNAME=$2 @@ -11,7 +11,7 @@ failed=0 samba4bindir="$BUILDDIR/bin" smbclient="$samba4bindir/smbclient$EXEEXT" -net="$samba4bindir/net$EXEEXT" +samba_tool="$samba4bindir/samba-tool$EXEEXT" testit() { name="$1" @@ -29,12 +29,12 @@ testit() { return $status } -testit "domain join" $VALGRIND $net join $DOMAIN $CONFIGURATION -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1` +testit "Test login with --machine-pass without kerberos" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER/tmp --machine-pass -k no -testit "Test login with --machine-pass without kerberos" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER/tmp --machine-pass -k no || failed=`expr $failed + 1` +testit "Test login with --machine-pass and kerberos" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER/tmp --machine-pass -k yes -testit "Test login with --machine-pass and kerberos" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER/tmp --machine-pass -k yes || failed=`expr $failed + 1` - -exit $failed +testit "time" $VALGRIND $samba_tool time $SERVER $CONFIGURATION -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ +# FIXME: testit "domainlevel.show" $VALGRIND $samba_tool domainlevel show $CONFIGURATION +exit $failed diff --git a/source4/utils/wscript_build b/source4/utils/wscript_build new file mode 100644 index 0000000000..da937dd357 --- /dev/null +++ b/source4/utils/wscript_build @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +bld.SAMBA_BINARY('ntlm_auth', + source='ntlm_auth.c', + manpages='man/ntlm_auth.1', + deps='''samba-hostconfig samba-util popt POPT_SAMBA POPT_CREDENTIALS gensec LIBCLI_RESOLVE + auth4 NTLMSSP_COMMON MESSAGING events service''', + pyembed=True + ) + + +bld.SAMBA_BINARY('oLschema2ldif', + source='oLschema2ldif.c', + manpages='man/oLschema2ldif.1', + deps='ldb-cmdline samdb POPT_SAMBA' + ) + |