wmi-1.3.16 from opsview.com

This commit is contained in:
Are Casilla
2019-02-16 00:16:52 +01:00
parent 163fdd3d1b
commit 17b3af2911
2146 changed files with 678824 additions and 0 deletions
+109
View File
@@ -0,0 +1,109 @@
# utils subsystem
#################################
# Start BINARY ndrdump
[BINARY::ndrdump]
INSTALLDIR = BINDIR
OBJ_FILES = \
ndrdump.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-CONFIG \
LIBSAMBA-UTIL \
LIBPOPT \
POPT_SAMBA \
NDR_TABLE
MANPAGE = man/ndrdump.1
# FIXME: ndrdump shouldn't have to depend on RPC...
# End BINARY ndrdump
#################################
#################################
# Start BINARY ntlm_auth
[BINARY::ntlm_auth]
INSTALLDIR = BINDIR
OBJ_FILES = \
ntlm_auth.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-CONFIG \
LIBSAMBA-UTIL \
LIBPOPT \
POPT_SAMBA \
POPT_CREDENTIALS \
gensec \
LIBCLI_RESOLVE \
auth \
MESSAGING \
LIBEVENTS
MANPAGE = man/ntlm_auth.1
# End BINARY ntlm_auth
#################################
#################################
# Start BINARY getntacl
[BINARY::getntacl]
MANPAGE = man/getntacl.1
INSTALLDIR = BINDIR
OBJ_FILES = \
getntacl.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-CONFIG \
LIBSAMBA-UTIL \
NDR_XATTR \
WRAP_XATTR
# End BINARY getntacl
#################################
#################################
# Start BINARY setntacl
[BINARY::setntacl]
# disabled until rewritten
#INSTALLDIR = BINDIR
OBJ_FILES = \
setntacl.o
# End BINARY setntacl
#################################
#################################
# Start BINARY setnttoken
[BINARY::setnttoken]
INSTALLDIR = BINDIR
OBJ_FILES = \
setnttoken.o
PRIVATE_DEPENDENCIES =
# End BINARY setnttoken
#################################
#################################
# Start BINARY nmblookup
[BINARY::nmblookup]
INSTALLDIR = BINDIR
OBJ_FILES = \
nmblookup.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-CONFIG \
LIBSAMBA-UTIL \
LIBCLI_NBT \
LIBPOPT \
POPT_SAMBA \
LIBNETIF \
LIBCLI_RESOLVE
# End BINARY nmblookup
#################################
#################################
# Start BINARY testparm
[BINARY::testparm]
INSTALLDIR = BINDIR
OBJ_FILES = \
testparm.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-CONFIG \
LIBSAMBA-UTIL \
LIBPOPT \
samba-socket \
POPT_SAMBA \
LIBCLI_RESOLVE \
CHARSET
# End BINARY testparm
#################################
+110
View File
@@ -0,0 +1,110 @@
/*
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 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 "system/filesys.h"
#include "librpc/gen_ndr/ndr_xattr.h"
#include "lib/util/wrap_xattr.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(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 = 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_size(*ntacl, 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);
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;
}
+45
View File
@@ -0,0 +1,45 @@
<?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>
+83
View File
@@ -0,0 +1,83 @@
<?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="ndrdump.1">
<refmeta>
<refentrytitle>ndrdump</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>ndrdump</refname>
<refpurpose>DCE/RPC Packet Parser and Dumper</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>ndrdump</command>
<arg choice="opt">-c context</arg>
<arg choice="req">pipe</arg>
<arg choice="req">function</arg>
<arg choice="req">in|out</arg>
<arg choice="req">filename</arg>
</cmdsynopsis>
<cmdsynopsis>
<command>ndrdump</command>
<arg choice="opt">pipe</arg>
</cmdsynopsis>
<cmdsynopsis>
<command>ndrdump</command>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>DESCRIPTION</title>
<para>ndrdump tries to parse the specified <replaceable>filename</replaceable>
using Samba's parser for the specified pipe and function. The
third argument should be
either <emphasis>in</emphasis> or <emphasis>out</emphasis>, depending
on whether the data should be parsed as a request or a reply.</para>
<para>Running ndrdump without arguments will list the pipes for which
parsers are available.</para>
<para>Running ndrdump with one argument will list the functions that
Samba can parse for the specified pipe.</para>
<para>The primary function of ndrdump is debugging Samba's internal
DCE/RPC parsing functions. The file being parsed is usually
one exported by wiresharks <quote>Export selected packet bytes</quote>
function.</para>
<para>The context argument can be used to load context data from the request
packet when parsing reply packets (such as array lengths).</para>
</refsect1>
<refsect1>
<title>VERSION</title>
<para>This man page is correct for version 4.0 of the Samba suite.</para>
</refsect1>
<refsect1>
<title>SEE ALSO</title>
<para>wireshark, pidl</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>ndrdump was written by Andrew Tridgell. </para>
<para>This manpage was written by Jelmer Vernooij. </para>
</refsect1>
</refentry>
+269
View File
@@ -0,0 +1,269 @@
<?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="ntlm-auth.1">
<refmeta>
<refentrytitle>ntlm_auth</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>ntlm_auth</refname>
<refpurpose>tool to allow external access to Winbind's NTLM authentication function</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>ntlm_auth</command>
<arg choice="opt">-d debuglevel</arg>
<arg choice="opt">-l logdir</arg>
<arg choice="opt">-s &lt;smb config file&gt;</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>DESCRIPTION</title>
<para>This tool is part of the <citerefentry><refentrytitle>samba</refentrytitle>
<manvolnum>7</manvolnum></citerefentry> suite.</para>
<para><command>ntlm_auth</command> is a helper utility that authenticates
users using NT/LM authentication. It returns 0 if the users is authenticated
successfully and 1 if access was denied. ntlm_auth uses winbind to access
the user and authentication data for a domain. This utility
is only indended to be used by other programs (currently squid).
</para>
</refsect1>
<refsect1>
<title>OPERATIONAL REQUIREMENTS</title>
<para>
The <citerefentry><refentrytitle>winbindd</refentrytitle>
<manvolnum>8</manvolnum></citerefentry> daemon must be operational
for many of these commands to function.</para>
<para>Some of these commands also require access to the directory
<filename>winbindd_privileged</filename> in
<filename>$LOCKDIR</filename>. This should be done either by running
this command as root or providing group access
to the <filename>winbindd_privileged</filename> directory. For
security reasons, this directory should not be world-accessable. </para>
</refsect1>
<refsect1>
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>--helper-protocol=PROTO</term>
<listitem><para>
Operate as a stdio-based helper. Valid helper protocols are:
</para>
<variablelist>
<varlistentry>
<term>squid-2.4-basic</term>
<listitem><para>
Server-side helper for use with Squid 2.4's basic (plaintext)
authentication. </para>
</listitem>
</varlistentry>
<varlistentry>
<term>squid-2.5-basic</term>
<listitem><para>
Server-side helper for use with Squid 2.5's basic (plaintext)
authentication. </para>
</listitem>
</varlistentry>
<varlistentry>
<term>squid-2.5-ntlmssp</term>
<listitem><para>
Server-side helper for use with Squid 2.5's NTLMSSP
authentication. </para>
<para>Requires access to the directory
<filename>winbindd_privileged</filename> in
<filename>$LOCKDIR</filename>. The protocol used is
described here: <ulink
url="http://devel.squid-cache.org/ntlm/squid_helper_protocol.html">http://devel.squid-cache.org/ntlm/squid_helper_protocol.html</ulink>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>ntlmssp-client-1</term>
<listitem><para>
Cleint-side helper for use with arbitary external
programs that may wish to use Samba's NTLMSSP
authentication knowlege. </para>
<para>This helper is a client, and as such may be run by any
user. The protocol used is
effectivly the reverse of the previous protocol.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>gss-spnego</term>
<listitem><para>
Server-side helper that implements GSS-SPNEGO. This
uses a protocol that is almost the same as
<command>squid-2.5-ntlmssp</command>, but has some
subtle differences that are undocumented outside the
source at this stage.
</para>
<para>Requires access to the directory
<filename>winbindd_privileged</filename> in
<filename>$LOCKDIR</filename>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>gss-spnego-client</term>
<listitem><para>
Client-side helper that implements GSS-SPNEGO. This
also uses a protocol similar to the above helpers, but
is currently undocumented.
</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
<varlistentry>
<term>--username=USERNAME</term>
<listitem><para>
Specify username of user to authenticate
</para></listitem>
</varlistentry>
<varlistentry>
<term>--domain=DOMAIN</term>
<listitem><para>
Specify domain of user to authenticate
</para></listitem>
</varlistentry>
<varlistentry>
<term>--workstation=WORKSTATION</term>
<listitem><para>
Specify the workstation the user authenticated from
</para></listitem>
</varlistentry>
<varlistentry>
<term>--challenge=STRING</term>
<listitem><para>NTLM challenge (in HEXADECIMAL)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>--lm-response=RESPONSE</term>
<listitem><para>LM Response to the challenge (in HEXADECIMAL)</para></listitem>
</varlistentry>
<varlistentry>
<term>--nt-response=RESPONSE</term>
<listitem><para>NT or NTLMv2 Response to the challenge (in HEXADECIMAL)</para></listitem>
</varlistentry>
<varlistentry>
<term>--password=PASSWORD</term>
<listitem><para>User's plaintext password</para><para>If
not specified on the command line, this is prompted for when
required. </para></listitem>
</varlistentry>
<varlistentry>
<term>--request-lm-key</term>
<listitem><para>Retreive LM session key</para></listitem>
</varlistentry>
<varlistentry>
<term>--request-nt-key</term>
<listitem><para>Request NT key</para></listitem>
</varlistentry>
<varlistentry>
<term>--diagnostics</term>
<listitem><para>Perform Diagnostics on the authentication
chain. Uses the password from <command>--password</command>
or prompts for one.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>--require-membership-of={SID|Name}</term>
<listitem><para>Require that a user be a member of specified
group (either name or SID) for authentication to succeed.</para>
</listitem>
</varlistentry>
&popt.common.samba;
&stdarg.help;
</variablelist>
</refsect1>
<refsect1>
<title>EXAMPLE SETUP</title>
<para>To setup ntlm_auth for use by squid 2.5, with both basic and
NTLMSSP authentication, the following
should be placed in the <filename>squid.conf</filename> file.
<programlisting>
auth_param ntlm program ntlm_auth --helper-protocol=squid-2.5-ntlmssp
auth_param basic program ntlm_auth --helper-protocol=squid-2.5-basic
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
</programlisting></para>
<note><para>This example assumes that ntlm_auth has been installed into your
path, and that the group permissions on
<filename>winbindd_privileged</filename> are as described above.</para></note>
<para>To setup ntlm_auth for use by squid 2.5 with group limitation in addition to the above
example, the following should be added to the <filename>squid.conf</filename> file.
<programlisting>
auth_param ntlm program ntlm_auth --helper-protocol=squid-2.5-ntlmssp --require-membership-of='WORKGROUP\Domain Users'
auth_param basic program ntlm_auth --helper-protocol=squid-2.5-basic --require-membership-of='WORKGROUP\Domain Users'
</programlisting></para>
</refsect1>
<refsect1>
<title>TROUBLESHOOTING</title>
<para>If you're experiencing problems with authenticating Internet Explorer running
under MS Windows 9X or Millenium Edition against ntlm_auth's NTLMSSP authentication
helper (--helper-protocol=squid-2.5-ntlmssp), then please read
<ulink url="http://support.microsoft.com/support/kb/articles/Q239/8/69.ASP">
the Microsoft Knowledge Base article #239869 and follow instructions described there</ulink>.
</para>
</refsect1>
<refsect1>
<title>VERSION</title>
<para>This man page is correct for version 3.0 of the Samba
suite.</para>
</refsect1>
<refsect1>
<title>AUTHOR</title>
<para>The original Samba software and related utilities
were created by Andrew Tridgell. Samba is now developed
by the Samba Team as an Open Source project similar
to the way the Linux kernel is developed.</para>
<para>The ntlm_auth manpage was written by Jelmer Vernooij and
Andrew Bartlett.</para>
</refsect1>
</refentry>
+369
View File
@@ -0,0 +1,369 @@
/*
Unix SMB/CIFS implementation.
SMB torture tester
Copyright (C) Andrew Tridgell 2003
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 "lib/cmdline/popt_common.h"
#include "system/filesys.h"
#include "system/locale.h"
#include "librpc/rpc/dcerpc.h"
#include "librpc/rpc/dcerpc_table.h"
static const struct dcerpc_interface_call *find_function(
const struct dcerpc_interface_table *p,
const char *function)
{
int i;
if (isdigit(function[0])) {
i = strtol(function, NULL, 0);
return &p->calls[i];
}
for (i=0;i<p->num_calls;i++) {
if (strcmp(p->calls[i].name, function) == 0) {
break;
}
}
if (i == p->num_calls) {
printf("Function '%s' not found\n", function);
exit(1);
}
return &p->calls[i];
}
static void show_pipes(void)
{
const struct dcerpc_interface_list *l;
printf("\nYou must specify a pipe\n");
printf("known pipes are:\n");
for (l=librpc_dcerpc_pipes();l;l=l->next) {
if(l->table->helpstring) {
printf("\t%s - %s\n", l->table->name, l->table->helpstring);
} else {
printf("\t%s\n", l->table->name);
}
}
exit(1);
}
static void show_functions(const struct dcerpc_interface_table *p)
{
int i;
printf("\nYou must specify a function\n");
printf("known functions on '%s' are:\n", p->name);
for (i=0;i<p->num_calls;i++) {
printf("\t0x%02x (%2d) %s\n", i, i, p->calls[i].name);
}
exit(1);
}
static char *stdin_load(TALLOC_CTX *mem_ctx, size_t *size)
{
int num_read, total_len = 0;
char buf[255];
char *result = NULL;
while((num_read = read(STDIN_FILENO, buf, 255)) > 0) {
if (result) {
result = (char *) talloc_realloc(
mem_ctx, result, char *, total_len + num_read);
} else {
result = talloc_size(mem_ctx, num_read);
}
memcpy(result + total_len, buf, num_read);
total_len += num_read;
}
if (size)
*size = total_len;
return result;
}
const struct dcerpc_interface_table *load_iface_from_plugin(const char *plugin, const char *pipe_name)
{
const struct dcerpc_interface_table *p;
void *handle;
char *symbol;
handle = dlopen(plugin, RTLD_NOW);
if (handle == NULL) {
printf("%s: Unable to open: %s\n", plugin, dlerror());
return NULL;
}
symbol = talloc_asprintf(NULL, "dcerpc_table_%s", pipe_name);
p = dlsym(handle, symbol);
if (!p) {
printf("%s: Unable to find DCE/RPC interface table for '%s': %s\n", plugin, pipe_name, dlerror());
talloc_free(symbol);
return NULL;
}
talloc_free(symbol);
return p;
}
int main(int argc, const char *argv[])
{
const struct dcerpc_interface_table *p = NULL;
const struct dcerpc_interface_call *f;
const char *pipe_name, *function, *inout, *filename;
uint8_t *data;
size_t size;
DATA_BLOB blob;
struct ndr_pull *ndr_pull;
struct ndr_print *ndr_print;
TALLOC_CTX *mem_ctx;
int flags;
poptContext pc;
NTSTATUS status;
void *st;
void *v_st;
const char *ctx_filename = NULL;
const char *plugin = NULL;
BOOL validate = False;
BOOL dumpdata = False;
int opt;
struct poptOption long_options[] = {
{"context-file", 'c', POPT_ARG_STRING, &ctx_filename, 0, "In-filename to parse first", "CTX-FILE" },
{"validate", 0, POPT_ARG_NONE, &validate, 0, "try to validate the data", NULL },
{"dump-data", 0, POPT_ARG_NONE, &dumpdata, 0, "dump the hex data", NULL },
{"load-dso", 'l', POPT_ARG_STRING, &plugin, 0, "load from shared object file", NULL },
POPT_COMMON_SAMBA
POPT_AUTOHELP
{ NULL }
};
dcerpc_table_init();
pc = poptGetContext("ndrdump", argc, argv, long_options, 0);
poptSetOtherOptionHelp(
pc, "<pipe|uuid> <function> <inout> [<filename>]");
while ((opt = poptGetNextOpt(pc)) != -1) {
}
pipe_name = poptGetArg(pc);
if (!pipe_name) {
poptPrintUsage(pc, stderr, 0);
show_pipes();
exit(1);
}
if (plugin != NULL) {
p = load_iface_from_plugin(plugin, pipe_name);
}
if (!p) {
p = idl_iface_by_name(pipe_name);
}
if (!p) {
struct GUID uuid;
status = GUID_from_string(pipe_name, &uuid);
if (NT_STATUS_IS_OK(status)) {
p = idl_iface_by_uuid(&uuid);
}
}
if (!p) {
printf("Unknown pipe or UUID '%s'\n", pipe_name);
exit(1);
}
function = poptGetArg(pc);
inout = poptGetArg(pc);
filename = poptGetArg(pc);
if (!function || !inout) {
poptPrintUsage(pc, stderr, 0);
show_functions(p);
exit(1);
}
if (strcmp(inout, "in") == 0 ||
strcmp(inout, "request") == 0) {
flags = NDR_IN;
} else if (strcmp(inout, "out") == 0 ||
strcmp(inout, "response") == 0) {
flags = NDR_OUT;
} else {
printf("Bad inout value '%s'\n", inout);
exit(1);
}
f = find_function(p, function);
mem_ctx = talloc_init("ndrdump");
st = talloc_zero_size(mem_ctx, f->struct_size);
if (!st) {
printf("Unable to allocate %d bytes\n", (int)f->struct_size);
exit(1);
}
v_st = talloc_zero_size(mem_ctx, f->struct_size);
if (!v_st) {
printf("Unable to allocate %d bytes\n", (int)f->struct_size);
exit(1);
}
if (ctx_filename) {
if (flags == NDR_IN) {
printf("Context file can only be used for \"out\" packages\n");
exit(1);
}
data = (uint8_t *)file_load(ctx_filename, &size, mem_ctx);
if (!data) {
perror(ctx_filename);
exit(1);
}
blob.data = data;
blob.length = size;
ndr_pull = ndr_pull_init_blob(&blob, mem_ctx);
ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC;
status = f->ndr_pull(ndr_pull, NDR_IN, st);
if (ndr_pull->offset != ndr_pull->data_size) {
printf("WARNING! %d unread bytes while parsing context file\n", ndr_pull->data_size - ndr_pull->offset);
}
if (!NT_STATUS_IS_OK(status)) {
printf("pull for context file returned %s\n", nt_errstr(status));
exit(1);
}
memcpy(v_st, st, f->struct_size);
}
if (filename)
data = (uint8_t *)file_load(filename, &size, mem_ctx);
else
data = (uint8_t *)stdin_load(mem_ctx, &size);
if (!data) {
if (filename)
perror(filename);
else
perror("stdin");
exit(1);
}
blob.data = data;
blob.length = size;
ndr_pull = ndr_pull_init_blob(&blob, mem_ctx);
ndr_pull->flags |= LIBNDR_FLAG_REF_ALLOC;
status = f->ndr_pull(ndr_pull, flags, st);
printf("pull returned %s\n", nt_errstr(status));
if (ndr_pull->offset != ndr_pull->data_size) {
printf("WARNING! %d unread bytes\n", ndr_pull->data_size - ndr_pull->offset);
dump_data(0, ndr_pull->data+ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
}
if (dumpdata) {
printf("%d bytes consumed\n", ndr_pull->offset);
dump_data(0, blob.data, blob.length);
}
ndr_print = talloc_zero(mem_ctx, struct ndr_print);
ndr_print->print = ndr_print_debug_helper;
ndr_print->depth = 1;
f->ndr_print(ndr_print, function, flags, st);
if (!NT_STATUS_IS_OK(status)) {
printf("dump FAILED\n");
exit(1);
}
if (validate) {
DATA_BLOB v_blob;
struct ndr_push *ndr_v_push;
struct ndr_pull *ndr_v_pull;
struct ndr_print *ndr_v_print;
ndr_v_push = ndr_push_init_ctx(mem_ctx);
status = f->ndr_push(ndr_v_push, flags, st);
if (!NT_STATUS_IS_OK(status)) {
printf("validate push FAILED\n");
exit(1);
}
v_blob = ndr_push_blob(ndr_v_push);
if (dumpdata) {
printf("%ld bytes generated (validate)\n", (long)v_blob.length);
dump_data(0, v_blob.data, v_blob.length);
}
ndr_v_pull = ndr_pull_init_blob(&v_blob, mem_ctx);
ndr_v_pull->flags |= LIBNDR_FLAG_REF_ALLOC;
status = f->ndr_pull(ndr_v_pull, flags, v_st);
if (!NT_STATUS_IS_OK(status)) {
printf("validate pull FAILED\n");
exit(1);
}
printf("pull returned %s\n", nt_errstr(status));
if (ndr_v_pull->offset != ndr_v_pull->data_size) {
printf("WARNING! %d unread bytes in validation\n", ndr_v_pull->data_size - ndr_v_pull->offset);
dump_data(0, ndr_v_pull->data+ndr_v_pull->offset, ndr_v_pull->data_size - ndr_v_pull->offset);
}
ndr_v_print = talloc_zero(mem_ctx, struct ndr_print);
ndr_v_print->print = ndr_print_debug_helper;
ndr_v_print->depth = 1;
f->ndr_print(ndr_v_print, function, flags, v_st);
if (blob.length != v_blob.length) {
printf("WARNING! orig bytes:%ld validated pushed bytes:%ld\n", (long)blob.length, (long)v_blob.length);
}
if (ndr_pull->offset != ndr_v_pull->offset) {
printf("WARNING! orig pulled bytes:%d validated pulled bytes:%d\n", ndr_pull->offset, ndr_v_pull->offset);
}
}
printf("dump OK\n");
talloc_free(mem_ctx);
poptFreeContext(pc);
return 0;
}
+23
View File
@@ -0,0 +1,23 @@
# utils/net subsystem
#################################
# Start BINARY net
[BINARY::net]
INSTALLDIR = BINDIR
PRIVATE_PROTO_HEADER = net_proto.h
OBJ_FILES = \
net.o \
net_password.o \
net_time.o \
net_join.o \
net_vampire.o \
net_user.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-CONFIG \
LIBSAMBA-UTIL \
LIBSAMBA-NET \
LIBPOPT \
POPT_SAMBA \
POPT_CREDENTIALS
# End BINARY net
#################################
+211
View File
@@ -0,0 +1,211 @@
/*
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 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.
*/
/*****************************************************/
/* */
/* 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"
/*
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},
{"samsync", "synchronise into the local ldb the sam of a domain\n", net_samsync_ldb, net_samsync_ldb_usage},
{"user", "manage user accounts\n", net_user, net_user_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;
TALLOC_CTX *mem_ctx;
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();
ldb_global_init();
mem_ctx = talloc_init("net_context");
ctx = talloc(mem_ctx, struct net_context);
if (!ctx) {
d_printf("talloc_init(net_context) failed\n");
exit(1);
}
ZERO_STRUCTP(ctx);
ctx->mem_ctx = mem_ctx;
ctx->credentials = cmdline_credentials;
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(mem_ctx);
return rc;
}
int main(int argc, const char **argv)
{
return binary_net(argc, argv);
}
+39
View File
@@ -0,0 +1,39 @@
/*
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 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.
*/
#ifndef _UTIL_NET_H
#define _UTIL_NET_H
struct net_context {
TALLOC_CTX *mem_ctx;
struct cli_credentials *credentials;
};
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 */
+102
View File
@@ -0,0 +1,102 @@
/*
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 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 "utils/net/net.h"
#include "libnet/libnet.h"
#include "libcli/security/security.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->mem_ctx, argv[0]);
break;
case 2: /* DOMAIN and role */
tmp = talloc_strdup(ctx->mem_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(NULL);
if (!libnetctx) {
return -1;
}
libnetctx->cred = ctx->credentials;
r = talloc(ctx->mem_ctx, struct libnet_Join);
if (!r) {
return -1;
}
/* prepare parameters for the join */
r->in.netbios_name = lp_netbios_name();
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->mem_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;
}
+171
View File
@@ -0,0 +1,171 @@
/*
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 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 "utils/net/net.h"
#include "libnet/libnet.h"
#include "system/filesys.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->mem_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(NULL);
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->mem_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->mem_ctx, argv[0]);
break;
case 2: /* DOM\\USER and password */
tmp = talloc_strdup(ctx->mem_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->mem_ctx, p+1);
} else {
account_name = tmp;
domain_name = cli_credentials_get_domain(ctx->credentials);
}
if (!new_password) {
password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:",
domain_name, account_name);
new_password = getpass(password_prompt);
}
libnetctx = libnet_context_init(NULL);
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->mem_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;
}
+78
View File
@@ -0,0 +1,78 @@
/*
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 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 "libnet/libnet.h"
#include "utils/net/net.h"
#include "system/time.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(NULL);
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->mem_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;
}
+125
View File
@@ -0,0 +1,125 @@
/*
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 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 "utils/net/net.h"
#include "libnet/libnet.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->mem_ctx, argv[0]);
break;
default:
return net_user_usage(ctx, argc, argv);
}
/* libnet context init and its params */
lnet_ctx = libnet_context_init(NULL);
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->mem_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->mem_ctx, argv[0]);
break;
default:
return net_user_usage(ctx, argc, argv);
}
/* libnet context init and its params */
lnet_ctx = libnet_context_init(NULL);
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->mem_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;
}
+180
View File
@@ -0,0 +1,180 @@
/*
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 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 "utils/net/net.h"
#include "libnet/libnet.h"
#include "librpc/gen_ndr/samr.h"
#include "auth/auth.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(NULL);
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->mem_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(NULL);
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->mem_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(NULL);
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);
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_ldb\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;
}
+361
View File
@@ -0,0 +1,361 @@
/*
Unix SMB/CIFS implementation.
NBT client - used to lookup netbios names
Copyright (C) Andrew Tridgell 1994-2005
Copyright (C) Jelmer Vernooij 2003 (Conversion to popt)
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 "lib/cmdline/popt_common.h"
#include "lib/socket/socket.h"
#include "system/network.h"
#include "system/locale.h"
#include "lib/socket/netif.h"
#include "librpc/gen_ndr/nbt.h"
#include "libcli/nbt/libnbt.h"
/* command line options */
static struct {
const char *broadcast_address;
const char *unicast_address;
BOOL find_master;
BOOL wins_lookup;
BOOL node_status;
BOOL root_port;
BOOL lookup_by_ip;
BOOL case_sensitive;
} options;
/*
clean any binary from a node name
*/
static const char *clean_name(TALLOC_CTX *mem_ctx, const char *name)
{
char *ret = talloc_strdup(mem_ctx, name);
int i;
for (i=0;ret[i];i++) {
if (!isprint((unsigned char)ret[i])) ret[i] = '.';
}
return ret;
}
/*
turn a node status flags field into a string
*/
static char *node_status_flags(TALLOC_CTX *mem_ctx, uint16_t flags)
{
char *ret;
const char *group = " ";
const char *type = "B";
if (flags & NBT_NM_GROUP) {
group = "<GROUP>";
}
switch (flags & NBT_NM_OWNER_TYPE) {
case NBT_NODE_B:
type = "B";
break;
case NBT_NODE_P:
type = "P";
break;
case NBT_NODE_M:
type = "M";
break;
case NBT_NODE_H:
type = "H";
break;
}
ret = talloc_asprintf(mem_ctx, "%s %s", group, type);
if (flags & NBT_NM_DEREGISTER) {
ret = talloc_asprintf_append(ret, " <DEREGISTERING>");
}
if (flags & NBT_NM_CONFLICT) {
ret = talloc_asprintf_append(ret, " <CONFLICT>");
}
if (flags & NBT_NM_ACTIVE) {
ret = talloc_asprintf_append(ret, " <ACTIVE>");
}
if (flags & NBT_NM_PERMANENT) {
ret = talloc_asprintf_append(ret, " <PERMANENT>");
}
return ret;
}
/* do a single node status */
static BOOL do_node_status(struct nbt_name_socket *nbtsock,
const char *addr)
{
struct nbt_name_status io;
NTSTATUS status;
io.in.name.name = "*";
io.in.name.type = NBT_NAME_CLIENT;
io.in.name.scope = NULL;
io.in.dest_addr = addr;
io.in.timeout = 1;
io.in.retries = 2;
status = nbt_name_status(nbtsock, nbtsock, &io);
if (NT_STATUS_IS_OK(status)) {
int i;
printf("Node status reply from %s\n",
io.out.reply_from);
for (i=0;i<io.out.status.num_names;i++) {
d_printf("\t%-16s <%02x> %s\n",
clean_name(nbtsock, io.out.status.names[i].name),
io.out.status.names[i].type,
node_status_flags(nbtsock, io.out.status.names[i].nb_flags));
}
printf("\n\tMAC Address = %02X-%02X-%02X-%02X-%02X-%02X\n",
io.out.status.statistics.unit_id[0],
io.out.status.statistics.unit_id[1],
io.out.status.statistics.unit_id[2],
io.out.status.statistics.unit_id[3],
io.out.status.statistics.unit_id[4],
io.out.status.statistics.unit_id[5]);
return True;
}
return False;
}
/* do a single node query */
static NTSTATUS do_node_query(struct nbt_name_socket *nbtsock,
const char *addr,
const char *node_name,
enum nbt_name_type node_type,
BOOL broadcast)
{
struct nbt_name_query io;
NTSTATUS status;
int i;
io.in.name.name = node_name;
io.in.name.type = node_type;
io.in.name.scope = NULL;
io.in.dest_addr = addr;
io.in.broadcast = broadcast;
io.in.wins_lookup = options.wins_lookup;
io.in.timeout = 1;
io.in.retries = 2;
status = nbt_name_query(nbtsock, nbtsock, &io);
NT_STATUS_NOT_OK_RETURN(status);
for (i=0;i<io.out.num_addrs;i++) {
printf("%s %s<%02x>\n",
io.out.reply_addrs[i],
io.out.name.name,
io.out.name.type);
}
if (options.node_status && io.out.num_addrs > 0) {
do_node_status(nbtsock, io.out.reply_addrs[0]);
}
return status;
}
static BOOL process_one(const char *name)
{
TALLOC_CTX *tmp_ctx = talloc_new(NULL);
enum nbt_name_type node_type = NBT_NAME_CLIENT;
char *node_name, *p;
struct socket_address *all_zero_addr;
struct nbt_name_socket *nbtsock;
NTSTATUS status = NT_STATUS_OK;
BOOL ret = True;
if (!options.case_sensitive) {
name = strupper_talloc(tmp_ctx, name);
}
if (options.find_master) {
node_type = NBT_NAME_MASTER;
if (*name == '-' || *name == '_') {
name = "\01\02__MSBROWSE__\02";
node_type = NBT_NAME_MS;
}
}
p = strchr(name, '#');
if (p) {
node_name = talloc_strndup(tmp_ctx, name, PTR_DIFF(p,name));
node_type = (enum nbt_name_type)strtol(p+1, NULL, 16);
} else {
node_name = talloc_strdup(tmp_ctx, name);
}
nbtsock = nbt_name_socket_init(tmp_ctx, NULL);
if (options.root_port) {
all_zero_addr = socket_address_from_strings(tmp_ctx, nbtsock->sock->backend_name,
"0.0.0.0", NBT_NAME_SERVICE_PORT);
if (!all_zero_addr) {
talloc_free(tmp_ctx);
return False;
}
status = socket_listen(nbtsock->sock, all_zero_addr, 0, 0);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to bind to local port 137 - %s\n", nt_errstr(status));
talloc_free(tmp_ctx);
return False;
}
}
if (options.lookup_by_ip) {
ret = do_node_status(nbtsock, name);
talloc_free(tmp_ctx);
return ret;
}
if (options.broadcast_address) {
status = do_node_query(nbtsock, options.broadcast_address, node_name, node_type, True);
} else if (options.unicast_address) {
status = do_node_query(nbtsock, options.unicast_address, node_name, node_type, False);
} else {
int i, num_interfaces = iface_count();
for (i=0;i<num_interfaces;i++) {
const char *bcast = iface_n_bcast(i);
if (bcast == NULL) continue;
status = do_node_query(nbtsock, bcast, node_name, node_type, True);
if (NT_STATUS_IS_OK(status)) break;
}
}
if (!NT_STATUS_IS_OK(status)) {
printf("Lookup failed - %s\n", nt_errstr(status));
ret = False;
}
talloc_free(tmp_ctx);
return ret;
}
/*
main program
*/
int main(int argc, const char *argv[])
{
BOOL ret = True;
poptContext pc;
int opt;
enum {
OPT_BROADCAST_ADDRESS = 1000,
OPT_UNICAST_ADDRESS,
OPT_FIND_MASTER,
OPT_WINS_LOOKUP,
OPT_NODE_STATUS,
OPT_ROOT_PORT,
OPT_LOOKUP_BY_IP,
OPT_CASE_SENSITIVE
};
struct poptOption long_options[] = {
POPT_AUTOHELP
{ "broadcast", 'B', POPT_ARG_STRING, NULL, OPT_BROADCAST_ADDRESS,
"Specify address to use for broadcasts", "BROADCAST-ADDRESS" },
{ "unicast", 'U', POPT_ARG_STRING, NULL, OPT_UNICAST_ADDRESS,
"Specify address to use for unicast", NULL },
{ "master-browser", 'M', POPT_ARG_NONE, NULL, OPT_FIND_MASTER,
"Search for a master browser", NULL },
{ "wins", 'W', POPT_ARG_NONE, NULL, OPT_WINS_LOOKUP,
"Do a WINS lookup", NULL },
{ "status", 'S', POPT_ARG_NONE, NULL, OPT_NODE_STATUS,
"Lookup node status as well", NULL },
{ "root-port", 'r', POPT_ARG_NONE, NULL, OPT_ROOT_PORT,
"Use root port 137 (Win95 only replies to this)", NULL },
{ "lookup-by-ip", 'A', POPT_ARG_NONE, NULL, OPT_LOOKUP_BY_IP,
"Do a node status on <name> as an IP Address", NULL },
{ "case-sensitive", 0, POPT_ARG_NONE, NULL, OPT_CASE_SENSITIVE,
"Don't uppercase the name before sending", NULL },
POPT_COMMON_SAMBA
{ 0, 0, 0, 0 }
};
pc = poptGetContext("nmblookup", argc, argv, long_options,
POPT_CONTEXT_KEEP_FIRST);
poptSetOtherOptionHelp(pc, "<NODE> ...");
while ((opt = poptGetNextOpt(pc)) != -1) {
switch(opt) {
case OPT_BROADCAST_ADDRESS:
options.broadcast_address = poptGetOptArg(pc);
break;
case OPT_UNICAST_ADDRESS:
options.unicast_address = poptGetOptArg(pc);
break;
case OPT_FIND_MASTER:
options.find_master = True;
break;
case OPT_WINS_LOOKUP:
options.wins_lookup = True;
break;
case OPT_NODE_STATUS:
options.node_status = True;
break;
case OPT_ROOT_PORT:
options.root_port = True;
break;
case OPT_LOOKUP_BY_IP:
options.lookup_by_ip = True;
break;
case OPT_CASE_SENSITIVE:
options.case_sensitive = True;
break;
}
}
/* swallow argv[0] */
poptGetArg(pc);
if(!poptPeekArg(pc)) {
poptPrintUsage(pc, stderr, 0);
exit(1);
}
while (poptPeekArg(pc)) {
const char *name = poptGetArg(pc);
ret &= process_one(name);
}
poptFreeContext(pc);
if (!ret) {
return 1;
}
return 0;
}
File diff suppressed because it is too large Load Diff
+29
View File
@@ -0,0 +1,29 @@
/*
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 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"
int main(int argc, char **argv)
{
printf("This utility disabled until rewritten\n");
return 1;
}
+29
View File
@@ -0,0 +1,29 @@
/*
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 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"
int main(int argc, char **argv)
{
printf("This utility disabled until rewritten\n");
return 1;
}
+242
View File
@@ -0,0 +1,242 @@
/*
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 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.
*/
/*
* 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"
/***********************************************
Here we do a set of 'hard coded' checks for bad
configuration settings.
************************************************/
static int do_global_checks(void)
{
int ret = 0;
if (!directory_exist(lp_lockdir())) {
fprintf(stderr, "ERROR: lock directory %s does not exist\n",
lp_lockdir());
ret = 1;
}
if (!directory_exist(lp_piddir())) {
fprintf(stderr, "ERROR: pid directory %s does not exist\n",
lp_piddir());
ret = 1;
}
if (strlen(lp_winbind_separator()) != 1) {
fprintf(stderr,"ERROR: the 'winbind separator' parameter must be a single character.\n");
ret = 1;
}
if (*lp_winbind_separator() == '+') {
fprintf(stderr,"'winbind separator = +' might cause problems with group membership.\n");
}
return ret;
}
int main(int argc, const char *argv[])
{
int s;
static BOOL silent_mode = False;
int ret = 0;
poptContext pc;
/*
static BOOL show_all_parameters = False;
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 show_defaults;
struct poptOption long_options[] = {
POPT_AUTOHELP
{"suppress-prompt", '\0', POPT_ARG_VAL, &silent_mode, 1, "Suppress prompt for enter"},
{"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "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_VAL, &show_all_parameters, True, "Show the parameters, type, possible values" },
*/
{"section-name", '\0', POPT_ARG_STRING, &section_name, 0, "Limit testparm to a named section" },
{"parameter-name", '\0', POPT_ARG_STRING, &parameter_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);
}
*/
/* We need this to force the output */
lp_set_cmdline("log level", "2");
fprintf(stderr,"Load smb config files from %s\n",lp_configfile());
if (!lp_load()) {
fprintf(stderr,"Error loading services.\n");
return(1);
}
fprintf(stderr,"Loaded services file OK.\n");
ret = do_global_checks();
for (s=0;s<lp_numservices();s++) {
if (lp_snum_ok(s))
if (strlen(lp_servicename(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();s++) {
if (lp_snum_ok(s)) {
const char **deny_list = lp_hostsdeny(s);
const char **allow_list = lp_hostsallow(s);
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(s) );
}
}
}
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(s) );
}
}
}
}
}
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 || parameter_name) {
BOOL isGlobal = False;
if (!section_name) {
section_name = GLOBAL_NAME;
isGlobal = True;
} else if ((isGlobal=!strwicmp(section_name, GLOBAL_NAME)) == 0 &&
(s=lp_servicenumber(section_name)) == -1) {
fprintf(stderr,"Unknown section %s\n",
section_name);
return(1);
}
if (!parameter_name) {
if (isGlobal == True) {
lp_dump(stdout, show_defaults, 0);
} else {
lp_dump_one(stdout, show_defaults, s);
}
} else {
ret = !lp_dump_a_parameter(s, parameter_name, stdout, isGlobal);
}
} else {
lp_dump(stdout, show_defaults, lp_numservices());
}
return(ret);
}
if(cname && caddr){
/* this is totally ugly, a real `quick' hack */
for (s=0;s<lp_numservices();s++) {
if (lp_snum_ok(s)) {
if (allow_access(NULL, lp_hostsdeny(-1), lp_hostsallow(-1), cname, caddr)
&& allow_access(NULL, lp_hostsdeny(s), lp_hostsallow(s), cname, caddr)) {
fprintf(stderr,"Allow connection from %s (%s) to %s\n",
cname,caddr,lp_servicename(s));
} else {
fprintf(stderr,"Deny connection from %s (%s) to %s\n",
cname,caddr,lp_servicename(s));
}
}
}
}
return(ret);
}