--- /dev/null
+<?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="vfs_preopen.8">
+
+<refmeta>
+ <refentrytitle>vfs_preopen</refentrytitle>
+ <manvolnum>8</manvolnum>
+ <refmiscinfo class="source">Samba</refmiscinfo>
+ <refmiscinfo class="manual">System Administration tools</refmiscinfo>
+ <refmiscinfo class="version">3.3</refmiscinfo>
+</refmeta>
+
+<refnamediv>
+ <refname>vfs_preopen</refname>
+ <refpurpose>Hide read latencies for applications reading numbered files</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+ <cmdsynopsis>
+ <command>vfs objects = preopen</command>
+ </cmdsynopsis>
+</refsynopsisdiv>
+
+<refsect1>
+ <title>DESCRIPTION</title>
+
+ <para>This VFS module is part of the
+ <citerefentry><refentrytitle>samba</refentrytitle>
+ <manvolnum>7</manvolnum></citerefentry> suite.</para>
+
+ <para>This module assists applications that want to read numbered
+ files in sequence with very strict latency requirements. One area
+ where this happens in video streaming applications that want to read
+ one file per frame.</para>
+
+ <para>When you use this module, a number of helper processes is
+ started that speculatively open files and read a number of bytes to
+ prime the file system cache, so that later on when the real
+ application's request comes along, no disk access is necessary.</para>
+
+ <para>This module is stackable.</para>
+
+</refsect1>
+
+
+<refsect1>
+ <title>OPTIONS</title>
+
+ <variablelist>
+
+ <varlistentry>
+ <term>preopen:names = /pattern/</term>
+ <listitem>
+ <para>
+ preopen:names specifies the file name pattern which should
+ trigger the preopen helpers to do their work. We assume that
+ the files are numbered incrementally. So if your file names
+ are numbered FRAME00000.frm FRAME00001.frm and so on you would
+ list them as <command>preopen:names=/FRAME*.frm/</command>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>preopen:num_bytes = BYTES</term>
+ <listitem>
+ <para>
+ Specifies the number of bytes the helpers should speculatively
+ read, defaults to 1.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>preopen:helpers = NUM-PROCS</term>
+ <listitem>
+ <para>
+ Number of forked helper processes, defaults to 1.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>preopen:queuelen = NUM-FILES</term>
+ <listitem>
+ <para>
+ Number of files that should be speculatively opened. Defaults
+ to the 10 subsequent files.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+</refsect1>
+
+<refsect1>
+ <title>VERSION</title>
+ <para>This man page is correct for version 3.3 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 PREOPEN VFS module was created with contributions from
+ Volker Lendecke and the developers at IBM.
+ </para>
+</refsect1>
+
+</refentry>
state->iov[0].iov_len -= written;
break;
}
- written = state->iov[0].iov_len;
+ written -= state->iov[0].iov_len;
state->iov += 1;
state->count -= 1;
}
#endif])
AC_CHECK_HEADERS(netinet/tcp.h netinet/in_ip.h)
AC_CHECK_HEADERS(sys/sockio.h sys/un.h)
+AC_CHECK_HEADERS(sys/uio.h)
dnl we need to check that net/if.h really can be used, to cope with hpux
dnl where including it always fails
#include <sys/ioctl.h>
#endif
+#ifdef HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif
+
#ifdef HAVE_STROPTS_H
#include <stropts.h>
#endif
#define TC_HDR_SIZE ((sizeof(struct talloc_chunk)+15)&~15)
#define TC_PTR_FROM_CHUNK(tc) ((void *)(TC_HDR_SIZE + (char*)tc))
+static void (*talloc_abort_fn)(const char *reason);
+
+void talloc_set_abort_fn(void (*abort_fn)(const char *reason))
+{
+ talloc_abort_fn = abort_fn;
+}
+
+static void talloc_abort(const char *reason)
+{
+ if (!talloc_abort_fn) {
+ TALLOC_ABORT(reason);
+ }
+
+ talloc_abort_fn(reason);
+}
+
static void talloc_abort_double_free(void)
{
- TALLOC_ABORT("Bad talloc magic value - double free");
+ talloc_abort("Bad talloc magic value - double free");
}
static void talloc_abort_unknown_value(void)
{
- TALLOC_ABORT("Bad talloc magic value - unknown value");
+ talloc_abort("Bad talloc magic value - unknown value");
}
/* panic if we get a bad magic value */
pool_object_count = talloc_pool_objectcount(pool);
if (*pool_object_count == 0) {
- TALLOC_ABORT("Pool object count zero!");
+ talloc_abort("Pool object count zero!");
}
*pool_object_count -= 1;
const char *name,
const char *expected)
{
- TALLOC_ABORT("Type missmatch");
+ const char *reason;
+
+ reason = talloc_asprintf(NULL,
+ "%s: Type mismatch: name[%s] expected[%s]",
+ location,
+ name?name:"NULL",
+ expected);
+ if (!reason) {
+ reason = "Type mismatch";
+ }
+
+ talloc_abort(reason);
}
void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location)
char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+void talloc_set_abort_fn(void (*abort_fn)(const char *reason));
+
#endif
#include "includes.h"
#include "system/filesys.h"
#include "system/network.h"
-#include "tdr/tdr.h"
+#include "lib/tdr/tdr.h"
#define TDR_BASE_MARSHALL_SIZE 1024
#include "includes.h"
#include "torture/torture.h"
#include "lib/tdr/tdr.h"
-#include "param/param.h"
static bool test_push_uint8(struct torture_context *tctx)
{
uint8_t v = 4;
- struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
+ struct tdr_push *tdr = tdr_push_init(tctx, global_iconv_convenience);
torture_assert_ntstatus_ok(tctx, tdr_push_uint8(tdr, &v), "push failed");
torture_assert_int_equal(tctx, tdr->data.length, 1, "length incorrect");
{
uint8_t d = 2;
uint8_t l;
- struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
+ struct tdr_pull *tdr = tdr_pull_init(tctx, global_iconv_convenience);
tdr->data.data = &d;
tdr->data.length = 1;
tdr->offset = 0;
static bool test_push_uint16(struct torture_context *tctx)
{
uint16_t v = 0xF32;
- struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
+ struct tdr_push *tdr = tdr_push_init(tctx, global_iconv_convenience);
torture_assert_ntstatus_ok(tctx, tdr_push_uint16(tdr, &v), "push failed");
torture_assert_int_equal(tctx, tdr->data.length, 2, "length incorrect");
{
uint8_t d[2] = { 782 & 0xFF, (782 & 0xFF00) / 0x100 };
uint16_t l;
- struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
+ struct tdr_pull *tdr = tdr_pull_init(tctx, global_iconv_convenience);
tdr->data.data = d;
tdr->data.length = 2;
tdr->offset = 0;
static bool test_push_uint32(struct torture_context *tctx)
{
uint32_t v = 0x100F32;
- struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
+ struct tdr_push *tdr = tdr_push_init(tctx, global_iconv_convenience);
torture_assert_ntstatus_ok(tctx, tdr_push_uint32(tdr, &v), "push failed");
torture_assert_int_equal(tctx, tdr->data.length, 4, "length incorrect");
{
uint8_t d[4] = { 782 & 0xFF, (782 & 0xFF00) / 0x100, 0, 0 };
uint32_t l;
- struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
+ struct tdr_pull *tdr = tdr_pull_init(tctx, global_iconv_convenience);
tdr->data.data = d;
tdr->data.length = 4;
tdr->offset = 0;
static bool test_pull_charset(struct torture_context *tctx)
{
- struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
+ struct tdr_pull *tdr = tdr_pull_init(tctx, global_iconv_convenience);
const char *l = NULL;
tdr->data.data = (uint8_t *)talloc_strdup(tctx, "bla");
tdr->data.length = 4;
static bool test_pull_charset_empty(struct torture_context *tctx)
{
- struct tdr_pull *tdr = tdr_pull_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
+ struct tdr_pull *tdr = tdr_pull_init(tctx, global_iconv_convenience);
const char *l = NULL;
tdr->data.data = (uint8_t *)talloc_strdup(tctx, "bla");
tdr->data.length = 4;
static bool test_push_charset(struct torture_context *tctx)
{
const char *l = "bloe";
- struct tdr_push *tdr = tdr_push_init(tctx, lp_iconv_convenience(tctx->lp_ctx));
+ struct tdr_push *tdr = tdr_push_init(tctx, global_iconv_convenience);
torture_assert_ntstatus_ok(tctx, tdr_push_charset(tdr, &l, 4, 1, CH_UTF8),
"push failed");
torture_assert_int_equal(tctx, 4, tdr->data.length, "offset invalid");
AC_PREREQ(2.50)
-AC_INIT(tevent, 0.9.3)
+AC_INIT(tevent, 0.9.4)
AC_CONFIG_SRCDIR([tevent.c])
AC_CONFIG_HEADER(config.h)
*/
#include "replace.h"
#include "system/filesys.h"
+#define TEVENT_DEPRECATED 1
#include "tevent.h"
#include "tevent_internal.h"
#include "tevent_util.h"
fde->event_ctx->ops->set_fd_flags(fde, flags);
}
+bool tevent_signal_support(struct tevent_context *ev)
+{
+ if (ev->ops->add_signal) {
+ return true;
+ }
+ return false;
+}
+
+static void (*tevent_abort_fn)(const char *reason);
+
+void tevent_set_abort_fn(void (*abort_fn)(const char *reason))
+{
+ tevent_abort_fn = abort_fn;
+}
+
+static void tevent_abort(struct tevent_context *ev, const char *reason)
+{
+ tevent_debug(ev, TEVENT_DEBUG_FATAL,
+ "abort: %s\n", reason);
+
+ if (!tevent_abort_fn) {
+ abort();
+ }
+
+ tevent_abort_fn(reason);
+}
+
/*
add a timer event
return NULL on failure
handler_name, location);
}
+void tevent_loop_allow_nesting(struct tevent_context *ev)
+{
+ ev->nesting.allowed = true;
+}
+
+void tevent_loop_set_nesting_hook(struct tevent_context *ev,
+ tevent_nesting_hook hook,
+ void *private_data)
+{
+ ev->nesting.hook_fn = hook;
+ ev->nesting.hook_private = private_data;
+}
+
+static void tevent_abort_nesting(struct tevent_context *ev, const char *location)
+{
+ const char *reason;
+
+ reason = talloc_asprintf(NULL, "tevent_loop_once() nesting at %s",
+ location);
+ if (!reason) {
+ reason = "tevent_loop_once() nesting";
+ }
+
+ tevent_abort(ev, reason);
+}
+
/*
do a single event loop using the events defined in ev
*/
-int tevent_loop_once(struct tevent_context *ev)
+int _tevent_loop_once(struct tevent_context *ev, const char *location)
{
- return ev->ops->loop_once(ev);
+ int ret;
+ void *nesting_stack_ptr = NULL;
+
+ ev->nesting.level++;
+
+ if (ev->nesting.level > 1) {
+ if (!ev->nesting.allowed) {
+ tevent_abort_nesting(ev, location);
+ errno = ELOOP;
+ return -1;
+ }
+ if (ev->nesting.hook_fn) {
+ int ret2;
+ ret2 = ev->nesting.hook_fn(ev,
+ ev->nesting.hook_private,
+ ev->nesting.level,
+ true,
+ (void *)&nesting_stack_ptr,
+ location);
+ if (ret2 != 0) {
+ ret = ret2;
+ goto done;
+ }
+ }
+ }
+
+ ret = ev->ops->loop_once(ev, location);
+
+ if (ev->nesting.level > 1) {
+ if (ev->nesting.hook_fn) {
+ int ret2;
+ ret2 = ev->nesting.hook_fn(ev,
+ ev->nesting.hook_private,
+ ev->nesting.level,
+ false,
+ (void *)&nesting_stack_ptr,
+ location);
+ if (ret2 != 0) {
+ ret = ret2;
+ goto done;
+ }
+ }
+ }
+
+done:
+ ev->nesting.level--;
+ return ret;
+}
+
+/*
+ this is a performance optimization for the samba4 nested event loop problems
+*/
+int _tevent_loop_until(struct tevent_context *ev,
+ bool (*finished)(void *private_data),
+ void *private_data,
+ const char *location)
+{
+ int ret = 0;
+ void *nesting_stack_ptr = NULL;
+
+ ev->nesting.level++;
+
+ if (ev->nesting.level > 1) {
+ if (!ev->nesting.allowed) {
+ tevent_abort_nesting(ev, location);
+ errno = ELOOP;
+ return -1;
+ }
+ if (ev->nesting.hook_fn) {
+ int ret2;
+ ret2 = ev->nesting.hook_fn(ev,
+ ev->nesting.hook_private,
+ ev->nesting.level,
+ true,
+ (void *)&nesting_stack_ptr,
+ location);
+ if (ret2 != 0) {
+ ret = ret2;
+ goto done;
+ }
+ }
+ }
+
+ while (!finished(private_data)) {
+ ret = ev->ops->loop_once(ev, location);
+ if (ret != 0) {
+ break;
+ }
+ }
+
+ if (ev->nesting.level > 1) {
+ if (ev->nesting.hook_fn) {
+ int ret2;
+ ret2 = ev->nesting.hook_fn(ev,
+ ev->nesting.hook_private,
+ ev->nesting.level,
+ false,
+ (void *)&nesting_stack_ptr,
+ location);
+ if (ret2 != 0) {
+ ret = ret2;
+ goto done;
+ }
+ }
+ }
+
+done:
+ ev->nesting.level--;
+ return ret;
}
/*
return on failure or (with 0) if all fd events are removed
*/
-int tevent_loop_wait(struct tevent_context *ev)
+int _tevent_loop_wait(struct tevent_context *ev, const char *location)
{
- return ev->ops->loop_wait(ev);
+ return ev->ops->loop_wait(ev, location);
}
_tevent_add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data, \
#handler, __location__)
-int tevent_loop_once(struct tevent_context *ev);
-int tevent_loop_wait(struct tevent_context *ev);
+int _tevent_loop_once(struct tevent_context *ev, const char *location);
+#define tevent_loop_once(ev) \
+ _tevent_loop_once(ev, __location__) \
+
+int _tevent_loop_wait(struct tevent_context *ev, const char *location);
+#define tevent_loop_wait(ev) \
+ _tevent_loop_wait(ev, __location__) \
void tevent_fd_set_close_fn(struct tevent_fd *fde,
tevent_fd_close_fn_t close_fn);
uint16_t tevent_fd_get_flags(struct tevent_fd *fde);
void tevent_fd_set_flags(struct tevent_fd *fde, uint16_t flags);
+bool tevent_signal_support(struct tevent_context *ev);
+
+void tevent_set_abort_fn(void (*abort_fn)(const char *reason));
+
/* bits for file descriptor event flags */
#define TEVENT_FD_READ 1
#define TEVENT_FD_WRITE 2
size_t tevent_queue_length(struct tevent_queue *queue);
+typedef int (*tevent_nesting_hook)(struct tevent_context *ev,
+ void *private_data,
+ uint32_t level,
+ bool begin,
+ void *stack_ptr,
+ const char *location);
+#ifdef TEVENT_DEPRECATED
+#ifndef _DEPRECATED_
+#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
+#define _DEPRECATED_ __attribute__ ((deprecated))
+#else
+#define _DEPRECATED_
+#endif
+#endif
+void tevent_loop_allow_nesting(struct tevent_context *ev) _DEPRECATED_;
+void tevent_loop_set_nesting_hook(struct tevent_context *ev,
+ tevent_nesting_hook hook,
+ void *private_data) _DEPRECATED_;
+int _tevent_loop_until(struct tevent_context *ev,
+ bool (*finished)(void *private_data),
+ void *private_data,
+ const char *location) _DEPRECATED_;
+#define tevent_loop_until(ev, finished, private_data) \
+ _tevent_loop_until(ev, finished, private_data, __location__)
+#endif
+
#ifdef TEVENT_COMPAT_DEFINES
#define event_context tevent_context
/*
do a single event loop using the events defined in ev
*/
-static int epoll_event_loop_once(struct tevent_context *ev)
+static int epoll_event_loop_once(struct tevent_context *ev, const char *location)
{
struct epoll_event_context *epoll_ev = talloc_get_type(ev->additional_data,
struct epoll_event_context);
/*
return on failure or (with 0) if all fd events are removed
*/
-static int epoll_event_loop_wait(struct tevent_context *ev)
+static int epoll_event_loop_wait(struct tevent_context *ev, const char *location)
{
struct epoll_event_context *epoll_ev = talloc_get_type(ev->additional_data,
struct epoll_event_context);
while (epoll_ev->ev->fd_events) {
- if (epoll_event_loop_once(ev) != 0) {
+ if (epoll_event_loop_once(ev, location) != 0) {
break;
}
}
const char *location);
/* loop functions */
- int (*loop_once)(struct tevent_context *ev);
- int (*loop_wait)(struct tevent_context *ev);
+ int (*loop_once)(struct tevent_context *ev, const char *location);
+ int (*loop_wait)(struct tevent_context *ev, const char *location);
};
struct tevent_fd {
/* debugging operations */
struct tevent_debug_ops debug_ops;
+
+ /* info about the nesting status */
+ struct {
+ bool allowed;
+ uint32_t level;
+ tevent_nesting_hook hook_fn;
+ void *hook_private;
+ } nesting;
};
/*
do a single event loop using the events defined in ev
*/
-static int select_event_loop_once(struct tevent_context *ev)
+static int select_event_loop_once(struct tevent_context *ev, const char *location)
{
struct select_event_context *select_ev = talloc_get_type(ev->additional_data,
struct select_event_context);
/*
return on failure or (with 0) if all fd events are removed
*/
-static int select_event_loop_wait(struct tevent_context *ev)
+static int select_event_loop_wait(struct tevent_context *ev, const char *location)
{
struct select_event_context *select_ev = talloc_get_type(ev->additional_data,
struct select_event_context);
select_ev->exit_code = 0;
while (ev->fd_events && select_ev->exit_code == 0) {
- if (select_event_loop_once(ev) != 0) {
+ if (select_event_loop_once(ev, location) != 0) {
break;
}
}
/*
do a single event loop using the events defined in ev
*/
-static int std_event_loop_once(struct tevent_context *ev)
+static int std_event_loop_once(struct tevent_context *ev, const char *location)
{
struct std_event_context *std_ev = talloc_get_type(ev->additional_data,
struct std_event_context);
/*
return on failure or (with 0) if all fd events are removed
*/
-static int std_event_loop_wait(struct tevent_context *ev)
+static int std_event_loop_wait(struct tevent_context *ev, const char *location)
{
struct std_event_context *std_ev = talloc_get_type(ev->additional_data,
struct std_event_context);
std_ev->exit_code = 0;
while (ev->fd_events && std_ev->exit_code == 0) {
- if (std_event_loop_once(ev) != 0) {
+ if (std_event_loop_once(ev, location) != 0) {
break;
}
}
EXECINFO_CFLAGS="$CFLAGS"
EXECINFO_CPPFLAGS="$CPPFLAGS"
EXECINFO_LDFLAGS="$LDFLAGS"
+ LIB_REMOVE_USR_LIB(EXECINFO_LDFLAGS)
else
SMB_ENABLE(EXECINFO,NO)
fi
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_PrinterInfo0(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo0 *r)
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrinterInfo0(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo0 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_PrinterInfo0(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo0 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrinterInfo0(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo0 *r)
{
uint32_t _ptr_printername;
TALLOC_CTX *_mem_save_printername_0;
ndr->depth--;
}
+_PUBLIC_ size_t ndr_size_spoolss_PrinterInfo0(const struct spoolss_PrinterInfo0 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterInfo0, ic);
+}
+
static enum ndr_err_code ndr_push_spoolss_DeviceModeFields(struct ndr_push *ndr, int ndr_flags, uint32_t r)
{
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_PrinterInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo1 *r)
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrinterInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo1 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_PrinterInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo1 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrinterInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo1 *r)
{
uint32_t _ptr_name;
TALLOC_CTX *_mem_save_name_0;
ndr->depth--;
}
+_PUBLIC_ size_t ndr_size_spoolss_PrinterInfo1(const struct spoolss_PrinterInfo1 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterInfo1, ic);
+}
+
static enum ndr_err_code ndr_push_spoolss_PrinterAttributes(struct ndr_push *ndr, int ndr_flags, uint32_t r)
{
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_PrinterInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo2 *r)
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrinterInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo2 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_PrinterInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo2 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrinterInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo2 *r)
{
uint32_t _ptr_servername;
TALLOC_CTX *_mem_save_servername_0;
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_PrinterInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo3 *r)
+_PUBLIC_ size_t ndr_size_spoolss_PrinterInfo2(const struct spoolss_PrinterInfo2 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterInfo2, ic);
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrinterInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo3 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_PrinterInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo3 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrinterInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo3 *r)
{
uint32_t _ptr_secdesc;
TALLOC_CTX *_mem_save_secdesc_0;
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_PrinterInfo4(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo4 *r)
+_PUBLIC_ size_t ndr_size_spoolss_PrinterInfo3(const struct spoolss_PrinterInfo3 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterInfo3, ic);
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrinterInfo4(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo4 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_PrinterInfo4(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo4 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrinterInfo4(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo4 *r)
{
uint32_t _ptr_printername;
TALLOC_CTX *_mem_save_printername_0;
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_PrinterInfo5(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo5 *r)
+_PUBLIC_ size_t ndr_size_spoolss_PrinterInfo4(const struct spoolss_PrinterInfo4 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterInfo4, ic);
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrinterInfo5(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo5 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_PrinterInfo5(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo5 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrinterInfo5(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo5 *r)
{
uint32_t _ptr_printername;
TALLOC_CTX *_mem_save_printername_0;
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_PrinterInfo6(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo6 *r)
+_PUBLIC_ size_t ndr_size_spoolss_PrinterInfo5(const struct spoolss_PrinterInfo5 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterInfo5, ic);
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrinterInfo6(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo6 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_PrinterInfo6(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo6 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrinterInfo6(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo6 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_pull_align(ndr, 4));
ndr->depth--;
}
+_PUBLIC_ size_t ndr_size_spoolss_PrinterInfo6(const struct spoolss_PrinterInfo6 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterInfo6, ic);
+}
+
static enum ndr_err_code ndr_push_spoolss_DsPrintAction(struct ndr_push *ndr, int ndr_flags, uint32_t r)
{
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_PrinterInfo7(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo7 *r)
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrinterInfo7(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo7 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_PrinterInfo7(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo7 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrinterInfo7(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo7 *r)
{
uint32_t _ptr_guid;
TALLOC_CTX *_mem_save_guid_0;
ndr->depth--;
}
+_PUBLIC_ size_t ndr_size_spoolss_PrinterInfo7(const struct spoolss_PrinterInfo7 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterInfo7, ic);
+}
+
static enum ndr_err_code ndr_push_spoolss_DeviceModeInfo(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DeviceModeInfo *r)
{
if (ndr_flags & NDR_SCALARS) {
}
}
+_PUBLIC_ size_t ndr_size_spoolss_PrinterInfo(const union spoolss_PrinterInfo *r, uint32_t level, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_union(r, flags, level, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterInfo, ic);
+}
+
static enum ndr_err_code ndr_push_spoolss_DevmodeContainer(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DevmodeContainer *r)
{
if (ndr_flags & NDR_SCALARS) {
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_JobInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo1 *r)
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_JobInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo1 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_JobInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo1 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_JobInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo1 *r)
{
uint32_t _ptr_printer_name;
TALLOC_CTX *_mem_save_printer_name_0;
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_JobInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo2 *r)
+_PUBLIC_ size_t ndr_size_spoolss_JobInfo1(const struct spoolss_JobInfo1 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_JobInfo1, ic);
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_JobInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo2 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_JobInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo2 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_JobInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo2 *r)
{
uint32_t _ptr_printer_name;
TALLOC_CTX *_mem_save_printer_name_0;
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_JobInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo3 *r)
+_PUBLIC_ size_t ndr_size_spoolss_JobInfo2(const struct spoolss_JobInfo2 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_JobInfo2, ic);
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_JobInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo3 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_JobInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo3 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_JobInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo3 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_pull_align(ndr, 4));
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_JobInfo4(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo4 *r)
+_PUBLIC_ size_t ndr_size_spoolss_JobInfo3(const struct spoolss_JobInfo3 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_JobInfo3, ic);
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_JobInfo4(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo4 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_JobInfo4(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo4 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_JobInfo4(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo4 *r)
{
uint32_t _ptr_printer_name;
TALLOC_CTX *_mem_save_printer_name_0;
ndr->depth--;
}
+_PUBLIC_ size_t ndr_size_spoolss_JobInfo4(const struct spoolss_JobInfo4 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_JobInfo4, ic);
+}
+
_PUBLIC_ enum ndr_err_code ndr_push_spoolss_JobInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_JobInfo *r)
{
uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr);
}
}
+_PUBLIC_ size_t ndr_size_spoolss_JobInfo(const union spoolss_JobInfo *r, uint32_t level, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_union(r, flags, level, (ndr_push_flags_fn_t)ndr_push_spoolss_JobInfo, ic);
+}
+
static enum ndr_err_code ndr_push_spoolss_SetJobInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_SetJobInfo1 *r)
{
if (ndr_flags & NDR_SCALARS) {
}
}
+_PUBLIC_ size_t ndr_size_spoolss_DriverInfo(const union spoolss_DriverInfo *r, uint32_t level, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_union(r, flags, level, (ndr_push_flags_fn_t)ndr_push_spoolss_DriverInfo, ic);
+}
+
_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverDirectoryInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverDirectoryInfo1 *r)
{
if (ndr_flags & NDR_SCALARS) {
void ndr_print_spoolss_MinorVersion(struct ndr_print *ndr, const char *name, enum spoolss_MinorVersion r);
void ndr_print_spoolss_PrinterStatus(struct ndr_print *ndr, const char *name, uint32_t r);
void ndr_print_spoolss_JobStatus(struct ndr_print *ndr, const char *name, uint32_t r);
+enum ndr_err_code ndr_push_spoolss_PrinterInfo0(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo0 *r);
+enum ndr_err_code ndr_pull_spoolss_PrinterInfo0(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo0 *r);
void ndr_print_spoolss_PrinterInfo0(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo0 *r);
+size_t ndr_size_spoolss_PrinterInfo0(const struct spoolss_PrinterInfo0 *r, struct smb_iconv_convenience *ic, int flags);
void ndr_print_spoolss_DeviceModeFields(struct ndr_print *ndr, const char *name, uint32_t r);
enum ndr_err_code ndr_push_spoolss_DeviceMode(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DeviceMode *r);
enum ndr_err_code ndr_pull_spoolss_DeviceMode(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DeviceMode *r);
enum ndr_err_code ndr_push_spoolss_EnumPrinterFlags(struct ndr_push *ndr, int ndr_flags, uint32_t r);
enum ndr_err_code ndr_pull_spoolss_EnumPrinterFlags(struct ndr_pull *ndr, int ndr_flags, uint32_t *r);
void ndr_print_spoolss_EnumPrinterFlags(struct ndr_print *ndr, const char *name, uint32_t r);
+enum ndr_err_code ndr_push_spoolss_PrinterInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo1 *r);
+enum ndr_err_code ndr_pull_spoolss_PrinterInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo1 *r);
void ndr_print_spoolss_PrinterInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo1 *r);
+size_t ndr_size_spoolss_PrinterInfo1(const struct spoolss_PrinterInfo1 *r, struct smb_iconv_convenience *ic, int flags);
void ndr_print_spoolss_PrinterAttributes(struct ndr_print *ndr, const char *name, uint32_t r);
+enum ndr_err_code ndr_push_spoolss_PrinterInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo2 *r);
+enum ndr_err_code ndr_pull_spoolss_PrinterInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo2 *r);
void ndr_print_spoolss_PrinterInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo2 *r);
+size_t ndr_size_spoolss_PrinterInfo2(const struct spoolss_PrinterInfo2 *r, struct smb_iconv_convenience *ic, int flags);
+enum ndr_err_code ndr_push_spoolss_PrinterInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo3 *r);
+enum ndr_err_code ndr_pull_spoolss_PrinterInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo3 *r);
void ndr_print_spoolss_PrinterInfo3(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo3 *r);
+size_t ndr_size_spoolss_PrinterInfo3(const struct spoolss_PrinterInfo3 *r, struct smb_iconv_convenience *ic, int flags);
+enum ndr_err_code ndr_push_spoolss_PrinterInfo4(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo4 *r);
+enum ndr_err_code ndr_pull_spoolss_PrinterInfo4(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo4 *r);
void ndr_print_spoolss_PrinterInfo4(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo4 *r);
+size_t ndr_size_spoolss_PrinterInfo4(const struct spoolss_PrinterInfo4 *r, struct smb_iconv_convenience *ic, int flags);
+enum ndr_err_code ndr_push_spoolss_PrinterInfo5(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo5 *r);
+enum ndr_err_code ndr_pull_spoolss_PrinterInfo5(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo5 *r);
void ndr_print_spoolss_PrinterInfo5(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo5 *r);
+size_t ndr_size_spoolss_PrinterInfo5(const struct spoolss_PrinterInfo5 *r, struct smb_iconv_convenience *ic, int flags);
+enum ndr_err_code ndr_push_spoolss_PrinterInfo6(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo6 *r);
+enum ndr_err_code ndr_pull_spoolss_PrinterInfo6(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo6 *r);
void ndr_print_spoolss_PrinterInfo6(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo6 *r);
+size_t ndr_size_spoolss_PrinterInfo6(const struct spoolss_PrinterInfo6 *r, struct smb_iconv_convenience *ic, int flags);
void ndr_print_spoolss_DsPrintAction(struct ndr_print *ndr, const char *name, uint32_t r);
+enum ndr_err_code ndr_push_spoolss_PrinterInfo7(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo7 *r);
+enum ndr_err_code ndr_pull_spoolss_PrinterInfo7(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo7 *r);
void ndr_print_spoolss_PrinterInfo7(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo7 *r);
+size_t ndr_size_spoolss_PrinterInfo7(const struct spoolss_PrinterInfo7 *r, struct smb_iconv_convenience *ic, int flags);
void ndr_print_spoolss_DeviceModeInfo(struct ndr_print *ndr, const char *name, const struct spoolss_DeviceModeInfo *r);
enum ndr_err_code ndr_push_spoolss_PrinterInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_PrinterInfo *r);
enum ndr_err_code ndr_pull_spoolss_PrinterInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_PrinterInfo *r);
void ndr_print_spoolss_PrinterInfo(struct ndr_print *ndr, const char *name, const union spoolss_PrinterInfo *r);
+size_t ndr_size_spoolss_PrinterInfo(const union spoolss_PrinterInfo *r, uint32_t level, struct smb_iconv_convenience *ic, int flags);
void ndr_print_spoolss_DevmodeContainer(struct ndr_print *ndr, const char *name, const struct spoolss_DevmodeContainer *r);
+enum ndr_err_code ndr_push_spoolss_JobInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo1 *r);
+enum ndr_err_code ndr_pull_spoolss_JobInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo1 *r);
void ndr_print_spoolss_JobInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfo1 *r);
+size_t ndr_size_spoolss_JobInfo1(const struct spoolss_JobInfo1 *r, struct smb_iconv_convenience *ic, int flags);
+enum ndr_err_code ndr_push_spoolss_JobInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo2 *r);
+enum ndr_err_code ndr_pull_spoolss_JobInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo2 *r);
void ndr_print_spoolss_JobInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfo2 *r);
+size_t ndr_size_spoolss_JobInfo2(const struct spoolss_JobInfo2 *r, struct smb_iconv_convenience *ic, int flags);
+enum ndr_err_code ndr_push_spoolss_JobInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo3 *r);
+enum ndr_err_code ndr_pull_spoolss_JobInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo3 *r);
void ndr_print_spoolss_JobInfo3(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfo3 *r);
+size_t ndr_size_spoolss_JobInfo3(const struct spoolss_JobInfo3 *r, struct smb_iconv_convenience *ic, int flags);
+enum ndr_err_code ndr_push_spoolss_JobInfo4(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo4 *r);
+enum ndr_err_code ndr_pull_spoolss_JobInfo4(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo4 *r);
void ndr_print_spoolss_JobInfo4(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfo4 *r);
+size_t ndr_size_spoolss_JobInfo4(const struct spoolss_JobInfo4 *r, struct smb_iconv_convenience *ic, int flags);
enum ndr_err_code ndr_push_spoolss_JobInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_JobInfo *r);
enum ndr_err_code ndr_pull_spoolss_JobInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_JobInfo *r);
void ndr_print_spoolss_JobInfo(struct ndr_print *ndr, const char *name, const union spoolss_JobInfo *r);
+size_t ndr_size_spoolss_JobInfo(const union spoolss_JobInfo *r, uint32_t level, struct smb_iconv_convenience *ic, int flags);
void ndr_print_spoolss_SetJobInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_SetJobInfo1 *r);
void ndr_print_spoolss_SetJobInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_SetJobInfo2 *r);
void ndr_print_spoolss_SetJobInfo4(struct ndr_print *ndr, const char *name, const struct spoolss_SetJobInfo4 *r);
enum ndr_err_code ndr_push_spoolss_DriverInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_DriverInfo *r);
enum ndr_err_code ndr_pull_spoolss_DriverInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_DriverInfo *r);
void ndr_print_spoolss_DriverInfo(struct ndr_print *ndr, const char *name, const union spoolss_DriverInfo *r);
+size_t ndr_size_spoolss_DriverInfo(const union spoolss_DriverInfo *r, uint32_t level, struct smb_iconv_convenience *ic, int flags);
enum ndr_err_code ndr_push_spoolss_DriverDirectoryInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverDirectoryInfo1 *r);
enum ndr_err_code ndr_pull_spoolss_DriverDirectoryInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverDirectoryInfo1 *r);
void ndr_print_spoolss_DriverDirectoryInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_DriverDirectoryInfo1 *r);
uint32_t ref_ic;
uint32_t reserved2;
uint32_t reserved3;
-};
+}/* [gensize,public] */;
/* bitmap spoolss_DeviceModeFields */
#define DEVMODE_ORIENTATION ( 0x00000001 )
const char * name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * description;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * comment;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
-};
+}/* [gensize,public] */;
/* bitmap spoolss_PrinterAttributes */
#define PRINTER_ATTRIBUTE_QUEUED ( 0x00000001 )
uint32_t status;
uint32_t cjobs;
uint32_t averageppm;
-};
+}/* [gensize,public] */;
struct spoolss_PrinterInfo3 {
struct security_descriptor *secdesc;/* [relative,subcontext(0)] */
-};
+}/* [gensize,public] */;
struct spoolss_PrinterInfo4 {
const char * printername;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * servername;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
uint32_t attributes;
-};
+}/* [gensize,public] */;
struct spoolss_PrinterInfo5 {
const char * printername;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
uint32_t attributes;
uint32_t device_not_selected_timeout;
uint32_t transmission_retry_timeout;
-};
+}/* [gensize,public] */;
struct spoolss_PrinterInfo6 {
uint32_t status;
-};
+}/* [gensize,public] */;
/* bitmap spoolss_DsPrintAction */
#define DSPRINT_PUBLISH ( 0x00000001 )
struct spoolss_PrinterInfo7 {
const char * guid;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
uint32_t action;
-};
+}/* [gensize,public] */;
struct spoolss_DeviceModeInfo {
struct spoolss_DeviceMode *devmode;/* [relative,subcontext(0)] */
struct spoolss_PrinterInfo7 info7;/* [case(7)] */
struct spoolss_DeviceModeInfo info8;/* [case(8)] */
struct spoolss_DeviceModeInfo info9;/* [case(9)] */
-}/* [relative_base,nodiscriminant,public] */;
+}/* [relative_base,gensize,public,nodiscriminant] */;
struct spoolss_DevmodeContainer {
uint32_t _ndr_size;/* [value(_ndr_size_spoolss_DeviceMode(devmode,ndr->iconv_convenience,ndr->flags))] */
uint32_t total_pages;
uint32_t pages_printed;
struct spoolss_Time submitted;
-};
+}/* [gensize,public] */;
struct spoolss_JobInfo2 {
uint32_t job_id;
struct spoolss_Time submitted;
uint32_t time;
uint32_t pages_printed;
-};
+}/* [gensize,public] */;
struct spoolss_JobInfo3 {
uint32_t job_id;
uint32_t next_job_id;
uint32_t reserved;
-};
+}/* [gensize,public] */;
struct spoolss_JobInfo4 {
uint32_t job_id;
uint32_t time;
uint32_t pages_printed;
uint32_t size_high;
-};
+}/* [gensize,public] */;
union spoolss_JobInfo {
struct spoolss_JobInfo1 info1;/* [case] */
struct spoolss_JobInfo2 info2;/* [case(2)] */
struct spoolss_JobInfo3 info3;/* [case(3)] */
struct spoolss_JobInfo4 info4;/* [case(4)] */
-}/* [relative_base,nodiscriminant,public] */;
+}/* [relative_base,gensize,public,nodiscriminant] */;
struct spoolss_SetJobInfo1 {
uint32_t job_id;
struct spoolss_DriverInfo6 info6;/* [case(6)] */
struct spoolss_DriverInfo8 info8;/* [case(8)] */
struct spoolss_DriverInfo101 info101;/* [case(101)] */
-}/* [relative_base,nodiscriminant,public] */;
+}/* [relative_base,gensize,public,nodiscriminant] */;
struct spoolss_DriverDirectoryInfo1 {
const char * directory_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */
JOB_STATUS_COMPLETE = 0x00001000
} spoolss_JobStatus;
- typedef struct {
+ typedef [public,gensize] struct {
[relative] nstring *printername;
[relative] nstring *servername;
uint32 cjobs;
PRINTER_ENUM_ICON7 |
PRINTER_ENUM_ICON8); /* 0x00ff0000 */
- typedef struct {
+ typedef [public,gensize] struct {
spoolss_EnumPrinterFlags flags;
[relative] nstring *name;
[relative] nstring *description;
PRINTER_ATTRIBUTE_TS = 0x00008000
} spoolss_PrinterAttributes;
- typedef struct {
+ typedef [public,gensize] struct {
[relative] nstring *servername;
[relative] nstring *printername;
[relative] nstring *sharename;
uint32 averageppm;
} spoolss_PrinterInfo2;
- typedef struct {
+ typedef [public,gensize] struct {
[relative,subcontext(0)] security_descriptor *secdesc;
} spoolss_PrinterInfo3;
- typedef struct {
+ typedef [public,gensize] struct {
[relative] nstring *printername;
[relative] nstring *servername;
spoolss_PrinterAttributes attributes;
} spoolss_PrinterInfo4;
- typedef struct {
+ typedef [public,gensize] struct {
[relative] nstring *printername;
[relative] nstring *portname;
spoolss_PrinterAttributes attributes;
uint32 transmission_retry_timeout;
} spoolss_PrinterInfo5;
- typedef struct {
+ typedef [public,gensize] struct {
spoolss_PrinterStatus status;
} spoolss_PrinterInfo6;
DSPRINT_PENDING = 0x80000000
} spoolss_DsPrintAction;
- typedef struct {
+ typedef [public,gensize] struct {
[relative] nstring *guid; /* text form of printer guid */
spoolss_DsPrintAction action;
} spoolss_PrinterInfo7;
[relative,subcontext(0)] spoolss_DeviceMode *devmode;
} spoolss_DeviceModeInfo;
- typedef [nodiscriminant,relative_base,public] union {
+ typedef [nodiscriminant,relative_base,public,gensize] union {
[case(0)] spoolss_PrinterInfo0 info0;
[case(1)] spoolss_PrinterInfo1 info1;
[case(2)] spoolss_PrinterInfo2 info2;
/******************/
/* Function: 0x02 */
- typedef struct {
+ typedef [public,gensize] struct {
uint32 job_id;
[relative] nstring *printer_name;
[relative] nstring *server_name;
spoolss_Time submitted;
} spoolss_JobInfo1;
- typedef struct {
+ typedef [public,gensize] struct {
uint32 job_id;
[relative] nstring *printer_name;
[relative] nstring *server_name;
uint32 pages_printed;
} spoolss_JobInfo2;
- typedef struct {
+ typedef [public,gensize] struct {
uint32 job_id;
uint32 next_job_id;
uint32 reserved;
} spoolss_JobInfo3;
- typedef struct {
+ typedef [public,gensize] struct {
uint32 job_id;
[relative] nstring *printer_name;
[relative] nstring *server_name;
uint32 size_high;
} spoolss_JobInfo4;
- typedef [nodiscriminant,relative_base,public] union {
+ typedef [nodiscriminant,relative_base,public,gensize] union {
[case(1)] spoolss_JobInfo1 info1;
[case(2)] spoolss_JobInfo2 info2;
[case(3)] spoolss_JobInfo3 info3;
[relative] nstring *provider;
} spoolss_DriverInfo101;
- typedef [nodiscriminant,relative_base,public] union {
+ typedef [nodiscriminant,relative_base,public,gensize] union {
[case(1)] spoolss_DriverInfo1 info1;
[case(2)] spoolss_DriverInfo2 info2;
[case(3)] spoolss_DriverInfo3 info3;
return NDR_ERR_SUCCESS;
}
-uint32_t ndr_size_spoolss_EnumJobss_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_JobInfo *info)
+uint32_t ndr_size_spoolss_EnumJobs_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_JobInfo *info)
{
NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumJobs);
}
return NDR_ERR_SUCCESS;
}
-uint32_t ndr_size_spoolss_EnumPrinterProcessors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
- uint32_t level, uint32_t count, union spoolss_PrintProcessorInfo *info)
+uint32_t ndr_size_spoolss_EnumPrintProcessors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
+ uint32_t level, uint32_t count, union spoolss_PrintProcessorInfo *info)
{
NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPrintProcessors);
}
uint32_t ndr_size_spoolss_EnumPrinters_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_PrinterInfo *info);
enum ndr_err_code ndr_push_spoolss_EnumJobs(struct ndr_push *ndr, int flags, const struct spoolss_EnumJobs *r);
enum ndr_err_code ndr_pull_spoolss_EnumJobs(struct ndr_pull *ndr, int flags, struct spoolss_EnumJobs *r);
-uint32_t ndr_size_spoolss_EnumJobss_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_JobInfo *info);
+uint32_t ndr_size_spoolss_EnumJobs_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_JobInfo *info);
enum ndr_err_code ndr_push_spoolss_EnumPrinterDrivers(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterDrivers *r);
enum ndr_err_code ndr_pull_spoolss_EnumPrinterDrivers(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDrivers *r);
uint32_t ndr_size_spoolss_EnumPrinterDrivers_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_DriverInfo *info);
uint32_t ndr_size_spoolss_EnumMonitors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_MonitorInfo *info);
enum ndr_err_code ndr_push_spoolss_EnumPrintProcessors(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcessors *r);
enum ndr_err_code ndr_pull_spoolss_EnumPrintProcessors(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcessors *r);
-uint32_t ndr_size_spoolss_EnumPrinterProcessors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
- uint32_t level, uint32_t count, union spoolss_PrintProcessorInfo *info);
+uint32_t ndr_size_spoolss_EnumPrintProcessors_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
+ uint32_t level, uint32_t count, union spoolss_PrintProcessorInfo *info);
enum ndr_err_code ndr_push_spoolss_EnumPrintProcDataTypes(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcDataTypes *r);
enum ndr_err_code ndr_pull_spoolss_EnumPrintProcDataTypes(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcDataTypes *r);
uint32_t ndr_size_spoolss_EnumPrintProcDataTypes_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
dnl $PYTHON_LDFLAGS
AC_DEFUN([AC_SAMBA_PYTHON_DEVEL],
[
- AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
+ if test -z "$PYTHON_VERSION"; then
+ AC_PATH_PROGS([PYTHON], [python2.6 python2.5 python2.4 python])
+ else
+ AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
+ fi
if test -z "$PYTHON"; then
working_python=no
AC_MSG_WARN([No python found])
$self->pidl("");
$self->pidl_hdr("/* autogenerated by pidl */");
$self->pidl_hdr("#include \"$baseheader\"");
- $self->pidl_hdr(choose_header("tdr/tdr.h", "tdr.h"));
+ $self->pidl_hdr(choose_header("lib/tdr/tdr.h", "tdr.h"));
$self->pidl_hdr("");
foreach (@$idl) { $self->ParserInterface($_) if ($_->{TYPE} eq "INTERFACE"); }
VPATH=@srcdir@
srcdir=@abs_srcdir@
builddir=@abs_builddir@
-SHELL=/bin/sh
-DESTDIR=/
-
# XXX: Perhaps this should be @SHELL@ instead -- apparently autoconf
# will search for a POSIX-compliant shell, and that might not be
# /bin/sh on some platforms. I guess it's not a big problem -- mbp
+SHELL=/bin/sh
+DESTDIR=/
# See the autoconf manual "Installation Directory Variables" for a
# discussion of the subtle use of these variables.
libsmb/clireadwrite.o libsmb/clilist.o libsmb/cliprint.o \
libsmb/clitrans.o libsmb/clisecdesc.o libsmb/clidgram.o \
libsmb/clistr.o libsmb/cliquota.o libsmb/clifsinfo.o libsmb/clidfs.o \
- libsmb/credentials.o libsmb/pwd_cache.o \
+ libsmb/credentials.o \
libsmb/clioplock.o libsmb/clirap2.o \
libsmb/smb_seal.o libsmb/async_smb.o \
$(LIBSAMBA_OBJ) \
VFS_TSMSM_OBJ = modules/vfs_tsmsm.o
VFS_FILEID_OBJ = modules/vfs_fileid.o
VFS_AIO_FORK_OBJ = modules/vfs_aio_fork.o
+VFS_PREOPEN_OBJ = modules/vfs_preopen.o
VFS_SYNCOPS_OBJ = modules/vfs_syncops.o
VFS_ACL_XATTR_OBJ = modules/vfs_acl_xattr.o
VFS_ACL_TDB_OBJ = modules/vfs_acl_tdb.o
@echo "Building plugin $@"
@$(SHLD_MODULE) $(VFS_AIO_FORK_OBJ)
+bin/preopen.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_PREOPEN_OBJ)
+ @echo "Building plugin $@"
+ @$(SHLD_MODULE) $(VFS_PREOPEN_OBJ)
+
bin/acl_xattr.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_ACL_XATTR_OBJ)
@echo "Building plugin $@"
@$(SHLD_MODULE) $(VFS_ACL_XATTR_OBJ)
rm -rf autom4te*.cache
rm -f configure include/config.h*
-IPATHS="-Im4 -I../lib/replace -I../source4"
+IPATHS="-Im4 -I../m4 -I../lib/replace -I../source4"
echo "$0: running $AUTOHEADER $IPATHS"
$AUTOHEADER $IPATHS || exit 1
SMB_OFF_T nread;
};
-static size_t push_source(uint8_t *inbuf, size_t n,
- const uint8_t **outbuf,
- void *priv)
+static size_t push_source(uint8_t *buf, size_t n, void *priv)
{
struct push_state *state = (struct push_state *)priv;
int result;
return 0;
}
- result = readfile(inbuf, n, state->f);
+ result = readfile(buf, n, state->f);
state->nread += result;
return result;
}
static int cmd_quit(void)
{
- cli_cm_shutdown();
+ cli_shutdown(cli);
exit(0);
/* NOTREACHED */
return 0;
state.f = f;
state.nread = 0;
- status = cli_push(targetcli, fnum, 0, 0, io_bufsize,
- false, push_source, &state);
+ status = cli_push(targetcli, fnum, 0, 0, io_bufsize, push_source,
+ &state);
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "cli_push returned %s\n", nt_errstr(status));
}
}
if (f == x_stdin) {
- cli_cm_shutdown();
+ cli_shutdown(cli);
exit(0);
}
static int cmd_list_connect(void)
{
- cli_cm_display();
+ cli_cm_display(cli);
return 0;
}
if (base_directory && *base_directory) {
rc = do_cd(base_directory);
if (rc) {
- cli_cm_shutdown();
+ cli_shutdown(cli);
return rc;
}
}
process_stdin();
}
- cli_cm_shutdown();
+ cli_shutdown(cli);
return rc;
}
/* Workgroups simply don't make sense over anything
else but port 139... */
- cli_cm_shutdown();
+ cli_shutdown(cli);
cli = cli_cm_open(talloc_tos(), NULL,
query_host, "IPC$", true, smb_encrypt,
max_protocol, 139, name_type);
list_servers(lp_workgroup());
- cli_cm_shutdown();
+ cli_shutdown(cli);
return(0);
}
if (base_directory && *base_directory) {
ret = do_cd(base_directory);
if (ret) {
- cli_cm_shutdown();
+ cli_shutdown(cli);
return ret;
}
}
ret=process_tar();
- cli_cm_shutdown();
+ cli_shutdown(cli);
return(ret);
}
if (!cli_session_request(cli, &calling, &called)) {
d_printf("session request failed\n");
- cli_cm_shutdown();
+ cli_shutdown(cli);
return 1;
}
send_message(get_cmdline_auth_info_username(auth_info));
- cli_cm_shutdown();
+ cli_shutdown(cli);
return 0;
}
}
}
printf("mount error(%d): %s\n", errno, strerror(errno));
- printf("Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)\n");
+ printf("Refer to the mount.cifs(8) manual page (e.g. man "
+ "mount.cifs)\n");
rc = EX_FAIL;
goto mount_exit;
}
m4_include(m4/samba_version.m4)
m4_include(m4/check_path.m4)
+m4_include(pkg.m4)
AC_LIBREPLACE_CC_CHECKS
-m4_include(../lib/talloc/libtalloc.m4)
+AC_ARG_ENABLE(external_libtalloc, [AS_HELP_STRING([--enable-external-libtalloc], [Enable external talloc [default=auto]])],
+[ enable_external_libtalloc=$enableval ], [ enable_external_libtalloc=auto ])
+
+if test "x$enable_external_libtalloc" != xno
+then
+ PKG_CHECK_MODULES(TALLOC, talloc >= 1.3.0,
+ [ enable_external_libtalloc=yes ],
+ [ if x$enable_external_libtalloc = xyes; then
+ AC_MSG_ERROR([Unable to find libtalloc])
+ else
+ enable_external_libtalloc=no
+ fi
+ ])
+fi
+
+if test "x$enable_external_libtalloc" = xno
+then
+ m4_include(../lib/talloc/libtalloc.m4)
+fi
LIBTALLOC_OBJ0=""
for obj in ${TALLOC_OBJ}; do
default_static_modules="pdb_smbpasswd pdb_tdbsam pdb_wbc_sam rpc_lsarpc rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl rpc_ntsvcs rpc_netlogon rpc_netdfs rpc_srvsvc rpc_spoolss2 rpc_eventlog auth_sam auth_unix auth_winbind auth_wbc auth_server auth_domain auth_builtin auth_netlogond vfs_default nss_info_template"
dnl These are preferably build shared, and static if dlopen() is not available
-default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb vfs_smb_traffic_analyzer"
+default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb vfs_smb_traffic_analyzer vfs_preopen"
if test "x$developer" = xyes; then
default_static_modules="$default_static_modules rpc_rpcecho"
#endif
],
[
- int main(int argc, const char ** argv)
- {
- pid_t me = (pid_t)-1;
- ptrace(PTRACE_ATTACH, me, 0, 0);
- ptrace(PTRACE_DETACH, me, 0, 0);
- return 0;
- }
+ pid_t me = (pid_t)-1;
+ ptrace(PTRACE_ATTACH, me, 0, 0);
+ ptrace(PTRACE_DETACH, me, 0, 0);
+ return 0;
],
[
AC_MSG_RESULT(yes)
SMB_MODULE(vfs_tsmsm, \$(VFS_TSMSM_OBJ), "bin/tsmsm.$SHLIBEXT", VFS)
SMB_MODULE(vfs_fileid, \$(VFS_FILEID_OBJ), "bin/fileid.$SHLIBEXT", VFS)
SMB_MODULE(vfs_aio_fork, \$(VFS_AIO_FORK_OBJ), "bin/aio_fork.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_preopen, \$(VFS_PREOPEN_OBJ), "bin/preopen.$SHLIBEXT", VFS)
SMB_MODULE(vfs_syncops, \$(VFS_SYNCOPS_OBJ), "bin/syncops.$SHLIBEXT", VFS)
SMB_MODULE(vfs_zfsacl, \$(VFS_ZFSACL_OBJ), "bin/zfsacl.$SHLIBEXT", VFS)
SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS)
};
struct cli_state {
+ /**
+ * A list of subsidiary connections for DFS.
+ */
+ struct cli_state *prev, *next;
int port;
int fd;
/* Last read or write error. */
fstring desthost;
/* The credentials used to open the cli_state connection. */
- fstring domain;
- fstring user_name;
- struct pwd_info pwd;
+ char *domain;
+ char *user_name;
+ char *password; /* Can be null to force use of zero NTLMSSP session key. */
/*
* The following strings are the
* chained async_req.
*/
struct cli_request *chain_accumulator;
+
+ /* Where (if anywhere) this is mounted under DFS. */
+ char *dfs_mountpoint;
};
typedef struct file_info {
const char *password,
const char *domain,
const char *sharename);
-const char *cli_cm_get_mntpoint(struct cli_state *c);
struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
struct cli_state *referring_cli,
const char *server,
int max_protocol,
int port,
int name_type);
-void cli_cm_shutdown(void);
-void cli_cm_display(void);
+void cli_cm_display(const struct cli_state *c);
void cli_cm_set_credentials(struct user_auth_info *auth_info);
void cli_cm_set_port(int port_number);
void cli_cm_set_dest_name_type(int type);
void cli_setup_packet_buf(struct cli_state *cli, char *buf);
void cli_setup_packet(struct cli_state *cli);
void cli_setup_bcc(struct cli_state *cli, void *p);
-void cli_init_creds(struct cli_state *cli, const char *username, const char *domain, const char *password);
+NTSTATUS cli_set_domain(struct cli_state *cli, const char *domain);
+NTSTATUS cli_set_username(struct cli_state *cli, const char *username);
+NTSTATUS cli_set_password(struct cli_state *cli, const char *password);
+NTSTATUS cli_init_creds(struct cli_state *cli, const char *username, const char *domain, const char *password);
struct cli_state *cli_initialise(void);
struct cli_state *cli_initialise_ex(int signing_state);
void cli_nt_pipes_close(struct cli_state *cli);
struct cli_state *cli,
uint16_t fnum, uint16_t mode,
off_t start_offset, size_t window_size,
- bool caller_buffers,
- size_t (*source)(uint8_t *inbuf, size_t n,
- const uint8_t **outbuf,
+ size_t (*source)(uint8_t *buf, size_t n,
void *priv),
void *priv);
NTSTATUS cli_push_recv(struct async_req *req);
NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
off_t start_offset, size_t window_size,
- bool caller_buffers,
- size_t (*source)(uint8_t *inbuf, size_t n,
- const uint8_t **outbuf,
- void *priv),
+ size_t (*source)(uint8_t *buf, size_t n, void *priv),
void *priv);
/* The following definitions come from libsmb/clisecdesc.c */
const char *old_passwd, const char *new_passwd,
char **err_str);
-/* The following definitions come from libsmb/pwd_cache.c */
-
-void pwd_set_cleartext(struct pwd_info *pwd, const char *clr);
-void pwd_get_cleartext(struct pwd_info *pwd, fstring clr);
-
/* The following definitions come from libsmb/samlogon_cache.c */
bool netsamlogon_cache_init(void);
const char *lock_type_name(enum brl_type lock_type);
const char *lock_flav_name(enum brl_flavour lock_flav);
-bool is_locked(files_struct *fsp,
- uint32 smbpid,
- uint64_t count,
- uint64_t offset,
- enum brl_type lock_type);
+void init_strict_lock_struct(files_struct *fsp,
+ uint32 smbpid,
+ br_off start,
+ br_off size,
+ enum brl_type lock_type,
+ struct lock_struct *plock);
+bool strict_lock_default(files_struct *fsp,
+ struct lock_struct *plock);
+void strict_unlock_default(files_struct *fsp,
+ struct lock_struct *plock);
NTSTATUS query_lock(files_struct *fsp,
uint32 *psmbpid,
uint64_t *pcount,
ssize_t print_job_write(int snum, uint32 jobid, const char *buf, SMB_OFF_T pos, size_t size);
int print_queue_length(int snum, print_status_struct *pstatus);
uint32 print_job_start(struct auth_serversupplied_info *server_info, int snum,
- char *jobname, NT_DEVICEMODE *nt_devmode );
+ const char *jobname, NT_DEVICEMODE *nt_devmode );
void print_job_endpage(int snum, uint32 jobid);
bool print_job_end(int snum, uint32 jobid, enum file_close_type close_type);
int print_queue_status(int snum,
uint32_t offered,
uint32_t *count,
union spoolss_MonitorInfo **info);
-WERROR rpccli_spoolss_enum_printers(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- char *name, uint32 flags, uint32 level,
- uint32 *num_printers, PRINTER_INFO_CTR *ctr);
-WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- uint32 level, const char *env,
- uint32 *num_drivers,
- PRINTER_DRIVER_CTR *ctr);
-WERROR rpccli_spoolss_enumjobs(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *hnd, uint32 level, uint32 firstjob,
- uint32 num_jobs, uint32 *returned, JOB_INFO_CTR *ctr);
+WERROR rpccli_spoolss_enumjobs(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ uint32_t firstjob,
+ uint32_t numjobs,
+ uint32_t level,
+ uint32_t offered,
+ uint32_t *count,
+ union spoolss_JobInfo **info);
+WERROR rpccli_spoolss_enumprinterdrivers(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ const char *server,
+ const char *environment,
+ uint32_t level,
+ uint32_t offered,
+ uint32_t *count,
+ union spoolss_DriverInfo **info);
+WERROR rpccli_spoolss_enumprinters(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ uint32_t flags,
+ const char *server,
+ uint32_t level,
+ uint32_t offered,
+ uint32_t *count,
+ union spoolss_PrinterInfo **info);
WERROR rpccli_spoolss_getprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *hnd, const char *valuename,
REGISTRY_VALUE *value);
const char *valuename, uint32 size);
bool spoolss_io_q_getprinterdata(const char *desc, SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *ps, int depth);
bool spoolss_io_r_getprinterdata(const char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_struct *ps, int depth);
-bool smb_io_printer_info_0(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_0 *info, int depth);
-bool smb_io_printer_info_1(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_1 *info, int depth);
-bool smb_io_printer_info_2(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_2 *info, int depth);
-bool smb_io_printer_info_3(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_3 *info, int depth);
-bool smb_io_printer_info_4(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_4 *info, int depth);
-bool smb_io_printer_info_5(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_5 *info, int depth);
-bool smb_io_printer_info_6(const char *desc, RPC_BUFFER *buffer,
- PRINTER_INFO_6 *info, int depth);
-bool smb_io_printer_info_7(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_7 *info, int depth);
-bool smb_io_printer_driver_info_1(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_1 *info, int depth) ;
-bool smb_io_printer_driver_info_2(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_2 *info, int depth) ;
-bool smb_io_printer_driver_info_3(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_3 *info, int depth);
-bool smb_io_printer_driver_info_6(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_6 *info, int depth);
-bool smb_io_job_info_1(const char *desc, RPC_BUFFER *buffer, JOB_INFO_1 *info, int depth);
-bool smb_io_job_info_2(const char *desc, RPC_BUFFER *buffer, JOB_INFO_2 *info, int depth);
-uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info);
-uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info);
-uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info);
-uint32 spoolss_size_printer_info_4(PRINTER_INFO_4 *info);
-uint32 spoolss_size_printer_info_5(PRINTER_INFO_5 *info);
-uint32 spoolss_size_printer_info_6(PRINTER_INFO_6 *info);
-uint32 spoolss_size_printer_info_3(PRINTER_INFO_3 *info);
-uint32 spoolss_size_printer_info_7(PRINTER_INFO_7 *info);
-uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info);
-uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info);
-uint32 spoolss_size_string_array(uint16 *string);
-uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info);
-uint32 spoolss_size_printer_driver_info_6(DRIVER_INFO_6 *info);
-uint32 spoolss_size_job_info_1(JOB_INFO_1 *info);
-uint32 spoolss_size_job_info_2(JOB_INFO_2 *info);
uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p);
-bool spoolss_io_q_getprinterdriver2(const char *desc, SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *ps, int depth);
-bool spoolss_io_r_getprinterdriver2(const char *desc, SPOOL_R_GETPRINTERDRIVER2 *r_u, prs_struct *ps, int depth);
-bool make_spoolss_q_enumprinters(
- SPOOL_Q_ENUMPRINTERS *q_u,
- uint32 flags,
- char *servername,
- uint32 level,
- RPC_BUFFER *buffer,
- uint32 offered
-);
-bool spoolss_io_q_enumprinters(const char *desc, SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *ps, int depth);
-bool spoolss_io_r_enumprinters(const char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth);
-bool spoolss_io_r_getprinter(const char *desc, SPOOL_R_GETPRINTER *r_u, prs_struct *ps, int depth);
-bool spoolss_io_q_getprinter(const char *desc, SPOOL_Q_GETPRINTER *q_u, prs_struct *ps, int depth);
-bool spoolss_io_r_enumjobs(const char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth);
-bool make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
- uint32 firstjob,
- uint32 numofjobs,
- uint32 level,
- RPC_BUFFER *buffer,
- uint32 offered);
-bool spoolss_io_q_enumjobs(const char *desc, SPOOL_Q_ENUMJOBS *q_u, prs_struct *ps, int depth);
-bool spoolss_io_r_enumprinterdrivers(const char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth);
-bool make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u,
- const char *name,
- const char *environment,
- uint32 level,
- RPC_BUFFER *buffer, uint32 offered);
-bool spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth);
bool make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src);
bool spoolss_io_r_enumprinterdata(const char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth);
bool spoolss_io_q_enumprinterdata(const char *desc, SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *ps, int depth);
char* value, uint32 data_type, char* data, uint32 data_size);
bool spoolss_io_q_setprinterdata(const char *desc, SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *ps, int depth);
bool spoolss_io_r_setprinterdata(const char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth);
-bool spoolss_io_r_getjob(const char *desc, SPOOL_R_GETJOB *r_u, prs_struct *ps, int depth);
-bool spoolss_io_q_getjob(const char *desc, SPOOL_Q_GETJOB *q_u, prs_struct *ps, int depth);
-void free_devmode(DEVICEMODE *devmode);
-void free_printer_info_1(PRINTER_INFO_1 *printer);
-void free_printer_info_2(PRINTER_INFO_2 *printer);
-void free_printer_info_3(PRINTER_INFO_3 *printer);
-void free_printer_info_4(PRINTER_INFO_4 *printer);
-void free_printer_info_5(PRINTER_INFO_5 *printer);
-void free_printer_info_6(PRINTER_INFO_6 *printer);
-void free_printer_info_7(PRINTER_INFO_7 *printer);
-void free_job_info_2(JOB_INFO_2 *job);
bool make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY *q_u,
POLICY_HND *hnd, const char *key,
uint32 size);
enum spoolss_Field field,
int id);
DEVICEMODE *construct_dev_mode(const char *servicename);
-WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_R_ENUMPRINTERS *r_u);
-WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GETPRINTER *r_u);
-WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_u, SPOOL_R_GETPRINTERDRIVER2 *r_u);
+struct spoolss_DeviceMode *construct_dev_mode_new(TALLOC_CTX *mem_ctx,
+ const char *servicename);
WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname, const char *uri );
bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer);
-WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJOBS *r_u);
-WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, SPOOL_R_ENUMPRINTERDRIVERS *r_u);
WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines );
WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, SPOOL_R_ENUMPRINTERDATA *r_u);
WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SPOOL_R_SETPRINTERDATA *r_u);
-WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_u);
WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPOOL_R_ENUMPRINTERKEY *r_u);
WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_u, SPOOL_R_ENUMPRINTERDATAEX *r_u);
}
SPOOL_R_GETPRINTERDATA;
-typedef struct printer_info_0
-{
- UNISTR printername;
- UNISTR servername;
- uint32 cjobs;
- uint32 total_jobs;
- uint32 total_bytes;
-
- uint16 year;
- uint16 month;
- uint16 dayofweek;
- uint16 day;
- uint16 hour;
- uint16 minute;
- uint16 second;
- uint16 milliseconds;
-
- uint32 global_counter;
- uint32 total_pages;
-
- uint16 major_version;
- uint16 build_version;
-
- uint32 unknown7;
- uint32 unknown8;
- uint32 unknown9;
- uint32 session_counter;
- uint32 unknown11;
- uint32 printer_errors;
- uint32 unknown13;
- uint32 unknown14;
- uint32 unknown15;
- uint32 unknown16;
- uint32 change_id;
- uint32 unknown18;
- uint32 status;
- uint32 unknown20;
- uint32 c_setprinter;
-
- uint16 unknown22;
- uint16 unknown23;
- uint16 unknown24;
- uint16 unknown25;
- uint16 unknown26;
- uint16 unknown27;
- uint16 unknown28;
- uint16 unknown29;
-} PRINTER_INFO_0;
-
-typedef struct printer_info_1
-{
- uint32 flags;
- UNISTR description;
- UNISTR name;
- UNISTR comment;
-}
-PRINTER_INFO_1;
-
-typedef struct printer_info_2
-{
- UNISTR servername;
- UNISTR printername;
- UNISTR sharename;
- UNISTR portname;
- UNISTR drivername;
- UNISTR comment;
- UNISTR location;
- DEVICEMODE *devmode;
- UNISTR sepfile;
- UNISTR printprocessor;
- UNISTR datatype;
- UNISTR parameters;
- SEC_DESC *secdesc;
- uint32 attributes;
- uint32 priority;
- uint32 defaultpriority;
- uint32 starttime;
- uint32 untiltime;
- uint32 status;
- uint32 cjobs;
- uint32 averageppm;
-}
-PRINTER_INFO_2;
-
-typedef struct printer_info_3
-{
- SEC_DESC *secdesc;
-}
-PRINTER_INFO_3;
-
-typedef struct printer_info_4
-{
- UNISTR printername;
- UNISTR servername;
- uint32 attributes;
-}
-PRINTER_INFO_4;
-
-typedef struct printer_info_5
-{
- UNISTR printername;
- UNISTR portname;
- uint32 attributes;
- uint32 device_not_selected_timeout;
- uint32 transmission_retry_timeout;
-}
-PRINTER_INFO_5;
-
-typedef struct printer_info_6
-{
- uint32 status;
-}
-PRINTER_INFO_6;
-
-typedef struct printer_info_7
-{
- UNISTR guid; /* text form of printer guid */
- uint32 action;
-}
-PRINTER_INFO_7;
-
-typedef struct spool_q_enumprinters
-{
- uint32 flags;
- uint32 servername_ptr;
- UNISTR2 servername;
- uint32 level;
- RPC_BUFFER *buffer;
- uint32 offered;
-}
-SPOOL_Q_ENUMPRINTERS;
-
-typedef struct printer_info_ctr_info
-{
- PRINTER_INFO_0 *printers_0;
- PRINTER_INFO_1 *printers_1;
- PRINTER_INFO_2 *printers_2;
- PRINTER_INFO_3 *printers_3;
- PRINTER_INFO_4 *printers_4;
- PRINTER_INFO_5 *printers_5;
- PRINTER_INFO_7 *printers_7;
-}
-PRINTER_INFO_CTR;
-
-typedef struct spool_r_enumprinters
-{
- RPC_BUFFER *buffer;
- uint32 needed; /* bytes needed */
- uint32 returned; /* number of printers */
- WERROR status;
-}
-SPOOL_R_ENUMPRINTERS;
-
-
-typedef struct spool_q_getprinter
-{
- POLICY_HND handle;
- uint32 level;
- RPC_BUFFER *buffer;
- uint32 offered;
-}
-SPOOL_Q_GETPRINTER;
-
-typedef struct printer_info_info
-{
- union
- {
- PRINTER_INFO_0 *info0;
- PRINTER_INFO_1 *info1;
- PRINTER_INFO_2 *info2;
- void *info;
- } printer;
-} PRINTER_INFO;
-
-typedef struct spool_r_getprinter
-{
- RPC_BUFFER *buffer;
- uint32 needed;
- WERROR status;
-} SPOOL_R_GETPRINTER;
-
-typedef struct driver_info_1
-{
- UNISTR name;
-} DRIVER_INFO_1;
-
-typedef struct driver_info_2
-{
- uint32 version;
- UNISTR name;
- UNISTR architecture;
- UNISTR driverpath;
- UNISTR datafile;
- UNISTR configfile;
-} DRIVER_INFO_2;
-
-typedef struct driver_info_3
-{
- uint32 version;
- UNISTR name;
- UNISTR architecture;
- UNISTR driverpath;
- UNISTR datafile;
- UNISTR configfile;
- UNISTR helpfile;
- uint16 *dependentfiles;
- UNISTR monitorname;
- UNISTR defaultdatatype;
-}
-DRIVER_INFO_3;
-
-typedef struct driver_info_6
-{
- uint32 version;
- UNISTR name;
- UNISTR architecture;
- UNISTR driverpath;
- UNISTR datafile;
- UNISTR configfile;
- UNISTR helpfile;
- uint16 *dependentfiles;
- UNISTR monitorname;
- UNISTR defaultdatatype;
- uint16* previousdrivernames;
- NTTIME driver_date;
- uint32 padding;
- uint32 driver_version_low;
- uint32 driver_version_high;
- UNISTR mfgname;
- UNISTR oem_url;
- UNISTR hardware_id;
- UNISTR provider;
-}
-DRIVER_INFO_6;
-
-typedef struct driver_info_info
-{
- DRIVER_INFO_1 *info1;
- DRIVER_INFO_2 *info2;
- DRIVER_INFO_3 *info3;
- DRIVER_INFO_6 *info6;
-}
-PRINTER_DRIVER_CTR;
-
-typedef struct spool_q_getprinterdriver2
-{
- POLICY_HND handle;
- uint32 architecture_ptr;
- UNISTR2 architecture;
- uint32 level;
- RPC_BUFFER *buffer;
- uint32 offered;
- uint32 clientmajorversion;
- uint32 clientminorversion;
-}
-SPOOL_Q_GETPRINTERDRIVER2;
-
-typedef struct spool_r_getprinterdriver2
-{
- RPC_BUFFER *buffer;
- uint32 needed;
- uint32 servermajorversion;
- uint32 serverminorversion;
- WERROR status;
-}
-SPOOL_R_GETPRINTERDRIVER2;
-
-
typedef struct add_jobinfo_1
{
UNISTR path;
}
SYSTEMTIME;
-typedef struct s_job_info_1
-{
- uint32 jobid;
- UNISTR printername;
- UNISTR machinename;
- UNISTR username;
- UNISTR document;
- UNISTR datatype;
- UNISTR text_status;
- uint32 status;
- uint32 priority;
- uint32 position;
- uint32 totalpages;
- uint32 pagesprinted;
- SYSTEMTIME submitted;
-}
-JOB_INFO_1;
-
-typedef struct s_job_info_2
-{
- uint32 jobid;
- UNISTR printername;
- UNISTR machinename;
- UNISTR username;
- UNISTR document;
- UNISTR notifyname;
- UNISTR datatype;
- UNISTR printprocessor;
- UNISTR parameters;
- UNISTR drivername;
- DEVICEMODE *devmode;
- UNISTR text_status;
-/* SEC_DESC sec_desc;*/
- uint32 status;
- uint32 priority;
- uint32 position;
- uint32 starttime;
- uint32 untiltime;
- uint32 totalpages;
- uint32 size;
- SYSTEMTIME submitted;
- uint32 timeelapsed;
- uint32 pagesprinted;
-}
-JOB_INFO_2;
-
-typedef struct spool_q_enumjobs
-{
- POLICY_HND handle;
- uint32 firstjob;
- uint32 numofjobs;
- uint32 level;
- RPC_BUFFER *buffer;
- uint32 offered;
-}
-SPOOL_Q_ENUMJOBS;
-
-typedef struct job_info_ctr_info
-{
- union
- {
- JOB_INFO_1 *job_info_1;
- JOB_INFO_2 *job_info_2;
- void *info;
- } job;
-
-} JOB_INFO_CTR;
-
-typedef struct spool_r_enumjobs
-{
- RPC_BUFFER *buffer;
- uint32 needed;
- uint32 returned;
- WERROR status;
-}
-SPOOL_R_ENUMJOBS;
-
-typedef struct job_info_info
-{
- union
- {
- JOB_INFO_1 job_info_1;
- JOB_INFO_2 job_info_2;
- }
- job;
-
-}
-JOB_INFO;
-
-typedef struct spool_q_enumprinterdrivers
-{
- uint32 name_ptr;
- UNISTR2 name;
- uint32 environment_ptr;
- UNISTR2 environment;
- uint32 level;
- RPC_BUFFER *buffer;
- uint32 offered;
-}
-SPOOL_Q_ENUMPRINTERDRIVERS;
-
-typedef struct spool_r_enumprinterdrivers
-{
- RPC_BUFFER *buffer;
- uint32 needed;
- uint32 returned;
- WERROR status;
-}
-SPOOL_R_ENUMPRINTERDRIVERS;
-
/********************************************/
typedef struct spool_q_enumprinterdata
}
FORM;
-typedef struct spool_q_getjob
-{
- POLICY_HND handle;
- uint32 jobid;
- uint32 level;
- RPC_BUFFER *buffer;
- uint32 offered;
-}
-SPOOL_Q_GETJOB;
-
-typedef struct pjob_info_info
-{
- union
- {
- JOB_INFO_1 *job_info_1;
- JOB_INFO_2 *job_info_2;
- void *info;
- }
- job;
-
-}
-PJOB_INFO;
-
-typedef struct spool_r_getjob
-{
- RPC_BUFFER *buffer;
- uint32 needed;
- WERROR status;
-}
-SPOOL_R_GETJOB;
-
typedef struct spool_q_enumprinterkey
{
POLICY_HND handle;
/* There really is more here ... */
};
-struct pwd_info {
- bool null_pwd;
- bool cleartext;
-
- fstring password;
-};
-
/* For split krb5 SPNEGO blobs. */
struct pending_auth_data {
struct pending_auth_data *prev, *next;
#define syscall_brl_cancel_count __profile_stats_value(PR_VALUE_SYSCALL_BRL_CANCEL, count)
#define syscall_brl_cancel_time __profile_stats_value(PR_VALUE_SYSCALL_BRL_CANCEL, time)
+ PR_VALUE_SYSCALL_STRICT_LOCK,
+#define syscall_strict_lock_count __profile_stats_value(PR_VALUE_SYSCALL_STRICT_LOCK, count)
+#define syscall_strict_lock_time __profile_stats_value(PR_VALUE_SYSCALL_STRICT_LOCK, time)
+
+ PR_VALUE_SYSCALL_STRICT_UNLOCK,
+#define syscall_strict_unlock_count __profile_stats_value(PR_VALUE_SYSCALL_STRICT_UNLOCK, count)
+#define syscall_strict_unlock_time __profile_stats_value(PR_VALUE_SYSCALL_STRICT_UNLOCK, time)
+
/* counters for individual SMB types */
PR_VALUE_SMBMKDIR,
#define SMBmkdir_count __profile_stats_value(PR_VALUE_SMBMKDIR, count)
/* Leave at 25 - not yet released. Add SMB_STRUCT_STAT to readdir. - sdann */
/* Leave at 25 - not yet released. Add init_search_op call. - sdann */
/* Leave at 25 - not yet released. Add locking calls. -- zkirsch. */
+/* Leave at 25 - not yet released. Add strict locking calls. -- drichards. */
#define SMB_VFS_INTERFACE_VERSION 25
SMB_VFS_OP_BRL_LOCK_WINDOWS,
SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
SMB_VFS_OP_BRL_CANCEL_WINDOWS,
+ SMB_VFS_OP_STRICT_LOCK,
+ SMB_VFS_OP_STRICT_UNLOCK,
/* NT ACL operations. */
struct lock_struct *plock,
struct blocking_lock_record *blr);
+ bool (*strict_lock)(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ struct lock_struct *plock);
+
+ void (*strict_unlock)(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ struct lock_struct *plock);
+
/* NT ACL operations. */
NTSTATUS (*fget_nt_acl)(struct vfs_handle_struct *handle,
struct vfs_handle_struct *brl_lock_windows;
struct vfs_handle_struct *brl_unlock_windows;
struct vfs_handle_struct *brl_cancel_windows;
+ struct vfs_handle_struct *strict_lock;
+ struct vfs_handle_struct *strict_unlock;
/* NT ACL operations. */
#define SMB_VFS_BRL_LOCK_WINDOWS(conn, br_lck, plock, blocking_lock, blr) ((conn)->vfs.ops.brl_lock_windows((conn)->vfs.handles.brl_lock_windows, (br_lck), (plock), (blocking_lock), (blr)))
#define SMB_VFS_BRL_UNLOCK_WINDOWS(conn, msg_ctx, br_lck, plock) ((conn)->vfs.ops.brl_unlock_windows((conn)->vfs.handles.brl_unlock_windows, (msg_ctx), (br_lck), (plock)))
#define SMB_VFS_BRL_CANCEL_WINDOWS(conn, br_lck, plock, blr) ((conn)->vfs.ops.brl_cancel_windows((conn)->vfs.handles.brl_cancel_windows, (br_lck), (plock), (blr)))
+#define SMB_VFS_STRICT_LOCK(conn, fsp, plock) ((conn)->vfs.ops.strict_lock((conn)->vfs.handles.strict_lock, (fsp), (plock)))
+#define SMB_VFS_STRICT_UNLOCK(conn, fsp, plock) ((conn)->vfs.ops.strict_unlock((conn)->vfs.handles.strict_unlock, (fsp), (plock)))
/* NT ACL operations. */
#define SMB_VFS_FGET_NT_ACL(fsp, security_info, ppdesc) ((fsp)->conn->vfs.ops.fget_nt_acl((fsp)->conn->vfs.handles.fget_nt_acl, (fsp), (security_info), (ppdesc)))
#define SMB_VFS_OPAQUE_BRL_LOCK_WINDOWS(conn, br_lck, plock, blocking_lock, blr) ((conn)->vfs_opaque.ops.brl_lock_windows((conn)->vfs_opaque.handles.brl_lock_windows, (br_lck), (plock), (blocking_lock), (blr)))
#define SMB_VFS_OPAQUE_BRL_UNLOCK_WINDOWS(conn, msg_ctx, br_lck, plock) ((conn)->vfs_opaque.ops.brl_unlock_windows((conn)->vfs_opaque.handles.brl_unlock_windows, (msg_ctx), (br_lck), (plock)))
#define SMB_VFS_OPAQUE_BRL_CANCEL_WINDOWS(conn, br_lck, plock, blr) ((conn)->vfs_opaque.ops.brl_cancel_windows((conn)->vfs_opaque.handles.brl_cancel_windows, (br_lck), (plock), (blr)))
+#define SMB_VFS_OPAQUE_STRICT_LOCK(conn, fsp, plock) ((conn)->vfs_opaque.ops.strict_lock((conn)->vfs_opaque.handles.strict_lock, (fsp), (plock)))
+#define SMB_VFS_OPAQUE_STRICT_UNLOCK(conn, fsp, plock) ((conn)->vfs_opaque.ops.strict_unlock((conn)->vfs_opaque.handles.strict_unlock, (fsp), (plock)))
/* NT ACL operations. */
#define SMB_VFS_OPAQUE_FGET_NT_ACL(fsp, security_info, ppdesc) ((fsp)->conn->vfs_opaque.ops.fget_nt_acl((fsp)->conn->vfs_opaque.handles.fget_nt_acl, (fsp), (security_info), (ppdesc)))
#define SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock, blocking_lock, blr) ((handle)->vfs_next.ops.brl_lock_windows((handle)->vfs_next.handles.brl_lock_windows, (br_lck), (plock), (blocking_lock), (blr)))
#define SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck, plock) ((handle)->vfs_next.ops.brl_unlock_windows((handle)->vfs_next.handles.brl_unlock_windows, (msg_ctx), (br_lck), (plock)))
#define SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr) ((handle)->vfs_next.ops.brl_cancel_windows((handle)->vfs_next.handles.brl_cancel_windows, (br_lck), (plock), (blr)))
+#define SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock) ((handle)->vfs_next.ops.strict_lock((handle)->vfs_next.handles.strict_lock, (fsp), (plock)))
+#define SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock) ((handle)->vfs_next.ops.strict_unlock((handle)->vfs_next.handles.strict_unlock, (fsp), (plock)))
/* NT ACL operations. */
#define SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc) ((handle)->vfs_next.ops.fget_nt_acl((handle)->vfs_next.handles.fget_nt_acl, (fsp), (security_info), (ppdesc)))
struct winbindd_response **presp);
struct tevent_req *wb_resp_write_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev, int fd,
+ struct tevent_context *ev,
+ struct tevent_queue *queue, int fd,
struct winbindd_response *wb_resp);
wbcErr wb_resp_write_recv(struct tevent_req *req);
return to_ret;
}
-static int s3_event_loop_once(struct tevent_context *ev)
+static int s3_event_loop_once(struct tevent_context *ev, const char *location)
{
struct timeval now, to;
fd_set r_fds, w_fds;
return 0;
}
-static int s3_event_loop_wait(struct tevent_context *ev)
+static int s3_event_loop_wait(struct tevent_context *ev, const char *location)
{
int ret = 0;
while (ret == 0) {
- ret = s3_event_loop_once(ev);
+ ret = s3_event_loop_once(ev, location);
}
return ret;
/********************************************************************
********************************************************************/
-WERROR libnetapi_shutdown_cm(struct libnetapi_ctx *ctx)
-{
- cli_cm_shutdown();
-
- return WERR_OK;
-}
-
-/********************************************************************
-********************************************************************/
-
struct client_pipe_connection {
struct client_pipe_connection *prev, *next;
struct rpc_pipe_client *pipe;
+ struct cli_state *cli;
};
static struct client_pipe_connection *pipe_connections;
/********************************************************************
********************************************************************/
+WERROR libnetapi_shutdown_cm(struct libnetapi_ctx *ctx)
+{
+ struct client_pipe_connection *p;
+
+ for (p = pipe_connections; p; p = p->next) {
+ cli_shutdown(p->cli);
+ }
+
+ return WERR_OK;
+}
+
+/********************************************************************
+********************************************************************/
+
static NTSTATUS pipe_cm_find(struct cli_state *cli,
const struct ndr_syntax_id *interface,
struct rpc_pipe_client **presult)
return status;
}
+ p->cli = cli;
DLIST_ADD(pipe_connections, p);
*presult = p->pipe;
return WERR_OK;
}
-
-
static void wb_resp_write_done(struct tevent_req *subreq);
struct tevent_req *wb_resp_write_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev, int fd,
+ struct tevent_context *ev,
+ struct tevent_queue *queue, int fd,
struct winbindd_response *wb_resp)
{
struct tevent_req *result, *subreq;
count = 2;
}
- subreq = writev_send(state, ev, NULL, fd, state->iov, count);
+ subreq = writev_send(state, ev, queue, fd, state->iov, count);
if (subreq == NULL) {
goto fail;
}
{
DATA_BLOB session_key = data_blob_null;
DATA_BLOB lm_response = data_blob_null;
+ NTSTATUS status;
fstring pword;
char *p;
/* use the returned vuid from now on */
cli->vuid = SVAL(cli->inbuf,smb_uid);
- fstrcpy(cli->user_name, user);
+ status = cli_set_username(cli, user);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
if (session_key.data) {
/* Have plaintext orginal */
cli->is_samba = True;
}
- fstrcpy(cli->user_name, "");
+ status = cli_set_username(cli, "");
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
return NT_STATUS_OK;
}
{
uint32 capabilities = cli_session_setup_capabilities(cli);
char *p;
+ NTSTATUS status;
fstring lanman;
fstr_sprintf( lanman, "Samba %s", samba_version_string());
-1, STR_TERMINATE);
p += clistr_pull(cli->inbuf, cli->server_domain, p, sizeof(fstring),
-1, STR_TERMINATE);
- fstrcpy(cli->user_name, user);
-
+ status = cli_set_username(cli, user);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
if (strstr(cli->server_type, "Samba")) {
cli->is_samba = True;
}
cli->is_samba = True;
}
- fstrcpy(cli->user_name, user);
+ result = cli_set_username(cli, user);
+ if (!NT_STATUS_IS_OK(result)) {
+ goto end;
+ }
if (session_key.data) {
/* Have plaintext orginal */
DATA_BLOB blob;
const char *p = NULL;
char *account = NULL;
+ NTSTATUS status;
DEBUG(3,("Doing spnego session setup (blob length=%lu)\n", (unsigned long)cli->secblob.length));
DEBUG(3,("got principal=%s\n", principal ? principal : "<null>"));
- fstrcpy(cli->user_name, user);
+ status = cli_set_username(cli, user);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ADS_ERROR_NT(status);
+ }
#ifdef HAVE_KRB5
/* If password is set we reauthenticate to kerberos server
}
}
- cli_init_creds(cli, user, domain, password);
+ nt_status = cli_init_creds(cli, user, domain, password);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ cli_shutdown(cli);
+ return nt_status;
+ }
*output_cli = cli;
return NT_STATUS_OK;
client connect/disconnect routines
Copyright (C) Andrew Tridgell 1994-1998
Copyright (C) Gerald (Jerry) Carter 2004
- Copyright (C) Jeremy Allison 2007
+ Copyright (C) Jeremy Allison 2007-2009
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
as a separator when looking at the pathname part.... JRA.
********************************************************************/
-struct client_connection {
- struct client_connection *prev, *next;
- struct cli_state *cli;
- char *mount;
-};
-
static struct cm_cred_struct {
char *username;
char *password;
static void cm_set_password(const char *newpass);
-static struct client_connection *connections;
-
static bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
struct cli_state *cli,
const char *sharename,
return status;
}
-
+
/********************************************************************
Return a connection to a server.
********************************************************************/
/****************************************************************************
****************************************************************************/
-static void cli_cm_set_mntpoint(struct cli_state *c, const char *mnt)
-{
- struct client_connection *p;
- int i;
-
- for (p=connections,i=0; p; p=p->next,i++) {
- if (strequal(p->cli->desthost, c->desthost) &&
- strequal(p->cli->share, c->share)) {
- break;
- }
- }
-
- if (p) {
- char *name = clean_name(NULL, mnt);
- if (!name) {
- return;
- }
- TALLOC_FREE(p->mount);
- p->mount = talloc_strdup(p, name);
- TALLOC_FREE(name);
- }
-}
-
-/****************************************************************************
-****************************************************************************/
-
-const char *cli_cm_get_mntpoint(struct cli_state *c)
+static void cli_set_mntpoint(struct cli_state *cli, const char *mnt)
{
- struct client_connection *p;
- int i;
-
- for (p=connections,i=0; p; p=p->next,i++) {
- if (strequal(p->cli->desthost, c->desthost) &&
- strequal(p->cli->share, c->share)) {
- break;
- }
- }
-
- if (p) {
- return p->mount;
+ char *name = clean_name(NULL, mnt);
+ if (!name) {
+ return;
}
- return NULL;
+ TALLOC_FREE(cli->dfs_mountpoint);
+ cli->dfs_mountpoint = talloc_strdup(cli, name);
+ TALLOC_FREE(name);
}
/********************************************************************
- Add a new connection to the list
+ Add a new connection to the list.
+ referring_cli == NULL means a new initial connection.
********************************************************************/
static struct cli_state *cli_cm_connect(TALLOC_CTX *ctx,
int port,
int name_type)
{
- struct client_connection *node;
-
- /* NB This must be the null context here... JRA. */
- node = TALLOC_ZERO_ARRAY(NULL, struct client_connection, 1);
- if (!node) {
- return NULL;
- }
+ struct cli_state *cli;
- node->cli = do_connect(ctx, server, share,
+ cli = do_connect(ctx, server, share,
show_hdr, force_encrypt, max_protocol,
port, name_type);
- if ( !node->cli ) {
- TALLOC_FREE( node );
+ if (!cli ) {
return NULL;
}
- DLIST_ADD( connections, node );
-
- cli_cm_set_mntpoint(node->cli, "");
+ /* Enter into the list. */
+ if (referring_cli) {
+ DLIST_ADD_END(referring_cli, cli, struct cli_state *);
+ }
if (referring_cli && referring_cli->posix_capabilities) {
uint16 major, minor;
uint32 caplow, caphigh;
- if (cli_unix_extensions_version(node->cli, &major,
+ if (cli_unix_extensions_version(cli, &major,
&minor, &caplow, &caphigh)) {
- cli_set_unix_extensions_capabilities(node->cli,
+ cli_set_unix_extensions_capabilities(cli,
major, minor,
caplow, caphigh);
}
}
- return node->cli;
+ return cli;
}
/********************************************************************
- Return a connection to a server.
+ Return a connection to a server on a particular share.
********************************************************************/
-static struct cli_state *cli_cm_find(const char *server, const char *share)
+static struct cli_state *cli_cm_find(struct cli_state *cli,
+ const char *server,
+ const char *share)
{
- struct client_connection *p;
+ struct cli_state *p;
- for (p=connections; p; p=p->next) {
- if ( strequal(server, p->cli->desthost) &&
- strequal(share,p->cli->share)) {
- return p->cli;
+ if (cli == NULL) {
+ return NULL;
+ }
+
+ /* Search to the start of the list. */
+ for (p = cli; p; p = p->prev) {
+ if (strequal(server, p->desthost) &&
+ strequal(share,p->share)) {
+ return p;
+ }
+ }
+
+ /* Search to the end of the list. */
+ for (p = cli->next; p; p = p->next) {
+ if (strequal(server, p->desthost) &&
+ strequal(share,p->share)) {
+ return p;
}
}
}
/****************************************************************************
- Open a client connection to a \\server\share. Set's the current *cli
- global variable as a side-effect (but only if the connection is successful).
+ Open a client connection to a \\server\share.
****************************************************************************/
struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
int port,
int name_type)
{
- struct cli_state *c;
+ /* Try to reuse an existing connection in this list. */
+ struct cli_state *c = cli_cm_find(referring_cli, server, share);
- /* try to reuse an existing connection */
+ if (c) {
+ return c;
+ }
- c = cli_cm_find(server, share);
- if (!c) {
- c = cli_cm_connect(ctx, referring_cli,
+ return cli_cm_connect(ctx, referring_cli,
server, share, show_hdr, force_encrypt,
max_protocol, port, name_type);
- }
-
- return c;
-}
-
-/****************************************************************************
-****************************************************************************/
-
-void cli_cm_shutdown(void)
-{
- struct client_connection *p, *x;
-
- for (p=connections; p;) {
- cli_shutdown(p->cli);
- x = p;
- p = p->next;
-
- TALLOC_FREE(x);
- }
-
- connections = NULL;
- return;
}
/****************************************************************************
****************************************************************************/
-void cli_cm_display(void)
+void cli_cm_display(const struct cli_state *cli)
{
- struct client_connection *p;
int i;
- for ( p=connections,i=0; p; p=p->next,i++ ) {
+ for (i=0; cli; cli = cli->next,i++ ) {
d_printf("%d:\tserver=%s, share=%s\n",
- i, p->cli->desthost, p->cli->share );
+ i, cli->desthost, cli->share );
}
}
return false;
}
- cli_cm_set_mntpoint(*targetcli, newmount);
+ cli_set_mntpoint(*targetcli, newmount);
/* Check for another dfs referral, note that we are not
checking for loops here. */
set_message_bcc(cli->outbuf, PTR_DIFF(p, smb_buf(cli->outbuf)));
}
+/****************************************************************************
+ Initialize Domain, user or password.
+****************************************************************************/
+
+NTSTATUS cli_set_domain(struct cli_state *cli, const char *domain)
+{
+ TALLOC_FREE(cli->domain);
+ cli->domain = talloc_strdup(cli, domain ? domain : "");
+ if (cli->domain == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ return NT_STATUS_OK;
+}
+
+NTSTATUS cli_set_username(struct cli_state *cli, const char *username)
+{
+ TALLOC_FREE(cli->user_name);
+ cli->user_name = talloc_strdup(cli, username ? username : "");
+ if (cli->user_name == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ return NT_STATUS_OK;
+}
+
+NTSTATUS cli_set_password(struct cli_state *cli, const char *password)
+{
+ TALLOC_FREE(cli->password);
+
+ /* Password can be NULL. */
+ if (password) {
+ cli->password = talloc_strdup(cli, password);
+ if (cli->password == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ } else {
+ /* Use zero NTLMSSP hashes and session key. */
+ cli->password = NULL;
+ }
+
+ return NT_STATUS_OK;
+}
+
/****************************************************************************
Initialise credentials of a client structure.
****************************************************************************/
-void cli_init_creds(struct cli_state *cli, const char *username, const char *domain, const char *password)
+NTSTATUS cli_init_creds(struct cli_state *cli, const char *username, const char *domain, const char *password)
{
- fstrcpy(cli->domain, domain);
- fstrcpy(cli->user_name, username);
- pwd_set_cleartext(&cli->pwd, password);
- if (!*username) {
- cli->pwd.null_pwd = true;
+ NTSTATUS status = cli_set_username(cli, username);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ status = cli_set_domain(cli, domain);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
+ DEBUG(10,("cli_init_creds: user %s domain %s\n", cli->user_name, cli->domain));
- DEBUG(10,("cli_init_creds: user %s domain %s\n", cli->user_name, cli->domain));
+ return cli_set_password(cli, password);
}
/****************************************************************************
- Initialise a client structure. Always returns a malloc'ed struct.
+ Initialise a client structure. Always returns a talloc'ed struct.
Set the signing state (used from the command line).
****************************************************************************/
return NULL;
}
+ cli->dfs_mountpoint = talloc_strdup(cli, "");
+ if (!cli->dfs_mountpoint) {
+ goto error;
+ }
cli->port = 0;
cli->fd = -1;
cli->cnum = -1;
SAFE_FREE(cli->inbuf);
SAFE_FREE(cli->outbuf);
- SAFE_FREE(cli);
+ TALLOC_FREE(cli);
return NULL;
}
void cli_shutdown(struct cli_state *cli)
{
+ if (cli->prev == NULL) {
+ /*
+ * Possible head of a DFS list,
+ * shutdown all subsidiary DFS
+ * connections.
+ */
+ struct cli_state *p, *next;
+
+ for (p = cli->next; p; p = next) {
+ next = p->next;
+ cli_shutdown(p);
+ }
+ } else {
+ /*
+ * We're a subsidiary connection.
+ * Just remove ourselves from the
+ * DFS list.
+ */
+ DLIST_REMOVE(cli->prev, cli);
+ }
+
cli_nt_pipes_close(cli);
/*
unsigned int param_len, data_len;
uint16 setup;
char *param;
- const char *mnt;
uint32 resume_key = 0;
TALLOC_CTX *frame = talloc_stackframe();
DATA_BLOB last_name_raw = data_blob(NULL, 0);
First = False;
}
- mnt = cli_cm_get_mntpoint( cli );
-
/* see if the server disconnected or the connection otherwise failed */
if (cli_is_error(cli)) {
total_received = -1;
info_level));
break;
}
- fn(mnt,&finfo, Mask, state);
+ fn(cli->dfs_mountpoint, &finfo, Mask, state);
}
}
uint16_t mode;
off_t start_offset;
size_t window_size;
- bool caller_buffers;
- size_t (*source)(uint8_t *inbuf, size_t n,
- const uint8_t **outbuf,
- void *priv);
+ size_t (*source)(uint8_t *buf, size_t n, void *priv);
void *priv;
bool eof;
substate->req = req;
substate->idx = idx;
substate->ofs = state->next_offset;
- if (state->caller_buffers) {
- substate->buf = NULL;
- } else {
- substate->buf = talloc_array(substate, uint8_t,
- state->chunk_size);
- if (!substate->buf) {
- talloc_free(substate);
- return false;
- }
+ substate->buf = talloc_array(substate, uint8_t, state->chunk_size);
+ if (!substate->buf) {
+ talloc_free(substate);
+ return false;
}
-
- /* source function can overwrite substate->buf... */
substate->size = state->source(substate->buf,
state->chunk_size,
- (const uint8_t **)&substate->buf,
state->priv);
if (substate->size == 0) {
state->eof = true;
struct cli_state *cli,
uint16_t fnum, uint16_t mode,
off_t start_offset, size_t window_size,
- bool caller_buffers,
- size_t (*source)(uint8_t *inbuf, size_t n,
- const uint8_t **outbuf,
+ size_t (*source)(uint8_t *buf, size_t n,
void *priv),
void *priv)
{
state->fnum = fnum;
state->start_offset = start_offset;
state->mode = mode;
- state->caller_buffers = caller_buffers;
state->source = source;
state->priv = priv;
state->eof = false;
NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
off_t start_offset, size_t window_size,
- bool caller_buffers,
- size_t (*source)(uint8_t *inbuf, size_t n,
- const uint8_t **outbuf,
- void *priv),
+ size_t (*source)(uint8_t *buf, size_t n, void *priv),
void *priv)
{
TALLOC_CTX *frame = talloc_stackframe();
}
req = cli_push_send(frame, ev, cli, fnum, mode, start_offset,
- window_size, caller_buffers, source, priv);
+ window_size, source, priv);
if (req == NULL) {
goto nomem;
}
return result;
}
- cli_init_creds(cli, "", "", NULL);
+ result = cli_init_creds(cli, "", "", NULL);
+ if (!NT_STATUS_IS_OK(result)) {
+ cli_shutdown(cli);
+ return result;
+ }
} else {
- cli_init_creds(cli, user_name, "", old_passwd);
+ result = cli_init_creds(cli, user_name, "", old_passwd);
+ if (!NT_STATUS_IS_OK(result)) {
+ cli_shutdown(cli);
+ return result;
+ }
}
result = cli_tcon_andx(cli, "IPC$", "IPC", "", 1);
TALLOC_FREE(pipe_hnd);
/* Try anonymous NTLMSSP... */
- cli_init_creds(cli, "", "", NULL);
+ result = cli_init_creds(cli, "", "", NULL);
+ if (!NT_STATUS_IS_OK(result)) {
+ cli_shutdown(cli);
+ return result;
+ }
result = NT_STATUS_UNSUCCESSFUL;
+++ /dev/null
-/*
- Unix SMB/CIFS implementation.
- Password cacheing. obfuscation is planned
- Copyright (C) Luke Kenneth Casson Leighton 1996-1998
-
- 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"
-
-/****************************************************************************
- Initialises a password structure.
-****************************************************************************/
-
-static void pwd_init(struct pwd_info *pwd)
-{
- memset((char *)pwd->password , '\0', sizeof(pwd->password ));
-
- pwd->null_pwd = True; /* safest option... */
-}
-
-/****************************************************************************
- Stores a cleartext password.
-****************************************************************************/
-
-void pwd_set_cleartext(struct pwd_info *pwd, const char *clr)
-{
- pwd_init(pwd);
- if (clr) {
- fstrcpy(pwd->password, clr);
- pwd->null_pwd = False;
- } else {
- pwd->null_pwd = True;
- }
-
- pwd->cleartext = True;
-}
-
-/****************************************************************************
- Gets a cleartext password.
-****************************************************************************/
-
-void pwd_get_cleartext(struct pwd_info *pwd, fstring clr)
-{
- if (pwd->cleartext)
- fstrcpy(clr, pwd->password);
- else
- clr[0] = 0;
-
-}
Called in the read/write codepath.
****************************************************************************/
-bool is_locked(files_struct *fsp,
- uint32 smbpid,
- uint64_t count,
- uint64_t offset,
- enum brl_type lock_type)
+void init_strict_lock_struct(files_struct *fsp,
+ uint32 smbpid,
+ br_off start,
+ br_off size,
+ enum brl_type lock_type,
+ struct lock_struct *plock)
+{
+ SMB_ASSERT(lock_type == READ_LOCK || lock_type == WRITE_LOCK);
+
+ plock->context.smbpid = smbpid;
+ plock->context.tid = fsp->conn->cnum;
+ plock->context.pid = procid_self();
+ plock->start = start;
+ plock->size = size;
+ plock->fnum = fsp->fnum;
+ plock->lock_type = lock_type;
+ plock->lock_flav = lp_posix_cifsu_locktype(fsp);
+}
+
+bool strict_lock_default(files_struct *fsp, struct lock_struct *plock)
{
int strict_locking = lp_strict_locking(fsp->conn->params);
- enum brl_flavour lock_flav = lp_posix_cifsu_locktype(fsp);
- bool ret = True;
-
- if (count == 0) {
- return False;
+ bool ret = False;
+
+ if (plock->size == 0) {
+ return True;
}
if (!lp_locking(fsp->conn->params) || !strict_locking) {
- return False;
+ return True;
}
if (strict_locking == Auto) {
- if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && (lock_type == READ_LOCK || lock_type == WRITE_LOCK)) {
+ if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && (plock->lock_type == READ_LOCK || plock->lock_type == WRITE_LOCK)) {
DEBUG(10,("is_locked: optimisation - exclusive oplock on file %s\n", fsp->fsp_name ));
- ret = False;
+ ret = True;
} else if ((fsp->oplock_type == LEVEL_II_OPLOCK) &&
- (lock_type == READ_LOCK)) {
+ (plock->lock_type == READ_LOCK)) {
DEBUG(10,("is_locked: optimisation - level II oplock on file %s\n", fsp->fsp_name ));
- ret = False;
+ ret = True;
} else {
struct byte_range_lock *br_lck = brl_get_locks_readonly(talloc_tos(), fsp);
if (!br_lck) {
- return False;
+ return True;
}
- ret = !brl_locktest(br_lck,
- smbpid,
- procid_self(),
- offset,
- count,
- lock_type,
- lock_flav);
+ ret = brl_locktest(br_lck,
+ plock->context.smbpid,
+ plock->context.pid,
+ plock->start,
+ plock->size,
+ plock->lock_type,
+ plock->lock_flav);
TALLOC_FREE(br_lck);
}
} else {
struct byte_range_lock *br_lck = brl_get_locks_readonly(talloc_tos(), fsp);
if (!br_lck) {
- return False;
+ return True;
}
- ret = !brl_locktest(br_lck,
- smbpid,
- procid_self(),
- offset,
- count,
- lock_type,
- lock_flav);
+ ret = brl_locktest(br_lck,
+ plock->context.smbpid,
+ plock->context.pid,
+ plock->start,
+ plock->size,
+ plock->lock_type,
+ plock->lock_flav);
TALLOC_FREE(br_lck);
}
- DEBUG(10,("is_locked: flavour = %s brl start=%.0f len=%.0f %s for fnum %d file %s\n",
- lock_flav_name(lock_flav),
- (double)offset, (double)count, ret ? "locked" : "unlocked",
- fsp->fnum, fsp->fsp_name ));
+ DEBUG(10,("strict_lock_default: flavour = %s brl start=%.0f "
+ "len=%.0f %s for fnum %d file %s\n",
+ lock_flav_name(plock->lock_flav),
+ (double)plock->start, (double)plock->size,
+ ret ? "unlocked" : "locked",
+ plock->fnum, fsp->fsp_name ));
return ret;
}
+void strict_unlock_default(files_struct *fsp, struct lock_struct *plock)
+{
+}
+
/****************************************************************************
Find out if a lock could be granted - return who is blocking us if we can't.
****************************************************************************/
struct lock_struct *plock,
struct blocking_lock_record *blr);
+bool onefs_strict_lock(vfs_handle_struct *handle,
+ files_struct *fsp,
+ struct lock_struct *plock);
+
+void onefs_strict_unlock(vfs_handle_struct *handle,
+ files_struct *fsp,
+ struct lock_struct *plock);
+
NTSTATUS onefs_notify_watch(vfs_handle_struct *vfs_handle,
struct sys_notify_context *ctx,
struct notify_entry *e,
{
int fd = br_lck->fsp->fh->fd;
uint64_t id = 0;
- bool exclusive = false;
+ enum cbrl_lock_type type;
bool async = false;
bool pending = false;
bool pending_async = false;
switch (plock->lock_type) {
case WRITE_LOCK:
- exclusive = true;
+ type = CBRL_LK_EX;
break;
case READ_LOCK:
+ type = CBRL_LK_SH;
break;
case PENDING_WRITE_LOCK:
/* Called when a blocking lock request is added - do an
* async lock. */
+ type = CBRL_LK_EX;
pending = true;
async = true;
- exclusive = true;
break;
case PENDING_READ_LOCK:
/* Called when a blocking lock request is added - do an
* async lock. */
+ type = CBRL_LK_SH;
pending = true;
async = true;
break;
}
DEBUG(10, ("Calling ifs_cbrl(LOCK)..."));
- error = ifs_cbrl(fd, CBRL_OP_LOCK, exclusive, plock->start,
+ error = ifs_cbrl(fd, CBRL_OP_LOCK, type, plock->start,
plock->size, async, id, plock->context.smbpid, plock->context.tid,
plock->fnum);
if (!error) {
return NT_STATUS_OK;
}
-#define CBRL_NOTYPE true
-
bool onefs_brl_unlock_windows(vfs_handle_struct *handle,
struct messaging_context *msg_ctx,
struct byte_range_lock *br_lck,
SMB_ASSERT(plock->lock_type == UNLOCK_LOCK);
DEBUG(10, ("Calling ifs_cbrl(UNLOCK)..."));
- error = ifs_cbrl(fd, CBRL_OP_UNLOCK, CBRL_NOTYPE,
- plock->start, plock->size, CBRL_NOTYPE, 0, plock->context.smbpid,
+ error = ifs_cbrl(fd, CBRL_OP_UNLOCK, CBRL_LK_SH,
+ plock->start, plock->size, false, 0, plock->context.smbpid,
plock->context.tid, plock->fnum);
END_PROFILE(syscall_brl_unlock);
/* A real cancel. */
DEBUG(10, ("Calling ifs_cbrl(CANCEL)..."));
- error = ifs_cbrl(fd, CBRL_OP_CANCEL, CBRL_NOTYPE, plock->start,
- plock->size, CBRL_NOTYPE, bs->id, plock->context.smbpid,
+ error = ifs_cbrl(fd, CBRL_OP_CANCEL, CBRL_LK_UNSPEC, plock->start,
+ plock->size, false, bs->id, plock->context.smbpid,
plock->context.tid, plock->fnum);
END_PROFILE(syscall_brl_cancel);
return true;
}
+bool onefs_strict_lock(vfs_handle_struct *handle,
+ files_struct *fsp,
+ struct lock_struct *plock)
+{
+ int error;
+
+ START_PROFILE(syscall_strict_lock);
+
+ SMB_ASSERT(plock->lock_type == READ_LOCK ||
+ plock->lock_type == WRITE_LOCK);
+
+ if (!lp_locking(handle->conn->params) ||
+ !lp_strict_locking(handle->conn->params)) {
+ END_PROFILE(syscall_strict_lock);
+ return True;
+ }
+
+ if (plock->lock_flav == POSIX_LOCK) {
+ END_PROFILE(syscall_strict_lock);
+ return SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
+ }
+
+ if (plock->size == 0) {
+ END_PROFILE(syscall_strict_lock);
+ return True;
+ }
+
+ error = ifs_cbrl(fsp->fh->fd, CBRL_OP_LOCK,
+ plock->lock_type == READ_LOCK ? CBRL_LK_RD : CBRL_LK_WR,
+ plock->start, plock->size, 0, 0, plock->context.smbpid,
+ plock->context.tid, plock->fnum);
+
+ END_PROFILE(syscall_strict_lock);
+
+ return (error == 0);
+}
+
+void onefs_strict_unlock(vfs_handle_struct *handle,
+ files_struct *fsp,
+ struct lock_struct *plock)
+{
+ START_PROFILE(syscall_strict_unlock);
+
+ SMB_ASSERT(plock->lock_type == READ_LOCK ||
+ plock->lock_type == WRITE_LOCK);
+
+ if (!lp_locking(handle->conn->params) ||
+ !lp_strict_locking(handle->conn->params)) {
+ END_PROFILE(syscall_strict_unlock);
+ return;
+ }
+
+ if (plock->lock_flav == POSIX_LOCK) {
+ SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
+ END_PROFILE(syscall_strict_unlock);
+ return;
+ }
+
+ if (plock->size == 0) {
+ END_PROFILE(syscall_strict_unlock);
+ return;
+ }
+
+ if (fsp->fh) {
+ ifs_cbrl(fsp->fh->fd, CBRL_OP_UNLOCK,
+ plock->lock_type == READ_LOCK ? CBRL_LK_RD : CBRL_LK_WR,
+ plock->start, plock->size, 0, 0, plock->context.smbpid,
+ plock->context.tid, plock->fnum);
+ }
+
+ END_PROFILE(syscall_strict_unlock);
+}
+
/* TODO Optimization: Abstract out brl_get_locks() in the Windows case.
* We'll malloc some memory or whatever (can't return NULL), but not actually
* touch the TDB. */
return brl_lock_cancel_default(br_lck, plock);
}
+static bool vfswrap_strict_lock(struct vfs_handle_struct *handle,
+ files_struct *fsp,
+ struct lock_struct *plock)
+{
+ SMB_ASSERT(plock->lock_type == READ_LOCK ||
+ plock->lock_type == WRITE_LOCK);
+
+ return strict_lock_default(fsp, plock);
+}
+
+static void vfswrap_strict_unlock(struct vfs_handle_struct *handle,
+ files_struct *fsp,
+ struct lock_struct *plock)
+{
+ SMB_ASSERT(plock->lock_type == READ_LOCK ||
+ plock->lock_type == WRITE_LOCK);
+
+ strict_unlock_default(fsp, plock);
+}
+
/* NT ACL operations. */
static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle,
SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(vfswrap_brl_cancel_windows),SMB_VFS_OP_BRL_CANCEL_WINDOWS,
SMB_VFS_LAYER_OPAQUE},
+ {SMB_VFS_OP(vfswrap_strict_lock), SMB_VFS_OP_STRICT_LOCK,
+ SMB_VFS_LAYER_OPAQUE},
+ {SMB_VFS_OP(vfswrap_strict_unlock), SMB_VFS_OP_STRICT_UNLOCK,
+ SMB_VFS_LAYER_OPAQUE},
/* NT ACL operations. */
struct byte_range_lock *br_lck,
struct lock_struct *plock,
struct blocking_lock_record *blr);
+static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ struct lock_struct *plock);
+static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ struct lock_struct *plock);
static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
uint32 security_info,
SEC_DESC **ppdesc);
SMB_VFS_LAYER_LOGGER},
{SMB_VFS_OP(smb_full_audit_brl_cancel_windows), SMB_VFS_OP_BRL_CANCEL_WINDOWS,
SMB_VFS_LAYER_LOGGER},
+ {SMB_VFS_OP(smb_full_audit_strict_lock), SMB_VFS_OP_STRICT_LOCK,
+ SMB_VFS_LAYER_LOGGER},
+ {SMB_VFS_OP(smb_full_audit_strict_unlock), SMB_VFS_OP_STRICT_UNLOCK,
+ SMB_VFS_LAYER_LOGGER},
/* NT ACL operations. */
{ SMB_VFS_OP_BRL_LOCK_WINDOWS, "brl_lock_windows" },
{ SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" },
{ SMB_VFS_OP_BRL_CANCEL_WINDOWS, "brl_cancel_windows" },
+ { SMB_VFS_OP_STRICT_LOCK, "strict_lock" },
+ { SMB_VFS_OP_STRICT_UNLOCK, "strict_unlock" },
{ SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
{ SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
{ SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
return result;
}
+static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ struct lock_struct *plock)
+{
+ bool result;
+
+ result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
+
+ do_log(SMB_VFS_OP_STRICT_LOCK, result, handle,
+ "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
+ plock->size);
+
+ return result;
+}
+
+static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
+ struct files_struct *fsp,
+ struct lock_struct *plock)
+{
+ SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
+
+ do_log(SMB_VFS_OP_STRICT_UNLOCK, true, handle,
+ "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
+ plock->size);
+
+ return;
+}
+
static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
uint32 security_info,
SEC_DESC **ppdesc)
SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(onefs_brl_cancel_windows), SMB_VFS_OP_BRL_CANCEL_WINDOWS,
SMB_VFS_LAYER_OPAQUE},
+ {SMB_VFS_OP(onefs_strict_lock), SMB_VFS_OP_STRICT_LOCK,
+ SMB_VFS_LAYER_OPAQUE},
+ {SMB_VFS_OP(onefs_strict_unlock), SMB_VFS_OP_STRICT_UNLOCK,
+ SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(onefs_notify_watch), SMB_VFS_OP_NOTIFY_WATCH,
SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(onefs_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
--- /dev/null
+/*
+ * Force a readahead of files by opening them and reading the first bytes
+ *
+ * Copyright (C) Volker Lendecke 2008
+ *
+ * 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"
+
+struct preopen_state;
+
+struct preopen_helper {
+ struct preopen_state *state;
+ struct fd_event *fde;
+ pid_t pid;
+ int fd;
+ bool busy;
+};
+
+struct preopen_state {
+ int num_helpers;
+ struct preopen_helper *helpers;
+
+ size_t to_read; /* How many bytes to read in children? */
+ int queue_max;
+
+ char *template_fname; /* Filename to be sent to children */
+ size_t number_start; /* start offset into "template_fname" */
+ int num_digits; /* How many digits is the number long? */
+
+ int fnum_sent; /* last fname sent to children */
+
+ int fnum_queue_end; /* last fname to be sent, based on
+ * last open call + preopen:queuelen
+ */
+
+ name_compare_entry *preopen_names;
+};
+
+static void preopen_helper_destroy(struct preopen_helper *c)
+{
+ int status;
+ close(c->fd);
+ c->fd = -1;
+ kill(c->pid, SIGKILL);
+ waitpid(c->pid, &status, 0);
+ c->busy = true;
+}
+
+static void preopen_queue_run(struct preopen_state *state)
+{
+ char *pdelimiter;
+ char delimiter;
+
+ pdelimiter = state->template_fname + state->number_start
+ + state->num_digits;
+ delimiter = *pdelimiter;
+
+ while (state->fnum_sent < state->fnum_queue_end) {
+
+ ssize_t written;
+ size_t to_write;
+ int helper;
+
+ for (helper=0; helper<state->num_helpers; helper++) {
+ if (state->helpers[helper].busy) {
+ continue;
+ }
+ break;
+ }
+ if (helper == state->num_helpers) {
+ /* everyone is busy */
+ return;
+ }
+
+ snprintf(state->template_fname + state->number_start,
+ state->num_digits + 1,
+ "%.*lu", state->num_digits,
+ (long unsigned int)(state->fnum_sent + 1));
+ *pdelimiter = delimiter;
+
+ to_write = talloc_get_size(state->template_fname);
+ written = write_data(state->helpers[helper].fd,
+ state->template_fname, to_write);
+ state->helpers[helper].busy = true;
+
+ if (written != to_write) {
+ preopen_helper_destroy(&state->helpers[helper]);
+ }
+ state->fnum_sent += 1;
+ }
+}
+
+static void preopen_helper_readable(struct event_context *ev,
+ struct fd_event *fde, uint16_t flags,
+ void *priv)
+{
+ struct preopen_helper *helper = (struct preopen_helper *)priv;
+ struct preopen_state *state = helper->state;
+ ssize_t nread;
+ char c;
+
+ if ((flags & EVENT_FD_READ) == 0) {
+ return;
+ }
+
+ nread = read(helper->fd, &c, 1);
+ if (nread <= 0) {
+ preopen_helper_destroy(helper);
+ return;
+ }
+
+ helper->busy = false;
+
+ preopen_queue_run(state);
+}
+
+static int preopen_helpers_destructor(struct preopen_state *c)
+{
+ int i;
+
+ for (i=0; i<c->num_helpers; i++) {
+ if (c->helpers[i].fd == -1) {
+ continue;
+ }
+ preopen_helper_destroy(&c->helpers[i]);
+ }
+
+ return 0;
+}
+
+static bool preopen_helper_open_one(int sock_fd, char **pnamebuf,
+ size_t to_read, void *filebuf)
+{
+ char *namebuf = *pnamebuf;
+ ssize_t nwritten, nread;
+ char c = 0;
+ int fd;
+
+ nread = 0;
+
+ while ((nread == 0) || (namebuf[nread-1] != '\0')) {
+ ssize_t thistime;
+
+ thistime = read(sock_fd, namebuf + nread,
+ talloc_get_size(namebuf) - nread);
+ if (thistime <= 0) {
+ return false;
+ }
+
+ nread += thistime;
+
+ if (nread == talloc_get_size(namebuf)) {
+ namebuf = TALLOC_REALLOC_ARRAY(
+ NULL, namebuf, char,
+ talloc_get_size(namebuf) * 2);
+ if (namebuf == NULL) {
+ return false;
+ }
+ *pnamebuf = namebuf;
+ }
+ }
+
+ fd = open(namebuf, O_RDONLY);
+ if (fd == -1) {
+ goto done;
+ }
+ nread = read(fd, filebuf, to_read);
+ close(fd);
+
+ done:
+ nwritten = write(sock_fd, &c, 1);
+ return true;
+}
+
+static bool preopen_helper(int fd, size_t to_read)
+{
+ char *namebuf;
+ void *readbuf;
+
+ namebuf = TALLOC_ARRAY(NULL, char, 1024);
+ if (namebuf == NULL) {
+ return false;
+ }
+
+ readbuf = talloc_size(NULL, to_read);
+ if (readbuf == NULL) {
+ TALLOC_FREE(namebuf);
+ return false;
+ }
+
+ while (preopen_helper_open_one(fd, &namebuf, to_read, readbuf)) {
+ ;
+ }
+
+ TALLOC_FREE(readbuf);
+ TALLOC_FREE(namebuf);
+ return false;
+}
+
+static NTSTATUS preopen_init_helper(struct preopen_helper *h)
+{
+ int fdpair[2];
+ NTSTATUS status;
+
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, fdpair) == -1) {
+ status = map_nt_error_from_unix(errno);
+ DEBUG(10, ("socketpair() failed: %s\n", strerror(errno)));
+ return status;
+ }
+
+ h->pid = sys_fork();
+
+ if (h->pid == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ if (h->pid == 0) {
+ close(fdpair[0]);
+ preopen_helper(fdpair[1], h->state->to_read);
+ exit(0);
+ }
+ close(fdpair[1]);
+ h->fd = fdpair[0];
+ h->fde = event_add_fd(smbd_event_context(), h->state, h->fd,
+ EVENT_FD_READ, preopen_helper_readable, h);
+ if (h->fde == NULL) {
+ close(h->fd);
+ h->fd = -1;
+ return NT_STATUS_NO_MEMORY;
+ }
+ h->busy = false;
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS preopen_init_helpers(TALLOC_CTX *mem_ctx, size_t to_read,
+ int num_helpers, int queue_max,
+ struct preopen_state **presult)
+{
+ struct preopen_state *result;
+ int i;
+
+ result = talloc(mem_ctx, struct preopen_state);
+ if (result == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ result->num_helpers = num_helpers;
+ result->helpers = TALLOC_ARRAY(result, struct preopen_helper,
+ num_helpers);
+ if (result->helpers == NULL) {
+ TALLOC_FREE(result);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ result->to_read = to_read;
+ result->queue_max = queue_max;
+ result->template_fname = NULL;
+ result->fnum_sent = 0;
+
+ for (i=0; i<num_helpers; i++) {
+ result->helpers[i].state = result;
+ result->helpers[i].fd = -1;
+ }
+
+ talloc_set_destructor(result, preopen_helpers_destructor);
+
+ for (i=0; i<num_helpers; i++) {
+ preopen_init_helper(&result->helpers[i]);
+ }
+
+ *presult = result;
+ return NT_STATUS_OK;
+}
+
+static void preopen_free_helpers(void **ptr)
+{
+ TALLOC_FREE(*ptr);
+}
+
+static struct preopen_state *preopen_state_get(vfs_handle_struct *handle)
+{
+ struct preopen_state *state;
+ NTSTATUS status;
+ const char *namelist;
+
+ if (SMB_VFS_HANDLE_TEST_DATA(handle)) {
+ SMB_VFS_HANDLE_GET_DATA(handle, state, struct preopen_state,
+ return NULL);
+ return state;
+ }
+
+ namelist = lp_parm_const_string(SNUM(handle->conn), "preopen", "names",
+ NULL);
+
+ if (namelist == NULL) {
+ return NULL;
+ }
+
+ status = preopen_init_helpers(
+ NULL,
+ lp_parm_int(SNUM(handle->conn), "preopen", "num_bytes", 1),
+ lp_parm_int(SNUM(handle->conn), "preopen", "helpers", 1),
+ lp_parm_int(SNUM(handle->conn), "preopen", "queuelen", 10),
+ &state);
+ if (!NT_STATUS_IS_OK(status)) {
+ return NULL;
+ }
+
+ set_namearray(&state->preopen_names, (char *)namelist);
+
+ if (state->preopen_names == NULL) {
+ TALLOC_FREE(state);
+ return NULL;
+ }
+
+ if (!SMB_VFS_HANDLE_TEST_DATA(handle)) {
+ SMB_VFS_HANDLE_SET_DATA(handle, state, preopen_free_helpers,
+ struct preopen_state, return NULL);
+ }
+
+ return state;
+}
+
+static bool preopen_parse_fname(const char *fname, unsigned long *pnum,
+ size_t *pstart_idx, int *pnum_digits)
+{
+ const char *p, *q;
+ unsigned long num;
+
+ p = strrchr_m(fname, '/');
+ if (p == NULL) {
+ p = fname;
+ }
+
+ p += 1;
+ while (p[0] != '\0') {
+ if (isdigit(p[0]) && isdigit(p[1]) && isdigit(p[2])) {
+ break;
+ }
+ p += 1;
+ }
+ if (*p == '\0') {
+ /* no digits around */
+ return false;
+ }
+
+ num = strtoul(p, (char **)&q, 10);
+
+ if (num+1 < num) {
+ /* overflow */
+ return false;
+ }
+
+ *pnum = num;
+ *pstart_idx = (p - fname);
+ *pnum_digits = (q - p);
+ return true;
+}
+
+static int preopen_open(vfs_handle_struct *handle, const char *fname,
+ files_struct *fsp, int flags, mode_t mode)
+{
+ struct preopen_state *state;
+ int res;
+ unsigned long num;
+
+ DEBUG(10, ("preopen_open called on %s\n", fname));
+
+ state = preopen_state_get(handle);
+ if (state == NULL) {
+ return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
+ }
+
+ res = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
+ if (res == -1) {
+ return -1;
+ }
+
+ if (flags != O_RDONLY) {
+ return res;
+ }
+
+ if (!is_in_path(fname, state->preopen_names, true)) {
+ DEBUG(10, ("%s does not match the preopen:names list\n",
+ fname));
+ return res;
+ }
+
+ TALLOC_FREE(state->template_fname);
+ state->template_fname = talloc_asprintf(
+ state, "%s/%s", fsp->conn->connectpath, fname);
+
+ if (state->template_fname == NULL) {
+ return res;
+ }
+
+ if (!preopen_parse_fname(state->template_fname, &num,
+ &state->number_start, &state->num_digits)) {
+ TALLOC_FREE(state->template_fname);
+ return res;
+ }
+
+ if (num > state->fnum_sent) {
+ /*
+ * Helpers were too slow, there's no point in reading
+ * files in helpers that we already read in the
+ * parent.
+ */
+ state->fnum_sent = num;
+ }
+
+ if ((state->fnum_queue_end != 0) /* Something was started earlier */
+ && (num < (state->fnum_queue_end - state->queue_max))) {
+ /*
+ * "num" is before the queue we announced. This means
+ * a new run is started.
+ */
+ state->fnum_sent = num;
+ }
+
+ state->fnum_queue_end = num + state->queue_max;
+
+ preopen_queue_run(state);
+
+ return res;
+}
+
+/* VFS operations structure */
+
+static vfs_op_tuple preopen_ops[] = {
+ {SMB_VFS_OP(preopen_open), SMB_VFS_OP_OPEN,
+ SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP,
+ SMB_VFS_LAYER_NOOP}
+};
+
+NTSTATUS vfs_preopen_init(void);
+NTSTATUS vfs_preopen_init(void)
+{
+ return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
+ "preopen", preopen_ops);
+}
subrec->subnet_name, nmb->header.rcode, inet_ntoa(p->ip)));
success = False;
} else {
+ if (!ip_equal_v4(rrec->packet->ip, p->ip)) {
+ DEBUG(5,("register_name_response: Ignoring WINS server response "
+ "from IP %s, for name %s. We sent to IP %s\n",
+ inet_ntoa(p->ip),
+ nmb_namestr(answer_name),
+ inet_ntoa(rrec->packet->ip)));
+ return;
+ }
/* Unicast - check to see if the response allows us to have the name. */
if (nmb->header.opcode == NMB_WACK_OPCODE) {
/* WINS server is telling us to wait. Pretend we didn't get
NTSTATUS result = NT_STATUS_OK;
char *domain = NULL;
char **account_names = NULL;
- char name[256];
enum lsa_SidType *attr_list = NULL;
int i;
if (attrs[i] == SID_NAME_UNKNOWN) {
names[i] = NULL;
} else {
- snprintf(name, sizeof(name), "%s%c%s", domain,
- *lp_winbind_separator(), account_names[i]);
- names[i] = talloc_strdup(names, name);
+ names[i] = talloc_strdup(names, account_names[i]);
+ if (names[i] == NULL) {
+ result = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
}
}
done:
TALLOC_FREE(account_names);
TALLOC_FREE(domain);
- TALLOC_FREE(attrs);
+ TALLOC_FREE(attr_list);
return result;
}
***************************************************************************/
uint32 print_job_start(struct auth_serversupplied_info *server_info, int snum,
- char *jobname, NT_DEVICEMODE *nt_devmode )
+ const char *jobname, NT_DEVICEMODE *nt_devmode )
{
uint32 jobid;
char *path;
if (cli == NULL) {
return false;
}
- E_md4hash(cli->pwd.password, nt_hash);
+ E_md4hash(cli->password ? cli->password : "", nt_hash);
return true;
}
status = rpccli_ntlmssp_bind_data(
result, auth_type, auth_level, domain, username,
- cli->pwd.null_pwd ? NULL : password, &auth);
+ password, &auth);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("rpccli_ntlmssp_bind_data returned %s\n",
nt_errstr(status)));
return werror;
}
-/*********************************************************************
- Decode various spoolss rpc's and info levels
- ********************************************************************/
-
-/**********************************************************************
-**********************************************************************/
-
-static bool decode_printer_info_0(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
- uint32 returned, PRINTER_INFO_0 **info)
-{
- uint32 i;
- PRINTER_INFO_0 *inf;
-
- if (returned) {
- inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_0, returned);
- if (!inf) {
- return False;
- }
- memset(inf, 0, returned*sizeof(PRINTER_INFO_0));
- } else {
- inf = NULL;
- }
-
- prs_set_offset(&buffer->prs,0);
-
- for (i=0; i<returned; i++) {
- if (!smb_io_printer_info_0("", buffer, &inf[i], 0)) {
- return False;
- }
- }
-
- *info=inf;
- return True;
-}
-
-/**********************************************************************
-**********************************************************************/
-
-static bool decode_printer_info_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
- uint32 returned, PRINTER_INFO_1 **info)
-{
- uint32 i;
- PRINTER_INFO_1 *inf;
-
- if (returned) {
- inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_1, returned);
- if (!inf) {
- return False;
- }
- memset(inf, 0, returned*sizeof(PRINTER_INFO_1));
- } else {
- inf = NULL;
- }
-
- prs_set_offset(&buffer->prs,0);
-
- for (i=0; i<returned; i++) {
- if (!smb_io_printer_info_1("", buffer, &inf[i], 0)) {
- return False;
- }
- }
-
- *info=inf;
- return True;
-}
-
/**********************************************************************
+ convencience wrapper around rpccli_spoolss_EnumJobs
**********************************************************************/
-static bool decode_printer_info_2(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
- uint32 returned, PRINTER_INFO_2 **info)
+WERROR rpccli_spoolss_enumjobs(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ uint32_t firstjob,
+ uint32_t numjobs,
+ uint32_t level,
+ uint32_t offered,
+ uint32_t *count,
+ union spoolss_JobInfo **info)
{
- uint32 i;
- PRINTER_INFO_2 *inf;
-
- if (returned) {
- inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_2, returned);
- if (!inf) {
- return False;
- }
- memset(inf, 0, returned*sizeof(PRINTER_INFO_2));
- } else {
- inf = NULL;
- }
-
- prs_set_offset(&buffer->prs,0);
-
- for (i=0; i<returned; i++) {
- /* a little initialization as we go */
- inf[i].secdesc = NULL;
- if (!smb_io_printer_info_2("", buffer, &inf[i], 0)) {
- return False;
- }
- }
-
- *info=inf;
- return True;
-}
-
-/**********************************************************************
-**********************************************************************/
-
-static bool decode_printer_info_3(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
- uint32 returned, PRINTER_INFO_3 **info)
-{
- uint32 i;
- PRINTER_INFO_3 *inf;
-
- if (returned) {
- inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_3, returned);
- if (!inf) {
- return False;
- }
- memset(inf, 0, returned*sizeof(PRINTER_INFO_3));
- } else {
- inf = NULL;
- }
-
- prs_set_offset(&buffer->prs,0);
-
- for (i=0; i<returned; i++) {
- inf[i].secdesc = NULL;
- if (!smb_io_printer_info_3("", buffer, &inf[i], 0)) {
- return False;
- }
- }
-
- *info=inf;
- return True;
-}
-
-/**********************************************************************
-**********************************************************************/
-
-static bool decode_printer_driver_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
- uint32 returned, DRIVER_INFO_1 **info)
-{
- uint32 i;
- DRIVER_INFO_1 *inf;
-
- if (returned) {
- inf=TALLOC_ARRAY(mem_ctx, DRIVER_INFO_1, returned);
- if (!inf) {
- return False;
- }
- memset(inf, 0, returned*sizeof(DRIVER_INFO_1));
- } else {
- inf = NULL;
- }
-
- prs_set_offset(&buffer->prs,0);
-
- for (i=0; i<returned; i++) {
- if (!smb_io_printer_driver_info_1("", buffer, &(inf[i]), 0)) {
- return False;
- }
- }
-
- *info=inf;
- return True;
-}
-
-/**********************************************************************
-**********************************************************************/
-
-static bool decode_printer_driver_2(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
- uint32 returned, DRIVER_INFO_2 **info)
-{
- uint32 i;
- DRIVER_INFO_2 *inf;
-
- if (returned) {
- inf=TALLOC_ARRAY(mem_ctx, DRIVER_INFO_2, returned);
- if (!inf) {
- return False;
- }
- memset(inf, 0, returned*sizeof(DRIVER_INFO_2));
- } else {
- inf = NULL;
- }
-
- prs_set_offset(&buffer->prs,0);
+ NTSTATUS status;
+ WERROR werror;
+ uint32_t needed;
+ DATA_BLOB buffer;
- for (i=0; i<returned; i++) {
- if (!smb_io_printer_driver_info_2("", buffer, &(inf[i]), 0)) {
- return False;
- }
+ if (offered > 0) {
+ buffer = data_blob_talloc_zero(mem_ctx, offered);
+ W_ERROR_HAVE_NO_MEMORY(buffer.data);
}
- *info=inf;
- return True;
-}
-
-/**********************************************************************
-**********************************************************************/
-
-static bool decode_printer_driver_3(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
- uint32 returned, DRIVER_INFO_3 **info)
-{
- uint32 i;
- DRIVER_INFO_3 *inf;
+ status = rpccli_spoolss_EnumJobs(cli, mem_ctx,
+ handle,
+ firstjob,
+ numjobs,
+ level,
+ (offered > 0) ? &buffer : NULL,
+ offered,
+ count,
+ info,
+ &needed,
+ &werror);
- if (returned) {
- inf=TALLOC_ARRAY(mem_ctx, DRIVER_INFO_3, returned);
- if (!inf) {
- return False;
- }
- memset(inf, 0, returned*sizeof(DRIVER_INFO_3));
- } else {
- inf = NULL;
- }
-
- prs_set_offset(&buffer->prs,0);
+ if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
+ offered = needed;
+ buffer = data_blob_talloc_zero(mem_ctx, needed);
+ W_ERROR_HAVE_NO_MEMORY(buffer.data);
- for (i=0; i<returned; i++) {
- if (!smb_io_printer_driver_info_3("", buffer, &(inf[i]), 0)) {
- return False;
- }
+ status = rpccli_spoolss_EnumJobs(cli, mem_ctx,
+ handle,
+ firstjob,
+ numjobs,
+ level,
+ (offered > 0) ? &buffer : NULL,
+ offered,
+ count,
+ info,
+ &needed,
+ &werror);
}
- *info=inf;
- return True;
+ return werror;
}
/**********************************************************************
+ convencience wrapper around rpccli_spoolss_EnumPrinterDrivers
**********************************************************************/
-static bool decode_jobs_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
- uint32 num_jobs, JOB_INFO_1 **jobs)
+WERROR rpccli_spoolss_enumprinterdrivers(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ const char *server,
+ const char *environment,
+ uint32_t level,
+ uint32_t offered,
+ uint32_t *count,
+ union spoolss_DriverInfo **info)
{
- uint32 i;
-
- if (num_jobs) {
- *jobs = TALLOC_ARRAY(mem_ctx, JOB_INFO_1, num_jobs);
- if (*jobs == NULL) {
- return False;
- }
- } else {
- *jobs = NULL;
- }
- prs_set_offset(&buffer->prs,0);
+ NTSTATUS status;
+ WERROR werror;
+ uint32_t needed;
+ DATA_BLOB buffer;
- for (i = 0; i < num_jobs; i++) {
- if (!smb_io_job_info_1("", buffer, &((*jobs)[i]), 0)) {
- return False;
- }
+ if (offered > 0) {
+ buffer = data_blob_talloc_zero(mem_ctx, offered);
+ W_ERROR_HAVE_NO_MEMORY(buffer.data);
}
- return True;
-}
-
-/**********************************************************************
-**********************************************************************/
-
-static bool decode_jobs_2(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
- uint32 num_jobs, JOB_INFO_2 **jobs)
-{
- uint32 i;
+ status = rpccli_spoolss_EnumPrinterDrivers(cli, mem_ctx,
+ server,
+ environment,
+ level,
+ (offered > 0) ? &buffer : NULL,
+ offered,
+ count,
+ info,
+ &needed,
+ &werror);
- if (num_jobs) {
- *jobs = TALLOC_ARRAY(mem_ctx, JOB_INFO_2, num_jobs);
- if (*jobs == NULL) {
- return False;
- }
- } else {
- *jobs = NULL;
- }
- prs_set_offset(&buffer->prs,0);
+ if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
+ offered = needed;
+ buffer = data_blob_talloc_zero(mem_ctx, needed);
+ W_ERROR_HAVE_NO_MEMORY(buffer.data);
- for (i = 0; i < num_jobs; i++) {
- if (!smb_io_job_info_2("", buffer, &((*jobs)[i]), 0)) {
- return False;
- }
+ status = rpccli_spoolss_EnumPrinterDrivers(cli, mem_ctx,
+ server,
+ environment,
+ level,
+ (offered > 0) ? &buffer : NULL,
+ offered,
+ count,
+ info,
+ &needed,
+ &werror);
}
- return True;
+ return werror;
}
/**********************************************************************
+ convencience wrapper around rpccli_spoolss_EnumPrinters
**********************************************************************/
-WERROR rpccli_spoolss_enum_printers(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- char *name, uint32 flags, uint32 level,
- uint32 *num_printers, PRINTER_INFO_CTR *ctr)
+WERROR rpccli_spoolss_enumprinters(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ uint32_t flags,
+ const char *server,
+ uint32_t level,
+ uint32_t offered,
+ uint32_t *count,
+ union spoolss_PrinterInfo **info)
{
- prs_struct qbuf, rbuf;
- SPOOL_Q_ENUMPRINTERS in;
- SPOOL_R_ENUMPRINTERS out;
- RPC_BUFFER buffer;
- uint32 offered;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- offered = 0;
- if (!rpcbuf_init(&buffer, offered, mem_ctx))
- return WERR_NOMEM;
- make_spoolss_q_enumprinters( &in, flags, name, level, &buffer, offered );
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMPRINTERS,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_enumprinters,
- spoolss_io_r_enumprinters,
- WERR_GENERAL_FAILURE );
-
- if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
- offered = out.needed;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- if (!rpcbuf_init(&buffer, offered, mem_ctx))
- return WERR_NOMEM;
- make_spoolss_q_enumprinters( &in, flags, name, level, &buffer, offered );
+ NTSTATUS status;
+ WERROR werror;
+ uint32_t needed;
+ DATA_BLOB buffer;
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMPRINTERS,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_enumprinters,
- spoolss_io_r_enumprinters,
- WERR_GENERAL_FAILURE );
+ if (offered > 0) {
+ buffer = data_blob_talloc_zero(mem_ctx, offered);
+ W_ERROR_HAVE_NO_MEMORY(buffer.data);
}
- if ( !W_ERROR_IS_OK(out.status) )
- return out.status;
-
- switch (level) {
- case 0:
- if (!decode_printer_info_0(mem_ctx, out.buffer, out.returned, &ctr->printers_0)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- case 1:
- if (!decode_printer_info_1(mem_ctx, out.buffer, out.returned, &ctr->printers_1)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- case 2:
- if (!decode_printer_info_2(mem_ctx, out.buffer, out.returned, &ctr->printers_2)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- case 3:
- if (!decode_printer_info_3(mem_ctx, out.buffer, out.returned, &ctr->printers_3)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- default:
- return WERR_UNKNOWN_LEVEL;
- }
-
- *num_printers = out.returned;
-
- return out.status;
-}
-
-/**********************************************************************
-**********************************************************************/
-
-WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- uint32 level, const char *env,
- uint32 *num_drivers,
- PRINTER_DRIVER_CTR *ctr)
-{
- prs_struct qbuf, rbuf;
- SPOOL_Q_ENUMPRINTERDRIVERS in;
- SPOOL_R_ENUMPRINTERDRIVERS out;
- RPC_BUFFER buffer;
- fstring server;
- uint32 offered;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
- strupper_m(server);
-
- offered = 0;
- if (!rpcbuf_init(&buffer, offered, mem_ctx))
- return WERR_NOMEM;
- make_spoolss_q_enumprinterdrivers( &in, server, env, level,
- &buffer, offered);
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMPRINTERDRIVERS,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_enumprinterdrivers,
- spoolss_io_r_enumprinterdrivers,
- WERR_GENERAL_FAILURE );
+ status = rpccli_spoolss_EnumPrinters(cli, mem_ctx,
+ flags,
+ server,
+ level,
+ (offered > 0) ? &buffer : NULL,
+ offered,
+ count,
+ info,
+ &needed,
+ &werror);
- if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
- offered = out.needed;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- if (!rpcbuf_init(&buffer, offered, mem_ctx))
- return WERR_NOMEM;
- make_spoolss_q_enumprinterdrivers( &in, server, env, level,
- &buffer, offered);
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMPRINTERDRIVERS,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_enumprinterdrivers,
- spoolss_io_r_enumprinterdrivers,
- WERR_GENERAL_FAILURE );
- }
-
- *num_drivers = out.returned;
+ if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
+ offered = needed;
+ buffer = data_blob_talloc_zero(mem_ctx, needed);
+ W_ERROR_HAVE_NO_MEMORY(buffer.data);
- if ( !W_ERROR_IS_OK(out.status) )
- return out.status;
-
- if ( out.returned ) {
-
- switch (level) {
- case 1:
- if (!decode_printer_driver_1(mem_ctx, out.buffer, out.returned, &ctr->info1)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- case 2:
- if (!decode_printer_driver_2(mem_ctx, out.buffer, out.returned, &ctr->info2)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- case 3:
- if (!decode_printer_driver_3(mem_ctx, out.buffer, out.returned, &ctr->info3)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- default:
- return WERR_UNKNOWN_LEVEL;
- }
+ status = rpccli_spoolss_EnumPrinters(cli, mem_ctx,
+ flags,
+ server,
+ level,
+ (offered > 0) ? &buffer : NULL,
+ offered,
+ count,
+ info,
+ &needed,
+ &werror);
}
- return out.status;
+ return werror;
}
-/**********************************************************************
-**********************************************************************/
-
-WERROR rpccli_spoolss_enumjobs(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *hnd, uint32 level, uint32 firstjob,
- uint32 num_jobs, uint32 *returned, JOB_INFO_CTR *ctr)
-{
- prs_struct qbuf, rbuf;
- SPOOL_Q_ENUMJOBS in;
- SPOOL_R_ENUMJOBS out;
- RPC_BUFFER buffer;
- uint32 offered;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- offered = 0;
- if (!rpcbuf_init(&buffer, offered, mem_ctx))
- return WERR_NOMEM;
- make_spoolss_q_enumjobs( &in, hnd, firstjob, num_jobs, level,
- &buffer, offered );
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMJOBS,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_enumjobs,
- spoolss_io_r_enumjobs,
- WERR_GENERAL_FAILURE );
-
- if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
- offered = out.needed;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- if (!rpcbuf_init(&buffer, offered, mem_ctx))
- return WERR_NOMEM;
- make_spoolss_q_enumjobs( &in, hnd, firstjob, num_jobs, level,
- &buffer, offered );
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMJOBS,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_enumjobs,
- spoolss_io_r_enumjobs,
- WERR_GENERAL_FAILURE );
- }
-
- if (!W_ERROR_IS_OK(out.status))
- return out.status;
-
- switch(level) {
- case 1:
- if (!decode_jobs_1(mem_ctx, out.buffer, out.returned, &ctr->job.job_info_1)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- case 2:
- if (!decode_jobs_2(mem_ctx, out.buffer, out.returned, &ctr->job.job_info_2)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- default:
- DEBUG(3, ("unsupported info level %d", level));
- return WERR_UNKNOWN_LEVEL;
- }
-
- *returned = out.returned;
-
- return out.status;
-}
+/*********************************************************************
+ Decode various spoolss rpc's and info levels
+ ********************************************************************/
/**********************************************************************
**********************************************************************/
}
/*******************************************************************
- * return the length of a uint16 (obvious, but the code is clean)
- ********************************************************************/
-
-static uint32 size_of_uint16(uint16 *value)
-{
- return (sizeof(*value));
-}
-
-/*******************************************************************
- * return the length of a uint32 (obvious, but the code is clean)
- ********************************************************************/
-
-static uint32 size_of_uint32(uint32 *value)
-{
- return (sizeof(*value));
-}
-
-/*******************************************************************
- * return the length of a NTTIME (obvious, but the code is clean)
- ********************************************************************/
-
-static uint32 size_of_nttime(NTTIME *value)
-{
- return (sizeof(*value));
-}
-
-/*******************************************************************
- * return the length of a uint32 (obvious, but the code is clean)
- ********************************************************************/
-
-static uint32 size_of_device_mode(DEVICEMODE *devmode)
-{
- if (devmode==NULL)
- return (4);
- else
- return (4+devmode->size+devmode->driverextra);
-}
-
-/*******************************************************************
- * return the length of a uint32 (obvious, but the code is clean)
- ********************************************************************/
-
-static uint32 size_of_systemtime(SYSTEMTIME *systime)
-{
- if (systime==NULL)
- return (4);
- else
- return (sizeof(SYSTEMTIME) +4);
-}
-
-/*******************************************************************
- Parse a DEVMODE structure and its relative pointer.
-********************************************************************/
-
-static bool smb_io_reldevmode(const char *desc, RPC_BUFFER *buffer, int depth, DEVICEMODE **devmode)
-{
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_reldevmode");
- depth++;
-
- if (MARSHALLING(ps)) {
- uint32 struct_offset = prs_offset(ps);
- uint32 relative_offset;
-
- if (*devmode == NULL) {
- relative_offset=0;
- if (!prs_uint32("offset", ps, depth, &relative_offset))
- return False;
- DEBUG(8, ("boing, the devmode was NULL\n"));
-
- return True;
- }
-
- buffer->string_at_end -= ((*devmode)->size + (*devmode)->driverextra);
-
- /* mz: we have to align the device mode for VISTA */
- if (buffer->string_at_end % 4) {
- buffer->string_at_end += 4 - (buffer->string_at_end % 4);
- }
-
- if(!prs_set_offset(ps, buffer->string_at_end))
- return False;
-
- /* write the DEVMODE */
- if (!spoolss_io_devmode(desc, ps, depth, *devmode))
- return False;
-
- if(!prs_set_offset(ps, struct_offset))
- return False;
-
- relative_offset=buffer->string_at_end - buffer->struct_start;
- /* write its offset */
- if (!prs_uint32("offset", ps, depth, &relative_offset))
- return False;
- }
- else {
- uint32 old_offset;
-
- /* read the offset */
- if (!prs_uint32("offset", ps, depth, &buffer->string_at_end))
- return False;
- if (buffer->string_at_end == 0) {
- *devmode = NULL;
- return True;
- }
-
- old_offset = prs_offset(ps);
- if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start))
- return False;
-
- /* read the string */
- if((*devmode=PRS_ALLOC_MEM(ps,DEVICEMODE,1)) == NULL)
- return False;
- if (!spoolss_io_devmode(desc, ps, depth, *devmode))
- return False;
-
- if(!prs_set_offset(ps, old_offset))
- return False;
- }
- return True;
-}
-
-/*******************************************************************
- Parse a PRINTER_INFO_0 structure.
-********************************************************************/
-
-bool smb_io_printer_info_0(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_0 *info, int depth)
-{
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_printer_info_0");
- depth++;
-
- buffer->struct_start=prs_offset(ps);
-
- if (!smb_io_relstr("printername", buffer, depth, &info->printername))
- return False;
- if (!smb_io_relstr("servername", buffer, depth, &info->servername))
- return False;
-
- if(!prs_uint32("cjobs", ps, depth, &info->cjobs))
- return False;
- if(!prs_uint32("total_jobs", ps, depth, &info->total_jobs))
- return False;
- if(!prs_uint32("total_bytes", ps, depth, &info->total_bytes))
- return False;
-
- if(!prs_uint16("year", ps, depth, &info->year))
- return False;
- if(!prs_uint16("month", ps, depth, &info->month))
- return False;
- if(!prs_uint16("dayofweek", ps, depth, &info->dayofweek))
- return False;
- if(!prs_uint16("day", ps, depth, &info->day))
- return False;
- if(!prs_uint16("hour", ps, depth, &info->hour))
- return False;
- if(!prs_uint16("minute", ps, depth, &info->minute))
- return False;
- if(!prs_uint16("second", ps, depth, &info->second))
- return False;
- if(!prs_uint16("milliseconds", ps, depth, &info->milliseconds))
- return False;
-
- if(!prs_uint32("global_counter", ps, depth, &info->global_counter))
- return False;
- if(!prs_uint32("total_pages", ps, depth, &info->total_pages))
- return False;
-
- if(!prs_uint16("major_version", ps, depth, &info->major_version))
- return False;
- if(!prs_uint16("build_version", ps, depth, &info->build_version))
- return False;
- if(!prs_uint32("unknown7", ps, depth, &info->unknown7))
- return False;
- if(!prs_uint32("unknown8", ps, depth, &info->unknown8))
- return False;
- if(!prs_uint32("unknown9", ps, depth, &info->unknown9))
- return False;
- if(!prs_uint32("session_counter", ps, depth, &info->session_counter))
- return False;
- if(!prs_uint32("unknown11", ps, depth, &info->unknown11))
- return False;
- if(!prs_uint32("printer_errors", ps, depth, &info->printer_errors))
- return False;
- if(!prs_uint32("unknown13", ps, depth, &info->unknown13))
- return False;
- if(!prs_uint32("unknown14", ps, depth, &info->unknown14))
- return False;
- if(!prs_uint32("unknown15", ps, depth, &info->unknown15))
- return False;
- if(!prs_uint32("unknown16", ps, depth, &info->unknown16))
- return False;
- if(!prs_uint32("change_id", ps, depth, &info->change_id))
- return False;
- if(!prs_uint32("unknown18", ps, depth, &info->unknown18))
- return False;
- if(!prs_uint32("status" , ps, depth, &info->status))
- return False;
- if(!prs_uint32("unknown20", ps, depth, &info->unknown20))
- return False;
- if(!prs_uint32("c_setprinter", ps, depth, &info->c_setprinter))
- return False;
- if(!prs_uint16("unknown22", ps, depth, &info->unknown22))
- return False;
- if(!prs_uint16("unknown23", ps, depth, &info->unknown23))
- return False;
- if(!prs_uint16("unknown24", ps, depth, &info->unknown24))
- return False;
- if(!prs_uint16("unknown25", ps, depth, &info->unknown25))
- return False;
- if(!prs_uint16("unknown26", ps, depth, &info->unknown26))
- return False;
- if(!prs_uint16("unknown27", ps, depth, &info->unknown27))
- return False;
- if(!prs_uint16("unknown28", ps, depth, &info->unknown28))
- return False;
- if(!prs_uint16("unknown29", ps, depth, &info->unknown29))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a PRINTER_INFO_1 structure.
-********************************************************************/
-
-bool smb_io_printer_info_1(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_1 *info, int depth)
-{
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_printer_info_1");
- depth++;
-
- buffer->struct_start=prs_offset(ps);
-
- if (!prs_uint32("flags", ps, depth, &info->flags))
- return False;
- if (!smb_io_relstr("description", buffer, depth, &info->description))
- return False;
- if (!smb_io_relstr("name", buffer, depth, &info->name))
- return False;
- if (!smb_io_relstr("comment", buffer, depth, &info->comment))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a PRINTER_INFO_2 structure.
-********************************************************************/
-
-bool smb_io_printer_info_2(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_2 *info, int depth)
-{
- prs_struct *ps=&buffer->prs;
- uint32 dm_offset, sd_offset, current_offset;
- uint32 dummy_value = 0, has_secdesc = 0;
-
- prs_debug(ps, depth, desc, "smb_io_printer_info_2");
- depth++;
-
- buffer->struct_start=prs_offset(ps);
-
- if (!smb_io_relstr("servername", buffer, depth, &info->servername))
- return False;
- if (!smb_io_relstr("printername", buffer, depth, &info->printername))
- return False;
- if (!smb_io_relstr("sharename", buffer, depth, &info->sharename))
- return False;
- if (!smb_io_relstr("portname", buffer, depth, &info->portname))
- return False;
- if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
- return False;
- if (!smb_io_relstr("comment", buffer, depth, &info->comment))
- return False;
- if (!smb_io_relstr("location", buffer, depth, &info->location))
- return False;
-
- /* save current offset and wind forwared by a uint32 */
- dm_offset = prs_offset(ps);
- if (!prs_uint32("devmode", ps, depth, &dummy_value))
- return False;
-
- if (!smb_io_relstr("sepfile", buffer, depth, &info->sepfile))
- return False;
- if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
- return False;
- if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
- return False;
- if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
- return False;
-
- /* save current offset for the sec_desc */
- sd_offset = prs_offset(ps);
- if (!prs_uint32("sec_desc", ps, depth, &has_secdesc))
- return False;
-
-
- /* save current location so we can pick back up here */
- current_offset = prs_offset(ps);
-
- /* parse the devmode */
- if (!prs_set_offset(ps, dm_offset))
- return False;
- if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
- return False;
-
- /* parse the sec_desc */
- if (info->secdesc) {
- if (!prs_set_offset(ps, sd_offset))
- return False;
- if (!smb_io_relsecdesc("secdesc", buffer, depth, &info->secdesc))
- return False;
- }
-
- /* pick up where we left off */
- if (!prs_set_offset(ps, current_offset))
- return False;
-
- if (!prs_uint32("attributes", ps, depth, &info->attributes))
- return False;
- if (!prs_uint32("priority", ps, depth, &info->priority))
- return False;
- if (!prs_uint32("defpriority", ps, depth, &info->defaultpriority))
- return False;
- if (!prs_uint32("starttime", ps, depth, &info->starttime))
- return False;
- if (!prs_uint32("untiltime", ps, depth, &info->untiltime))
- return False;
- if (!prs_uint32("status", ps, depth, &info->status))
- return False;
- if (!prs_uint32("jobs", ps, depth, &info->cjobs))
- return False;
- if (!prs_uint32("averageppm", ps, depth, &info->averageppm))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a PRINTER_INFO_3 structure.
-********************************************************************/
-
-bool smb_io_printer_info_3(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_3 *info, int depth)
-{
- uint32 offset = 0;
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_printer_info_3");
- depth++;
-
- buffer->struct_start=prs_offset(ps);
-
- if (MARSHALLING(ps)) {
- /* Ensure the SD is 8 byte aligned in the buffer. */
- uint32 start = prs_offset(ps); /* Remember the start position. */
- uint32 off_val = 0;
-
- /* Write a dummy value. */
- if (!prs_uint32("offset", ps, depth, &off_val))
- return False;
-
- /* 8 byte align. */
- if (!prs_align_uint64(ps))
- return False;
-
- /* Remember where we must seek back to write the SD. */
- offset = prs_offset(ps);
-
- /* Calculate the real offset for the SD. */
-
- off_val = offset - start;
-
- /* Seek back to where we store the SD offset & store. */
- prs_set_offset(ps, start);
- if (!prs_uint32("offset", ps, depth, &off_val))
- return False;
-
- /* Return to after the 8 byte align. */
- prs_set_offset(ps, offset);
-
- } else {
- if (!prs_uint32("offset", ps, depth, &offset))
- return False;
- /* Seek within the buffer. */
- if (!prs_set_offset(ps, offset))
- return False;
- }
- if (!sec_io_desc("sec_desc", &info->secdesc, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a PRINTER_INFO_4 structure.
-********************************************************************/
-
-bool smb_io_printer_info_4(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_4 *info, int depth)
-{
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_printer_info_4");
- depth++;
-
- buffer->struct_start=prs_offset(ps);
-
- if (!smb_io_relstr("printername", buffer, depth, &info->printername))
- return False;
- if (!smb_io_relstr("servername", buffer, depth, &info->servername))
- return False;
- if (!prs_uint32("attributes", ps, depth, &info->attributes))
- return False;
- return True;
-}
-
-/*******************************************************************
- Parse a PRINTER_INFO_5 structure.
-********************************************************************/
-
-bool smb_io_printer_info_5(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_5 *info, int depth)
-{
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_printer_info_5");
- depth++;
-
- buffer->struct_start=prs_offset(ps);
-
- if (!smb_io_relstr("printername", buffer, depth, &info->printername))
- return False;
- if (!smb_io_relstr("portname", buffer, depth, &info->portname))
- return False;
- if (!prs_uint32("attributes", ps, depth, &info->attributes))
- return False;
- if (!prs_uint32("device_not_selected_timeout", ps, depth, &info->device_not_selected_timeout))
- return False;
- if (!prs_uint32("transmission_retry_timeout", ps, depth, &info->transmission_retry_timeout))
- return False;
- return True;
-}
-
-/*******************************************************************
- Parse a PRINTER_INFO_6 structure.
-********************************************************************/
-
-bool smb_io_printer_info_6(const char *desc, RPC_BUFFER *buffer,
- PRINTER_INFO_6 *info, int depth)
-{
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_printer_info_6");
- depth++;
-
- if (!prs_uint32("status", ps, depth, &info->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a PRINTER_INFO_7 structure.
-********************************************************************/
-
-bool smb_io_printer_info_7(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_7 *info, int depth)
-{
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_printer_info_7");
- depth++;
-
- buffer->struct_start=prs_offset(ps);
-
- if (!smb_io_relstr("guid", buffer, depth, &info->guid))
- return False;
- if (!prs_uint32("action", ps, depth, &info->action))
- return False;
- return True;
-}
-
-/*******************************************************************
- Parse a DRIVER_INFO_1 structure.
-********************************************************************/
-
-bool smb_io_printer_driver_info_1(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_1 *info, int depth)
-{
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_printer_driver_info_1");
- depth++;
-
- buffer->struct_start=prs_offset(ps);
-
- if (!smb_io_relstr("name", buffer, depth, &info->name))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a DRIVER_INFO_2 structure.
-********************************************************************/
-
-bool smb_io_printer_driver_info_2(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_2 *info, int depth)
-{
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_printer_driver_info_2");
- depth++;
-
- buffer->struct_start=prs_offset(ps);
-
- if (!prs_uint32("version", ps, depth, &info->version))
- return False;
- if (!smb_io_relstr("name", buffer, depth, &info->name))
- return False;
- if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
- return False;
- if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
- return False;
- if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
- return False;
- if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a DRIVER_INFO_3 structure.
-********************************************************************/
-
-bool smb_io_printer_driver_info_3(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_3 *info, int depth)
-{
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_printer_driver_info_3");
- depth++;
-
- buffer->struct_start=prs_offset(ps);
-
- if (!prs_uint32("version", ps, depth, &info->version))
- return False;
- if (!smb_io_relstr("name", buffer, depth, &info->name))
- return False;
- if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
- return False;
- if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
- return False;
- if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
- return False;
- if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
- return False;
- if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
- return False;
-
- if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
- return False;
-
- if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
- return False;
- if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a DRIVER_INFO_6 structure.
-********************************************************************/
-
-bool smb_io_printer_driver_info_6(const char *desc, RPC_BUFFER *buffer, DRIVER_INFO_6 *info, int depth)
-{
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_printer_driver_info_6");
- depth++;
-
- buffer->struct_start=prs_offset(ps);
-
- if (!prs_uint32("version", ps, depth, &info->version))
- return False;
- if (!smb_io_relstr("name", buffer, depth, &info->name))
- return False;
- if (!smb_io_relstr("architecture", buffer, depth, &info->architecture))
- return False;
- if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath))
- return False;
- if (!smb_io_relstr("datafile", buffer, depth, &info->datafile))
- return False;
- if (!smb_io_relstr("configfile", buffer, depth, &info->configfile))
- return False;
- if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile))
- return False;
-
- if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles))
- return False;
-
- if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname))
- return False;
- if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype))
- return False;
-
- if (!smb_io_relarraystr("previousdrivernames", buffer, depth, &info->previousdrivernames))
- return False;
-
- if (!prs_uint64("date", ps, depth, &info->driver_date))
- return False;
-
- if (!prs_uint32("padding", ps, depth, &info->padding))
- return False;
-
- if (!prs_uint32("driver_version_low", ps, depth, &info->driver_version_low))
- return False;
-
- if (!prs_uint32("driver_version_high", ps, depth, &info->driver_version_high))
- return False;
-
- if (!smb_io_relstr("mfgname", buffer, depth, &info->mfgname))
- return False;
- if (!smb_io_relstr("oem_url", buffer, depth, &info->oem_url))
- return False;
- if (!smb_io_relstr("hardware_id", buffer, depth, &info->hardware_id))
- return False;
- if (!smb_io_relstr("provider", buffer, depth, &info->provider))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a JOB_INFO_1 structure.
-********************************************************************/
-
-bool smb_io_job_info_1(const char *desc, RPC_BUFFER *buffer, JOB_INFO_1 *info, int depth)
-{
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_job_info_1");
- depth++;
-
- buffer->struct_start=prs_offset(ps);
-
- if (!prs_uint32("jobid", ps, depth, &info->jobid))
- return False;
- if (!smb_io_relstr("printername", buffer, depth, &info->printername))
- return False;
- if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
- return False;
- if (!smb_io_relstr("username", buffer, depth, &info->username))
- return False;
- if (!smb_io_relstr("document", buffer, depth, &info->document))
- return False;
- if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
- return False;
- if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
- return False;
- if (!prs_uint32("status", ps, depth, &info->status))
- return False;
- if (!prs_uint32("priority", ps, depth, &info->priority))
- return False;
- if (!prs_uint32("position", ps, depth, &info->position))
- return False;
- if (!prs_uint32("totalpages", ps, depth, &info->totalpages))
- return False;
- if (!prs_uint32("pagesprinted", ps, depth, &info->pagesprinted))
- return False;
- if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a JOB_INFO_2 structure.
-********************************************************************/
-
-bool smb_io_job_info_2(const char *desc, RPC_BUFFER *buffer, JOB_INFO_2 *info, int depth)
-{
- uint32 pipo=0;
- prs_struct *ps=&buffer->prs;
-
- prs_debug(ps, depth, desc, "smb_io_job_info_2");
- depth++;
-
- buffer->struct_start=prs_offset(ps);
-
- if (!prs_uint32("jobid",ps, depth, &info->jobid))
- return False;
- if (!smb_io_relstr("printername", buffer, depth, &info->printername))
- return False;
- if (!smb_io_relstr("machinename", buffer, depth, &info->machinename))
- return False;
- if (!smb_io_relstr("username", buffer, depth, &info->username))
- return False;
- if (!smb_io_relstr("document", buffer, depth, &info->document))
- return False;
- if (!smb_io_relstr("notifyname", buffer, depth, &info->notifyname))
- return False;
- if (!smb_io_relstr("datatype", buffer, depth, &info->datatype))
- return False;
-
- if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor))
- return False;
- if (!smb_io_relstr("parameters", buffer, depth, &info->parameters))
- return False;
- if (!smb_io_relstr("drivername", buffer, depth, &info->drivername))
- return False;
- if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode))
- return False;
- if (!smb_io_relstr("text_status", buffer, depth, &info->text_status))
- return False;
-
-/* SEC_DESC sec_desc;*/
- if (!prs_uint32("Hack! sec desc", ps, depth, &pipo))
- return False;
-
- if (!prs_uint32("status",ps, depth, &info->status))
- return False;
- if (!prs_uint32("priority",ps, depth, &info->priority))
- return False;
- if (!prs_uint32("position",ps, depth, &info->position))
- return False;
- if (!prs_uint32("starttime",ps, depth, &info->starttime))
- return False;
- if (!prs_uint32("untiltime",ps, depth, &info->untiltime))
- return False;
- if (!prs_uint32("totalpages",ps, depth, &info->totalpages))
- return False;
- if (!prs_uint32("size",ps, depth, &info->size))
- return False;
- if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted) )
- return False;
- if (!prs_uint32("timeelapsed",ps, depth, &info->timeelapsed))
- return False;
- if (!prs_uint32("pagesprinted",ps, depth, &info->pagesprinted))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info)
-{
- int size=0;
-
- size+=size_of_relative_string( &info->printername );
- size+=size_of_relative_string( &info->servername );
-
- size+=size_of_uint32( &info->cjobs);
- size+=size_of_uint32( &info->total_jobs);
- size+=size_of_uint32( &info->total_bytes);
-
- size+=size_of_uint16( &info->year);
- size+=size_of_uint16( &info->month);
- size+=size_of_uint16( &info->dayofweek);
- size+=size_of_uint16( &info->day);
- size+=size_of_uint16( &info->hour);
- size+=size_of_uint16( &info->minute);
- size+=size_of_uint16( &info->second);
- size+=size_of_uint16( &info->milliseconds);
-
- size+=size_of_uint32( &info->global_counter);
- size+=size_of_uint32( &info->total_pages);
-
- size+=size_of_uint16( &info->major_version);
- size+=size_of_uint16( &info->build_version);
-
- size+=size_of_uint32( &info->unknown7);
- size+=size_of_uint32( &info->unknown8);
- size+=size_of_uint32( &info->unknown9);
- size+=size_of_uint32( &info->session_counter);
- size+=size_of_uint32( &info->unknown11);
- size+=size_of_uint32( &info->printer_errors);
- size+=size_of_uint32( &info->unknown13);
- size+=size_of_uint32( &info->unknown14);
- size+=size_of_uint32( &info->unknown15);
- size+=size_of_uint32( &info->unknown16);
- size+=size_of_uint32( &info->change_id);
- size+=size_of_uint32( &info->unknown18);
- size+=size_of_uint32( &info->status);
- size+=size_of_uint32( &info->unknown20);
- size+=size_of_uint32( &info->c_setprinter);
-
- size+=size_of_uint16( &info->unknown22);
- size+=size_of_uint16( &info->unknown23);
- size+=size_of_uint16( &info->unknown24);
- size+=size_of_uint16( &info->unknown25);
- size+=size_of_uint16( &info->unknown26);
- size+=size_of_uint16( &info->unknown27);
- size+=size_of_uint16( &info->unknown28);
- size+=size_of_uint16( &info->unknown29);
-
- return size;
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info)
-{
- int size=0;
-
- size+=size_of_uint32( &info->flags );
- size+=size_of_relative_string( &info->description );
- size+=size_of_relative_string( &info->name );
- size+=size_of_relative_string( &info->comment );
-
- return size;
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info)
-{
- uint32 size=0;
-
- size += 4;
-
- size += ndr_size_security_descriptor( info->secdesc, NULL, 0 );
-
- size+=size_of_device_mode( info->devmode );
-
- size+=size_of_relative_string( &info->servername );
- size+=size_of_relative_string( &info->printername );
- size+=size_of_relative_string( &info->sharename );
- size+=size_of_relative_string( &info->portname );
- size+=size_of_relative_string( &info->drivername );
- size+=size_of_relative_string( &info->comment );
- size+=size_of_relative_string( &info->location );
-
- size+=size_of_relative_string( &info->sepfile );
- size+=size_of_relative_string( &info->printprocessor );
- size+=size_of_relative_string( &info->datatype );
- size+=size_of_relative_string( &info->parameters );
-
- size+=size_of_uint32( &info->attributes );
- size+=size_of_uint32( &info->priority );
- size+=size_of_uint32( &info->defaultpriority );
- size+=size_of_uint32( &info->starttime );
- size+=size_of_uint32( &info->untiltime );
- size+=size_of_uint32( &info->status );
- size+=size_of_uint32( &info->cjobs );
- size+=size_of_uint32( &info->averageppm );
-
- /*
- * add any adjustments for alignment. This is
- * not optimal since we could be calling this
- * function from a loop (e.g. enumprinters), but
- * it is easier to maintain the calculation here and
- * not place the burden on the caller to remember. --jerry
- */
- if ((size % 4) != 0)
- size += 4 - (size % 4);
-
- return size;
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_printer_info_4(PRINTER_INFO_4 *info)
-{
- uint32 size=0;
-
- size+=size_of_relative_string( &info->printername );
- size+=size_of_relative_string( &info->servername );
-
- size+=size_of_uint32( &info->attributes );
- return size;
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_printer_info_5(PRINTER_INFO_5 *info)
-{
- uint32 size=0;
-
- size+=size_of_relative_string( &info->printername );
- size+=size_of_relative_string( &info->portname );
-
- size+=size_of_uint32( &info->attributes );
- size+=size_of_uint32( &info->device_not_selected_timeout );
- size+=size_of_uint32( &info->transmission_retry_timeout );
- return size;
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_printer_info_6(PRINTER_INFO_6 *info)
-{
- return sizeof(uint32);
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_printer_info_3(PRINTER_INFO_3 *info)
-{
- /* The 8 is for the self relative pointer - 8 byte aligned.. */
- return 8 + (uint32)ndr_size_security_descriptor( info->secdesc, NULL, 0 );
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_printer_info_7(PRINTER_INFO_7 *info)
-{
- uint32 size=0;
-
- size+=size_of_relative_string( &info->guid );
- size+=size_of_uint32( &info->action );
- return size;
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info)
-{
- int size=0;
- size+=size_of_relative_string( &info->name );
-
- return size;
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info)
-{
- int size=0;
- size+=size_of_uint32( &info->version );
- size+=size_of_relative_string( &info->name );
- size+=size_of_relative_string( &info->architecture );
- size+=size_of_relative_string( &info->driverpath );
- size+=size_of_relative_string( &info->datafile );
- size+=size_of_relative_string( &info->configfile );
-
- return size;
-}
-
-/*******************************************************************
-return the size required by a string array.
-********************************************************************/
-
-uint32 spoolss_size_string_array(uint16 *string)
-{
- uint32 i = 0;
-
- if (string) {
- for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
- }
- i=i+2; /* to count all chars including the leading zero */
- i=2*i; /* because we need the value in bytes */
- i=i+4; /* the offset pointer size */
-
- return i;
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info)
-{
- int size=0;
-
- size+=size_of_uint32( &info->version );
- size+=size_of_relative_string( &info->name );
- size+=size_of_relative_string( &info->architecture );
- size+=size_of_relative_string( &info->driverpath );
- size+=size_of_relative_string( &info->datafile );
- size+=size_of_relative_string( &info->configfile );
- size+=size_of_relative_string( &info->helpfile );
- size+=size_of_relative_string( &info->monitorname );
- size+=size_of_relative_string( &info->defaultdatatype );
-
- size+=spoolss_size_string_array(info->dependentfiles);
-
- return size;
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_printer_driver_info_6(DRIVER_INFO_6 *info)
-{
- uint32 size=0;
-
- size+=size_of_uint32( &info->version );
- size+=size_of_relative_string( &info->name );
- size+=size_of_relative_string( &info->architecture );
- size+=size_of_relative_string( &info->driverpath );
- size+=size_of_relative_string( &info->datafile );
- size+=size_of_relative_string( &info->configfile );
- size+=size_of_relative_string( &info->helpfile );
-
- size+=spoolss_size_string_array(info->dependentfiles);
-
- size+=size_of_relative_string( &info->monitorname );
- size+=size_of_relative_string( &info->defaultdatatype );
-
- size+=spoolss_size_string_array(info->previousdrivernames);
-
- size+=size_of_nttime(&info->driver_date);
- size+=size_of_uint32( &info->padding );
- size+=size_of_uint32( &info->driver_version_low );
- size+=size_of_uint32( &info->driver_version_high );
- size+=size_of_relative_string( &info->mfgname );
- size+=size_of_relative_string( &info->oem_url );
- size+=size_of_relative_string( &info->hardware_id );
- size+=size_of_relative_string( &info->provider );
-
- return size;
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_job_info_1(JOB_INFO_1 *info)
-{
- int size=0;
- size+=size_of_uint32( &info->jobid );
- size+=size_of_relative_string( &info->printername );
- size+=size_of_relative_string( &info->machinename );
- size+=size_of_relative_string( &info->username );
- size+=size_of_relative_string( &info->document );
- size+=size_of_relative_string( &info->datatype );
- size+=size_of_relative_string( &info->text_status );
- size+=size_of_uint32( &info->status );
- size+=size_of_uint32( &info->priority );
- size+=size_of_uint32( &info->position );
- size+=size_of_uint32( &info->totalpages );
- size+=size_of_uint32( &info->pagesprinted );
- size+=size_of_systemtime( &info->submitted );
-
- return size;
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-
-uint32 spoolss_size_job_info_2(JOB_INFO_2 *info)
-{
- int size=0;
-
- size+=4; /* size of sec desc ptr */
-
- size+=size_of_uint32( &info->jobid );
- size+=size_of_relative_string( &info->printername );
- size+=size_of_relative_string( &info->machinename );
- size+=size_of_relative_string( &info->username );
- size+=size_of_relative_string( &info->document );
- size+=size_of_relative_string( &info->notifyname );
- size+=size_of_relative_string( &info->datatype );
- size+=size_of_relative_string( &info->printprocessor );
- size+=size_of_relative_string( &info->parameters );
- size+=size_of_relative_string( &info->drivername );
- size+=size_of_device_mode( info->devmode );
- size+=size_of_relative_string( &info->text_status );
-/* SEC_DESC sec_desc;*/
- size+=size_of_uint32( &info->status );
- size+=size_of_uint32( &info->priority );
- size+=size_of_uint32( &info->position );
- size+=size_of_uint32( &info->starttime );
- size+=size_of_uint32( &info->untiltime );
- size+=size_of_uint32( &info->totalpages );
- size+=size_of_uint32( &info->size );
- size+=size_of_systemtime( &info->submitted );
- size+=size_of_uint32( &info->timeelapsed );
- size+=size_of_uint32( &info->pagesprinted );
-
- return size;
-}
-
-/*******************************************************************
-return the size required by a struct in the stream
-********************************************************************/
-uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p)
-{
- uint32 size = 0;
-
- if (!p)
- return 0;
-
- /* uint32(offset) + uint32(length) + length) */
- size += (size_of_uint32(&p->value_len)*2) + p->value_len;
- size += (size_of_uint32(&p->data_len)*2) + p->data_len + (p->data_len%2) ;
-
- size += size_of_uint32(&p->type);
-
- return size;
-}
-
-/*******************************************************************
- * read a structure.
- * called from spoolss_getprinterdriver2 (srv_spoolss.c)
- ********************************************************************/
-
-bool spoolss_io_q_getprinterdriver2(const char *desc, SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriver2");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
- return False;
- if(!prs_uint32("architecture_ptr", ps, depth, &q_u->architecture_ptr))
- return False;
- if(!smb_io_unistr2("architecture", &q_u->architecture, q_u->architecture_ptr, ps, depth))
- return False;
-
- if(!prs_align(ps))
- return False;
- if(!prs_uint32("level", ps, depth, &q_u->level))
- return False;
-
- if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("offered", ps, depth, &q_u->offered))
- return False;
-
- if(!prs_uint32("clientmajorversion", ps, depth, &q_u->clientmajorversion))
- return False;
- if(!prs_uint32("clientminorversion", ps, depth, &q_u->clientminorversion))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- * read a structure.
- * called from spoolss_getprinterdriver2 (srv_spoolss.c)
- ********************************************************************/
-
-bool spoolss_io_r_getprinterdriver2(const char *desc, SPOOL_R_GETPRINTERDRIVER2 *r_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriver2");
- depth++;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
- return False;
-
- if (!prs_align(ps))
- return False;
- if (!prs_uint32("needed", ps, depth, &r_u->needed))
- return False;
- if (!prs_uint32("servermajorversion", ps, depth, &r_u->servermajorversion))
- return False;
- if (!prs_uint32("serverminorversion", ps, depth, &r_u->serverminorversion))
- return False;
- if (!prs_werror("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- * init a structure.
- ********************************************************************/
-
-bool make_spoolss_q_enumprinters(
- SPOOL_Q_ENUMPRINTERS *q_u,
- uint32 flags,
- char *servername,
- uint32 level,
- RPC_BUFFER *buffer,
- uint32 offered
-)
-{
- q_u->flags=flags;
-
- q_u->servername_ptr = (servername != NULL) ? 1 : 0;
- init_buf_unistr2(&q_u->servername, &q_u->servername_ptr, servername);
-
- q_u->level=level;
- q_u->buffer=buffer;
- q_u->offered=offered;
-
- return True;
-}
-
-/*******************************************************************
- * read a structure.
- * called from spoolss_enumprinters (srv_spoolss.c)
- ********************************************************************/
-
-bool spoolss_io_q_enumprinters(const char *desc, SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_q_enumprinters");
- depth++;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_uint32("flags", ps, depth, &q_u->flags))
- return False;
- if (!prs_uint32("servername_ptr", ps, depth, &q_u->servername_ptr))
- return False;
-
- if (!smb_io_unistr2("", &q_u->servername, q_u->servername_ptr, ps, depth))
- return False;
-
- if (!prs_align(ps))
- return False;
- if (!prs_uint32("level", ps, depth, &q_u->level))
- return False;
-
- if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
- return False;
-
- if (!prs_align(ps))
- return False;
- if (!prs_uint32("offered", ps, depth, &q_u->offered))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a SPOOL_R_ENUMPRINTERS structure.
- ********************************************************************/
-
-bool spoolss_io_r_enumprinters(const char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_r_enumprinters");
- depth++;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
- return False;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_uint32("needed", ps, depth, &r_u->needed))
- return False;
-
- if (!prs_uint32("returned", ps, depth, &r_u->returned))
- return False;
-
- if (!prs_werror("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- * write a structure.
- * called from spoolss_r_enum_printers (srv_spoolss.c)
- *
- ********************************************************************/
-
-bool spoolss_io_r_getprinter(const char *desc, SPOOL_R_GETPRINTER *r_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_r_getprinter");
- depth++;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
- return False;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_uint32("needed", ps, depth, &r_u->needed))
- return False;
-
- if (!prs_werror("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- * read a structure.
- * called from spoolss_getprinter (srv_spoolss.c)
- ********************************************************************/
-
-bool spoolss_io_q_getprinter(const char *desc, SPOOL_Q_GETPRINTER *q_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_q_getprinter");
- depth++;
-
- if (!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
- return False;
- if (!prs_uint32("level", ps, depth, &q_u->level))
- return False;
-
- if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
- return False;
-
- if (!prs_align(ps))
- return False;
- if (!prs_uint32("offered", ps, depth, &q_u->offered))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-bool spoolss_io_r_enumjobs(const char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_r_enumjobs");
- depth++;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
- return False;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_uint32("needed", ps, depth, &r_u->needed))
- return False;
-
- if (!prs_uint32("returned", ps, depth, &r_u->returned))
- return False;
-
- if (!prs_werror("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-bool make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
- uint32 firstjob,
- uint32 numofjobs,
- uint32 level,
- RPC_BUFFER *buffer,
- uint32 offered)
-{
- if (q_u == NULL)
- {
- return False;
- }
- memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
- q_u->firstjob = firstjob;
- q_u->numofjobs = numofjobs;
- q_u->level = level;
- q_u->buffer= buffer;
- q_u->offered = offered;
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-bool spoolss_io_q_enumjobs(const char *desc, SPOOL_Q_ENUMJOBS *q_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_q_enumjobs");
- depth++;
-
- if (!prs_align(ps))
- return False;
-
- if (!smb_io_pol_hnd("printer handle",&q_u->handle, ps, depth))
- return False;
-
- if (!prs_uint32("firstjob", ps, depth, &q_u->firstjob))
- return False;
- if (!prs_uint32("numofjobs", ps, depth, &q_u->numofjobs))
- return False;
- if (!prs_uint32("level", ps, depth, &q_u->level))
- return False;
-
- if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if (!prs_uint32("offered", ps, depth, &q_u->offered))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a SPOOL_R_ENUMPRINTERDRIVERS structure.
-********************************************************************/
-
-bool spoolss_io_r_enumprinterdrivers(const char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdrivers");
- depth++;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
- return False;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_uint32("needed", ps, depth, &r_u->needed))
- return False;
-
- if (!prs_uint32("returned", ps, depth, &r_u->returned))
- return False;
-
- if (!prs_werror("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- * init a structure.
+ * return the length of a uint32 (obvious, but the code is clean)
********************************************************************/
-bool make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u,
- const char *name,
- const char *environment,
- uint32 level,
- RPC_BUFFER *buffer, uint32 offered)
+static uint32 size_of_uint32(uint32 *value)
{
- init_buf_unistr2(&q_u->name, &q_u->name_ptr, name);
- init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, environment);
-
- q_u->level=level;
- q_u->buffer=buffer;
- q_u->offered=offered;
-
- return True;
+ return (sizeof(*value));
}
/*******************************************************************
- Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure.
+return the size required by a struct in the stream
********************************************************************/
-
-bool spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth)
+uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p)
{
-
- prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdrivers");
- depth++;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr))
- return False;
- if (!smb_io_unistr2("", &q_u->name, q_u->name_ptr,ps, depth))
- return False;
-
- if (!prs_align(ps))
- return False;
- if (!prs_uint32("environment_ptr", ps, depth, &q_u->environment_ptr))
- return False;
- if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth))
- return False;
-
- if (!prs_align(ps))
- return False;
- if (!prs_uint32("level", ps, depth, &q_u->level))
- return False;
-
- if (!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
- return False;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_uint32("offered", ps, depth, &q_u->offered))
- return False;
-
- return True;
+ uint32 size = 0;
+
+ if (!p)
+ return 0;
+
+ /* uint32(offset) + uint32(length) + length) */
+ size += (size_of_uint32(&p->value_len)*2) + p->value_len;
+ size += (size_of_uint32(&p->data_len)*2) + p->data_len + (p->data_len%2) ;
+
+ size += size_of_uint32(&p->type);
+
+ return size;
}
/*******************************************************************
return True;
}
-/*******************************************************************
- Parse a SPOOL_R_GETJOB structure.
-********************************************************************/
-
-bool spoolss_io_r_getjob(const char *desc, SPOOL_R_GETJOB *r_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_r_getjob");
- depth++;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_rpcbuffer_p("", ps, depth, &r_u->buffer))
- return False;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_uint32("needed", ps, depth, &r_u->needed))
- return False;
-
- if (!prs_werror("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a SPOOL_Q_GETJOB structure.
-********************************************************************/
-
-bool spoolss_io_q_getjob(const char *desc, SPOOL_Q_GETJOB *q_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth))
- return False;
- if(!prs_uint32("jobid", ps, depth, &q_u->jobid))
- return False;
- if(!prs_uint32("level", ps, depth, &q_u->level))
- return False;
-
- if(!prs_rpcbuffer_p("", ps, depth, &q_u->buffer))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("offered", ps, depth, &q_u->offered))
- return False;
-
- return True;
-}
-
-void free_devmode(DEVICEMODE *devmode)
-{
- if (devmode!=NULL) {
- SAFE_FREE(devmode->dev_private);
- SAFE_FREE(devmode);
- }
-}
-
-void free_printer_info_1(PRINTER_INFO_1 *printer)
-{
- SAFE_FREE(printer);
-}
-
-void free_printer_info_2(PRINTER_INFO_2 *printer)
-{
- if (printer!=NULL) {
- free_devmode(printer->devmode);
- printer->devmode = NULL;
- SAFE_FREE(printer);
- }
-}
-
-void free_printer_info_3(PRINTER_INFO_3 *printer)
-{
- SAFE_FREE(printer);
-}
-
-void free_printer_info_4(PRINTER_INFO_4 *printer)
-{
- SAFE_FREE(printer);
-}
-
-void free_printer_info_5(PRINTER_INFO_5 *printer)
-{
- SAFE_FREE(printer);
-}
-
-void free_printer_info_6(PRINTER_INFO_6 *printer)
-{
- SAFE_FREE(printer);
-}
-
-void free_printer_info_7(PRINTER_INFO_7 *printer)
-{
- SAFE_FREE(printer);
-}
-
-void free_job_info_2(JOB_INFO_2 *job)
-{
- if (job!=NULL)
- free_devmode(job->devmode);
-}
-
/*******************************************************************
* read a structure.
********************************************************************/
static bool api_spoolss_enumprinters(pipes_struct *p)
{
- SPOOL_Q_ENUMPRINTERS q_u;
- SPOOL_R_ENUMPRINTERS r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n"));
- return False;
- }
-
- r_u.status = _spoolss_enumprinters( p, &q_u, &r_u);
-
- if (!spoolss_io_r_enumprinters("", &r_u, rdata, 0)) {
- DEBUG(0,("spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTERS);
}
/********************************************************************
static bool api_spoolss_getprinter(pipes_struct *p)
{
- SPOOL_Q_GETPRINTER q_u;
- SPOOL_R_GETPRINTER r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!spoolss_io_q_getprinter("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n"));
- return False;
- }
-
- r_u.status = _spoolss_getprinter(p, &q_u, &r_u);
-
- if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) {
- DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTER);
}
/********************************************************************
static bool api_spoolss_getprinterdriver2(pipes_struct *p)
{
- SPOOL_Q_GETPRINTERDRIVER2 q_u;
- SPOOL_R_GETPRINTERDRIVER2 r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n"));
- return False;
- }
-
- r_u.status = _spoolss_getprinterdriver2(p, &q_u, &r_u);
-
- if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) {
- DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTERDRIVER2);
}
/********************************************************************
static bool api_spoolss_enumjobs(pipes_struct *p)
{
- SPOOL_Q_ENUMJOBS q_u;
- SPOOL_R_ENUMJOBS r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n"));
- return False;
- }
-
- r_u.status = _spoolss_enumjobs(p, &q_u, &r_u);
-
- if (!spoolss_io_r_enumjobs("",&r_u,rdata,0)) {
- DEBUG(0,("spoolss_io_r_enumjobs: unable to marshall SPOOL_R_ENUMJOBS.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMJOBS);
}
/****************************************************************************
static bool api_spoolss_enumprinterdrivers(pipes_struct *p)
{
- SPOOL_Q_ENUMPRINTERDRIVERS q_u;
- SPOOL_R_ENUMPRINTERDRIVERS r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n"));
- return False;
- }
-
- r_u.status = _spoolss_enumprinterdrivers(p, &q_u, &r_u);
-
- if (!spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) {
- DEBUG(0,("spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTERDRIVERS);
}
/****************************************************************************
static bool api_spoolss_getjob(pipes_struct *p)
{
- SPOOL_Q_GETJOB q_u;
- SPOOL_R_GETJOB r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!spoolss_io_q_getjob("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n"));
- return False;
- }
-
- r_u.status = _spoolss_getjob(p, &q_u, &r_u);
-
- if(!spoolss_io_r_getjob("",&r_u,rdata,0)) {
- DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_GETJOB);
}
/********************************************************************
#include "includes.h"
+/* macros stolen from s4 spoolss server */
+#define SPOOLSS_BUFFER_UNION(fn,ic,info,level) \
+ ((info)?ndr_size_##fn(info, level, ic, 0):0)
+
+#define SPOOLSS_BUFFER_UNION_ARRAY(mem_ctx,fn,ic,info,level,count) \
+ ((info)?ndr_size_##fn##_info(mem_ctx, ic, level, count, info):0)
+
+#define SPOOLSS_BUFFER_OK(val_true,val_false) ((r->in.offered >= *r->out.needed)?val_true:val_false)
+
+
extern userdom_struct current_user_info;
#undef DBGC_CLASS
* fill a printer_info_0 struct
********************************************************************/
-static bool construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *printer, int snum)
+static WERROR construct_printer_info0(TALLOC_CTX *mem_ctx,
+ const NT_PRINTER_INFO_LEVEL *ntprinter,
+ struct spoolss_PrinterInfo0 *r,
+ int snum)
{
- char *chaine = NULL;
int count;
- NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
counter_printer_0 *session_counter;
- uint32 global_counter;
- struct tm *t;
time_t setuptime;
print_status_struct status;
- TALLOC_CTX *ctx = talloc_tos();
- if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum))))
- return False;
-
- init_unistr(&printer->printername, ntprinter->info_2->printername);
+ r->printername = talloc_strdup(mem_ctx, ntprinter->info_2->printername);
+ W_ERROR_HAVE_NO_MEMORY(r->printername);
- chaine = talloc_asprintf(ctx, "\\\\%s", get_server_name(print_hnd));
- if (!chaine) {
- free_a_printer(&ntprinter,2);
-