1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

Merge branch 'master' of ssh://git.samba.org/data/git/samba into wspp-schema

This commit is contained in:
Andrew Bartlett 2009-03-20 13:22:08 +11:00
commit 27c6eca04c
228 changed files with 13477 additions and 13982 deletions

1
.gitignore vendored
View File

@ -280,6 +280,7 @@ source4/tests
source4/torture/auth/proto.h
source4/torture/basic/proto.h
source4/torture/ldap/proto.h
source4/torture/ldb/proto.h
source4/torture/libnet/proto.h
source4/torture/local/proto.h
source4/torture/nbench/proto.h

View File

@ -18,11 +18,11 @@
<refsynopsisdiv>
<title>DESCRIPTION</title>
<para>The idmap_hash plugin implements a hashing algorithm used
map SIDs for domain users and groups to a 31-bit uid and gid.
<para>The idmap_hash plugin implements a hashing algorithm used to map
SIDs for domain users and groups to 31-bit uids and gids, respectively.
This plugin also implements the nss_info API and can be used
to support a local name mapping files if enabled via the
&quot;winbind normlaize names&quot; and &quot;winbind nss info&quot;
&quot;winbind normalize names&quot; and &quot;winbind nss info&quot;
parameters in smb.conf.
</para>
</refsynopsisdiv>

View File

@ -194,48 +194,6 @@ bool async_req_is_error(struct async_req *req, enum async_req_state *state,
return true;
}
static void async_req_timedout(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval now,
void *priv)
{
struct async_req *req = talloc_get_type_abort(priv, struct async_req);
TALLOC_FREE(te);
async_req_finish(req, ASYNC_REQ_TIMED_OUT);
}
bool async_req_set_timeout(struct async_req *req, struct tevent_context *ev,
struct timeval to)
{
return (tevent_add_timer(
ev, req,
tevent_timeval_current_ofs(to.tv_sec, to.tv_usec),
async_req_timedout, req)
!= NULL);
}
struct async_req *async_wait_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct timeval to)
{
struct async_req *result;
result = async_req_new(mem_ctx);
if (result == NULL) {
return result;
}
if (!async_req_set_timeout(result, ev, to)) {
TALLOC_FREE(result);
return NULL;
}
return result;
}
bool async_wait_recv(struct async_req *req)
{
return true;
}
struct async_queue_entry {
struct async_queue_entry *prev, *next;
struct async_req_queue *queue;

View File

@ -139,15 +139,6 @@ bool async_post_error(struct async_req *req, struct tevent_context *ev,
bool async_req_is_error(struct async_req *req, enum async_req_state *state,
uint64_t *error);
bool async_req_set_timeout(struct async_req *req, struct tevent_context *ev,
struct timeval to);
struct async_req *async_wait_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct timeval to);
bool async_wait_recv(struct async_req *req);
struct async_req_queue;
struct async_req_queue *async_req_queue_init(TALLOC_CTX *mem_ctx);

View File

@ -389,7 +389,6 @@ struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
{
struct tevent_req *result;
struct writev_state *state;
struct tevent_fd *fde;
result = tevent_req_create(mem_ctx, &state, struct writev_state);
if (result == NULL) {
@ -405,22 +404,7 @@ struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
goto fail;
}
/*
* This if () should go away once our callers are converted to always
* pass in a queue.
*/
if (queue != NULL) {
if (!tevent_queue_add(queue, ev, result, writev_trigger,
NULL)) {
goto fail;
}
return result;
}
fde = tevent_add_fd(ev, state, fd, TEVENT_FD_WRITE, writev_handler,
result);
if (fde == NULL) {
if (!tevent_queue_add(queue, ev, result, writev_trigger, NULL)) {
goto fail;
}
return result;
@ -485,7 +469,7 @@ static void writev_handler(struct tevent_context *ev, struct tevent_fd *fde,
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;
}

View File

@ -8,14 +8,18 @@ LIBREPLACE_NETWORK_LIBS=""
AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h)
AC_CHECK_HEADERS(netinet/in_systm.h)
AC_CHECK_HEADERS([netinet/ip.h], [], [],[#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h>
#endif])
AC_CHECK_HEADERS([netinet/ip.h], [], [],[
#include <sys/types.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h>
#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
@ -241,7 +245,7 @@ AC_CHECK_MEMBERS([struct sockaddr.sa_len],
dnl test for getifaddrs and freeifaddrs
AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[
AC_TRY_COMPILE([
AC_TRY_LINK([
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>

View File

@ -83,6 +83,10 @@
#include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
#endif
#ifdef HAVE_STROPTS_H
#include <stropts.h>
#endif

View File

@ -1,5 +1,5 @@
AC_PREREQ(2.50)
AC_INIT(talloc, 1.2.1)
AC_INIT(talloc, 1.3.0)
AC_CONFIG_SRCDIR([talloc.c])
AC_SUBST(datarootdir)
AC_CONFIG_HEADER(config.h)

View File

@ -138,14 +138,30 @@ struct talloc_chunk {
#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 */
@ -564,7 +580,7 @@ static inline int _talloc_free(void *ptr)
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;
@ -810,7 +826,18 @@ static void talloc_abort_type_missmatch(const char *location,
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)

View File

@ -94,6 +94,7 @@ typedef void TALLOC_CTX;
#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type)
#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__)
#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count)
#define talloc_array_length(ctx) ((ctx) ? talloc_get_size(ctx)/sizeof(*ctx) : 0)
#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type)
#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__)
@ -115,6 +116,8 @@ typedef void TALLOC_CTX;
#define talloc_append_string(c, s, a) (s?talloc_strdup_append(s,a):talloc_strdup(c, a))
#endif
#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
/* The following definitions come from talloc.c */
void *_talloc(const void *context, size_t size);
void *talloc_pool(const void *context, size_t size);
@ -182,4 +185,6 @@ char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3)
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

View File

@ -23,7 +23,7 @@
#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

View File

@ -21,12 +21,11 @@
#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");
@ -38,7 +37,7 @@ static bool test_pull_uint8(struct torture_context *tctx)
{
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;
@ -53,7 +52,7 @@ static bool test_pull_uint8(struct torture_context *tctx)
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");
@ -66,7 +65,7 @@ static bool test_pull_uint16(struct torture_context *tctx)
{
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;
@ -81,7 +80,7 @@ static bool test_pull_uint16(struct torture_context *tctx)
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");
@ -96,7 +95,7 @@ static bool test_pull_uint32(struct torture_context *tctx)
{
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;
@ -110,7 +109,7 @@ static bool test_pull_uint32(struct torture_context *tctx)
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;
@ -132,7 +131,7 @@ static bool test_pull_charset(struct torture_context *tctx)
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;
@ -151,7 +150,7 @@ static bool test_pull_charset_empty(struct torture_context *tctx)
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");

View File

@ -1,5 +1,5 @@
AC_PREREQ(2.50)
AC_INIT(tevent, 0.9.3)
AC_INIT(tevent, 0.9.5)
AC_CONFIG_SRCDIR([tevent.c])
AC_CONFIG_HEADER(config.h)

View File

@ -26,7 +26,8 @@ AC_SUBST(TEVENT_LIBS)
TEVENT_CFLAGS="-I$teventdir"
TEVENT_OBJ="tevent.o tevent_fd.o tevent_timed.o tevent_signal.o tevent_debug.o tevent_util.o"
TEVENT_OBJ="tevent.o tevent_debug.o tevent_util.o"
TEVENT_OBJ="$TEVENT_OBJ tevent_fd.o tevent_timed.o tevent_immediate.o tevent_signal.o"
TEVENT_OBJ="$TEVENT_OBJ tevent_req.o tevent_wakeup.o tevent_queue.o"
TEVENT_OBJ="$TEVENT_OBJ tevent_standard.o tevent_select.o"

View File

@ -59,6 +59,7 @@
*/
#include "replace.h"
#include "system/filesys.h"
#define TEVENT_DEPRECATED 1
#include "tevent.h"
#include "tevent_internal.h"
#include "tevent_util.h"
@ -142,6 +143,7 @@ int tevent_common_context_destructor(struct tevent_context *ev)
{
struct tevent_fd *fd, *fn;
struct tevent_timer *te, *tn;
struct tevent_immediate *ie, *in;
struct tevent_signal *se, *sn;
if (ev->pipe_fde) {
@ -161,6 +163,13 @@ int tevent_common_context_destructor(struct tevent_context *ev)
DLIST_REMOVE(ev->timer_events, te);
}
for (ie = ev->immediate_events; ie; ie = in) {
in = ie->next;
ie->event_ctx = NULL;
ie->cancel_fn = NULL;
DLIST_REMOVE(ev->immediate_events, ie);
}
for (se = ev->signal_events; se; se = sn) {
sn = se->next;
se->event_ctx = NULL;
@ -305,6 +314,33 @@ void tevent_fd_set_flags(struct tevent_fd *fde, uint16_t flags)
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
@ -321,6 +357,47 @@ struct tevent_timer *_tevent_add_timer(struct tevent_context *ev,
handler_name, location);
}
/*
allocate an immediate event
return NULL on failure (memory allocation error)
*/
struct tevent_immediate *_tevent_create_immediate(TALLOC_CTX *mem_ctx,
const char *location)
{
struct tevent_immediate *im;
im = talloc(mem_ctx, struct tevent_immediate);
if (im == NULL) return NULL;
im->prev = NULL;
im->next = NULL;
im->event_ctx = NULL;
im->create_location = location;
im->handler = NULL;
im->private_data = NULL;
im->handler_name = NULL;
im->schedule_location = NULL;
im->cancel_fn = NULL;
im->additional_data = NULL;
return im;
}
/*
schedule an immediate event
return NULL on failure
*/
void _tevent_schedule_immediate(struct tevent_immediate *im,
struct tevent_context *ev,
tevent_immediate_handler_t handler,
void *private_data,
const char *handler_name,
const char *location)
{
ev->ops->schedule_immediate(im, ev, handler, private_data,
handler_name, location);
}
/*
add a signal event
@ -341,18 +418,192 @@ struct tevent_signal *_tevent_add_signal(struct tevent_context *ev,
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)
{
if (ev->nesting.hook_fn &&
(ev->nesting.hook_fn != hook ||
ev->nesting.hook_private != private_data)) {
/* the way the nesting hook code is currently written
we cannot support two different nesting hooks at the
same time. */
tevent_abort(ev, "tevent: Violation of nesting hook rules\n");
}
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.level > 0) {
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 > 0) {
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.level > 0) {
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 > 0) {
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_common_loop_wait(struct tevent_context *ev,
const char *location)
{
return ev->ops->loop_wait(ev);
/*
* loop as long as we have events pending
*/
while (ev->fd_events ||
ev->timer_events ||
ev->immediate_events ||
ev->signal_events) {
int ret;
ret = _tevent_loop_once(ev, location);
if (ret != 0) {
tevent_debug(ev, TEVENT_DEBUG_FATAL,
"_tevent_loop_once() failed: %d - %s\n",
ret, strerror(errno));
return ret;
}
}
tevent_debug(ev, TEVENT_DEBUG_WARNING,
"tevent_common_loop_wait() out of events\n");
return 0;
}
/*
return on failure or (with 0) if all fd events are removed
*/
int _tevent_loop_wait(struct tevent_context *ev, const char *location)
{
return ev->ops->loop_wait(ev, location);
}

View File

@ -37,6 +37,7 @@ struct tevent_context;
struct tevent_ops;
struct tevent_fd;
struct tevent_timer;
struct tevent_immediate;
struct tevent_signal;
/* event handler types */
@ -52,6 +53,9 @@ typedef void (*tevent_timer_handler_t)(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval current_time,
void *private_data);
typedef void (*tevent_immediate_handler_t)(struct tevent_context *ctx,
struct tevent_immediate *im,
void *private_data);
typedef void (*tevent_signal_handler_t)(struct tevent_context *ev,
struct tevent_signal *se,
int signum,
@ -87,6 +91,21 @@ struct tevent_timer *_tevent_add_timer(struct tevent_context *ev,
_tevent_add_timer(ev, mem_ctx, next_event, handler, private_data, \
#handler, __location__)
struct tevent_immediate *_tevent_create_immediate(TALLOC_CTX *mem_ctx,
const char *location);
#define tevent_create_immediate(mem_ctx) \
_tevent_create_immediate(mem_ctx, __location__)
void _tevent_schedule_immediate(struct tevent_immediate *im,
struct tevent_context *ctx,
tevent_immediate_handler_t handler,
void *private_data,
const char *handler_name,
const char *location);
#define tevent_schedule_immediate(im, ctx, handler, private_data) \
_tevent_schedule_immediate(im, ctx, handler, private_data, \
#handler, __location__);
struct tevent_signal *_tevent_add_signal(struct tevent_context *ev,
TALLOC_CTX *mem_ctx,
int signum,
@ -99,8 +118,13 @@ struct tevent_signal *_tevent_add_signal(struct tevent_context *ev,
_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);
@ -108,6 +132,10 @@ void tevent_fd_set_auto_close(struct tevent_fd *fde);
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
@ -224,13 +252,22 @@ bool tevent_req_set_endtime(struct tevent_req *req,
struct tevent_context *ev,
struct timeval endtime);
void tevent_req_done(struct tevent_req *req);
void _tevent_req_done(struct tevent_req *req,
const char *location);
#define tevent_req_done(req) \
_tevent_req_done(req, __location__)
bool tevent_req_error(struct tevent_req *req,
uint64_t error);
bool _tevent_req_error(struct tevent_req *req,
uint64_t error,
const char *location);
#define tevent_req_error(req, error) \
_tevent_req_error(req, error, __location__)
bool tevent_req_nomem(const void *p,
struct tevent_req *req);
bool _tevent_req_nomem(const void *p,
struct tevent_req *req,
const char *location);
#define tevent_req_nomem(p, req) \
_tevent_req_nomem(p, req, __location__)
struct tevent_req *tevent_req_post(struct tevent_req *req,
struct tevent_context *ev);
@ -286,12 +323,37 @@ bool tevent_queue_add(struct tevent_queue *queue,
struct tevent_req *req,
tevent_queue_trigger_fn_t trigger,
void *private_data);
bool tevent_queue_start(struct tevent_queue *queue,
struct tevent_context *ev);
void tevent_queue_start(struct tevent_queue *queue);
void tevent_queue_stop(struct tevent_queue *queue);
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

View File

@ -35,14 +35,6 @@ struct epoll_event_context {
/* a pointer back to the generic event_context */
struct tevent_context *ev;
/* this is changed by the destructors for the fd event
type. It is used to detect event destruction by event
handlers, which means the code that is calling the event
handler needs to assume that the linked list is no longer
valid
*/
uint32_t destruction_count;
/* when using epoll this is the handle from epoll_create */
int epoll_fd;
@ -242,9 +234,8 @@ static void epoll_change_event(struct epoll_event_context *epoll_ev, struct teve
static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval *tvalp)
{
int ret, i;
#define MAXEVENTS 32
#define MAXEVENTS 1
struct epoll_event events[MAXEVENTS];
uint32_t destruction_count = ++epoll_ev->destruction_count;
int timeout = -1;
if (epoll_ev->epoll_fd == -1) return -1;
@ -305,9 +296,7 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval
if (events[i].events & EPOLLOUT) flags |= TEVENT_FD_WRITE;
if (flags) {
fde->handler(epoll_ev->ev, fde, flags, fde->private_data);
if (destruction_count != epoll_ev->destruction_count) {
break;
}
break;
}
}
@ -351,8 +340,6 @@ static int epoll_event_fd_destructor(struct tevent_fd *fde)
epoll_check_reopen(epoll_ev);
epoll_ev->destruction_count++;
epoll_del_event(epoll_ev, fde);
}
@ -411,12 +398,22 @@ static void epoll_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
/*
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);
struct timeval tval;
if (ev->signal_events &&
tevent_common_check_signal(ev)) {
return 0;
}
if (ev->immediate_events &&
tevent_common_loop_immediate(ev)) {
return 0;
}
tval = tevent_common_loop_timer_delay(ev);
if (tevent_timeval_is_zero(&tval)) {
return 0;
@ -427,32 +424,17 @@ static int epoll_event_loop_once(struct tevent_context *ev)
return epoll_event_loop(epoll_ev, &tval);
}
/*
return on failure or (with 0) if all fd events are removed
*/
static int epoll_event_loop_wait(struct tevent_context *ev)
{
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) {
break;
}
}
return 0;
}
static const struct tevent_ops epoll_event_ops = {
.context_init = epoll_event_context_init,
.add_fd = epoll_event_add_fd,
.set_fd_close_fn= tevent_common_fd_set_close_fn,
.get_fd_flags = tevent_common_fd_get_flags,
.set_fd_flags = epoll_event_set_fd_flags,
.add_timer = tevent_common_add_timer,
.add_signal = tevent_common_add_signal,
.loop_once = epoll_event_loop_once,
.loop_wait = epoll_event_loop_wait,
.context_init = epoll_event_context_init,
.add_fd = epoll_event_add_fd,
.set_fd_close_fn = tevent_common_fd_set_close_fn,
.get_fd_flags = tevent_common_fd_get_flags,
.set_fd_flags = epoll_event_set_fd_flags,
.add_timer = tevent_common_add_timer,
.schedule_immediate = tevent_common_schedule_immediate,
.add_signal = tevent_common_add_signal,
.loop_once = epoll_event_loop_once,
.loop_wait = tevent_common_loop_wait,
};
bool tevent_epoll_init(void)

View File

@ -0,0 +1,139 @@
/*
Unix SMB/CIFS implementation.
common events code for immediate events
Copyright (C) Stefan Metzmacher 2009
** NOTE! The following LGPL license applies to the tevent
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "replace.h"
#include "tevent.h"
#include "tevent_internal.h"
#include "tevent_util.h"
static void tevent_common_immediate_cancel(struct tevent_immediate *im)
{
if (!im->event_ctx) {
return;
}
tevent_debug(im->event_ctx, TEVENT_DEBUG_TRACE,
"Cancel immediate event %p \"%s\"\n",
im, im->handler_name);
/* let the backend free im->additional_data */
if (im->cancel_fn) {
im->cancel_fn(im);
}
DLIST_REMOVE(im->event_ctx->immediate_events, im);
im->event_ctx = NULL;
im->handler = NULL;
im->private_data = NULL;
im->handler_name = NULL;
im->schedule_location = NULL;
im->cancel_fn = NULL;
im->additional_data = NULL;
talloc_set_destructor(im, NULL);
}
/*
destroy an immediate event
*/
static int tevent_common_immediate_destructor(struct tevent_immediate *im)
{
tevent_common_immediate_cancel(im);
return 0;
}
/*
* schedule an immediate event on
*/
void tevent_common_schedule_immediate(struct tevent_immediate *im,
struct tevent_context *ev,
tevent_immediate_handler_t handler,
void *private_data,
const char *handler_name,
const char *location)
{
tevent_common_immediate_cancel(im);
if (!handler) {
return;
}
im->event_ctx = ev;
im->handler = handler;
im->private_data = private_data;
im->handler_name = handler_name;
im->schedule_location = location;
im->cancel_fn = NULL;
im->additional_data = NULL;
DLIST_ADD_END(ev->immediate_events, im, struct tevent_immediate *);
talloc_set_destructor(im, tevent_common_immediate_destructor);
tevent_debug(ev, TEVENT_DEBUG_TRACE,
"Schedule immediate event \"%s\": %p\n",
handler_name, im);
}
/*
trigger the first immediate event and return true
if no event was triggered return false
*/
bool tevent_common_loop_immediate(struct tevent_context *ev)
{
struct tevent_immediate *im = ev->immediate_events;
tevent_immediate_handler_t handler;
void *private_data;
if (!im) {
return false;
}
tevent_debug(ev, TEVENT_DEBUG_TRACE,
"Run immediate event \"%s\": %p\n",
im->handler_name, im);
/*
* remember the handler and then clear the event
* the handler might reschedule the event
*/
handler = im->handler;
private_data = im->private_data;
DLIST_REMOVE(im->event_ctx->immediate_events, im);
im->event_ctx = NULL;
im->handler = NULL;
im->private_data = NULL;
im->handler_name = NULL;
im->schedule_location = NULL;
im->cancel_fn = NULL;
im->additional_data = NULL;
talloc_set_destructor(im, NULL);
handler(ev, im, private_data);
return true;
}

View File

@ -85,7 +85,17 @@ struct tevent_req {
*
* This for debugging only.
*/
const char *location;
const char *create_location;
/**
* @brief The location where the request was finished
*
* This uses the __location__ macro via the tevent_req_done(),
* tevent_req_error() or tevent_req_nomem() macro.
*
* This for debugging only.
*/
const char *finish_location;
/**
* @brief The external state - will be queried by the caller
@ -105,10 +115,10 @@ struct tevent_req {
uint64_t error;
/**
* @brief the timer event if tevent_req_post was used
* @brief the immediate event used by tevent_req_post
*
*/
struct tevent_timer *trigger;
struct tevent_immediate *trigger;
/**
* @brief the timer event if tevent_req_set_timeout was used
@ -143,6 +153,15 @@ struct tevent_ops {
void *private_data,
const char *handler_name,
const char *location);
/* immediate event functions */
void (*schedule_immediate)(struct tevent_immediate *im,
struct tevent_context *ev,
tevent_immediate_handler_t handler,
void *private_data,
const char *handler_name,
const char *location);
/* signal functions */
struct tevent_signal *(*add_signal)(struct tevent_context *ev,
TALLOC_CTX *mem_ctx,
@ -153,8 +172,8 @@ struct tevent_ops {
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 {
@ -188,6 +207,21 @@ struct tevent_timer {
void *additional_data;
};
struct tevent_immediate {
struct tevent_immediate *prev, *next;
struct tevent_context *event_ctx;
tevent_immediate_handler_t handler;
/* this is private for the specific handler */
void *private_data;
/* this is for debugging only! */
const char *handler_name;
const char *create_location;
const char *schedule_location;
/* this is private for the events_ops implementation */
void (*cancel_fn)(struct tevent_immediate *im);
void *additional_data;
};
struct tevent_signal {
struct tevent_signal *prev, *next;
struct tevent_context *event_ctx;
@ -222,6 +256,9 @@ struct tevent_context {
/* list of timed events - used by common code */
struct tevent_timer *timer_events;
/* list of immediate events - used by common code */
struct tevent_immediate *immediate_events;
/* list of signal events - used by common code */
struct tevent_signal *signal_events;
@ -233,12 +270,22 @@ struct tevent_context {
/* 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;
};
bool tevent_register_backend(const char *name, const struct tevent_ops *ops);
int tevent_common_context_destructor(struct tevent_context *ev);
int tevent_common_loop_wait(struct tevent_context *ev,
const char *location);
int tevent_common_fd_destructor(struct tevent_fd *fde);
struct tevent_fd *tevent_common_add_fd(struct tevent_context *ev,
@ -263,6 +310,14 @@ struct tevent_timer *tevent_common_add_timer(struct tevent_context *ev,
const char *location);
struct timeval tevent_common_loop_timer_delay(struct tevent_context *);
void tevent_common_schedule_immediate(struct tevent_immediate *im,
struct tevent_context *ev,
tevent_immediate_handler_t handler,
void *private_data,
const char *handler_name,
const char *location);
bool tevent_common_loop_immediate(struct tevent_context *ev);
struct tevent_signal *tevent_common_add_signal(struct tevent_context *ev,
TALLOC_CTX *mem_ctx,
int signum,

View File

@ -34,6 +34,7 @@ struct tevent_queue_entry {
bool triggered;
struct tevent_req *req;
struct tevent_context *ev;
tevent_queue_trigger_fn_t trigger;
void *private_data;
@ -44,12 +45,16 @@ struct tevent_queue {
const char *location;
bool running;
struct tevent_timer *timer;
struct tevent_immediate *immediate;
size_t length;
struct tevent_queue_entry *list;
};
static void tevent_queue_immediate_trigger(struct tevent_context *ev,
struct tevent_immediate *im,
void *private_data);
static int tevent_queue_entry_destructor(struct tevent_queue_entry *e)
{
struct tevent_queue *q = e->queue;
@ -61,14 +66,23 @@ static int tevent_queue_entry_destructor(struct tevent_queue_entry *e)
DLIST_REMOVE(q->list, e);
q->length--;
if (e->triggered &&
q->running &&
q->list) {
q->list->triggered = true;
q->list->trigger(q->list->req,
q->list->private_data);
if (!q->running) {
return 0;
}
if (!q->list) {
return 0;
}
if (q->list->triggered) {
return 0;
}
tevent_schedule_immediate(q->immediate,
q->list->ev,
tevent_queue_immediate_trigger,
q);
return 0;
}
@ -100,6 +114,11 @@ struct tevent_queue *_tevent_queue_create(TALLOC_CTX *mem_ctx,
talloc_free(queue);
return NULL;
}
queue->immediate = tevent_create_immediate(queue);
if (!queue->immediate) {
talloc_free(queue);
return NULL;
}
queue->location = location;
@ -110,16 +129,16 @@ struct tevent_queue *_tevent_queue_create(TALLOC_CTX *mem_ctx,
return queue;
}
static void tevent_queue_timer_start(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval now,
void *private_data)
static void tevent_queue_immediate_trigger(struct tevent_context *ev,
struct tevent_immediate *im,
void *private_data)
{
struct tevent_queue *q = talloc_get_type(private_data,
struct tevent_queue);
talloc_free(te);
q->timer = NULL;
if (!q->running) {
return;
}
q->list->triggered = true;
q->list->trigger(q->list->req, q->list->private_data);
@ -140,56 +159,56 @@ bool tevent_queue_add(struct tevent_queue *queue,
e->queue = queue;
e->req = req;
e->ev = ev;
e->trigger = trigger;
e->private_data = private_data;
if (queue->running &&
!queue->timer &&
!queue->list) {
queue->timer = tevent_add_timer(ev, queue, tevent_timeval_zero(),
tevent_queue_timer_start,
queue);
if (!queue->timer) {
talloc_free(e);
return false;
}
}
DLIST_ADD_END(queue->list, e, struct tevent_queue_entry *);
queue->length++;
talloc_set_destructor(e, tevent_queue_entry_destructor);
return true;
}
bool tevent_queue_start(struct tevent_queue *queue,
struct tevent_context *ev)
{
if (queue->running) {
/* already started */
if (!queue->running) {
return true;
}
if (!queue->timer &&
queue->list) {
queue->timer = tevent_add_timer(ev, queue, tevent_timeval_zero(),
tevent_queue_timer_start,
queue);
if (!queue->timer) {
return false;
}
if (queue->list->triggered) {
return true;
}
tevent_schedule_immediate(queue->immediate,
queue->list->ev,
tevent_queue_immediate_trigger,
queue);
return true;
}
void tevent_queue_start(struct tevent_queue *queue)
{
if (queue->running) {
/* already started */
return;
}
queue->running = true;
return true;
if (!queue->list) {
return;
}
if (queue->list->triggered) {
return;
}
tevent_schedule_immediate(queue->immediate,
queue->list->ev,
tevent_queue_immediate_trigger,
queue);
}
void tevent_queue_stop(struct tevent_queue *queue)
{
queue->running = false;
talloc_free(queue->timer);
queue->timer = NULL;
}
size_t tevent_queue_length(struct tevent_queue *queue)

View File

@ -43,7 +43,7 @@ char *tevent_req_default_print(struct tevent_req *req, TALLOC_CTX *mem_ctx)
return talloc_asprintf(mem_ctx,
"tevent_req[%p/%s]: state[%d] error[%lld (0x%llX)] "
" state[%s (%p)] timer[%p]",
req, req->internal.location,
req, req->internal.create_location,
req->internal.state,
(unsigned long long)req->internal.error,
(unsigned long long)req->internal.error,
@ -95,8 +95,14 @@ struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
return NULL;
}
req->internal.private_type = type;
req->internal.location = location;
req->internal.create_location = location;
req->internal.finish_location = NULL;
req->internal.state = TEVENT_REQ_IN_PROGRESS;
req->internal.trigger = tevent_create_immediate(req);
if (!req->internal.trigger) {
talloc_free(req);
return NULL;
}
data = talloc_size(req, data_size);
if (data == NULL) {
@ -111,9 +117,12 @@ struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
return req;
}
static void tevent_req_finish(struct tevent_req *req, enum tevent_req_state state)
static void tevent_req_finish(struct tevent_req *req,
enum tevent_req_state state,
const char *location)
{
req->internal.state = state;
req->internal.finish_location = location;
if (req->async.fn != NULL) {
req->async.fn(req);
}
@ -128,9 +137,10 @@ static void tevent_req_finish(struct tevent_req *req, enum tevent_req_state stat
* function.
*/
void tevent_req_done(struct tevent_req *req)
void _tevent_req_done(struct tevent_req *req,
const char *location)
{
tevent_req_finish(req, TEVENT_REQ_DONE);
tevent_req_finish(req, TEVENT_REQ_DONE, location);
}
/**
@ -161,14 +171,16 @@ void tevent_req_done(struct tevent_req *req)
* \endcode
*/
bool tevent_req_error(struct tevent_req *req, uint64_t error)
bool _tevent_req_error(struct tevent_req *req,
uint64_t error,
const char *location)
{
if (error == 0) {
return false;
}
req->internal.error = error;
tevent_req_finish(req, TEVENT_REQ_USER_ERROR);
tevent_req_finish(req, TEVENT_REQ_USER_ERROR, location);
return true;
}
@ -189,42 +201,39 @@ bool tevent_req_error(struct tevent_req *req, uint64_t error)
* \endcode
*/
bool tevent_req_nomem(const void *p, struct tevent_req *req)
bool _tevent_req_nomem(const void *p,
struct tevent_req *req,
const char *location)
{
if (p != NULL) {
return false;
}
tevent_req_finish(req, TEVENT_REQ_NO_MEMORY);
tevent_req_finish(req, TEVENT_REQ_NO_MEMORY, location);
return true;
}
/**
* @brief Timed event callback
* @brief Immediate event callback
* @param[in] ev Event context
* @param[in] te The timed event
* @param[in] now zero time
* @param[in] im The immediate event
* @param[in] priv The async request to be finished
*/
static void tevent_req_trigger(struct tevent_context *ev,
struct tevent_timer *te,
struct timeval zero,
struct tevent_immediate *im,
void *private_data)
{
struct tevent_req *req = talloc_get_type(private_data,
struct tevent_req);
talloc_free(req->internal.trigger);
req->internal.trigger = NULL;
tevent_req_finish(req, req->internal.state);
tevent_req_finish(req, req->internal.state,
req->internal.finish_location);
}
/**
* @brief Finish a request before the caller had the change to set the callback
* @param[in] req The finished request
* @param[in] ev The tevent_context for the timed event
* @retval On success req will be returned,
* on failure req will be destroyed
* @retval req will be returned
*
* An implementation of an async request might find that it can either finish
* the request without waiting for an external event, or it can't even start
@ -237,13 +246,8 @@ static void tevent_req_trigger(struct tevent_context *ev,
struct tevent_req *tevent_req_post(struct tevent_req *req,
struct tevent_context *ev)
{
req->internal.trigger = tevent_add_timer(ev, req, tevent_timeval_zero(),
tevent_req_trigger, req);
if (!req->internal.trigger) {
talloc_free(req);
return NULL;
}
tevent_schedule_immediate(req->internal.trigger,
ev, tevent_req_trigger, req);
return req;
}
@ -265,14 +269,11 @@ bool tevent_req_is_in_progress(struct tevent_req *req)
*/
void tevent_req_received(struct tevent_req *req)
{
talloc_free(req->data);
req->data = NULL;
TALLOC_FREE(req->data);
req->private_print = NULL;
talloc_free(req->internal.trigger);
req->internal.trigger = NULL;
talloc_free(req->internal.timer);
req->internal.timer = NULL;
TALLOC_FREE(req->internal.trigger);
TALLOC_FREE(req->internal.timer);
req->internal.state = TEVENT_REQ_RECEIVED;
}
@ -313,17 +314,16 @@ static void tevent_req_timedout(struct tevent_context *ev,
struct tevent_req *req = talloc_get_type(private_data,
struct tevent_req);
talloc_free(req->internal.timer);
req->internal.timer = NULL;
TALLOC_FREE(req->internal.timer);
tevent_req_finish(req, TEVENT_REQ_TIMED_OUT);
tevent_req_finish(req, TEVENT_REQ_TIMED_OUT, __FUNCTION__);
}
bool tevent_req_set_endtime(struct tevent_req *req,
struct tevent_context *ev,
struct timeval endtime)
{
talloc_free(req->internal.timer);
TALLOC_FREE(req->internal.timer);
req->internal.timer = tevent_add_timer(ev, req, endtime,
tevent_req_timedout,

View File

@ -38,10 +38,6 @@ struct select_event_context {
/* information for exiting from the event loop */
int exit_code;
/* this is incremented when the loop over events causes something which
could change the events yet to be processed */
uint32_t destruction_count;
};
/*
@ -95,8 +91,6 @@ static int select_event_fd_destructor(struct tevent_fd *fde)
if (select_ev->maxfd == fde->fd) {
select_ev->maxfd = EVENT_INVALID_MAXFD;
}
select_ev->destruction_count++;
}
return tevent_common_fd_destructor(fde);
@ -138,7 +132,6 @@ static int select_event_loop_select(struct select_event_context *select_ev, stru
fd_set r_fds, w_fds;
struct tevent_fd *fde;
int selrtn;
uint32_t destruction_count = ++select_ev->destruction_count;
/* we maybe need to recalculate the maxfd */
if (select_ev->maxfd == EVENT_INVALID_MAXFD) {
@ -200,25 +193,33 @@ static int select_event_loop_select(struct select_event_context *select_ev, stru
if (FD_ISSET(fde->fd, &w_fds)) flags |= TEVENT_FD_WRITE;
if (flags) {
fde->handler(select_ev->ev, fde, flags, fde->private_data);
if (destruction_count != select_ev->destruction_count) {
break;
}
break;
}
}
}
return 0;
}
}
/*
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);
struct timeval tval;
if (ev->signal_events &&
tevent_common_check_signal(ev)) {
return 0;
}
if (ev->immediate_events &&
tevent_common_loop_immediate(ev)) {
return 0;
}
tval = tevent_common_loop_timer_delay(ev);
if (tevent_timeval_is_zero(&tval)) {
return 0;
@ -227,34 +228,17 @@ static int select_event_loop_once(struct tevent_context *ev)
return select_event_loop_select(select_ev, &tval);
}
/*
return on failure or (with 0) if all fd events are removed
*/
static int select_event_loop_wait(struct tevent_context *ev)
{
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) {
break;
}
}
return select_ev->exit_code;
}
static const struct tevent_ops select_event_ops = {
.context_init = select_event_context_init,
.add_fd = select_event_add_fd,
.set_fd_close_fn= tevent_common_fd_set_close_fn,
.get_fd_flags = tevent_common_fd_get_flags,
.set_fd_flags = tevent_common_fd_set_flags,
.add_timer = tevent_common_add_timer,
.add_signal = tevent_common_add_signal,
.loop_once = select_event_loop_once,
.loop_wait = select_event_loop_wait,
.context_init = select_event_context_init,
.add_fd = select_event_add_fd,
.set_fd_close_fn = tevent_common_fd_set_close_fn,
.get_fd_flags = tevent_common_fd_get_flags,
.set_fd_flags = tevent_common_fd_set_flags,
.add_timer = tevent_common_add_timer,
.schedule_immediate = tevent_common_schedule_immediate,
.add_signal = tevent_common_add_signal,
.loop_once = select_event_loop_once,
.loop_wait = tevent_common_loop_wait,
};
bool tevent_select_init(void)

View File

@ -48,14 +48,6 @@ struct std_event_context {
/* information for exiting from the event loop */
int exit_code;
/* this is changed by the destructors for the fd event
type. It is used to detect event destruction by event
handlers, which means the code that is calling the event
handler needs to assume that the linked list is no longer
valid
*/
uint32_t destruction_count;
/* when using epoll this is the handle from epoll_create */
int epoll_fd;
@ -253,9 +245,8 @@ static void epoll_change_event(struct std_event_context *std_ev, struct tevent_f
static int epoll_event_loop(struct std_event_context *std_ev, struct timeval *tvalp)
{
int ret, i;
#define MAXEVENTS 8
#define MAXEVENTS 1
struct epoll_event events[MAXEVENTS];
uint32_t destruction_count = ++std_ev->destruction_count;
int timeout = -1;
if (std_ev->epoll_fd == -1) return -1;
@ -316,9 +307,7 @@ static int epoll_event_loop(struct std_event_context *std_ev, struct timeval *tv
if (events[i].events & EPOLLOUT) flags |= TEVENT_FD_WRITE;
if (flags) {
fde->handler(std_ev->ev, fde, flags, fde->private_data);
if (destruction_count != std_ev->destruction_count) {
break;
}
break;
}
}
@ -390,8 +379,6 @@ static int std_event_fd_destructor(struct tevent_fd *fde)
std_ev->maxfd = EVENT_INVALID_MAXFD;
}
std_ev->destruction_count++;
epoll_del_event(std_ev, fde);
}
@ -459,7 +446,6 @@ static int std_event_loop_select(struct std_event_context *std_ev, struct timeva
fd_set r_fds, w_fds;
struct tevent_fd *fde;
int selrtn;
uint32_t destruction_count = ++std_ev->destruction_count;
/* we maybe need to recalculate the maxfd */
if (std_ev->maxfd == EVENT_INVALID_MAXFD) {
@ -521,9 +507,7 @@ static int std_event_loop_select(struct std_event_context *std_ev, struct timeva
if (FD_ISSET(fde->fd, &w_fds)) flags |= TEVENT_FD_WRITE;
if (flags) {
fde->handler(std_ev->ev, fde, flags, fde->private_data);
if (destruction_count != std_ev->destruction_count) {
break;
}
break;
}
}
}
@ -534,12 +518,22 @@ static int std_event_loop_select(struct std_event_context *std_ev, struct timeva
/*
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);
struct timeval tval;
if (ev->signal_events &&
tevent_common_check_signal(ev)) {
return 0;
}
if (ev->immediate_events &&
tevent_common_loop_immediate(ev)) {
return 0;
}
tval = tevent_common_loop_timer_delay(ev);
if (tevent_timeval_is_zero(&tval)) {
return 0;
@ -554,34 +548,17 @@ static int std_event_loop_once(struct tevent_context *ev)
return std_event_loop_select(std_ev, &tval);
}
/*
return on failure or (with 0) if all fd events are removed
*/
static int std_event_loop_wait(struct tevent_context *ev)
{
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) {
break;
}
}
return std_ev->exit_code;
}
static const struct tevent_ops std_event_ops = {
.context_init = std_event_context_init,
.add_fd = std_event_add_fd,
.set_fd_close_fn= tevent_common_fd_set_close_fn,
.get_fd_flags = tevent_common_fd_get_flags,
.set_fd_flags = std_event_set_fd_flags,
.add_timer = tevent_common_add_timer,
.add_signal = tevent_common_add_signal,
.loop_once = std_event_loop_once,
.loop_wait = std_event_loop_wait,
.context_init = std_event_context_init,
.add_fd = std_event_add_fd,
.set_fd_close_fn = tevent_common_fd_set_close_fn,
.get_fd_flags = tevent_common_fd_get_flags,
.set_fd_flags = std_event_set_fd_flags,
.add_timer = tevent_common_add_timer,
.schedule_immediate = tevent_common_schedule_immediate,
.add_signal = tevent_common_add_signal,
.loop_once = std_event_loop_once,
.loop_wait = tevent_common_loop_wait,
};

17
lib/tsocket/config.mk Normal file
View File

@ -0,0 +1,17 @@
[SUBSYSTEM::LIBTSOCKET]
PRIVATE_DEPENDENCIES = LIBTALLOC LIBTEVENT LIBREPLACE_NETWORK
LIBTSOCKET_OBJ_FILES = $(addprefix ../lib/tsocket/, \
tsocket.o \
tsocket_helpers.o \
tsocket_bsd.o \
tsocket_recvfrom.o \
tsocket_sendto.o \
tsocket_connect.o \
tsocket_writev.o \
tsocket_readv.o)
PUBLIC_HEADERS += $(addprefix ../lib/tsocket/, \
tsocket.h\
tsocket_internal.h)

231
lib/tsocket/tsocket.c Normal file
View File

@ -0,0 +1,231 @@
/*
Unix SMB/CIFS implementation.
Copyright (C) Stefan Metzmacher 2009
** NOTE! The following LGPL license applies to the tevent
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "replace.h"
#include "system/network.h"
#include "tsocket.h"
#include "tsocket_internal.h"
static int tsocket_context_destructor(struct tsocket_context *sock)
{
tsocket_disconnect(sock);
return 0;
}
struct tsocket_context *_tsocket_context_create(TALLOC_CTX *mem_ctx,
const struct tsocket_context_ops *ops,
void *pstate,
size_t psize,
const char *type,
const char *location)
{
void **ppstate = (void **)pstate;
struct tsocket_context *sock;
sock = talloc_zero(mem_ctx, struct tsocket_context);
if (!sock) {
return NULL;
}
sock->ops = ops;
sock->location = location;
sock->private_data = talloc_size(sock, psize);
if (!sock->private_data) {
talloc_free(sock);
return NULL;
}
talloc_set_name_const(sock->private_data, type);
talloc_set_destructor(sock, tsocket_context_destructor);
*ppstate = sock->private_data;
return sock;
}
int tsocket_set_event_context(struct tsocket_context *sock,
struct tevent_context *ev)
{
return sock->ops->set_event_context(sock, ev);
}
int tsocket_set_readable_handler(struct tsocket_context *sock,
tsocket_event_handler_t handler,
void *private_data)
{
return sock->ops->set_read_handler(sock, handler, private_data);
}
int tsocket_set_writeable_handler(struct tsocket_context *sock,
tsocket_event_handler_t handler,
void *private_data)
{
return sock->ops->set_write_handler(sock, handler, private_data);
}
int tsocket_connect(struct tsocket_context *sock,
const struct tsocket_address *remote_addr)
{
return sock->ops->connect_to(sock, remote_addr);
}
int tsocket_listen(struct tsocket_context *sock,
int queue_size)
{
return sock->ops->listen_on(sock, queue_size);
}
int _tsocket_accept(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
struct tsocket_context **new_sock,
const char *location)
{
return sock->ops->accept_new(sock, mem_ctx, new_sock, location);
}
ssize_t tsocket_pending(struct tsocket_context *sock)
{
return sock->ops->pending_data(sock);
}
int tsocket_readv(struct tsocket_context *sock,
const struct iovec *vector, size_t count)
{
return sock->ops->readv_data(sock, vector, count);
}
int tsocket_writev(struct tsocket_context *sock,
const struct iovec *vector, size_t count)
{
return sock->ops->writev_data(sock, vector, count);
}
ssize_t tsocket_recvfrom(struct tsocket_context *sock,
uint8_t *data, size_t len,
TALLOC_CTX *addr_ctx,
struct tsocket_address **src_addr)
{
return sock->ops->recvfrom_data(sock, data, len, addr_ctx, src_addr);
}
ssize_t tsocket_sendto(struct tsocket_context *sock,
const uint8_t *data, size_t len,
const struct tsocket_address *dest_addr)
{
return sock->ops->sendto_data(sock, data, len, dest_addr);
}
int tsocket_get_status(const struct tsocket_context *sock)
{
return sock->ops->get_status(sock);
}
int _tsocket_get_local_address(const struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
struct tsocket_address **local_addr,
const char *location)
{
return sock->ops->get_local_address(sock, mem_ctx,
local_addr, location);
}
int _tsocket_get_remote_address(const struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
struct tsocket_address **remote_addr,
const char *location)
{
return sock->ops->get_remote_address(sock, mem_ctx,
remote_addr, location);
}
int tsocket_get_option(const struct tsocket_context *sock,
const char *option,
TALLOC_CTX *mem_ctx,
char **value)
{
return sock->ops->get_option(sock, option, mem_ctx, value);
}
int tsocket_set_option(const struct tsocket_context *sock,
const char *option,
bool force,
const char *value)
{
return sock->ops->set_option(sock, option, force, value);
}
void tsocket_disconnect(struct tsocket_context *sock)
{
sock->ops->disconnect(sock);
}
struct tsocket_address *_tsocket_address_create(TALLOC_CTX *mem_ctx,
const struct tsocket_address_ops *ops,
void *pstate,
size_t psize,
const char *type,
const char *location)
{
void **ppstate = (void **)pstate;
struct tsocket_address *addr;
addr = talloc_zero(mem_ctx, struct tsocket_address);
if (!addr) {
return NULL;
}
addr->ops = ops;
addr->location = location;
addr->private_data = talloc_size(addr, psize);
if (!addr->private_data) {
talloc_free(addr);
return NULL;
}
talloc_set_name_const(addr->private_data, type);
*ppstate = addr->private_data;
return addr;
}
char *tsocket_address_string(const struct tsocket_address *addr,
TALLOC_CTX *mem_ctx)
{
if (!addr) {
return talloc_strdup(mem_ctx, "NULL");
}
return addr->ops->string(addr, mem_ctx);
}
struct tsocket_address *_tsocket_address_copy(const struct tsocket_address *addr,
TALLOC_CTX *mem_ctx,
const char *location)
{
return addr->ops->copy(addr, mem_ctx, location);
}
int _tsocket_address_create_socket(const struct tsocket_address *addr,
enum tsocket_type type,
TALLOC_CTX *mem_ctx,
struct tsocket_context **sock,
const char *location)
{
return addr->ops->create_socket(addr, type, mem_ctx, sock, location);
}

220
lib/tsocket/tsocket.h Normal file
View File

@ -0,0 +1,220 @@
/*
Unix SMB/CIFS implementation.
Copyright (C) Stefan Metzmacher 2009
** NOTE! The following LGPL license applies to the tevent
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TSOCKET_H
#define _TSOCKET_H
#include <talloc.h>
#include <tevent.h>
struct tsocket_context;
struct tsocket_address;
struct iovec;
enum tsocket_type {
TSOCKET_TYPE_STREAM = 1,
TSOCKET_TYPE_DGRAM,
TSOCKET_TYPE_MESSAGE
};
typedef void (*tsocket_event_handler_t)(struct tsocket_context *, void *);
int tsocket_set_event_context(struct tsocket_context *sock,
struct tevent_context *ev);
int tsocket_set_readable_handler(struct tsocket_context *sock,
tsocket_event_handler_t handler,
void *private_data);
int tsocket_set_writeable_handler(struct tsocket_context *sock,
tsocket_event_handler_t handler,
void *private_data);
int tsocket_connect(struct tsocket_context *sock,
const struct tsocket_address *remote_addr);
int tsocket_listen(struct tsocket_context *sock,
int queue_size);
int _tsocket_accept(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
struct tsocket_context **new_sock,
const char *location);
#define tsocket_accept(sock, mem_ctx, new_sock) \
_tsocket_accept(sock, mem_ctx, new_sock, __location__)
ssize_t tsocket_pending(struct tsocket_context *sock);
int tsocket_readv(struct tsocket_context *sock,
const struct iovec *vector, size_t count);
int tsocket_writev(struct tsocket_context *sock,
const struct iovec *vector, size_t count);
ssize_t tsocket_recvfrom(struct tsocket_context *sock,
uint8_t *data, size_t len,
TALLOC_CTX *addr_ctx,
struct tsocket_address **src_addr);
ssize_t tsocket_sendto(struct tsocket_context *sock,
const uint8_t *data, size_t len,
const struct tsocket_address *dest_addr);
int tsocket_get_status(const struct tsocket_context *sock);
int _tsocket_get_local_address(const struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
struct tsocket_address **local_addr,
const char *location);
#define tsocket_get_local_address(sock, mem_ctx, local_addr) \
_tsocket_get_local_address(sock, mem_ctx, local_addr, __location__)
int _tsocket_get_remote_address(const struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
struct tsocket_address **remote_addr,
const char *location);
#define tsocket_get_remote_address(sock, mem_ctx, remote_addr) \
_tsocket_get_remote_address(sock, mem_ctx, remote_addr, __location__)
int tsocket_get_option(const struct tsocket_context *sock,
const char *option,
TALLOC_CTX *mem_ctx,
char **value);
int tsocket_set_option(const struct tsocket_context *sock,
const char *option,
bool force,
const char *value);
void tsocket_disconnect(struct tsocket_context *sock);
char *tsocket_address_string(const struct tsocket_address *addr,
TALLOC_CTX *mem_ctx);
struct tsocket_address *_tsocket_address_copy(const struct tsocket_address *addr,
TALLOC_CTX *mem_ctx,
const char *location);
#define tsocket_address_copy(addr, mem_ctx) \
_tsocket_address_copy(addr, mem_ctx, __location__)
int _tsocket_address_create_socket(const struct tsocket_address *addr,
enum tsocket_type type,
TALLOC_CTX *mem_ctx,
struct tsocket_context **sock,
const char *location);
#define tsocket_address_create_socket(addr, type, mem_ctx, sock) \
_tsocket_address_create_socket(addr, type, mem_ctx, sock,\
__location__)
/*
* BSD sockets: inet, inet6 and unix
*/
int _tsocket_address_inet_from_strings(TALLOC_CTX *mem_ctx,
const char *fam,
const char *addr,
uint16_t port,
struct tsocket_address **_addr,
const char *location);
#define tsocket_address_inet_from_strings(mem_ctx, fam, addr, port, _addr) \
_tsocket_address_inet_from_strings(mem_ctx, fam, addr, port, _addr, \
__location__)
char *tsocket_address_inet_addr_string(const struct tsocket_address *addr,
TALLOC_CTX *mem_ctx);
uint16_t tsocket_address_inet_port(const struct tsocket_address *addr);
int tsocket_address_inet_set_port(struct tsocket_address *addr,
uint16_t port);
void tsocket_address_inet_set_broadcast(struct tsocket_address *addr,
bool broadcast);
int _tsocket_address_unix_from_path(TALLOC_CTX *mem_ctx,
const char *path,
struct tsocket_address **_addr,
const char *location);
#define tsocket_address_unix_from_path(mem_ctx, path, _addr) \
_tsocket_address_unix_from_path(mem_ctx, path, _addr, \
__location__)
char *tsocket_address_unix_path(const struct tsocket_address *addr,
TALLOC_CTX *mem_ctx);
int _tsocket_context_bsd_wrap_existing(TALLOC_CTX *mem_ctx,
int fd, bool close_on_disconnect,
struct tsocket_context **_sock,
const char *location);
#define tsocket_context_bsd_wrap_existing(mem_ctx, fd, cod, _sock) \
_tsocket_context_bsd_wrap_existing(mem_ctx, fd, cod, _sock, \
__location__)
/*
* Async helpers
*/
struct tevent_req *tsocket_recvfrom_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx);
ssize_t tsocket_recvfrom_recv(struct tevent_req *req,
int *perrno,
TALLOC_CTX *mem_ctx,
uint8_t **buf,
struct tsocket_address **src);
struct tevent_req *tsocket_sendto_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
const uint8_t *buf,
size_t len,
const struct tsocket_address *dst);
ssize_t tsocket_sendto_recv(struct tevent_req *req, int *perrno);
struct tevent_req *tsocket_sendto_queue_send(TALLOC_CTX *mem_ctx,
struct tsocket_context *sock,
struct tevent_queue *queue,
const uint8_t *buf,
size_t len,
struct tsocket_address *dst);
ssize_t tsocket_sendto_queue_recv(struct tevent_req *req, int *perrno);
struct tevent_req *tsocket_connect_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
const struct tsocket_address *dst);
int tsocket_connect_recv(struct tevent_req *req, int *perrno);
struct tevent_req *tsocket_writev_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
const struct iovec *vector,
size_t count);
int tsocket_writev_recv(struct tevent_req *req, int *perrno);
struct tevent_req *tsocket_writev_queue_send(TALLOC_CTX *mem_ctx,
struct tsocket_context *sock,
struct tevent_queue *queue,
const struct iovec *vector,
size_t count);
int tsocket_writev_queue_recv(struct tevent_req *req, int *perrno);
typedef int (*tsocket_readv_next_iovec_t)(struct tsocket_context *sock,
void *private_data,
TALLOC_CTX *mem_ctx,
struct iovec **vector,
size_t *count);
struct tevent_req *tsocket_readv_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
tsocket_readv_next_iovec_t next_iovec_fn,
void *private_data);
int tsocket_readv_recv(struct tevent_req *req, int *perrno);
#endif /* _TSOCKET_H */

1126
lib/tsocket/tsocket_bsd.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,122 @@
/*
Unix SMB/CIFS implementation.
Copyright (C) Stefan Metzmacher 2009
** NOTE! The following LGPL license applies to the tevent
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "replace.h"
#include "system/network.h"
#include "tsocket.h"
#include "tsocket_internal.h"
struct tsocket_connect_state {
/* this structs are owned by the caller */
struct {
struct tsocket_context *sock;
const struct tsocket_address *dst;
} caller;
};
static void tsocket_connect_handler(struct tsocket_context *sock,
void *private_data);
struct tevent_req *tsocket_connect_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
const struct tsocket_address *dst)
{
struct tevent_req *req;
struct tsocket_connect_state *state;
int ret;
int err;
bool retry;
bool dummy;
req = tevent_req_create(mem_ctx, &state,
struct tsocket_connect_state);
if (!req) {
return NULL;
}
state->caller.sock = sock;
state->caller.dst = dst;
ret = tsocket_connect(state->caller.sock,
state->caller.dst);
err = tsocket_error_from_errno(ret, errno, &retry);
if (retry) {
/* retry later */
goto async;
}
if (tevent_req_error(req, err)) {
goto post;
}
tevent_req_done(req);
goto post;
async:
ret = tsocket_set_readable_handler(state->caller.sock,
tsocket_connect_handler,
req);
err = tsocket_error_from_errno(ret, errno, &dummy);
if (tevent_req_error(req, err)) {
goto post;
}
return req;
post:
return tevent_req_post(req, sock->event.ctx);
}
static void tsocket_connect_handler(struct tsocket_context *sock,
void *private_data)
{
struct tevent_req *req = talloc_get_type(private_data,
struct tevent_req);
struct tsocket_connect_state *state = tevent_req_data(req,
struct tsocket_connect_state);
int ret;
int err;
bool retry;
ret = tsocket_get_status(state->caller.sock);
err = tsocket_error_from_errno(ret, errno, &retry);
if (retry) {
/* retry later */
return;
}
if (tevent_req_error(req, err)) {
return;
}
tevent_req_done(req);
}
int tsocket_connect_recv(struct tevent_req *req, int *perrno)
{
int ret;
ret = tsocket_simple_int_recv(req, perrno);
tevent_req_received(req);
return ret;
}

View File

@ -0,0 +1,503 @@
Basic design of the tsocket abstraction
=======================================
The tsocket layer is designed to match more or less
the bsd socket layer, but it hides the filedescriptor
within a opaque 'tsocket_context' structure to make virtual
sockets possible. The virtual sockets can be encrypted tunnels
(like TLS, SASL or GSSAPI) or named pipes over smb.
The tsocket layer is a bit like an abstract class, which defines
common methods to work with sockets in a non blocking fashion.
The whole library is based on the talloc(3) and 'tevent' libraries.
The 'tsocket_address' structure is the 2nd abstracted class
which represends the address of a socket endpoint.
Each different type of socket has its own constructor.
Typically the constructor for a tsocket_context is attached to
the tsocket_address of the source endpoint. That means
the tsocket_address_create_socket() function takes the
tsocket_address of the local endpoint and creates a tsocket_context
for the communication.
For some usecases it's possible to wrap an existing socket into a
tsocket_context, e.g. to wrap an existing pipe(2) into
tsocket_context, so that you can use the same functions to
communicate over the pipe.
The tsocket_address abstraction
===============================
The tsocket_address represents an socket endpoint genericly.
As it's like an abstract class it has no specific constructor.
The specific constructors are descripted later sections.
There's a function get the string representation of the
endpoint for debugging. Callers should not try to parse
the string! The should use additional methods of the specific
tsocket_address implemention to get more details.
char *tsocket_address_string(const struct tsocket_address *addr,
TALLOC_CTX *mem_ctx);
There's a function to create a copy of the tsocket_address.
This is useful when before doing modifications to a socket
via additional methods of the specific tsocket_address implementation.
struct tsocket_address *tsocket_address_copy(const struct tsocket_address *addr,
TALLOC_CTX *mem_ctx);
There's a function to create a tsocket_context based on the given local
socket endpoint. The return value is 0 on success and -1 on failure
with errno holding the specific error. Specific details are descripted in later
sections. Note not all specific implementation have to implement all socket
types.
enum tsocket_type {
TSOCKET_TYPE_STREAM = 1,
TSOCKET_TYPE_DGRAM,
TSOCKET_TYPE_MESSAGE
};
int tsocket_address_create_socket(const struct tsocket_address *addr,
enum tsocket_type type,
TALLOC_CTX *mem_ctx,
struct tsocket_context **sock);
The tsocket_context abstraction
===============================
The tsocket_context is like an abstract class and represents
a socket similar to bsd style sockets. The methods are more
or less equal to the bsd socket api, while the filedescriptor
is replaced by tsocket_context and sockaddr, socklen_t pairs
are replaced by tsocket_address. The 'bind' operation happens
in the specific constructor as the constructor is typically based
on tsocket_address of local socket endpoint.
All operations are by design non blocking and can return error
values like EAGAIN, EINPROGRESS, EWOULDBLOCK or EINTR which
indicate that the caller should retry the operation later.
Also read the "The glue to tevent" section.
The socket can of types:
- TSOCKET_TYPE_STREAM is the equivalent to SOCK_STREAM in the bsd socket api.
- TSOCKET_TYPE_DGRAM is the equivalent to SOCK_DGRAM in the bsd socket api.
- TSOCKET_TYPE_MESSAGE operates on a connected socket and is therefore
like TSOCKET_TYPE_STREAM, but the consumer needs to first read all
data of a message, which was generated by one message 'write' on the sender,
before the consumer gets data of the next message. This matches a bit
like message mode pipes on windows. The concept is to transfer ordered
messages between to endpoints.
There's a function to connect to a remote endpoint. The behavior
and error codes match the connect(2) function of the bsd socket api.
Maybe the specific tsocket_context implementation speficied some
further details.
int tsocket_connect(struct tsocket_context *sock,
const struct tsocket_address *remote_addr);
There's a function to listen for incoming connections. The behavior
and error codes match the listen(2) function of the bsd socket api.
Maybe the specific tsocket_context implementation speficied some
further details.
int tsocket_listen(struct tsocket_context *sock,
int queue_size);
There's a function to accept incoming connections. The behavior
and error codes match the accept(2) function of the bsd socket api.
Maybe the specific tsocket_context implementation speficied some
further details.
int tsocket_accept(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
struct tsocket_context **new_sock);
There's a function to ask how many bytes are in input buffer
of the connection. For sockets of type TSOCKET_TYPE_DGRAM or
TSOCKET_TYPE_MESSAGE the size of the next available dgram/message
is returned. A return value of -1 indicates a socket error
and errno will hold the specific error code. If no data
is available 0 is returned, but retry error codes like
EINTR can also be returned.
ssize_t tsocket_pending(struct tsocket_context *sock);
There's a function to read data from the socket. The behavior
and error codes match the readv(3) function, also take a look
at the recv(2) function of the bsd socket api.
Maybe the specific tsocket_context implementation speficied some
further details.
int tsocket_readv(struct tsocket_context *sock,
const struct iovec *vector, size_t count);
There's a function to write data from the socket. The behavior
and error codes match the writev(3) function, also take a look
at the send(2) function of the bsd socket api.
Maybe the specific tsocket_context implementation speficied some
further details.
int tsocket_writev(struct tsocket_context *sock,
const struct iovec *vector, size_t count);
There's a function to read a datagram from a remote endpoint.
The behavior and error codes match the recvfrom(2) function of
the bsd socket api. As TSOCKET_TYPE_DGRAM sockets can also be
used in connected mode src_addr can be NULL, if the caller don't
want to get the source address. Maybe the specific tsocket_context
implementation speficied some further details.
ssize_t tsocket_recvfrom(struct tsocket_context *sock,
uint8_t *data, size_t len,
TALLOC_CTX *addr_ctx,
struct tsocket_address **src_addr);
There's a function to send a datagram to a remote endpoint the socket.
The behavior and error codes match the recvfrom(2) function of the
bsd socket api. As TSOCKET_TYPE_DGRAM sockets can also be used in
connected mode dest_addr must be NULL in connected mode and a valid
tsocket_address otherwise. Maybe the specific tsocket_context
implementation speficied some further details.
ssize_t tsocket_sendto(struct tsocket_context *sock,
const uint8_t *data, size_t len,
const struct tsocket_address *dest_addr);
There's a function to get the current status of the socket.
The behavior and error codes match the getsockopt(2) function
of the bsd socket api, with SOL_SOCKET and SO_ERROR as arguments.
Maybe the specific tsocket_context implementation speficied some
further details.
int tsocket_get_status(const struct tsocket_context *sock);
There's a function to get tsocket_address of the local endpoint.
The behavior and error codes match the getsockname(2) function
of the bsd socket api. Maybe the specific tsocket_context
implementation speficied some further details.
int tsocket_get_local_address(const struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
struct tsocket_address **local_addr);
There's a function to get tsocket_address of the remote endpoint
of a connected socket. The behavior and error codes match the
getpeername(2) function of the bsd socket api. Maybe the specific
tsocket_context implementation speficied some further details.
int tsocket_get_remote_address(const struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
struct tsocket_address **remote_addr,
const char *location);
There's a function to ask for specific options of the socket.
The behavior and error codes match the getsockopt(2) function
of the bsd socket api. The option and value are represented as string
values, where the 'value' parameter can be NULL is the caller don't want to
get the value. The supported options and values are up to the specific
tsocket_context implementation.
int tsocket_get_option(const struct tsocket_context *sock,
const char *option,
TALLOC_CTX *mem_ctx,
char **value);
There's a function to set specific options of the socket.
The behavior and error codes match the setsockopt(2) function
of the bsd socket api. The option and value are represented as string
values, where the 'value' parameter can be NULL. The supported options
and values are up to the specific tsocket_context implementation.
The 'force' parameter specifies whether an error should be returned
for unsupported options.
int tsocket_set_option(const struct tsocket_context *sock,
const char *option,
bool force,
const char *value);
There's a function to disconnect the socket. The behavior
and error codes match the close(2) function of the bsd socket api.
Maybe the specific tsocket_context implementation speficied some
further details.
void tsocket_disconnect(struct tsocket_context *sock);
The glue to tevent
==================
As the tsocket library is based on the tevent library,
there need to be functions to let the caller register
callback functions, which are triggered when the socket
is writeable or readable. Typically one would use
tevent fd events, but in order to hide the filedescriptor
the tsocket_context abstraction has their own functions.
There's a function to set the currently active tevent_context
for the socket. It's important there's only one tevent_context
actively used with the socket. A second call will cancel
all low level events made on the old tevent_context, it will
also resets the send and recv handlers to NULL. If the caller
sets attaches a new event context to the socket, the callback
function also need to be registered again. It's important
that the caller keeps the given tevent_context in memory
and actively calls tsocket_set_event_context(sock, NULL)
before calling talloc_free(event_context).
The function returns 0 on success and -1 together with an errno
on failure.
int tsocket_set_event_context(struct tsocket_context *sock,
struct tevent_context *ev);
There's a function to register a callback function which is called
when the socket is readable. If the caller don't want to get notified
anymore the function should be called with NULL as handler.
The function returns 0 on success and -1 together with an errno
on failure.
typedef void (*tsocket_event_handler_t)(struct tsocket_context *, void *);
int tsocket_set_readable_handler(struct tsocket_context *sock,
tsocket_event_handler_t handler,
void *private_data);
There's a function to register a callback function which is called
when the socket is writeable. If the caller don't want to get notified
anymore the function should be called with NULL as handler.
The function returns 0 on success and -1 together with an errno
on failure.
typedef void (*tsocket_event_handler_t)(struct tsocket_context *, void *);
int tsocket_set_writeable_handler(struct tsocket_context *sock,
tsocket_event_handler_t handler,
void *private_data);
Note: if the socket is readable and writeable, only the writeable
handler is called, this avoids deadlocks at the application level.
Async helper functions
======================
To make the life easier for the callers, there're 'tevent_req' based
helper functions for non-blocking io-operations. For each of this functions
to work the caller must attach the tevent_context to the tsocket_context
with tsocket_set_event_context(). Please remember that attching a new
tevent_context will reset the event state of the socket and should only
be done, when there's no async request is pending on the socket!
The detailed calling conventions for 'tevent_req' based programming
will be explained in the 'tevent' documentation.
To receive the next availabe datagram from socket there's a wrapper
for tsocket_recvfrom(). The caller virtually sends its desire to receive
the next available datagram by calling the tsocket_recvfrom_send() function
and attaches a callback function to the returned tevent_req via tevent_req_set_callback().
The callback function is called when a datagram is available or an error has happened.
The callback function needs to get the result by calling
tsocket_recvfrom_recv(). The return value of tsocket_recvfrom_recv()
matches the return value from tsocket_recvfrom(). A possible errno is delivered
via the perrno parameter instead of the global errno variable. The datagram
buffer and optional the source tsocket_address of the datagram are returned as talloc
childs of the mem_ctx passed to tsocket_recvfrom_recv().
It's important that the caller garanties that there's only one async
read request on the socket at a time.
struct tevent_req *tsocket_recvfrom_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx);
ssize_t tsocket_recvfrom_recv(struct tevent_req *req,
int *perrno,
TALLOC_CTX *mem_ctx,
uint8_t **buf,
struct tsocket_address **src);
To send a datagram there's a wrapper for tsocket_sendto().
The caller calls tsocket_sendto_send() instead of tsocket_sendto()
which returns a tevent_req allocated on the given TALLOC_CTX.
The caller attaches a callback function to the returned tevent_req via
tevent_req_set_callback(). The callback function is called when a datagram was
deliviered into the socket or an error has happened.
The callback function needs to get the result by calling
tsocket_sendto_recv(). The return value of tsocket_sendto_recv()
matches the return value from tsocket_sendto(). A possible errno is delivered
via the perrno parameter instead of the global errno variable.
Normal callers should not use this function directly, they should use
tsocket_sendto_queue_send/recv() instead.
struct tevent_req *tsocket_sendto_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
const uint8_t *buf,
size_t len,
const struct tsocket_address *dst);
ssize_t tsocket_sendto_recv(struct tevent_req *req, int *perrno);
As only one async tsocket_sendto() call should happen at a time,
there's a 'tevent_queue' is used to serialize the sendto requests.
struct tevent_req *tsocket_sendto_queue_send(TALLOC_CTX *mem_ctx,
struct tsocket_context *sock,
struct tevent_queue *queue,
const uint8_t *buf,
size_t len,
struct tsocket_address *dst);
ssize_t tsocket_sendto_queue_recv(struct tevent_req *req, int *perrno);
Ther's an async helper for tsocket_connect(), which should be used
to connect TSOCKET_TYPE_STREAM based sockets.
The caller virtually sends its desire to connect to the destination
tsocket_address by calling tsocket_connect_send() and gets back a tevent_req.
The caller sets a callback function via tevent_req_set_callback().
The callback function is called if the tsocket is connected or an error has happened.
The callback function needs to get the result by calling
tsocket_connect_recv(). The return value of tsocket_connect_recv()
matches the return value from tsocket_connect()/tsocket_get_status().
A possible errno is delivered via the perrno parameter instead of the global
errno variable.
struct tevent_req *tsocket_connect_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
const struct tsocket_address *dst);
int tsocket_connect_recv(struct tevent_req *req, int *perrno);
To send an 'iovec' there's a wrapper for tsocket_writev().
The caller calls tsocket_writev_send() instead of tsocket_writev()
which returns a tevent_req allocated on the given TALLOC_CTX.
The caller attaches a callback function to the returned tevent_req via
tevent_req_set_callback(). The callback function is called when the whole iovec
was deliviered into the socket or an error has happened.
The callback function needs to get the result by calling
tsocket_writev_recv(). The return value of tsocket_writev_recv()
matches the return value from tsocket_writev(). A possible errno is delivered
via the perrno parameter instead of the global errno variable.
Normal callers should not use this function directly, they should use
tsocket_writev_queue_send/recv() instead.
struct tevent_req *tsocket_writev_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
const struct iovec *vector,
size_t count);
int tsocket_writev_recv(struct tevent_req *req, int *perrno);
As only one async tsocket_writev() call should happen at a time,
there's a 'tevent_queue' is used to serialize the writev requests.
struct tevent_req *tsocket_writev_queue_send(TALLOC_CTX *mem_ctx,
struct tsocket_context *sock,
struct tevent_queue *queue,
const struct iovec *vector,
size_t count);
int tsocket_writev_queue_recv(struct tevent_req *req, int *perrno);
For TSOCKET_TYPE_STREAM sockets, it's typically desired to split the stream
into PDUs. That's why the helper function for tsocket_readv() is a bit
different compared to the other helper functions. The general rule
is still to get a tevent_req, set a callback which gets called when the
operation is done. The callback function needs to get the result by
calling tsocket_readv_recv(). The 'next_iovec' callback function
makes the difference to the other helper function.
The tsocket_writev_send/recv() logic asks the caller via the
next_iovec_fn for an iovec array, which will be filled completely
with bytes from the socket, then the next_iovec_fn is called for
the next iovec array to fill, untill the next_iovec_fn returns an empty
iovec array. That next_iovec_fn should allocate the array as child of the
passed mem_ctx, while the buffers the array referr to belong to the caller.
The tsocket_writev_send/recv() engine will modify and free the given array!
The basic idea is that the caller allocates and maintains the real buffers.
The next_iovec_fn should report error by returning -1 and setting errno to
the specific error code. The engine will pass the error to the caller
via tsocket_readv_recv().
typedef int (*tsocket_readv_next_iovec_t)(struct tsocket_context *sock,
void *private_data,
TALLOC_CTX *mem_ctx,
struct iovec **vector,
size_t *count);
struct tevent_req *tsocket_readv_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
tsocket_readv_next_iovec_t next_iovec_fn,
void *private_data);
int tsocket_readv_recv(struct tevent_req *req, int *perrno);
Wrapper for BSD style sockets
=============================
Support for BSD style sockets of AF_INET, AF_INET6 and AF_UNIX
are part of the main tsocket library.
To wrap an existing fd into a tsocket_context the function
tsocket_context_bsd_wrap_existing() can be used.
The caller needs to make sure the fd is marked as non-blocking!
Normaly the tsocket_disconnect() function would close the fd,
but the caller can influence this behavior based on the close_on_disconnect
parameter. The caller should also make sure that the socket is only
accessed via the tsocket_context wrapper after the call to
tsocket_context_bsd_wrap_existing().
int tsocket_context_bsd_wrap_existing(TALLOC_CTX *mem_ctx,
int fd, bool close_on_disconnect,
struct tsocket_context **_sock);
To create a tsocket_address for an inet address you need to use
the tsocket_address_inet_from_strings() function. It takes the family
as parameter which can be "ipv4", "ipv6" or "ip", where "ip" autodetects
"ipv4" or "ipv6", based on the given address string. Depending on the
operating system, "ipv6" may not be supported. Note: NULL as address
is mapped to "0.0.0.0" or "::" based on the given family.
The address parameter only accepts valid ipv4 or ipv6 address strings
and no names! The caller need to resolve names before using this function.
int tsocket_address_inet_from_strings(TALLOC_CTX *mem_ctx,
const char *family,
const char *address,
uint16_t port,
struct tsocket_address **addr);
To get the address of the inet tsocket_address as string the
tsocket_address_inet_addr_string() function should be used.
The caller should not try to parse the tsocket_address_string() output!
char *tsocket_address_inet_addr_string(const struct tsocket_address *addr,
TALLOC_CTX *mem_ctx);
To get the port number of the inet tsocket_address the
tsocket_address_inet_port() function should be used.
The caller should not try to parse the tsocket_address_string() output!
uint16_t tsocket_address_inet_port(const struct tsocket_address *addr);
To alter the port number of an inet tsocket_address the
tsocket_address_inet_set_port() function can be used.
This is usefull if the caller gets the address from
tsocket_address_copy(), tsocket_context_remote_address() or
tsocket_context_remote_address() instead of tsocket_address_inet_from_strings().
int tsocket_address_inet_set_port(struct tsocket_address *addr,
uint16_t port);
If the caller wants to create a broadcast socket, with the SO_BROADCAST
socket option, the broadcast option needs to be set with the
tsocket_address_inet_set_broadcast() function before calling
tsocket_address_create_socket().
void tsocket_address_inet_set_broadcast(struct tsocket_address *addr,
bool broadcast);
To create a tsocket_address for AF_UNIX style sockets the
tsocket_address_unix_from_path() should be used.
NULL as path is handled like "".
int tsocket_address_unix_from_path(TALLOC_CTX *mem_ctx,
const char *path,
struct tsocket_address **addr);
To get the unix path of an existing unix tsocket_address
the tsocket_address_unix_path() should be used.
The caller should not try to parse the tsocket_address_string() output!
char *tsocket_address_unix_path(const struct tsocket_address *addr,
TALLOC_CTX *mem_ctx);

View File

@ -0,0 +1,177 @@
/*
Unix SMB/CIFS implementation.
Copyright (C) Stefan Metzmacher 2009
** NOTE! The following LGPL license applies to the tevent
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "replace.h"
#include "system/network.h"
#include "system/filesys.h"
#include "tsocket.h"
#include "tsocket_internal.h"
int tsocket_error_from_errno(int ret,
int sys_errno,
bool *retry)
{
*retry = false;
if (ret >= 0) {
return 0;
}
if (ret != -1) {
return EIO;
}
if (sys_errno == 0) {
return EIO;
}
if (sys_errno == EINTR) {
*retry = true;
return sys_errno;
}
if (sys_errno == EINPROGRESS) {
*retry = true;
return sys_errno;
}
if (sys_errno == EAGAIN) {
*retry = true;
return sys_errno;
}
#ifdef EWOULDBLOCK
if (sys_errno == EWOULDBLOCK) {
*retry = true;
return sys_errno;
}
#endif
return sys_errno;
}
int tsocket_simple_int_recv(struct tevent_req *req, int *perrno)
{
enum tevent_req_state state;
uint64_t error;
if (!tevent_req_is_error(req, &state, &error)) {
return 0;
}
switch (state) {
case TEVENT_REQ_NO_MEMORY:
*perrno = ENOMEM;
return -1;
case TEVENT_REQ_TIMED_OUT:
*perrno = ETIMEDOUT;
return -1;
case TEVENT_REQ_USER_ERROR:
*perrno = (int)error;
return -1;
default:
*perrno = EIO;
return -1;
}
*perrno = EIO;
return -1;
}
int tsocket_common_prepare_fd(int fd, bool high_fd)
{
int i;
int sys_errno = 0;
int fds[3];
int num_fds = 0;
int result, flags;
if (fd == -1) {
return -1;
}
/* first make a fd >= 3 */
if (high_fd) {
while (fd < 3) {
fds[num_fds++] = fd;
fd = dup(fd);
if (fd == -1) {
sys_errno = errno;
break;
}
}
for (i=0; i<num_fds; i++) {
close(fds[i]);
}
if (fd == -1) {
errno = sys_errno;
return fd;
}
}
/* fd should be nonblocking. */
#ifdef O_NONBLOCK
#define FLAG_TO_SET O_NONBLOCK
#else
#ifdef SYSV
#define FLAG_TO_SET O_NDELAY
#else /* BSD */
#define FLAG_TO_SET FNDELAY
#endif
#endif
if ((flags = fcntl(fd, F_GETFL)) == -1) {
goto fail;
}
flags |= FLAG_TO_SET;
if (fcntl(fd, F_SETFL, flags) == -1) {
goto fail;
}
#undef FLAG_TO_SET
/* fd should be closed on exec() */
#ifdef FD_CLOEXEC
result = flags = fcntl(fd, F_GETFD, 0);
if (flags >= 0) {
flags |= FD_CLOEXEC;
result = fcntl(fd, F_SETFD, flags);
}
if (result < 0) {
goto fail;
}
#endif
return fd;
fail:
if (fd != -1) {
sys_errno = errno;
close(fd);
errno = sys_errno;
}
return -1;
}

View File

@ -0,0 +1,157 @@
/*
Unix SMB/CIFS implementation.
Copyright (C) Stefan Metzmacher 2009
** NOTE! The following LGPL license applies to the tevent
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TSOCKET_INTERNAL_H
#define _TSOCKET_INTERNAL_H
struct tsocket_context_ops {
const char *name;
/* event handling */
int (*set_event_context)(struct tsocket_context *sock,
struct tevent_context *ev);
int (*set_read_handler)(struct tsocket_context *sock,
tsocket_event_handler_t handler,
void *private_data);
int (*set_write_handler)(struct tsocket_context *sock,
tsocket_event_handler_t handler,
void *private_data);
/* client ops */
int (*connect_to)(struct tsocket_context *sock,
const struct tsocket_address *remote_addr);
/* server ops */
int (*listen_on)(struct tsocket_context *sock,
int queue_size);
int (*accept_new)(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
struct tsocket_context **new_sock,
const char *location);
/* general ops */
ssize_t (*pending_data)(struct tsocket_context *sock);
int (*readv_data)(struct tsocket_context *sock,
const struct iovec *vector, size_t count);
int (*writev_data)(struct tsocket_context *sock,
const struct iovec *vector, size_t count);
ssize_t (*recvfrom_data)(struct tsocket_context *sock,
uint8_t *data, size_t len,
TALLOC_CTX *addr_ctx,
struct tsocket_address **remote_addr);
ssize_t (*sendto_data)(struct tsocket_context *sock,
const uint8_t *data, size_t len,
const struct tsocket_address *remote_addr);
/* info */
int (*get_status)(const struct tsocket_context *sock);
int (*get_local_address)(const struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
struct tsocket_address **local_addr,
const char *location);
int (*get_remote_address)(const struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
struct tsocket_address **remote_addr,
const char *location);
/* options */
int (*get_option)(const struct tsocket_context *sock,
const char *option,
TALLOC_CTX *mem_ctx,
char **value);
int (*set_option)(const struct tsocket_context *sock,
const char *option,
bool force,
const char *value);
/* close/disconnect */
void (*disconnect)(struct tsocket_context *sock);
};
struct tsocket_context {
const char *location;
const struct tsocket_context_ops *ops;
void *private_data;
struct {
struct tevent_context *ctx;
void *read_private;
tsocket_event_handler_t read_handler;
void *write_private;
tsocket_event_handler_t write_handler;
} event;
};
struct tsocket_context *_tsocket_context_create(TALLOC_CTX *mem_ctx,
const struct tsocket_context_ops *ops,
void *pstate,
size_t psize,
const char *type,
const char *location);
#define tsocket_context_create(mem_ctx, ops, state, type, location) \
_tsocket_context_create(mem_ctx, ops, state, sizeof(type), \
#type, location)
struct tsocket_address_ops {
const char *name;
char *(*string)(const struct tsocket_address *addr,
TALLOC_CTX *mem_ctx);
struct tsocket_address *(*copy)(const struct tsocket_address *addr,
TALLOC_CTX *mem_ctx,
const char *location);
int (*create_socket)(const struct tsocket_address *addr,
enum tsocket_type,
TALLOC_CTX *mem_ctx,
struct tsocket_context **sock,
const char *location);
};
struct tsocket_address {
const char *location;
const struct tsocket_address_ops *ops;
void *private_data;
};
struct tsocket_address *_tsocket_address_create(TALLOC_CTX *mem_ctx,
const struct tsocket_address_ops *ops,
void *pstate,
size_t psize,
const char *type,
const char *location);
#define tsocket_address_create(mem_ctx, ops, state, type, location) \
_tsocket_address_create(mem_ctx, ops, state, sizeof(type), \
#type, location)
int tsocket_error_from_errno(int ret, int sys_errno, bool *retry);
int tsocket_simple_int_recv(struct tevent_req *req, int *perrno);
int tsocket_common_prepare_fd(int fd, bool high_fd);
#endif /* _TSOCKET_H */

222
lib/tsocket/tsocket_readv.c Normal file
View File

@ -0,0 +1,222 @@
/*
Unix SMB/CIFS implementation.
Copyright (C) Stefan Metzmacher 2009
** NOTE! The following LGPL license applies to the tevent
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "replace.h"
#include "system/network.h"
#include "tsocket.h"
#include "tsocket_internal.h"
struct tsocket_readv_state {
/* this structs are owned by the caller */
struct {
struct tsocket_context *sock;
tsocket_readv_next_iovec_t next_iovec_fn;
void *private_data;
} caller;
/*
* Each call to the callback resets iov and count
* the callback allocated the iov as child of our state,
* that means we are allowed to modify and free it.
*
* we should call the callback every time we filled the given
* vector and ask for a new vector. We return if the callback
* ask for 0 bytes.
*/
struct iovec *iov;
size_t count;
/*
* the total number of bytes we read,
* the return value of the _recv function
*/
int total_read;
};
static int tsocket_readv_state_destructor(struct tsocket_readv_state *state)
{
if (state->caller.sock) {
tsocket_set_readable_handler(state->caller.sock, NULL, NULL);
}
ZERO_STRUCT(state->caller);
return 0;
}
static bool tsocket_readv_ask_for_next_vector(struct tevent_req *req,
struct tsocket_readv_state *state)
{
int ret;
int err;
bool dummy;
size_t to_read = 0;
size_t i;
talloc_free(state->iov);
state->iov = NULL;
state->count = 0;
ret = state->caller.next_iovec_fn(state->caller.sock,
state->caller.private_data,
state, &state->iov, &state->count);
err = tsocket_error_from_errno(ret, errno, &dummy);
if (tevent_req_error(req, err)) {
return false;
}
for (i=0; i < state->count; i++) {
size_t tmp = to_read;
tmp += state->iov[i].iov_len;
if (tmp < to_read) {
tevent_req_error(req, EMSGSIZE);
return false;
}
to_read = tmp;
}
if (to_read == 0) {
tevent_req_done(req);
return false;
}
if (state->total_read + to_read < state->total_read) {
tevent_req_error(req, EMSGSIZE);
return false;
}
return true;
}
static void tsocket_readv_handler(struct tsocket_context *sock,
void *private_data);
struct tevent_req *tsocket_readv_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
tsocket_readv_next_iovec_t next_iovec_fn,
void *private_data)
{
struct tevent_req *req;
struct tsocket_readv_state *state;
int ret;
int err;
bool dummy;
req = tevent_req_create(mem_ctx, &state,
struct tsocket_readv_state);
if (!req) {
return NULL;
}
state->caller.sock = sock;
state->caller.next_iovec_fn = next_iovec_fn;
state->caller.private_data = private_data;
state->iov = NULL;
state->count = 0;
state->total_read = 0;
if (!tsocket_readv_ask_for_next_vector(req, state)) {
goto post;
}
talloc_set_destructor(state, tsocket_readv_state_destructor);
ret = tsocket_set_readable_handler(sock,
tsocket_readv_handler,
req);
err = tsocket_error_from_errno(ret, errno, &dummy);
if (tevent_req_error(req, err)) {
goto post;
}
return req;
post:
return tevent_req_post(req, sock->event.ctx);
}
static void tsocket_readv_handler(struct tsocket_context *sock,
void *private_data)
{
struct tevent_req *req = talloc_get_type(private_data,
struct tevent_req);
struct tsocket_readv_state *state = tevent_req_data(req,
struct tsocket_readv_state);
ssize_t ret;
int err;
bool retry;
ret = tsocket_readv(state->caller.sock,
state->iov,
state->count);
err = tsocket_error_from_errno(ret, errno, &retry);
if (retry) {
/* retry later */
return;
}
if (tevent_req_error(req, err)) {
return;
}
state->total_read += ret;
while (ret > 0) {
if (ret < state->iov[0].iov_len) {
uint8_t *base;
base = (uint8_t *)state->iov[0].iov_base;
base += ret;
state->iov[0].iov_base = base;
state->iov[0].iov_len -= ret;
break;
}
ret -= state->iov[0].iov_len;
state->iov += 1;
state->count -= 1;
}
if (state->count) {
/* we have more to read */
return;
}
/* ask the callback for a new vector we should fill */
tsocket_readv_ask_for_next_vector(req, state);
}
int tsocket_readv_recv(struct tevent_req *req, int *perrno)
{
struct tsocket_readv_state *state = tevent_req_data(req,
struct tsocket_readv_state);
int ret;
ret = tsocket_simple_int_recv(req, perrno);
if (ret == 0) {
ret = state->total_read;
}
tevent_req_received(req);
return ret;
}

View File

@ -0,0 +1,164 @@
/*
Unix SMB/CIFS implementation.
Copyright (C) Stefan Metzmacher 2009
** NOTE! The following LGPL license applies to the tevent
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "replace.h"
#include "system/network.h"
#include "tsocket.h"
#include "tsocket_internal.h"
struct tsocket_recvfrom_state {
/* this structs are owned by the caller */
struct {
struct tsocket_context *sock;
} caller;
uint8_t *buf;
size_t len;
struct tsocket_address *src;
};
static int tsocket_recvfrom_state_destructor(struct tsocket_recvfrom_state *state)
{
if (state->caller.sock) {
tsocket_set_readable_handler(state->caller.sock, NULL, NULL);
}
ZERO_STRUCT(state->caller);
return 0;
}
static void tsocket_recvfrom_handler(struct tsocket_context *sock,
void *private_data);
struct tevent_req *tsocket_recvfrom_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx)
{
struct tevent_req *req;
struct tsocket_recvfrom_state *state;
int ret;
int err;
bool dummy;
req = tevent_req_create(mem_ctx, &state,
struct tsocket_recvfrom_state);
if (!req) {
return NULL;
}
state->caller.sock = sock;
state->buf = NULL;
state->len = 0;
state->src = NULL;
talloc_set_destructor(state, tsocket_recvfrom_state_destructor);
ret = tsocket_set_readable_handler(sock,
tsocket_recvfrom_handler,
req);
err = tsocket_error_from_errno(ret, errno, &dummy);
if (tevent_req_error(req, err)) {
goto post;
}
return req;
post:
return tevent_req_post(req, sock->event.ctx);
}
static void tsocket_recvfrom_handler(struct tsocket_context *sock,
void *private_data)
{
struct tevent_req *req = talloc_get_type(private_data,
struct tevent_req);
struct tsocket_recvfrom_state *state = tevent_req_data(req,
struct tsocket_recvfrom_state);
ssize_t ret;
int err;
bool retry;
ret = tsocket_pending(state->caller.sock);
if (ret == 0) {
/* retry later */
return;
}
err = tsocket_error_from_errno(ret, errno, &retry);
if (retry) {
/* retry later */
return;
}
if (tevent_req_error(req, err)) {
return;
}
state->buf = talloc_array(state, uint8_t, ret);
if (tevent_req_nomem(state->buf, req)) {
return;
}
state->len = ret;
ret = tsocket_recvfrom(state->caller.sock,
state->buf,
state->len,
state,
&state->src);
err = tsocket_error_from_errno(ret, errno, &retry);
if (retry) {
/* retry later */
return;
}
if (tevent_req_error(req, err)) {
return;
}
if (ret != state->len) {
tevent_req_error(req, EIO);
return;
}
tevent_req_done(req);
}
ssize_t tsocket_recvfrom_recv(struct tevent_req *req,
int *perrno,
TALLOC_CTX *mem_ctx,
uint8_t **buf,
struct tsocket_address **src)
{
struct tsocket_recvfrom_state *state = tevent_req_data(req,
struct tsocket_recvfrom_state);
ssize_t ret;
ret = tsocket_simple_int_recv(req, perrno);
if (ret == 0) {
*buf = talloc_move(mem_ctx, &state->buf);
ret = state->len;
if (src) {
*src = talloc_move(mem_ctx, &state->src);
}
}
tevent_req_received(req);
return ret;
}

View File

@ -0,0 +1,271 @@
/*
Unix SMB/CIFS implementation.
Copyright (C) Stefan Metzmacher 2009
** NOTE! The following LGPL license applies to the tevent
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "replace.h"
#include "system/network.h"
#include "tsocket.h"
#include "tsocket_internal.h"
struct tsocket_sendto_state {
/* this structs are owned by the caller */
struct {
struct tsocket_context *sock;
const uint8_t *buf;
size_t len;
const struct tsocket_address *dst;
} caller;
ssize_t ret;
};
static int tsocket_sendto_state_destructor(struct tsocket_sendto_state *state)
{
if (state->caller.sock) {
tsocket_set_writeable_handler(state->caller.sock, NULL, NULL);
}
ZERO_STRUCT(state->caller);
return 0;
}
static void tsocket_sendto_handler(struct tsocket_context *sock,
void *private_data);
struct tevent_req *tsocket_sendto_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
const uint8_t *buf,
size_t len,
const struct tsocket_address *dst)
{
struct tevent_req *req;
struct tsocket_sendto_state *state;
int ret;
int err;
bool dummy;
req = tevent_req_create(mem_ctx, &state,
struct tsocket_sendto_state);
if (!req) {
return NULL;
}
state->caller.sock = sock;
state->caller.buf = buf;
state->caller.len = len;
state->caller.dst = dst;
state->ret = -1;
/*
* this is a fast path, not waiting for the
* socket to become explicit writeable gains
* about 10%-20% performance in benchmark tests.
*/
tsocket_sendto_handler(sock, req);
if (!tevent_req_is_in_progress(req)) {
goto post;
}
talloc_set_destructor(state, tsocket_sendto_state_destructor);
ret = tsocket_set_writeable_handler(sock,
tsocket_sendto_handler,
req);
err = tsocket_error_from_errno(ret, errno, &dummy);
if (tevent_req_error(req, err)) {
goto post;
}
return req;
post:
return tevent_req_post(req, sock->event.ctx);
}
static void tsocket_sendto_handler(struct tsocket_context *sock,
void *private_data)
{
struct tevent_req *req = talloc_get_type(private_data,
struct tevent_req);
struct tsocket_sendto_state *state = tevent_req_data(req,
struct tsocket_sendto_state);
ssize_t ret;
int err;
bool retry;
ret = tsocket_sendto(state->caller.sock,
state->caller.buf,
state->caller.len,
state->caller.dst);
err = tsocket_error_from_errno(ret, errno, &retry);
if (retry) {
/* retry later */
return;
}
if (tevent_req_error(req, err)) {
return;
}
state->ret = ret;
tevent_req_done(req);
}
ssize_t tsocket_sendto_recv(struct tevent_req *req, int *perrno)
{
struct tsocket_sendto_state *state = tevent_req_data(req,
struct tsocket_sendto_state);
ssize_t ret;
ret = tsocket_simple_int_recv(req, perrno);
if (ret == 0) {
ret = state->ret;
}
tevent_req_received(req);
return ret;
}
struct tsocket_sendto_queue_state {
/* this structs are owned by the caller */
struct {
struct tsocket_context *sock;
const uint8_t *buf;
size_t len;
const struct tsocket_address *dst;
} caller;
ssize_t ret;
};
static void tsocket_sendto_queue_trigger(struct tevent_req *req,
void *private_data);
static void tsocket_sendto_queue_done(struct tevent_req *subreq);
/**
* @brief Queue a dgram blob for sending through the socket
* @param[in] mem_ctx The memory context for the result
* @param[in] sock The socket to send the message buffer
* @param[in] queue The existing dgram queue
* @param[in] buf The message buffer
* @param[in] len The message length
* @param[in] dst The destination socket address
* @retval The async request handle
*
* This function queues a blob for sending to destination through an existing
* dgram socket. The async callback is triggered when the whole blob is
* delivered to the underlying system socket.
*
* The caller needs to make sure that all non-scalar input parameters hang
* arround for the whole lifetime of the request.
*/
struct tevent_req *tsocket_sendto_queue_send(TALLOC_CTX *mem_ctx,
struct tsocket_context *sock,
struct tevent_queue *queue,
const uint8_t *buf,
size_t len,
struct tsocket_address *dst)
{
struct tevent_req *req;
struct tsocket_sendto_queue_state *state;
bool ok;
req = tevent_req_create(mem_ctx, &state,
struct tsocket_sendto_queue_state);
if (!req) {
return NULL;
}
state->caller.sock = sock;
state->caller.buf = buf;
state->caller.len = len;
state->caller.dst = dst;
state->ret = -1;
ok = tevent_queue_add(queue,
sock->event.ctx,
req,
tsocket_sendto_queue_trigger,
NULL);
if (!ok) {
tevent_req_nomem(NULL, req);
goto post;
}
return req;
post:
return tevent_req_post(req, sock->event.ctx);
}
static void tsocket_sendto_queue_trigger(struct tevent_req *req,
void *private_data)
{
struct tsocket_sendto_queue_state *state = tevent_req_data(req,
struct tsocket_sendto_queue_state);
struct tevent_req *subreq;
subreq = tsocket_sendto_send(state->caller.sock,
state,
state->caller.buf,
state->caller.len,
state->caller.dst);
if (tevent_req_nomem(subreq, req)) {
return;
}
tevent_req_set_callback(subreq, tsocket_sendto_queue_done ,req);
}
static void tsocket_sendto_queue_done(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(subreq,
struct tevent_req);
struct tsocket_sendto_queue_state *state = tevent_req_data(req,
struct tsocket_sendto_queue_state);
ssize_t ret;
int sys_errno;
ret = tsocket_sendto_recv(subreq, &sys_errno);
talloc_free(subreq);
if (ret == -1) {
tevent_req_error(req, sys_errno);
return;
}
state->ret = ret;
tevent_req_done(req);
}
ssize_t tsocket_sendto_queue_recv(struct tevent_req *req, int *perrno)
{
struct tsocket_sendto_queue_state *state = tevent_req_data(req,
struct tsocket_sendto_queue_state);
ssize_t ret;
ret = tsocket_simple_int_recv(req, perrno);
if (ret == 0) {
ret = state->ret;
}
tevent_req_received(req);
return ret;
}

View File

@ -0,0 +1,316 @@
/*
Unix SMB/CIFS implementation.
Copyright (C) Stefan Metzmacher 2009
** NOTE! The following LGPL license applies to the tevent
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "replace.h"
#include "system/network.h"
#include "tsocket.h"
#include "tsocket_internal.h"
struct tsocket_writev_state {
/* this structs are owned by the caller */
struct {
struct tsocket_context *sock;
const struct iovec *vector;
size_t count;
} caller;
struct iovec *iov;
size_t count;
int total_written;
};
static int tsocket_writev_state_destructor(struct tsocket_writev_state *state)
{
if (state->caller.sock) {
tsocket_set_writeable_handler(state->caller.sock, NULL, NULL);
}
ZERO_STRUCT(state->caller);
return 0;
}
static void tsocket_writev_handler(struct tsocket_context *sock,
void *private_data);
struct tevent_req *tsocket_writev_send(struct tsocket_context *sock,
TALLOC_CTX *mem_ctx,
const struct iovec *vector,
size_t count)
{
struct tevent_req *req;
struct tsocket_writev_state *state;
int ret;
int err;
bool dummy;
int to_write = 0;
size_t i;
req = tevent_req_create(mem_ctx, &state,
struct tsocket_writev_state);
if (!req) {
return NULL;
}
state->caller.sock = sock;
state->caller.vector = vector;
state->caller.count = count;
state->iov = NULL;
state->count = count;
state->total_written = 0;
state->iov = talloc_array(state, struct iovec, count);
if (tevent_req_nomem(state->iov, req)) {
goto post;
}
memcpy(state->iov, vector, sizeof(struct iovec) * count);
for (i=0; i < count; i++) {
int tmp = to_write;
tmp += state->iov[i].iov_len;
if (tmp < to_write) {
tevent_req_error(req, EMSGSIZE);
goto post;
}
to_write = tmp;
}
if (to_write == 0) {
tevent_req_done(req);
goto post;
}
/*
* this is a fast path, not waiting for the
* socket to become explicit writeable gains
* about 10%-20% performance in benchmark tests.
*/
tsocket_writev_handler(sock, req);
if (!tevent_req_is_in_progress(req)) {
goto post;
}
talloc_set_destructor(state, tsocket_writev_state_destructor);
ret = tsocket_set_writeable_handler(sock,
tsocket_writev_handler,
req);
err = tsocket_error_from_errno(ret, errno, &dummy);
if (tevent_req_error(req, err)) {
goto post;
}
return req;
post:
return tevent_req_post(req, sock->event.ctx);
}
static void tsocket_writev_handler(struct tsocket_context *sock,
void *private_data)
{
struct tevent_req *req = talloc_get_type(private_data,
struct tevent_req);
struct tsocket_writev_state *state = tevent_req_data(req,
struct tsocket_writev_state);
int ret;
int err;
bool retry;
ret = tsocket_writev(state->caller.sock,
state->iov,
state->count);
err = tsocket_error_from_errno(ret, errno, &retry);
if (retry) {
/* retry later */
return;
}
if (tevent_req_error(req, err)) {
return;
}
state->total_written += ret;
/*
* we have not written everything yet, so we need to truncate
* the already written bytes from our iov copy
*/
while (ret > 0) {
if (ret < state->iov[0].iov_len) {
uint8_t *base;
base = (uint8_t *)state->iov[0].iov_base;
base += ret;
state->iov[0].iov_base = base;
state->iov[0].iov_len -= ret;
break;
}
ret -= state->iov[0].iov_len;
state->iov += 1;
state->count -= 1;
}
if (state->count > 0) {
/* more to write */
return;
}
tevent_req_done(req);
}
int tsocket_writev_recv(struct tevent_req *req, int *perrno)
{
struct tsocket_writev_state *state = tevent_req_data(req,
struct tsocket_writev_state);
int ret;
ret = tsocket_simple_int_recv(req, perrno);
if (ret == 0) {
ret = state->total_written;
}
tevent_req_received(req);
return ret;
}
struct tsocket_writev_queue_state {
/* this structs are owned by the caller */
struct {
struct tsocket_context *sock;
const struct iovec *vector;
size_t count;
} caller;
int ret;
};
static void tsocket_writev_queue_trigger(struct tevent_req *req,
void *private_data);
static void tsocket_writev_queue_done(struct tevent_req *subreq);
/**
* @brief Queue a dgram blob for sending through the socket
* @param[in] mem_ctx The memory context for the result
* @param[in] sock The socket to send data through
* @param[in] queue The existing send queue
* @param[in] vector The iovec vector so write
* @param[in] count The size of the vector
* @retval The async request handle
*
* This function queues a blob for sending to destination through an existing
* dgram socket. The async callback is triggered when the whole blob is
* delivered to the underlying system socket.
*
* The caller needs to make sure that all non-scalar input parameters hang
* arround for the whole lifetime of the request.
*/
struct tevent_req *tsocket_writev_queue_send(TALLOC_CTX *mem_ctx,
struct tsocket_context *sock,
struct tevent_queue *queue,
const struct iovec *vector,
size_t count)
{
struct tevent_req *req;
struct tsocket_writev_queue_state *state;
bool ok;
req = tevent_req_create(mem_ctx, &state,
struct tsocket_writev_queue_state);
if (!req) {
return NULL;
}
state->caller.sock = sock;
state->caller.vector = vector;
state->caller.count = count;
state->ret = -1;
ok = tevent_queue_add(queue,
sock->event.ctx,
req,
tsocket_writev_queue_trigger,
NULL);
if (!ok) {
tevent_req_nomem(NULL, req);
goto post;
}
return req;
post:
return tevent_req_post(req, sock->event.ctx);
}
static void tsocket_writev_queue_trigger(struct tevent_req *req,
void *private_data)
{
struct tsocket_writev_queue_state *state = tevent_req_data(req,
struct tsocket_writev_queue_state);
struct tevent_req *subreq;
subreq = tsocket_writev_send(state->caller.sock,
state,
state->caller.vector,
state->caller.count);
if (tevent_req_nomem(subreq, req)) {
return;
}
tevent_req_set_callback(subreq, tsocket_writev_queue_done ,req);
}
static void tsocket_writev_queue_done(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(subreq,
struct tevent_req);
struct tsocket_writev_queue_state *state = tevent_req_data(req,
struct tsocket_writev_queue_state);
int ret;
int sys_errno;
ret = tsocket_writev_recv(subreq, &sys_errno);
talloc_free(subreq);
if (ret == -1) {
tevent_req_error(req, sys_errno);
return;
}
state->ret = ret;
tevent_req_done(req);
}
int tsocket_writev_queue_recv(struct tevent_req *req, int *perrno)
{
struct tsocket_writev_queue_state *state = tevent_req_data(req,
struct tsocket_writev_queue_state);
int ret;
ret = tsocket_simple_int_recv(req, perrno);
if (ret == 0) {
ret = state->ret;
}
tevent_req_received(req);
return ret;
}

View File

@ -5,7 +5,7 @@ PUBLIC_DEPENDENCIES = \
CHARSET EXECINFO
LIBSAMBA-UTIL_OBJ_FILES = $(addprefix $(libutilsrcdir)/, \
xfile.o \
xfile.o \
debug.o \
fault.o \
signal.o \
@ -68,6 +68,13 @@ PUBLIC_DEPENDENCIES = LIBTDB
UTIL_TDB_OBJ_FILES = $(libutilsrcdir)/util_tdb.o
[SUBSYSTEM::UTIL_TEVENT]
PUBLIC_DEPENDENCIES = LIBTEVENT
UTIL_TEVENT_OBJ_FILES = $(addprefix $(libutilsrcdir)/, \
tevent_unix.o \
tevent_ntstatus.o)
[SUBSYSTEM::UTIL_LDB]
PUBLIC_DEPENDENCIES = LIBLDB

View File

@ -8,6 +8,7 @@ if test x"$ac_cv_header_execinfo_h" = x"yes" -a x"$ac_cv_func_ext_backtrace" = x
EXECINFO_CFLAGS="$CFLAGS"
EXECINFO_CPPFLAGS="$CPPFLAGS"
EXECINFO_LDFLAGS="$LDFLAGS"
LIB_REMOVE_USR_LIB(EXECINFO_LDFLAGS)
else
SMB_ENABLE(EXECINFO,NO)
fi

1125
libcli/cldap/cldap.c Normal file

File diff suppressed because it is too large Load Diff

133
libcli/cldap/cldap.h Normal file
View File

@ -0,0 +1,133 @@
/*
Unix SMB/CIFS implementation.
a async CLDAP library
Copyright (C) Andrew Tridgell 2005
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../libcli/netlogon.h"
struct ldap_message;
struct tsocket_address;
struct cldap_socket;
struct cldap_incoming {
int recv_errno;
uint8_t *buf;
size_t len;
struct tsocket_address *src;
struct ldap_message *ldap_msg;
};
/*
a general cldap search request
*/
struct cldap_search {
struct {
const char *dest_address;
uint16_t dest_port;
const char *filter;
const char * const *attributes;
int timeout;
int retries;
} in;
struct {
struct ldap_SearchResEntry *response;
struct ldap_Result *result;
} out;
};
NTSTATUS cldap_socket_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
const struct tsocket_address *local_addr,
const struct tsocket_address *remote_addr,
struct cldap_socket **_cldap);
NTSTATUS cldap_set_incoming_handler(struct cldap_socket *cldap,
void (*handler)(struct cldap_socket *,
void *private_data,
struct cldap_incoming *),
void *private_data);
struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
struct cldap_socket *cldap,
const struct cldap_search *io);
NTSTATUS cldap_search_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
struct cldap_search *io);
NTSTATUS cldap_search(struct cldap_socket *cldap, TALLOC_CTX *mem_ctx,
struct cldap_search *io);
/*
a general cldap reply
*/
struct cldap_reply {
uint32_t messageid;
struct tsocket_address *dest;
struct ldap_SearchResEntry *response;
struct ldap_Result *result;
};
NTSTATUS cldap_reply_send(struct cldap_socket *cldap, struct cldap_reply *io);
NTSTATUS cldap_empty_reply(struct cldap_socket *cldap,
uint32_t message_id,
struct tsocket_address *dst);
NTSTATUS cldap_error_reply(struct cldap_socket *cldap,
uint32_t message_id,
struct tsocket_address *dst,
int resultcode,
const char *errormessage);
/*
a netlogon cldap request
*/
struct cldap_netlogon {
struct {
const char *dest_address;
uint16_t dest_port;
const char *realm;
const char *host;
const char *user;
const char *domain_guid;
const char *domain_sid;
int acct_control;
uint32_t version;
bool map_response;
} in;
struct {
struct netlogon_samlogon_response netlogon;
} out;
};
struct tevent_req *cldap_netlogon_send(TALLOC_CTX *mem_ctx,
struct cldap_socket *cldap,
const struct cldap_netlogon *io);
NTSTATUS cldap_netlogon_recv(struct tevent_req *req,
struct smb_iconv_convenience *iconv_convenience,
TALLOC_CTX *mem_ctx,
struct cldap_netlogon *io);
NTSTATUS cldap_netlogon(struct cldap_socket *cldap,
struct smb_iconv_convenience *iconv_convenience,
TALLOC_CTX *mem_ctx,
struct cldap_netlogon *io);
NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap,
struct smb_iconv_convenience *iconv_convenience,
uint32_t message_id,
struct tsocket_address *dst,
uint32_t version,
struct netlogon_samlogon_response *netlogon);

7
libcli/cldap/config.mk Normal file
View File

@ -0,0 +1,7 @@
[SUBSYSTEM::LIBCLI_CLDAP]
PUBLIC_DEPENDENCIES = LIBCLI_LDAP
PRIVATE_DEPENDENCIES = LIBTSOCKET LIBSAMBA-UTIL UTIL_TEVENT LIBLDB LIBCLI_NETLOGON
LIBCLI_CLDAP_OBJ_FILES = ../libcli/cldap/cldap.o
# PUBLIC_HEADERS += ../libcli/cldap/cldap.h

View File

@ -1302,8 +1302,8 @@ NTSTATUS rpccli_spoolss_GetPrinterData(struct rpc_pipe_client *cli,
struct policy_handle *handle /* [in] [ref] */,
const char *value_name /* [in] [charset(UTF16)] */,
uint32_t offered /* [in] */,
enum spoolss_PrinterDataType *type /* [out] [ref] */,
union spoolss_PrinterData data /* [out] [subcontext_size(offered),subcontext(4),switch_is(*type)] */,
enum winreg_Type *type /* [out] [ref] */,
union spoolss_PrinterData *data /* [out] [subcontext_size(offered),ref,subcontext(4),switch_is(*type)] */,
uint32_t *needed /* [out] [ref] */,
WERROR *werror)
{
@ -1339,7 +1339,7 @@ NTSTATUS rpccli_spoolss_GetPrinterData(struct rpc_pipe_client *cli,
/* Return variables */
*type = *r.out.type;
return NT_STATUS_NOT_SUPPORTED;
*data = *r.out.data;
*needed = *r.out.needed;
/* Return result */
@ -1354,7 +1354,7 @@ NTSTATUS rpccli_spoolss_SetPrinterData(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle /* [in] [ref] */,
const char *value_name /* [in] [charset(UTF16)] */,
enum spoolss_PrinterDataType type /* [in] */,
enum winreg_Type type /* [in] */,
union spoolss_PrinterData data /* [in] [subcontext(4),switch_is(type)] */,
uint32_t _offered /* [in] [value(ndr_size_spoolss_PrinterData(&data,type,ndr->iconv_convenience,flags))] */,
WERROR *werror)
@ -3426,8 +3426,8 @@ NTSTATUS rpccli_spoolss_EnumPrinterData(struct rpc_pipe_client *cli,
const char *value_name /* [out] [charset(UTF16),size_is(value_offered/2)] */,
uint32_t value_offered /* [in] */,
uint32_t *value_needed /* [out] [ref] */,
uint32_t *printerdata_type /* [out] [ref] */,
DATA_BLOB *buffer /* [out] [ref] */,
enum winreg_Type *type /* [out] [ref] */,
uint8_t *data /* [out] [ref,flag(LIBNDR_PRINT_ARRAY_HEX),size_is(data_offered)] */,
uint32_t data_offered /* [in] */,
uint32_t *data_needed /* [out] [ref] */,
WERROR *werror)
@ -3466,8 +3466,8 @@ NTSTATUS rpccli_spoolss_EnumPrinterData(struct rpc_pipe_client *cli,
/* Return variables */
memcpy(CONST_DISCARD(char *, value_name), r.out.value_name, r.in.value_offered / 2 * sizeof(*value_name));
*value_needed = *r.out.value_needed;
*printerdata_type = *r.out.printerdata_type;
*buffer = *r.out.buffer;
*type = *r.out.type;
memcpy(data, r.out.data, r.in.data_offered * sizeof(*data));
*data_needed = *r.out.data_needed;
/* Return result */
@ -3651,7 +3651,7 @@ NTSTATUS rpccli_spoolss_SetPrinterDataEx(struct rpc_pipe_client *cli,
struct policy_handle *handle /* [in] [ref] */,
const char *key_name /* [in] [charset(UTF16)] */,
const char *value_name /* [in] [charset(UTF16)] */,
uint32_t type /* [in] */,
enum winreg_Type type /* [in] */,
uint8_t *buffer /* [in] [ref,size_is(offered)] */,
uint32_t offered /* [in] */,
WERROR *werror)
@ -3704,7 +3704,7 @@ NTSTATUS rpccli_spoolss_GetPrinterDataEx(struct rpc_pipe_client *cli,
struct policy_handle *handle /* [in] [ref] */,
const char *key_name /* [in] [charset(UTF16)] */,
const char *value_name /* [in] [charset(UTF16)] */,
uint32_t *type /* [out] [ref] */,
enum winreg_Type *type /* [out] [ref] */,
uint8_t *buffer /* [out] [ref,size_is(offered)] */,
uint32_t offered /* [in] */,
uint32_t *needed /* [out] [ref] */,
@ -3758,10 +3758,10 @@ NTSTATUS rpccli_spoolss_EnumPrinterDataEx(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle /* [in] [ref] */,
const char *key_name /* [in] [charset(UTF16)] */,
uint8_t *buffer /* [out] [ref,size_is(offered)] */,
uint32_t offered /* [in] */,
uint32_t *needed /* [out] [ref] */,
uint32_t *count /* [out] [ref] */,
struct spoolss_PrinterEnumValues **info /* [out] [ref,size_is(,*count)] */,
uint32_t *needed /* [out] [ref] */,
WERROR *werror)
{
struct spoolss_EnumPrinterDataEx r;
@ -3795,9 +3795,9 @@ NTSTATUS rpccli_spoolss_EnumPrinterDataEx(struct rpc_pipe_client *cli,
}
/* Return variables */
memcpy(buffer, r.out.buffer, r.in.offered * sizeof(*buffer));
*needed = *r.out.needed;
*count = *r.out.count;
*info = *r.out.info;
*needed = *r.out.needed;
/* Return result */
if (werror) {
@ -3811,8 +3811,8 @@ NTSTATUS rpccli_spoolss_EnumPrinterKey(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle /* [in] [ref] */,
const char *key_name /* [in] [charset(UTF16)] */,
uint16_t *key_buffer /* [out] [ref,size_is(key_buffer_size/2)] */,
uint32_t key_buffer_size /* [in] */,
const char ** *key_buffer /* [out] [subcontext_size(offered),ref,subcontext(0),flag(LIBNDR_FLAG_STR_NULLTERM)] */,
uint32_t offered /* [in] */,
uint32_t *needed /* [out] [ref] */,
WERROR *werror)
{
@ -3822,7 +3822,7 @@ NTSTATUS rpccli_spoolss_EnumPrinterKey(struct rpc_pipe_client *cli,
/* In parameters */
r.in.handle = handle;
r.in.key_name = key_name;
r.in.key_buffer_size = key_buffer_size;
r.in.offered = offered;
if (DEBUGLEVEL >= 10) {
NDR_PRINT_IN_DEBUG(spoolss_EnumPrinterKey, &r);
@ -3847,7 +3847,7 @@ NTSTATUS rpccli_spoolss_EnumPrinterKey(struct rpc_pipe_client *cli,
}
/* Return variables */
memcpy(key_buffer, r.out.key_buffer, r.in.key_buffer_size / 2 * sizeof(*key_buffer));
*key_buffer = *r.out.key_buffer;
*needed = *r.out.needed;
/* Return result */

View File

@ -191,15 +191,15 @@ NTSTATUS rpccli_spoolss_GetPrinterData(struct rpc_pipe_client *cli,
struct policy_handle *handle /* [in] [ref] */,
const char *value_name /* [in] [charset(UTF16)] */,
uint32_t offered /* [in] */,
enum spoolss_PrinterDataType *type /* [out] [ref] */,
union spoolss_PrinterData data /* [out] [subcontext_size(offered),subcontext(4),switch_is(*type)] */,
enum winreg_Type *type /* [out] [ref] */,
union spoolss_PrinterData *data /* [out] [subcontext_size(offered),ref,subcontext(4),switch_is(*type)] */,
uint32_t *needed /* [out] [ref] */,
WERROR *werror);
NTSTATUS rpccli_spoolss_SetPrinterData(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle /* [in] [ref] */,
const char *value_name /* [in] [charset(UTF16)] */,
enum spoolss_PrinterDataType type /* [in] */,
enum winreg_Type type /* [in] */,
union spoolss_PrinterData data /* [in] [subcontext(4),switch_is(type)] */,
uint32_t _offered /* [in] [value(ndr_size_spoolss_PrinterData(&data,type,ndr->iconv_convenience,flags))] */,
WERROR *werror);
@ -446,8 +446,8 @@ NTSTATUS rpccli_spoolss_EnumPrinterData(struct rpc_pipe_client *cli,
const char *value_name /* [out] [charset(UTF16),size_is(value_offered/2)] */,
uint32_t value_offered /* [in] */,
uint32_t *value_needed /* [out] [ref] */,
uint32_t *printerdata_type /* [out] [ref] */,
DATA_BLOB *buffer /* [out] [ref] */,
enum winreg_Type *type /* [out] [ref] */,
uint8_t *data /* [out] [ref,flag(LIBNDR_PRINT_ARRAY_HEX),size_is(data_offered)] */,
uint32_t data_offered /* [in] */,
uint32_t *data_needed /* [out] [ref] */,
WERROR *werror);
@ -470,7 +470,7 @@ NTSTATUS rpccli_spoolss_SetPrinterDataEx(struct rpc_pipe_client *cli,
struct policy_handle *handle /* [in] [ref] */,
const char *key_name /* [in] [charset(UTF16)] */,
const char *value_name /* [in] [charset(UTF16)] */,
uint32_t type /* [in] */,
enum winreg_Type type /* [in] */,
uint8_t *buffer /* [in] [ref,size_is(offered)] */,
uint32_t offered /* [in] */,
WERROR *werror);
@ -479,7 +479,7 @@ NTSTATUS rpccli_spoolss_GetPrinterDataEx(struct rpc_pipe_client *cli,
struct policy_handle *handle /* [in] [ref] */,
const char *key_name /* [in] [charset(UTF16)] */,
const char *value_name /* [in] [charset(UTF16)] */,
uint32_t *type /* [out] [ref] */,
enum winreg_Type *type /* [out] [ref] */,
uint8_t *buffer /* [out] [ref,size_is(offered)] */,
uint32_t offered /* [in] */,
uint32_t *needed /* [out] [ref] */,
@ -488,17 +488,17 @@ NTSTATUS rpccli_spoolss_EnumPrinterDataEx(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle /* [in] [ref] */,
const char *key_name /* [in] [charset(UTF16)] */,
uint8_t *buffer /* [out] [ref,size_is(offered)] */,
uint32_t offered /* [in] */,
uint32_t *needed /* [out] [ref] */,
uint32_t *count /* [out] [ref] */,
struct spoolss_PrinterEnumValues **info /* [out] [ref,size_is(,*count)] */,
uint32_t *needed /* [out] [ref] */,
WERROR *werror);
NTSTATUS rpccli_spoolss_EnumPrinterKey(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle /* [in] [ref] */,
const char *key_name /* [in] [charset(UTF16)] */,
uint16_t *key_buffer /* [out] [ref,size_is(key_buffer_size/2)] */,
uint32_t key_buffer_size /* [in] */,
const char ** *key_buffer /* [out] [subcontext_size(offered),ref,subcontext(0),flag(LIBNDR_FLAG_STR_NULLTERM)] */,
uint32_t offered /* [in] */,
uint32_t *needed /* [out] [ref] */,
WERROR *werror);
NTSTATUS rpccli_spoolss_DeletePrinterDataEx(struct rpc_pipe_client *cli,

File diff suppressed because it is too large Load Diff

View File

@ -213,7 +213,10 @@ void ndr_print_spoolss_MajorVersion(struct ndr_print *ndr, const char *name, enu
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);
@ -222,27 +225,62 @@ size_t ndr_size_spoolss_DeviceMode(const struct spoolss_DeviceMode *r, struct sm
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);
@ -315,6 +353,7 @@ size_t ndr_size_spoolss_DriverInfo101(const struct spoolss_DriverInfo101 *r, str
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);
@ -348,7 +387,6 @@ enum ndr_err_code ndr_push_spoolss_OSVersionEx(struct ndr_push *ndr, int ndr_fla
enum ndr_err_code ndr_pull_spoolss_OSVersionEx(struct ndr_pull *ndr, int ndr_flags, struct spoolss_OSVersionEx *r);
void ndr_print_spoolss_OSVersionEx(struct ndr_print *ndr, const char *name, const struct spoolss_OSVersionEx *r);
size_t ndr_size_spoolss_OSVersionEx(const struct spoolss_OSVersionEx *r, struct smb_iconv_convenience *ic, int flags);
void ndr_print_spoolss_PrinterDataType(struct ndr_print *ndr, const char *name, enum spoolss_PrinterDataType r);
enum ndr_err_code ndr_push_spoolss_PrinterData(struct ndr_push *ndr, int ndr_flags, const union spoolss_PrinterData *r);
enum ndr_err_code ndr_pull_spoolss_PrinterData(struct ndr_pull *ndr, int ndr_flags, union spoolss_PrinterData *r);
void ndr_print_spoolss_PrinterData(struct ndr_print *ndr, const char *name, const union spoolss_PrinterData *r);
@ -413,8 +451,14 @@ enum ndr_err_code ndr_push_spoolss_PrintProcDataTypesInfo(struct ndr_push *ndr,
enum ndr_err_code ndr_pull_spoolss_PrintProcDataTypesInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_PrintProcDataTypesInfo *r);
void ndr_print_spoolss_PrintProcDataTypesInfo(struct ndr_print *ndr, const char *name, const union spoolss_PrintProcDataTypesInfo *r);
void ndr_print_spoolss_PrinterChangeFlags(struct ndr_print *ndr, const char *name, uint32_t r);
void ndr_print_spoolss_Field(struct ndr_print *ndr, const char *name, enum spoolss_Field r);
enum ndr_err_code ndr_push_spoolss_JobNotifyField(struct ndr_push *ndr, int ndr_flags, enum spoolss_JobNotifyField r);
enum ndr_err_code ndr_pull_spoolss_JobNotifyField(struct ndr_pull *ndr, int ndr_flags, enum spoolss_JobNotifyField *r);
void ndr_print_spoolss_JobNotifyField(struct ndr_print *ndr, const char *name, enum spoolss_JobNotifyField r);
enum ndr_err_code ndr_push_spoolss_PrintNotifyField(struct ndr_push *ndr, int ndr_flags, enum spoolss_PrintNotifyField r);
enum ndr_err_code ndr_pull_spoolss_PrintNotifyField(struct ndr_pull *ndr, int ndr_flags, enum spoolss_PrintNotifyField *r);
void ndr_print_spoolss_PrintNotifyField(struct ndr_print *ndr, const char *name, enum spoolss_PrintNotifyField r);
void ndr_print_spoolss_NotifyType(struct ndr_print *ndr, const char *name, enum spoolss_NotifyType r);
void ndr_print_spoolss_Field(struct ndr_print *ndr, const char *name, const union spoolss_Field *r);
void ndr_print_spoolss_NotifyOptionType(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyOptionType *r);
void ndr_print_spoolssNotifyOptionFlags(struct ndr_print *ndr, const char *name, uint32_t r);
void ndr_print_spoolss_NotifyOption(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyOption *r);
@ -431,6 +475,10 @@ void ndr_print_spoolss_UserLevel3(struct ndr_print *ndr, const char *name, const
void ndr_print_spoolss_UserLevel(struct ndr_print *ndr, const char *name, const union spoolss_UserLevel *r);
void ndr_print_spoolss_UserLevelCtr(struct ndr_print *ndr, const char *name, const struct spoolss_UserLevelCtr *r);
void ndr_print_spoolss_AccessRights(struct ndr_print *ndr, const char *name, uint32_t r);
enum ndr_err_code ndr_push_spoolss_PrinterEnumValues(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterEnumValues *r);
enum ndr_err_code ndr_pull_spoolss_PrinterEnumValues(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterEnumValues *r);
void ndr_print_spoolss_PrinterEnumValues(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterEnumValues *r);
size_t ndr_size_spoolss_PrinterEnumValues(const struct spoolss_PrinterEnumValues *r, struct smb_iconv_convenience *ic, int flags);
enum ndr_err_code ndr_push_spoolss_DeleteDriverFlags(struct ndr_push *ndr, int ndr_flags, uint32_t r);
enum ndr_err_code ndr_pull_spoolss_DeleteDriverFlags(struct ndr_pull *ndr, int ndr_flags, uint32_t *r);
void ndr_print_spoolss_DeleteDriverFlags(struct ndr_print *ndr, const char *name, uint32_t r);
@ -623,6 +671,12 @@ void ndr_print_spoolss_4b(struct ndr_print *ndr, const char *name, int flags, co
void ndr_print_spoolss_4c(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_4c *r);
void ndr_print_spoolss_SetPrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_SetPrinterDataEx *r);
void ndr_print_spoolss_GetPrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinterDataEx *r);
enum ndr_err_code ndr_push__spoolss_EnumPrinterDataEx(struct ndr_push *ndr, int flags, const struct _spoolss_EnumPrinterDataEx *r);
enum ndr_err_code ndr_pull__spoolss_EnumPrinterDataEx(struct ndr_pull *ndr, int flags, struct _spoolss_EnumPrinterDataEx *r);
void ndr_print__spoolss_EnumPrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_EnumPrinterDataEx *r);
enum ndr_err_code ndr_push___spoolss_EnumPrinterDataEx(struct ndr_push *ndr, int flags, const struct __spoolss_EnumPrinterDataEx *r);
enum ndr_err_code ndr_pull___spoolss_EnumPrinterDataEx(struct ndr_pull *ndr, int flags, struct __spoolss_EnumPrinterDataEx *r);
void ndr_print___spoolss_EnumPrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_EnumPrinterDataEx *r);
enum ndr_err_code ndr_push_spoolss_EnumPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterDataEx *r);
enum ndr_err_code ndr_pull_spoolss_EnumPrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDataEx *r);
void ndr_print_spoolss_EnumPrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrinterDataEx *r);

View File

@ -15,6 +15,10 @@
#define PRINTER_ENUM_ICONMASK ( (PRINTER_ENUM_ICON1|PRINTER_ENUM_ICON2|PRINTER_ENUM_ICON3|PRINTER_ENUM_ICON4|PRINTER_ENUM_ICON5|PRINTER_ENUM_ICON6|PRINTER_ENUM_ICON7|PRINTER_ENUM_ICON8) )
#define SPOOLSS_ARCHITECTURE_NT_X86 ( "Windows NT x86" )
#define SPOOLSS_DEFAULT_SERVER_PATH ( "C:\\WINDOWS\\system32\\spool" )
#define SPL_LOCAL_PORT ( "Local Port" )
#define SPL_TCPIP_PORT ( "Standard TCP/IP Port" )
#define SPL_XCV_MONITOR_LOCALMON ( ",XcvMonitor Local Port" )
#define SPL_XCV_MONITOR_TCPMON ( ",XcvMonitor Standard TCP/IP Port" )
#define PRINTER_CHANGE_PRINTER ( 0x000000FF )
#define PRINTER_CHANGE_JOB ( 0x0000FF00 )
#define PRINTER_CHANGE_FORM ( (PRINTER_CHANGE_ADD_FORM|PRINTER_CHANGE_SET_FORM|PRINTER_CHANGE_DELETE_FORM) )
@ -193,7 +197,7 @@ struct spoolss_PrinterInfo0 {
uint32_t ref_ic;
uint32_t reserved2;
uint32_t reserved3;
};
}/* [gensize,public] */;
/* bitmap spoolss_DeviceModeFields */
#define DEVMODE_ORIENTATION ( 0x00000001 )
@ -289,7 +293,7 @@ struct spoolss_PrinterInfo1 {
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 )
@ -324,24 +328,24 @@ struct spoolss_PrinterInfo2 {
const char * parameters;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
struct security_descriptor *secdesc;/* [relative,subcontext(0)] */
uint32_t attributes;
uint32_t priority;
uint32_t priority;/* [range(0,99)] */
uint32_t defaultpriority;
uint32_t starttime;
uint32_t untiltime;
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)] */
@ -349,11 +353,11 @@ struct spoolss_PrinterInfo5 {
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 )
@ -365,7 +369,7 @@ struct spoolss_PrinterInfo6 {
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)] */
@ -382,7 +386,7 @@ union spoolss_PrinterInfo {
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))] */
@ -398,12 +402,12 @@ struct spoolss_JobInfo1 {
const char * data_type;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * text_status;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
uint32_t status;
uint32_t priority;
uint32_t priority;/* [range(0,99)] */
uint32_t position;
uint32_t total_pages;
uint32_t pages_printed;
struct spoolss_Time submitted;
};
}/* [gensize,public] */;
struct spoolss_JobInfo2 {
uint32_t job_id;
@ -420,7 +424,7 @@ struct spoolss_JobInfo2 {
const char * text_status;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
struct security_descriptor *secdesc;/* [relative] */
uint32_t status;
uint32_t priority;
uint32_t priority;/* [range(0,99)] */
uint32_t position;
uint32_t start_time;
uint32_t until_time;
@ -429,13 +433,13 @@ struct spoolss_JobInfo2 {
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;
@ -452,7 +456,7 @@ struct spoolss_JobInfo4 {
const char * text_status;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
struct security_descriptor *secdesc;/* [relative] */
uint32_t status;
uint32_t priority;
uint32_t priority;/* [range(0,99)] */
uint32_t position;
uint32_t start_time;
uint32_t until_time;
@ -462,14 +466,14 @@ struct spoolss_JobInfo4 {
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;
@ -480,7 +484,7 @@ struct spoolss_SetJobInfo1 {
const char *data_type;/* [unique,charset(UTF16)] */
const char *text_status;/* [unique,charset(UTF16)] */
uint32_t status;
uint32_t priority;
uint32_t priority;/* [range(0,99)] */
uint32_t position;
uint32_t total_pages;
uint32_t pages_printed;
@ -502,7 +506,7 @@ struct spoolss_SetJobInfo2 {
const char *text_status;/* [unique,charset(UTF16)] */
uint32_t _secdesc_ptr;
uint32_t status;
uint32_t priority;
uint32_t priority;/* [range(0,99)] */
uint32_t position;
uint32_t start_time;
uint32_t until_time;
@ -528,7 +532,7 @@ struct spoolss_SetJobInfo4 {
const char *text_status;/* [unique,charset(UTF16)] */
uint32_t _secdesc_ptr;
uint32_t status;
uint32_t priority;
uint32_t priority;/* [range(0,99)] */
uint32_t position;
uint32_t start_time;
uint32_t until_time;
@ -652,7 +656,7 @@ struct spoolss_SetPrinterInfo2 {
const char *parameters;/* [unique,charset(UTF16)] */
struct security_descriptor *secdesc;/* [unique,subcontext(0)] */
uint32_t attributes;
uint32_t priority;
uint32_t priority;/* [range(0,99)] */
uint32_t defaultpriority;
uint32_t starttime;
uint32_t untiltime;
@ -1002,7 +1006,7 @@ union spoolss_DriverInfo {
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)] */
@ -1058,30 +1062,11 @@ struct spoolss_OSVersionEx {
uint32_t unknown3;
}/* [gensize,public] */;
enum spoolss_PrinterDataType
#ifndef USE_UINT_ENUMS
{
SPOOLSS_PRINTER_DATA_TYPE_NULL=0,
SPOOLSS_PRINTER_DATA_TYPE_STRING=1,
SPOOLSS_PRINTER_DATA_TYPE_BINARY=3,
SPOOLSS_PRINTER_DATA_TYPE_UINT32=4,
SPOOLSS_PRINTER_DATA_TYPE_STRING_ARRAY=7
}
#else
{ __donnot_use_enum_spoolss_PrinterDataType=0x7FFFFFFF}
#define SPOOLSS_PRINTER_DATA_TYPE_NULL ( 0 )
#define SPOOLSS_PRINTER_DATA_TYPE_STRING ( 1 )
#define SPOOLSS_PRINTER_DATA_TYPE_BINARY ( 3 )
#define SPOOLSS_PRINTER_DATA_TYPE_UINT32 ( 4 )
#define SPOOLSS_PRINTER_DATA_TYPE_STRING_ARRAY ( 7 )
#endif
;
union spoolss_PrinterData {
const char * string;/* [flag(LIBNDR_FLAG_STR_NULLTERM),case(SPOOLSS_PRINTER_DATA_TYPE_STRING)] */
DATA_BLOB binary;/* [flag(LIBNDR_FLAG_REMAINING),case(SPOOLSS_PRINTER_DATA_TYPE_BINARY)] */
uint32_t value;/* [case(SPOOLSS_PRINTER_DATA_TYPE_UINT32)] */
const char ** string_array;/* [flag(LIBNDR_FLAG_STR_NULLTERM),case(SPOOLSS_PRINTER_DATA_TYPE_STRING_ARRAY)] */
const char * string;/* [flag(LIBNDR_FLAG_STR_NULLTERM),case(REG_SZ)] */
DATA_BLOB binary;/* [flag(LIBNDR_FLAG_REMAINING),case(REG_BINARY)] */
uint32_t value;/* [case(REG_DWORD)] */
const char ** string_array;/* [flag(LIBNDR_FLAG_STR_NULLTERM),case(REG_MULTI_SZ)] */
DATA_BLOB data;/* [flag(LIBNDR_FLAG_REMAINING),default] */
}/* [gensize,public,nodiscriminant] */;
@ -1299,87 +1284,152 @@ union spoolss_PrintProcDataTypesInfo {
#define PRINTER_CHANGE_DELETE_PRINTER_DRIVER ( 0x40000000 )
#define PRINTER_CHANGE_TIMEOUT ( 0x80000000 )
enum spoolss_Field
enum spoolss_JobNotifyField
#ifndef USE_UINT_ENUMS
{
SPOOLSS_FIELD_SERVER_NAME=0,
SPOOLSS_FIELD_PRINTER_NAME=1,
SPOOLSS_FIELD_SHARE_NAME=2,
SPOOLSS_FIELD_PORT_NAME=3,
SPOOLSS_FIELD_DRIVER_NAME=4,
SPOOLSS_FIELD_COMMENT=5,
SPOOLSS_FIELD_LOCATION=6,
SPOOLSS_FIELD_DEVMODE=7,
SPOOLSS_FIELD_SEPFILE=8,
SPOOLSS_FIELD_PRINT_PROCESSOR=9,
SPOOLSS_FIELD_PARAMETERS=10,
SPOOLSS_FIELD_DATATYPE=11,
SPOOLSS_FIELD_SECURITY_DESCRIPTOR=12,
SPOOLSS_FIELD_ATTRIBUTES=13,
SPOOLSS_FIELD_PRIORITY=14,
SPOOLSS_FIELD_DEFAULT_PRIORITY=15,
SPOOLSS_FIELD_START_TIME=16,
SPOOLSS_FIELD_UNTIL_TIME=17,
SPOOLSS_FIELD_STATUS=18,
SPOOLSS_FIELD_STATUS_STRING=19,
SPOOLSS_FIELD_CJOBS=20,
SPOOLSS_FIELD_AVERAGE_PPM=21,
SPOOLSS_FIELD_TOTAL_PAGES=22,
SPOOLSS_FIELD_PAGES_PRINTED=23,
SPOOLSS_FIELD_TOTAL_BYTES=24,
SPOOLSS_FIELD_BYTES_PRINTED=25
JOB_NOTIFY_FIELD_PRINTER_NAME=0x00,
JOB_NOTIFY_FIELD_MACHINE_NAME=0x01,
JOB_NOTIFY_FIELD_PORT_NAME=0x02,
JOB_NOTIFY_FIELD_USER_NAME=0x03,
JOB_NOTIFY_FIELD_NOTIFY_NAME=0x04,
JOB_NOTIFY_FIELD_DATATYPE=0x05,
JOB_NOTIFY_FIELD_PRINT_PROCESSOR=0x06,
JOB_NOTIFY_FIELD_PARAMETERS=0x07,
JOB_NOTIFY_FIELD_DRIVER_NAME=0x08,
JOB_NOTIFY_FIELD_DEVMODE=0x09,
JOB_NOTIFY_FIELD_STATUS=0x0a,
JOB_NOTIFY_FIELD_STATUS_STRING=0x0b,
JOB_NOTIFY_FIELD_SECURITY_DESCRIPTOR=0x0c,
JOB_NOTIFY_FIELD_DOCUMENT=0x0d,
JOB_NOTIFY_FIELD_PRIORITY=0x0e,
JOB_NOTIFY_FIELD_POSITION=0x0f,
JOB_NOTIFY_FIELD_SUBMITTED=0x10,
JOB_NOTIFY_FIELD_START_TIME=0x11,
JOB_NOTIFY_FIELD_UNTIL_TIME=0x12,
JOB_NOTIFY_FIELD_TIME=0x13,
JOB_NOTIFY_FIELD_TOTAL_PAGES=0x14,
JOB_NOTIFY_FIELD_PAGES_PRINTED=0x15,
JOB_NOTIFY_FIELD_TOTAL_BYTES=0x16,
JOB_NOTIFY_FIELD_BYTES_PRINTED=0x17
}
#else
{ __donnot_use_enum_spoolss_Field=0x7FFFFFFF}
#define SPOOLSS_FIELD_SERVER_NAME ( 0 )
#define SPOOLSS_FIELD_PRINTER_NAME ( 1 )
#define SPOOLSS_FIELD_SHARE_NAME ( 2 )
#define SPOOLSS_FIELD_PORT_NAME ( 3 )
#define SPOOLSS_FIELD_DRIVER_NAME ( 4 )
#define SPOOLSS_FIELD_COMMENT ( 5 )
#define SPOOLSS_FIELD_LOCATION ( 6 )
#define SPOOLSS_FIELD_DEVMODE ( 7 )
#define SPOOLSS_FIELD_SEPFILE ( 8 )
#define SPOOLSS_FIELD_PRINT_PROCESSOR ( 9 )
#define SPOOLSS_FIELD_PARAMETERS ( 10 )
#define SPOOLSS_FIELD_DATATYPE ( 11 )
#define SPOOLSS_FIELD_SECURITY_DESCRIPTOR ( 12 )
#define SPOOLSS_FIELD_ATTRIBUTES ( 13 )
#define SPOOLSS_FIELD_PRIORITY ( 14 )
#define SPOOLSS_FIELD_DEFAULT_PRIORITY ( 15 )
#define SPOOLSS_FIELD_START_TIME ( 16 )
#define SPOOLSS_FIELD_UNTIL_TIME ( 17 )
#define SPOOLSS_FIELD_STATUS ( 18 )
#define SPOOLSS_FIELD_STATUS_STRING ( 19 )
#define SPOOLSS_FIELD_CJOBS ( 20 )
#define SPOOLSS_FIELD_AVERAGE_PPM ( 21 )
#define SPOOLSS_FIELD_TOTAL_PAGES ( 22 )
#define SPOOLSS_FIELD_PAGES_PRINTED ( 23 )
#define SPOOLSS_FIELD_TOTAL_BYTES ( 24 )
#define SPOOLSS_FIELD_BYTES_PRINTED ( 25 )
{ __donnot_use_enum_spoolss_JobNotifyField=0x7FFFFFFF}
#define JOB_NOTIFY_FIELD_PRINTER_NAME ( 0x00 )
#define JOB_NOTIFY_FIELD_MACHINE_NAME ( 0x01 )
#define JOB_NOTIFY_FIELD_PORT_NAME ( 0x02 )
#define JOB_NOTIFY_FIELD_USER_NAME ( 0x03 )
#define JOB_NOTIFY_FIELD_NOTIFY_NAME ( 0x04 )
#define JOB_NOTIFY_FIELD_DATATYPE ( 0x05 )
#define JOB_NOTIFY_FIELD_PRINT_PROCESSOR ( 0x06 )
#define JOB_NOTIFY_FIELD_PARAMETERS ( 0x07 )
#define JOB_NOTIFY_FIELD_DRIVER_NAME ( 0x08 )
#define JOB_NOTIFY_FIELD_DEVMODE ( 0x09 )
#define JOB_NOTIFY_FIELD_STATUS ( 0x0a )
#define JOB_NOTIFY_FIELD_STATUS_STRING ( 0x0b )
#define JOB_NOTIFY_FIELD_SECURITY_DESCRIPTOR ( 0x0c )
#define JOB_NOTIFY_FIELD_DOCUMENT ( 0x0d )
#define JOB_NOTIFY_FIELD_PRIORITY ( 0x0e )
#define JOB_NOTIFY_FIELD_POSITION ( 0x0f )
#define JOB_NOTIFY_FIELD_SUBMITTED ( 0x10 )
#define JOB_NOTIFY_FIELD_START_TIME ( 0x11 )
#define JOB_NOTIFY_FIELD_UNTIL_TIME ( 0x12 )
#define JOB_NOTIFY_FIELD_TIME ( 0x13 )
#define JOB_NOTIFY_FIELD_TOTAL_PAGES ( 0x14 )
#define JOB_NOTIFY_FIELD_PAGES_PRINTED ( 0x15 )
#define JOB_NOTIFY_FIELD_TOTAL_BYTES ( 0x16 )
#define JOB_NOTIFY_FIELD_BYTES_PRINTED ( 0x17 )
#endif
;
enum spoolss_PrintNotifyField
#ifndef USE_UINT_ENUMS
{
PRINTER_NOTIFY_FIELD_SERVER_NAME=0x00,
PRINTER_NOTIFY_FIELD_PRINTER_NAME=0x01,
PRINTER_NOTIFY_FIELD_SHARE_NAME=0x02,
PRINTER_NOTIFY_FIELD_PORT_NAME=0x03,
PRINTER_NOTIFY_FIELD_DRIVER_NAME=0x04,
PRINTER_NOTIFY_FIELD_COMMENT=0x05,
PRINTER_NOTIFY_FIELD_LOCATION=0x06,
PRINTER_NOTIFY_FIELD_DEVMODE=0x07,
PRINTER_NOTIFY_FIELD_SEPFILE=0x08,
PRINTER_NOTIFY_FIELD_PRINT_PROCESSOR=0x09,
PRINTER_NOTIFY_FIELD_PARAMETERS=0x0a,
PRINTER_NOTIFY_FIELD_DATATYPE=0x0b,
PRINTER_NOTIFY_FIELD_SECURITY_DESCRIPTOR=0x0c,
PRINTER_NOTIFY_FIELD_ATTRIBUTES=0x0d,
PRINTER_NOTIFY_FIELD_PRIORITY=0x0e,
PRINTER_NOTIFY_FIELD_DEFAULT_PRIORITY=0x0f,
PRINTER_NOTIFY_FIELD_START_TIME=0x10,
PRINTER_NOTIFY_FIELD_UNTIL_TIME=0x11,
PRINTER_NOTIFY_FIELD_STATUS=0x12,
PRINTER_NOTIFY_FIELD_STATUS_STRING=0x13,
PRINTER_NOTIFY_FIELD_CJOBS=0x14,
PRINTER_NOTIFY_FIELD_AVERAGE_PPM=0x15,
PRINTER_NOTIFY_FIELD_TOTAL_PAGES=0x16,
PRINTER_NOTIFY_FIELD_PAGES_PRINTED=0x17,
PRINTER_NOTIFY_FIELD_TOTAL_BYTES=0x18,
PRINTER_NOTIFY_FIELD_BYTES_PRINTED=0x19,
PRINTER_NOTIFY_FIELD_OBJECT_GUID=0x1a,
PRINTER_NOTIFY_FIELD_FRIENDLY_NAME=0x1b
}
#else
{ __donnot_use_enum_spoolss_PrintNotifyField=0x7FFFFFFF}
#define PRINTER_NOTIFY_FIELD_SERVER_NAME ( 0x00 )
#define PRINTER_NOTIFY_FIELD_PRINTER_NAME ( 0x01 )
#define PRINTER_NOTIFY_FIELD_SHARE_NAME ( 0x02 )
#define PRINTER_NOTIFY_FIELD_PORT_NAME ( 0x03 )
#define PRINTER_NOTIFY_FIELD_DRIVER_NAME ( 0x04 )
#define PRINTER_NOTIFY_FIELD_COMMENT ( 0x05 )
#define PRINTER_NOTIFY_FIELD_LOCATION ( 0x06 )
#define PRINTER_NOTIFY_FIELD_DEVMODE ( 0x07 )
#define PRINTER_NOTIFY_FIELD_SEPFILE ( 0x08 )
#define PRINTER_NOTIFY_FIELD_PRINT_PROCESSOR ( 0x09 )
#define PRINTER_NOTIFY_FIELD_PARAMETERS ( 0x0a )
#define PRINTER_NOTIFY_FIELD_DATATYPE ( 0x0b )
#define PRINTER_NOTIFY_FIELD_SECURITY_DESCRIPTOR ( 0x0c )
#define PRINTER_NOTIFY_FIELD_ATTRIBUTES ( 0x0d )
#define PRINTER_NOTIFY_FIELD_PRIORITY ( 0x0e )
#define PRINTER_NOTIFY_FIELD_DEFAULT_PRIORITY ( 0x0f )
#define PRINTER_NOTIFY_FIELD_START_TIME ( 0x10 )
#define PRINTER_NOTIFY_FIELD_UNTIL_TIME ( 0x11 )
#define PRINTER_NOTIFY_FIELD_STATUS ( 0x12 )
#define PRINTER_NOTIFY_FIELD_STATUS_STRING ( 0x13 )
#define PRINTER_NOTIFY_FIELD_CJOBS ( 0x14 )
#define PRINTER_NOTIFY_FIELD_AVERAGE_PPM ( 0x15 )
#define PRINTER_NOTIFY_FIELD_TOTAL_PAGES ( 0x16 )
#define PRINTER_NOTIFY_FIELD_PAGES_PRINTED ( 0x17 )
#define PRINTER_NOTIFY_FIELD_TOTAL_BYTES ( 0x18 )
#define PRINTER_NOTIFY_FIELD_BYTES_PRINTED ( 0x19 )
#define PRINTER_NOTIFY_FIELD_OBJECT_GUID ( 0x1a )
#define PRINTER_NOTIFY_FIELD_FRIENDLY_NAME ( 0x1b )
#endif
;
enum spoolss_NotifyType
#ifndef USE_UINT_ENUMS
{
SPOOLSS_NOTIFY_PRINTER=0,
SPOOLSS_NOTIFY_JOB=1
PRINTER_NOTIFY_TYPE=0x00,
JOB_NOTIFY_TYPE=0x01
}
#else
{ __donnot_use_enum_spoolss_NotifyType=0x7FFFFFFF}
#define SPOOLSS_NOTIFY_PRINTER ( 0 )
#define SPOOLSS_NOTIFY_JOB ( 1 )
#define PRINTER_NOTIFY_TYPE ( 0x00 )
#define JOB_NOTIFY_TYPE ( 0x01 )
#endif
;
union spoolss_Field {
uint16_t field;/* [case(PRINTER_NOTIFY_TYPE)] */
}/* [noprint,nodiscriminant] */;
struct spoolss_NotifyOptionType {
enum spoolss_NotifyType type;
uint16_t u1;
uint32_t u2;
uint32_t u3;
uint32_t count;
enum spoolss_Field *fields;/* [unique,size_is(count)] */
union spoolss_Field *fields;/* [unique,switch_is(type),size_is(count)] */
};
/* bitmap spoolssNotifyOptionFlags */
@ -1426,7 +1476,7 @@ union spoolss_NotifyData {
struct spoolss_Notify {
enum spoolss_NotifyType type;
enum spoolss_Field field;
union spoolss_Field field;/* [switch_is(type)] */
enum spoolss_NotifyTable variable_type;
uint32_t job_id;
union spoolss_NotifyData data;/* [switch_is(variable_type)] */
@ -1494,6 +1544,14 @@ struct spoolss_UserLevelCtr {
#define JOB_ACCESS_ADMINISTER ( 0x00000010 )
#define JOB_ACCESS_READ ( 0x00000020 )
struct spoolss_PrinterEnumValues {
const char * value_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
uint32_t value_name_len;/* [value(2*strlen_m_term(value_name))] */
enum winreg_Type type;
union spoolss_PrinterData *data;/* [relative,subcontext_size(r->data_length),subcontext(0),switch_is(type)] */
uint32_t data_length;/* [value(ndr_size_spoolss_PrinterData(data,type,ndr->iconv_convenience,ndr->flags))] */
}/* [relative_base,gensize,public] */;
/* bitmap spoolss_DeleteDriverFlags */
#define DPD_DELETE_UNUSED_FILES ( 0x00000001 )
#define DPD_DELETE_SPECIFIC_VERSION ( 0x00000002 )
@ -2087,8 +2145,8 @@ struct _spoolss_GetPrinterData {
} in;
struct {
enum spoolss_PrinterDataType *type;/* [ref] */
DATA_BLOB data;
enum winreg_Type *type;/* [ref] */
DATA_BLOB *data;/* [ref] */
uint32_t *needed;/* [ref] */
WERROR result;
} out;
@ -2098,11 +2156,11 @@ struct _spoolss_GetPrinterData {
struct __spoolss_GetPrinterData {
struct {
enum spoolss_PrinterDataType type;
enum winreg_Type type;
} in;
struct {
union spoolss_PrinterData data;/* [switch_is(type)] */
union spoolss_PrinterData *data;/* [ref,switch_is(type)] */
} out;
};
@ -2116,8 +2174,8 @@ struct spoolss_GetPrinterData {
} in;
struct {
enum spoolss_PrinterDataType *type;/* [ref] */
union spoolss_PrinterData data;/* [subcontext_size(offered),subcontext(4),switch_is(*type)] */
enum winreg_Type *type;/* [ref] */
union spoolss_PrinterData *data;/* [subcontext_size(offered),ref,subcontext(4),switch_is(*type)] */
uint32_t *needed;/* [ref] */
WERROR result;
} out;
@ -2129,7 +2187,7 @@ struct _spoolss_SetPrinterData {
struct {
struct policy_handle *handle;/* [ref] */
const char *value_name;/* [charset(UTF16)] */
enum spoolss_PrinterDataType type;
enum winreg_Type type;
DATA_BLOB data;
uint32_t _offered;
} in;
@ -2143,11 +2201,11 @@ struct _spoolss_SetPrinterData {
struct __spoolss_SetPrinterData {
struct {
enum spoolss_PrinterDataType type;
enum winreg_Type type;
} in;
struct {
union spoolss_PrinterData data;/* [switch_is(type)] */
union spoolss_PrinterData *data;/* [ref,switch_is(type)] */
} out;
};
@ -2157,7 +2215,7 @@ struct spoolss_SetPrinterData {
struct {
struct policy_handle *handle;/* [ref] */
const char *value_name;/* [charset(UTF16)] */
enum spoolss_PrinterDataType type;
enum winreg_Type type;
union spoolss_PrinterData data;/* [subcontext(4),switch_is(type)] */
uint32_t _offered;/* [value(ndr_size_spoolss_PrinterData(&data,type,ndr->iconv_convenience,flags))] */
} in;
@ -2826,8 +2884,8 @@ struct spoolss_EnumPrinterData {
struct {
const char *value_name;/* [charset(UTF16),size_is(value_offered/2)] */
uint32_t *value_needed;/* [ref] */
uint32_t *printerdata_type;/* [ref] */
DATA_BLOB *buffer;/* [ref] */
enum winreg_Type *type;/* [ref] */
uint8_t *data;/* [ref,flag(LIBNDR_PRINT_ARRAY_HEX),size_is(data_offered)] */
uint32_t *data_needed;/* [ref] */
WERROR result;
} out;
@ -2877,7 +2935,7 @@ struct spoolss_SetPrinterDataEx {
struct policy_handle *handle;/* [ref] */
const char *key_name;/* [charset(UTF16)] */
const char *value_name;/* [charset(UTF16)] */
uint32_t type;
enum winreg_Type type;
uint8_t *buffer;/* [ref,size_is(offered)] */
uint32_t offered;
} in;
@ -2898,7 +2956,7 @@ struct spoolss_GetPrinterDataEx {
} in;
struct {
uint32_t *type;/* [ref] */
enum winreg_Type *type;/* [ref] */
uint8_t *buffer;/* [ref,size_is(offered)] */
uint32_t *needed;/* [ref] */
WERROR result;
@ -2907,6 +2965,35 @@ struct spoolss_GetPrinterDataEx {
};
struct _spoolss_EnumPrinterDataEx {
struct {
struct policy_handle *handle;/* [ref] */
const char *key_name;/* [charset(UTF16)] */
uint32_t offered;
} in;
struct {
DATA_BLOB info;
uint32_t *needed;/* [ref] */
uint32_t *count;/* [ref] */
WERROR result;
} out;
};
struct __spoolss_EnumPrinterDataEx {
struct {
uint32_t count;
} in;
struct {
struct spoolss_PrinterEnumValues *info;
} out;
};
struct spoolss_EnumPrinterDataEx {
struct {
struct policy_handle *handle;/* [ref] */
@ -2915,9 +3002,9 @@ struct spoolss_EnumPrinterDataEx {
} in;
struct {
uint8_t *buffer;/* [ref,size_is(offered)] */
uint32_t *needed;/* [ref] */
uint32_t *count;/* [ref] */
struct spoolss_PrinterEnumValues **info;/* [ref,size_is(,*count)] */
uint32_t *needed;/* [ref] */
WERROR result;
} out;
@ -2928,11 +3015,11 @@ struct spoolss_EnumPrinterKey {
struct {
struct policy_handle *handle;/* [ref] */
const char *key_name;/* [charset(UTF16)] */
uint32_t key_buffer_size;
uint32_t offered;
} in;
struct {
uint16_t *key_buffer;/* [ref,size_is(key_buffer_size/2)] */
const char ** *key_buffer;/* [subcontext_size(offered),ref,subcontext(0),flag(LIBNDR_FLAG_STR_NULLTERM)] */
uint32_t *needed;/* [ref] */
WERROR result;
} out;

View File

@ -2113,12 +2113,18 @@ static bool api_spoolss_GetPrinterData(pipes_struct *p)
}
ZERO_STRUCT(r->out);
r->out.type = talloc_zero(r, enum spoolss_PrinterDataType);
r->out.type = talloc_zero(r, enum winreg_Type);
if (r->out.type == NULL) {
talloc_free(r);
return false;
}
r->out.data = talloc_zero(r, union spoolss_PrinterData);
if (r->out.data == NULL) {
talloc_free(r);
return false;
}
r->out.needed = talloc_zero(r, uint32_t);
if (r->out.needed == NULL) {
talloc_free(r);
@ -5649,14 +5655,14 @@ static bool api_spoolss_EnumPrinterData(pipes_struct *p)
return false;
}
r->out.printerdata_type = talloc_zero(r, uint32_t);
if (r->out.printerdata_type == NULL) {
r->out.type = talloc_zero(r, enum winreg_Type);
if (r->out.type == NULL) {
talloc_free(r);
return false;
}
r->out.buffer = talloc_zero(r, DATA_BLOB);
if (r->out.buffer == NULL) {
r->out.data = talloc_zero_array(r, uint8_t, r->in.data_offered);
if (r->out.data == NULL) {
talloc_free(r);
return false;
}
@ -6106,7 +6112,7 @@ static bool api_spoolss_GetPrinterDataEx(pipes_struct *p)
}
ZERO_STRUCT(r->out);
r->out.type = talloc_zero(r, uint32_t);
r->out.type = talloc_zero(r, enum winreg_Type);
if (r->out.type == NULL) {
talloc_free(r);
return false;
@ -6198,8 +6204,14 @@ static bool api_spoolss_EnumPrinterDataEx(pipes_struct *p)
}
ZERO_STRUCT(r->out);
r->out.buffer = talloc_zero_array(r, uint8_t, r->in.offered);
if (r->out.buffer == NULL) {
r->out.count = talloc_zero(r, uint32_t);
if (r->out.count == NULL) {
talloc_free(r);
return false;
}
r->out.info = talloc_zero(r, struct spoolss_PrinterEnumValues *);
if (r->out.info == NULL) {
talloc_free(r);
return false;
}
@ -6210,12 +6222,6 @@ static bool api_spoolss_EnumPrinterDataEx(pipes_struct *p)
return false;
}
r->out.count = talloc_zero(r, uint32_t);
if (r->out.count == NULL) {
talloc_free(r);
return false;
}
r->out.result = _spoolss_EnumPrinterDataEx(p, r);
if (p->rng_fault_state) {
@ -6290,7 +6296,7 @@ static bool api_spoolss_EnumPrinterKey(pipes_struct *p)
}
ZERO_STRUCT(r->out);
r->out.key_buffer = talloc_zero_array(r, uint16_t, r->in.key_buffer_size / 2);
r->out.key_buffer = talloc_zero(r, const char **);
if (r->out.key_buffer == NULL) {
talloc_free(r);
return false;
@ -7865,11 +7871,16 @@ NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
case NDR_SPOOLSS_GETPRINTERDATA: {
struct spoolss_GetPrinterData *r = (struct spoolss_GetPrinterData *)_r;
ZERO_STRUCT(r->out);
r->out.type = talloc_zero(mem_ctx, enum spoolss_PrinterDataType);
r->out.type = talloc_zero(mem_ctx, enum winreg_Type);
if (r->out.type == NULL) {
return NT_STATUS_NO_MEMORY;
}
r->out.data = talloc_zero(mem_ctx, union spoolss_PrinterData);
if (r->out.data == NULL) {
return NT_STATUS_NO_MEMORY;
}
r->out.needed = talloc_zero(mem_ctx, uint32_t);
if (r->out.needed == NULL) {
return NT_STATUS_NO_MEMORY;
@ -8292,13 +8303,13 @@ NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
r->out.printerdata_type = talloc_zero(mem_ctx, uint32_t);
if (r->out.printerdata_type == NULL) {
r->out.type = talloc_zero(mem_ctx, enum winreg_Type);
if (r->out.type == NULL) {
return NT_STATUS_NO_MEMORY;
}
r->out.buffer = talloc_zero(mem_ctx, DATA_BLOB);
if (r->out.buffer == NULL) {
r->out.data = talloc_zero_array(mem_ctx, uint8_t, r->in.data_offered);
if (r->out.data == NULL) {
return NT_STATUS_NO_MEMORY;
}
@ -8344,7 +8355,7 @@ NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
case NDR_SPOOLSS_GETPRINTERDATAEX: {
struct spoolss_GetPrinterDataEx *r = (struct spoolss_GetPrinterDataEx *)_r;
ZERO_STRUCT(r->out);
r->out.type = talloc_zero(mem_ctx, uint32_t);
r->out.type = talloc_zero(mem_ctx, enum winreg_Type);
if (r->out.type == NULL) {
return NT_STATUS_NO_MEMORY;
}
@ -8366,8 +8377,13 @@ NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
case NDR_SPOOLSS_ENUMPRINTERDATAEX: {
struct spoolss_EnumPrinterDataEx *r = (struct spoolss_EnumPrinterDataEx *)_r;
ZERO_STRUCT(r->out);
r->out.buffer = talloc_zero_array(mem_ctx, uint8_t, r->in.offered);
if (r->out.buffer == NULL) {
r->out.count = talloc_zero(mem_ctx, uint32_t);
if (r->out.count == NULL) {
return NT_STATUS_NO_MEMORY;
}
r->out.info = talloc_zero(mem_ctx, struct spoolss_PrinterEnumValues *);
if (r->out.info == NULL) {
return NT_STATUS_NO_MEMORY;
}
@ -8376,11 +8392,6 @@ NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
r->out.count = talloc_zero(mem_ctx, uint32_t);
if (r->out.count == NULL) {
return NT_STATUS_NO_MEMORY;
}
r->out.result = _spoolss_EnumPrinterDataEx(cli->pipes_struct, r);
return NT_STATUS_OK;
}
@ -8388,7 +8399,7 @@ NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
case NDR_SPOOLSS_ENUMPRINTERKEY: {
struct spoolss_EnumPrinterKey *r = (struct spoolss_EnumPrinterKey *)_r;
ZERO_STRUCT(r->out);
r->out.key_buffer = talloc_zero_array(mem_ctx, uint16_t, r->in.key_buffer_size / 2);
r->out.key_buffer = talloc_zero(mem_ctx, const char **);
if (r->out.key_buffer == NULL) {
return NT_STATUS_NO_MEMORY;
}

View File

@ -116,7 +116,7 @@ import "misc.idl", "security.idl", "winreg.idl";
JOB_STATUS_COMPLETE = 0x00001000
} spoolss_JobStatus;
typedef struct {
typedef [public,gensize] struct {
[relative] nstring *printername;
[relative] nstring *servername;
uint32 cjobs;
@ -248,7 +248,7 @@ import "misc.idl", "security.idl", "winreg.idl";
PRINTER_ENUM_ICON7 |
PRINTER_ENUM_ICON8); /* 0x00ff0000 */
typedef struct {
typedef [public,gensize] struct {
spoolss_EnumPrinterFlags flags;
[relative] nstring *name;
[relative] nstring *description;
@ -274,7 +274,7 @@ import "misc.idl", "security.idl", "winreg.idl";
PRINTER_ATTRIBUTE_TS = 0x00008000
} spoolss_PrinterAttributes;
typedef struct {
typedef [public,gensize] struct {
[relative] nstring *servername;
[relative] nstring *printername;
[relative] nstring *sharename;
@ -289,7 +289,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[relative] nstring *parameters;
[relative,subcontext(0)] security_descriptor *secdesc;
spoolss_PrinterAttributes attributes;
uint32 priority;
[range(0,99)] uint32 priority;
uint32 defaultpriority;
uint32 starttime;
uint32 untiltime;
@ -298,17 +298,17 @@ import "misc.idl", "security.idl", "winreg.idl";
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;
@ -316,7 +316,7 @@ import "misc.idl", "security.idl", "winreg.idl";
uint32 transmission_retry_timeout;
} spoolss_PrinterInfo5;
typedef struct {
typedef [public,gensize] struct {
spoolss_PrinterStatus status;
} spoolss_PrinterInfo6;
@ -328,7 +328,7 @@ import "misc.idl", "security.idl", "winreg.idl";
DSPRINT_PENDING = 0x80000000
} spoolss_DsPrintAction;
typedef struct {
typedef [public,gensize] struct {
[relative] nstring *guid; /* text form of printer guid */
spoolss_DsPrintAction action;
} spoolss_PrinterInfo7;
@ -337,7 +337,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[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;
@ -401,7 +401,7 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x02 */
typedef struct {
typedef [public,gensize] struct {
uint32 job_id;
[relative] nstring *printer_name;
[relative] nstring *server_name;
@ -410,14 +410,14 @@ import "misc.idl", "security.idl", "winreg.idl";
[relative] nstring *data_type;
[relative] nstring *text_status;
spoolss_JobStatus status;
uint32 priority;
[range(0,99)] uint32 priority;
uint32 position;
uint32 total_pages;
uint32 pages_printed;
spoolss_Time submitted;
} spoolss_JobInfo1;
typedef struct {
typedef [public,gensize] struct {
uint32 job_id;
[relative] nstring *printer_name;
[relative] nstring *server_name;
@ -432,7 +432,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[relative] nstring *text_status;
[relative] security_descriptor *secdesc;
spoolss_JobStatus status;
uint32 priority;
[range(0,99)] uint32 priority;
uint32 position;
uint32 start_time;
uint32 until_time;
@ -443,13 +443,13 @@ import "misc.idl", "security.idl", "winreg.idl";
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;
@ -464,7 +464,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[relative] nstring *text_status;
[relative] security_descriptor *secdesc;
spoolss_JobStatus status;
uint32 priority;
[range(0,99)] uint32 priority;
uint32 position;
uint32 start_time;
uint32 until_time;
@ -476,7 +476,7 @@ import "misc.idl", "security.idl", "winreg.idl";
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;
@ -493,7 +493,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[string,charset(UTF16)] uint16 *data_type;
[string,charset(UTF16)] uint16 *text_status;
spoolss_JobStatus status;
uint32 priority;
[range(0,99)] uint32 priority;
uint32 position;
uint32 total_pages;
uint32 pages_printed;
@ -515,7 +515,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[string,charset(UTF16)] uint16 *text_status;
uint32 _secdesc_ptr;
spoolss_JobStatus status;
uint32 priority;
[range(0,99)] uint32 priority;
uint32 position;
uint32 start_time;
uint32 until_time;
@ -541,7 +541,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[string,charset(UTF16)] uint16 *text_status;
uint32 _secdesc_ptr;
spoolss_JobStatus status;
uint32 priority;
[range(0,99)] uint32 priority;
uint32 position;
uint32 start_time;
uint32 until_time;
@ -704,7 +704,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[string,charset(UTF16)] uint16 *parameters;
[subcontext(0)] security_descriptor *secdesc;
spoolss_PrinterAttributes attributes;
uint32 priority;
[range(0,99)] uint32 priority;
uint32 defaultpriority;
uint32 starttime;
uint32 untiltime;
@ -1052,7 +1052,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[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;
@ -1302,20 +1302,12 @@ import "misc.idl", "security.idl", "winreg.idl";
uint32 unknown3;/* hmm? w2k3: 131346(0x20112) winxp sp1: 503382272 0x1E010100 */
} spoolss_OSVersionEx;
typedef [v1_enum] enum {
SPOOLSS_PRINTER_DATA_TYPE_NULL = 0,
SPOOLSS_PRINTER_DATA_TYPE_STRING = 1,
SPOOLSS_PRINTER_DATA_TYPE_BINARY = 3,
SPOOLSS_PRINTER_DATA_TYPE_UINT32 = 4,
SPOOLSS_PRINTER_DATA_TYPE_STRING_ARRAY = 7
} spoolss_PrinterDataType;
typedef [nodiscriminant,public,gensize] union {
[case(SPOOLSS_PRINTER_DATA_TYPE_NULL)];
[case(SPOOLSS_PRINTER_DATA_TYPE_STRING)] nstring string;
[case(SPOOLSS_PRINTER_DATA_TYPE_BINARY),flag(NDR_REMAINING)] DATA_BLOB binary;
[case(SPOOLSS_PRINTER_DATA_TYPE_UINT32)] uint32 value;
[case(SPOOLSS_PRINTER_DATA_TYPE_STRING_ARRAY)] nstring_array string_array;
[case(REG_NONE)];
[case(REG_SZ)] nstring string;
[case(REG_BINARY),flag(NDR_REMAINING)] DATA_BLOB binary;
[case(REG_DWORD)] uint32 value;
[case(REG_MULTI_SZ)] nstring_array string_array;
[default,flag(NDR_REMAINING)] DATA_BLOB data;
} spoolss_PrinterData;
@ -1323,20 +1315,20 @@ import "misc.idl", "security.idl", "winreg.idl";
[in,ref] policy_handle *handle,
[in] [string,charset(UTF16)] uint16 value_name[],
[in] uint32 offered,
[out,ref] spoolss_PrinterDataType *type,
[out] DATA_BLOB data,
[out,ref] winreg_Type *type,
[out,ref] DATA_BLOB *data,
[out,ref] uint32 *needed
);
[noopnum,noprint,public] void __spoolss_GetPrinterData(
[in] spoolss_PrinterDataType type,
[out,switch_is(type)] spoolss_PrinterData data
[in] winreg_Type type,
[out,ref,switch_is(type)] spoolss_PrinterData *data
);
[nopull,nopush,public] WERROR spoolss_GetPrinterData(
[in,ref] policy_handle *handle,
[in] [string,charset(UTF16)] uint16 value_name[],
[in] uint32 offered,
[out,ref] spoolss_PrinterDataType *type,
[out,subcontext(4),subcontext_size(offered),switch_is(*type)] spoolss_PrinterData data,
[out,ref] winreg_Type *type,
[out,ref,subcontext(4),subcontext_size(offered),switch_is(*type)] spoolss_PrinterData *data,
[out,ref] uint32 *needed
);
@ -1345,18 +1337,18 @@ import "misc.idl", "security.idl", "winreg.idl";
[noopnum,nopull,noprint,public] WERROR _spoolss_SetPrinterData(
[in,ref] policy_handle *handle,
[in] [string,charset(UTF16)] uint16 value_name[],
[in] spoolss_PrinterDataType type,
[in] winreg_Type type,
[in] DATA_BLOB data,
[in] uint32 _offered
);
[noopnum,nopull,noprint,public] void __spoolss_SetPrinterData(
[in] spoolss_PrinterDataType type,
[out,switch_is(type)] spoolss_PrinterData data
[in] winreg_Type type,
[out,ref,switch_is(type)] spoolss_PrinterData *data
);
[nopush] WERROR spoolss_SetPrinterData(
[in,ref] policy_handle *handle,
[in] [string,charset(UTF16)] uint16 value_name[],
[in] spoolss_PrinterDataType type,
[in] winreg_Type type,
[in,subcontext(4),switch_is(type)] spoolss_PrinterData data,
[in,value(ndr_size_spoolss_PrinterData(&data,type,ndr->iconv_convenience,flags))] uint32 _offered
);
@ -1509,6 +1501,16 @@ import "misc.idl", "security.idl", "winreg.idl";
[out,ref] uint32 *needed
);
/*
* Special strings for the OpenPrinter() call. See the MSDN DDK
* docs on the XcvDataPort() for more details.
*/
const string SPL_LOCAL_PORT = "Local Port";
const string SPL_TCPIP_PORT = "Standard TCP/IP Port";
const string SPL_XCV_MONITOR_LOCALMON = ",XcvMonitor Local Port";
const string SPL_XCV_MONITOR_TCPMON = ",XcvMonitor Standard TCP/IP Port";
typedef [public,gensize] struct {
[relative] nstring *port_name;
} spoolss_PortInfo1;
@ -1890,40 +1892,75 @@ import "misc.idl", "security.idl", "winreg.idl";
[todo] WERROR spoolss_ResetPrinterEx(
);
typedef [enum16bit] enum {
SPOOLSS_FIELD_SERVER_NAME = 0,
SPOOLSS_FIELD_PRINTER_NAME = 1,
SPOOLSS_FIELD_SHARE_NAME = 2,
SPOOLSS_FIELD_PORT_NAME = 3,
SPOOLSS_FIELD_DRIVER_NAME = 4,
SPOOLSS_FIELD_COMMENT = 5,
SPOOLSS_FIELD_LOCATION = 6,
SPOOLSS_FIELD_DEVMODE = 7,
SPOOLSS_FIELD_SEPFILE = 8,
SPOOLSS_FIELD_PRINT_PROCESSOR = 9,
SPOOLSS_FIELD_PARAMETERS = 10,
SPOOLSS_FIELD_DATATYPE = 11,
SPOOLSS_FIELD_SECURITY_DESCRIPTOR=12,
SPOOLSS_FIELD_ATTRIBUTES = 13,
SPOOLSS_FIELD_PRIORITY = 14,
SPOOLSS_FIELD_DEFAULT_PRIORITY = 15,
SPOOLSS_FIELD_START_TIME = 16,
SPOOLSS_FIELD_UNTIL_TIME = 17,
SPOOLSS_FIELD_STATUS = 18,
SPOOLSS_FIELD_STATUS_STRING = 19,
SPOOLSS_FIELD_CJOBS = 20,
SPOOLSS_FIELD_AVERAGE_PPM = 21,
SPOOLSS_FIELD_TOTAL_PAGES = 22,
SPOOLSS_FIELD_PAGES_PRINTED = 23,
SPOOLSS_FIELD_TOTAL_BYTES = 24,
SPOOLSS_FIELD_BYTES_PRINTED = 25
} spoolss_Field;
typedef [enum16bit,public] enum {
JOB_NOTIFY_FIELD_PRINTER_NAME = 0x00,
JOB_NOTIFY_FIELD_MACHINE_NAME = 0x01,
JOB_NOTIFY_FIELD_PORT_NAME = 0x02,
JOB_NOTIFY_FIELD_USER_NAME = 0x03,
JOB_NOTIFY_FIELD_NOTIFY_NAME = 0x04,
JOB_NOTIFY_FIELD_DATATYPE = 0x05,
JOB_NOTIFY_FIELD_PRINT_PROCESSOR = 0x06,
JOB_NOTIFY_FIELD_PARAMETERS = 0x07,
JOB_NOTIFY_FIELD_DRIVER_NAME = 0x08,
JOB_NOTIFY_FIELD_DEVMODE = 0x09,
JOB_NOTIFY_FIELD_STATUS = 0x0a,
JOB_NOTIFY_FIELD_STATUS_STRING = 0x0b,
JOB_NOTIFY_FIELD_SECURITY_DESCRIPTOR = 0x0c,
JOB_NOTIFY_FIELD_DOCUMENT = 0x0d,
JOB_NOTIFY_FIELD_PRIORITY = 0x0e,
JOB_NOTIFY_FIELD_POSITION = 0x0f,
JOB_NOTIFY_FIELD_SUBMITTED = 0x10,
JOB_NOTIFY_FIELD_START_TIME = 0x11,
JOB_NOTIFY_FIELD_UNTIL_TIME = 0x12,
JOB_NOTIFY_FIELD_TIME = 0x13,
JOB_NOTIFY_FIELD_TOTAL_PAGES = 0x14,
JOB_NOTIFY_FIELD_PAGES_PRINTED = 0x15,
JOB_NOTIFY_FIELD_TOTAL_BYTES = 0x16,
JOB_NOTIFY_FIELD_BYTES_PRINTED = 0x17
} spoolss_JobNotifyField;
typedef [enum16bit,public] enum {
PRINTER_NOTIFY_FIELD_SERVER_NAME = 0x00,
PRINTER_NOTIFY_FIELD_PRINTER_NAME = 0x01,
PRINTER_NOTIFY_FIELD_SHARE_NAME = 0x02,
PRINTER_NOTIFY_FIELD_PORT_NAME = 0x03,
PRINTER_NOTIFY_FIELD_DRIVER_NAME = 0x04,
PRINTER_NOTIFY_FIELD_COMMENT = 0x05,
PRINTER_NOTIFY_FIELD_LOCATION = 0x06,
PRINTER_NOTIFY_FIELD_DEVMODE = 0x07,
PRINTER_NOTIFY_FIELD_SEPFILE = 0x08,
PRINTER_NOTIFY_FIELD_PRINT_PROCESSOR = 0x09,
PRINTER_NOTIFY_FIELD_PARAMETERS = 0x0a,
PRINTER_NOTIFY_FIELD_DATATYPE = 0x0b,
PRINTER_NOTIFY_FIELD_SECURITY_DESCRIPTOR = 0x0c,
PRINTER_NOTIFY_FIELD_ATTRIBUTES = 0x0d,
PRINTER_NOTIFY_FIELD_PRIORITY = 0x0e,
PRINTER_NOTIFY_FIELD_DEFAULT_PRIORITY = 0x0f,
PRINTER_NOTIFY_FIELD_START_TIME = 0x10,
PRINTER_NOTIFY_FIELD_UNTIL_TIME = 0x11,
PRINTER_NOTIFY_FIELD_STATUS = 0x12,
PRINTER_NOTIFY_FIELD_STATUS_STRING = 0x13,
PRINTER_NOTIFY_FIELD_CJOBS = 0x14,
PRINTER_NOTIFY_FIELD_AVERAGE_PPM = 0x15,
PRINTER_NOTIFY_FIELD_TOTAL_PAGES = 0x16,
PRINTER_NOTIFY_FIELD_PAGES_PRINTED = 0x17,
PRINTER_NOTIFY_FIELD_TOTAL_BYTES = 0x18,
PRINTER_NOTIFY_FIELD_BYTES_PRINTED = 0x19,
PRINTER_NOTIFY_FIELD_OBJECT_GUID = 0x1a,
PRINTER_NOTIFY_FIELD_FRIENDLY_NAME = 0x1b
} spoolss_PrintNotifyField;
typedef [enum16bit] enum {
SPOOLSS_NOTIFY_PRINTER = 0,
SPOOLSS_NOTIFY_JOB = 1
PRINTER_NOTIFY_TYPE = 0x00,
JOB_NOTIFY_TYPE = 0x01
} spoolss_NotifyType;
typedef [nodiscriminant,noprint] union {
[case(PRINTER_NOTIFY_TYPE)] uint16 field;
[case(JOB_NOTIFY_TYPE)] uint16 field;
[default] uint16 field;
} spoolss_Field;
/******************/
/* Function: 0x41 */
typedef struct {
@ -1932,7 +1969,7 @@ import "misc.idl", "security.idl", "winreg.idl";
uint32 u2;
uint32 u3;
uint32 count;
[size_is(count)] spoolss_Field *fields;
[size_is(count),switch_is(type)] spoolss_Field *fields;
} spoolss_NotifyOptionType;
typedef [bitmap32bit] bitmap {
@ -1981,7 +2018,7 @@ import "misc.idl", "security.idl", "winreg.idl";
typedef struct {
spoolss_NotifyType type;
spoolss_Field field;
[switch_is(type)] spoolss_Field field;
spoolss_NotifyTable variable_type;
uint32 job_id;
[switch_is(variable_type)] spoolss_NotifyData data;
@ -2163,8 +2200,8 @@ import "misc.idl", "security.idl", "winreg.idl";
[out,size_is(value_offered/2),charset(UTF16)] uint16 value_name[],
[in] uint32 value_offered,
[out,ref] uint32 *value_needed,
[out,ref] uint32 *printerdata_type,
[out,ref] DATA_BLOB *buffer,
[out,ref] winreg_Type *type,
[out,ref,size_is(data_offered),flag(LIBNDR_PRINT_ARRAY_HEX)] uint8 *data,
[in] uint32 data_offered,
[out,ref] uint32 *data_needed
);
@ -2197,7 +2234,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[in,ref] policy_handle *handle,
[in] [string,charset(UTF16)] uint16 key_name[],
[in] [string,charset(UTF16)] uint16 value_name[],
[in] uint32 type,
[in] winreg_Type type,
[in,ref] [size_is(offered)] uint8 *buffer,
[in] uint32 offered
);
@ -2208,7 +2245,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[in,ref] policy_handle *handle,
[in] [string,charset(UTF16)] uint16 key_name[],
[in] [string,charset(UTF16)] uint16 value_name[],
[out,ref] uint32 *type,
[out,ref] winreg_Type *type,
[out,ref] [size_is(offered)] uint8 *buffer,
[in] uint32 offered,
[out,ref] uint32 *needed
@ -2216,22 +2253,43 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x4f */
[public] WERROR spoolss_EnumPrinterDataEx(
typedef [relative_base,public,gensize] struct {
[relative] nstring *value_name;
[value(2*strlen_m_term(value_name))] uint32 value_name_len;
winreg_Type type;
[relative,switch_is(type),subcontext(0),subcontext_size(r->data_length)] spoolss_PrinterData *data;
[value(ndr_size_spoolss_PrinterData(data, type, ndr->iconv_convenience, ndr->flags))] uint32 data_length;
} spoolss_PrinterEnumValues;
[public,noopnum,noprint] WERROR _spoolss_EnumPrinterDataEx(
[in,ref] policy_handle *handle,
[in] [string,charset(UTF16)] uint16 key_name[],
[out,ref] [size_is(offered)] uint8 *buffer,
[in] uint32 offered,
[out] DATA_BLOB info,
[in] uint32 offered,
[out,ref] uint32 *needed,
[out,ref] uint32 *count
);
[public,noopnum,noprint] void __spoolss_EnumPrinterDataEx(
[in] uint32 count,
[out] spoolss_PrinterEnumValues info[count]
);
[nopull,nopush] WERROR spoolss_EnumPrinterDataEx(
[in,ref] policy_handle *handle,
[in] [string,charset(UTF16)] uint16 key_name[],
[in] uint32 offered,
[out,ref] uint32 *count,
[out,ref,size_is(,*count)] spoolss_PrinterEnumValues **info,
[out,ref] uint32 *needed
);
/******************/
/* Function: 0x50 */
[public] WERROR spoolss_EnumPrinterKey(
[in, ref] policy_handle *handle,
[in] [string,charset(UTF16)] uint16 key_name[],
[out,ref] [size_is(key_buffer_size/2)] uint16 *key_buffer,
[in] uint32 key_buffer_size,
[out,ref] [subcontext(0),subcontext_size(offered)] nstring_array **key_buffer,
[in] uint32 offered,
[out,ref] uint32 *needed
);

View File

@ -5,6 +5,7 @@
Copyright (C) Andrew Tridgell 2003
Copyright (C) Tim Potter 2003
Copyright (C) Guenther Deschner 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
@ -173,7 +174,7 @@
} while (0)
/* TODO: set _ndr_info->flags correct */
#define NDR_SPOOLSS_SIZE_ENUM(fn) do { \
#define NDR_SPOOLSS_SIZE_ENUM_LEVEL(fn) do { \
struct __##fn __r;\
DATA_BLOB _data_blob_info;\
struct ndr_push *_ndr_info = ndr_push_init_ctx(mem_ctx, iconv_convenience);\
@ -187,6 +188,21 @@
return _data_blob_info.length;\
} while(0)
/* TODO: set _ndr_info->flags correct */
#define NDR_SPOOLSS_SIZE_ENUM(fn) do { \
struct __##fn __r;\
DATA_BLOB _data_blob_info;\
struct ndr_push *_ndr_info = ndr_push_init_ctx(mem_ctx, iconv_convenience);\
if (!_ndr_info) return 0;\
_ndr_info->flags|=0;\
__r.in.count = count;\
__r.out.info = info;\
_NDR_CHECK_UINT32(ndr_push___##fn(_ndr_info, NDR_OUT, &__r)); \
_data_blob_info = ndr_push_blob(_ndr_info);\
return _data_blob_info.length;\
} while(0)
/*
spoolss_EnumPrinters
*/
@ -216,7 +232,7 @@ enum ndr_err_code ndr_pull_spoolss_EnumPrinters(struct ndr_pull *ndr, int flags,
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)
{
NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPrinters);
NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPrinters);
}
/*
@ -250,9 +266,9 @@ enum ndr_err_code ndr_pull_spoolss_EnumJobs(struct ndr_pull *ndr, int flags, str
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);
NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumJobs);
}
/*
@ -284,7 +300,7 @@ enum ndr_err_code ndr_pull_spoolss_EnumPrinterDrivers(struct ndr_pull *ndr, int
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)
{
NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPrinterDrivers);
NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPrinterDrivers);
}
/*
@ -312,7 +328,7 @@ enum ndr_err_code ndr_pull_spoolss_EnumForms(struct ndr_pull *ndr, int flags, st
uint32_t ndr_size_spoolss_EnumForms_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_FormInfo *info)
{
NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumForms);
NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumForms);
}
/*
@ -340,7 +356,7 @@ enum ndr_err_code ndr_pull_spoolss_EnumPorts(struct ndr_pull *ndr, int flags, st
uint32_t ndr_size_spoolss_EnumPorts_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, uint32_t level, uint32_t count, union spoolss_PortInfo *info)
{
NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPorts);
NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPorts);
}
/*
@ -368,7 +384,7 @@ enum ndr_err_code ndr_pull_spoolss_EnumMonitors(struct ndr_pull *ndr, int flags,
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)
{
NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumMonitors);
NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumMonitors);
}
/*
@ -398,10 +414,10 @@ enum ndr_err_code ndr_pull_spoolss_EnumPrintProcessors(struct ndr_pull *ndr, int
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);
NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPrintProcessors);
}
/*
@ -434,7 +450,107 @@ enum ndr_err_code ndr_pull_spoolss_EnumPrintProcDataTypes(struct ndr_pull *ndr,
uint32_t ndr_size_spoolss_EnumPrintProcDataTypes_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
uint32_t level, uint32_t count, union spoolss_PrintProcDataTypesInfo *info)
{
NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPrintProcDataTypes);
NDR_SPOOLSS_SIZE_ENUM_LEVEL(spoolss_EnumPrintProcDataTypes);
}
/*
spoolss_EnumPrinterDataEx
*/
enum ndr_err_code ndr_push_spoolss_EnumPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterDataEx *r)
{
struct _spoolss_EnumPrinterDataEx _r;
if (flags & NDR_IN) {
_r.in.handle = r->in.handle;
_r.in.key_name = r->in.key_name;
_r.in.offered = r->in.offered;
NDR_CHECK(ndr_push__spoolss_EnumPrinterDataEx(ndr, flags, &_r));
}
if (flags & NDR_OUT) {
struct ndr_push *_ndr_info;
_r.in.handle = r->in.handle;
_r.in.key_name = r->in.key_name;
_r.in.offered = r->in.offered;
_r.out.count = r->out.count;
_r.out.needed = r->out.needed;
_r.out.result = r->out.result;
_r.out.info = data_blob(NULL, 0);
if (r->in.offered >= *r->out.needed) {
struct __spoolss_EnumPrinterDataEx __r;
_ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(_ndr_info);
_ndr_info->flags= ndr->flags;
__r.in.count = *r->out.count;
__r.out.info = *r->out.info;
NDR_CHECK(ndr_push___spoolss_EnumPrinterDataEx(_ndr_info, flags, &__r));
if (r->in.offered > _ndr_info->offset) {
uint32_t _padding_len = r->in.offered - _ndr_info->offset;
NDR_CHECK(ndr_push_zero(_ndr_info, _padding_len));
}
_r.out.info = ndr_push_blob(_ndr_info);
}
NDR_CHECK(ndr_push__spoolss_EnumPrinterDataEx(ndr, flags, &_r));
}
return NDR_ERR_SUCCESS;
}
enum ndr_err_code ndr_pull_spoolss_EnumPrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDataEx *r)
{
struct _spoolss_EnumPrinterDataEx _r;
if (flags & NDR_IN) {
_r.in.handle = r->in.handle;
_r.in.key_name = r->in.key_name;
ZERO_STRUCT(r->out);
NDR_CHECK(ndr_pull__spoolss_EnumPrinterDataEx(ndr, flags, &_r));
r->in.handle = _r.in.handle;
r->in.key_name = _r.in.key_name;
r->in.offered = _r.in.offered;
r->out.needed = _r.out.needed;
r->out.count = _r.out.count;
NDR_PULL_ALLOC(ndr, r->out.info);
ZERO_STRUCTP(r->out.info);
}
if (flags & NDR_OUT) {
_r.in.handle = r->in.handle;
_r.in.key_name = r->in.key_name;
_r.in.offered = r->in.offered;
_r.out.count = r->out.count;
_r.out.needed = r->out.needed;
NDR_CHECK(ndr_pull__spoolss_EnumPrinterDataEx(ndr, flags, &_r));
if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
NDR_PULL_ALLOC(ndr, r->out.info);
}
*r->out.info = NULL;
r->out.needed = _r.out.needed;
r->out.count = _r.out.count;
r->out.result = _r.out.result;
if (_r.out.info.length) {
struct ndr_pull *_ndr_info;
NDR_PULL_ALLOC(ndr, *r->out.info);
_ndr_info = ndr_pull_init_blob(&_r.out.info, *r->out.info, ndr->iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(_ndr_info);
_ndr_info->flags= ndr->flags;
if (r->in.offered != _ndr_info->data_size) {
return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,
"SPOOLSS Buffer: offered[%u] doesn't match length of buffer[%u]",
(unsigned)r->in.offered, (unsigned)_ndr_info->data_size);
}
if (*r->out.needed <= _ndr_info->data_size) {
struct __spoolss_EnumPrinterDataEx __r;
__r.in.count = *r->out.count;
__r.out.info = NULL;
NDR_CHECK(ndr_pull___spoolss_EnumPrinterDataEx(_ndr_info, flags, &__r));
*r->out.info = __r.out.info;
}
}
}
return NDR_ERR_SUCCESS;
}
uint32_t ndr_size_spoolss_EnumPrinterDataEx_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
uint32_t count, struct spoolss_PrinterEnumValues *info)
{
NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPrinterDataEx);
}
/*
@ -451,15 +567,17 @@ enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flag
}
if (flags & NDR_OUT) {
struct ndr_push *_ndr_info;
DATA_BLOB blob = data_blob(NULL, 0);
_r.in.handle = r->in.handle;
_r.in.value_name= r->in.value_name;
_r.in.offered = r->in.offered;
_r.out.type = r->out.type;
_r.out.data = data_blob(NULL, 0);
_r.out.data = &blob;
_r.out.needed = r->out.needed;
_r.out.result = r->out.result;
{
struct __spoolss_GetPrinterData __r;
DATA_BLOB _blob;
_ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(_ndr_info);
_ndr_info->flags= ndr->flags;
@ -470,7 +588,8 @@ enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flag
uint32_t _padding_len = r->in.offered - _ndr_info->offset;
NDR_CHECK(ndr_push_zero(_ndr_info, _padding_len));
}
_r.out.data = ndr_push_blob(_ndr_info);
_blob = ndr_push_blob(_ndr_info);
_r.out.data = &_blob;
}
NDR_CHECK(ndr_push__spoolss_GetPrinterData(ndr, flags, &_r));
}
@ -481,13 +600,14 @@ enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flag
{
struct _spoolss_GetPrinterData _r;
if (flags & NDR_IN) {
DATA_BLOB blob = data_blob(NULL,0);
ZERO_STRUCT(r->out);
_r.in.handle = r->in.handle;
_r.in.value_name= r->in.value_name;
_r.in.offered = r->in.offered;
_r.out.type = r->out.type;
_r.out.data = data_blob(NULL,0),
_r.out.data = &blob;
_r.out.needed = r->out.needed;
NDR_CHECK(ndr_pull__spoolss_GetPrinterData(ndr, flags, &_r));
r->in.handle = _r.in.handle;
@ -496,26 +616,30 @@ enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flag
r->out.needed = _r.out.needed;
}
if (flags & NDR_OUT) {
DATA_BLOB blob = data_blob_talloc(ndr,NULL,0);
_r.in.handle = r->in.handle;
_r.in.value_name= r->in.value_name;
_r.in.offered = r->in.offered;
_r.out.type = r->out.type;
_r.out.data = data_blob(NULL,0),
_r.out.data = &blob;
_r.out.needed = r->out.needed;
_r.out.result = r->out.result;
NDR_CHECK(ndr_pull__spoolss_GetPrinterData(ndr, flags, &_r));
r->out.type = _r.out.type;
ZERO_STRUCT(r->out.data);
if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
NDR_PULL_ALLOC(ndr, r->out.data);
}
ZERO_STRUCTP(r->out.data);
r->out.needed = _r.out.needed;
r->out.result = _r.out.result;
if (_r.out.data.length != r->in.offered) {
if (_r.out.data && _r.out.data->length != r->in.offered) {
return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,
"SPOOLSS Buffer: r->in.offered[%u] doesn't match length of out buffer[%u]",
(unsigned)r->in.offered, (unsigned)_r.out.data.length);
(unsigned)r->in.offered, (unsigned)_r.out.data->length);
}
if (_r.out.data.length > 0 && *r->out.needed <= _r.out.data.length) {
if (_r.out.data && _r.out.data->length > 0 && *r->out.needed <= _r.out.data->length) {
struct __spoolss_GetPrinterData __r;
struct ndr_pull *_ndr_data = ndr_pull_init_blob(&_r.out.data, ndr, ndr->iconv_convenience);
struct ndr_pull *_ndr_data = ndr_pull_init_blob(_r.out.data, ndr, ndr->iconv_convenience);
NDR_ERR_HAVE_NO_MEMORY(_ndr_data);
_ndr_data->flags= ndr->flags;
__r.in.type = *r->out.type;
@ -523,7 +647,7 @@ enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flag
NDR_CHECK(ndr_pull___spoolss_GetPrinterData(_ndr_data, flags, &__r));
r->out.data = __r.out.data;
} else {
*r->out.type = SPOOLSS_PRINTER_DATA_TYPE_NULL;
*r->out.type = REG_NONE;
}
}
return NDR_ERR_SUCCESS;
@ -545,7 +669,7 @@ enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flag
_ndr_data->flags= ndr->flags;
__r.in.type = r->in.type;
__r.out.data = r->in.data;
__r.out.data = discard_const_p(union spoolss_PrinterData, &r->in.data);
NDR_CHECK(ndr_push___spoolss_SetPrinterData(_ndr_data, NDR_OUT, &__r));
_data_blob_data = ndr_push_blob(_ndr_data);
@ -1062,3 +1186,25 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo101(struct ndr_pull *ndr,
}
return NDR_ERR_SUCCESS;
}
void ndr_print_spoolss_Field(struct ndr_print *ndr, const char *name, const union spoolss_Field *r)
{
int level;
level = ndr_print_get_switch_value(ndr, r);
ndr_print_union(ndr, name, level, "spoolss_Field");
switch (level) {
case PRINTER_NOTIFY_TYPE:
ndr_print_spoolss_PrintNotifyField(ndr, "field", r->field);
break;
case JOB_NOTIFY_TYPE:
ndr_print_spoolss_JobNotifyField(ndr, "field", r->field);
break;
default:
ndr_print_uint16(ndr, "field", r->field);
break;
}
}

View File

@ -17,7 +17,7 @@ enum ndr_err_code ndr_pull_spoolss_EnumPrinters(struct ndr_pull *ndr, int flags,
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);
@ -32,13 +32,16 @@ enum ndr_err_code ndr_pull_spoolss_EnumMonitors(struct ndr_pull *ndr, int flags,
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,
uint32_t level, uint32_t count, union spoolss_PrintProcDataTypesInfo *info);
enum ndr_err_code ndr_push_spoolss_EnumPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterDataEx *r);
enum ndr_err_code ndr_pull_spoolss_EnumPrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDataEx *r);
uint32_t ndr_size_spoolss_EnumPrinterDataEx_info(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience,
uint32_t count, struct spoolss_PrinterEnumValues *info);
enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterData *r);
enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterData *r);
enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterData *r);
@ -46,6 +49,7 @@ uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct
size_t ndr_size_spoolss_StringArray(const struct spoolss_StringArray *r, struct smb_iconv_convenience *ic, int flags);
_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo101(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo101 *r);
_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo101(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo101 *r);
void ndr_print_spoolss_Field(struct ndr_print *ndr, const char *name, const union spoolss_Field *r);
#undef _PRINTF_ATTRIBUTE
#define _PRINTF_ATTRIBUTE(a1, a2)

View File

@ -41,7 +41,11 @@ dnl $PYTHON_CFLAGS
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])

156
m4/pkg.m4 Normal file
View File

@ -0,0 +1,156 @@
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
#
# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
#
# 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/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# PKG_PROG_PKG_CONFIG([MIN-VERSION])
# ----------------------------------
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=m4_default([$1], [0.9.0])
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
PKG_CONFIG=""
fi
fi[]dnl
])# PKG_PROG_PKG_CONFIG
# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# Check to see whether a particular set of modules exists. Similar
# to PKG_CHECK_MODULES(), but does not set variables or print errors.
#
#
# Similar to PKG_CHECK_MODULES, make sure that the first instance of
# this or PKG_CHECK_MODULES is called, or make sure to call
# PKG_CHECK_EXISTS manually
# --------------------------------------------------------------
AC_DEFUN([PKG_CHECK_EXISTS],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
if test -n "$PKG_CONFIG" && \
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
m4_ifval([$2], [$2], [:])
m4_ifvaln([$3], [else
$3])dnl
fi])
# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
# ---------------------------------------------
m4_define([_PKG_CONFIG],
[if test -n "$PKG_CONFIG"; then
if test -n "$$1"; then
pkg_cv_[]$1="$$1"
else
PKG_CHECK_EXISTS([$3],
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
[pkg_failed=yes])
fi
else
pkg_failed=untried
fi[]dnl
])# _PKG_CONFIG
# _PKG_SHORT_ERRORS_SUPPORTED
# -----------------------------
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi[]dnl
])# _PKG_SHORT_ERRORS_SUPPORTED
# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
# [ACTION-IF-NOT-FOUND])
#
#
# Note that if there is a possibility the first call to
# PKG_CHECK_MODULES might not happen, you should be sure to include an
# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
#
#
# --------------------------------------------------------------
AC_DEFUN([PKG_CHECK_MODULES],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
AC_MSG_CHECKING([for $1])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
else
$1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
fi
# Put the nasty error message in config.log where it belongs
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
ifelse([$4], , [AC_MSG_ERROR(dnl
[Package requirements ($2) were not met:
$$1_PKG_ERRORS
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
_PKG_TEXT
])],
[AC_MSG_RESULT([no])
$4])
elif test $pkg_failed = untried; then
ifelse([$4], , [AC_MSG_FAILURE(dnl
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
_PKG_TEXT
To get pkg-config, see <http://www.freedesktop.org/software/pkgconfig>.])],
[$4])
else
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
AC_MSG_RESULT([yes])
ifelse([$3], , :, [$3])
fi[]dnl
])# PKG_CHECK_MODULES

View File

@ -171,6 +171,8 @@ struct pwb_context {
uint32_t ctrl;
};
#ifndef TALLOC_FREE
#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
#endif
#define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
#define TALLOC_P(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)

View File

@ -271,7 +271,7 @@ sub Parser($$$$)
$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"); }

View File

@ -88,12 +88,11 @@ UNINSTALLLIBCMD_A=@UNINSTALLLIBCMD_A@
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.
@ -449,7 +448,19 @@ LIBSAMBA_OBJ = $(LIBSMB_OBJ0) \
LIBCLI_LDAP_MESSAGE_OBJ = ../libcli/ldap/ldap_message.o
LIBCLI_LDAP_NDR_OBJ = ../libcli/ldap/ldap_ndr.o
CLDAP_OBJ = libads/cldap.o $(LIBCLI_LDAP_MESSAGE_OBJ) $(LIBCLI_LDAP_NDR_OBJ)
LIBTSOCKET_OBJ = ../lib/tsocket/tsocket.o \
../lib/tsocket/tsocket_helpers.o \
../lib/tsocket/tsocket_bsd.o \
../lib/tsocket/tsocket_recvfrom.o \
../lib/tsocket/tsocket_sendto.o \
../lib/tsocket/tsocket_connect.o \
../lib/tsocket/tsocket_writev.o \
../lib/tsocket/tsocket_readv.o
CLDAP_OBJ = libads/cldap.o \
../libcli/cldap/cldap.o \
../lib/util/idtree.o \
$(LIBCLI_LDAP_MESSAGE_OBJ) $(LIBCLI_LDAP_NDR_OBJ) $(LIBTSOCKET_OBJ)
LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
libsmb/clikrb5.o libsmb/clispnego.o ../lib/util/asn1.o \
@ -457,7 +468,7 @@ LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
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) \
@ -578,7 +589,7 @@ RPC_NTSVCS_OBJ = rpc_server/srv_ntsvcs_nt.o \
RPC_DFS_OBJ = ../librpc/gen_ndr/srv_dfs.o rpc_server/srv_dfs_nt.o
RPC_SPOOLSS_OBJ = rpc_server/srv_spoolss.o rpc_server/srv_spoolss_nt.o \
RPC_SPOOLSS_OBJ = rpc_server/srv_spoolss_nt.o \
../librpc/gen_ndr/srv_spoolss.o
RPC_EVENTLOG_OBJ = rpc_server/srv_eventlog_nt.o \
@ -591,9 +602,7 @@ RPC_ECHO_OBJ = rpc_server/srv_echo_nt.o ../librpc/gen_ndr/srv_echo.o
RPC_SERVER_OBJ = @RPC_STATIC@ $(RPC_PIPE_OBJ)
RPC_PARSE_OBJ = $(RPC_PARSE_OBJ2) \
rpc_parse/parse_spoolss.o \
rpc_parse/parse_buffer.o
RPC_PARSE_OBJ = $(RPC_PARSE_OBJ2)
RPC_CLIENT_OBJ = rpc_client/cli_pipe.o rpc_client/rpc_transport_np.o \
rpc_client/rpc_transport_sock.o rpc_client/rpc_transport_smbd.o
@ -611,7 +620,7 @@ PASSDB_OBJ = $(PASSDB_GET_SET_OBJ) passdb/passdb.o passdb/pdb_interface.o \
passdb/util_unixsids.o passdb/lookup_sid.o \
passdb/login_cache.o @PDB_STATIC@ \
lib/account_pol.o $(PRIVILEGES_OBJ) \
lib/util_nscd.o lib/winbind_util.o
lib/util_nscd.o lib/winbind_util.o $(SERVER_MUTEX_OBJ)
DEVEL_HELP_WEIRD_OBJ = modules/weird.o
CP850_OBJ = modules/CP850.o
@ -715,7 +724,7 @@ SMBD_OBJ_SRV = smbd/files.o smbd/chgpasswd.o smbd/connection.o \
smbd/dosmode.o smbd/filename.o smbd/open.o smbd/close.o \
smbd/blocking.o smbd/sec_ctx.o smbd/srvstr.o \
smbd/vfs.o smbd/perfcount.o smbd/statcache.o smbd/seal.o \
smbd/posix_acls.o lib/sysacls.o $(SERVER_MUTEX_OBJ) \
smbd/posix_acls.o lib/sysacls.o \
smbd/process.o smbd/service.o smbd/error.o \
printing/printfsp.o lib/sysquotas.o lib/sysquotas_linux.o \
lib/sysquotas_xfs.o lib/sysquotas_4A.o \
@ -932,7 +941,7 @@ NET_OBJ = $(NET_OBJ1) \
$(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) $(LIBADDNS_OBJ0) \
$(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) \
$(LIBADS_OBJ) $(LIBADS_SERVER_OBJ) $(POPT_LIB_OBJ) \
$(SMBLDAP_OBJ) $(DCUTIL_OBJ) $(SERVER_MUTEX_OBJ) \
$(SMBLDAP_OBJ) $(DCUTIL_OBJ) \
$(AFS_OBJ) $(AFS_SETTOKEN_OBJ) $(READLINE_OBJ) \
$(LDB_OBJ) $(LIBGPO_OBJ) @BUILD_INIPARSER@ $(DISPLAY_SEC_OBJ) \
$(REG_SMBCONF_OBJ) @LIBNETAPI_STATIC@ $(LIBNET_OBJ) \
@ -1095,7 +1104,7 @@ WINBINDD_OBJ = \
$(LIBADS_OBJ) $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) \
$(DCUTIL_OBJ) $(IDMAP_OBJ) $(NSS_INFO_OBJ) \
$(AFS_OBJ) $(AFS_SETTOKEN_OBJ) \
$(LIBADS_SERVER_OBJ) $(SERVER_MUTEX_OBJ) $(LDB_OBJ) \
$(LIBADS_SERVER_OBJ) $(LDB_OBJ) \
$(TDB_VALIDATE_OBJ)
WBINFO_OBJ = ../nsswitch/wbinfo.o $(LIBSAMBA_OBJ) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \
@ -1162,7 +1171,7 @@ NTLM_AUTH_OBJ1 = utils/ntlm_auth.o utils/ntlm_auth_diagnostics.o
NTLM_AUTH_OBJ = ${NTLM_AUTH_OBJ1} $(LIBSAMBA_OBJ) $(POPT_LIB_OBJ) \
../lib/util/asn1.o libsmb/spnego.o libsmb/clikrb5.o libads/kerberos.o \
$(SERVER_MUTEX_OBJ) $(LIBADS_SERVER_OBJ) \
$(LIBADS_SERVER_OBJ) \
$(PASSDB_OBJ) $(GROUPDB_OBJ) \
$(SMBLDAP_OBJ) $(LIBNMB_OBJ) \
$(LDB_OBJ) $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@ \
@ -1632,6 +1641,10 @@ bin/ldbrename: $(BINARY_PREREQS) $(LDBRENAME_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED
$(LIBS) $(POPT_LIBS) $(LDAP_LIBS) \
$(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS)
bin/versiontest: $(BINARY_PREREQS) lib/version_test.o $(VERSION_OBJ)
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(VERSION_OBJ) lib/version_test.o
#####################################################################
#
@ -2280,7 +2293,7 @@ bin/librpc_dssetup.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_DSSETUP_OBJ)
@echo "Linking $@"
@$(SHLD_MODULE) $(RPC_DSSETUP_OBJ)
bin/librpc_spoolss2.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_SPOOLSS_OBJ)
bin/librpc_spoolss.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_SPOOLSS_OBJ)
@echo "Linking $@"
@$(SHLD_MODULE) $(RPC_SPOOLSS_OBJ)

View File

@ -65,7 +65,7 @@ echo "$0: running script/mkversion.sh"
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

View File

@ -103,6 +103,9 @@ struct cli_state *cli;
static char CLI_DIRSEP_CHAR = '\\';
static char CLI_DIRSEP_STR[] = { '\\', '\0' };
/* Authentication for client connections. */
struct user_auth_info *auth_info;
/* Accessor functions for directory paths. */
static char *fileselection;
static const char *client_get_fileselection(void)
@ -220,9 +223,7 @@ struct push_state {
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;
@ -231,7 +232,7 @@ static size_t push_source(uint8_t *inbuf, size_t n,
return 0;
}
result = readfile(inbuf, n, state->f);
result = readfile(buf, n, state->f);
state->nread += result;
return result;
}
@ -301,7 +302,7 @@ static int do_dskattr(void)
char *targetpath = NULL;
TALLOC_CTX *ctx = talloc_tos();
if ( !cli_resolve_path(ctx, "", cli, client_get_cur_dir(), &targetcli, &targetpath)) {
if ( !cli_resolve_path(ctx, "", auth_info, cli, client_get_cur_dir(), &targetcli, &targetpath)) {
d_printf("Error in dskattr: %s\n", cli_errstr(cli));
return 1;
}
@ -395,7 +396,7 @@ static int do_cd(const char *new_dir)
new_cd = clean_name(ctx, new_cd);
client_set_cur_dir(new_cd);
if ( !cli_resolve_path(ctx, "", cli, new_cd, &targetcli, &targetpath)) {
if ( !cli_resolve_path(ctx, "", auth_info, cli, new_cd, &targetcli, &targetpath)) {
d_printf("cd %s: %s\n", new_cd, cli_errstr(cli));
client_set_cur_dir(saved_dir);
goto out;
@ -821,7 +822,7 @@ void do_list(const char *mask,
/* check for dfs */
if ( !cli_resolve_path(ctx, "", cli, head, &targetcli, &targetpath ) ) {
if ( !cli_resolve_path(ctx, "", auth_info, cli, head, &targetcli, &targetpath ) ) {
d_printf("do_list: [%s] %s\n", head, cli_errstr(cli));
remove_do_list_queue_head();
continue;
@ -854,7 +855,7 @@ void do_list(const char *mask,
}
} else {
/* check for dfs */
if (cli_resolve_path(ctx, "", cli, mask, &targetcli, &targetpath)) {
if (cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetpath)) {
if (cli_list(targetcli, targetpath, attribute, do_list_helper, NULL) == -1) {
d_printf("%s listing %s\n",
cli_errstr(targetcli), targetpath);
@ -1020,7 +1021,7 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
strlower_m(lname);
}
if (!cli_resolve_path(ctx, "", cli, rname, &targetcli, &targetname ) ) {
if (!cli_resolve_path(ctx, "", auth_info, cli, rname, &targetcli, &targetname ) ) {
d_printf("Failed to open %s: %s\n", rname, cli_errstr(cli));
return 1;
}
@ -1383,7 +1384,7 @@ static bool do_mkdir(const char *name)
struct cli_state *targetcli;
char *targetname = NULL;
if (!cli_resolve_path(ctx, "", cli, name, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli, &targetname)) {
d_printf("mkdir %s: %s\n", name, cli_errstr(cli));
return false;
}
@ -1421,7 +1422,7 @@ static bool do_altname(const char *name)
static int cmd_quit(void)
{
cli_cm_shutdown();
cli_shutdown(cli);
exit(0);
/* NOTREACHED */
return 0;
@ -1466,7 +1467,7 @@ static int cmd_mkdir(void)
return 1;
}
if (!cli_resolve_path(ctx, "", cli, mask, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
return 1;
}
@ -1627,7 +1628,7 @@ static int do_put(const char *rname, const char *lname, bool reput)
struct push_state state;
NTSTATUS status;
if (!cli_resolve_path(ctx, "", cli, rname, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, rname, &targetcli, &targetname)) {
d_printf("Failed to open %s: %s\n", rname, cli_errstr(cli));
return 1;
}
@ -1683,8 +1684,8 @@ static int do_put(const char *rname, const char *lname, bool reput)
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));
}
@ -1716,7 +1717,7 @@ static int do_put(const char *rname, const char *lname, bool reput)
}
if (f == x_stdin) {
cli_cm_shutdown();
cli_shutdown(cli);
exit(0);
}
@ -2185,7 +2186,7 @@ static int cmd_wdel(void)
return 1;
}
if (!cli_resolve_path(ctx, "", cli, mask, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
d_printf("cmd_wdel %s: %s\n", mask, cli_errstr(cli));
return 1;
}
@ -2220,7 +2221,7 @@ static int cmd_open(void)
return 1;
}
if (!cli_resolve_path(ctx, "", cli, mask, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
d_printf("open %s: %s\n", mask, cli_errstr(cli));
return 1;
}
@ -2313,7 +2314,7 @@ static int cmd_posix_open(void)
}
mode = (mode_t)strtol(buf, (char **)NULL, 8);
if (!cli_resolve_path(ctx, "", cli, mask, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
d_printf("posix_open %s: %s\n", mask, cli_errstr(cli));
return 1;
}
@ -2361,7 +2362,7 @@ static int cmd_posix_mkdir(void)
}
mode = (mode_t)strtol(buf, (char **)NULL, 8);
if (!cli_resolve_path(ctx, "", cli, mask, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
d_printf("posix_mkdir %s: %s\n", mask, cli_errstr(cli));
return 1;
}
@ -2395,7 +2396,7 @@ static int cmd_posix_unlink(void)
return 1;
}
if (!cli_resolve_path(ctx, "", cli, mask, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
d_printf("posix_unlink %s: %s\n", mask, cli_errstr(cli));
return 1;
}
@ -2429,7 +2430,7 @@ static int cmd_posix_rmdir(void)
return 1;
}
if (!cli_resolve_path(ctx, "", cli, mask, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
d_printf("posix_rmdir %s: %s\n", mask, cli_errstr(cli));
return 1;
}
@ -2669,7 +2670,7 @@ static int cmd_rmdir(void)
return 1;
}
if (!cli_resolve_path(ctx, "", cli, mask, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, &targetname)) {
d_printf("rmdir %s: %s\n", mask, cli_errstr(cli));
return 1;
}
@ -2716,7 +2717,7 @@ static int cmd_link(void)
return 1;
}
if (!cli_resolve_path(ctx, "", cli, oldname, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, oldname, &targetcli, &targetname)) {
d_printf("link %s: %s\n", oldname, cli_errstr(cli));
return 1;
}
@ -2767,7 +2768,7 @@ static int cmd_symlink(void)
return 1;
}
if (!cli_resolve_path(ctx, "", cli, oldname, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, oldname, &targetcli, &targetname)) {
d_printf("link %s: %s\n", oldname, cli_errstr(cli));
return 1;
}
@ -2815,7 +2816,7 @@ static int cmd_chmod(void)
mode = (mode_t)strtol(buf, NULL, 8);
if (!cli_resolve_path(ctx, "", cli, src, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
d_printf("chmod %s: %s\n", src, cli_errstr(cli));
return 1;
}
@ -2968,7 +2969,7 @@ static int cmd_getfacl(void)
return 1;
}
if (!cli_resolve_path(ctx, "", cli, src, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
d_printf("stat %s: %s\n", src, cli_errstr(cli));
return 1;
}
@ -3134,7 +3135,7 @@ static int cmd_stat(void)
return 1;
}
if (!cli_resolve_path(ctx, "", cli, src, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
d_printf("stat %s: %s\n", src, cli_errstr(cli));
return 1;
}
@ -3235,7 +3236,7 @@ static int cmd_chown(void)
if (!src) {
return 1;
}
if (!cli_resolve_path(ctx, "", cli, src, &targetcli, &targetname) ) {
if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname) ) {
d_printf("chown %s: %s\n", src, cli_errstr(cli));
return 1;
}
@ -3289,12 +3290,12 @@ static int cmd_rename(void)
return 1;
}
if (!cli_resolve_path(ctx, "", cli, src, &targetcli, &targetsrc)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetsrc)) {
d_printf("rename %s: %s\n", src, cli_errstr(cli));
return 1;
}
if (!cli_resolve_path(ctx, "", cli, dest, &targetcli, &targetdest)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, dest, &targetcli, &targetdest)) {
d_printf("rename %s: %s\n", dest, cli_errstr(cli));
return 1;
}
@ -3364,7 +3365,7 @@ static int cmd_hardlink(void)
return 1;
}
if (!cli_resolve_path(ctx, "", cli, src, &targetcli, &targetname)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, &targetname)) {
d_printf("hardlink %s: %s\n", src, cli_errstr(cli));
return 1;
}
@ -3817,7 +3818,7 @@ static int cmd_logon(void)
static int cmd_list_connect(void)
{
cli_cm_display();
cli_cm_display(cli);
return 0;
}
@ -3831,7 +3832,7 @@ static int cmd_show_connect( void )
struct cli_state *targetcli;
char *targetpath;
if (!cli_resolve_path(ctx, "", cli, client_get_cur_dir(),
if (!cli_resolve_path(ctx, "", auth_info, cli, client_get_cur_dir(),
&targetcli, &targetpath ) ) {
d_printf("showconnect %s: %s\n", cur_dir, cli_errstr(cli));
return 1;
@ -4053,7 +4054,8 @@ static int process_command_string(const char *cmd_in)
if (!cli) {
cli = cli_cm_open(talloc_tos(), NULL,
have_ip ? dest_ss_str : desthost,
service, true, smb_encrypt,
service, auth_info,
true, smb_encrypt,
max_protocol, port, name_type);
if (!cli) {
return 1;
@ -4222,7 +4224,7 @@ static char **remote_completion(const char *text, int len)
goto cleanup;
}
if (!cli_resolve_path(ctx, "", cli, dirmask, &targetcli, &targetpath)) {
if (!cli_resolve_path(ctx, "", auth_info, cli, dirmask, &targetcli, &targetpath)) {
goto cleanup;
}
if (cli_list(targetcli, targetpath, aDIR | aSYSTEM | aHIDDEN,
@ -4519,7 +4521,7 @@ static int process(const char *base_directory)
cli = cli_cm_open(talloc_tos(), NULL,
have_ip ? dest_ss_str : desthost,
service, true, smb_encrypt,
service, auth_info, true, smb_encrypt,
max_protocol, port, name_type);
if (!cli) {
return 1;
@ -4528,7 +4530,7 @@ static int process(const char *base_directory)
if (base_directory && *base_directory) {
rc = do_cd(base_directory);
if (rc) {
cli_cm_shutdown();
cli_shutdown(cli);
return rc;
}
}
@ -4539,7 +4541,7 @@ static int process(const char *base_directory)
process_stdin();
}
cli_cm_shutdown();
cli_shutdown(cli);
return rc;
}
@ -4552,7 +4554,7 @@ static int do_host_query(const char *query_host)
struct sockaddr_storage ss;
cli = cli_cm_open(talloc_tos(), NULL,
query_host, "IPC$", true, smb_encrypt,
query_host, "IPC$", auth_info, true, smb_encrypt,
max_protocol, port, name_type);
if (!cli)
return 1;
@ -4570,9 +4572,9 @@ static int do_host_query(const char *query_host)
/* 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,
query_host, "IPC$", auth_info, true, smb_encrypt,
max_protocol, 139, name_type);
}
@ -4583,7 +4585,7 @@ static int do_host_query(const char *query_host)
list_servers(lp_workgroup());
cli_cm_shutdown();
cli_shutdown(cli);
return(0);
}
@ -4600,7 +4602,7 @@ static int do_tar_op(const char *base_directory)
if (!cli) {
cli = cli_cm_open(talloc_tos(), NULL,
have_ip ? dest_ss_str : desthost,
service, true, smb_encrypt,
service, auth_info, true, smb_encrypt,
max_protocol, port, name_type);
if (!cli)
return 1;
@ -4611,14 +4613,14 @@ static int do_tar_op(const char *base_directory)
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);
}
@ -4627,7 +4629,7 @@ static int do_tar_op(const char *base_directory)
Handle a message operation.
****************************************************************************/
static int do_message_op(struct user_auth_info *auth_info)
static int do_message_op(struct user_auth_info *a_info)
{
struct sockaddr_storage ss;
struct nmb_name called, calling;
@ -4665,12 +4667,12 @@ static int do_message_op(struct user_auth_info *auth_info)
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();
send_message(get_cmdline_auth_info_username(a_info));
cli_shutdown(cli);
return 0;
}
@ -4716,7 +4718,6 @@ static int do_message_op(struct user_auth_info *auth_info)
POPT_TABLEEND
};
TALLOC_CTX *frame = talloc_stackframe();
struct user_auth_info *auth_info;
if (!client_set_cur_dir("\\")) {
exit(ENOMEM);
@ -4972,12 +4973,11 @@ static int do_message_op(struct user_auth_info *auth_info)
poptFreeContext(pc);
/* Store the username and password for dfs support */
cli_cm_set_credentials(auth_info);
DEBUG(3,("Client started (version %s).\n", samba_version_string()));
/* Ensure we have a password (or equivalent). */
set_cmdline_auth_info_getpass(auth_info);
if (tar_type) {
if (cmdstr)
process_command_string(cmdstr);

View File

@ -1463,7 +1463,8 @@ mount_retry:
}
}
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;
}

View File

@ -20,10 +20,29 @@ AC_SUBST(builddir)
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 test 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
@ -266,7 +285,7 @@ if test "$ac_cv_prog_gnu_ld" = "yes"; then
else
AC_MSG_CHECKING(GNU ld release version)
changequote(,)dnl
ac_cv_gnu_ld_vernr=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([1-9][0-9]*\.[0-9][0-9]*\).*$,\1,p'`
ac_cv_gnu_ld_vernr=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*[^0-9\.]\+\([1-9][0-9]*\.[0-9][0-9]*\).*$,\1,p'`
ac_cv_gnu_ld_vernr_major=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 1`
ac_cv_gnu_ld_vernr_minor=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 2`
changequote([,])dnl
@ -278,7 +297,7 @@ if test "$ac_cv_prog_gnu_ld" = "yes"; then
if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
fi
if test "$ac_cv_gnu_ld_vernr_major" -gt 2 || test "$ac_cv_gnu_ld_vernr_major"=2 && test "$ac_cv_gnu_ld_vernr_minor" -ge 12; then
if test "$ac_cv_gnu_ld_vernr_major" -gt 2 || test "$ac_cv_gnu_ld_vernr_major" = 2 && test "$ac_cv_gnu_ld_vernr_minor" -ge 12; then
ac_cv_gnu_ld_version_script=yes
fi
fi
@ -414,7 +433,7 @@ AC_SUBST(DYNEXP)
dnl Add modules that have to be built by default here
dnl These have to be built static:
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"
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_spoolss 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 vfs_preopen"
@ -1177,13 +1196,10 @@ if test x"$LIBUNWIND_PTRACE" != x"" ; then
#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)
@ -3261,6 +3277,9 @@ if test x"$with_ads_support" != x"no"; then
ac_save_CPPFLAGS=$CPPFLAGS
ac_save_LDFLAGS=$LDFLAGS
# remove needless evil rpath stuff as early as possible:
LIB_REMOVE_USR_LIB(KRB5_LIBS)
LIB_REMOVE_USR_LIB(KRB5_LDFLAGS)
CFLAGS="$KRB5_CFLAGS $CFLAGS"
CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
@ -6071,7 +6090,7 @@ do
done
dnl Always build these modules static
MODULE_rpc_spoolss2=STATIC
MODULE_rpc_spoolss=STATIC
MODULE_rpc_srvsvc=STATIC
MODULE_idmap_tdb=STATIC
MODULE_idmap_passdb=STATIC
@ -6115,7 +6134,7 @@ SMB_MODULE(rpc_ntsvcs, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs.$SHLIBEXT", RPC)
SMB_MODULE(rpc_netlogon, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
SMB_MODULE(rpc_srvsvc, \$(RPC_SVC_OBJ), "bin/librpc_svcsvc.$SHLIBEXT", RPC)
SMB_MODULE(rpc_spoolss2, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss2.$SHLIBEXT", RPC)
SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
SMB_MODULE(rpc_eventlog, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog.$SHLIBEXT", RPC)
SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_rpcecho.$SHLIBEXT", RPC)
@ -6342,7 +6361,6 @@ AC_ZLIB([ZLIB_OBJS=""], [
dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
LIB_REMOVE_USR_LIB(LDFLAGS)
LIB_REMOVE_USR_LIB(LIBS)
LIB_REMOVE_USR_LIB(KRB5_LIBS)
dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)

View File

@ -167,6 +167,10 @@ struct smb_trans_enc_state {
};
struct cli_state {
/**
* A list of subsidiary connections for DFS.
*/
struct cli_state *prev, *next;
int port;
int fd;
/* Last read or write error. */
@ -183,9 +187,9 @@ struct cli_state {
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
@ -276,6 +280,9 @@ struct cli_state {
* chained async_req.
*/
struct cli_request *chain_accumulator;
/* Where (if anywhere) this is mounted under DFS. */
char *dfs_mountpoint;
};
typedef struct file_info {

View File

@ -622,7 +622,6 @@ struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx);
#include "ntdomain.h"
#include "reg_objects.h"
#include "reg_db.h"
#include "rpc_spoolss.h"
#include "rpc_perfcount.h"
#include "rpc_perfcount_defs.h"
#include "librpc/gen_ndr/notify.h"

View File

@ -74,7 +74,7 @@ struct _SMBCSRV {
bool no_pathinfo;
bool no_pathinfo2;
bool no_nt_session;
POLICY_HND pol;
struct policy_handle pol;
SMBCSRV *next, *prev;
@ -181,6 +181,12 @@ struct SMBC_internal_data {
*/
bool case_sensitive;
/*
* Auth info needed for DFS traversal.
*/
struct user_auth_info *auth_info;
struct smbc_server_cache * server_cache;
/* POSIX emulation functions */

View File

@ -440,7 +440,7 @@ typedef struct _Printer{
fstring localmachine;
uint32 printerlocal;
struct spoolss_NotifyOption *option;
POLICY_HND client_hnd;
struct policy_handle client_hnd;
bool client_connected;
uint32 change;
/* are we in a FindNextPrinterChangeNotify() call? */
@ -459,4 +459,20 @@ typedef struct _Printer{
} Printer_entry;
/*
* The printer attributes.
* I #defined all of them (grabbed form MSDN)
* I'm only using:
* ( SHARED | NETWORK | RAW_ONLY )
* RAW_ONLY _MUST_ be present otherwise NT will send an EMF file
*/
#define PRINTER_ATTRIBUTE_SAMBA (PRINTER_ATTRIBUTE_RAW_ONLY|\
PRINTER_ATTRIBUTE_SHARED|\
PRINTER_ATTRIBUTE_LOCAL)
#define PRINTER_ATTRIBUTE_NOT_SAMBA (PRINTER_ATTRIBUTE_NETWORK)
#define DRIVER_ANY_VERSION 0xffffffff
#define DRIVER_MAX_VERSION 4
#endif /* NT_PRINTING_H_ */

View File

@ -117,7 +117,7 @@ typedef struct _input_data {
struct policy {
struct policy *next, *prev;
POLICY_HND pol_hnd;
struct policy_handle pol_hnd;
void *data_ptr;
};
@ -293,11 +293,4 @@ struct api_struct {
/* end higher order functions */
typedef struct {
uint32 size;
prs_struct prs;
uint32 struct_start;
uint32 string_at_end;
} RPC_BUFFER;
#endif /* _NT_DOMAIN_H */

View File

@ -53,6 +53,7 @@ struct user_auth_info {
int signing_state;
bool smb_encrypt;
bool use_machine_account;
bool fallback_after_kerberos;
};
#endif /* _POPT_COMMON_H */

View File

@ -1072,27 +1072,31 @@ const char *my_netbios_names(int i);
bool set_netbios_aliases(const char **str_array);
bool init_names(void);
struct user_auth_info *user_auth_info_init(TALLOC_CTX *mem_ctx);
const char *get_cmdline_auth_info_username(struct user_auth_info *auth_info);
const char *get_cmdline_auth_info_username(const struct user_auth_info *auth_info);
void set_cmdline_auth_info_username(struct user_auth_info *auth_info,
const char *username);
void set_cmdline_auth_info_password(struct user_auth_info *auth_info,
const char *password);
const char *get_cmdline_auth_info_password(struct user_auth_info *auth_info);
const char *get_cmdline_auth_info_password(const struct user_auth_info *auth_info);
bool set_cmdline_auth_info_signing_state(struct user_auth_info *auth_info,
const char *arg);
int get_cmdline_auth_info_signing_state(struct user_auth_info *auth_info);
int get_cmdline_auth_info_signing_state(const struct user_auth_info *auth_info);
void set_cmdline_auth_info_use_kerberos(struct user_auth_info *auth_info,
bool b);
bool get_cmdline_auth_info_use_kerberos(struct user_auth_info *auth_info);
bool get_cmdline_auth_info_use_kerberos(const struct user_auth_info *auth_info);
void set_cmdline_auth_info_fallback_after_kerberos(struct user_auth_info *auth_info,
bool b);
bool get_cmdline_auth_info_fallback_after_kerberos(const struct user_auth_info *auth_info);
void set_cmdline_auth_info_use_krb5_ticket(struct user_auth_info *auth_info);
void set_cmdline_auth_info_smb_encrypt(struct user_auth_info *auth_info);
void set_cmdline_auth_info_use_machine_account(struct user_auth_info *auth_info);
bool get_cmdline_auth_info_got_pass(struct user_auth_info *auth_info);
bool get_cmdline_auth_info_smb_encrypt(struct user_auth_info *auth_info);
bool get_cmdline_auth_info_use_machine_account(struct user_auth_info *auth_info);
bool get_cmdline_auth_info_got_pass(const struct user_auth_info *auth_info);
bool get_cmdline_auth_info_smb_encrypt(const struct user_auth_info *auth_info);
bool get_cmdline_auth_info_use_machine_account(const struct user_auth_info *auth_info);
struct user_auth_info *get_cmdline_auth_info_copy(TALLOC_CTX *mem_ctx,
struct user_auth_info *info);
const struct user_auth_info *info);
bool set_cmdline_auth_info_machine_account_creds(struct user_auth_info *auth_info);
void set_cmdline_auth_info_getpass(struct user_auth_info *auth_info);
bool add_gid_to_array_unique(TALLOC_CTX *mem_ctx, gid_t gid,
gid_t **gids, size_t *num_gids);
bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf);
@ -1205,7 +1209,7 @@ void *_talloc_zero_array_zeronull(const void *ctx, size_t el_size, unsigned coun
void *talloc_zeronull(const void *context, size_t size, const char *name);
NTSTATUS split_ntfs_stream_name(TALLOC_CTX *mem_ctx, const char *fname,
char **pbase, char **pstream);
bool is_valid_policy_hnd(const POLICY_HND *hnd);
bool is_valid_policy_hnd(const struct policy_handle *hnd);
bool policy_hnd_equal(const struct policy_handle *hnd1,
const struct policy_handle *hnd2);
const char *strip_hostname(const char *s);
@ -1396,13 +1400,13 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
uint16_t port,
int timeout);
NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd);
struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct timeval wait_time,
const struct sockaddr_storage *pss,
uint16_t port,
int timeout);
NTSTATUS open_socket_out_defer_recv(struct async_req *req, int *pfd);
struct tevent_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct timeval wait_time,
const struct sockaddr_storage *pss,
uint16_t port,
int timeout);
NTSTATUS open_socket_out_defer_recv(struct tevent_req *req, int *pfd);
bool open_any_socket_out(struct sockaddr_storage *addrs, int num_addrs,
int timeout, int *fd_index, int *fd);
int open_udp_socket(const char *host, int port);
@ -1553,7 +1557,6 @@ char *rpcstr_pull_unistr2_talloc(TALLOC_CTX *ctx, const UNISTR2 *src);
int rpcstr_push(void *dest, const char *src, size_t dest_len, int flags);
int rpcstr_push_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src);
void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen);
void unistr3_to_ascii(char *dest, const UNISTR3 *str, size_t maxlen);
char *unistr2_to_ascii_talloc(TALLOC_CTX *ctx, const UNISTR2 *str);
const char *unistr2_static(const UNISTR2 *str);
smb_ucs2_t toupper_w(smb_ucs2_t val);
@ -2355,27 +2358,17 @@ NTSTATUS cli_cm_force_encryption(struct cli_state *c,
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,
const char *share,
const struct user_auth_info *auth_info,
bool show_hdr,
bool force_encrypt,
int max_protocol,
int port,
int name_type);
void cli_cm_shutdown(void);
void cli_cm_display(void);
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_cm_set_signing_state(int state);
void cli_cm_set_username(const char *username);
void cli_cm_set_password(const char *newpass);
void cli_cm_set_use_kerberos(void);
void cli_cm_set_fallback_after_kerberos(void);
void cli_cm_set_dest_ss(struct sockaddr_storage *pss);
void cli_cm_display(const struct cli_state *c);
bool cli_dfs_get_referral(TALLOC_CTX *ctx,
struct cli_state *cli,
const char *path,
@ -2384,6 +2377,7 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx,
uint16 *consumed);
bool cli_resolve_path(TALLOC_CTX *ctx,
const char *mountpt,
const struct user_auth_info *dfs_auth_info,
struct cli_state *rootcli,
const char *path,
struct cli_state **targetcli,
@ -2426,7 +2420,10 @@ bool cli_send_smb_direct_writeX(struct cli_state *cli,
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);
@ -2790,18 +2787,13 @@ struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
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 */
@ -3161,11 +3153,6 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam
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);
@ -3416,11 +3403,16 @@ void brl_register_msgs(struct messaging_context *msg_ctx);
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,
@ -4797,7 +4789,6 @@ bool nt_printing_init(struct messaging_context *msg_ctx);
uint32 update_c_setprinter(bool initialize);
uint32 get_c_setprinter(void);
int get_builtin_ntforms(nt_forms_struct **list);
bool get_a_builtin_ntform(UNISTR2 *uni_formname,nt_forms_struct *form);
bool get_a_builtin_ntform_by_string(const char *form_name, nt_forms_struct *form);
int get_ntforms(nt_forms_struct **list);
int write_ntforms(nt_forms_struct **list, int number);
@ -4933,7 +4924,7 @@ bool print_job_resume(struct auth_serversupplied_info *server_info, int snum,
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,
@ -5179,13 +5170,13 @@ WERROR regkey_open_internal( TALLOC_CTX *ctx, REGISTRY_KEY **regkey,
NTSTATUS rpccli_lsa_open_policy(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
bool sec_qos, uint32 des_access,
POLICY_HND *pol);
struct policy_handle *pol);
NTSTATUS rpccli_lsa_open_policy2(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx, bool sec_qos,
uint32 des_access, POLICY_HND *pol);
uint32 des_access, struct policy_handle *pol);
NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
POLICY_HND *pol,
struct policy_handle *pol,
int num_sids,
const DOM_SID *sids,
char ***pdomains,
@ -5193,7 +5184,7 @@ NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
enum lsa_SidType **ptypes);
NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
POLICY_HND *pol, int num_names,
struct policy_handle *pol, int num_names,
const char **names,
const char ***dom_names,
int level,
@ -5407,7 +5398,7 @@ NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd,
NTSTATUS rpccli_winreg_Connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
uint32 reg_type, uint32 access_mask,
POLICY_HND *reg_hnd);
struct policy_handle *reg_hnd);
/* The following definitions come from rpc_client/cli_samr.c */
@ -5440,7 +5431,7 @@ void get_query_dispinfo_params(int loop_count, uint32 *max_entries,
NTSTATUS rpccli_try_samr_connects(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
uint32_t access_mask,
POLICY_HND *connect_pol);
struct policy_handle *connect_pol);
/* The following definitions come from rpc_client/cli_spoolss.c */
@ -5513,38 +5504,63 @@ WERROR rpccli_spoolss_enummonitors(struct rpc_pipe_client *cli,
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_getprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *hnd, const char *valuename,
REGISTRY_VALUE *value);
WERROR rpccli_spoolss_setprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *hnd, REGISTRY_VALUE *value);
WERROR rpccli_spoolss_enumprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *hnd, uint32 ndx,
uint32 value_offered, uint32 data_offered,
uint32 *value_needed, uint32 *data_needed,
REGISTRY_VALUE *value);
WERROR rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *hnd, const char *keyname,
REGVAL_CTR *ctr);
WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *hnd, const char *keyname,
uint16 **keylist, uint32 *len);
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,
struct policy_handle *handle,
const char *value_name,
uint32_t offered,
enum winreg_Type *type,
union spoolss_PrinterData *data);
WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
const char *key_name,
const char ***key_buffer,
uint32_t offered);
WERROR rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *handle,
const char *key_name,
uint32_t offered,
uint32_t *count,
struct spoolss_PrinterEnumValues **info);
/* The following definitions come from rpc_client/init_spoolss.c */
bool init_systemtime(struct spoolss_Time *r,
struct tm *unixtime);
WERROR pull_spoolss_PrinterData(TALLOC_CTX *mem_ctx,
const DATA_BLOB *blob,
union spoolss_PrinterData *data,
enum winreg_Type type);
WERROR push_spoolss_PrinterData(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
enum winreg_Type type,
union spoolss_PrinterData *data);
/* The following definitions come from rpc_client/init_lsa.c */
@ -5657,44 +5673,16 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli,
const struct ndr_interface_table *table,
uint32 opnum, void *r);
/* The following definitions come from rpc_parse/parse_buffer.c */
bool rpcbuf_init(RPC_BUFFER *buffer, uint32 size, TALLOC_CTX *ctx);
bool prs_rpcbuffer(const char *desc, prs_struct *ps, int depth, RPC_BUFFER *buffer);
bool prs_rpcbuffer_p(const char *desc, prs_struct *ps, int depth, RPC_BUFFER **buffer);
bool rpcbuf_alloc_size(RPC_BUFFER *buffer, uint32 buffer_size);
void rpcbuf_move(RPC_BUFFER *src, RPC_BUFFER **dest);
uint32 rpcbuf_get_size(RPC_BUFFER *buffer);
bool smb_io_relstr(const char *desc, RPC_BUFFER *buffer, int depth, UNISTR *string);
bool smb_io_relarraystr(const char *desc, RPC_BUFFER *buffer, int depth, uint16 **string);
bool smb_io_relsecdesc(const char *desc, RPC_BUFFER *buffer, int depth, SEC_DESC **secdesc);
uint32 size_of_relative_string(UNISTR *string);
/* The following definitions come from rpc_parse/parse_misc.c */
bool smb_io_time(const char *desc, NTTIME *nttime, prs_struct *ps, int depth);
bool smb_io_nttime(const char *desc, prs_struct *ps, int depth, NTTIME *nttime);
bool smb_io_system_time(const char *desc, prs_struct *ps, int depth, SYSTEMTIME *systime);
bool make_systemtime(SYSTEMTIME *systime, struct tm *unixtime);
bool smb_io_dom_sid(const char *desc, DOM_SID *sid, prs_struct *ps, int depth);
bool smb_io_uuid(const char *desc, struct GUID *uuid,
prs_struct *ps, int depth);
void init_unistr(UNISTR *str, const char *buf);
bool smb_io_unistr(const char *desc, UNISTR *uni, prs_struct *ps, int depth);
bool smb_io_buffer5(const char *desc, BUFFER5 *buf5, prs_struct *ps, int depth);
void init_buf_unistr2(UNISTR2 *str, uint32 *ptr, const char *buf);
void copy_unistr2(UNISTR2 *str, const UNISTR2 *from);
void init_unistr2(UNISTR2 *str, const char *buf, enum unistr2_term_codes flags);
void init_unistr2_w(TALLOC_CTX *ctx, UNISTR2 *str, const smb_ucs2_t *buf);
void init_unistr2_from_unistr(TALLOC_CTX *ctx, UNISTR2 *to, const UNISTR *from);
void init_unistr2_from_datablob(UNISTR2 *str, DATA_BLOB *blob) ;
bool prs_io_unistr2_p(const char *desc, prs_struct *ps, int depth, UNISTR2 **uni2);
bool prs_io_unistr2(const char *desc, prs_struct *ps, int depth, UNISTR2 *uni2 );
bool smb_io_unistr2(const char *desc, UNISTR2 *uni2, uint32 buffer, prs_struct *ps, int depth);
bool smb_io_pol_hnd(const char *desc, POLICY_HND *pol, prs_struct *ps, int depth);
void init_unistr3(UNISTR3 *str, const char *buf);
bool smb_io_unistr3(const char *desc, UNISTR3 *name, prs_struct *ps, int depth);
bool prs_uint64(const char *name, prs_struct *ps, int depth, uint64 *data64);
uint32 str_len_uni(UNISTR *source);
bool policy_handle_is_valid(const POLICY_HND *hnd);
/* The following definitions come from rpc_parse/parse_prs.c */
@ -5742,6 +5730,7 @@ bool prs_pointer( const char *name, prs_struct *ps, int depth,
bool prs_uint16(const char *name, prs_struct *ps, int depth, uint16 *data16);
bool prs_uint32(const char *name, prs_struct *ps, int depth, uint32 *data32);
bool prs_int32(const char *name, prs_struct *ps, int depth, int32 *data32);
bool prs_uint64(const char *name, prs_struct *ps, int depth, uint64 *data64);
bool prs_ntstatus(const char *name, prs_struct *ps, int depth, NTSTATUS *status);
bool prs_dcerpc_status(const char *name, prs_struct *ps, int depth, NTSTATUS *status);
bool prs_werror(const char *name, prs_struct *ps, int depth, WERROR *status);
@ -5749,9 +5738,7 @@ bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, uint
bool prs_uint16s(bool charmode, const char *name, prs_struct *ps, int depth, uint16 *data16s, int len);
bool prs_uint16uni(bool charmode, const char *name, prs_struct *ps, int depth, uint16 *data16s, int len);
bool prs_uint32s(bool charmode, const char *name, prs_struct *ps, int depth, uint32 *data32s, int len);
bool prs_buffer5(bool charmode, const char *name, prs_struct *ps, int depth, BUFFER5 *str);
bool prs_unistr2(bool charmode, const char *name, prs_struct *ps, int depth, UNISTR2 *str);
bool prs_unistr3(bool charmode, const char *name, UNISTR3 *str, prs_struct *ps, int depth);
bool prs_unistr(const char *name, prs_struct *ps, int depth, UNISTR *str);
bool prs_string(const char *name, prs_struct *ps, int depth, char *str, int max_buf_size);
bool prs_string_alloc(const char *name, prs_struct *ps, int depth, const char **str);
@ -5821,108 +5808,6 @@ bool smb_io_rpc_auth_schannel_chk(const char *desc, int auth_len,
bool sec_io_desc(const char *desc, SEC_DESC **ppsd, prs_struct *ps, int depth);
bool sec_io_desc_buf(const char *desc, SEC_DESC_BUF **ppsdb, prs_struct *ps, int depth);
/* The following definitions come from rpc_parse/parse_spoolss.c */
bool spoolss_io_system_time(const char *desc, prs_struct *ps, int depth, SYSTEMTIME *systime);
bool make_systemtime(SYSTEMTIME *systime, struct tm *unixtime);
bool spoolss_io_devmode(const char *desc, prs_struct *ps, int depth, DEVICEMODE *devmode);
bool make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
const POLICY_HND *handle,
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);
bool make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u,
const POLICY_HND *hnd,
uint32 idx, uint32 valuelen, uint32 datalen);
bool make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX *q_u,
const POLICY_HND *hnd, const char *key,
uint32 size);
bool make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, const POLICY_HND *hnd,
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);
bool spoolss_io_q_enumprinterkey(const char *desc, SPOOL_Q_ENUMPRINTERKEY *q_u, prs_struct *ps, int depth);
bool spoolss_io_r_enumprinterkey(const char *desc, SPOOL_R_ENUMPRINTERKEY *r_u, prs_struct *ps, int depth);
bool spoolss_io_q_enumprinterdataex(const char *desc, SPOOL_Q_ENUMPRINTERDATAEX *q_u, prs_struct *ps, int depth);
bool spoolss_io_r_enumprinterdataex(const char *desc, SPOOL_R_ENUMPRINTERDATAEX *r_u, prs_struct *ps, int depth);
/* The following definitions come from rpc_server/srv_eventlog_lib.c */
TDB_CONTEXT *elog_init_tdb( char *tdbfilename );
@ -5960,9 +5845,9 @@ NTSTATUS evlog_tdb_entry_to_evt_entry(TALLOC_CTX *mem_ctx,
bool init_pipe_handle_list(pipes_struct *p,
const struct ndr_syntax_id *syntax);
bool create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void *data_ptr);
bool find_policy_by_hnd(pipes_struct *p, POLICY_HND *hnd, void **data_p);
bool close_policy_hnd(pipes_struct *p, POLICY_HND *hnd);
bool create_policy_hnd(pipes_struct *p, struct policy_handle *hnd, void *data_ptr);
bool find_policy_by_hnd(pipes_struct *p, struct policy_handle *hnd, void **data_p);
bool close_policy_hnd(pipes_struct *p, struct policy_handle *hnd);
void close_policy_by_pipe(pipes_struct *p);
bool pipe_access_check(pipes_struct *p);
@ -6001,14 +5886,14 @@ NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
const char *client_address,
struct auth_serversupplied_info *server_info,
struct fake_file_handle **phandle);
struct async_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct fake_file_handle *handle,
const uint8_t *data, size_t len);
NTSTATUS np_write_recv(struct tevent_req *req, ssize_t *pnwritten);
struct tevent_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct fake_file_handle *handle,
const uint8_t *data, size_t len);
NTSTATUS np_write_recv(struct async_req *req, ssize_t *nwritten);
struct async_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct fake_file_handle *handle,
uint8_t *data, size_t len);
NTSTATUS np_read_recv(struct async_req *req, ssize_t *nread,
uint8_t *data, size_t len);
NTSTATUS np_read_recv(struct tevent_req *req, ssize_t *nread,
bool *is_data_outstanding);
/* The following definitions come from rpc_server/srv_samr_util.c */
@ -6023,11 +5908,6 @@ void copy_id23_to_sam_passwd(struct samu *to,
void copy_id25_to_sam_passwd(struct samu *to,
struct samr_UserInfo25 *from);
/* The following definitions come from rpc_server/srv_spoolss.c */
void spoolss2_get_pipe_fns( struct api_struct **fns, int *n_fns );
NTSTATUS rpc_spoolss2_init(void);
/* The following definitions come from rpc_server/srv_spoolss_nt.c */
WERROR delete_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *sharename );
@ -6042,11 +5922,11 @@ void reset_all_printerdata(struct messaging_context *msg,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data);
bool convert_devicemode(const char *printername, const DEVICEMODE *devmode,
NT_DEVICEMODE **pp_nt_devmode);
bool convert_devicemode(const char *printername,
const struct spoolss_DeviceMode *devmode,
NT_DEVICEMODE **pp_nt_devmode);
WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value,
uint32 type, uint8 *data, int real_len );
WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPOOL_R_GETPRINTERDATA *r_u);
void spoolss_notify_server_name(int snum,
struct spoolss_Notify *data,
print_queue_struct *queue,
@ -6114,22 +5994,13 @@ void spoolss_notify_cjobs(int snum,
TALLOC_CTX *mem_ctx);
void construct_info_data(struct spoolss_Notify *info_data,
enum spoolss_NotifyType type,
enum spoolss_Field field,
uint16_t 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(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);
/* The following definitions come from rpc_server/srv_srvsvc_nt.c */

View File

@ -41,34 +41,4 @@
#define prs_init_empty( _ps_, _ctx_, _io_ ) (void) prs_init((_ps_), 0, (_ctx_), (_io_))
/* macro to expand cookie-cutter code in cli_xxx() using rpc_api_pipe_req() */
#define CLI_DO_RPC_WERR( pcli, ctx, interface, opnum, q_in, r_out, \
q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \
{\
SMB_ASSERT(ndr_syntax_id_equal(&pcli->abstract_syntax, interface)); \
if (!prs_init( &q_ps, RPC_MAX_PDU_FRAG_LEN, ctx, MARSHALL )) { \
return WERR_NOMEM;\
}\
if ( q_io_fn("", &q_in, &q_ps, 0) ) {\
NTSTATUS _smb_pipe_stat_ = rpc_api_pipe_req(ctx, pcli, opnum, &q_ps, &r_ps); \
if (!NT_STATUS_IS_OK(_smb_pipe_stat_)) {\
prs_mem_free( &q_ps );\
prs_mem_free( &r_ps );\
return ntstatus_to_werror(_smb_pipe_stat_);\
}\
if (!r_io_fn("", &r_out, &r_ps, 0)) {\
prs_mem_free( &q_ps );\
prs_mem_free( &r_ps );\
return default_error;\
}\
} else {\
prs_mem_free( &q_ps );\
prs_mem_free( &r_ps );\
return default_error;\
}\
prs_mem_free( &q_ps );\
prs_mem_free( &r_ps );\
}
#endif /* _RPC_CLIENT_H */

View File

@ -159,8 +159,6 @@ enum schannel_direction {
/* RPC_IFACE */
typedef struct ndr_syntax_id RPC_IFACE;
extern const struct ndr_syntax_id syntax_spoolss;
#define RPC_IFACE_LEN (UUID_SIZE + 4)
/* RPC_HDR - dce rpc header */

View File

@ -90,8 +90,6 @@ enum unistr2_term_codes { UNI_FLAGS_NONE = 0, UNI_STR_TERMINATE = 1, UNI_MAXLEN_
/**********************************************************************
* RPC policy handle used pretty much everywhere
**********************************************************************/
typedef struct policy_handle POLICY_HND;
#define OUR_HANDLE(hnd) (((hnd)==NULL) ? "NULL" :\
( IVAL((hnd)->uuid.node,2) == (uint32)sys_getpid() ? "OURS" : \
@ -99,17 +97,6 @@ typedef struct policy_handle POLICY_HND;
((unsigned int)sys_getpid() )
/**********************************************************************
* Buffers use by spoolss (i might be able to replace it with
* an RPC_DATA_BLOB)
**********************************************************************/
typedef struct {
uint32 buf_len;
uint16 *buffer; /* data */
} BUFFER5;
/**********************************************************************
* UNICODE string variations
**********************************************************************/
@ -130,12 +117,23 @@ typedef struct { /* UNISTR2 - unicode string size (in
should include the NULL character */
} UNISTR2;
/* i think this is the same as a BUFFER5 used in the spoolss code --jerry */
/* not sure about how the termination matches between the uint16 buffers thought */
typedef struct { /* UNISTR3 - XXXX not sure about this structure */
uint32 uni_str_len;
UNISTR str;
} UNISTR3;
/*
* I'm really wondering how many different time formats
* I will have to cope with
*
* JFM, 09/13/98 In a mad mood ;-(
*/
typedef struct systemtime
{
uint16 year;
uint16 month;
uint16 dayofweek;
uint16 day;
uint16 hour;
uint16 minute;
uint16 second;
uint16 milliseconds;
}
SYSTEMTIME;
#endif /* _RPC_MISC_H */

View File

@ -1,859 +0,0 @@
/*
Unix SMB/Netbios implementation.
Copyright (C) Andrew Tridgell 1992-2000,
Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
Copyright (C) Jean Francois Micouleau 1998-2000.
Copyright (C) Gerald Carter 2001-2006.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "librpc/gen_ndr/spoolss.h"
#ifndef _RPC_SPOOLSS_H /* _RPC_SPOOLSS_H */
#define _RPC_SPOOLSS_H
/* spoolss pipe: this are the calls which are not implemented ...
#define SPOOLSS_GETPRINTERDRIVER 0x0b
#define SPOOLSS_READPRINTER 0x16
#define SPOOLSS_WAITFORPRINTERCHANGE 0x1c
#define SPOOLSS_ADDPORT 0x25
#define SPOOLSS_CONFIGUREPORT 0x26
#define SPOOLSS_DELETEPORT 0x27
#define SPOOLSS_CREATEPRINTERIC 0x28
#define SPOOLSS_PLAYGDISCRIPTONPRINTERIC 0x29
#define SPOOLSS_DELETEPRINTERIC 0x2a
#define SPOOLSS_ADDPRINTERCONNECTION 0x2b
#define SPOOLSS_DELETEPRINTERCONNECTION 0x2c
#define SPOOLSS_PRINTERMESSAGEBOX 0x2d
#define SPOOLSS_ADDMONITOR 0x2e
#define SPOOLSS_DELETEMONITOR 0x2f
#define SPOOLSS_DELETEPRINTPROCESSOR 0x30
#define SPOOLSS_ADDPRINTPROVIDOR 0x31
#define SPOOLSS_DELETEPRINTPROVIDOR 0x32
#define SPOOLSS_FINDFIRSTPRINTERCHANGENOTIFICATION 0x36
#define SPOOLSS_FINDNEXTPRINTERCHANGENOTIFICATION 0x37
#define SPOOLSS_ROUTERFINDFIRSTPRINTERNOTIFICATIONOLD 0x39
#define SPOOLSS_ADDPORTEX 0x3d
#define SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFICATION0x3e
#define SPOOLSS_SPOOLERINIT 0x3f
#define SPOOLSS_RESETPRINTEREX 0x40
*/
/* those are implemented */
#define SPOOLSS_ENUMPRINTERS 0x00
#define SPOOLSS_OPENPRINTER 0x01
#define SPOOLSS_SETJOB 0x02
#define SPOOLSS_GETJOB 0x03
#define SPOOLSS_ENUMJOBS 0x04
#define SPOOLSS_ADDPRINTER 0x05
#define SPOOLSS_DELETEPRINTER 0x06
#define SPOOLSS_SETPRINTER 0x07
#define SPOOLSS_GETPRINTER 0x08
#define SPOOLSS_ADDPRINTERDRIVER 0x09
#define SPOOLSS_ENUMPRINTERDRIVERS 0x0a
#define SPOOLSS_GETPRINTERDRIVERDIRECTORY 0x0c
#define SPOOLSS_DELETEPRINTERDRIVER 0x0d
#define SPOOLSS_ADDPRINTPROCESSOR 0x0e
#define SPOOLSS_ENUMPRINTPROCESSORS 0x0f
#define SPOOLSS_GETPRINTPROCESSORDIRECTORY 0x10
#define SPOOLSS_STARTDOCPRINTER 0x11
#define SPOOLSS_STARTPAGEPRINTER 0x12
#define SPOOLSS_WRITEPRINTER 0x13
#define SPOOLSS_ENDPAGEPRINTER 0x14
#define SPOOLSS_ABORTPRINTER 0x15
#define SPOOLSS_ENDDOCPRINTER 0x17
#define SPOOLSS_ADDJOB 0x18
#define SPOOLSS_SCHEDULEJOB 0x19
#define SPOOLSS_GETPRINTERDATA 0x1a
#define SPOOLSS_SETPRINTERDATA 0x1b
#define SPOOLSS_CLOSEPRINTER 0x1d
#define SPOOLSS_ADDFORM 0x1e
#define SPOOLSS_DELETEFORM 0x1f
#define SPOOLSS_GETFORM 0x20
#define SPOOLSS_SETFORM 0x21
#define SPOOLSS_ENUMFORMS 0x22
#define SPOOLSS_ENUMPORTS 0x23
#define SPOOLSS_ENUMMONITORS 0x24
#define SPOOLSS_ENUMPRINTPROCDATATYPES 0x33
#define SPOOLSS_RESETPRINTER 0x34
#define SPOOLSS_GETPRINTERDRIVER2 0x35
#define SPOOLSS_FCPN 0x38 /* FindClosePrinterNotify */
#define SPOOLSS_REPLYOPENPRINTER 0x3a
#define SPOOLSS_ROUTERREPLYPRINTER 0x3b
#define SPOOLSS_REPLYCLOSEPRINTER 0x3c
#define SPOOLSS_RFFPCNEX 0x41 /* RemoteFindFirstPrinterChangeNotifyEx */
#define SPOOLSS_RRPCN 0x42 /* RouteRefreshPrinterChangeNotification */
#define SPOOLSS_RFNPCNEX 0x43 /* RemoteFindNextPrinterChangeNotifyEx */
#define SPOOLSS_OPENPRINTEREX 0x45
#define SPOOLSS_ADDPRINTEREX 0x46
#define SPOOLSS_ENUMPRINTERDATA 0x48
#define SPOOLSS_DELETEPRINTERDATA 0x49
#define SPOOLSS_SETPRINTERDATAEX 0x4d
#define SPOOLSS_GETPRINTERDATAEX 0x4e
#define SPOOLSS_ENUMPRINTERDATAEX 0x4f
#define SPOOLSS_ENUMPRINTERKEY 0x50
#define SPOOLSS_DELETEPRINTERDATAEX 0x51
#define SPOOLSS_DELETEPRINTERKEY 0x52
#define SPOOLSS_DELETEPRINTERDRIVEREX 0x54
#define SPOOLSS_XCVDATAPORT 0x58
#define SPOOLSS_ADDPRINTERDRIVEREX 0x59
/*
* Special strings for the OpenPrinter() call. See the MSDN DDK
* docs on the XcvDataPort() for more details.
*/
#define SPL_LOCAL_PORT "Local Port"
#define SPL_TCPIP_PORT "Standard TCP/IP Port"
#define SPL_XCV_MONITOR_LOCALMON ",XcvMonitor Local Port"
#define SPL_XCV_MONITOR_TCPMON ",XcvMonitor Standard TCP/IP Port"
/* Notify field types */
#define PRINTER_NOTIFY_TYPE 0x00
#define JOB_NOTIFY_TYPE 0x01
#define PRINTER_NOTIFY_SERVER_NAME 0x00
#define PRINTER_NOTIFY_PRINTER_NAME 0x01
#define PRINTER_NOTIFY_SHARE_NAME 0x02
#define PRINTER_NOTIFY_PORT_NAME 0x03
#define PRINTER_NOTIFY_DRIVER_NAME 0x04
#define PRINTER_NOTIFY_COMMENT 0x05
#define PRINTER_NOTIFY_LOCATION 0x06
#define PRINTER_NOTIFY_DEVMODE 0x07
#define PRINTER_NOTIFY_SEPFILE 0x08
#define PRINTER_NOTIFY_PRINT_PROCESSOR 0x09
#define PRINTER_NOTIFY_PARAMETERS 0x0A
#define PRINTER_NOTIFY_DATATYPE 0x0B
#define PRINTER_NOTIFY_SECURITY_DESCRIPTOR 0x0C
#define PRINTER_NOTIFY_ATTRIBUTES 0x0D
#define PRINTER_NOTIFY_PRIORITY 0x0E
#define PRINTER_NOTIFY_DEFAULT_PRIORITY 0x0F
#define PRINTER_NOTIFY_START_TIME 0x10
#define PRINTER_NOTIFY_UNTIL_TIME 0x11
#define PRINTER_NOTIFY_STATUS 0x12
#define PRINTER_NOTIFY_STATUS_STRING 0x13
#define PRINTER_NOTIFY_CJOBS 0x14
#define PRINTER_NOTIFY_AVERAGE_PPM 0x15
#define PRINTER_NOTIFY_TOTAL_PAGES 0x16
#define PRINTER_NOTIFY_PAGES_PRINTED 0x17
#define PRINTER_NOTIFY_TOTAL_BYTES 0x18
#define PRINTER_NOTIFY_BYTES_PRINTED 0x19
#define JOB_NOTIFY_PRINTER_NAME 0x00
#define JOB_NOTIFY_MACHINE_NAME 0x01
#define JOB_NOTIFY_PORT_NAME 0x02
#define JOB_NOTIFY_USER_NAME 0x03
#define JOB_NOTIFY_NOTIFY_NAME 0x04
#define JOB_NOTIFY_DATATYPE 0x05
#define JOB_NOTIFY_PRINT_PROCESSOR 0x06
#define JOB_NOTIFY_PARAMETERS 0x07
#define JOB_NOTIFY_DRIVER_NAME 0x08
#define JOB_NOTIFY_DEVMODE 0x09
#define JOB_NOTIFY_STATUS 0x0A
#define JOB_NOTIFY_STATUS_STRING 0x0B
#define JOB_NOTIFY_SECURITY_DESCRIPTOR 0x0C
#define JOB_NOTIFY_DOCUMENT 0x0D
#define JOB_NOTIFY_PRIORITY 0x0E
#define JOB_NOTIFY_POSITION 0x0F
#define JOB_NOTIFY_SUBMITTED 0x10
#define JOB_NOTIFY_START_TIME 0x11
#define JOB_NOTIFY_UNTIL_TIME 0x12
#define JOB_NOTIFY_TIME 0x13
#define JOB_NOTIFY_TOTAL_PAGES 0x14
#define JOB_NOTIFY_PAGES_PRINTED 0x15
#define JOB_NOTIFY_TOTAL_BYTES 0x16
#define JOB_NOTIFY_BYTES_PRINTED 0x17
/*
* Set of macros for flagging what changed in the PRINTER_INFO_2 struct
* when sending messages to other smbd's
*/
#define PRINTER_MESSAGE_NULL 0x00000000
#define PRINTER_MESSAGE_DRIVER 0x00000001
#define PRINTER_MESSAGE_COMMENT 0x00000002
#define PRINTER_MESSAGE_PRINTERNAME 0x00000004
#define PRINTER_MESSAGE_LOCATION 0x00000008
#define PRINTER_MESSAGE_DEVMODE 0x00000010 /* not curently supported */
#define PRINTER_MESSAGE_SEPFILE 0x00000020
#define PRINTER_MESSAGE_PRINTPROC 0x00000040
#define PRINTER_MESSAGE_PARAMS 0x00000080
#define PRINTER_MESSAGE_DATATYPE 0x00000100
#define PRINTER_MESSAGE_SECDESC 0x00000200
#define PRINTER_MESSAGE_CJOBS 0x00000400
#define PRINTER_MESSAGE_PORT 0x00000800
#define PRINTER_MESSAGE_SHARENAME 0x00001000
#define PRINTER_MESSAGE_ATTRIBUTES 0x00002000
typedef struct printer_message_info {
uint32 low; /* PRINTER_CHANGE_XXX */
uint32 high; /* PRINTER_CHANGE_XXX */
fstring printer_name;
uint32 flags; /* PRINTER_MESSAGE_XXX */
}
PRINTER_MESSAGE_INFO;
/*
* The printer attributes.
* I #defined all of them (grabbed form MSDN)
* I'm only using:
* ( SHARED | NETWORK | RAW_ONLY )
* RAW_ONLY _MUST_ be present otherwise NT will send an EMF file
*/
#define PRINTER_ATTRIBUTE_SAMBA (PRINTER_ATTRIBUTE_RAW_ONLY|\
PRINTER_ATTRIBUTE_SHARED|\
PRINTER_ATTRIBUTE_LOCAL)
#define PRINTER_ATTRIBUTE_NOT_SAMBA (PRINTER_ATTRIBUTE_NETWORK)
#define NO_PRIORITY 0
#define MAX_PRIORITY 99
#define MIN_PRIORITY 1
#define DEF_PRIORITY 1
/* the flags of each printers */
#define DRIVER_ANY_VERSION 0xffffffff
#define DRIVER_MAX_VERSION 4
/*
* Devicemode structure
*/
typedef struct devicemode
{
UNISTR devicename;
uint16 specversion;
uint16 driverversion;
uint16 size;
uint16 driverextra;
uint32 fields;
uint16 orientation;
uint16 papersize;
uint16 paperlength;
uint16 paperwidth;
uint16 scale;
uint16 copies;
uint16 defaultsource;
uint16 printquality;
uint16 color;
uint16 duplex;
uint16 yresolution;
uint16 ttoption;
uint16 collate;
UNISTR formname;
uint16 logpixels;
uint32 bitsperpel;
uint32 pelswidth;
uint32 pelsheight;
uint32 displayflags;
uint32 displayfrequency;
uint32 icmmethod;
uint32 icmintent;
uint32 mediatype;
uint32 dithertype;
uint32 reserved1;
uint32 reserved2;
uint32 panningwidth;
uint32 panningheight;
uint8 *dev_private;
}
DEVICEMODE;
typedef struct _devmode_cont
{
uint32 size;
uint32 devmode_ptr;
DEVICEMODE *devmode;
}
DEVMODE_CTR;
typedef struct _printer_default
{
uint32 datatype_ptr;
UNISTR2 datatype;
DEVMODE_CTR devmode_cont;
uint32 access_required;
}
PRINTER_DEFAULT;
/********************************************/
typedef struct spool_q_getprinterdata
{
POLICY_HND handle;
UNISTR2 valuename;
uint32 size;
}
SPOOL_Q_GETPRINTERDATA;
typedef struct spool_r_getprinterdata
{
uint32 type;
uint32 size;
uint8 *data;
uint32 needed;
WERROR status;
}
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;
uint32 job_number;
}
ADD_JOBINFO_1;
/*
* I'm really wondering how many different time formats
* I will have to cope with
*
* JFM, 09/13/98 In a mad mood ;-(
*/
typedef struct systemtime
{
uint16 year;
uint16 month;
uint16 dayofweek;
uint16 day;
uint16 hour;
uint16 minute;
uint16 second;
uint16 milliseconds;
}
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
{
POLICY_HND handle;
uint32 index;
uint32 valuesize;
uint32 datasize;
}
SPOOL_Q_ENUMPRINTERDATA;
typedef struct spool_r_enumprinterdata
{
uint32 valuesize;
uint16 *value;
uint32 realvaluesize;
uint32 type;
uint32 datasize;
uint8 *data;
uint32 realdatasize;
WERROR status;
}
SPOOL_R_ENUMPRINTERDATA;
typedef struct spool_q_setprinterdata
{
POLICY_HND handle;
UNISTR2 value;
uint32 type;
uint32 max_len;
uint8 *data;
uint32 real_len;
uint32 numeric_data;
}
SPOOL_Q_SETPRINTERDATA;
typedef struct spool_r_setprinterdata
{
WERROR status;
}
SPOOL_R_SETPRINTERDATA;
typedef struct _form
{
uint32 flags;
uint32 name_ptr;
uint32 size_x;
uint32 size_y;
uint32 left;
uint32 top;
uint32 right;
uint32 bottom;
UNISTR2 name;
}
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;
UNISTR2 key;
uint32 size;
}
SPOOL_Q_ENUMPRINTERKEY;
typedef struct spool_r_enumprinterkey
{
BUFFER5 keys;
uint32 needed; /* in bytes */
WERROR status;
}
SPOOL_R_ENUMPRINTERKEY;
typedef struct printer_enum_values
{
UNISTR valuename;
uint32 value_len;
uint32 type;
uint8 *data;
uint32 data_len;
}
PRINTER_ENUM_VALUES;
typedef struct printer_enum_values_ctr
{
uint32 size;
uint32 size_of_array;
PRINTER_ENUM_VALUES *values;
}
PRINTER_ENUM_VALUES_CTR;
typedef struct spool_q_enumprinterdataex
{
POLICY_HND handle;
UNISTR2 key;
uint32 size;
}
SPOOL_Q_ENUMPRINTERDATAEX;
typedef struct spool_r_enumprinterdataex
{
PRINTER_ENUM_VALUES_CTR ctr;
uint32 needed;
uint32 returned;
WERROR status;
}
SPOOL_R_ENUMPRINTERDATAEX;
#endif /* _RPC_SPOOLSS_H */

View File

@ -1759,13 +1759,6 @@ struct node_status_extra {
/* 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;

View File

@ -256,7 +256,9 @@ NULL returns on zero request. JRA.
#define TALLOC_REALLOC(ctx, ptr, count) _talloc_realloc(ctx, ptr, count, __location__)
#define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type)
#define talloc_destroy(ctx) talloc_free(ctx)
#ifndef TALLOC_FREE
#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
#endif
/* only define PARANOID_MALLOC_CHECKER with --enable-developer */

View File

@ -243,6 +243,14 @@ enum profile_stats_values
#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)

View File

@ -116,6 +116,7 @@
/* 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
@ -223,6 +224,8 @@ typedef enum _vfs_op_type {
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. */
@ -415,6 +418,14 @@ struct vfs_ops {
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,
@ -556,6 +567,8 @@ struct vfs_ops {
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. */

View File

@ -91,6 +91,8 @@
#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)))
@ -223,6 +225,8 @@
#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)))
@ -356,6 +360,8 @@
#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)))

View File

@ -22,23 +22,18 @@
#include "nsswitch/libwbclient/wbclient.h"
struct wb_context {
struct async_req_queue *queue;
int fd;
bool is_priv;
};
struct wb_context;
struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct wb_context *wb_ctx, bool need_priv,
struct winbindd_request *wb_req);
wbcErr wb_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
struct tevent_req *wb_trans_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct wb_context *wb_ctx, bool need_priv,
struct winbindd_request *wb_req);
wbcErr wb_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
struct winbindd_response **presponse);
struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx);
/* Definitions from wb_reqtrans.c */
bool async_req_is_wbcerr(struct async_req *req, wbcErr *pwbc_err);
wbcErr map_wbc_err_from_errno(int error);
wbcErr async_req_simple_recv_wbcerr(struct async_req *req);
bool tevent_req_is_wbcerr(struct tevent_req *req, wbcErr *pwbc_err);
wbcErr tevent_req_simple_recv_wbcerr(struct tevent_req *req);
@ -61,7 +56,8 @@ wbcErr wb_resp_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
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);

View File

@ -91,6 +91,11 @@ bool run_events(struct tevent_context *ev,
return true;
}
if (ev->immediate_events &&
tevent_common_loop_immediate(ev)) {
return true;
}
GetTimeOfDay(&now);
if ((ev->timer_events != NULL)
@ -145,7 +150,7 @@ struct timeval *get_timed_events_timeout(struct tevent_context *ev,
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;
@ -181,17 +186,6 @@ static int s3_event_loop_once(struct tevent_context *ev)
return 0;
}
static int s3_event_loop_wait(struct tevent_context *ev)
{
int ret = 0;
while (ret == 0) {
ret = s3_event_loop_once(ev);
}
return ret;
}
void event_context_reinit(struct tevent_context *ev)
{
tevent_common_context_destructor(ev);
@ -238,15 +232,16 @@ void dump_event_list(struct tevent_context *ev)
}
static const struct tevent_ops s3_event_ops = {
.context_init = s3_event_context_init,
.add_fd = tevent_common_add_fd,
.set_fd_close_fn= tevent_common_fd_set_close_fn,
.get_fd_flags = tevent_common_fd_get_flags,
.set_fd_flags = tevent_common_fd_set_flags,
.add_timer = tevent_common_add_timer,
.add_signal = tevent_common_add_signal,
.loop_once = s3_event_loop_once,
.loop_wait = s3_event_loop_wait,
.context_init = s3_event_context_init,
.add_fd = tevent_common_add_fd,
.set_fd_close_fn = tevent_common_fd_set_close_fn,
.get_fd_flags = tevent_common_fd_get_flags,
.set_fd_flags = tevent_common_fd_set_flags,
.add_timer = tevent_common_add_timer,
.schedule_immediate = tevent_common_schedule_immediate,
.add_signal = tevent_common_add_signal,
.loop_once = s3_event_loop_once,
.loop_wait = tevent_common_loop_wait,
};
static bool s3_tevent_init(void)

View File

@ -29,36 +29,36 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
const char *server_name,
struct cli_state **cli)
{
struct user_auth_info *auth_info = NULL;
struct cli_state *cli_ipc = NULL;
if (!ctx || !cli || !server_name) {
return WERR_INVALID_PARAM;
}
cli_cm_set_signing_state(Undefined);
if (ctx->use_kerberos) {
cli_cm_set_use_kerberos();
}
if (ctx->password) {
cli_cm_set_password(ctx->password);
}
if (ctx->username) {
cli_cm_set_username(ctx->username);
auth_info = user_auth_info_init(NULL);
if (!auth_info) {
return WERR_NOMEM;
}
auth_info->signing_state = Undefined;
set_cmdline_auth_info_use_kerberos(auth_info, ctx->use_kerberos);
set_cmdline_auth_info_password(auth_info, ctx->password);
set_cmdline_auth_info_username(auth_info, ctx->username);
if (ctx->username && ctx->username[0] &&
ctx->password && ctx->password[0] &&
ctx->use_kerberos) {
cli_cm_set_fallback_after_kerberos();
set_cmdline_auth_info_fallback_after_kerberos(auth_info, true);
}
cli_ipc = cli_cm_open(ctx, NULL,
server_name, "IPC$",
false, false,
PROTOCOL_NT1,
0, 0x20);
server_name, "IPC$",
auth_info,
false, false,
PROTOCOL_NT1,
0, 0x20);
TALLOC_FREE(auth_info);
if (!cli_ipc) {
libnetapi_set_error_string(ctx,
"Failed to connect to IPC$ share on %s", server_name);
@ -73,22 +73,27 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
/********************************************************************
********************************************************************/
WERROR libnetapi_shutdown_cm(struct libnetapi_ctx *ctx)
{
cli_cm_shutdown();
struct client_pipe_connection {
struct client_pipe_connection *prev, *next;
struct rpc_pipe_client *pipe;
struct cli_state *cli;
};
return WERR_OK;
}
static struct client_pipe_connection *pipe_connections;
/********************************************************************
********************************************************************/
struct client_pipe_connection {
struct client_pipe_connection *prev, *next;
struct rpc_pipe_client *pipe;
};
WERROR libnetapi_shutdown_cm(struct libnetapi_ctx *ctx)
{
struct client_pipe_connection *p;
static struct client_pipe_connection *pipe_connections;
for (p = pipe_connections; p; p = p->next) {
cli_shutdown(p->cli);
}
return WERR_OK;
}
/********************************************************************
********************************************************************/
@ -138,6 +143,7 @@ static NTSTATUS pipe_cm_connect(TALLOC_CTX *mem_ctx,
return status;
}
p->cli = cli;
DLIST_ADD(pipe_connections, p);
*presult = p->pipe;
@ -193,5 +199,3 @@ WERROR libnetapi_open_pipe(struct libnetapi_ctx *ctx,
return WERR_OK;
}

View File

@ -33,7 +33,7 @@ WERROR NetGroupAdd_r(struct libnetapi_ctx *ctx,
struct rpc_pipe_client *pipe_cli = NULL;
NTSTATUS status;
WERROR werr;
POLICY_HND connect_handle, domain_handle, group_handle;
struct policy_handle connect_handle, domain_handle, group_handle;
struct lsa_String lsa_group_name;
struct dom_sid2 *domain_sid = NULL;
uint32_t rid = 0;
@ -223,7 +223,7 @@ WERROR NetGroupDel_r(struct libnetapi_ctx *ctx,
struct rpc_pipe_client *pipe_cli = NULL;
NTSTATUS status;
WERROR werr;
POLICY_HND connect_handle, domain_handle, group_handle;
struct policy_handle connect_handle, domain_handle, group_handle;
struct lsa_String lsa_group_name;
struct dom_sid2 *domain_sid = NULL;
int i = 0;
@ -384,7 +384,7 @@ WERROR NetGroupSetInfo_r(struct libnetapi_ctx *ctx,
struct rpc_pipe_client *pipe_cli = NULL;
NTSTATUS status;
WERROR werr;
POLICY_HND connect_handle, domain_handle, group_handle;
struct policy_handle connect_handle, domain_handle, group_handle;
struct lsa_String lsa_group_name;
struct dom_sid2 *domain_sid = NULL;
@ -624,7 +624,7 @@ WERROR NetGroupGetInfo_r(struct libnetapi_ctx *ctx,
struct rpc_pipe_client *pipe_cli = NULL;
NTSTATUS status;
WERROR werr;
POLICY_HND connect_handle, domain_handle, group_handle;
struct policy_handle connect_handle, domain_handle, group_handle;
struct lsa_String lsa_group_name;
struct dom_sid2 *domain_sid = NULL;
@ -742,7 +742,7 @@ WERROR NetGroupAddUser_r(struct libnetapi_ctx *ctx,
struct rpc_pipe_client *pipe_cli = NULL;
NTSTATUS status;
WERROR werr;
POLICY_HND connect_handle, domain_handle, group_handle;
struct policy_handle connect_handle, domain_handle, group_handle;
struct lsa_String lsa_group_name, lsa_user_name;
struct dom_sid2 *domain_sid = NULL;
@ -863,7 +863,7 @@ WERROR NetGroupDelUser_r(struct libnetapi_ctx *ctx,
struct rpc_pipe_client *pipe_cli = NULL;
NTSTATUS status;
WERROR werr;
POLICY_HND connect_handle, domain_handle, group_handle;
struct policy_handle connect_handle, domain_handle, group_handle;
struct lsa_String lsa_group_name, lsa_user_name;
struct dom_sid2 *domain_sid = NULL;

View File

@ -352,7 +352,7 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx,
struct rpc_pipe_client *pipe_cli = NULL;
NTSTATUS status;
WERROR werr;
POLICY_HND connect_handle, domain_handle, user_handle;
struct policy_handle connect_handle, domain_handle, user_handle;
struct lsa_String lsa_account_name;
struct dom_sid2 *domain_sid = NULL;
union samr_UserInfo *user_info = NULL;
@ -496,7 +496,7 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx,
struct rpc_pipe_client *pipe_cli = NULL;
NTSTATUS status;
WERROR werr;
POLICY_HND connect_handle, builtin_handle, domain_handle, user_handle;
struct policy_handle connect_handle, builtin_handle, domain_handle, user_handle;
struct lsa_String lsa_account_name;
struct samr_Ids user_rids, name_types;
struct dom_sid2 *domain_sid = NULL;

View File

@ -290,7 +290,7 @@ struct user_auth_info *user_auth_info_init(TALLOC_CTX *mem_ctx)
return result;
}
const char *get_cmdline_auth_info_username(struct user_auth_info *auth_info)
const char *get_cmdline_auth_info_username(const struct user_auth_info *auth_info)
{
if (!auth_info->username) {
return "";
@ -308,7 +308,7 @@ void set_cmdline_auth_info_username(struct user_auth_info *auth_info,
}
}
const char *get_cmdline_auth_info_password(struct user_auth_info *auth_info)
const char *get_cmdline_auth_info_password(const struct user_auth_info *auth_info)
{
if (!auth_info->password) {
return "";
@ -320,6 +320,9 @@ void set_cmdline_auth_info_password(struct user_auth_info *auth_info,
const char *password)
{
TALLOC_FREE(auth_info->password);
if (password == NULL) {
password = "";
}
auth_info->password = talloc_strdup(auth_info, password);
if (!auth_info->password) {
exit(ENOMEM);
@ -346,7 +349,7 @@ bool set_cmdline_auth_info_signing_state(struct user_auth_info *auth_info,
return true;
}
int get_cmdline_auth_info_signing_state(struct user_auth_info *auth_info)
int get_cmdline_auth_info_signing_state(const struct user_auth_info *auth_info)
{
return auth_info->signing_state;
}
@ -357,11 +360,22 @@ void set_cmdline_auth_info_use_kerberos(struct user_auth_info *auth_info,
auth_info->use_kerberos = b;
}
bool get_cmdline_auth_info_use_kerberos(struct user_auth_info *auth_info)
bool get_cmdline_auth_info_use_kerberos(const struct user_auth_info *auth_info)
{
return auth_info->use_kerberos;
}
void set_cmdline_auth_info_fallback_after_kerberos(struct user_auth_info *auth_info,
bool b)
{
auth_info->fallback_after_kerberos = b;
}
bool get_cmdline_auth_info_fallback_after_kerberos(const struct user_auth_info *auth_info)
{
return auth_info->fallback_after_kerberos;
}
/* This should only be used by lib/popt_common.c JRA */
void set_cmdline_auth_info_use_krb5_ticket(struct user_auth_info *auth_info)
{
@ -380,23 +394,23 @@ void set_cmdline_auth_info_use_machine_account(struct user_auth_info *auth_info)
auth_info->use_machine_account = true;
}
bool get_cmdline_auth_info_got_pass(struct user_auth_info *auth_info)
bool get_cmdline_auth_info_got_pass(const struct user_auth_info *auth_info)
{
return auth_info->got_pass;
}
bool get_cmdline_auth_info_smb_encrypt(struct user_auth_info *auth_info)
bool get_cmdline_auth_info_smb_encrypt(const struct user_auth_info *auth_info)
{
return auth_info->smb_encrypt;
}
bool get_cmdline_auth_info_use_machine_account(struct user_auth_info *auth_info)
bool get_cmdline_auth_info_use_machine_account(const struct user_auth_info *auth_info)
{
return auth_info->use_machine_account;
}
struct user_auth_info *get_cmdline_auth_info_copy(TALLOC_CTX *mem_ctx,
struct user_auth_info *src)
const struct user_auth_info *src)
{
struct user_auth_info *result;
@ -455,6 +469,32 @@ bool set_cmdline_auth_info_machine_account_creds(struct user_auth_info *auth_inf
return true;
}
/****************************************************************************
Ensure we have a password if one not given.
****************************************************************************/
void set_cmdline_auth_info_getpass(struct user_auth_info *auth_info)
{
char *label = NULL;
char *pass;
TALLOC_CTX *frame;
if (get_cmdline_auth_info_got_pass(auth_info) ||
get_cmdline_auth_info_use_kerberos(auth_info)) {
/* Already got one... */
return;
}
frame = talloc_stackframe();
label = talloc_asprintf(frame, "Enter %s's password: ",
get_cmdline_auth_info_username(auth_info));
pass = getpass(label);
if (pass) {
set_cmdline_auth_info_password(auth_info, pass);
}
TALLOC_FREE(frame);
}
/****************************************************************************
Add a gid to an array of gids if it's not already there.
****************************************************************************/
@ -3102,9 +3142,9 @@ NTSTATUS split_ntfs_stream_name(TALLOC_CTX *mem_ctx, const char *fname,
return NT_STATUS_OK;
}
bool is_valid_policy_hnd(const POLICY_HND *hnd)
bool is_valid_policy_hnd(const struct policy_handle *hnd)
{
POLICY_HND tmp;
struct policy_handle tmp;
ZERO_STRUCT(tmp);
return (memcmp(&tmp, hnd, sizeof(tmp)) != 0);
}

View File

@ -519,7 +519,7 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
}
while (nread < mincnt) {
readret = sys_read(fd, buf + nread, maxcnt - nread);
readret = sys_recv(fd, buf + nread, maxcnt - nread, 0);
if (readret == 0) {
DEBUG(5,("read_socket_with_timeout: "
@ -588,7 +588,7 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
return NT_STATUS_IO_TIMEOUT;
}
readret = sys_read(fd, buf+nread, maxcnt-nread);
readret = sys_recv(fd, buf+nread, maxcnt-nread, 0);
if (readret == 0) {
/* we got EOF on the file descriptor */
@ -1152,22 +1152,22 @@ struct open_socket_out_defer_state {
int fd;
};
static void open_socket_out_defer_waited(struct async_req *subreq);
static void open_socket_out_defer_waited(struct tevent_req *subreq);
static void open_socket_out_defer_connected(struct tevent_req *subreq);
struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct timeval wait_time,
const struct sockaddr_storage *pss,
uint16_t port,
int timeout)
struct tevent_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct timeval wait_time,
const struct sockaddr_storage *pss,
uint16_t port,
int timeout)
{
struct async_req *result, *subreq;
struct tevent_req *req, *subreq;
struct open_socket_out_defer_state *state;
NTSTATUS status;
if (!async_req_setup(mem_ctx, &result, &state,
struct open_socket_out_defer_state)) {
req = tevent_req_create(mem_ctx, &state,
struct open_socket_out_defer_state);
if (req == NULL) {
return NULL;
}
state->ev = ev;
@ -1175,73 +1175,66 @@ struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx,
state->port = port;
state->timeout = timeout;
subreq = async_wait_send(state, ev, wait_time);
subreq = tevent_wakeup_send(
state, ev,
timeval_current_ofs(wait_time.tv_sec, wait_time.tv_usec));
if (subreq == NULL) {
status = NT_STATUS_NO_MEMORY;
goto post_status;
}
subreq->async.fn = open_socket_out_defer_waited;
subreq->async.priv = result;
return result;
post_status:
if (!async_post_ntstatus(result, ev, status)) {
goto fail;
}
return result;
tevent_req_set_callback(subreq, open_socket_out_defer_waited, req);
return req;
fail:
TALLOC_FREE(result);
TALLOC_FREE(req);
return NULL;
}
static void open_socket_out_defer_waited(struct async_req *subreq)
static void open_socket_out_defer_waited(struct tevent_req *subreq)
{
struct async_req *req = talloc_get_type_abort(
subreq->async.priv, struct async_req);
struct open_socket_out_defer_state *state = talloc_get_type_abort(
req->private_data, struct open_socket_out_defer_state);
struct tevent_req *subreq2;
struct tevent_req *req = tevent_req_callback_data(
subreq, struct tevent_req);
struct open_socket_out_defer_state *state = tevent_req_data(
req, struct open_socket_out_defer_state);
bool ret;
ret = async_wait_recv(subreq);
ret = tevent_wakeup_recv(subreq);
TALLOC_FREE(subreq);
if (!ret) {
async_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
return;
}
subreq2 = open_socket_out_send(state, state->ev, &state->ss,
state->port, state->timeout);
if (async_req_nomem(subreq2, req)) {
subreq = open_socket_out_send(state, state->ev, &state->ss,
state->port, state->timeout);
if (tevent_req_nomem(subreq, req)) {
return;
}
tevent_req_set_callback(subreq2, open_socket_out_defer_connected, req);
tevent_req_set_callback(subreq, open_socket_out_defer_connected, req);
}
static void open_socket_out_defer_connected(struct tevent_req *subreq)
{
struct async_req *req =
tevent_req_callback_data(subreq, struct async_req);
struct open_socket_out_defer_state *state = talloc_get_type_abort(
req->private_data, struct open_socket_out_defer_state);
struct tevent_req *req = tevent_req_callback_data(
subreq, struct tevent_req);
struct open_socket_out_defer_state *state = tevent_req_data(
req, struct open_socket_out_defer_state);
NTSTATUS status;
status = open_socket_out_recv(subreq, &state->fd);
TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
async_req_nterror(req, status);
tevent_req_nterror(req, status);
return;
}
async_req_done(req);
tevent_req_done(req);
}
NTSTATUS open_socket_out_defer_recv(struct async_req *req, int *pfd)
NTSTATUS open_socket_out_defer_recv(struct tevent_req *req, int *pfd)
{
struct open_socket_out_defer_state *state = talloc_get_type_abort(
req->private_data, struct open_socket_out_defer_state);
struct open_socket_out_defer_state *state = tevent_req_data(
req, struct open_socket_out_defer_state);
NTSTATUS status;
if (async_req_is_nterror(req, &status)) {
if (tevent_req_is_nterror(req, &status)) {
return status;
}
*pfd = state->fd;

View File

@ -383,22 +383,6 @@ void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen)
pull_ucs2(NULL, dest, str->buffer, maxlen, str->uni_str_len*2, STR_NOALIGN);
}
#if 0
/*******************************************************************
Convert a (little-endian) UNISTR3 structure to an ASCII string.
********************************************************************/
void unistr3_to_ascii(char *dest, const UNISTR3 *str, size_t maxlen)
{
if ((str == NULL) || (str->uni_str_len == 0)) {
*dest='\0';
return;
}
pull_ucs2(NULL, dest, str->str.buffer, maxlen, str->uni_str_len*2,
STR_NOALIGN);
}
#endif
/*******************************************************************
Duplicate a UNISTR2 string into a null terminated char*
using a talloc context.

View File

@ -0,0 +1,26 @@
/*
* Unix SMB/CIFS implementation.
* version_test - test program for samba_version_strion()
* Copyright (C) Michael Adam 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
int main(void)
{
printf("%s\n", samba_version_string());
return 0;
}

View File

@ -25,32 +25,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
bool async_req_is_wbcerr(struct async_req *req, wbcErr *pwbc_err)
{
enum async_req_state state;
uint64_t error;
if (!async_req_is_error(req, &state, &error)) {
*pwbc_err = WBC_ERR_SUCCESS;
return false;
}
switch (state) {
case ASYNC_REQ_USER_ERROR:
*pwbc_err = error;
break;
case ASYNC_REQ_TIMED_OUT:
*pwbc_err = WBC_ERR_UNKNOWN_FAILURE;
break;
case ASYNC_REQ_NO_MEMORY:
*pwbc_err = WBC_ERR_NO_MEMORY;
break;
default:
*pwbc_err = WBC_ERR_UNKNOWN_FAILURE;
break;
}
return true;
}
wbcErr map_wbc_err_from_errno(int error)
{
switch(error) {
@ -65,17 +39,6 @@ wbcErr map_wbc_err_from_errno(int error)
}
}
wbcErr async_req_simple_recv_wbcerr(struct async_req *req)
{
wbcErr wbc_err;
if (async_req_is_wbcerr(req, &wbc_err)) {
return wbc_err;
}
return WBC_ERR_SUCCESS;
}
bool tevent_req_is_wbcerr(struct tevent_req *req, wbcErr *pwbc_err)
{
enum tevent_req_state state;
@ -372,7 +335,8 @@ struct resp_write_state {
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;
@ -394,7 +358,7 @@ struct tevent_req *wb_resp_write_send(TALLOC_CTX *mem_ctx,
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;
}

View File

@ -20,6 +20,12 @@
#include "includes.h"
#include "wbc_async.h"
struct wb_context {
struct tevent_queue *queue;
int fd;
bool is_priv;
};
static int make_nonstd_fd(int fd)
{
int i;
@ -138,7 +144,7 @@ struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx)
if (result == NULL) {
return NULL;
}
result->queue = async_req_queue_init(result);
result->queue = tevent_queue_create(result, "wb_trans");
if (result->queue == NULL) {
TALLOC_FREE(result);
return NULL;
@ -545,43 +551,18 @@ struct wb_trans_state {
static void wb_trans_connect_done(struct tevent_req *subreq);
static void wb_trans_done(struct tevent_req *subreq);
static void wb_trans_retry_wait_done(struct async_req *subreq);
static void wb_trans_retry_wait_done(struct tevent_req *subreq);
static void wb_trigger_trans(struct async_req *req)
struct tevent_req *wb_trans_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct wb_context *wb_ctx, bool need_priv,
struct winbindd_request *wb_req)
{
struct wb_trans_state *state = talloc_get_type_abort(
req->private_data, struct wb_trans_state);
struct tevent_req *subreq;
if ((state->wb_ctx->fd == -1)
|| (state->need_priv && !state->wb_ctx->is_priv)) {
subreq = wb_open_pipe_send(state, state->ev, state->wb_ctx,
state->need_priv);
if (async_req_nomem(subreq, req)) {
return;
}
tevent_req_set_callback(subreq, wb_trans_connect_done, req);
return;
}
subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd,
state->wb_req);
if (async_req_nomem(subreq, req)) {
return;
}
tevent_req_set_callback(subreq, wb_trans_done, req);
}
struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct wb_context *wb_ctx, bool need_priv,
struct winbindd_request *wb_req)
{
struct async_req *result;
struct tevent_req *req, *subreq;
struct wb_trans_state *state;
if (!async_req_setup(mem_ctx, &result, &state,
struct wb_trans_state)) {
req = tevent_req_create(mem_ctx, &state, struct wb_trans_state);
if (req == NULL) {
return NULL;
}
state->wb_ctx = wb_ctx;
@ -590,21 +571,32 @@ struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
state->num_retries = 10;
state->need_priv = need_priv;
if (!async_req_enqueue(wb_ctx->queue, ev, result, wb_trigger_trans)) {
if ((wb_ctx->fd == -1) || (need_priv && !wb_ctx->is_priv)) {
subreq = wb_open_pipe_send(state, ev, wb_ctx, need_priv);
if (subreq == NULL) {
goto fail;
}
tevent_req_set_callback(subreq, wb_trans_connect_done, req);
return req;
}
subreq = wb_int_trans_send(state, ev, wb_ctx->queue, wb_ctx->fd,
wb_req);
if (subreq == NULL) {
goto fail;
}
return result;
tevent_req_set_callback(subreq, wb_trans_done, req);
return req;
fail:
TALLOC_FREE(result);
TALLOC_FREE(req);
return NULL;
}
static bool wb_trans_retry(struct async_req *req,
static bool wb_trans_retry(struct tevent_req *req,
struct wb_trans_state *state,
wbcErr wbc_err)
{
struct async_req *subreq;
struct tevent_req *subreq;
if (WBC_ERROR_IS_OK(wbc_err)) {
return false;
@ -615,13 +607,13 @@ static bool wb_trans_retry(struct async_req *req,
* Winbind not around or we can't connect to the pipe. Fail
* immediately.
*/
async_req_error(req, wbc_err);
tevent_req_error(req, wbc_err);
return true;
}
state->num_retries -= 1;
if (state->num_retries == 0) {
async_req_error(req, wbc_err);
tevent_req_error(req, wbc_err);
return true;
}
@ -634,47 +626,44 @@ static bool wb_trans_retry(struct async_req *req,
state->wb_ctx->fd = -1;
}
subreq = async_wait_send(state, state->ev, timeval_set(1, 0));
if (async_req_nomem(subreq, req)) {
subreq = tevent_wakeup_send(state, state->ev,
timeval_current_ofs(1, 0));
if (tevent_req_nomem(subreq, req)) {
return true;
}
subreq->async.fn = wb_trans_retry_wait_done;
subreq->async.priv = req;
tevent_req_set_callback(subreq, wb_trans_retry_wait_done, req);
return true;
}
static void wb_trans_retry_wait_done(struct async_req *subreq)
static void wb_trans_retry_wait_done(struct tevent_req *subreq)
{
struct async_req *req = talloc_get_type_abort(
subreq->async.priv, struct async_req);
struct wb_trans_state *state = talloc_get_type_abort(
req->private_data, struct wb_trans_state);
struct tevent_req *subreq2;
struct tevent_req *req = tevent_req_callback_data(
subreq, struct tevent_req);
struct wb_trans_state *state = tevent_req_data(
req, struct wb_trans_state);
bool ret;
ret = async_wait_recv(subreq);
ret = tevent_wakeup_recv(subreq);
TALLOC_FREE(subreq);
if (ret) {
async_req_error(req, WBC_ERR_UNKNOWN_FAILURE);
if (!ret) {
tevent_req_error(req, WBC_ERR_UNKNOWN_FAILURE);
return;
}
subreq2 = wb_open_pipe_send(state, state->ev, state->wb_ctx,
state->need_priv);
if (async_req_nomem(subreq2, req)) {
subreq = wb_open_pipe_send(state, state->ev, state->wb_ctx,
state->need_priv);
if (tevent_req_nomem(subreq, req)) {
return;
}
tevent_req_set_callback(subreq2, wb_trans_connect_done, req);
tevent_req_set_callback(subreq, wb_trans_connect_done, req);
}
static void wb_trans_connect_done(struct tevent_req *subreq)
{
struct async_req *req = tevent_req_callback_data(
subreq, struct async_req);
struct wb_trans_state *state = talloc_get_type_abort(
req->private_data, struct wb_trans_state);
struct tevent_req *subreq2;
struct tevent_req *req = tevent_req_callback_data(
subreq, struct tevent_req);
struct wb_trans_state *state = tevent_req_data(
req, struct wb_trans_state);
wbcErr wbc_err;
wbc_err = wb_open_pipe_recv(subreq);
@ -684,20 +673,20 @@ static void wb_trans_connect_done(struct tevent_req *subreq)
return;
}
subreq2 = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd,
state->wb_req);
if (async_req_nomem(subreq2, req)) {
subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd,
state->wb_req);
if (tevent_req_nomem(subreq, req)) {
return;
}
tevent_req_set_callback(subreq2, wb_trans_done, req);
tevent_req_set_callback(subreq, wb_trans_done, req);
}
static void wb_trans_done(struct tevent_req *subreq)
{
struct async_req *req = tevent_req_callback_data(
subreq, struct async_req);
struct wb_trans_state *state = talloc_get_type_abort(
req->private_data, struct wb_trans_state);
struct tevent_req *req = tevent_req_callback_data(
subreq, struct tevent_req);
struct wb_trans_state *state = tevent_req_data(
req, struct wb_trans_state);
wbcErr wbc_err;
wbc_err = wb_int_trans_recv(subreq, state, &state->wb_resp);
@ -707,17 +696,17 @@ static void wb_trans_done(struct tevent_req *subreq)
return;
}
async_req_done(req);
tevent_req_done(req);
}
wbcErr wb_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
wbcErr wb_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
struct winbindd_response **presponse)
{
struct wb_trans_state *state = talloc_get_type_abort(
req->private_data, struct wb_trans_state);
struct wb_trans_state *state = tevent_req_data(
req, struct wb_trans_state);
wbcErr wbc_err;
if (async_req_is_wbcerr(req, &wbc_err)) {
if (tevent_req_is_wbcerr(req, &wbc_err)) {
return wbc_err;
}

View File

@ -322,7 +322,6 @@ bool winbind_get_sid_aliases(TALLOC_CTX *mem_ctx,
&rids,
&num_rids);
if (ret != WBC_ERR_SUCCESS) {
wbcFreeMemory(rids);
return false;
}

View File

@ -133,7 +133,9 @@ void *talloc_zeronull(const void *context, size_t size, const char *name);
#define TALLOC_REALLOC(ctx, ptr, count) _talloc_realloc(ctx, ptr, count, __location__)
#define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type)
#define talloc_destroy(ctx) talloc_free(ctx)
#ifndef TALLOC_FREE
#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
#endif
/*******************************************************************
Type definitions for int16, int32, uint16 and uint32. Needed

View File

@ -4,6 +4,7 @@
Copyright (C) 2001 Andrew Tridgell (tridge@samba.org)
Copyright (C) 2003 Jim McDonough (jmcd@us.ibm.com)
Copyright (C) 2008 Guenther Deschner (gd@samba.org)
Copyright (C) 2009 Stefan Metzmacher (metze@samba.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -20,221 +21,8 @@
*/
#include "includes.h"
/*
do a cldap netlogon query
*/
static int send_cldap_netlogon(TALLOC_CTX *mem_ctx, int sock, const char *domain,
const char *hostname, unsigned ntversion)
{
ASN1_DATA *data;
char ntver[4];
#ifdef CLDAP_USER_QUERY
char aac[4];
SIVAL(aac, 0, 0x00000180);
#endif
SIVAL(ntver, 0, ntversion);
data = asn1_init(mem_ctx);
if (data == NULL) {
return -1;
}
asn1_push_tag(data,ASN1_SEQUENCE(0));
asn1_write_Integer(data, 4);
asn1_push_tag(data, ASN1_APPLICATION(3));
asn1_write_OctetString(data, NULL, 0);
asn1_write_enumerated(data, 0);
asn1_write_enumerated(data, 0);
asn1_write_Integer(data, 0);
asn1_write_Integer(data, 0);
asn1_write_BOOLEAN(data, False);
asn1_push_tag(data, ASN1_CONTEXT(0));
if (domain) {
asn1_push_tag(data, ASN1_CONTEXT(3));
asn1_write_OctetString(data, "DnsDomain", 9);
asn1_write_OctetString(data, domain, strlen(domain));
asn1_pop_tag(data);
}
asn1_push_tag(data, ASN1_CONTEXT(3));
asn1_write_OctetString(data, "Host", 4);
asn1_write_OctetString(data, hostname, strlen(hostname));
asn1_pop_tag(data);
#ifdef CLDAP_USER_QUERY
asn1_push_tag(data, ASN1_CONTEXT(3));
asn1_write_OctetString(data, "User", 4);
asn1_write_OctetString(data, "SAMBA$", 6);
asn1_pop_tag(data);
asn1_push_tag(data, ASN1_CONTEXT(3));
asn1_write_OctetString(data, "AAC", 4);
asn1_write_OctetString(data, aac, 4);
asn1_pop_tag(data);
#endif
asn1_push_tag(data, ASN1_CONTEXT(3));
asn1_write_OctetString(data, "NtVer", 5);
asn1_write_OctetString(data, ntver, 4);
asn1_pop_tag(data);
asn1_pop_tag(data);
asn1_push_tag(data,ASN1_SEQUENCE(0));
asn1_write_OctetString(data, "NetLogon", 8);
asn1_pop_tag(data);
asn1_pop_tag(data);
asn1_pop_tag(data);
if (data->has_error) {
DEBUG(2,("Failed to build cldap netlogon at offset %d\n", (int)data->ofs));
asn1_free(data);
return -1;
}
if (write(sock, data->data, data->length) != (ssize_t)data->length) {
DEBUG(2,("failed to send cldap query (%s)\n", strerror(errno)));
asn1_free(data);
return -1;
}
asn1_free(data);
return 0;
}
/*
receive a cldap netlogon reply
*/
static int recv_cldap_netlogon(TALLOC_CTX *mem_ctx,
int sock,
uint32_t nt_version,
struct netlogon_samlogon_response **reply)
{
int ret;
ASN1_DATA *data;
DATA_BLOB blob = data_blob_null;
DATA_BLOB os1 = data_blob_null;
DATA_BLOB os2 = data_blob_null;
DATA_BLOB os3 = data_blob_null;
int i1;
struct netlogon_samlogon_response *r = NULL;
NTSTATUS status;
fd_set r_fds;
struct timeval timeout;
blob = data_blob(NULL, 8192);
if (blob.data == NULL) {
DEBUG(1, ("data_blob failed\n"));
errno = ENOMEM;
return -1;
}
FD_ZERO(&r_fds);
FD_SET(sock, &r_fds);
/*
* half the time of a regular ldap timeout, not less than 3 seconds.
*/
timeout.tv_sec = MAX(3,lp_ldap_timeout()/2);
timeout.tv_usec = 0;
ret = sys_select(sock+1, &r_fds, NULL, NULL, &timeout);
if (ret == -1) {
DEBUG(10, ("select failed: %s\n", strerror(errno)));
data_blob_free(&blob);
return -1;
}
if (ret == 0) {
DEBUG(1,("no reply received to cldap netlogon\n"));
data_blob_free(&blob);
return -1;
}
ret = read(sock, blob.data, blob.length);
if (ret <= 0) {
DEBUG(1,("no reply received to cldap netlogon\n"));
data_blob_free(&blob);
return -1;
}
blob.length = ret;
data = asn1_init(mem_ctx);
if (data == NULL) {
data_blob_free(&blob);
return -1;
}
asn1_load(data, blob);
asn1_start_tag(data, ASN1_SEQUENCE(0));
asn1_read_Integer(data, &i1);
asn1_start_tag(data, ASN1_APPLICATION(4));
asn1_read_OctetString(data, NULL, &os1);
asn1_start_tag(data, ASN1_SEQUENCE(0));
asn1_start_tag(data, ASN1_SEQUENCE(0));
asn1_read_OctetString(data, NULL, &os2);
asn1_start_tag(data, ASN1_SET);
asn1_read_OctetString(data, NULL, &os3);
asn1_end_tag(data);
asn1_end_tag(data);
asn1_end_tag(data);
asn1_end_tag(data);
asn1_end_tag(data);
if (data->has_error) {
data_blob_free(&blob);
data_blob_free(&os1);
data_blob_free(&os2);
data_blob_free(&os3);
asn1_free(data);
DEBUG(1,("Failed to parse cldap reply\n"));
return -1;
}
r = TALLOC_ZERO_P(mem_ctx, struct netlogon_samlogon_response);
if (!r) {
errno = ENOMEM;
data_blob_free(&os1);
data_blob_free(&os2);
data_blob_free(&os3);
data_blob_free(&blob);
asn1_free(data);
return -1;
}
status = pull_netlogon_samlogon_response(&os3, mem_ctx, NULL, r);
if (!NT_STATUS_IS_OK(status)) {
data_blob_free(&os1);
data_blob_free(&os2);
data_blob_free(&os3);
data_blob_free(&blob);
asn1_free(data);
TALLOC_FREE(r);
return -1;
}
map_netlogon_samlogon_response(r);
data_blob_free(&os1);
data_blob_free(&os2);
data_blob_free(&os3);
data_blob_free(&blob);
asn1_free(data);
if (reply) {
*reply = r;
} else {
TALLOC_FREE(r);
}
return 0;
}
#include "../libcli/cldap/cldap.h"
#include "../lib/tsocket/tsocket.h"
/*******************************************************************
do a cldap netlogon query. Always 389/udp
@ -244,31 +32,81 @@ bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx,
const char *server,
const char *realm,
uint32_t nt_version,
struct netlogon_samlogon_response **reply)
struct netlogon_samlogon_response **_reply)
{
int sock;
struct cldap_socket *cldap;
struct cldap_netlogon io;
struct netlogon_samlogon_response *reply;
NTSTATUS status;
struct in_addr addr;
char addrstr[INET_ADDRSTRLEN];
const char *dest_str;
int ret;
struct tsocket_address *dest_addr;
sock = open_udp_socket(server, LDAP_PORT );
if (sock == -1) {
DEBUG(2,("ads_cldap_netlogon: Failed to open udp socket to %s\n",
addr = interpret_addr2(server);
dest_str = inet_ntop(AF_INET, &addr,
addrstr, sizeof(addrstr));
if (!dest_str) {
DEBUG(2,("Failed to resolve[%s] into an address for cldap\n",
server));
return False;
return false;
}
ret = send_cldap_netlogon(mem_ctx, sock, realm, global_myname(), nt_version);
ret = tsocket_address_inet_from_strings(mem_ctx, "ipv4",
dest_str, LDAP_PORT,
&dest_addr);
if (ret != 0) {
close(sock);
return False;
}
ret = recv_cldap_netlogon(mem_ctx, sock, nt_version, reply);
close(sock);
if (ret == -1) {
return False;
status = map_nt_error_from_unix(errno);
DEBUG(2,("Failed to create cldap tsocket_address for %s - %s\n",
dest_str, nt_errstr(status)));
return false;
}
return True;
/*
* as we use a connected udp socket
*/
status = cldap_socket_init(mem_ctx, NULL, NULL, dest_addr, &cldap);
TALLOC_FREE(dest_addr);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(2,("Failed to create cldap socket to %s: %s\n",
dest_str, nt_errstr(status)));
return false;
}
reply = talloc(cldap, struct netlogon_samlogon_response);
if (!reply) {
goto failed;
}
/*
* as we use a connected socket, so we don't need to specify the
* destination
*/
io.in.dest_address = NULL;
io.in.dest_port = 0;
io.in.realm = realm;
io.in.host = NULL;
io.in.user = NULL;
io.in.domain_guid = NULL;
io.in.domain_sid = NULL;
io.in.acct_control = 0;
io.in.version = nt_version;
io.in.map_response = false;
status = cldap_netlogon(cldap, NULL, reply, &io);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(2,("cldap_netlogon() failed: %s\n", nt_errstr(status)));
goto failed;
}
*reply = io.out.netlogon;
*_reply = talloc_move(mem_ctx, &reply);
TALLOC_FREE(cldap);
return true;
failed:
TALLOC_FREE(cldap);
return false;
}
/*******************************************************************

View File

@ -30,12 +30,10 @@ static const struct {
{KRB5KDC_ERR_CLIENT_REVOKED, NT_STATUS_ACCESS_DENIED},
{KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN, NT_STATUS_INVALID_ACCOUNT_NAME},
{KRB5KDC_ERR_ETYPE_NOSUPP, NT_STATUS_LOGON_FAILURE},
#if defined(KRB5KDC_ERR_KEY_EXPIRED) /* Heimdal */
{KRB5KDC_ERR_KEY_EXPIRED, NT_STATUS_PASSWORD_EXPIRED},
#elif defined(KRB5KDC_ERR_KEY_EXP) /* MIT */
#if defined(KRB5KDC_ERR_KEY_EXP) /* MIT */
{KRB5KDC_ERR_KEY_EXP, NT_STATUS_PASSWORD_EXPIRED},
#else
#error Neither KRB5KDC_ERR_KEY_EXPIRED nor KRB5KDC_ERR_KEY_EXP available
#else /* old Heimdal releases have it with different name only in an enum: */
{KRB5KDC_ERR_KEY_EXPIRED, NT_STATUS_PASSWORD_EXPIRED},
#endif
{25, NT_STATUS_PASSWORD_EXPIRED}, /* FIXME: bug in heimdal 0.7 krb5_get_init_creds_password (Inappropriate ioctl for device (25)) */
{KRB5KDC_ERR_NULL_KEY, NT_STATUS_LOGON_FAILURE},

View File

@ -311,9 +311,10 @@ WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli,
{
WERROR result;
char *printername;
REGVAL_CTR *dsdriver_ctr, *dsspooler_ctr;
struct spoolss_PrinterEnumValues *info;
uint32_t count;
uint32 i;
POLICY_HND pol;
struct policy_handle pol;
if ((asprintf(&printername, "%s\\%s", cli->srv_name_slash, printer) == -1)) {
DEBUG(3, ("Insufficient memory\n"));
@ -330,48 +331,64 @@ WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli,
SAFE_FREE(printername);
return result;
}
if ( !(dsdriver_ctr = TALLOC_ZERO_P( mem_ctx, REGVAL_CTR )) ) {
SAFE_FREE(printername);
return WERR_NOMEM;
}
result = rpccli_spoolss_enumprinterdataex(cli, mem_ctx, &pol, SPOOL_DSDRIVER_KEY, dsdriver_ctr);
result = rpccli_spoolss_enumprinterdataex(cli, mem_ctx, &pol,
SPOOL_DSDRIVER_KEY,
0,
&count,
&info);
if (!W_ERROR_IS_OK(result)) {
DEBUG(3, ("Unable to do enumdataex on %s, error is %s.\n",
printername, win_errstr(result)));
} else {
uint32 num_values = regval_ctr_numvals( dsdriver_ctr );
/* Have the data we need now, so start building */
for (i=0; i < num_values; i++) {
map_regval_to_ads(mem_ctx, mods, dsdriver_ctr->values[i]);
for (i=0; i < count; i++) {
REGISTRY_VALUE v;
DATA_BLOB blob;
result = push_spoolss_PrinterData(mem_ctx, &blob,
info[i].type,
info[i].data);
if (W_ERROR_IS_OK(result)) {
fstrcpy(v.valuename, info[i].value_name);
v.type = info[i].type;
v.data_p = blob.data;
v.size = blob.length;
map_regval_to_ads(mem_ctx, mods, &v);
}
}
}
if ( !(dsspooler_ctr = TALLOC_ZERO_P( mem_ctx, REGVAL_CTR )) ) {
SAFE_FREE(printername);
return WERR_NOMEM;
}
result = rpccli_spoolss_enumprinterdataex(cli, mem_ctx, &pol, SPOOL_DSSPOOLER_KEY, dsspooler_ctr);
result = rpccli_spoolss_enumprinterdataex(cli, mem_ctx, &pol,
SPOOL_DSSPOOLER_KEY,
0,
&count,
&info);
if (!W_ERROR_IS_OK(result)) {
DEBUG(3, ("Unable to do enumdataex on %s, error is %s.\n",
printername, win_errstr(result)));
} else {
uint32 num_values = regval_ctr_numvals( dsspooler_ctr );
for (i=0; i < count; i++) {
REGISTRY_VALUE v;
DATA_BLOB blob;
for (i=0; i<num_values; i++) {
map_regval_to_ads(mem_ctx, mods, dsspooler_ctr->values[i]);
result = push_spoolss_PrinterData(mem_ctx, &blob,
info[i].type,
info[i].data);
if (W_ERROR_IS_OK(result)) {
fstrcpy(v.valuename, info[i].value_name);
v.type = info[i].type;
v.data_p = blob.data;
v.size = blob.length;
map_regval_to_ads(mem_ctx, mods, &v);
}
}
}
ads_mod_str(mem_ctx, mods, SPOOL_REG_PRINTERNAME, printer);
TALLOC_FREE( dsdriver_ctr );
TALLOC_FREE( dsspooler_ctr );
ads_mod_str(mem_ctx, mods, SPOOL_REG_PRINTERNAME, printer);
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
SAFE_FREE(printername);

View File

@ -680,7 +680,7 @@ static NTSTATUS libnet_join_lookup_dc_rpc(TALLOC_CTX *mem_ctx,
struct cli_state **cli)
{
struct rpc_pipe_client *pipe_hnd = NULL;
POLICY_HND lsa_pol;
struct policy_handle lsa_pol;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
union lsa_PolicyInformation *info = NULL;
@ -750,7 +750,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
struct cli_state *cli)
{
struct rpc_pipe_client *pipe_hnd = NULL;
POLICY_HND sam_pol, domain_pol, user_pol;
struct policy_handle sam_pol, domain_pol, user_pol;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
char *acct_name;
struct lsa_String lsa_acct_name;
@ -1132,7 +1132,7 @@ static NTSTATUS libnet_join_unjoindomain_rpc(TALLOC_CTX *mem_ctx,
{
struct cli_state *cli = NULL;
struct rpc_pipe_client *pipe_hnd = NULL;
POLICY_HND sam_pol, domain_pol, user_pol;
struct policy_handle sam_pol, domain_pol, user_pol;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
char *acct_name;
uint32_t user_rid;

View File

@ -61,6 +61,7 @@ static NTSTATUS cli_session_setup_lanman2(struct cli_state *cli,
{
DATA_BLOB session_key = data_blob_null;
DATA_BLOB lm_response = data_blob_null;
NTSTATUS status;
fstring pword;
char *p;
@ -129,7 +130,10 @@ static NTSTATUS cli_session_setup_lanman2(struct cli_state *cli,
/* 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 */
@ -237,7 +241,10 @@ NTSTATUS cli_session_setup_guest_recv(struct async_req *req)
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;
}
@ -289,6 +296,7 @@ static NTSTATUS cli_session_setup_plaintext(struct cli_state *cli,
{
uint32 capabilities = cli_session_setup_capabilities(cli);
char *p;
NTSTATUS status;
fstring lanman;
fstr_sprintf( lanman, "Samba %s", samba_version_string());
@ -349,8 +357,10 @@ static NTSTATUS cli_session_setup_plaintext(struct cli_state *cli,
-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;
}
@ -520,7 +530,10 @@ static NTSTATUS cli_session_setup_nt1(struct cli_state *cli, const char *user,
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 */
@ -898,6 +911,7 @@ ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user,
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));
@ -936,7 +950,10 @@ ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user,
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
@ -1768,15 +1785,20 @@ bool cli_session_request(struct cli_state *cli,
return(True);
}
static void smb_sock_connected(struct async_req *req)
struct fd_struct {
int fd;
};
static void smb_sock_connected(struct tevent_req *req)
{
int *pfd = (int *)req->async.priv;
struct fd_struct *pfd = tevent_req_callback_data(
req, struct fd_struct);
int fd;
NTSTATUS status;
status = open_socket_out_defer_recv(req, &fd);
if (NT_STATUS_IS_OK(status)) {
*pfd = fd;
pfd->fd = fd;
}
}
@ -1784,10 +1806,9 @@ static NTSTATUS open_smb_socket(const struct sockaddr_storage *pss,
uint16_t *port, int timeout, int *pfd)
{
struct event_context *ev;
struct async_req *r139, *r445;
int fd139 = -1;
int fd445 = -1;
NTSTATUS status;
struct tevent_req *r139, *r445;
struct fd_struct *fd139, *fd445;
NTSTATUS status = NT_STATUS_NO_MEMORY;
if (*port != 0) {
return open_socket_out(pss, *port, timeout, pfd);
@ -1798,43 +1819,54 @@ static NTSTATUS open_smb_socket(const struct sockaddr_storage *pss,
return NT_STATUS_NO_MEMORY;
}
fd139 = talloc(ev, struct fd_struct);
if (fd139 == NULL) {
goto done;
}
fd139->fd = -1;
fd445 = talloc(ev, struct fd_struct);
if (fd445 == NULL) {
goto done;
}
fd445->fd = -1;
r445 = open_socket_out_defer_send(ev, ev, timeval_set(0, 0),
pss, 445, timeout);
r139 = open_socket_out_defer_send(ev, ev, timeval_set(0, 3000),
pss, 139, timeout);
if ((r445 == NULL) || (r139 == NULL)) {
status = NT_STATUS_NO_MEMORY;
goto done;
}
r445->async.fn = smb_sock_connected;
r445->async.priv = &fd445;
r139->async.fn = smb_sock_connected;
r139->async.priv = &fd139;
tevent_req_set_callback(r445, smb_sock_connected, fd445);
tevent_req_set_callback(r139, smb_sock_connected, fd139);
while ((fd139 == -1) && (r139->state < ASYNC_REQ_DONE)
&& (fd445 == -1) && (r445->state < ASYNC_REQ_DONE)) {
while ((fd139->fd == -1)
&& tevent_req_is_in_progress(r139)
&& (fd445->fd == -1)
&& tevent_req_is_in_progress(r445)) {
event_loop_once(ev);
}
if ((fd139 != -1) && (fd445 != -1)) {
close(fd139);
fd139 = -1;
if ((fd139->fd != -1) && (fd445->fd != -1)) {
close(fd139->fd);
fd139->fd = -1;
}
if (fd445 != -1) {
if (fd445->fd != -1) {
*port = 445;
*pfd = fd445;
*pfd = fd445->fd;
status = NT_STATUS_OK;
goto done;
}
if (fd139 != -1) {
if (fd139->fd != -1) {
*port = 139;
*pfd = fd139;
*pfd = fd139->fd;
status = NT_STATUS_OK;
goto done;
}
status = open_socket_out_defer_recv(r445, &fd445);
status = open_socket_out_defer_recv(r445, &fd445->fd);
done:
TALLOC_FREE(ev);
return status;
@ -2101,7 +2133,11 @@ NTSTATUS cli_full_connection(struct cli_state **output_cli,
}
}
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;

View File

@ -3,7 +3,7 @@
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
@ -32,25 +32,6 @@
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;
bool got_pass;
bool use_kerberos;
bool fallback_after_kerberos;
int signing_state;
} cm_creds;
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,
@ -96,7 +77,7 @@ NTSTATUS cli_cm_force_encryption(struct cli_state *c,
return status;
}
/********************************************************************
Return a connection to a server.
********************************************************************/
@ -104,6 +85,7 @@ NTSTATUS cli_cm_force_encryption(struct cli_state *c,
static struct cli_state *do_connect(TALLOC_CTX *ctx,
const char *server,
const char *share,
const struct user_auth_info *auth_info,
bool show_sessetup,
bool force_encrypt,
int max_protocol,
@ -151,7 +133,7 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
zero_sockaddr(&ss);
/* have to open a new connection */
if (!(c=cli_initialise_ex(cm_creds.signing_state))) {
if (!(c=cli_initialise_ex(get_cmdline_auth_info_signing_state(auth_info)))) {
d_printf("Connection to %s failed\n", server_n);
if (c) {
cli_shutdown(c);
@ -175,8 +157,9 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
max_protocol = PROTOCOL_NT1;
}
c->protocol = max_protocol;
c->use_kerberos = cm_creds.use_kerberos;
c->fallback_after_kerberos = cm_creds.fallback_after_kerberos;
c->use_kerberos = get_cmdline_auth_info_use_kerberos(auth_info);
c->fallback_after_kerberos =
get_cmdline_auth_info_fallback_after_kerberos(auth_info);
if (!cli_session_request(c, &calling, &called)) {
char *p;
@ -206,20 +189,8 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
return NULL;
}
if (!cm_creds.got_pass && !cm_creds.use_kerberos) {
char *label = NULL;
char *pass;
label = talloc_asprintf(ctx, "Enter %s's password: ",
cm_creds.username);
pass = getpass(label);
if (pass) {
cm_set_password(pass);
}
TALLOC_FREE(label);
}
username = cm_creds.username ? cm_creds.username : "";
password = cm_creds.password ? cm_creds.password : "";
username = get_cmdline_auth_info_username(auth_info);
password = get_cmdline_auth_info_password(auth_info);
if (!NT_STATUS_IS_OK(cli_session_setup(c, username,
password, strlen(password),
@ -227,8 +198,9 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
lp_workgroup()))) {
/* If a password was not supplied then
* try again with a null username. */
if (password[0] || !username[0] || cm_creds.use_kerberos ||
!NT_STATUS_IS_OK(cli_session_setup(c, "",
if (password[0] || !username[0] ||
get_cmdline_auth_info_use_kerberos(auth_info) ||
!NT_STATUS_IS_OK(cli_session_setup(c, "",
"", 0,
"", 0,
lp_workgroup()))) {
@ -267,7 +239,7 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
lp_workgroup())) {
cli_shutdown(c);
return do_connect(ctx, newserver,
newshare, false,
newshare, auth_info, false,
force_encrypt, max_protocol,
port, name_type);
}
@ -301,111 +273,90 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
/****************************************************************************
****************************************************************************/
static void cli_cm_set_mntpoint(struct cli_state *c, const char *mnt)
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;
}
char *name = clean_name(NULL, mnt);
if (!name) {
return;
}
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)
{
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;
}
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,
struct cli_state *referring_cli,
const char *server,
const char *share,
const struct user_auth_info *auth_info,
bool show_hdr,
bool force_encrypt,
int max_protocol,
int port,
int name_type)
{
struct client_connection *node;
struct cli_state *cli;
/* NB This must be the null context here... JRA. */
node = TALLOC_ZERO_ARRAY(NULL, struct client_connection, 1);
if (!node) {
return NULL;
}
node->cli = do_connect(ctx, server, share,
cli = do_connect(ctx, server, share,
auth_info,
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;
}
}
@ -413,82 +364,68 @@ static struct cli_state *cli_cm_find(const char *server, const char *share)
}
/****************************************************************************
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,
struct cli_state *referring_cli,
const char *server,
const char *share,
const struct user_auth_info *auth_info,
bool show_hdr,
bool force_encrypt,
int max_protocol,
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 */
c = cli_cm_find(server, share);
if (!c) {
c = cli_cm_connect(ctx, referring_cli,
server, share, show_hdr, force_encrypt,
max_protocol, port, name_type);
if (c) {
return c;
}
return c;
if (auth_info == NULL) {
/* Can't do a new connection
* without auth info. */
d_printf("cli_cm_open() Unable to open connection [\\%s\\%s] "
"without auth info\n",
server, share );
return NULL;
}
return cli_cm_connect(ctx,
referring_cli,
server,
share,
auth_info,
show_hdr,
force_encrypt,
max_protocol,
port,
name_type);
}
/****************************************************************************
****************************************************************************/
void cli_cm_shutdown(void)
void cli_cm_display(const struct cli_state *cli)
{
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)
{
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 );
}
}
/****************************************************************************
****************************************************************************/
static void cm_set_password(const char *newpass)
{
SAFE_FREE(cm_creds.password);
cm_creds.password = SMB_STRDUP(newpass);
if (cm_creds.password) {
cm_creds.got_pass = true;
}
}
/****************************************************************************
****************************************************************************/
#if 0
void cli_cm_set_credentials(struct user_auth_info *auth_info)
{
SAFE_FREE(cm_creds.username);
@ -503,51 +440,7 @@ void cli_cm_set_credentials(struct user_auth_info *auth_info)
cm_creds.fallback_after_kerberos = false;
cm_creds.signing_state = get_cmdline_auth_info_signing_state(auth_info);
}
/****************************************************************************
****************************************************************************/
void cli_cm_set_signing_state(int state)
{
cm_creds.signing_state = state;
}
/****************************************************************************
****************************************************************************/
void cli_cm_set_username(const char *username)
{
SAFE_FREE(cm_creds.username);
cm_creds.username = SMB_STRDUP(username);
}
/****************************************************************************
****************************************************************************/
void cli_cm_set_password(const char *newpass)
{
SAFE_FREE(cm_creds.password);
cm_creds.password = SMB_STRDUP(newpass);
if (cm_creds.password) {
cm_creds.got_pass = true;
}
}
/****************************************************************************
****************************************************************************/
void cli_cm_set_use_kerberos(void)
{
cm_creds.use_kerberos = true;
}
/****************************************************************************
****************************************************************************/
void cli_cm_set_fallback_after_kerberos(void)
{
cm_creds.fallback_after_kerberos = true;
}
#endif
/**********************************************************************
split a dfs path into the server, share name, and extrapath components
@ -658,13 +551,23 @@ static char *cli_dfs_make_full_path(TALLOC_CTX *ctx,
struct cli_state *cli,
const char *dir)
{
char path_sep = '\\';
/* Ensure the extrapath doesn't start with a separator. */
while (IS_DIRECTORY_SEP(*dir)) {
dir++;
}
return talloc_asprintf(ctx, "\\%s\\%s\\%s",
cli->desthost, cli->share, dir);
if (cli->posix_capabilities & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
path_sep = '/';
}
return talloc_asprintf(ctx, "%c%s%c%s%c%s",
path_sep,
cli->desthost,
path_sep,
cli->share,
path_sep,
dir);
}
/********************************************************************
@ -817,6 +720,7 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx,
bool cli_resolve_path(TALLOC_CTX *ctx,
const char *mountpt,
const struct user_auth_info *dfs_auth_info,
struct cli_state *rootcli,
const char *path,
struct cli_state **targetcli,
@ -897,13 +801,16 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
/* Check for the referral. */
if (!(cli_ipc = cli_cm_open(ctx, rootcli,
rootcli->desthost,
"IPC$", false,
(rootcli->trans_enc_state != NULL),
rootcli->protocol,
0,
0x20))) {
if (!(cli_ipc = cli_cm_open(ctx,
rootcli,
rootcli->desthost,
"IPC$",
dfs_auth_info,
false,
(rootcli->trans_enc_state != NULL),
rootcli->protocol,
0,
0x20))) {
return false;
}
@ -947,6 +854,7 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
if ((*targetcli = cli_cm_open(ctx, rootcli,
server,
share,
dfs_auth_info,
false,
(rootcli->trans_enc_state != NULL),
rootcli->protocol,
@ -998,7 +906,7 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
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. */
@ -1006,6 +914,7 @@ bool cli_resolve_path(TALLOC_CTX *ctx,
if (!strequal(*pp_targetpath, "\\") && !strequal(*pp_targetpath, "/")) {
if (cli_resolve_path(ctx,
newmount,
dfs_auth_info,
*targetcli,
*pp_targetpath,
&newcli,

View File

@ -409,23 +409,68 @@ void cli_setup_bcc(struct cli_state *cli, void *p)
}
/****************************************************************************
Initialise credentials of a client structure.
Initialize Domain, user or password.
****************************************************************************/
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)
{
fstrcpy(cli->domain, domain);
fstrcpy(cli->user_name, username);
pwd_set_cleartext(&cli->pwd, password);
if (!*username) {
cli->pwd.null_pwd = true;
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;
}
DEBUG(10,("cli_init_creds: user %s domain %s\n", cli->user_name, cli->domain));
return NT_STATUS_OK;
}
/****************************************************************************
Initialise a client structure. Always returns a malloc'ed struct.
Initialise credentials of a client structure.
****************************************************************************/
NTSTATUS cli_init_creds(struct cli_state *cli, const char *username, const char *domain, const char *password)
{
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));
return cli_set_password(cli, password);
}
/****************************************************************************
Initialise a client structure. Always returns a talloc'ed struct.
Set the signing state (used from the command line).
****************************************************************************/
@ -446,6 +491,10 @@ struct cli_state *cli_initialise_ex(int signing_state)
return NULL;
}
cli->dfs_mountpoint = talloc_strdup(cli, "");
if (!cli->dfs_mountpoint) {
goto error;
}
cli->port = 0;
cli->fd = -1;
cli->cnum = -1;
@ -521,7 +570,7 @@ struct cli_state *cli_initialise_ex(int signing_state)
SAFE_FREE(cli->inbuf);
SAFE_FREE(cli->outbuf);
SAFE_FREE(cli);
TALLOC_FREE(cli);
return NULL;
}
@ -550,6 +599,27 @@ void cli_nt_pipes_close(struct cli_state *cli)
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);
/*

View File

@ -244,7 +244,6 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
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);
@ -457,8 +456,6 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
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;
@ -479,7 +476,7 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
info_level));
break;
}
fn(mnt,&finfo, Mask, state);
fn(cli->dfs_mountpoint, &finfo, Mask, state);
}
}

View File

@ -930,11 +930,8 @@ struct cli_push_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;
@ -966,21 +963,13 @@ static bool cli_push_write_setup(struct async_req *req,
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;
@ -1013,9 +1002,7 @@ struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
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)
{
@ -1032,7 +1019,6 @@ struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
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;
@ -1122,10 +1108,7 @@ 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)
{
TALLOC_CTX *frame = talloc_stackframe();
@ -1146,7 +1129,7 @@ NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
}
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;
}

View File

@ -112,9 +112,6 @@ bool cli_send_trans(struct cli_state *cli, int trans,
this_lparam = MIN(lparam-tot_param,cli->max_xmit - 500); /* hack */
this_ldata = MIN(ldata-tot_data,cli->max_xmit - (500+this_lparam));
client_set_trans_sign_state_off(cli, mid);
client_set_trans_sign_state_on(cli, mid);
cli_set_message(cli->outbuf,trans==SMBtrans?8:9,0,True);
SCVAL(cli->outbuf,smb_com,(trans==SMBtrans ? SMBtranss : SMBtranss2));
@ -138,20 +135,14 @@ bool cli_send_trans(struct cli_state *cli, int trans,
memcpy(outdata,data+tot_data,this_ldata);
cli_setup_bcc(cli, outdata+this_ldata);
/*
* Save the mid we're using. We need this for finding
* signing replies.
*/
mid = cli->mid;
show_msg(cli->outbuf);
client_set_trans_sign_state_off(cli, mid);
cli->mid = mid;
if (!cli_send_smb(cli)) {
client_set_trans_sign_state_off(cli, mid);
return False;
}
/* Ensure we use the same mid for the secondaries. */
cli->mid = mid;
client_set_trans_sign_state_on(cli, mid);
tot_data += this_ldata;
tot_param += this_lparam;
@ -461,21 +452,14 @@ bool cli_send_nt_trans(struct cli_state *cli,
memcpy(outdata,data+tot_data,this_ldata);
cli_setup_bcc(cli, outdata+this_ldata);
/*
* Save the mid we're using. We need this for finding
* signing replies.
*/
mid = cli->mid;
show_msg(cli->outbuf);
client_set_trans_sign_state_off(cli, mid);
cli->mid = mid;
if (!cli_send_smb(cli)) {
client_set_trans_sign_state_off(cli, mid);
return False;
}
/* Ensure we use the same mid for the secondaries. */
cli->mid = mid;
client_set_trans_sign_state_on(cli, mid);
tot_data += this_ldata;
tot_param += this_lparam;
@ -747,6 +731,7 @@ static struct async_req *cli_ship_trans(TALLOC_CTX *mem_ctx,
uint16_t this_data = 0;
uint32_t useable_space;
uint8_t cmd;
uint8_t pad[3];
frame = talloc_stackframe();
@ -759,9 +744,16 @@ static struct async_req *cli_ship_trans(TALLOC_CTX *mem_ctx,
param_offset = smb_size - 4;
bytes = TALLOC_ARRAY(talloc_tos(), uint8_t, 0); /* padding */
if (bytes == NULL) {
goto fail;
}
switch (cmd) {
case SMBtrans:
bytes = TALLOC_ZERO_P(talloc_tos(), uint8_t); /* padding */
pad[0] = 0;
bytes = (uint8_t *)talloc_append_blob(talloc_tos(), bytes,
data_blob_const(pad, 1));
if (bytes == NULL) {
goto fail;
}
@ -775,13 +767,14 @@ static struct async_req *cli_ship_trans(TALLOC_CTX *mem_ctx,
param_offset += talloc_get_size(bytes);
break;
case SMBtrans2:
bytes = TALLOC_ARRAY(talloc_tos(), uint8_t, 3); /* padding */
pad[0] = 0;
pad[1] = 'D'; /* Copy this from "old" 3.0 behaviour */
pad[2] = ' ';
bytes = (uint8_t *)talloc_append_blob(talloc_tos(), bytes,
data_blob_const(pad, 3));
if (bytes == NULL) {
goto fail;
}
bytes[0] = 0;
bytes[1] = 'D'; /* Copy this from "old" 3.0 behaviour */
bytes[2] = ' ';
wct = 14 + state->num_setup;
param_offset += talloc_get_size(bytes);
break;

Some files were not shown because too many files have changed in this diff Show More