Merge branch 'master' of ssh://git.samba.org/data/git/samba
authorJelmer Vernooij <jelmer@samba.org>
Wed, 25 Feb 2009 14:22:31 +0000 (15:22 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 25 Feb 2009 14:22:31 +0000 (15:22 +0100)
16 files changed:
lib/async_req/async_sock.c
lib/async_req/async_sock.h
lib/tevent/tevent.h
lib/tevent/tevent_req.c
librpc/gen_ndr/ndr_spoolss.c
librpc/gen_ndr/ndr_spoolss.h
librpc/gen_ndr/spoolss.h
librpc/idl/spoolss.idl
source3/include/proto.h
source3/lib/events.c
source3/passdb/pdb_wbc_sam.c
source3/rpc_client/cli_spoolss.c
source3/rpc_client/rpc_transport_sock.c
source3/rpcclient/cmd_samr.c
source3/rpcclient/cmd_spoolss.c
source4/lib/events/tevent_s4.c

index 3563421e0e56c62363ab752e55db3ea788db2136..40e7bca4c86da183de29bb3fce494615fac18b29 100644 (file)
 #define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
 #endif
 
-/**
- * Discriminator for async_syscall_state
- */
-enum async_syscall_type {
-       ASYNC_SYSCALL_SEND,
-       ASYNC_SYSCALL_RECV,
-};
-
-/**
- * Holder for syscall arguments and the result
- */
-
-struct async_syscall_state {
-       enum async_syscall_type syscall_type;
-       struct tevent_fd *fde;
-
-       union {
-               struct param_send {
-                       int fd;
-                       const void *buffer;
-                       size_t length;
-                       int flags;
-               } param_send;
-               struct param_recv {
-                       int fd;
-                       void *buffer;
-                       size_t length;
-                       int flags;
-               } param_recv;
-       } param;
-
-       union {
-               ssize_t result_ssize_t;
-               size_t result_size_t;
-               int result_int;
-       } result;
-       int sys_errno;
-};
-
 /**
  * @brief Map async_req states to unix-style errnos
  * @param[in]  req     The async req to get the state from
@@ -117,267 +78,6 @@ int async_req_simple_recv_errno(struct async_req *req)
        return 0;
 }
 
-/**
- * @brief Create a new async syscall req
- * @param[in] mem_ctx  The memory context to hang the result off
- * @param[in] ev       The event context to work from
- * @param[in] type     Which syscall will this be
- * @param[in] pstate   Where to put the newly created private_data state
- * @retval The new request
- *
- * This is a helper function to prepare a new struct async_req with an
- * associated struct async_syscall_state. The async_syscall_state will be put
- * into the async_req as private_data.
- */
-
-static struct async_req *async_syscall_new(TALLOC_CTX *mem_ctx,
-                                          struct tevent_context *ev,
-                                          enum async_syscall_type type,
-                                          struct async_syscall_state **pstate)
-{
-       struct async_req *result;
-       struct async_syscall_state *state;
-
-       if (!async_req_setup(mem_ctx, &result, &state,
-                            struct async_syscall_state)) {
-               return NULL;
-       }
-       state->syscall_type = type;
-
-       result->private_data = state;
-
-       *pstate = state;
-
-       return result;
-}
-
-/**
- * @brief Create a new async syscall req based on a fd
- * @param[in] mem_ctx  The memory context to hang the result off
- * @param[in] ev       The event context to work from
- * @param[in] type     Which syscall will this be
- * @param[in] fd       The file descriptor we work on
- * @param[in] fde_flags TEVENT_FD_READ/WRITE -- what are we interested in?
- * @param[in] fde_cb   The callback function for the file descriptor event
- * @param[in] pstate   Where to put the newly created private_data state
- * @retval The new request
- *
- * This is a helper function to prepare a new struct async_req with an
- * associated struct async_syscall_state and an associated file descriptor
- * event.
- */
-
-static struct async_req *async_fde_syscall_new(
-       TALLOC_CTX *mem_ctx,
-       struct tevent_context *ev,
-       enum async_syscall_type type,
-       int fd,
-       uint16_t fde_flags,
-       void (*fde_cb)(struct tevent_context *ev,
-                      struct tevent_fd *fde, uint16_t flags,
-                      void *priv),
-       struct async_syscall_state **pstate)
-{
-       struct async_req *result;
-       struct async_syscall_state *state;
-
-       result = async_syscall_new(mem_ctx, ev, type, &state);
-       if (result == NULL) {
-               return NULL;
-       }
-
-       state->fde = tevent_add_fd(ev, state, fd, fde_flags, fde_cb, result);
-       if (state->fde == NULL) {
-               TALLOC_FREE(result);
-               return NULL;
-       }
-       *pstate = state;
-       return result;
-}
-
-/**
- * Retrieve a ssize_t typed result from an async syscall
- * @param[in] req      The syscall that has just finished
- * @param[out] perrno  Where to put the syscall's errno
- * @retval The return value from the asynchronously called syscall
- */
-
-ssize_t async_syscall_result_ssize_t(struct async_req *req, int *perrno)
-{
-       struct async_syscall_state *state = talloc_get_type_abort(
-               req->private_data, struct async_syscall_state);
-
-       *perrno = state->sys_errno;
-       return state->result.result_ssize_t;
-}
-
-/**
- * Retrieve a size_t typed result from an async syscall
- * @param[in] req      The syscall that has just finished
- * @param[out] perrno  Where to put the syscall's errno
- * @retval The return value from the asynchronously called syscall
- */
-
-size_t async_syscall_result_size_t(struct async_req *req, int *perrno)
-{
-       struct async_syscall_state *state = talloc_get_type_abort(
-               req->private_data, struct async_syscall_state);
-
-       *perrno = state->sys_errno;
-       return state->result.result_size_t;
-}
-
-/**
- * Retrieve a int typed result from an async syscall
- * @param[in] req      The syscall that has just finished
- * @param[out] perrno  Where to put the syscall's errno
- * @retval The return value from the asynchronously called syscall
- */
-
-int async_syscall_result_int(struct async_req *req, int *perrno)
-{
-       struct async_syscall_state *state = talloc_get_type_abort(
-               req->private_data, struct async_syscall_state);
-
-       *perrno = state->sys_errno;
-       return state->result.result_int;
-}
-
-/**
- * fde event handler for the "send" syscall
- * @param[in] ev       The event context that sent us here
- * @param[in] fde      The file descriptor event associated with the send
- * @param[in] flags    Can only be TEVENT_FD_WRITE here
- * @param[in] priv     private data, "struct async_req *" in this case
- */
-
-static void async_send_callback(struct tevent_context *ev,
-                               struct tevent_fd *fde, uint16_t flags,
-                               void *priv)
-{
-       struct async_req *req = talloc_get_type_abort(
-               priv, struct async_req);
-       struct async_syscall_state *state = talloc_get_type_abort(
-               req->private_data, struct async_syscall_state);
-       struct param_send *p = &state->param.param_send;
-
-       if (state->syscall_type != ASYNC_SYSCALL_SEND) {
-               async_req_error(req, EIO);
-               return;
-       }
-
-       state->result.result_ssize_t = send(p->fd, p->buffer, p->length,
-                                           p->flags);
-       state->sys_errno = errno;
-
-       TALLOC_FREE(state->fde);
-
-       async_req_done(req);
-}
-
-/**
- * Async version of send(2)
- * @param[in] mem_ctx  The memory context to hang the result off
- * @param[in] ev       The event context to work from
- * @param[in] fd       The socket to send to
- * @param[in] buffer   The buffer to send
- * @param[in] length   How many bytes to send
- * @param[in] flags    flags passed to send(2)
- *
- * This function is a direct counterpart of send(2)
- */
-
-struct async_req *async_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-                            int fd, const void *buffer, size_t length,
-                            int flags)
-{
-       struct async_req *result;
-       struct async_syscall_state *state;
-
-       result = async_fde_syscall_new(
-               mem_ctx, ev, ASYNC_SYSCALL_SEND,
-               fd, TEVENT_FD_WRITE, async_send_callback,
-               &state);
-       if (result == NULL) {
-               return NULL;
-       }
-
-       state->param.param_send.fd = fd;
-       state->param.param_send.buffer = buffer;
-       state->param.param_send.length = length;
-       state->param.param_send.flags = flags;
-
-       return result;
-}
-
-/**
- * fde event handler for the "recv" syscall
- * @param[in] ev       The event context that sent us here
- * @param[in] fde      The file descriptor event associated with the recv
- * @param[in] flags    Can only be TEVENT_FD_READ here
- * @param[in] priv     private data, "struct async_req *" in this case
- */
-
-static void async_recv_callback(struct tevent_context *ev,
-                               struct tevent_fd *fde, uint16_t flags,
-                               void *priv)
-{
-       struct async_req *req = talloc_get_type_abort(
-               priv, struct async_req);
-       struct async_syscall_state *state = talloc_get_type_abort(
-               req->private_data, struct async_syscall_state);
-       struct param_recv *p = &state->param.param_recv;
-
-       if (state->syscall_type != ASYNC_SYSCALL_RECV) {
-               async_req_error(req, EIO);
-               return;
-       }
-
-       state->result.result_ssize_t = recv(p->fd, p->buffer, p->length,
-                                           p->flags);
-       state->sys_errno = errno;
-
-       TALLOC_FREE(state->fde);
-
-       async_req_done(req);
-}
-
-/**
- * Async version of recv(2)
- * @param[in] mem_ctx  The memory context to hang the result off
- * @param[in] ev       The event context to work from
- * @param[in] fd       The socket to recv from
- * @param[in] buffer   The buffer to recv into
- * @param[in] length   How many bytes to recv
- * @param[in] flags    flags passed to recv(2)
- *
- * This function is a direct counterpart of recv(2)
- */
-
-struct async_req *async_recv(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-                            int fd, void *buffer, size_t length,
-                            int flags)
-{
-       struct async_req *result;
-       struct async_syscall_state *state;
-
-       result = async_fde_syscall_new(
-               mem_ctx, ev, ASYNC_SYSCALL_RECV,
-               fd, TEVENT_FD_READ, async_recv_callback,
-               &state);
-
-       if (result == NULL) {
-               return NULL;
-       }
-
-       state->param.param_recv.fd = fd;
-       state->param.param_recv.buffer = buffer;
-       state->param.param_recv.length = length;
-       state->param.param_recv.flags = flags;
-
-       return result;
-}
-
 struct async_send_state {
        int fd;
        const void *buf;
index bfc4346d39a03b52753efdcb52429c167da596eb..e001709d2783b4f5696875e208bab330bc55fb9f 100644 (file)
 bool async_req_is_errno(struct async_req *req, int *err);
 int async_req_simple_recv_errno(struct async_req *req);
 
-ssize_t async_syscall_result_ssize_t(struct async_req *req, int *perrno);
-size_t async_syscall_result_size_t(struct async_req *req, int *perrno);
-int async_syscall_result_int(struct async_req *req, int *perrno);
-
-struct async_req *async_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-                            int fd, const void *buffer, size_t length,
-                            int flags);
-struct async_req *async_recv(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-                            int fd, void *buffer, size_t length,
-                            int flags);
-
 struct tevent_req *async_send_send(TALLOC_CTX *mem_ctx,
                                   struct tevent_context *ev,
                                   int fd, const void *buf, size_t len,
index b3d1c6d59a52d8903cab44ea48c6c9690e6ba185..185a8fa193e3f2d47dea546f43c01a507a271c94 100644 (file)
@@ -211,6 +211,15 @@ struct tevent_req {
         */
        void *private_state;
 
+       /**
+        * @brief A function to overwrite the default print function
+        *
+        * The implementation doing the work may want to imeplement a
+        * custom function to print the text representation of the async
+        * request.
+        */
+       char *(*private_print)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
+
        /**
         * @brief Internal state of the request
         *
@@ -267,6 +276,8 @@ struct tevent_req {
        } internal;
 };
 
+char *tevent_req_default_print(struct tevent_req *req, TALLOC_CTX *mem_ctx);
+
 char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req);
 
 struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
@@ -296,6 +307,9 @@ struct tevent_req *tevent_req_post(struct tevent_req *req,
 
 bool tevent_req_is_in_progress(struct tevent_req *req);
 
+bool tevent_req_poll(struct tevent_req *req,
+                    struct tevent_context *ev);
+
 bool tevent_req_is_error(struct tevent_req *req,
                         enum tevent_req_state *state,
                         uint64_t *error);
index 800e3855d1985ba0aa34ce13a5b202016590842c..e243c7de5de3d4787bf4a3a962be9022dfe5c42c 100644 (file)
 #include "tevent_util.h"
 
 /**
- * @brief Print an tevent_req structure in debug messages
- * @param[in] mem_ctx  The memory context for the result
+ * @brief The default print function for creating debug messages
  * @param[in] req      The request to be printed
+ * @param[in] mem_ctx  The memory context for the result
  * @retval             Text representation of req
  *
+ * The function should not be used by users of the asynx API,
+ * but custom print function can use it and append custom text
+ * to the string.
  */
 
-char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req)
+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)] "
@@ -50,6 +53,24 @@ char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req)
                               );
 }
 
+/**
+ * @brief Print an tevent_req structure in debug messages
+ * @param[in] mem_ctx  The memory context for the result
+ * @param[in] req      The request to be printed
+ * @retval             Text representation of req
+ *
+ * This function should be used by callers of the async API
+ */
+
+char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req)
+{
+       if (!req->private_print) {
+               return tevent_req_default_print(req, mem_ctx);
+       }
+
+       return req->private_print(req, mem_ctx);
+}
+
 /**
  * @brief Create an async request
  * @param[in] mem_ctx  The memory context for the result
@@ -235,6 +256,21 @@ bool tevent_req_is_in_progress(struct tevent_req *req)
        return false;
 }
 
+bool tevent_req_poll(struct tevent_req *req,
+                    struct tevent_context *ev)
+{
+       while (tevent_req_is_in_progress(req)) {
+               int ret;
+
+               ret = tevent_loop_once(ev);
+               if (ret != 0) {
+                       return false;
+               }
+       }
+
+       return true;
+}
+
 bool tevent_req_is_error(struct tevent_req *req, enum tevent_req_state *state,
                        uint64_t *error)
 {
index fdafa2582b5bde60de8fb65cd45fb8ae405e5a96..25c9dc49d7499fe9a09cec09dae5110361b2097e 100644 (file)
@@ -12232,6 +12232,275 @@ _PUBLIC_ void ndr_print_spoolss_FormInfo1(struct ndr_print *ndr, const char *nam
        ndr->depth--;
 }
 
+static enum ndr_err_code ndr_push_spoolss_FormStringType(struct ndr_push *ndr, int ndr_flags, uint32_t r)
+{
+       NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
+       return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_FormStringType(struct ndr_pull *ndr, int ndr_flags, uint32_t *r)
+{
+       uint32_t v;
+       NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
+       *r = v;
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_FormStringType(struct ndr_print *ndr, const char *name, uint32_t r)
+{
+       ndr_print_uint32(ndr, name, r);
+       ndr->depth++;
+       ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SPOOLSS_FORM_STRING_TYPE_NONE", SPOOLSS_FORM_STRING_TYPE_NONE, r);
+       ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SPOOLSS_FORM_STRING_TYPE_MUI_DLL", SPOOLSS_FORM_STRING_TYPE_MUI_DLL, r);
+       ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SPOOLSS_FORM_STRING_TYPE_LANG_PAIR", SPOOLSS_FORM_STRING_TYPE_LANG_PAIR, r);
+       ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_spoolss_FormInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_FormInfo2 *r)
+{
+       if (ndr_flags & NDR_SCALARS) {
+               NDR_CHECK(ndr_push_align(ndr, 4));
+               NDR_CHECK(ndr_push_spoolss_FormFlags(ndr, NDR_SCALARS, r->flags));
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       NDR_CHECK(ndr_push_relative_ptr1(ndr, r->form_name));
+                       ndr->flags = _flags_save_string;
+               }
+               NDR_CHECK(ndr_push_spoolss_FormSize(ndr, NDR_SCALARS, &r->size));
+               NDR_CHECK(ndr_push_spoolss_FormArea(ndr, NDR_SCALARS, &r->area));
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       NDR_CHECK(ndr_push_relative_ptr1(ndr, r->keyword));
+                       ndr->flags = _flags_save_string;
+               }
+               NDR_CHECK(ndr_push_spoolss_FormStringType(ndr, NDR_SCALARS, r->string_type));
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       NDR_CHECK(ndr_push_relative_ptr1(ndr, r->mui_dll));
+                       ndr->flags = _flags_save_string;
+               }
+               NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->ressource_id));
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       NDR_CHECK(ndr_push_relative_ptr1(ndr, r->display_name));
+                       ndr->flags = _flags_save_string;
+               }
+               NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->lang_id));
+       }
+       if (ndr_flags & NDR_BUFFERS) {
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       if (r->form_name) {
+                               NDR_CHECK(ndr_push_relative_ptr2(ndr, r->form_name));
+                               NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->form_name));
+                       }
+                       ndr->flags = _flags_save_string;
+               }
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       if (r->keyword) {
+                               NDR_CHECK(ndr_push_relative_ptr2(ndr, r->keyword));
+                               NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->keyword));
+                       }
+                       ndr->flags = _flags_save_string;
+               }
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       if (r->mui_dll) {
+                               NDR_CHECK(ndr_push_relative_ptr2(ndr, r->mui_dll));
+                               NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->mui_dll));
+                       }
+                       ndr->flags = _flags_save_string;
+               }
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       if (r->display_name) {
+                               NDR_CHECK(ndr_push_relative_ptr2(ndr, r->display_name));
+                               NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->display_name));
+                       }
+                       ndr->flags = _flags_save_string;
+               }
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_FormInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_FormInfo2 *r)
+{
+       uint32_t _ptr_form_name;
+       TALLOC_CTX *_mem_save_form_name_0;
+       uint32_t _ptr_keyword;
+       TALLOC_CTX *_mem_save_keyword_0;
+       uint32_t _ptr_mui_dll;
+       TALLOC_CTX *_mem_save_mui_dll_0;
+       uint32_t _ptr_display_name;
+       TALLOC_CTX *_mem_save_display_name_0;
+       if (ndr_flags & NDR_SCALARS) {
+               NDR_CHECK(ndr_pull_align(ndr, 4));
+               NDR_CHECK(ndr_pull_spoolss_FormFlags(ndr, NDR_SCALARS, &r->flags));
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_form_name));
+                       if (_ptr_form_name) {
+                               NDR_PULL_ALLOC(ndr, r->form_name);
+                               NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->form_name, _ptr_form_name));
+                       } else {
+                               r->form_name = NULL;
+                       }
+                       ndr->flags = _flags_save_string;
+               }
+               NDR_CHECK(ndr_pull_spoolss_FormSize(ndr, NDR_SCALARS, &r->size));
+               NDR_CHECK(ndr_pull_spoolss_FormArea(ndr, NDR_SCALARS, &r->area));
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_keyword));
+                       if (_ptr_keyword) {
+                               NDR_PULL_ALLOC(ndr, r->keyword);
+                               NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->keyword, _ptr_keyword));
+                       } else {
+                               r->keyword = NULL;
+                       }
+                       ndr->flags = _flags_save_string;
+               }
+               NDR_CHECK(ndr_pull_spoolss_FormStringType(ndr, NDR_SCALARS, &r->string_type));
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_mui_dll));
+                       if (_ptr_mui_dll) {
+                               NDR_PULL_ALLOC(ndr, r->mui_dll);
+                               NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->mui_dll, _ptr_mui_dll));
+                       } else {
+                               r->mui_dll = NULL;
+                       }
+                       ndr->flags = _flags_save_string;
+               }
+               NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ressource_id));
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_display_name));
+                       if (_ptr_display_name) {
+                               NDR_PULL_ALLOC(ndr, r->display_name);
+                               NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->display_name, _ptr_display_name));
+                       } else {
+                               r->display_name = NULL;
+                       }
+                       ndr->flags = _flags_save_string;
+               }
+               NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->lang_id));
+       }
+       if (ndr_flags & NDR_BUFFERS) {
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       if (r->form_name) {
+                               uint32_t _relative_save_offset;
+                               _relative_save_offset = ndr->offset;
+                               NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->form_name));
+                               _mem_save_form_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+                               NDR_PULL_SET_MEM_CTX(ndr, r->form_name, 0);
+                               NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->form_name));
+                               NDR_PULL_SET_MEM_CTX(ndr, _mem_save_form_name_0, 0);
+                               ndr->offset = _relative_save_offset;
+                       }
+                       ndr->flags = _flags_save_string;
+               }
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       if (r->keyword) {
+                               uint32_t _relative_save_offset;
+                               _relative_save_offset = ndr->offset;
+                               NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->keyword));
+                               _mem_save_keyword_0 = NDR_PULL_GET_MEM_CTX(ndr);
+                               NDR_PULL_SET_MEM_CTX(ndr, r->keyword, 0);
+                               NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->keyword));
+                               NDR_PULL_SET_MEM_CTX(ndr, _mem_save_keyword_0, 0);
+                               ndr->offset = _relative_save_offset;
+                       }
+                       ndr->flags = _flags_save_string;
+               }
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       if (r->mui_dll) {
+                               uint32_t _relative_save_offset;
+                               _relative_save_offset = ndr->offset;
+                               NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->mui_dll));
+                               _mem_save_mui_dll_0 = NDR_PULL_GET_MEM_CTX(ndr);
+                               NDR_PULL_SET_MEM_CTX(ndr, r->mui_dll, 0);
+                               NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->mui_dll));
+                               NDR_PULL_SET_MEM_CTX(ndr, _mem_save_mui_dll_0, 0);
+                               ndr->offset = _relative_save_offset;
+                       }
+                       ndr->flags = _flags_save_string;
+               }
+               {
+                       uint32_t _flags_save_string = ndr->flags;
+                       ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+                       if (r->display_name) {
+                               uint32_t _relative_save_offset;
+                               _relative_save_offset = ndr->offset;
+                               NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->display_name));
+                               _mem_save_display_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+                               NDR_PULL_SET_MEM_CTX(ndr, r->display_name, 0);
+                               NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->display_name));
+                               NDR_PULL_SET_MEM_CTX(ndr, _mem_save_display_name_0, 0);
+                               ndr->offset = _relative_save_offset;
+                       }
+                       ndr->flags = _flags_save_string;
+               }
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_FormInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_FormInfo2 *r)
+{
+       ndr_print_struct(ndr, name, "spoolss_FormInfo2");
+       ndr->depth++;
+       ndr_print_spoolss_FormFlags(ndr, "flags", r->flags);
+       ndr_print_ptr(ndr, "form_name", r->form_name);
+       ndr->depth++;
+       if (r->form_name) {
+               ndr_print_string(ndr, "form_name", r->form_name);
+       }
+       ndr->depth--;
+       ndr_print_spoolss_FormSize(ndr, "size", &r->size);
+       ndr_print_spoolss_FormArea(ndr, "area", &r->area);
+       ndr_print_ptr(ndr, "keyword", r->keyword);
+       ndr->depth++;
+       if (r->keyword) {
+               ndr_print_string(ndr, "keyword", r->keyword);
+       }
+       ndr->depth--;
+       ndr_print_spoolss_FormStringType(ndr, "string_type", r->string_type);
+       ndr_print_ptr(ndr, "mui_dll", r->mui_dll);
+       ndr->depth++;
+       if (r->mui_dll) {
+               ndr_print_string(ndr, "mui_dll", r->mui_dll);
+       }
+       ndr->depth--;
+       ndr_print_uint32(ndr, "ressource_id", r->ressource_id);
+       ndr_print_ptr(ndr, "display_name", r->display_name);
+       ndr->depth++;
+       if (r->display_name) {
+               ndr_print_string(ndr, "display_name", r->display_name);
+       }
+       ndr->depth--;
+       ndr_print_uint32(ndr, "lang_id", r->lang_id);
+       ndr->depth--;
+}
+
 _PUBLIC_ enum ndr_err_code ndr_push_spoolss_FormInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_FormInfo *r)
 {
        uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr);
@@ -12244,6 +12513,12 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_FormInfo(struct ndr_push *ndr, int n
                                NDR_CHECK(ndr_push_spoolss_FormInfo1(ndr, NDR_SCALARS, &r->info1));
                        break; }
 
+                       case 2: {
+                               NDR_CHECK(ndr_push_align(ndr, 4));
+                               NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset));
+                               NDR_CHECK(ndr_push_spoolss_FormInfo2(ndr, NDR_SCALARS, &r->info2));
+                       break; }
+
                        default: {
                        break; }
 
@@ -12257,6 +12532,10 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_FormInfo(struct ndr_push *ndr, int n
                                NDR_CHECK(ndr_push_spoolss_FormInfo1(ndr, NDR_BUFFERS, &r->info1));
                        break;
 
+                       case 2:
+                               NDR_CHECK(ndr_push_spoolss_FormInfo2(ndr, NDR_BUFFERS, &r->info2));
+                       break;
+
                        default:
                        break;
 
@@ -12279,6 +12558,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_FormInfo(struct ndr_pull *ndr, int n
                                NDR_CHECK(ndr_pull_spoolss_FormInfo1(ndr, NDR_SCALARS, &r->info1));
                        break; }
 
+                       case 2: {
+                               NDR_CHECK(ndr_pull_align(ndr, 4));
+                               NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset));
+                               NDR_CHECK(ndr_pull_spoolss_FormInfo2(ndr, NDR_SCALARS, &r->info2));
+                       break; }
+
                        default: {
                        break; }
 
@@ -12291,6 +12576,10 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_FormInfo(struct ndr_pull *ndr, int n
                                NDR_CHECK(ndr_pull_spoolss_FormInfo1(ndr, NDR_BUFFERS, &r->info1));
                        break;
 
+                       case 2:
+                               NDR_CHECK(ndr_pull_spoolss_FormInfo2(ndr, NDR_BUFFERS, &r->info2));
+                       break;
+
                        default:
                        break;
 
@@ -12310,6 +12599,10 @@ _PUBLIC_ void ndr_print_spoolss_FormInfo(struct ndr_print *ndr, const char *name
                        ndr_print_spoolss_FormInfo1(ndr, "info1", &r->info1);
                break;
 
+               case 2:
+                       ndr_print_spoolss_FormInfo2(ndr, "info2", &r->info2);
+               break;
+
                default:
                break;
 
index 5b32d510c089a9b8166ad5895e44d47ff3b750ed..5ecadc04d6ab02193a38164ebec4257d70d5528f 100644 (file)
@@ -344,6 +344,8 @@ void ndr_print_spoolss_FormFlags(struct ndr_print *ndr, const char *name, enum s
 void ndr_print_spoolss_FormSize(struct ndr_print *ndr, const char *name, const struct spoolss_FormSize *r);
 void ndr_print_spoolss_FormArea(struct ndr_print *ndr, const char *name, const struct spoolss_FormArea *r);
 void ndr_print_spoolss_FormInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_FormInfo1 *r);
+void ndr_print_spoolss_FormStringType(struct ndr_print *ndr, const char *name, uint32_t r);
+void ndr_print_spoolss_FormInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_FormInfo2 *r);
 enum ndr_err_code ndr_push_spoolss_FormInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_FormInfo *r);
 enum ndr_err_code ndr_pull_spoolss_FormInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_FormInfo *r);
 void ndr_print_spoolss_FormInfo(struct ndr_print *ndr, const char *name, const union spoolss_FormInfo *r);
index c960d5439bc25338619e4cd49460748af7794f38..4ecb2a71b60e712197698f3ef662b57d54c05c89 100644 (file)
@@ -960,8 +960,27 @@ struct spoolss_FormInfo1 {
        struct spoolss_FormArea area;
 };
 
+/* bitmap spoolss_FormStringType */
+#define SPOOLSS_FORM_STRING_TYPE_NONE ( 0x00000001 )
+#define SPOOLSS_FORM_STRING_TYPE_MUI_DLL ( 0x00000002 )
+#define SPOOLSS_FORM_STRING_TYPE_LANG_PAIR ( 0x00000004 )
+
+struct spoolss_FormInfo2 {
+       enum spoolss_FormFlags flags;
+       const char * form_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+       struct spoolss_FormSize size;
+       struct spoolss_FormArea area;
+       const char * keyword;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+       uint32_t string_type;
+       const char * mui_dll;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+       uint32_t ressource_id;
+       const char * display_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+       uint32_t lang_id;
+};
+
 union spoolss_FormInfo {
        struct spoolss_FormInfo1 info1;/* [case] */
+       struct spoolss_FormInfo2 info2;/* [case(2)] */
 }/* [relative_base,gensize,public,nodiscriminant] */;
 
 struct spoolss_AddFormInfo1 {
index 3e35399f8d9cd614945c6f8894bb4466ea51e5c3..5359fdf4a2dc8bafc72f7449fd78025737bd2103 100644 (file)
@@ -1237,8 +1237,28 @@ import "misc.idl", "security.idl", "winreg.idl";
                spoolss_FormArea area;
        } spoolss_FormInfo1;
 
+       typedef [bitmap32bit] bitmap {
+               SPOOLSS_FORM_STRING_TYPE_NONE           = 0x00000001,
+               SPOOLSS_FORM_STRING_TYPE_MUI_DLL        = 0x00000002,
+               SPOOLSS_FORM_STRING_TYPE_LANG_PAIR      = 0x00000004
+       } spoolss_FormStringType;
+
+       typedef struct {
+               spoolss_FormFlags flags;
+               [relative] nstring *form_name;
+               spoolss_FormSize size;
+               spoolss_FormArea area;
+               [relative] nstring *keyword;
+               spoolss_FormStringType string_type;
+               [relative] nstring *mui_dll;
+               uint32 ressource_id;
+               [relative] nstring *display_name;
+               uint32 lang_id;
+       } spoolss_FormInfo2;
+
        typedef [nodiscriminant,relative_base,public,gensize] union {
                [case(1)] spoolss_FormInfo1 info1;
+               [case(2)] spoolss_FormInfo2 info2;
                [default];
        } spoolss_FormInfo;
 
index 808411114513c945db9a74a80a8c4c4234ed44c4..2d92b0fc908837c521024448e08b52dcef958d19 100644 (file)
@@ -4693,6 +4693,10 @@ NTSTATUS pdb_nds_init(void);
 
 NTSTATUS pdb_smbpasswd_init(void) ;
 
+/* The following definitions come from passdb/pdb_wbc_sam.c  */
+
+NTSTATUS pdb_wbc_sam_init(void);
+
 /* The following definitions come from passdb/pdb_tdb.c  */
 
 bool init_sam_from_buffer_v2(struct samu *sampass, uint8 *buf, uint32 buflen);
index 44b45627577044be7faabacaed11a0315db23305..9e81a4779611c01ba6fc66582ae919189b50b703 100644 (file)
@@ -282,7 +282,7 @@ static void s3_event_debug(void *context, enum tevent_debug_level level,
                samba_level = 2;
                break;
        case TEVENT_DEBUG_TRACE:
-               samba_level = 5;
+               samba_level = 10;
                break;
 
        };
index 33dc03fe4cd787a2620abce7cd2970f849a984de..d2c7fda2936c8d0451392de49eeec619a20c1751 100644 (file)
@@ -115,10 +115,12 @@ static NTSTATUS pdb_wbc_sam_enum_group_memberships(struct pdb_methods *methods,
 {
        size_t i;
        const char *username = pdb_get_username(user);
+       uint32_t num_groups;
 
-       if (!winbind_get_groups(mem_ctx, username, p_num_groups, pp_gids)) {
+       if (!winbind_get_groups(mem_ctx, username, &num_groups, pp_gids)) {
                return NT_STATUS_NO_SUCH_USER;
        }
+       *p_num_groups = num_groups;
 
        if (*p_num_groups == 0) {
                smb_panic("primary group missing");
index c9d23efdf26513816666546fbaacc94b97b0506f..4c1d57e063f85253b10bbfd5587ed396c9df0023 100644 (file)
@@ -359,38 +359,6 @@ static bool decode_printer_info_3(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
        return True;
 }
 
-/**********************************************************************
-**********************************************************************/
-
-static bool decode_printer_info_7(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
-                               uint32 returned, PRINTER_INFO_7 **info)
-{
-       uint32 i;
-       PRINTER_INFO_7  *inf;
-
-       if (returned) {
-               inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_7, returned);
-               if (!inf) {
-                       return False;
-               }
-               memset(inf, 0, returned*sizeof(PRINTER_INFO_7));
-       } else {
-               inf = NULL;
-       }
-
-       prs_set_offset(&buffer->prs,0);
-
-       for (i=0; i<returned; i++) {
-               if (!smb_io_printer_info_7("", buffer, &inf[i], 0)) {
-                       return False;
-               }
-       }
-
-       *info=inf;
-       return True;
-}
-
-
 /**********************************************************************
 **********************************************************************/
 
index c0fa41b0de0427860495a0af600f5c4af6e3cd83..658ffe30d6d5e54a9951ac8cbf232373b1c968ac 100644 (file)
@@ -35,6 +35,12 @@ static int rpc_transport_sock_state_destructor(struct rpc_transport_sock_state *
        return 0;
 }
 
+struct rpc_sock_read_state {
+       ssize_t received;
+};
+
+static void rpc_sock_read_done(struct tevent_req *subreq);
+
 static struct async_req *rpc_sock_read_send(TALLOC_CTX *mem_ctx,
                                            struct event_context *ev,
                                            uint8_t *data, size_t size,
@@ -42,25 +48,62 @@ static struct async_req *rpc_sock_read_send(TALLOC_CTX *mem_ctx,
 {
        struct rpc_transport_sock_state *sock_transp = talloc_get_type_abort(
                priv, struct rpc_transport_sock_state);
-       return async_recv(mem_ctx, ev, sock_transp->fd, data, size, 0);
+       struct async_req *result;
+       struct tevent_req *subreq;
+       struct rpc_sock_read_state *state;
+
+       if (!async_req_setup(mem_ctx, &result, &state,
+                            struct rpc_sock_read_state)) {
+               return NULL;
+       }
+
+       subreq = async_recv_send(state, ev, sock_transp->fd, data, size, 0);
+       if (subreq == NULL) {
+               goto fail;
+       }
+       subreq->async.fn = rpc_sock_read_done;
+       subreq->async.private_data = result;
+       return result;
+ fail:
+       TALLOC_FREE(result);
+       return NULL;
 }
 
-static NTSTATUS rpc_sock_read_recv(struct async_req *req, ssize_t *preceived)
+static void rpc_sock_read_done(struct tevent_req *subreq)
 {
-       ssize_t received;
-       int sys_errno;
+       struct async_req *req = talloc_get_type_abort(
+               subreq->async.private_data, struct async_req);
+       struct rpc_sock_read_state *state = talloc_get_type_abort(
+               req->private_data, struct rpc_sock_read_state);
+       int err;
 
-       received = async_syscall_result_ssize_t(req, &sys_errno);
-       if (received == -1) {
-               return map_nt_error_from_unix(sys_errno);
+       state->received = async_recv_recv(subreq, &err);
+       if (state->received == -1) {
+               async_req_nterror(req, map_nt_error_from_unix(err));
+               return;
        }
-       if (received == 0) {
-               return NT_STATUS_END_OF_FILE;
+       async_req_done(req);
+}
+
+static NTSTATUS rpc_sock_read_recv(struct async_req *req, ssize_t *preceived)
+{
+       struct rpc_sock_read_state *state = talloc_get_type_abort(
+               req->private_data, struct rpc_sock_read_state);
+       NTSTATUS status;
+
+       if (async_req_is_nterror(req, &status)) {
+               return status;
        }
-       *preceived = received;
+       *preceived = state->received;
        return NT_STATUS_OK;
 }
 
+struct rpc_sock_write_state {
+       ssize_t sent;
+};
+
+static void rpc_sock_write_done(struct tevent_req *subreq);
+
 static struct async_req *rpc_sock_write_send(TALLOC_CTX *mem_ctx,
                                             struct event_context *ev,
                                             const uint8_t *data, size_t size,
@@ -68,19 +111,52 @@ static struct async_req *rpc_sock_write_send(TALLOC_CTX *mem_ctx,
 {
        struct rpc_transport_sock_state *sock_transp = talloc_get_type_abort(
                priv, struct rpc_transport_sock_state);
-       return async_send(mem_ctx, ev, sock_transp->fd, data, size, 0);
+       struct async_req *result;
+       struct tevent_req *subreq;
+       struct rpc_sock_write_state *state;
+
+       if (!async_req_setup(mem_ctx, &result, &state,
+                            struct rpc_sock_write_state)) {
+               return NULL;
+       }
+       subreq = async_send_send(state, ev, sock_transp->fd, data, size, 0);
+       if (subreq == NULL) {
+               goto fail;
+       }
+       subreq->async.fn = rpc_sock_write_done;
+       subreq->async.private_data = result;
+       return result;
+ fail:
+       TALLOC_FREE(result);
+       return NULL;
+}
+
+static void rpc_sock_write_done(struct tevent_req *subreq)
+{
+       struct async_req *req = talloc_get_type_abort(
+               subreq->async.private_data, struct async_req);
+       struct rpc_sock_write_state *state = talloc_get_type_abort(
+               req->private_data, struct rpc_sock_write_state);
+       int err;
+
+       state->sent = async_send_recv(subreq, &err);
+       if (state->sent == -1) {
+               async_req_nterror(req, map_nt_error_from_unix(err));
+               return;
+       }
+       async_req_done(req);
 }
 
 static NTSTATUS rpc_sock_write_recv(struct async_req *req, ssize_t *psent)
 {
-       ssize_t sent;
-       int sys_errno;
+       struct rpc_sock_write_state *state = talloc_get_type_abort(
+               req->private_data, struct rpc_sock_write_state);
+       NTSTATUS status;
 
-       sent = async_syscall_result_ssize_t(req, &sys_errno);
-       if (sent == -1) {
-               return map_nt_error_from_unix(sys_errno);
+       if (async_req_is_nterror(req, &status)) {
+               return status;
        }
-       *psent = sent;
+       *psent = state->sent;
        return NT_STATUS_OK;
 }
 
index 31977e955467c8db6b2bb9b6a985b829e486c3c8..936c2081f3676e01bf42c8d9f0427742d77d45e5 100644 (file)
@@ -789,7 +789,6 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
        struct samr_SamArray *dom_users = NULL;
        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
        uint32 acb_mask = ACB_NORMAL;
-       bool got_connect_pol = False, got_domain_pol = False;
 
        if ((argc < 1) || (argc > 3)) {
                printf("Usage: %s [access_mask] [acb_mask]\n", argv[0]);
@@ -811,8 +810,6 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
        if (!NT_STATUS_IS_OK(result))
                goto done;
 
-       got_connect_pol = True;
-
        /* Get domain policy handle */
 
        result = rpccli_samr_OpenDomain(cli, mem_ctx,
@@ -824,8 +821,6 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
        if (!NT_STATUS_IS_OK(result))
                goto done;
 
-       got_domain_pol = True;
-
        /* Enumerate domain users */
 
        start_idx = 0;
@@ -852,10 +847,10 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
        } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
 
  done:
-       if (got_domain_pol)
+       if (is_valid_policy_hnd(&domain_pol))
                rpccli_samr_Close(cli, mem_ctx, &domain_pol);
 
-       if (got_connect_pol)
+       if (is_valid_policy_hnd(&connect_pol))
                rpccli_samr_Close(cli, mem_ctx, &connect_pol);
 
        return result;
@@ -872,7 +867,6 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli,
        uint32 start_idx, size, num_dom_groups, i;
        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
        struct samr_SamArray *dom_groups = NULL;
-       bool got_connect_pol = False, got_domain_pol = False;
 
        if ((argc < 1) || (argc > 2)) {
                printf("Usage: %s [access_mask]\n", argv[0]);
@@ -891,8 +885,6 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli,
        if (!NT_STATUS_IS_OK(result))
                goto done;
 
-       got_connect_pol = True;
-
        /* Get domain policy handle */
 
        result = rpccli_samr_OpenDomain(cli, mem_ctx,
@@ -904,8 +896,6 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli,
        if (!NT_STATUS_IS_OK(result))
                goto done;
 
-       got_domain_pol = True;
-
        /* Enumerate domain groups */
 
        start_idx = 0;
@@ -930,10 +920,10 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli,
        } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
 
  done:
-       if (got_domain_pol)
+       if (is_valid_policy_hnd(&domain_pol))
                rpccli_samr_Close(cli, mem_ctx, &domain_pol);
 
-       if (got_connect_pol)
+       if (is_valid_policy_hnd(&connect_pol))
                rpccli_samr_Close(cli, mem_ctx, &connect_pol);
 
        return result;
@@ -950,7 +940,6 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
        uint32 start_idx, size, num_als_groups, i;
        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
        struct samr_SamArray *als_groups = NULL;
-       bool got_connect_pol = False, got_domain_pol = False;
 
        if ((argc < 2) || (argc > 3)) {
                printf("Usage: %s builtin|domain [access mask]\n", argv[0]);
@@ -969,8 +958,6 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
        if (!NT_STATUS_IS_OK(result))
                goto done;
 
-       got_connect_pol = True;
-
        /* Get domain policy handle */
 
        result = get_domain_handle(cli, mem_ctx, argv[1],
@@ -982,8 +969,6 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
        if (!NT_STATUS_IS_OK(result))
                goto done;
 
-       got_domain_pol = True;
-
        /* Enumerate alias groups */
 
        start_idx = 0;
@@ -1008,10 +993,10 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
        } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
 
  done:
-       if (got_domain_pol)
+       if (is_valid_policy_hnd(&domain_pol))
                rpccli_samr_Close(cli, mem_ctx, &domain_pol);
 
-       if (got_connect_pol)
+       if (is_valid_policy_hnd(&connect_pol))
                rpccli_samr_Close(cli, mem_ctx, &connect_pol);
 
        return result;
@@ -1027,7 +1012,6 @@ static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli,
        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
        uint32 start_idx, size, num_entries, i;
        uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
-       bool got_connect_pol = false;
        struct samr_SamArray *sam = NULL;
 
        if ((argc < 1) || (argc > 2)) {
@@ -1049,8 +1033,6 @@ static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli,
                goto done;
        }
 
-       got_connect_pol = true;
-
        /* Enumerate alias groups */
 
        start_idx = 0;
@@ -1075,7 +1057,7 @@ static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli,
        } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
 
  done:
-       if (got_connect_pol) {
+       if (is_valid_policy_hnd(&connect_pol)) {
                rpccli_samr_Close(cli, mem_ctx, &connect_pol);
        }
 
index fe2554e02d2c40f9172a191852376ef2efab7d74..51fcaaa54c6b96cc9d4ef39c6374a4641d1f1889 100644 (file)
@@ -1812,7 +1812,6 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
        WERROR werror;
        NTSTATUS status;
        const char *printername;
-       bool got_handle = False;
        union spoolss_AddFormInfo info;
        struct spoolss_AddFormInfo1 info1;
 
@@ -1834,8 +1833,6 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
        if (!W_ERROR_IS_OK(werror))
                goto done;
 
-       got_handle = True;
-
        /* Dummy up some values for the form data */
 
        info1.flags             = FORM_USER;
@@ -1859,7 +1856,7 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
                                        &werror);
 
  done:
-       if (got_handle)
+       if (is_valid_policy_hnd(&handle))
                rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
 
        return werror;
@@ -1875,7 +1872,6 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
        WERROR werror;
        NTSTATUS status;
        const char *printername;
-       bool got_handle = False;
        union spoolss_AddFormInfo info;
        struct spoolss_AddFormInfo1 info1;
 
@@ -1897,8 +1893,6 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
        if (!W_ERROR_IS_OK(werror))
                goto done;
 
-       got_handle = True;
-
        /* Dummy up some values for the form data */
 
        info1.flags             = FORM_PRINTER;
@@ -1922,7 +1916,7 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
                                        &werror);
 
  done:
-       if (got_handle)
+       if (is_valid_policy_hnd(&handle))
                rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
 
        return werror;
@@ -1984,6 +1978,28 @@ static void display_form_info1(struct spoolss_FormInfo1 *r)
 /****************************************************************************
 ****************************************************************************/
 
+static void display_form_info2(struct spoolss_FormInfo2 *r)
+{
+       printf("%s\n" \
+               "\tflag: %s (%d)\n" \
+               "\twidth: %d, length: %d\n" \
+               "\tleft: %d, right: %d, top: %d, bottom: %d\n",
+               r->form_name, get_form_flag(r->flags), r->flags,
+               r->size.width, r->size.height,
+               r->area.left, r->area.right,
+               r->area.top, r->area.bottom);
+       printf("\tkeyword: %s\n", r->keyword);
+       printf("\tstring_type: 0x%08x\n", r->string_type);
+       printf("\tmui_dll: %s\n", r->mui_dll);
+       printf("\tressource_id: 0x%08x\n", r->ressource_id);
+       printf("\tdisplay_name: %s\n", r->display_name);
+       printf("\tlang_id: %d\n", r->lang_id);
+       printf("\n");
+}
+
+/****************************************************************************
+****************************************************************************/
+
 static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
                                    int argc, const char **argv)
 {
@@ -1991,16 +2007,16 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
        WERROR werror;
        NTSTATUS status;
        const char *printername;
-       bool got_handle = False;
        DATA_BLOB buffer;
        uint32_t offered = 0;
        union spoolss_FormInfo info;
        uint32_t needed;
+       uint32_t level = 1;
 
        /* Parse the command arguments */
 
-       if (argc != 3) {
-               printf ("Usage: %s <printer> <formname>\n", argv[0]);
+       if (argc < 3 || argc > 5) {
+               printf ("Usage: %s <printer> <formname> [level]\n", argv[0]);
                return WERR_OK;
         }
 
@@ -2015,26 +2031,28 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
        if (!W_ERROR_IS_OK(werror))
                goto done;
 
-       got_handle = True;
+       if (argc == 4) {
+               level = atoi(argv[3]);
+       }
 
        /* Get the form */
 
        status = rpccli_spoolss_GetForm(cli, mem_ctx,
                                        &handle,
                                        argv[2],
-                                       1,
+                                       level,
                                        NULL,
                                        offered,
                                        &info,
                                        &needed,
                                        &werror);
        if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
-               buffer = data_blob_talloc(mem_ctx, NULL, needed);
+               buffer = data_blob_talloc_zero(mem_ctx, needed);
                offered = needed;
                status = rpccli_spoolss_GetForm(cli, mem_ctx,
                                                &handle,
                                                argv[2],
-                                               1,
+                                               level,
                                                &buffer,
                                                offered,
                                                &info,
@@ -2046,9 +2064,17 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
                return werror;
        }
 
-       display_form_info1(&info.info1);
+       switch (level) {
+       case 1:
+               display_form_info1(&info.info1);
+               break;
+       case 2:
+               display_form_info2(&info.info2);
+               break;
+       }
+
  done:
-       if (got_handle)
+       if (is_valid_policy_hnd(&handle))
                rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
 
        return werror;
@@ -2065,7 +2091,6 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli,
        WERROR werror;
        NTSTATUS status;
        const char *printername;
-       bool got_handle = False;
 
        /* Parse the command arguments */
 
@@ -2085,8 +2110,6 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli,
        if (!W_ERROR_IS_OK(werror))
                goto done;
 
-       got_handle = True;
-
        /* Delete the form */
 
        status = rpccli_spoolss_DeleteForm(cli, mem_ctx,
@@ -2098,7 +2121,7 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli,
        }
 
  done:
-       if (got_handle)
+       if (is_valid_policy_hnd(&handle))
                rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
 
        return werror;
@@ -2114,7 +2137,6 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
        POLICY_HND handle;
        WERROR werror;
        const char *printername;
-       bool got_handle = False;
        uint32 num_forms, level = 1, i;
        FORM_1 *forms;
 
@@ -2136,8 +2158,6 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
        if (!W_ERROR_IS_OK(werror))
                goto done;
 
-       got_handle = True;
-
        /* Enumerate forms */
 
        werror = rpccli_spoolss_enumforms(cli, mem_ctx, &handle, level, &num_forms, &forms);
@@ -2154,7 +2174,7 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
        }
 
  done:
-       if (got_handle)
+       if (is_valid_policy_hnd(&handle))
                rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
 
        return werror;
index a05ac0796fc8311e022a035e9290a7b983ab7a5b..89ca7bbe5ca6833c7c05c52f3adc27958485094e 100644 (file)
@@ -41,7 +41,7 @@ static void ev_wrap_debug(void *context, enum tevent_debug_level level,
                samba_level = 2;
                break;
        case TEVENT_DEBUG_TRACE:
-               samba_level = 5;
+               samba_level = 10;
                break;
 
        };