From 3aeee79096e7a3c4f1467228d5cbee6986866400 Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Sun, 25 Jan 2009 14:38:44 -0800 Subject: s3 make test: Add the ability to specify a custom smb.conf for make test - Adds new -c option to selftest.sh that when specified adds a line to make test's server.conf: "include " - Adds getopts processing to selftest.sh - Changes selftest.sh shrdir arg to use -s - Changes selftest.sh smbtorture4_path arg to use -t - Adds configure option --with-selftest-custom-conf= - Updates Makefile.in to take advantage of the new/changed parameters --- source3/Makefile.in | 18 +++++++++++-- source3/m4/check_path.m4 | 19 ++++++++++++++ source3/script/tests/selftest.sh | 55 ++++++++++++++++++++++++++++++++-------- 3 files changed, 79 insertions(+), 13 deletions(-) diff --git a/source3/Makefile.in b/source3/Makefile.in index cbbf821b22..a1873eb6d5 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -19,6 +19,7 @@ datarootdir=@datarootdir@ selftest_prefix=@selftest_prefix@ selftest_shrdir=@selftest_shrdir@ smbtorture4_path=@smbtorture4_path@ +selftest_custom_conf=@selftest_custom_conf@ LIBS=@LIBS@ CC=@CC@ @@ -2928,9 +2929,22 @@ test_pam_modules:: pam_modules ## ## Targets for 'make test' ## + +ifdef smbtorture4_path +smbtorture4_path_arg=-t ${smbtorture4_path} +endif + +ifdef selftest_shrdir +selftest_shrdir_arg=-s ${selftest_shrdir} +endif + +ifdef selftest_custom_conf +selftest_custom_conf_arg=-c ${selftest_custom_conf} +endif + test:: all torture timelimit @echo Running Test suite - @LIB_PATH_VAR=$(LIB_PATH_VAR) PERL="$(PERL)" $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all "${smbtorture4_path}" ${selftest_shrdir} + @LIB_PATH_VAR=$(LIB_PATH_VAR) PERL="$(PERL)" $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all ${smbtorture4_path_arg} ${selftest_shrdir_arg} ${selftest_custom_conf_arg} valgrindtest:: all torture timelimit @echo Running Test suite with valgrind @@ -2939,7 +2953,7 @@ valgrindtest:: all torture timelimit WINBINDD_VALGRIND="xterm -n winbindd -e valgrind -q --db-attach=yes --num-callers=30" \ SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \ VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \ - PERL="$(PERL)" $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all "${smbtorture4_path}" + PERL="$(PERL)" $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all ${smbtorture4_path_arg} ${selftest_shrdir_arg} ${selftest_custom_conf_arg} SELFTEST_FORMAT = plain selftestdir = ../selftest diff --git a/source3/m4/check_path.m4 b/source3/m4/check_path.m4 index 444ea1c401..962e2765a0 100644 --- a/source3/m4/check_path.m4 +++ b/source3/m4/check_path.m4 @@ -361,6 +361,25 @@ AC_ARG_WITH(smbtorture4_path, esac ]) +################################################# +# set custom conf for make test +selftest_custom_conf="" +AC_SUBST(selftest_custom_conf) +AC_ARG_WITH(selftest_custom_conf, +[AS_HELP_STRING([--with-selftest-custom-conf=PATH], [An optional custom smb.conf that is included in the server smb.conf during make test(none)])], +[ case "$withval" in + yes|no) + AC_MSG_ERROR([--with-selftest-custom-conf should take a path]) + ;; + * ) + selftest_custom_conf="$withval" + if test -z "$selftest_custom_conf" -a ! -f $selftest_custom_conf; then + AC_MSG_ERROR(['$selftest_custom_conf' does not exist!]) + fi + ;; + esac +]) + ## check for --enable-debug first before checking CFLAGS before ## so that we don't mix -O and -g debug=no diff --git a/source3/script/tests/selftest.sh b/source3/script/tests/selftest.sh index 94fd791b51..ea2260d32d 100755 --- a/source3/script/tests/selftest.sh +++ b/source3/script/tests/selftest.sh @@ -1,17 +1,44 @@ #!/bin/sh -if [ $# != 3 -a $# != 4 ]; then - echo "$0 []" +if [ $# -lt 2 ]; then + echo "$0 [-t ] [-s ] " \ + "[-c ]" exit 1 fi -SMBTORTURE4=$3 -SUBTESTS=$2 +## +## Setup the required args +## +DIRECTORY=$1; shift; +SUBTESTS=$1; shift; + +## +## Parse oprtional args +## +while getopts s:c:t: f +do + case $f in + t) SMBTORTURE4=$OPTARG;; + s) ALT_SHRDIR_ARG=$OPTARG;; + c) CUSTOM_CONF_ARG=$OPTARG;; + esac +done + +echo "Running selftest with the following" +echo "Selftest Directory:\t\t$DIRECTORY" +echo "Subtests to Run:\t\t$SUBTESTS" +echo "smbtorture4 Path:\t\t$SMBTORTURE4" +echo "Alternative Share Dir:\t\t$ALT_SHRDIR_ARG" +echo "Custom Configuration:\t\t$CUSTOM_CONF_ARG" + +if [ $CUSTOM_CONF_ARG ]; then + INCLUDE_CUSTOM_CONF="include = $CUSTOM_CONF_ARG" +fi ## ## create the test directory ## -PREFIX=`echo $1 | sed s+//+/+` +PREFIX=`echo $DIRECTORY | sed s+//+/+` mkdir -p $PREFIX || exit $? OLD_PWD=`pwd` cd $PREFIX || exit $? @@ -68,8 +95,10 @@ export WINBINDD_SOCKET_DIR WINBINDD_PRIV_PIPE_DIR PATH=bin:$PATH export PATH -SAMBA4BINDIR=`dirname $SMBTORTURE4` -SAMBA4SHAREDDIR="$SAMBA4BINDIR/shared" +if [ $SMBTORTRE4 ]; then + SAMBA4BINDIR=`dirname $SMBTORTURE4` + SAMBA4SHAREDDIR="$SAMBA4BINDIR/shared" +fi export SAMBA4SHAREDDIR export SMBTORTURE4 @@ -116,8 +145,8 @@ chmod 755 $WINBINDD_SOCKET_DIR ## ## Create an alternate shrdir if one was specified. ## -if [ $# = 4 ]; then - ALT_SHRDIR=`echo $4 | sed s+//+/+` +if [ $ALT_SHRDIR_ARG ]; then + ALT_SHRDIR=`echo $ALT_SHRDIR_ARG | sed s+//+/+` mkdir -p $ALT_SHRDIR || exit $? OLD_PWD=`pwd` cd $ALT_SHRDIR || exit $? @@ -200,8 +229,6 @@ cat >$SERVERCONFFILE<$SERVERCONFFILE< Date: Mon, 26 Jan 2009 15:38:19 -0800 Subject: s3 make test: Fix a bug in the previous commit Luckily the build farm caught this --- source3/script/tests/selftest.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source3/script/tests/selftest.sh b/source3/script/tests/selftest.sh index ea2260d32d..0f1ca32e4a 100755 --- a/source3/script/tests/selftest.sh +++ b/source3/script/tests/selftest.sh @@ -25,11 +25,11 @@ do done echo "Running selftest with the following" -echo "Selftest Directory:\t\t$DIRECTORY" -echo "Subtests to Run:\t\t$SUBTESTS" -echo "smbtorture4 Path:\t\t$SMBTORTURE4" -echo "Alternative Share Dir:\t\t$ALT_SHRDIR_ARG" -echo "Custom Configuration:\t\t$CUSTOM_CONF_ARG" +echo "Selftest Directory: $DIRECTORY" +echo "Subtests to Run: $SUBTESTS" +echo "smbtorture4 Path: $SMBTORTURE4" +echo "Alternative Share Dir: $ALT_SHRDIR_ARG" +echo "Custom Configuration: $CUSTOM_CONF_ARG" if [ $CUSTOM_CONF_ARG ]; then INCLUDE_CUSTOM_CONF="include = $CUSTOM_CONF_ARG" @@ -95,11 +95,12 @@ export WINBINDD_SOCKET_DIR WINBINDD_PRIV_PIPE_DIR PATH=bin:$PATH export PATH -if [ $SMBTORTRE4 ]; then +if [ $SMBTORTURE4 ]; then SAMBA4BINDIR=`dirname $SMBTORTURE4` - SAMBA4SHAREDDIR="$SAMBA4BINDIR/shared" fi +SAMBA4SHAREDDIR="$SAMBA4BINDIR/shared" + export SAMBA4SHAREDDIR export SMBTORTURE4 -- cgit From 692b63e93a19b1226669ff51a77484dbc50926d0 Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Mon, 26 Jan 2009 16:50:31 -0800 Subject: s3 build: Eliminate the gmake-specific Makefile syntax --- source3/Makefile.in | 16 +++------------- source3/m4/check_path.m4 | 4 +++- source3/samba4.m4 | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/source3/Makefile.in b/source3/Makefile.in index a1873eb6d5..1f28e49b9f 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -2930,21 +2930,11 @@ test_pam_modules:: pam_modules ## Targets for 'make test' ## -ifdef smbtorture4_path -smbtorture4_path_arg=-t ${smbtorture4_path} -endif - -ifdef selftest_shrdir -selftest_shrdir_arg=-s ${selftest_shrdir} -endif - -ifdef selftest_custom_conf -selftest_custom_conf_arg=-c ${selftest_custom_conf} -endif +TEST_EXTRA_ARGS = ${smbtorture4_path} ${selftest_shrdir} ${selftest_custom_conf} test:: all torture timelimit @echo Running Test suite - @LIB_PATH_VAR=$(LIB_PATH_VAR) PERL="$(PERL)" $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all ${smbtorture4_path_arg} ${selftest_shrdir_arg} ${selftest_custom_conf_arg} + @LIB_PATH_VAR=$(LIB_PATH_VAR) PERL="$(PERL)" $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all ${TEST_EXTRA_ARGS} valgrindtest:: all torture timelimit @echo Running Test suite with valgrind @@ -2953,7 +2943,7 @@ valgrindtest:: all torture timelimit WINBINDD_VALGRIND="xterm -n winbindd -e valgrind -q --db-attach=yes --num-callers=30" \ SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \ VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \ - PERL="$(PERL)" $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all ${smbtorture4_path_arg} ${selftest_shrdir_arg} ${selftest_custom_conf_arg} + PERL="$(PERL)" $(srcdir)/script/tests/selftest.sh ${selftest_prefix} all ${TEST_EXTRA_ARGS} SELFTEST_FORMAT = plain selftestdir = ../selftest diff --git a/source3/m4/check_path.m4 b/source3/m4/check_path.m4 index 962e2765a0..2a468d7002 100644 --- a/source3/m4/check_path.m4 +++ b/source3/m4/check_path.m4 @@ -337,7 +337,7 @@ AC_ARG_WITH(selftest-shrdir, AC_MSG_WARN([--with-selftest-shrdir called without argument - will use default]) ;; * ) - selftest_shrdir="$withval" + selftest_shrdir="-s $withval" ;; esac ]) @@ -357,6 +357,7 @@ AC_ARG_WITH(smbtorture4_path, if test -z "$smbtorture4_path" -a ! -f $smbtorture4_path; then AC_MSG_ERROR(['$smbtorture_path' does not exist!]) fi + smbtorture4_path="-t $withval" ;; esac ]) @@ -376,6 +377,7 @@ AC_ARG_WITH(selftest_custom_conf, if test -z "$selftest_custom_conf" -a ! -f $selftest_custom_conf; then AC_MSG_ERROR(['$selftest_custom_conf' does not exist!]) fi + selftest_custom_conf="-c $withval" ;; esac ]) diff --git a/source3/samba4.m4 b/source3/samba4.m4 index 421ace0dbb..fd0cc8305c 100644 --- a/source3/samba4.m4 +++ b/source3/samba4.m4 @@ -1,5 +1,5 @@ AC_SUBST(BLDSHARED) -smbtorture4_path=bin/smbtorture4 +smbtorture4_path="-t bin/smbtorture4" m4_include(build/m4/public.m4) m4_include(../m4/check_python.m4) -- cgit From cdab2a412790c50feea754f5cfc4fe8b503e4b32 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 27 Jan 2009 12:11:49 +0100 Subject: libreplace: fix bug #6066 - netinet/ip.h present but cannot be compiled under solaris Michael --- lib/replace/libreplace_network.m4 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/replace/libreplace_network.m4 b/lib/replace/libreplace_network.m4 index 4edb55c03a..8d8379a566 100644 --- a/lib/replace/libreplace_network.m4 +++ b/lib/replace/libreplace_network.m4 @@ -7,7 +7,10 @@ LIBREPLACE_NETWORK_OBJS="" LIBREPLACE_NETWORK_LIBS="" AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) -AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) +AC_CHECK_HEADERS([netinet/ip.h], [], [],[#ifdef HAVE_NETINET_IN_H +#include +#endif]) +AC_CHECK_HEADERS(netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) AC_CHECK_HEADERS(sys/sockio.h sys/un.h) dnl we need to check that net/if.h really can be used, to cope with hpux -- cgit From a7e620522e72e27361ebe34172048db458fe581a Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Tue, 27 Jan 2009 10:37:35 +0100 Subject: async_req: Fix the S4 build --- lib/async_req/async_req.c | 40 ++++++++++++++++++++++++---------------- lib/async_req/async_req.h | 8 ++++---- source3/configure.in | 2 +- source3/include/includes.h | 2 +- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/lib/async_req/async_req.c b/lib/async_req/async_req.c index 011948a158..be70a56380 100644 --- a/lib/async_req/async_req.c +++ b/lib/async_req/async_req.c @@ -18,6 +18,14 @@ */ #include "includes.h" +#include "lib/tevent/tevent.h" +#include "lib/talloc/talloc.h" +#include "lib/util/dlinklist.h" +#include "lib/async_req/async_req.h" + +#ifndef TALLOC_FREE +#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0) +#endif /** * @brief Print an async_req structure @@ -53,7 +61,7 @@ struct async_req *async_req_new(TALLOC_CTX *mem_ctx) { struct async_req *result; - result = TALLOC_ZERO_P(mem_ctx, struct async_req); + result = talloc_zero(mem_ctx, struct async_req); if (result == NULL) { return NULL; } @@ -107,7 +115,7 @@ void async_req_error(struct async_req *req, NTSTATUS status) * @param[in] priv The async request to be finished */ -static void async_trigger(struct event_context *ev, struct timed_event *te, +static void async_trigger(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); @@ -134,12 +142,12 @@ static void async_trigger(struct event_context *ev, struct timed_event *te, * conventions, independent of whether the request was actually deferred. */ -bool async_post_status(struct async_req *req, struct event_context *ev, +bool async_post_status(struct async_req *req, struct tevent_context *ev, NTSTATUS status) { req->status = status; - if (event_add_timed(ev, req, timeval_zero(), + if (tevent_add_timer(ev, req, timeval_zero(), async_trigger, req) == NULL) { return false; } @@ -195,8 +203,8 @@ NTSTATUS async_req_simple_recv(struct async_req *req) return NT_STATUS_OK; } -static void async_req_timedout(struct event_context *ev, - struct timed_event *te, +static void async_req_timedout(struct tevent_context *ev, + struct tevent_timer *te, struct timeval now, void *priv) { @@ -206,17 +214,17 @@ static void async_req_timedout(struct event_context *ev, async_req_error(req, NT_STATUS_IO_TIMEOUT); } -bool async_req_set_timeout(struct async_req *req, struct event_context *ev, +bool async_req_set_timeout(struct async_req *req, struct tevent_context *ev, struct timeval to) { - return (event_add_timed(ev, req, + return (tevent_add_timer(ev, req, 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 event_context *ev, + struct tevent_context *ev, struct timeval to) { struct async_req *result; @@ -250,7 +258,7 @@ struct async_req_queue { struct async_req_queue *async_req_queue_init(TALLOC_CTX *mem_ctx) { - return TALLOC_ZERO_P(mem_ctx, struct async_req_queue); + return talloc_zero(mem_ctx, struct async_req_queue); } static int async_queue_entry_destructor(struct async_queue_entry *e) @@ -266,8 +274,8 @@ static int async_queue_entry_destructor(struct async_queue_entry *e) return 0; } -static void async_req_immediate_trigger(struct event_context *ev, - struct timed_event *te, +static void async_req_immediate_trigger(struct tevent_context *ev, + struct tevent_timer *te, struct timeval now, void *priv) { @@ -278,7 +286,7 @@ static void async_req_immediate_trigger(struct event_context *ev, e->trigger(e->req); } -bool async_req_enqueue(struct async_req_queue *queue, struct event_context *ev, +bool async_req_enqueue(struct async_req_queue *queue, struct tevent_context *ev, struct async_req *req, void (*trigger)(struct async_req *req)) { @@ -300,9 +308,9 @@ bool async_req_enqueue(struct async_req_queue *queue, struct event_context *ev, talloc_set_destructor(e, async_queue_entry_destructor); if (!busy) { - struct timed_event *te; + struct tevent_timer *te; - te = event_add_timed(ev, e, timeval_zero(), + te = tevent_add_timer(ev, e, timeval_zero(), async_req_immediate_trigger, e); if (te == NULL) { @@ -330,7 +338,7 @@ bool _async_req_setup(TALLOC_CTX *mem_ctx, struct async_req **preq, TALLOC_FREE(req); return false; } - talloc_set_name(state, typename); + talloc_set_name_const(state, typename); req->private_data = state; *preq = req; diff --git a/lib/async_req/async_req.h b/lib/async_req/async_req.h index 3907a08f67..59f5bd19b2 100644 --- a/lib/async_req/async_req.h +++ b/lib/async_req/async_req.h @@ -123,7 +123,7 @@ void async_req_done(struct async_req *req); void async_req_error(struct async_req *req, NTSTATUS status); -bool async_post_status(struct async_req *req, struct event_context *ev, +bool async_post_status(struct async_req *req, struct tevent_context *ev, NTSTATUS status); bool async_req_nomem(const void *p, struct async_req *req); @@ -132,11 +132,11 @@ bool async_req_is_error(struct async_req *req, NTSTATUS *status); NTSTATUS async_req_simple_recv(struct async_req *req); -bool async_req_set_timeout(struct async_req *req, struct event_context *ev, +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 event_context *ev, + struct tevent_context *ev, struct timeval to); NTSTATUS async_wait_recv(struct async_req *req); @@ -146,7 +146,7 @@ struct async_req_queue; struct async_req_queue *async_req_queue_init(TALLOC_CTX *mem_ctx); bool async_req_enqueue(struct async_req_queue *queue, - struct event_context *ev, + struct tevent_context *ev, struct async_req *req, void (*trigger)(struct async_req *req)); diff --git a/source3/configure.in b/source3/configure.in index 321924889a..c63f7c84a8 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -63,7 +63,7 @@ SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TEVENT_CFLAGS}" SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TDB_CFLAGS}" SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns" SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc" -SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/async_req" +SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/.." SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/popt" diff --git a/source3/include/includes.h b/source3/include/includes.h index 9c7f15b9cb..50140c17f7 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -647,7 +647,7 @@ struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx); #include "ctdbd_conn.h" #include "../lib/util/talloc_stack.h" #include "memcache.h" -#include "async_req.h" +#include "../lib/async_req/async_req.h" #include "async_smb.h" #include "async_sock.h" #include "services.h" -- cgit From 920f8b15685eb3f378c6ba5865a57e5f4d36e042 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 23 Jan 2009 10:42:31 +0100 Subject: tevent: change SA_INFO_QUEUE_COUNT from 10 to 100 The samba3 aio code requires lp_max_mux() with a default of 50 and the samba3 linux oplock code requires 100. May we could make the size dynamic later. metze --- lib/tevent/tevent_signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tevent/tevent_signal.c b/lib/tevent/tevent_signal.c index c21ba209af..04ee6975bd 100644 --- a/lib/tevent/tevent_signal.c +++ b/lib/tevent/tevent_signal.c @@ -29,7 +29,7 @@ #define NUM_SIGNALS 64 /* maximum number of SA_SIGINFO signals to hold in the queue */ -#define SA_INFO_QUEUE_COUNT 10 +#define SA_INFO_QUEUE_COUNT 100 struct sigcounter { uint32_t count; -- cgit From 7d93d3d4b8db230ceb51a81f18650b8114528f1f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 22 Jan 2009 10:19:14 +0100 Subject: s3:namecache: remove unused namecache_shutdown() function metze --- source3/include/proto.h | 1 - source3/libsmb/namecache.c | 21 --------------------- source3/smbd/server.c | 2 -- 3 files changed, 24 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 8838419705..c02a41a678 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2944,7 +2944,6 @@ NTSTATUS map_nt_error_from_gss(uint32 gss_maj, uint32 minor); /* The following definitions come from libsmb/namecache.c */ bool namecache_enable(void); -bool namecache_shutdown(void); bool namecache_store(const char *name, int name_type, int num_names, diff --git a/source3/libsmb/namecache.c b/source3/libsmb/namecache.c index ba706e5ee2..d3230cffef 100644 --- a/source3/libsmb/namecache.c +++ b/source3/libsmb/namecache.c @@ -61,27 +61,6 @@ bool namecache_enable(void) return True; } -/** - * Shutdown namecache. Routine calls gencache close function - * to safely close gencache file. - * - * @return true upon successful shutdown of the cache or - * false on failure - **/ - -bool namecache_shutdown(void) -{ - if (!gencache_shutdown()) { - DEBUG(2, ("namecache_shutdown: " - "Couldn't close namecache on top of gencache.\n")); - return False; - } - - DEBUG(5, ("namecache_shutdown: " - "netbios namecache closed successfully.\n")); - return True; -} - /** * Generates a key for netbios name lookups on basis of * netbios name and type. diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 505763014e..65fb0a84d1 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -1476,8 +1476,6 @@ extern void build_options(bool screen); smbd_process(); - namecache_shutdown(); - exit_server_cleanly(NULL); return(0); } -- cgit From 6a2b7f98151ef0b5b434e1ed522a47770e2151ea Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 22 Jan 2009 10:13:45 +0100 Subject: s3:smbd: we should setup the client socket in the same way in all code pathes We should behave the same in inetd, interactive and deamon modes. metze --- source3/smbd/server.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 65fb0a84d1..794e9d2ac6 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -199,9 +199,6 @@ static bool open_sockets_inetd(void) /* close our standard file descriptors */ close_low_fds(False); /* Don't close stderr */ - - set_socket_options(smbd_server_fd(),"SO_KEEPALIVE"); - set_socket_options(smbd_server_fd(), lp_socket_options()); return True; } @@ -690,17 +687,11 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ continue; } - /* Ensure child is set to blocking mode */ - set_blocking(smbd_server_fd(),True); - - if (smbd_server_fd() != -1 && interactive) + if (interactive) return True; if (allowable_number_of_smbd_processes() && - smbd_server_fd() != -1 && ((child = sys_fork())==0)) { - char remaddr[INET6_ADDRSTRLEN]; - /* Child code ... */ /* Stop zombies, the parent explicitly handles @@ -719,17 +710,6 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ close_low_fds(False); am_parent = 0; - set_socket_options(smbd_server_fd(),"SO_KEEPALIVE"); - set_socket_options(smbd_server_fd(), - lp_socket_options()); - - /* this is needed so that we get decent entries - in smbstatus for port 445 connects */ - set_remote_machine_name(get_peer_addr(smbd_server_fd(), - remaddr, - sizeof(remaddr)), - false); - if (!reinit_after_fork( smbd_messaging_context(), smbd_event_context(), @@ -1114,6 +1094,7 @@ extern void build_options(bool screen); POPT_COMMON_DYNCONFIG POPT_TABLEEND }; + char remaddr[INET6_ADDRSTRLEN]; TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */ smbd_init_globals(); @@ -1379,6 +1360,19 @@ extern void build_options(bool screen); * everything after this point is run after the fork() */ + /* Ensure child is set to blocking mode */ + set_blocking(smbd_server_fd(),True); + + set_socket_options(smbd_server_fd(),"SO_KEEPALIVE"); + set_socket_options(smbd_server_fd(), lp_socket_options()); + + /* this is needed so that we get decent entries + in smbstatus for port 445 connects */ + set_remote_machine_name(get_peer_addr(smbd_server_fd(), + remaddr, + sizeof(remaddr)), + false); + static_init_rpc; init_modules(); -- cgit From 27f812f3a85ce21ca79143f59c823913f57fa507 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 22 Jan 2009 12:36:42 +0100 Subject: s3:smbd: move all code that handles a client connection into smbd_process() metze --- source3/smbd/process.c | 224 +++++++++++++++++++++++++++++++++++++++++++++++-- source3/smbd/server.c | 212 ---------------------------------------------- 2 files changed, 218 insertions(+), 218 deletions(-) diff --git a/source3/smbd/process.c b/source3/smbd/process.c index a025bb4197..a07b71e5ac 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -1903,12 +1903,135 @@ static void smbd_server_connection_handler(struct event_context *ev, } } + +/**************************************************************************** +received when we should release a specific IP +****************************************************************************/ +static void release_ip(const char *ip, void *priv) +{ + char addr[INET6_ADDRSTRLEN]; + + if (strcmp(client_socket_addr(get_client_fd(),addr,sizeof(addr)), ip) == 0) { + /* we can't afford to do a clean exit - that involves + database writes, which would potentially mean we + are still running after the failover has finished - + we have to get rid of this process ID straight + away */ + DEBUG(0,("Got release IP message for our IP %s - exiting immediately\n", + ip)); + /* note we must exit with non-zero status so the unclean handler gets + called in the parent, so that the brl database is tickled */ + _exit(1); + } +} + +static void msg_release_ip(struct messaging_context *msg_ctx, void *private_data, + uint32_t msg_type, struct server_id server_id, DATA_BLOB *data) +{ + release_ip((char *)data->data, NULL); +} + +#ifdef CLUSTER_SUPPORT +static int client_get_tcp_info(struct sockaddr_storage *server, + struct sockaddr_storage *client) +{ + socklen_t length; + if (server_fd == -1) { + return -1; + } + length = sizeof(*server); + if (getsockname(server_fd, (struct sockaddr *)server, &length) != 0) { + return -1; + } + length = sizeof(*client); + if (getpeername(server_fd, (struct sockaddr *)client, &length) != 0) { + return -1; + } + return 0; +} +#endif + +/* + * Send keepalive packets to our client + */ +static bool keepalive_fn(const struct timeval *now, void *private_data) +{ + if (!send_keepalive(smbd_server_fd())) { + DEBUG( 2, ( "Keepalive failed - exiting.\n" ) ); + return False; + } + return True; +} + +/* + * Do the recurring check if we're idle + */ +static bool deadtime_fn(const struct timeval *now, void *private_data) +{ + if ((conn_num_open() == 0) + || (conn_idle_all(now->tv_sec))) { + DEBUG( 2, ( "Closing idle connection\n" ) ); + messaging_send(smbd_messaging_context(), procid_self(), + MSG_SHUTDOWN, &data_blob_null); + return False; + } + + return True; +} + +/* + * Do the recurring log file and smb.conf reload checks. + */ + +static bool housekeeping_fn(const struct timeval *now, void *private_data) +{ + change_to_root_user(); + + /* update printer queue caches if necessary */ + update_monitored_printq_cache(); + + /* check if we need to reload services */ + check_reload(time(NULL)); + + /* Change machine password if neccessary. */ + attempt_machine_password_change(); + + /* + * Force a log file check. + */ + force_check_log_size(); + check_log_size(); + return true; +} + /**************************************************************************** Process commands from the client ****************************************************************************/ void smbd_process(void) { + TALLOC_CTX *frame = talloc_stackframe(); + char remaddr[INET6_ADDRSTRLEN]; + + smbd_server_conn = talloc_zero(smbd_event_context(), struct smbd_server_connection); + if (!smbd_server_conn) { + exit_server("failed to create smbd_server_connection"); + } + + /* Ensure child is set to blocking mode */ + set_blocking(smbd_server_fd(),True); + + set_socket_options(smbd_server_fd(),"SO_KEEPALIVE"); + set_socket_options(smbd_server_fd(), lp_socket_options()); + + /* this is needed so that we get decent entries + in smbstatus for port 445 connects */ + set_remote_machine_name(get_peer_addr(smbd_server_fd(), + remaddr, + sizeof(remaddr)), + false); + reload_services(true); + /* * Before the first packet, check the global hosts allow/ hosts deny * parameters before doing any parsing of packets passed to us by the @@ -1931,12 +2054,96 @@ void smbd_process(void) exit_server_cleanly("connection denied"); } - max_recv = MIN(lp_maxxmit(),BUFFER_SIZE); + static_init_rpc; - smbd_server_conn = talloc_zero(smbd_event_context(), struct smbd_server_connection); - if (!smbd_server_conn) { - exit_server("failed to create smbd_server_connection"); + init_modules(); + + if (!init_account_policy()) { + exit_server("Could not open account policy tdb.\n"); + } + + if (*lp_rootdir()) { + if (chroot(lp_rootdir()) != 0) { + DEBUG(0,("Failed changed root to %s\n", lp_rootdir())); + exit_server("Failed to chroot()"); + } + DEBUG(0,("Changed root to %s\n", lp_rootdir())); + } + + /* Setup oplocks */ + if (!init_oplocks(smbd_messaging_context())) + exit_server("Failed to init oplocks"); + + /* Setup aio signal handler. */ + initialize_async_io_handler(); + + /* register our message handlers */ + messaging_register(smbd_messaging_context(), NULL, + MSG_SMB_FORCE_TDIS, msg_force_tdis); + messaging_register(smbd_messaging_context(), NULL, + MSG_SMB_RELEASE_IP, msg_release_ip); + messaging_register(smbd_messaging_context(), NULL, + MSG_SMB_CLOSE_FILE, msg_close_file); + + if ((lp_keepalive() != 0) + && !(event_add_idle(smbd_event_context(), NULL, + timeval_set(lp_keepalive(), 0), + "keepalive", keepalive_fn, + NULL))) { + DEBUG(0, ("Could not add keepalive event\n")); + exit(1); + } + + if (!(event_add_idle(smbd_event_context(), NULL, + timeval_set(IDLE_CLOSED_TIMEOUT, 0), + "deadtime", deadtime_fn, NULL))) { + DEBUG(0, ("Could not add deadtime event\n")); + exit(1); } + + if (!(event_add_idle(smbd_event_context(), NULL, + timeval_set(SMBD_SELECT_TIMEOUT, 0), + "housekeeping", housekeeping_fn, NULL))) { + DEBUG(0, ("Could not add housekeeping event\n")); + exit(1); + } + +#ifdef CLUSTER_SUPPORT + + if (lp_clustering()) { + /* + * We need to tell ctdb about our client's TCP + * connection, so that for failover ctdbd can send + * tickle acks, triggering a reconnection by the + * client. + */ + + struct sockaddr_storage srv, clnt; + + if (client_get_tcp_info(&srv, &clnt) == 0) { + + NTSTATUS status; + + status = ctdbd_register_ips( + messaging_ctdbd_connection(), + &srv, &clnt, release_ip, NULL); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("ctdbd_register_ips failed: %s\n", + nt_errstr(status))); + } + } else + { + DEBUG(0,("Unable to get tcp info for " + "CTDB_CONTROL_TCP_CLIENT: %s\n", + strerror(errno))); + } + } + +#endif + + max_recv = MIN(lp_maxxmit(),BUFFER_SIZE); + smbd_server_conn->fde = event_add_fd(smbd_event_context(), smbd_server_conn, smbd_server_fd(), @@ -1947,9 +2154,12 @@ void smbd_process(void) exit_server("failed to create smbd_server_connection fde"); } + TALLOC_FREE(frame); + while (True) { NTSTATUS status; - TALLOC_CTX *frame = talloc_stackframe_pool(8192); + + frame = talloc_stackframe_pool(8192); errno = 0; @@ -1958,9 +2168,11 @@ void smbd_process(void) !NT_STATUS_IS_OK(status)) { DEBUG(3, ("smbd_server_connection_loop_once failed: %s," " exiting\n", nt_errstr(status))); - return; + break; } TALLOC_FREE(frame); } + + exit_server_cleanly(NULL); } diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 794e9d2ac6..c5d3c8932a 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -45,26 +45,6 @@ int get_client_fd(void) return server_fd; } -#ifdef CLUSTER_SUPPORT -static int client_get_tcp_info(struct sockaddr_storage *server, - struct sockaddr_storage *client) -{ - socklen_t length; - if (server_fd == -1) { - return -1; - } - length = sizeof(*server); - if (getsockname(server_fd, (struct sockaddr *)server, &length) != 0) { - return -1; - } - length = sizeof(*client); - if (getpeername(server_fd, (struct sockaddr *)client, &length) != 0) { - return -1; - } - return 0; -} -#endif - struct event_context *smbd_event_context(void) { if (!smbd_event_ctx) { @@ -943,34 +923,6 @@ void exit_server_fault(void) exit_server("critical server fault"); } - -/**************************************************************************** -received when we should release a specific IP -****************************************************************************/ -static void release_ip(const char *ip, void *priv) -{ - char addr[INET6_ADDRSTRLEN]; - - if (strcmp(client_socket_addr(get_client_fd(),addr,sizeof(addr)), ip) == 0) { - /* we can't afford to do a clean exit - that involves - database writes, which would potentially mean we - are still running after the failover has finished - - we have to get rid of this process ID straight - away */ - DEBUG(0,("Got release IP message for our IP %s - exiting immediately\n", - ip)); - /* note we must exit with non-zero status so the unclean handler gets - called in the parent, so that the brl database is tickled */ - _exit(1); - } -} - -static void msg_release_ip(struct messaging_context *msg_ctx, void *private_data, - uint32_t msg_type, struct server_id server_id, DATA_BLOB *data) -{ - release_ip((char *)data->data, NULL); -} - /**************************************************************************** Initialise connect, service and file structs. ****************************************************************************/ @@ -997,59 +949,6 @@ static bool init_structs(void ) return True; } -/* - * Send keepalive packets to our client - */ -static bool keepalive_fn(const struct timeval *now, void *private_data) -{ - if (!send_keepalive(smbd_server_fd())) { - DEBUG( 2, ( "Keepalive failed - exiting.\n" ) ); - return False; - } - return True; -} - -/* - * Do the recurring check if we're idle - */ -static bool deadtime_fn(const struct timeval *now, void *private_data) -{ - if ((conn_num_open() == 0) - || (conn_idle_all(now->tv_sec))) { - DEBUG( 2, ( "Closing idle connection\n" ) ); - messaging_send(smbd_messaging_context(), procid_self(), - MSG_SHUTDOWN, &data_blob_null); - return False; - } - - return True; -} - -/* - * Do the recurring log file and smb.conf reload checks. - */ - -static bool housekeeping_fn(const struct timeval *now, void *private_data) -{ - change_to_root_user(); - - /* update printer queue caches if necessary */ - update_monitored_printq_cache(); - - /* check if we need to reload services */ - check_reload(time(NULL)); - - /* Change machine password if neccessary. */ - attempt_machine_password_change(); - - /* - * Force a log file check. - */ - force_check_log_size(); - check_log_size(); - return true; -} - /**************************************************************************** main program. ****************************************************************************/ @@ -1094,7 +993,6 @@ extern void build_options(bool screen); POPT_COMMON_DYNCONFIG POPT_TABLEEND }; - char remaddr[INET6_ADDRSTRLEN]; TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */ smbd_init_globals(); @@ -1356,116 +1254,6 @@ extern void build_options(bool screen); if (!open_sockets_smbd(is_daemon, interactive, ports)) exit(1); - /* - * everything after this point is run after the fork() - */ - - /* Ensure child is set to blocking mode */ - set_blocking(smbd_server_fd(),True); - - set_socket_options(smbd_server_fd(),"SO_KEEPALIVE"); - set_socket_options(smbd_server_fd(), lp_socket_options()); - - /* this is needed so that we get decent entries - in smbstatus for port 445 connects */ - set_remote_machine_name(get_peer_addr(smbd_server_fd(), - remaddr, - sizeof(remaddr)), - false); - - static_init_rpc; - - init_modules(); - - /* Possibly reload the services file. Only worth doing in - * daemon mode. In inetd mode, we know we only just loaded this. - */ - if (is_daemon) { - reload_services(True); - } - - if (!init_account_policy()) { - DEBUG(0,("Could not open account policy tdb.\n")); - exit(1); - } - - if (*lp_rootdir()) { - if (chroot(lp_rootdir()) == 0) - DEBUG(2,("Changed root to %s\n", lp_rootdir())); - } - - /* Setup oplocks */ - if (!init_oplocks(smbd_messaging_context())) - exit(1); - - /* Setup aio signal handler. */ - initialize_async_io_handler(); - - /* register our message handlers */ - messaging_register(smbd_messaging_context(), NULL, - MSG_SMB_FORCE_TDIS, msg_force_tdis); - messaging_register(smbd_messaging_context(), NULL, - MSG_SMB_RELEASE_IP, msg_release_ip); - messaging_register(smbd_messaging_context(), NULL, - MSG_SMB_CLOSE_FILE, msg_close_file); - - if ((lp_keepalive() != 0) - && !(event_add_idle(smbd_event_context(), NULL, - timeval_set(lp_keepalive(), 0), - "keepalive", keepalive_fn, - NULL))) { - DEBUG(0, ("Could not add keepalive event\n")); - exit(1); - } - - if (!(event_add_idle(smbd_event_context(), NULL, - timeval_set(IDLE_CLOSED_TIMEOUT, 0), - "deadtime", deadtime_fn, NULL))) { - DEBUG(0, ("Could not add deadtime event\n")); - exit(1); - } - - if (!(event_add_idle(smbd_event_context(), NULL, - timeval_set(SMBD_SELECT_TIMEOUT, 0), - "housekeeping", housekeeping_fn, NULL))) { - DEBUG(0, ("Could not add housekeeping event\n")); - exit(1); - } - -#ifdef CLUSTER_SUPPORT - - if (lp_clustering()) { - /* - * We need to tell ctdb about our client's TCP - * connection, so that for failover ctdbd can send - * tickle acks, triggering a reconnection by the - * client. - */ - - struct sockaddr_storage srv, clnt; - - if (client_get_tcp_info(&srv, &clnt) == 0) { - - NTSTATUS status; - - status = ctdbd_register_ips( - messaging_ctdbd_connection(), - &srv, &clnt, release_ip, NULL); - - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0, ("ctdbd_register_ips failed: %s\n", - nt_errstr(status))); - } - } else - { - DEBUG(0,("Unable to get tcp info for " - "CTDB_CONTROL_TCP_CLIENT: %s\n", - strerror(errno))); - } - } - -#endif - TALLOC_FREE(frame); smbd_process(); -- cgit From ac61f650ae640c13beee9d48304d7939f700aa11 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 21 Jan 2009 23:24:18 +0100 Subject: s3:smbd: use signal events for SIGTERM, SIGHUP and SIGCHLD metze --- source3/include/proto.h | 2 + source3/printing/printing.c | 18 ++----- source3/smbd/globals.c | 3 -- source3/smbd/globals.h | 3 -- source3/smbd/process.c | 65 ++++++++++++++++++----- source3/smbd/server.c | 127 ++++++++++++++++++-------------------------- 6 files changed, 107 insertions(+), 111 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index c02a41a678..d625f98186 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -7115,6 +7115,8 @@ SEC_DESC *get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fname); /* The following definitions come from smbd/process.c */ +void smbd_setup_sig_term_handler(void); +void smbd_setup_sig_hup_handler(void); bool srv_send_smb(int fd, char *buffer, bool do_encrypt); int srv_set_message(char *buf, int num_words, diff --git a/source3/printing/printing.c b/source3/printing/printing.c index bb29380007..0721713c01 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -22,8 +22,6 @@ #include "includes.h" #include "printing.h" -extern SIG_ATOMIC_T got_sig_term; -extern SIG_ATOMIC_T reload_after_sighup; extern struct current_user current_user; extern userdom_struct current_user_info; @@ -1427,6 +1425,9 @@ void start_background_queue(void) smb_panic("reinit_after_fork() failed"); } + smbd_setup_sig_term_handler(); + smbd_setup_sig_hup_handler(); + claim_connection( NULL, "smbd lpq backend", FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINT_GENERAL); @@ -1483,19 +1484,6 @@ void start_background_queue(void) exit_server_cleanly(NULL); } - /* check for some essential signals first */ - - if (got_sig_term) { - exit_server_cleanly(NULL); - } - - if (reload_after_sighup) { - change_to_root_user(); - DEBUG(1,("Reloading services after SIGHUP\n")); - reload_services(False); - reload_after_sighup = 0; - } - if (run_events(smbd_event_context(), ret, &r_fds, &w_fds)) { continue; } diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c index c5681223f9..d99f2b0680 100644 --- a/source3/smbd/globals.c +++ b/source3/smbd/globals.c @@ -125,8 +125,6 @@ int max_send = BUFFER_SIZE; * Can be modified by the max xmit parameter. */ int max_recv = BUFFER_SIZE; -SIG_ATOMIC_T reload_after_sighup = 0; -SIG_ATOMIC_T got_sig_term = 0; uint16 last_session_tag = UID_FIELD_INVALID; int trans_num = 0; char *orig_inbuf = NULL; @@ -186,7 +184,6 @@ struct kernel_oplocks *koplocks = NULL; struct notify_mid_map *notify_changes_by_mid = NULL; int am_parent = 1; -SIG_ATOMIC_T got_sig_cld = 0; int server_fd = -1; struct event_context *smbd_event_ctx = NULL; struct messaging_context *smbd_msg_ctx = NULL; diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 2c4f8b5821..15085d9d35 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -124,8 +124,6 @@ extern int max_send; * Can be modified by the max xmit parameter. */ extern int max_recv; -extern SIG_ATOMIC_T reload_after_sighup; -extern SIG_ATOMIC_T got_sig_term; extern uint16 last_session_tag; extern int trans_num; extern char *orig_inbuf; @@ -199,7 +197,6 @@ extern struct kernel_oplocks *koplocks; extern struct notify_mid_map *notify_changes_by_mid; extern int am_parent; -extern SIG_ATOMIC_T got_sig_cld; extern int server_fd; extern struct event_context *smbd_event_ctx; extern struct messaging_context *smbd_msg_ctx; diff --git a/source3/smbd/process.c b/source3/smbd/process.c index a07b71e5ac..2326bdab90 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -692,6 +692,56 @@ struct idle_event *event_add_idle(struct event_context *event_ctx, return result; } +static void smbd_sig_term_handler(struct tevent_context *ev, + struct tevent_signal *se, + int signum, + int count, + void *siginfo, + void *private_data) +{ + exit_server_cleanly("termination signal"); +} + +void smbd_setup_sig_term_handler(void) +{ + struct tevent_signal *se; + + se = tevent_add_signal(smbd_event_context(), + smbd_event_context(), + SIGTERM, 0, + smbd_sig_term_handler, + NULL); + if (!se) { + exit_server("failed to setup SIGTERM handler"); + } +} + +static void smbd_sig_hup_handler(struct tevent_context *ev, + struct tevent_signal *se, + int signum, + int count, + void *siginfo, + void *private_data) +{ + change_to_root_user(); + DEBUG(1,("Reloading services after SIGHUP\n")); + reload_services(False); +} + +void smbd_setup_sig_hup_handler(void) +{ + struct tevent_signal *se; + + se = tevent_add_signal(smbd_event_context(), + smbd_event_context(), + SIGHUP, 0, + smbd_sig_hup_handler, + NULL); + if (!se) { + exit_server("failed to setup SIGHUP handler"); + } +} + /**************************************************************************** Do all async processing in here. This includes kernel oplock messages, change notify events etc. @@ -709,18 +759,6 @@ static void async_processing(void) select and may have eaten our signal. */ /* Is this till true? -- vl */ process_aio_queue(); - - if (got_sig_term) { - exit_server_cleanly("termination signal"); - } - - /* check for sighup processing */ - if (reload_after_sighup) { - change_to_root_user(); - DEBUG(1,("Reloading services after SIGHUP\n")); - reload_services(False); - reload_after_sighup = 0; - } } /**************************************************************************** @@ -1830,9 +1868,8 @@ void check_reload(time_t t) mypid = getpid(); } - if (reload_after_sighup || (t >= last_smb_conf_reload_time+SMBD_RELOAD_CHECK)) { + if (t >= last_smb_conf_reload_time+SMBD_RELOAD_CHECK) { reload_services(True); - reload_after_sighup = False; last_smb_conf_reload_time = t; } diff --git a/source3/smbd/server.c b/source3/smbd/server.c index c5d3c8932a..e6ea5f3986 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -113,35 +113,6 @@ static void smb_stat_cache_delete(struct messaging_context *msg, stat_cache_delete(name); } -/**************************************************************************** - Terminate signal. -****************************************************************************/ - -static void sig_term(void) -{ - got_sig_term = 1; - sys_select_signal(SIGTERM); -} - -/**************************************************************************** - Catch a sighup. -****************************************************************************/ - -static void sig_hup(int sig) -{ - reload_after_sighup = 1; - sys_select_signal(SIGHUP); -} - -/**************************************************************************** - Catch a sigcld -****************************************************************************/ -static void sig_cld(int sig) -{ - got_sig_cld = 1; - sys_select_signal(SIGCLD); -} - /**************************************************************************** Send a SIGTERM to our process group. *****************************************************************************/ @@ -298,6 +269,50 @@ static bool allowable_number_of_smbd_processes(void) return num_children < max_processes; } +static void smbd_sig_chld_handler(struct tevent_context *ev, + struct tevent_signal *se, + int signum, + int count, + void *siginfo, + void *private_data) +{ + pid_t pid; + int status; + + while ((pid = sys_waitpid(-1, &status, WNOHANG)) > 0) { + bool unclean_shutdown = False; + + /* If the child terminated normally, assume + it was an unclean shutdown unless the + status is 0 + */ + if (WIFEXITED(status)) { + unclean_shutdown = WEXITSTATUS(status); + } + /* If the child terminated due to a signal + we always assume it was unclean. + */ + if (WIFSIGNALED(status)) { + unclean_shutdown = True; + } + remove_child_pid(pid, unclean_shutdown); + } +} + +static void smbd_setup_sig_chld_handler(void) +{ + struct tevent_signal *se; + + se = tevent_add_signal(smbd_event_context(), + smbd_event_context(), + SIGCHLD, 0, + smbd_sig_chld_handler, + NULL); + if (!se) { + exit_server("failed to setup SIGCHLD handler"); + } +} + /**************************************************************************** Open the socket communication. ****************************************************************************/ @@ -324,7 +339,7 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ #endif /* Stop zombies */ - CatchSignal(SIGCLD, sig_cld); + smbd_setup_sig_chld_handler(); FD_ZERO(&listen_set); @@ -550,32 +565,6 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ fd_set r_fds, w_fds; int num; - if (got_sig_cld) { - pid_t pid; - int status; - - got_sig_cld = False; - - while ((pid = sys_waitpid(-1, &status, WNOHANG)) > 0) { - bool unclean_shutdown = False; - - /* If the child terminated normally, assume - it was an unclean shutdown unless the - status is 0 - */ - if (WIFEXITED(status)) { - unclean_shutdown = WEXITSTATUS(status); - } - /* If the child terminated due to a signal - we always assume it was unclean. - */ - if (WIFSIGNALED(status)) { - unclean_shutdown = True; - } - remove_child_pid(pid, unclean_shutdown); - } - } - if (run_events(smbd_event_context(), 0, NULL, NULL)) { continue; } @@ -605,23 +594,6 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ continue; } - if (num == -1 && errno == EINTR) { - if (got_sig_term) { - exit_server_cleanly(NULL); - } - - /* check for sighup processing */ - if (reload_after_sighup) { - change_to_root_user(); - DEBUG(1,("Reloading services after SIGHUP\n")); - reload_services(False); - reload_after_sighup = 0; - } - - continue; - } - - /* If the idle timeout fired and we don't have any connected * users, exit gracefully. We should be running under a process * controller that will restart us if necessry. @@ -698,6 +670,9 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ smb_panic("reinit_after_fork() failed"); } + smbd_setup_sig_term_handler(); + smbd_setup_sig_hup_handler(); + return True; } /* The parent doesn't need this socket */ @@ -1078,9 +1053,6 @@ extern void build_options(bool screen); fault_setup((void (*)(void *))exit_server_fault); dump_core_setup("smbd"); - CatchSignal(SIGTERM , SIGNAL_CAST sig_term); - CatchSignal(SIGHUP,SIGNAL_CAST sig_hup); - /* we are never interested in SIGPIPE */ BlockSignals(True,SIGPIPE); @@ -1190,6 +1162,9 @@ extern void build_options(bool screen); exit(1); } + smbd_setup_sig_term_handler(); + smbd_setup_sig_hup_handler(); + /* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */ if (smbd_memcache() == NULL) { -- cgit From e6612c99fe6c2cb87f09dbc76d077bed789a592d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 22 Jan 2009 14:54:21 +0100 Subject: s3:winbindd: handle SIG_TERM, SIGHUP, SIGCHLD and SIGUSR2 via tevent metze --- source3/winbindd/winbindd.c | 227 ++++++++++++++++++++++++++------------ source3/winbindd/winbindd_dual.c | 11 +- source3/winbindd/winbindd_proto.h | 4 +- 3 files changed, 165 insertions(+), 77 deletions(-) diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index fad27ea224..5720bfc517 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -173,36 +173,161 @@ static void terminate(bool is_parent) exit(0); } -static SIG_ATOMIC_T do_sigterm = 0; +static void winbindd_sig_term_handler(struct tevent_context *ev, + struct tevent_signal *se, + int signum, + int count, + void *siginfo, + void *private_data) +{ + bool *is_parent = talloc_get_type_abort(private_data, bool); + + DEBUG(0,("Got sig[%d] terminate (is_parent=%d)\n", + signum, (int)*is_parent)); + terminate(*is_parent); +} -static void termination_handler(int signum) +bool winbindd_setup_sig_term_handler(bool parent) { - do_sigterm = 1; - sys_select_signal(signum); + struct tevent_signal *se; + bool *is_parent; + + is_parent = talloc(winbind_event_context(), bool); + if (!is_parent) { + return false; + } + + *is_parent = parent; + + se = tevent_add_signal(winbind_event_context(), + is_parent, + SIGTERM, 0, + winbindd_sig_term_handler, + is_parent); + if (!se) { + DEBUG(0,("failed to setup SIGTERM handler")); + talloc_free(is_parent); + return false; + } + + se = tevent_add_signal(winbind_event_context(), + is_parent, + SIGINT, 0, + winbindd_sig_term_handler, + is_parent); + if (!se) { + DEBUG(0,("failed to setup SIGINT handler")); + talloc_free(is_parent); + return false; + } + + se = tevent_add_signal(winbind_event_context(), + is_parent, + SIGQUIT, 0, + winbindd_sig_term_handler, + is_parent); + if (!se) { + DEBUG(0,("failed to setup SIGINT handler")); + talloc_free(is_parent); + return false; + } + + return true; } -static SIG_ATOMIC_T do_sigusr2 = 0; +static void winbindd_sig_hup_handler(struct tevent_context *ev, + struct tevent_signal *se, + int signum, + int count, + void *siginfo, + void *private_data) +{ + const char *file = (const char *)private_data; + + DEBUG(1,("Reloading services after SIGHUP\n")); + flush_caches(); + reload_services_file(file); +} -static void sigusr2_handler(int signum) +bool winbindd_setup_sig_hup_handler(const char *lfile) { - do_sigusr2 = 1; - sys_select_signal(SIGUSR2); + struct tevent_signal *se; + char *file = NULL; + + if (lfile) { + file = talloc_strdup(winbind_event_context(), + lfile); + if (!file) { + return false; + } + } + + se = tevent_add_signal(winbind_event_context(), + winbind_event_context(), + SIGHUP, 0, + winbindd_sig_hup_handler, + file); + if (!se) { + return false; + } + + return true; } -static SIG_ATOMIC_T do_sighup = 0; +static void winbindd_sig_chld_handler(struct tevent_context *ev, + struct tevent_signal *se, + int signum, + int count, + void *siginfo, + void *private_data) +{ + pid_t pid; + + while ((pid = sys_waitpid(-1, NULL, WNOHANG)) > 0) { + winbind_child_died(pid); + } +} -static void sighup_handler(int signum) +static bool winbindd_setup_sig_chld_handler(void) { - do_sighup = 1; - sys_select_signal(SIGHUP); + struct tevent_signal *se; + + se = tevent_add_signal(winbind_event_context(), + winbind_event_context(), + SIGCHLD, 0, + winbindd_sig_chld_handler, + NULL); + if (!se) { + return false; + } + + return true; } -static SIG_ATOMIC_T do_sigchld = 0; +static void winbindd_sig_usr2_handler(struct tevent_context *ev, + struct tevent_signal *se, + int signum, + int count, + void *siginfo, + void *private_data) +{ + print_winbindd_status(); +} -static void sigchld_handler(int signum) +static bool winbindd_setup_sig_usr2_handler(void) { - do_sigchld = 1; - sys_select_signal(SIGCHLD); + struct tevent_signal *se; + + se = tevent_add_signal(winbind_event_context(), + winbind_event_context(), + SIGCHLD, 0, + winbindd_sig_usr2_handler, + NULL); + if (!se) { + return false; + } + + return true; } /* React on 'smbcontrol winbindd reload-config' in the same way as on SIGHUP*/ @@ -224,7 +349,9 @@ static void msg_shutdown(struct messaging_context *msg, struct server_id server_id, DATA_BLOB *data) { - do_sigterm = 1; + /* only the parent waits for this message */ + DEBUG(0,("Got shutdown message\n")); + terminate(true); } @@ -797,27 +924,6 @@ static bool remove_idle_client(void) return False; } -/* check if HUP has been received and reload files */ -void winbind_check_sighup(const char *lfile) -{ - if (do_sighup) { - - DEBUG(3, ("got SIGHUP\n")); - - flush_caches(); - reload_services_file(lfile); - - do_sighup = 0; - } -} - -/* check if TERM has been received */ -void winbind_check_sigterm(bool is_parent) -{ - if (do_sigterm) - terminate(is_parent); -} - /* Process incoming clients on listen_sock. We use a tricky non-blocking, non-forking, non-threaded model which allows us to handle many simultaneous connections while remaining impervious to many denial of @@ -979,26 +1085,6 @@ static void process_loop(void) #if 0 winbindd_check_cache_size(time(NULL)); #endif - - /* Check signal handling things */ - - winbind_check_sigterm(true); - winbind_check_sighup(NULL); - - if (do_sigusr2) { - print_winbindd_status(); - do_sigusr2 = 0; - } - - if (do_sigchld) { - pid_t pid; - - do_sigchld = 0; - - while ((pid = sys_waitpid(-1, NULL, WNOHANG)) > 0) { - winbind_child_died(pid); - } - } } /* Main function */ @@ -1168,18 +1254,6 @@ int main(int argc, char **argv, char **envp) BlockSignals(False, SIGHUP); BlockSignals(False, SIGCHLD); - /* Setup signal handlers */ - - CatchSignal(SIGINT, termination_handler); /* Exit on these sigs */ - CatchSignal(SIGQUIT, termination_handler); - CatchSignal(SIGTERM, termination_handler); - CatchSignal(SIGCHLD, sigchld_handler); - - CatchSignal(SIGPIPE, SIG_IGN); /* Ignore sigpipe */ - - CatchSignal(SIGUSR2, sigusr2_handler); /* Debugging sigs */ - CatchSignal(SIGHUP, sighup_handler); - if (!interactive) become_daemon(Fork, no_process_group); @@ -1207,6 +1281,19 @@ int main(int argc, char **argv, char **envp) exit(1); } + /* Setup signal handlers */ + + if (!winbindd_setup_sig_term_handler(true)) + exit(1); + if (!winbindd_setup_sig_hup_handler(NULL)) + exit(1); + if (!winbindd_setup_sig_chld_handler()) + exit(1); + if (!winbindd_setup_sig_usr2_handler()) + exit(1); + + CatchSignal(SIGPIPE, SIG_IGN); /* Ignore sigpipe */ + /* * Ensure all cache and idmap caches are consistent * and initialized before we startup. diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index c320e96746..1385c76bae 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -1160,6 +1160,12 @@ bool winbindd_reinit_after_fork(const char *logfilename) reopen_logs(); } + if (!winbindd_setup_sig_term_handler(false)) + return false; + if (!winbindd_setup_sig_hup_handler(override_logfile ? NULL : + logfilename)) + return false; + /* Don't handle the same messages as our parent. */ messaging_deregister(winbind_messaging_context(), MSG_SMB_CONF_UPDATED, NULL); @@ -1379,11 +1385,6 @@ static bool fork_domain_child(struct winbindd_child *child) struct timeval now; TALLOC_CTX *frame = talloc_stackframe(); - /* check for signals */ - winbind_check_sigterm(false); - winbind_check_sighup(override_logfile ? NULL : - child->logfilename); - if (run_events(winbind_event_context(), 0, NULL, NULL)) { TALLOC_FREE(frame); continue; diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index 594f8be942..d72351d021 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -63,8 +63,8 @@ void setup_async_write(struct winbindd_fd_event *event, void *data, size_t lengt void *private_data); void request_error(struct winbindd_cli_state *state); void request_ok(struct winbindd_cli_state *state); -void winbind_check_sighup(const char *lfile); -void winbind_check_sigterm(bool in_parent); +bool winbindd_setup_sig_term_handler(bool parent); +bool winbindd_setup_sig_hup_handler(const char *logfile); int main(int argc, char **argv, char **envp); /* The following definitions come from winbindd/winbindd_reqtrans.c */ -- cgit From e663df195c2a6c108e90273b8fa9831abdbc3b1c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 23 Jan 2009 10:13:29 +0100 Subject: s3:nmbd: install the SIG_DFL handler for SIGTERM while we're waiting for interfaces We should handle all 3 cases where we actively wait for interfaces in the same way. metze --- source3/nmbd/nmbd.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 0922e455a3..870b9a1f30 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -282,6 +282,7 @@ static void reload_interfaces(time_t t) /* We need to wait if there are no subnets... */ if (FIRST_SUBNET == NULL) { + void (*saved_handler)(int); if (print_waiting_msg) { DEBUG(0,("reload_interfaces: " @@ -293,29 +294,20 @@ static void reload_interfaces(time_t t) * Whilst we're waiting for an interface, allow SIGTERM to * cause us to exit. */ - - BlockSignals(false, SIGTERM); + saved_handler = CatchSignal( SIGTERM, SIGNAL_CAST SIG_DFL ); /* We only count IPv4, non-loopback interfaces here. */ - while (iface_count_v4_nl() == 0 && !got_sig_term) { + while (iface_count_v4_nl() == 0) { sleep(5); load_interfaces(); } - /* - * Handle termination inband. - */ - - if (got_sig_term) { - got_sig_term = 0; - terminate(); - } + CatchSignal( SIGTERM, SIGNAL_CAST saved_handler ); /* * We got an interface, go back to blocking term. */ - BlockSignals(true, SIGTERM); goto try_again; } } -- cgit From 2630d4a2523894386f4e1a37cfb3a312f4e8fdf5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 23 Jan 2009 10:15:00 +0100 Subject: s3:nmbd: as the sig_term() handler only sets a flag we don't need to block SIGTERM The arguments of commit d98bea900ee694cdba83149620c65bd7f8765f26 are no longer valid. metze --- source3/nmbd/asyncdns.c | 12 ------------ source3/nmbd/nmbd.c | 3 --- source3/nmbd/nmbd_packets.c | 8 -------- 3 files changed, 23 deletions(-) diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c index baa88bc44b..0736a66fb8 100644 --- a/source3/nmbd/asyncdns.c +++ b/source3/nmbd/asyncdns.c @@ -210,9 +210,6 @@ void run_dns_queue(void) if (fd_in == -1) return; - /* Allow SIGTERM to kill us. */ - BlockSignals(False, SIGTERM); - if (!process_exists_by_pid(child_pid)) { close(fd_in); close(fd_out); @@ -224,12 +221,9 @@ void run_dns_queue(void) if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("read from child failed: %s\n", nt_errstr(status))); fd_in = -1; - BlockSignals(True, SIGTERM); return; } - BlockSignals(True, SIGTERM); - namerec = add_dns_result(&r.name, r.result); if (dns_current) { @@ -338,14 +332,8 @@ bool queue_dns_query(struct packet_struct *p,struct nmb_name *question) DEBUG(3,("DNS search for %s - ", nmb_namestr(question))); - /* Unblock TERM signal so we can be killed in DNS lookup. */ - BlockSignals(False, SIGTERM); - dns_ip.s_addr = interpret_addr(qname); - /* Re-block TERM signal. */ - BlockSignals(True, SIGTERM); - namerec = add_dns_result(question, dns_ip); if(namerec == NULL) { send_wins_name_query_response(NAM_ERR, p, NULL); diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 870b9a1f30..1b26c0a5ad 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -969,9 +969,6 @@ static bool open_sockets(bool isdaemon, int port) exit(1); } - /* We can only take signals in the select. */ - BlockSignals( True, SIGTERM ); - TALLOC_FREE(frame); process(); diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c index 489034899e..f69845b346 100644 --- a/source3/nmbd/nmbd_packets.c +++ b/source3/nmbd/nmbd_packets.c @@ -1794,16 +1794,8 @@ bool listen_for_packets(bool run_election) &r_fds, &w_fds, &timeout, &maxfd); } - /* Prepare for the select - allow certain signals. */ - - BlockSignals(False, SIGTERM); - selrtn = sys_select(maxfd+1,&r_fds,&w_fds,NULL,&timeout); - /* We can only take signals when we are in the select - block them again here. */ - - BlockSignals(True, SIGTERM); - if (run_events(nmbd_event_context(), selrtn, &r_fds, &w_fds)) { return False; } -- cgit From d361e332a86075c5c1f76e334b869da8aaa34b01 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 22 Jan 2009 16:17:23 +0100 Subject: s3:nmbd: handle SIG_TERM and SIGHUP via tevent metze --- source3/nmbd/nmbd.c | 115 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 67 insertions(+), 48 deletions(-) diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 1b26c0a5ad..adefb7d94f 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -85,41 +85,80 @@ static void terminate(void) exit(0); } -/**************************************************************************** ** - Handle a SHUTDOWN message from smbcontrol. - **************************************************************************** */ - -static void nmbd_terminate(struct messaging_context *msg, - void *private_data, - uint32_t msg_type, - struct server_id server_id, - DATA_BLOB *data) +static void nmbd_sig_term_handler(struct tevent_context *ev, + struct tevent_signal *se, + int signum, + int count, + void *siginfo, + void *private_data) { terminate(); } -/**************************************************************************** ** - Catch a SIGTERM signal. - **************************************************************************** */ +static bool nmbd_setup_sig_term_handler(void) +{ + struct tevent_signal *se; + + se = tevent_add_signal(nmbd_event_context(), + nmbd_event_context(), + SIGTERM, 0, + nmbd_sig_term_handler, + NULL); + if (!se) { + DEBUG(0,("failed to setup SIGTERM handler")); + return false; + } + + return true; +} -static SIG_ATOMIC_T got_sig_term; +static void msg_reload_nmbd_services(struct messaging_context *msg, + void *private_data, + uint32_t msg_type, + struct server_id server_id, + DATA_BLOB *data); + +static void nmbd_sig_hup_handler(struct tevent_context *ev, + struct tevent_signal *se, + int signum, + int count, + void *siginfo, + void *private_data) +{ + DEBUG(0,("Got SIGHUP dumping debug info.\n")); + msg_reload_nmbd_services(nmbd_messaging_context(), + NULL, MSG_SMB_CONF_UPDATED, + procid_self(), NULL); +} -static void sig_term(int sig) +static bool nmbd_setup_sig_hup_handler(void) { - got_sig_term = 1; - sys_select_signal(SIGTERM); + struct tevent_signal *se; + + se = tevent_add_signal(nmbd_event_context(), + nmbd_event_context(), + SIGHUP, 0, + nmbd_sig_hup_handler, + NULL); + if (!se) { + DEBUG(0,("failed to setup SIGHUP handler")); + return false; + } + + return true; } /**************************************************************************** ** - Catch a SIGHUP signal. + Handle a SHUTDOWN message from smbcontrol. **************************************************************************** */ -static SIG_ATOMIC_T reload_after_sighup; - -static void sig_hup(int sig) +static void nmbd_terminate(struct messaging_context *msg, + void *private_data, + uint32_t msg_type, + struct server_id server_id, + DATA_BLOB *data) { - reload_after_sighup = 1; - sys_select_signal(SIGHUP); + terminate(); } /**************************************************************************** ** @@ -451,15 +490,6 @@ static void process(void) return; } - /* - * Handle termination inband. - */ - - if (got_sig_term) { - got_sig_term = 0; - terminate(); - } - /* * Process all incoming packets * read above. This calls the success and @@ -629,19 +659,6 @@ static void process(void) clear_unexpected(t); - /* - * Reload the services file if we got a sighup. - */ - - if(reload_after_sighup) { - DEBUG( 0, ( "Got SIGHUP dumping debug info.\n" ) ); - msg_reload_nmbd_services(nmbd_messaging_context(), - NULL, MSG_SMB_CONF_UPDATED, - procid_self(), NULL); - - reload_after_sighup = 0; - } - /* check for new network interfaces */ reload_interfaces(t); @@ -807,10 +824,7 @@ static bool open_sockets(bool isdaemon, int port) BlockSignals(False, SIGHUP); BlockSignals(False, SIGUSR1); BlockSignals(False, SIGTERM); - - CatchSignal( SIGHUP, SIGNAL_CAST sig_hup ); - CatchSignal( SIGTERM, SIGNAL_CAST sig_term ); - + #if defined(SIGFPE) /* we are never interested in SIGFPE */ BlockSignals(True,SIGFPE); @@ -905,6 +919,11 @@ static bool open_sockets(bool isdaemon, int port) exit(1); } + if (!nmbd_setup_sig_term_handler()) + exit(1); + if (!nmbd_setup_sig_hup_handler()) + exit(1); + /* get broadcast messages */ claim_connection(NULL,"",FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP); -- cgit From b8c416fe2ac37b3ba0124811cfeddf2015c8d31f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 22 Jan 2009 18:04:17 +0100 Subject: s3:smbd: convert aio to use tevent_signal metze --- source3/include/proto.h | 18 +---- source3/modules/vfs_aio_fork.c | 3 +- source3/smbd/aio.c | 150 ++++++++++++++--------------------------- source3/smbd/globals.c | 3 +- source3/smbd/globals.h | 3 +- 5 files changed, 54 insertions(+), 123 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index d625f98186..dd5b601c2c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6475,8 +6475,6 @@ REGVAL_CTR *svcctl_fetch_regvalues( const char *name, NT_USER_TOKEN *token ); /* The following definitions come from smbd/aio.c */ -void aio_request_done(uint16_t mid); -bool aio_finished(void); void initialize_async_io_handler(void); bool schedule_aio_read_and_X(connection_struct *conn, struct smb_request *req, @@ -6487,23 +6485,9 @@ bool schedule_aio_write_and_X(connection_struct *conn, files_struct *fsp, char *data, SMB_OFF_T startpos, size_t numtowrite); -int process_aio_queue(void); int wait_for_aio_completion(files_struct *fsp); void cancel_aio_by_fsp(files_struct *fsp); -bool aio_finished(void); -void initialize_async_io_handler(void); -int process_aio_queue(void); -bool schedule_aio_read_and_X(connection_struct *conn, - struct smb_request *req, - files_struct *fsp, SMB_OFF_T startpos, - size_t smb_maxcnt); -bool schedule_aio_write_and_X(connection_struct *conn, - struct smb_request *req, - files_struct *fsp, char *data, - SMB_OFF_T startpos, - size_t numtowrite); -void cancel_aio_by_fsp(files_struct *fsp); -int wait_for_aio_completion(files_struct *fsp); +void smbd_aio_complete_mid(unsigned int mid); /* The following definitions come from smbd/blocking.c */ diff --git a/source3/modules/vfs_aio_fork.c b/source3/modules/vfs_aio_fork.c index 30b14f280f..e29ce5e7a8 100644 --- a/source3/modules/vfs_aio_fork.c +++ b/source3/modules/vfs_aio_fork.c @@ -406,8 +406,7 @@ static void handle_aio_completion(struct event_context *event_ctx, DEBUG(10, ("mid %d finished\n", (int)mid)); - aio_request_done(mid); - process_aio_queue(); + smbd_aio_complete_mid(mid); } static int aio_child_destructor(struct aio_child *child) diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index 54ae45a789..4ce43c95e8 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -108,58 +108,6 @@ static struct aio_extra *find_aio_ex(uint16 mid) We can have these many aio buffers in flight. *****************************************************************************/ -/**************************************************************************** - Signal handler when an aio request completes. -*****************************************************************************/ - -void aio_request_done(uint16_t mid) -{ - if (aio_signals_received < aio_pending_size) { - aio_pending_array[aio_signals_received] = mid; - aio_signals_received++; - } - /* Else signal is lost. */ -} - -static void signal_handler(int sig, siginfo_t *info, void *unused) -{ - aio_request_done(info->si_value.sival_int); - sys_select_signal(RT_SIGNAL_AIO); -} - -/**************************************************************************** - Is there a signal waiting ? -*****************************************************************************/ - -bool aio_finished(void) -{ - return (aio_signals_received != 0); -} - -/**************************************************************************** - Initialize the signal handler for aio read/write. -*****************************************************************************/ - -void initialize_async_io_handler(void) -{ - struct sigaction act; - - aio_pending_size = lp_maxmux(); - aio_pending_array = SMB_MALLOC_ARRAY(uint16, aio_pending_size); - SMB_ASSERT(aio_pending_array != NULL); - - ZERO_STRUCT(act); - act.sa_sigaction = signal_handler; - act.sa_flags = SA_SIGINFO; - sigemptyset( &act.sa_mask ); - if (sigaction(RT_SIGNAL_AIO, &act, NULL) != 0) { - DEBUG(0,("Failed to setup RT_SIGNAL_AIO handler\n")); - } - - /* the signal can start off blocked due to a bug in bash */ - BlockSignals(False, RT_SIGNAL_AIO); -} - /**************************************************************************** Set up an aio request from a SMBreadX call. *****************************************************************************/ @@ -573,57 +521,47 @@ static bool handle_aio_completed(struct aio_extra *aio_ex, int *perr) Returns non-zero errno if fail or zero if all ok. *****************************************************************************/ -int process_aio_queue(void) +void smbd_aio_complete_mid(unsigned int mid) { - int i; + files_struct *fsp = NULL; + struct aio_extra *aio_ex = find_aio_ex(mid); int ret = 0; - BlockSignals(True, RT_SIGNAL_AIO); - - DEBUG(10,("process_aio_queue: signals_received = %d\n", - (int)aio_signals_received)); - DEBUG(10,("process_aio_queue: outstanding_aio_calls = %d\n", - outstanding_aio_calls)); + DEBUG(10,("smbd_aio_complete_mid: mid[%u]\n", mid)); - if (!aio_signals_received) { - BlockSignals(False, RT_SIGNAL_AIO); - return 0; + if (!aio_ex) { + DEBUG(3,("smbd_aio_complete_mid: Can't find record to " + "match mid %u.\n", mid)); + srv_cancel_sign_response(mid); + return; } - /* Drain all the complete aio_reads. */ - for (i = 0; i < aio_signals_received; i++) { - uint16 mid = aio_pending_array[i]; - files_struct *fsp = NULL; - struct aio_extra *aio_ex = find_aio_ex(mid); - - if (!aio_ex) { - DEBUG(3,("process_aio_queue: Can't find record to " - "match mid %u.\n", (unsigned int)mid)); - srv_cancel_sign_response(mid); - continue; - } + fsp = aio_ex->fsp; + if (fsp == NULL) { + /* file was closed whilst I/O was outstanding. Just + * ignore. */ + DEBUG( 3,( "smbd_aio_complete_mid: file closed whilst " + "aio outstanding (mid[%u]).\n", mid)); + srv_cancel_sign_response(mid); + return; + } - fsp = aio_ex->fsp; - if (fsp == NULL) { - /* file was closed whilst I/O was outstanding. Just - * ignore. */ - DEBUG( 3,( "process_aio_queue: file closed whilst " - "aio outstanding.\n")); - srv_cancel_sign_response(mid); - continue; - } + if (!handle_aio_completed(aio_ex, &ret)) { + return; + } - if (!handle_aio_completed(aio_ex, &ret)) { - continue; - } + TALLOC_FREE(aio_ex); +} - TALLOC_FREE(aio_ex); - } +static void smbd_aio_signal_handler(struct tevent_context *ev_ctx, + struct tevent_signal *se, + int signum, int count, + void *_info, void *private_data) +{ + siginfo_t *info = (siginfo_t *)_info; + unsigned int mid = (unsigned int)info->si_value.sival_int; - outstanding_aio_calls -= aio_signals_received; - aio_signals_received = 0; - BlockSignals(False, RT_SIGNAL_AIO); - return ret; + smbd_aio_complete_mid(mid); } /**************************************************************************** @@ -755,19 +693,28 @@ void cancel_aio_by_fsp(files_struct *fsp) } } -#else -bool aio_finished(void) -{ - return False; -} +/**************************************************************************** + Initialize the signal handler for aio read/write. +*****************************************************************************/ void initialize_async_io_handler(void) { + aio_signal_event = tevent_add_signal(smbd_event_context(), + smbd_event_context(), + RT_SIGNAL_AIO, SA_SIGINFO, + smbd_aio_signal_handler, + NULL); + if (!aio_signal_event) { + exit_server("Failed to setup RT_SIGNAL_AIO handler"); + } + + /* tevent supports 100 signal with SA_SIGINFO */ + aio_pending_size = 100; } -int process_aio_queue(void) +#else +void initialize_async_io_handler(void) { - return False; } bool schedule_aio_read_and_X(connection_struct *conn, @@ -795,4 +742,7 @@ int wait_for_aio_completion(files_struct *fsp) { return ENOSYS; } + +void smbd_aio_complete_mid(unsigned int mid); + #endif diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c index d99f2b0680..28b5a709bd 100644 --- a/source3/smbd/globals.c +++ b/source3/smbd/globals.c @@ -22,10 +22,9 @@ #if defined(WITH_AIO) struct aio_extra *aio_list_head = NULL; +struct tevent_signal *aio_signal_event = NULL; int aio_pending_size = 0; -sig_atomic_t aio_signals_received = 0; int outstanding_aio_calls = 0; -uint16 *aio_pending_array = NULL; #endif /* dlink list we store pending lock records on. */ diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 15085d9d35..283425caf7 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -20,10 +20,9 @@ #if defined(WITH_AIO) struct aio_extra; extern struct aio_extra *aio_list_head; +extern struct tevent_signal *aio_signal_event; extern int aio_pending_size; -extern sig_atomic_t aio_signals_received; extern int outstanding_aio_calls; -extern uint16_t *aio_pending_array; #endif /* dlink list we store pending lock records on. */ -- cgit From 4a2271349503933776f9d2791edfcb874a2c7261 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 23 Jan 2009 10:07:45 +0100 Subject: s3:smbd: remove pointless respond_to_all_remaining_local_messages() function This the process_kernel_oplock() function never response to messages, it only generates messages to ourself. metze --- source3/include/proto.h | 1 - source3/smbd/process.c | 25 ------------------------- source3/smbd/server.c | 2 -- 3 files changed, 28 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index dd5b601c2c..1713760666 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -7126,7 +7126,6 @@ struct idle_event *event_add_idle(struct event_context *event_ctx, void *private_data), void *private_data); NTSTATUS allow_new_trans(struct trans_state *list, int mid); -void respond_to_all_remaining_local_messages(void); void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes); const char *smb_fn_name(int type); void add_to_common_flags2(uint32 v); diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 2326bdab90..9527d94825 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -904,31 +904,6 @@ NTSTATUS allow_new_trans(struct trans_state *list, int mid) return NT_STATUS_OK; } -/**************************************************************************** - We're terminating and have closed all our files/connections etc. - If there are any pending local messages we need to respond to them - before termination so that other smbds don't think we just died whilst - holding oplocks. -****************************************************************************/ - -void respond_to_all_remaining_local_messages(void) -{ - /* - * Assert we have no exclusive open oplocks. - */ - - if(get_number_of_exclusive_open_oplocks()) { - DEBUG(0,("respond_to_all_remaining_local_messages: PANIC : we have %d exclusive oplocks.\n", - get_number_of_exclusive_open_oplocks() )); - return; - } - - process_kernel_oplocks(smbd_messaging_context()); - - return; -} - - /* These flags determine some of the permissions required to do an operation diff --git a/source3/smbd/server.c b/source3/smbd/server.c index e6ea5f3986..7bc96ff5fb 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -832,8 +832,6 @@ static void exit_server_common(enum server_exit_reason how, /* delete our entry in the connections database. */ yield_connection(NULL,""); - respond_to_all_remaining_local_messages(); - #ifdef WITH_DFS if (dcelogin_atmost_once) { dfs_unlogin(); -- cgit From 52f6a4436f9da439fc687894b329898833af7ff8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 23 Jan 2009 10:08:44 +0100 Subject: s3:smbd: make kernel oplocks event driven And use signal events for Linux oplocks. metze --- source3/include/proto.h | 4 +-- source3/include/smb.h | 2 -- source3/smbd/globals.c | 9 ------ source3/smbd/globals.h | 6 ---- source3/smbd/oplock.c | 64 ++++++++------------------------------- source3/smbd/oplock_irix.c | 15 ++------- source3/smbd/oplock_linux.c | 66 +++++++++++----------------------------- source3/smbd/process.c | 74 --------------------------------------------- 8 files changed, 34 insertions(+), 206 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 1713760666..ae49290539 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -7018,13 +7018,11 @@ NTSTATUS get_relative_fid_filename(connection_struct *conn, /* The following definitions come from smbd/oplock.c */ int32 get_number_of_exclusive_open_oplocks(void); -bool oplock_message_waiting(void); -void process_kernel_oplocks(struct messaging_context *msg_ctx); +void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp); bool set_file_oplock(files_struct *fsp, int oplock_type); void release_file_oplock(files_struct *fsp); bool remove_oplock(files_struct *fsp); bool downgrade_oplock(files_struct *fsp); -int oplock_notify_fd(void); void reply_to_oplock_break_requests(files_struct *fsp); void release_level_2_oplocks_on_change(files_struct *fsp); void share_mode_entry_to_message(char *msg, const struct share_mode_entry *e); diff --git a/source3/include/smb.h b/source3/include/smb.h index aa2db693a3..3f71cde395 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -1680,12 +1680,10 @@ struct kernel_oplocks { /* if a kernel does support oplocks then a structure of the following typee is used to describe how to interact with the kernel */ struct kernel_oplocks_ops { - files_struct * (*receive_message)(struct kernel_oplocks *ctx); bool (*set_oplock)(struct kernel_oplocks *ctx, files_struct *fsp, int oplock_type); void (*release_oplock)(struct kernel_oplocks *ctx, files_struct *fsp); - bool (*msg_waiting)(struct kernel_oplocks *ctx); }; #include "smb_macros.h" diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c index 28b5a709bd..3f8cb411e5 100644 --- a/source3/smbd/globals.c +++ b/source3/smbd/globals.c @@ -169,11 +169,6 @@ struct vfs_init_function_entry *backends = NULL; char *sparse_buf = NULL; char *LastDir = NULL; -#if HAVE_KERNEL_OPLOCKS_LINUX -SIG_ATOMIC_T oplock_signals_received = 0; -SIG_ATOMIC_T fd_pending_array[FD_PENDING_SIZE]; -#endif - /* Current number of oplocks we have outstanding. */ int32_t exclusive_oplocks_open = 0; int32_t level_II_oplocks_open = 0; @@ -201,8 +196,4 @@ void smbd_init_globals(void) ZERO_STRUCT(conn_ctx_stack); ZERO_STRUCT(sec_ctx_stack); - -#if HAVE_KERNEL_OPLOCKS_LINUX - ZERO_STRUCT(fd_pending_array); -#endif } diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 283425caf7..6ac92ed3dd 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -181,12 +181,6 @@ extern struct vfs_init_function_entry *backends; extern char *sparse_buf; extern char *LastDir; -#if HAVE_KERNEL_OPLOCKS_LINUX -extern SIG_ATOMIC_T oplock_signals_received; -#define FD_PENDING_SIZE 100 -extern SIG_ATOMIC_T fd_pending_array[FD_PENDING_SIZE]; -#endif - /* Current number of oplocks we have outstanding. */ extern int32_t exclusive_oplocks_open; extern int32_t level_II_oplocks_open; diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index e4b5016538..788d2f7238 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -32,61 +32,23 @@ int32 get_number_of_exclusive_open_oplocks(void) return exclusive_oplocks_open; } -/**************************************************************************** - Return True if an oplock message is pending. -****************************************************************************/ - -bool oplock_message_waiting(void) -{ - if (koplocks && koplocks->ops->msg_waiting(koplocks)) { - return True; - } - - return False; -} - -/**************************************************************************** - Find out if there are any kernel oplock messages waiting and process them - if so. pfds is the fd_set from the main select loop (which contains any - kernel oplock fd if that's what the system uses (IRIX). If may be NULL if - we're calling this in a shutting down state. -****************************************************************************/ - -void process_kernel_oplocks(struct messaging_context *msg_ctx) +/* + * helper function used by the kernel oplock backends to post the break message + */ +void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp) { - /* - * We need to check for kernel oplocks before going into the select - * here, as the EINTR generated by the linux kernel oplock may have - * already been eaten. JRA. - */ - - if (!koplocks) { - return; - } + uint8_t msg[MSG_SMB_KERNEL_BREAK_SIZE]; - while (koplocks->ops->msg_waiting(koplocks)) { - files_struct *fsp; - char msg[MSG_SMB_KERNEL_BREAK_SIZE]; + /* Put the kernel break info into the message. */ + push_file_id_16((char *)msg, &fsp->file_id); + SIVAL(msg,16,fsp->fh->gen_id); - fsp = koplocks->ops->receive_message(koplocks); + /* Don't need to be root here as we're only ever + sending to ourselves. */ - if (fsp == NULL) { - DEBUG(3, ("Kernel oplock message announced, but none " - "received\n")); - return; - } - - /* Put the kernel break info into the message. */ - push_file_id_16(msg, &fsp->file_id); - SIVAL(msg,16,fsp->fh->gen_id); - - /* Don't need to be root here as we're only ever - sending to ourselves. */ - - messaging_send_buf(msg_ctx, procid_self(), - MSG_SMB_KERNEL_BREAK, - (uint8 *)&msg, MSG_SMB_KERNEL_BREAK_SIZE); - } + messaging_send_buf(msg_ctx, procid_self(), + MSG_SMB_KERNEL_BREAK, + msg, MSG_SMB_KERNEL_BREAK_SIZE); } /**************************************************************************** diff --git a/source3/smbd/oplock_irix.c b/source3/smbd/oplock_irix.c index 0cfa960425..d7f45e67de 100644 --- a/source3/smbd/oplock_irix.c +++ b/source3/smbd/oplock_irix.c @@ -252,13 +252,6 @@ static void irix_release_kernel_oplock(struct kernel_oplocks *_ctx, } } -static bool irix_oplock_msg_waiting(struct kernel_oplocks *_ctx) -{ - struct irix_oplocks_context *ctx = talloc_get_type(_ctx->private_data, - struct irix_oplocks_context); - return ctx->pending; -} - static void irix_oplocks_read_fde_handler(struct event_context *ev, struct fd_event *fde, uint16_t flags, @@ -266,10 +259,10 @@ static void irix_oplocks_read_fde_handler(struct event_context *ev, { struct irix_oplocks_context *ctx = talloc_get_type(private_data, struct irix_oplocks_context); + files_struct *fsp; - ctx->pending = true; - process_kernel_oplocks(smbd_messaging_context()); - ctx->pending = false; + fsp = irix_oplock_receive_message(ctx->ctx); + break_kernel_oplock(smbd_messaging_context(), fsp); } /**************************************************************************** @@ -277,10 +270,8 @@ static void irix_oplocks_read_fde_handler(struct event_context *ev, ****************************************************************************/ static const struct kernel_oplocks_ops irix_koplocks = { - .receive_message = irix_oplock_receive_message, .set_oplock = irix_set_kernel_oplock, .release_oplock = irix_release_kernel_oplock, - .msg_waiting = irix_oplock_msg_waiting }; struct kernel_oplocks *irix_init_kernel_oplocks(TALLOC_CTX *mem_ctx) diff --git a/source3/smbd/oplock_linux.c b/source3/smbd/oplock_linux.c index 8087167ff4..51cce0ed48 100644 --- a/source3/smbd/oplock_linux.c +++ b/source3/smbd/oplock_linux.c @@ -43,19 +43,6 @@ #define F_SETSIG 10 #endif -/**************************************************************************** - Handle a LEASE signal, incrementing the signals_received and blocking the signal. -****************************************************************************/ - -static void signal_handler(int sig, siginfo_t *info, void *unused) -{ - if (oplock_signals_received < FD_PENDING_SIZE - 1) { - fd_pending_array[oplock_signals_received] = (SIG_ATOMIC_T)info->si_fd; - oplock_signals_received++; - } /* Else signal is lost. */ - sys_select_signal(RT_SIGNAL_LEASE); -} - /* * public function to get linux lease capability. Needed by some VFS modules (eg. gpfs.c) */ @@ -101,24 +88,17 @@ int linux_setlease(int fd, int leasetype) * oplock break protocol. ****************************************************************************/ -static files_struct *linux_oplock_receive_message(struct kernel_oplocks *ctx) +static void linux_oplock_signal_handler(struct tevent_context *ev_ctx, + struct tevent_signal *se, + int signum, int count, + void *_info, void *private_data) { - int fd; + siginfo_t *info = (siginfo_t *)_info; + int fd = info->si_fd; files_struct *fsp; - BlockSignals(True, RT_SIGNAL_LEASE); - fd = fd_pending_array[0]; fsp = file_find_fd(fd); - fd_pending_array[0] = (SIG_ATOMIC_T)-1; - if (oplock_signals_received > 1) - memmove(CONST_DISCARD(void *, &fd_pending_array[0]), - CONST_DISCARD(void *, &fd_pending_array[1]), - sizeof(SIG_ATOMIC_T)*(oplock_signals_received-1)); - oplock_signals_received--; - /* now we can receive more signals */ - BlockSignals(False, RT_SIGNAL_LEASE); - - return fsp; + break_kernel_oplock(smbd_messaging_context(), fsp); } /**************************************************************************** @@ -179,15 +159,6 @@ static void linux_release_kernel_oplock(struct kernel_oplocks *ctx, } } -/**************************************************************************** - See if a oplock message is waiting. -****************************************************************************/ - -static bool linux_oplock_msg_waiting(struct kernel_oplocks *ctx) -{ - return oplock_signals_received != 0; -} - /**************************************************************************** See if the kernel supports oplocks. ****************************************************************************/ @@ -208,16 +179,14 @@ static bool linux_oplocks_available(void) ****************************************************************************/ static const struct kernel_oplocks_ops linux_koplocks = { - .receive_message = linux_oplock_receive_message, .set_oplock = linux_set_kernel_oplock, .release_oplock = linux_release_kernel_oplock, - .msg_waiting = linux_oplock_msg_waiting }; struct kernel_oplocks *linux_init_kernel_oplocks(TALLOC_CTX *mem_ctx) { - struct sigaction act; struct kernel_oplocks *ctx; + struct tevent_signal *se; if (!linux_oplocks_available()) { DEBUG(3,("Linux kernel oplocks not available\n")); @@ -232,19 +201,18 @@ struct kernel_oplocks *linux_init_kernel_oplocks(TALLOC_CTX *mem_ctx) ctx->ops = &linux_koplocks; - ZERO_STRUCT(act); - - act.sa_handler = NULL; - act.sa_sigaction = signal_handler; - act.sa_flags = SA_SIGINFO; - sigemptyset( &act.sa_mask ); - if (sigaction(RT_SIGNAL_LEASE, &act, NULL) != 0) { - DEBUG(0,("Failed to setup RT_SIGNAL_LEASE handler\n")); + se = tevent_add_signal(smbd_event_context(), + ctx, + RT_SIGNAL_LEASE, SA_SIGINFO, + linux_oplock_signal_handler, + ctx); + if (!se) { + DEBUG(0,("Failed to setup RT_SIGNAL_LEASE handler")); + TALLOC_FREE(ctx); return NULL; } - /* the signal can start off blocked due to a bug in bash */ - BlockSignals(False, RT_SIGNAL_LEASE); + ctx->private_data = se; DEBUG(3,("Linux kernel oplocks enabled\n")); diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 9527d94825..d617ef1915 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -742,46 +742,6 @@ void smbd_setup_sig_hup_handler(void) } } -/**************************************************************************** - Do all async processing in here. This includes kernel oplock messages, change - notify events etc. -****************************************************************************/ - -static void async_processing(void) -{ - DEBUG(10,("async_processing: Doing async processing.\n")); - - process_aio_queue(); - - process_kernel_oplocks(smbd_messaging_context()); - - /* Do the aio check again after receive_local_message as it does a - select and may have eaten our signal. */ - /* Is this till true? -- vl */ - process_aio_queue(); -} - -/**************************************************************************** - Do a select on an two fd's - with timeout. - - If a local udp message has been pushed onto the - queue (this can only happen during oplock break - processing) call async_processing() - - If a pending smb message has been pushed onto the - queue (this can only happen during oplock break - processing) return this next. - - If the first smbfd is ready then read an smb from it. - if the second (loopback UDP) fd is ready then read a message - from it and setup the buffer header to identify the length - and from address. - Returns False on timeout or error. - Else returns True. - -The timeout is in milliseconds -****************************************************************************/ - static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection *conn) { fd_set r_fds, w_fds; @@ -799,26 +759,6 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection * FD_ZERO(&r_fds); FD_ZERO(&w_fds); - /* - * Ensure we process oplock break messages by preference. - * We have to do this before the select, after the select - * and if the select returns EINTR. This is due to the fact - * that the selects called from async_processing can eat an EINTR - * caused by a signal (we can't take the break message there). - * This is hideously complex - *MUST* be simplified for 3.0 ! JRA. - */ - - if (oplock_message_waiting()) { - DEBUG(10,("receive_message_or_smb: oplock_message is waiting.\n")); - async_processing(); - /* - * After async processing we must go and do the select again, as - * the state of the flag in fds for the server file descriptor is - * indeterminate - we may have done I/O on it in the oplock processing. JRA. - */ - return NT_STATUS_RETRY; - } - /* * Are there any timed events waiting ? If so, ensure we don't * select for longer than it would take to wait for them. @@ -852,20 +792,6 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection * return NT_STATUS_RETRY; } - /* if we get EINTR then maybe we have received an oplock - signal - treat this as select returning 1. This is ugly, but - is the best we can do until the oplock code knows more about - signals */ - if (selrtn == -1 && errno == EINTR) { - async_processing(); - /* - * After async processing we must go and do the select again, as - * the state of the flag in fds for the server file descriptor is - * indeterminate - we may have done I/O on it in the oplock processing. JRA. - */ - return NT_STATUS_RETRY; - } - /* Check if error */ if (selrtn == -1) { /* something is wrong. Maybe the socket is dead? */ -- cgit From e11e82318c92fdfdc231eb48abb2fb6faac3dcf0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 23 Jan 2009 13:08:22 +0100 Subject: s3:smbd: make inetd code path more clear metze --- source3/smbd/server.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 7bc96ff5fb..f95fa874ff 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -136,24 +136,6 @@ static void msg_sam_sync(struct messaging_context *msg, DEBUG(10, ("** sam sync message received, ignoring\n")); } - -/**************************************************************************** - Open the socket communication - inetd. -****************************************************************************/ - -static bool open_sockets_inetd(void) -{ - /* Started from inetd. fd 0 is the socket. */ - /* We will abort gracefully when the client or remote system - goes away */ - smbd_set_server_fd(dup(0)); - - /* close our standard file descriptors */ - close_low_fds(False); /* Don't close stderr */ - - return True; -} - static void msg_exit_server(struct messaging_context *msg, void *private_data, uint32_t msg_type, @@ -317,7 +299,7 @@ static void smbd_setup_sig_chld_handler(void) Open the socket communication. ****************************************************************************/ -static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ports) +static bool open_sockets_smbd(bool interactive, const char *smb_ports) { int num_interfaces = iface_count(); int num_sockets = 0; @@ -330,10 +312,6 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ struct dns_reg_state * dns_reg = NULL; unsigned dns_port = 0; - if (!is_daemon) { - return open_sockets_inetd(); - } - #ifdef HAVE_ATEXIT atexit(killkids); #endif @@ -1224,7 +1202,25 @@ extern void build_options(bool screen); start_background_queue(); } - if (!open_sockets_smbd(is_daemon, interactive, ports)) + if (!is_daemon) { + /* inetd mode */ + TALLOC_FREE(frame); + + /* Started from inetd. fd 0 is the socket. */ + /* We will abort gracefully when the client or remote system + goes away */ + smbd_set_server_fd(dup(0)); + + /* close our standard file descriptors */ + close_low_fds(False); /* Don't close stderr */ + + smbd_process(); + + exit_server_cleanly(NULL); + return(0); + } + + if (!open_sockets_smbd(interactive, ports)) exit(1); TALLOC_FREE(frame); -- cgit From bf2347bd7df19156da8a2884e41ca5b98a3c94c6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 26 Jan 2009 14:55:54 +0100 Subject: s3:smbd: make mdns registration event driven. metze --- source3/include/includes.h | 14 --- source3/include/proto.h | 11 +-- source3/smbd/dnsregister.c | 208 +++++++++++++++++++++------------------------ source3/smbd/server.c | 25 +++--- 4 files changed, 111 insertions(+), 147 deletions(-) diff --git a/source3/include/includes.h b/source3/include/includes.h index 50140c17f7..ea856f1c16 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -678,20 +678,6 @@ struct printjob; #include "smb_ldap.h" -struct dns_reg_state; - -void dns_register_smbd(struct dns_reg_state ** dns_state_ptr, - unsigned port, - int *maxfd, - fd_set *listen_set, - struct timeval *timeout); - -void dns_register_close(struct dns_reg_state ** dns_state_ptr); - - -bool dns_register_smbd_reply(struct dns_reg_state *dns_state, - fd_set *lfds, struct timeval *timeout); - /* * Reasons for cache flush. */ diff --git a/source3/include/proto.h b/source3/include/proto.h index ae49290539..f8a9dbce66 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6651,14 +6651,9 @@ uint32 dmapi_file_flags(const char * const path); /* The following definitions come from smbd/dnsregister.c */ -void dns_register_close(struct dns_reg_state **dns_state_ptr); -void dns_register_smbd(struct dns_reg_state ** dns_state_ptr, - unsigned port, - int *maxfd, - fd_set *listen_set, - struct timeval *timeout); -bool dns_register_smbd_reply(struct dns_reg_state *dns_state, - fd_set *lfds, struct timeval *timeout); +bool smbd_setup_mdns_registration(struct tevent_context *ev, + TALLOC_CTX *mem_ctx, + uint16_t port); /* The following definitions come from smbd/dosmode.c */ diff --git a/source3/smbd/dnsregister.c b/source3/smbd/dnsregister.c index c092251fee..2fd95f9fb7 100644 --- a/source3/smbd/dnsregister.c +++ b/source3/smbd/dnsregister.c @@ -35,18 +35,16 @@ #include struct dns_reg_state { + struct tevent_context *event_ctx; + uint16_t port; DNSServiceRef srv_ref; - struct timed_event *retry_handler; + struct tevent_timer *te; + int fd; + struct tevent_fd *fde; }; -void dns_register_close(struct dns_reg_state **dns_state_ptr) +static int dns_reg_state_destructor(struct dns_reg_state *dns_state) { - struct dns_reg_state *dns_state = *dns_state_ptr; - - if (dns_state == NULL) { - return; - } - if (dns_state->srv_ref != NULL) { /* Close connection to the mDNS daemon */ DNSServiceRefDeallocate(dns_state->srv_ref); @@ -54,81 +52,52 @@ void dns_register_close(struct dns_reg_state **dns_state_ptr) } /* Clear event handler */ - if (dns_state->retry_handler != NULL) { - TALLOC_FREE(dns_state->retry_handler); - dns_state->retry_handler = NULL; - } + TALLOC_FREE(dns_state->te); + TALLOC_FREE(dns_state->fde); + dns_state->fd = -1; - talloc_free(dns_state); - *dns_state_ptr = NULL; + return 0; } -static void dns_register_smbd_retry(struct event_context *ctx, - struct timed_event *te, - const struct timeval *now, - void *private_data) +static void dns_register_smbd_retry(struct tevent_context *ctx, + struct tevent_timer *te, + struct timeval now, + void *private_data); +static void dns_register_smbd_fde_handler(struct tevent_context *ev, + struct tevent_fd *fde, + uint16_t flags, + void *private_data); + +static bool dns_register_smbd_schedule(struct dns_reg_state *dns_state, + struct timeval tval) { - struct dns_reg_state *dns_state = (struct dns_reg_state *)private_data; - - /* Clear previous registration state to force new - * registration attempt. Clears event handler. - */ - dns_register_close(&dns_state); -} - -static void schedule_dns_register_smbd_retry(struct dns_reg_state *dns_state, - struct timeval *timeout) -{ - struct timed_event * event; - - dns_state->srv_ref = NULL; - event= event_add_timed(smbd_event_context(), - NULL, - timeval_current_ofs(DNS_REG_RETRY_INTERVAL, 0), - dns_register_smbd_retry, - dns_state); + dns_reg_state_destructor(dns_state); + + dns_state->te = tevent_add_timer(dns_state->event_ctx, + dns_state, + tval, + dns_register_smbd_retry, + dns_state); + if (!dns_state->te) { + return false; + } - dns_state->retry_handler = event; - get_timed_events_timeout(smbd_event_context(), timeout); + return true; } -/* Kick off a mDNS request to register the "_smb._tcp" on the specified port. - * We really ought to register on all the ports we are listening on. This will - * have to be an exercise for some-one who knows the DNS registration API a bit - * better. - */ -void dns_register_smbd(struct dns_reg_state ** dns_state_ptr, - unsigned port, - int *maxfd, - fd_set *listen_set, - struct timeval *timeout) +static void dns_register_smbd_retry(struct tevent_context *ctx, + struct tevent_timer *te, + struct timeval now, + void *private_data) { - int mdnsd_conn_fd; + struct dns_reg_state *dns_state = talloc_get_type_abort(private_data, + struct dns_reg_state); DNSServiceErrorType err; - struct dns_reg_state *dns_state = *dns_state_ptr; - - if (dns_state == NULL) { - *dns_state_ptr = dns_state = talloc(NULL, struct dns_reg_state); - if (dns_state == NULL) { - return; - } - } - - /* Quit if a re-try attempt has been scheduled. */ - if (dns_state->retry_handler != NULL) { - return; - } - /* If a registration is active add conn - * fd to select listen_set and return - */ - if (dns_state->srv_ref != NULL) { - mdnsd_conn_fd = DNSServiceRefSockFD(dns_state->srv_ref); - FD_SET(mdnsd_conn_fd, listen_set); - return; - } + dns_reg_state_destructor(dns_state); - DEBUG(6, ("registering _smb._tcp service on port %d\n", port)); + DEBUG(6, ("registering _smb._tcp service on port %d\n", + dns_state->port)); /* Register service with DNS. Connects with the mDNS * daemon running on the local system to perform DNS @@ -140,7 +109,7 @@ void dns_register_smbd(struct dns_reg_state ** dns_state_ptr, "_smb._tcp" /* service type */, NULL /* domain */, "" /* SRV target host name */, - htons(port), + htons(dns_state->port), 0 /* TXT record len */, NULL /* TXT record data */, NULL /* callback func */, @@ -150,62 +119,81 @@ void dns_register_smbd(struct dns_reg_state ** dns_state_ptr, /* Failed to register service. Schedule a re-try attempt. */ DEBUG(3, ("unable to register with mDNS (err %d)\n", err)); - schedule_dns_register_smbd_retry(dns_state, timeout); - return; + goto retry; + } + + dns_state->fd = DNSServiceRefSockFD(dns_state->srv_ref); + if (dns_state->fd == -1) { + goto retry; } - mdnsd_conn_fd = DNSServiceRefSockFD(dns_state->srv_ref); - FD_SET(mdnsd_conn_fd, listen_set); - *maxfd = MAX(*maxfd, mdnsd_conn_fd); - *timeout = timeval_zero(); + dns_state->fde = tevent_add_fd(dns_state->event_ctx, + dns_state, + dns_state->fd, + TEVENT_FD_READ, + dns_register_smbd_fde_handler, + dns_state); + if (!dns_state->fde) { + goto retry; + } + return; + retry: + dns_register_smbd_schedule(dns_state, + timeval_current_ofs(DNS_REG_RETRY_INTERVAL, 0)); } /* Processes reply from mDNS daemon. Returns true if a reply was received */ -bool dns_register_smbd_reply(struct dns_reg_state *dns_state, - fd_set *lfds, struct timeval *timeout) +static void dns_register_smbd_fde_handler(struct tevent_context *ev, + struct tevent_fd *fde, + uint16_t flags, + void *private_data) { - int mdnsd_conn_fd = -1; + struct dns_reg_state *dns_state = talloc_get_type_abort(private_data, + struct dns_reg_state); + DNSServiceErrorType err; - if (dns_state->srv_ref == NULL) { - return false; + err = DNSServiceProcessResult(dns_state->srv_ref); + if (err != kDNSServiceErr_NoError) { + DEBUG(3, ("failed to process mDNS result (err %d), re-trying\n", + err)); + goto retry; } - mdnsd_conn_fd = DNSServiceRefSockFD(dns_state->srv_ref); + talloc_free(dns_state); + return; - /* Process reply from daemon. Handles any errors. */ - if ((mdnsd_conn_fd != -1) && (FD_ISSET(mdnsd_conn_fd,lfds)) ) { - DNSServiceErrorType err; - - err = DNSServiceProcessResult(dns_state->srv_ref); - if (err != kDNSServiceErr_NoError) { - DEBUG(3, ("failed to process mDNS result (err %d), re-trying\n", - err)); - schedule_dns_register_smbd_retry(dns_state, timeout); - } + retry: + dns_register_smbd_schedule(dns_state, + timeval_current_ofs(DNS_REG_RETRY_INTERVAL, 0)); +} - return true; +bool smbd_setup_mdns_registration(struct tevent_context *ev, + TALLOC_CTX *mem_ctx, + uint16_t port) +{ + struct dns_reg_state *dns_state; + + dns_state = talloc_zero(mem_ctx, struct dns_reg_state); + if (dns_state == NULL) { + return false; } + dns_state->event_ctx = ev; + dns_state->port = port; + dns_state->fd = -1; + + talloc_set_destructor(dns_state, dns_reg_state_destructor); - return false; + return dns_register_smbd_schedule(dns_state, timeval_zero()); } #else /* WITH_DNSSD_SUPPORT */ - void dns_register_smbd(struct dns_reg_state ** dns_state_ptr, - unsigned port, - int *maxfd, - fd_set *listen_set, - struct timeval *timeout) -{} - - void dns_register_close(struct dns_reg_state ** dns_state_ptr) -{} - - bool dns_register_smbd_reply(struct dns_reg_state *dns_state, - fd_set *lfds, struct timeval *timeout) +bool smbd_setup_mdns_registration(struct tevent_context *ev, + TALLOC_CTX *mem_ctx, + uint16_t port) { - return false; + return true; } #endif /* WITH_DNSSD_SUPPORT */ diff --git a/source3/smbd/server.c b/source3/smbd/server.c index f95fa874ff..d71a04ebc1 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -309,13 +309,15 @@ static bool open_sockets_smbd(bool interactive, const char *smb_ports) int maxfd = 0; int i; char *ports; - struct dns_reg_state * dns_reg = NULL; + TALLOC_CTX *dns_ctx = NULL; unsigned dns_port = 0; #ifdef HAVE_ATEXIT atexit(killkids); #endif + dns_ctx = talloc_new(NULL); + /* Stop zombies */ smbd_setup_sig_chld_handler(); @@ -535,6 +537,11 @@ static bool open_sockets_smbd(bool interactive, const char *smb_ports) MSG_SMB_INJECT_FAULT, msg_inject_fault); #endif + if (dns_port != 0) { + smbd_setup_mdns_registration(smbd_event_context(), + dns_ctx, dns_port); + } + /* now accept incoming connections - forking a new process for each incoming connection */ DEBUG(2,("waiting for a connection\n")); @@ -554,12 +561,6 @@ static bool open_sockets_smbd(bool interactive, const char *smb_ports) FD_ZERO(&w_fds); GetTimeOfDay(&now); - /* Kick off our mDNS registration. */ - if (dns_port != 0) { - dns_register_smbd(&dns_reg, dns_port, &maxfd, - &r_fds, &idle_timeout); - } - event_add_to_select_args(smbd_event_context(), &now, &r_fds, &w_fds, &idle_timeout, &maxfd); @@ -580,11 +581,6 @@ static bool open_sockets_smbd(bool interactive, const char *smb_ports) exit_server_cleanly("idle timeout"); } - /* process pending nDNS responses */ - if (dns_register_smbd_reply(dns_reg, &r_fds, &idle_timeout)) { - --num; - } - /* check if we need to reload services */ check_reload(time(NULL)); @@ -624,6 +620,8 @@ static bool open_sockets_smbd(bool interactive, const char *smb_ports) ((child = sys_fork())==0)) { /* Child code ... */ + TALLOC_FREE(dns_ctx); + /* Stop zombies, the parent explicitly handles * them, counting worker smbds. */ CatchChild(); @@ -632,9 +630,6 @@ static bool open_sockets_smbd(bool interactive, const char *smb_ports) for(i = 0; i < num_sockets; i++) close(fd_listenset[i]); - /* close our mDNS daemon handle */ - dns_register_close(&dns_reg); - /* close our standard file descriptors */ close_low_fds(False); -- cgit From e0232934fbf69a9e72de1d9844b14d70b34a2d6a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 27 Jan 2009 10:02:43 +0100 Subject: s3:smbd: wait for new connection via fd events metze --- source3/smbd/server.c | 438 ++++++++++++++++++++++++++------------------------ 1 file changed, 227 insertions(+), 211 deletions(-) diff --git a/source3/smbd/server.c b/source3/smbd/server.c index d71a04ebc1..7644cebe69 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -295,44 +295,224 @@ static void smbd_setup_sig_chld_handler(void) } } +struct smbd_open_socket; + +struct smbd_parent_context { + bool interactive; + + /* the list of listening sockets */ + struct smbd_open_socket *sockets; +}; + +struct smbd_open_socket { + struct smbd_open_socket *prev, *next; + struct smbd_parent_context *parent; + int fd; + struct tevent_fd *fde; +}; + +static void smbd_open_socket_close_fn(struct tevent_context *ev, + struct tevent_fd *fde, + int fd, + void *private_data) +{ + /* this might be the socket_wrapper swrap_close() */ + close(fd); +} + +static void smbd_accept_connection(struct tevent_context *ev, + struct tevent_fd *fde, + uint16_t flags, + void *private_data) +{ + struct smbd_open_socket *s = talloc_get_type_abort(private_data, + struct smbd_open_socket); + struct sockaddr_storage addr; + socklen_t in_addrlen = sizeof(addr); + pid_t pid = 0; + + smbd_set_server_fd(accept(s->fd,(struct sockaddr *)&addr,&in_addrlen)); + + if (smbd_server_fd() == -1 && errno == EINTR) + return; + + if (smbd_server_fd() == -1) { + DEBUG(0,("open_sockets_smbd: accept: %s\n", + strerror(errno))); + return; + } + + if (s->parent->interactive) { + smbd_process(); + exit_server_cleanly("end of interactive mode"); + return; + } + + if (!allowable_number_of_smbd_processes()) { + close(smbd_server_fd()); + smbd_set_server_fd(-1); + return; + } + + pid = sys_fork(); + if (pid == 0) { + /* Child code ... */ + am_parent = 0; + + /* Stop zombies, the parent explicitly handles + * them, counting worker smbds. */ + CatchChild(); + + /* close our standard file + descriptors */ + close_low_fds(False); + + TALLOC_FREE(s->parent); + s = NULL; + + if (!reinit_after_fork( + smbd_messaging_context(), + smbd_event_context(), + true)) { + DEBUG(0,("reinit_after_fork() failed\n")); + smb_panic("reinit_after_fork() failed"); + } + + smbd_setup_sig_term_handler(); + smbd_setup_sig_hup_handler(); + + smbd_process(); + exit_server_cleanly("end of child"); + return; + } else if (pid < 0) { + DEBUG(0,("smbd_accept_connection: sys_fork() failed: %s\n", + strerror(errno))); + } + + /* The parent doesn't need this socket */ + close(smbd_server_fd()); + + /* Sun May 6 18:56:14 2001 ackley@cs.unm.edu: + Clear the closed fd info out of server_fd -- + and more importantly, out of client_fd in + util_sock.c, to avoid a possible + getpeername failure if we reopen the logs + and use %I in the filename. + */ + + smbd_set_server_fd(-1); + + if (pid != 0) { + add_child_pid(pid); + } + + /* Force parent to check log size after + * spawning child. Fix from + * klausr@ITAP.Physik.Uni-Stuttgart.De. The + * parent smbd will log to logserver.smb. It + * writes only two messages for each child + * started/finished. But each child writes, + * say, 50 messages also in logserver.smb, + * begining with the debug_count of the + * parent, before the child opens its own log + * file logserver.client. In a worst case + * scenario the size of logserver.smb would be + * checked after about 50*50=2500 messages + * (ca. 100kb). + * */ + force_check_log_size(); +} + +bool smbd_open_one_socket(struct smbd_parent_context *parent, + const struct sockaddr_storage *ifss, + uint16_t port) +{ + struct smbd_open_socket *s; + + s = talloc(parent, struct smbd_open_socket); + if (!s) { + return false; + } + + s->parent = parent; + s->fd = open_socket_in(SOCK_STREAM, + port, + parent->sockets == NULL ? 0 : 2, + ifss, + true); + if (s->fd == -1) { + DEBUG(0,("smbd_open_once_socket: open_socket_in: " + "%s\n", strerror(errno))); + close(s->fd); + TALLOC_FREE(s); + return false; + } + + /* ready to listen */ + set_socket_options(s->fd, "SO_KEEPALIVE"); + set_socket_options(s->fd, lp_socket_options()); + + /* Set server socket to + * non-blocking for the accept. */ + set_blocking(s->fd, False); + + if (listen(s->fd, SMBD_LISTEN_BACKLOG) == -1) { + DEBUG(0,("open_sockets_smbd: listen: " + "%s\n", strerror(errno))); + close(s->fd); + TALLOC_FREE(s); + return false; + } + + s->fde = tevent_add_fd(smbd_event_context(), + s, + s->fd, TEVENT_FD_READ, + smbd_accept_connection, + s); + if (!s->fde) { + DEBUG(0,("open_sockets_smbd: " + "tevent_add_fd: %s\n", + strerror(errno))); + close(s->fd); + TALLOC_FREE(s); + return false; + } + tevent_fd_set_close_fn(s->fde, smbd_open_socket_close_fn); + + DLIST_ADD_END(parent->sockets, s, struct smbd_open_socket *); + + return true; +} + /**************************************************************************** Open the socket communication. ****************************************************************************/ -static bool open_sockets_smbd(bool interactive, const char *smb_ports) +static bool open_sockets_smbd(struct smbd_parent_context *parent, + const char *smb_ports) { int num_interfaces = iface_count(); - int num_sockets = 0; - int fd_listenset[FD_SETSIZE]; - fd_set listen_set; - int s; - int maxfd = 0; int i; char *ports; - TALLOC_CTX *dns_ctx = NULL; unsigned dns_port = 0; #ifdef HAVE_ATEXIT atexit(killkids); #endif - dns_ctx = talloc_new(NULL); - /* Stop zombies */ smbd_setup_sig_chld_handler(); - FD_ZERO(&listen_set); - /* use a reasonable default set of ports - listing on 445 and 139 */ if (!smb_ports) { ports = lp_smb_ports(); if (!ports || !*ports) { - ports = smb_xstrdup(SMB_PORTS); + ports = talloc_strdup(talloc_tos(), SMB_PORTS); } else { - ports = smb_xstrdup(ports); + ports = talloc_strdup(talloc_tos(), ports); } } else { - ports = smb_xstrdup(smb_ports); + ports = talloc_strdup(talloc_tos(), smb_ports); } if (lp_interfaces() && lp_bind_interfaces_only()) { @@ -344,7 +524,6 @@ static bool open_sockets_smbd(bool interactive, const char *smb_ports) /* Now open a listen socket for each of the interfaces. */ for(i = 0; i < num_interfaces; i++) { - TALLOC_CTX *frame = NULL; const struct sockaddr_storage *ifss = iface_n_sockaddr_storage(i); char *tok; @@ -357,64 +536,22 @@ static bool open_sockets_smbd(bool interactive, const char *smb_ports) continue; } - frame = talloc_stackframe(); for (ptr=ports; - next_token_talloc(frame,&ptr, &tok, " \t,");) { + next_token_talloc(talloc_tos(),&ptr, &tok, " \t,");) { unsigned port = atoi(tok); if (port == 0 || port > 0xffff) { continue; } - /* Keep the first port for mDNS service - * registration. - */ - if (dns_port == 0) { - dns_port = port; - } - - s = fd_listenset[num_sockets] = - open_socket_in(SOCK_STREAM, - port, - num_sockets == 0 ? 0 : 2, - ifss, - true); - if(s == -1) { - continue; - } - - /* ready to listen */ - set_socket_options(s,"SO_KEEPALIVE"); - set_socket_options(s,lp_socket_options()); - - /* Set server socket to - * non-blocking for the accept. */ - set_blocking(s,False); - - if (listen(s, SMBD_LISTEN_BACKLOG) == -1) { - DEBUG(0,("open_sockets_smbd: listen: " - "%s\n", strerror(errno))); - close(s); - TALLOC_FREE(frame); - return False; - } - FD_SET(s,&listen_set); - maxfd = MAX( maxfd, s); - - num_sockets++; - if (num_sockets >= FD_SETSIZE) { - DEBUG(0,("open_sockets_smbd: Too " - "many sockets to bind to\n")); - TALLOC_FREE(frame); - return False; + if (!smbd_open_one_socket(parent, ifss, port)) { + return false; } } - TALLOC_FREE(frame); } } else { /* Just bind to 0.0.0.0 - accept connections from anywhere. */ - TALLOC_CTX *frame = talloc_stackframe(); char *tok; const char *ptr; const char *sock_addr = lp_socket_address(); @@ -431,8 +568,8 @@ static bool open_sockets_smbd(bool interactive, const char *smb_ports) } for (sock_ptr=sock_addr; - next_token_talloc(frame, &sock_ptr, &sock_tok, " \t,"); ) { - for (ptr=ports; next_token_talloc(frame, &ptr, &tok, " \t,"); ) { + next_token_talloc(talloc_tos(), &sock_ptr, &sock_tok, " \t,"); ) { + for (ptr=ports; next_token_talloc(talloc_tos(), &ptr, &tok, " \t,"); ) { struct sockaddr_storage ss; unsigned port = atoi(tok); @@ -453,52 +590,14 @@ static bool open_sockets_smbd(bool interactive, const char *smb_ports) continue; } - s = open_socket_in(SOCK_STREAM, - port, - num_sockets == 0 ? 0 : 2, - &ss, - true); - if (s == -1) { - continue; - } - - /* ready to listen */ - set_socket_options(s,"SO_KEEPALIVE"); - set_socket_options(s,lp_socket_options()); - - /* Set server socket to non-blocking - * for the accept. */ - set_blocking(s,False); - - if (listen(s, SMBD_LISTEN_BACKLOG) == -1) { - DEBUG(0,("open_sockets_smbd: " - "listen: %s\n", - strerror(errno))); - close(s); - TALLOC_FREE(frame); - return False; - } - - fd_listenset[num_sockets] = s; - FD_SET(s,&listen_set); - maxfd = MAX( maxfd, s); - - num_sockets++; - - if (num_sockets >= FD_SETSIZE) { - DEBUG(0,("open_sockets_smbd: Too " - "many sockets to bind to\n")); - TALLOC_FREE(frame); - return False; + if (!smbd_open_one_socket(parent, &ss, port)) { + return false; } } } - TALLOC_FREE(frame); } - SAFE_FREE(ports); - - if (num_sockets == 0) { + if (parent->sockets == NULL) { DEBUG(0,("open_sockets_smbd: No " "sockets available to bind to.\n")); return false; @@ -539,26 +638,33 @@ static bool open_sockets_smbd(bool interactive, const char *smb_ports) if (dns_port != 0) { smbd_setup_mdns_registration(smbd_event_context(), - dns_ctx, dns_port); + parent, dns_port); } + return true; +} + +static void smbd_parent_loop(struct smbd_parent_context *parent) +{ /* now accept incoming connections - forking a new process for each incoming connection */ DEBUG(2,("waiting for a connection\n")); while (1) { struct timeval now, idle_timeout; fd_set r_fds, w_fds; + int maxfd = 0; int num; + TALLOC_CTX *frame = talloc_stackframe(); if (run_events(smbd_event_context(), 0, NULL, NULL)) { + TALLOC_FREE(frame); continue; } idle_timeout = timeval_zero(); - memcpy((char *)&r_fds, (char *)&listen_set, - sizeof(listen_set)); FD_ZERO(&w_fds); + FD_ZERO(&r_fds); GetTimeOfDay(&now); event_add_to_select_args(smbd_event_context(), &now, @@ -569,7 +675,11 @@ static bool open_sockets_smbd(bool interactive, const char *smb_ports) timeval_is_zero(&idle_timeout) ? NULL : &idle_timeout); + /* check if we need to reload services */ + check_reload(time(NULL)); + if (run_events(smbd_event_context(), num, &r_fds, &w_fds)) { + TALLOC_FREE(frame); continue; } @@ -580,108 +690,7 @@ static bool open_sockets_smbd(bool interactive, const char *smb_ports) if (num == 0 && count_all_current_connections() == 0) { exit_server_cleanly("idle timeout"); } - - /* check if we need to reload services */ - check_reload(time(NULL)); - - /* Find the sockets that are read-ready - - accept on these. */ - for( ; num > 0; num--) { - struct sockaddr addr; - socklen_t in_addrlen = sizeof(addr); - pid_t child = 0; - - s = -1; - for(i = 0; i < num_sockets; i++) { - if(FD_ISSET(fd_listenset[i],&r_fds)) { - s = fd_listenset[i]; - /* Clear this so we don't look - at it again. */ - FD_CLR(fd_listenset[i],&r_fds); - break; - } - } - - smbd_set_server_fd(accept(s,&addr,&in_addrlen)); - - if (smbd_server_fd() == -1 && errno == EINTR) - continue; - - if (smbd_server_fd() == -1) { - DEBUG(2,("open_sockets_smbd: accept: %s\n", - strerror(errno))); - continue; - } - - if (interactive) - return True; - - if (allowable_number_of_smbd_processes() && - ((child = sys_fork())==0)) { - /* Child code ... */ - - TALLOC_FREE(dns_ctx); - - /* Stop zombies, the parent explicitly handles - * them, counting worker smbds. */ - CatchChild(); - - /* close the listening socket(s) */ - for(i = 0; i < num_sockets; i++) - close(fd_listenset[i]); - - /* close our standard file - descriptors */ - close_low_fds(False); - am_parent = 0; - - if (!reinit_after_fork( - smbd_messaging_context(), - smbd_event_context(), - true)) { - DEBUG(0,("reinit_after_fork() failed\n")); - smb_panic("reinit_after_fork() failed"); - } - - smbd_setup_sig_term_handler(); - smbd_setup_sig_hup_handler(); - - return True; - } - /* The parent doesn't need this socket */ - close(smbd_server_fd()); - - /* Sun May 6 18:56:14 2001 ackley@cs.unm.edu: - Clear the closed fd info out of server_fd -- - and more importantly, out of client_fd in - util_sock.c, to avoid a possible - getpeername failure if we reopen the logs - and use %I in the filename. - */ - - smbd_set_server_fd(-1); - - if (child != 0) { - add_child_pid(child); - } - - /* Force parent to check log size after - * spawning child. Fix from - * klausr@ITAP.Physik.Uni-Stuttgart.De. The - * parent smbd will log to logserver.smb. It - * writes only two messages for each child - * started/finished. But each child writes, - * say, 50 messages also in logserver.smb, - * begining with the debug_count of the - * parent, before the child opens its own log - * file logserver.client. In a worst case - * scenario the size of logserver.smb would be - * checked after about 50*50=2500 messages - * (ca. 100kb). - * */ - force_check_log_size(); - - } /* end for num */ + TALLOC_FREE(frame); } /* end while 1 */ /* NOTREACHED return True; */ @@ -939,6 +948,7 @@ extern void build_options(bool screen); POPT_COMMON_DYNCONFIG POPT_TABLEEND }; + struct smbd_parent_context *parent = NULL; TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */ smbd_init_globals(); @@ -1215,12 +1225,18 @@ extern void build_options(bool screen); return(0); } - if (!open_sockets_smbd(interactive, ports)) - exit(1); + parent = talloc_zero(smbd_event_context(), struct smbd_parent_context); + if (!parent) { + exit_server("talloc(struct smbd_parent_context) failed"); + } + parent->interactive = interactive; + + if (!open_sockets_smbd(parent, ports)) + exit_server("open_sockets_smbd() failed"); TALLOC_FREE(frame); - smbd_process(); + smbd_parent_loop(parent); exit_server_cleanly(NULL); return(0); -- cgit From f6d8d94510498796e24fe5c52cb5ff3b14fd7f97 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 27 Jan 2009 09:48:48 +0100 Subject: s3:rpc_server: use get_client_fd() instead of smbd_server_fd() Both are absolutely the same, but smbd_server_fd() is otherwise only used in smbd/*.c and would like to remove smbd_server_fd() soon. metze --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ba2fe774b8..e61d343731 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1701,7 +1701,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* check smb.conf parameters and the the sec_desc */ - if ( !check_access(smbd_server_fd(), lp_hostsallow(snum), lp_hostsdeny(snum)) ) { + if ( !check_access(get_client_fd(), lp_hostsallow(snum), lp_hostsdeny(snum)) ) { DEBUG(3, ("access DENIED (hosts allow/deny) for printer open\n")); return WERR_ACCESS_DENIED; } -- cgit From 86ed67f0737aa309014b93860ccc6c79e3cc6ea5 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 27 Jan 2009 15:46:25 +0100 Subject: libreplace: fix detection of netinet/ip.h on solaris 8 (The test needs to additionally include .) Michael --- lib/replace/libreplace_network.m4 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/replace/libreplace_network.m4 b/lib/replace/libreplace_network.m4 index 8d8379a566..30be30f4ab 100644 --- a/lib/replace/libreplace_network.m4 +++ b/lib/replace/libreplace_network.m4 @@ -7,10 +7,14 @@ LIBREPLACE_NETWORK_OBJS="" 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 +#endif +#ifdef HAVE_NETINET_IN_SYSTM_H +#include #endif]) -AC_CHECK_HEADERS(netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) +AC_CHECK_HEADERS(netinet/tcp.h netinet/in_ip.h) AC_CHECK_HEADERS(sys/sockio.h sys/un.h) dnl we need to check that net/if.h really can be used, to cope with hpux -- cgit From 31e46ff4ac2c2c339542450cf0e5f46cc990df71 Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Tue, 27 Jan 2009 10:37:51 -0800 Subject: s3: Fix shadowed declaration --- source3/winbindd/winbindd_proto.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index d72351d021..87639dc59e 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -64,7 +64,7 @@ void setup_async_write(struct winbindd_fd_event *event, void *data, size_t lengt void request_error(struct winbindd_cli_state *state); void request_ok(struct winbindd_cli_state *state); bool winbindd_setup_sig_term_handler(bool parent); -bool winbindd_setup_sig_hup_handler(const char *logfile); +bool winbindd_setup_sig_hup_handler(const char *lfile); int main(int argc, char **argv, char **envp); /* The following definitions come from winbindd/winbindd_reqtrans.c */ -- cgit From fffd94b442e143ddd995ba356497dc6c2528ed4b Mon Sep 17 00:00:00 2001 From: Steven Danneman Date: Tue, 27 Jan 2009 13:24:38 -0800 Subject: Move S3 specific parameters to S3 conf file in make test. --- source3/script/tests/selftest.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source3/script/tests/selftest.sh b/source3/script/tests/selftest.sh index 0f1ca32e4a..94621841f5 100755 --- a/source3/script/tests/selftest.sh +++ b/source3/script/tests/selftest.sh @@ -170,8 +170,6 @@ cat >$COMMONCONFFILE<$SERVERCONFFILE< Date: Tue, 27 Jan 2009 16:19:09 -0800 Subject: Fix detection of dns_sd libraries. Jeremy. --- source3/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/configure.in b/source3/configure.in index c63f7c84a8..b4c021cd0d 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -5999,7 +5999,7 @@ if test x"$enable_dnssd" != x"no"; then AC_CHECK_FUNCS(DNSServiceRegister) AC_CHECK_LIB_EXT(dns_sd, DNSSD_LIBS, DNSServiceRegister) if test x"$ac_cv_func_DNSServiceRegister" != x"yes" -a \ - x"$ac_cv_lib_ext_DNSServiceRegister" != x"yes"; then + x"$ac_cv_lib_ext_dns_sd_DNSServiceRegister" != x"yes"; then have_dnssd_support=no fi -- cgit From 59859b547c81bf398d12a1f9b206a32c6fd55433 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 28 Jan 2009 08:52:53 +0100 Subject: s3: separate tdb validation code out into its own source file So this gets now linked only into its single user: winbindd (needed by winbindd_cache.c) Michael --- source3/Makefile.in | 5 +- source3/include/util_tdb.h | 15 -- source3/lib/tdb_validate.c | 502 ++++++++++++++++++++++++++++++++++++++ source3/lib/tdb_validate.h | 78 ++++++ source3/lib/util_tdb.c | 484 ------------------------------------ source3/winbindd/winbindd_cache.c | 1 + 6 files changed, 585 insertions(+), 500 deletions(-) create mode 100644 source3/lib/tdb_validate.c create mode 100644 source3/lib/tdb_validate.h diff --git a/source3/Makefile.in b/source3/Makefile.in index 1f28e49b9f..a0ec9a7452 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -242,6 +242,8 @@ TDB_LIB_OBJ = lib/util_tdb.o ../lib/util/util_tdb.o \ lib/dbwrap_ctdb.o \ lib/dbwrap_rbt.o @LIBTDB_STATIC@ +TDB_VALIDATE_OBJ = lib/tdb_validate.o + SMBLDAP_OBJ = @SMBLDAP@ @SMBLDAPUTIL@ VERSION_OBJ = lib/version.o @@ -1065,7 +1067,8 @@ 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) $(SERVER_MUTEX_OBJ) $(LDB_OBJ) \ + $(TDB_VALIDATE_OBJ) WBINFO_OBJ = ../nsswitch/wbinfo.o $(LIBSAMBA_OBJ) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ $(POPT_LIB_OBJ) $(AFS_SETTOKEN_OBJ) \ diff --git a/source3/include/util_tdb.h b/source3/include/util_tdb.h index 127176b887..21f64fa3d3 100644 --- a/source3/include/util_tdb.h +++ b/source3/include/util_tdb.h @@ -31,16 +31,6 @@ struct tdb_wrap { struct tdb_wrap *next, *prev; }; -struct tdb_validation_status { - bool tdb_error; - bool bad_freelist; - bool bad_entry; - bool unknown_key; - bool success; -}; - -typedef int (*tdb_validate_data_func)(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state); - TDB_DATA make_tdb_data(const uint8_t *dptr, size_t dsize); TDB_DATA string_tdb_data(const char *string); TDB_DATA string_term_tdb_data(const char *string); @@ -90,9 +80,4 @@ struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx, NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err); -int tdb_validate(struct tdb_context *tdb, tdb_validate_data_func validate_fn); -int tdb_validate_open(const char *tdb_path, tdb_validate_data_func validate_fn); -int tdb_validate_and_backup(const char *tdb_path, - tdb_validate_data_func validate_fn); - #endif /* __TDBUTIL_H__ */ diff --git a/source3/lib/tdb_validate.c b/source3/lib/tdb_validate.c new file mode 100644 index 0000000000..c1ca97787c --- /dev/null +++ b/source3/lib/tdb_validate.c @@ -0,0 +1,502 @@ +/* + * Unix SMB/CIFS implementation. + * + * A general tdb content validation mechanism + * + * Copyright (C) Michael Adam 2007 + * + * 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 . + */ + +#include "includes.h" +#include "tdb_validate.h" + +/* + * internal validation function, executed by the child. + */ +static int tdb_validate_child(struct tdb_context *tdb, + tdb_validate_data_func validate_fn) +{ + int ret = 1; + int num_entries = 0; + struct tdb_validation_status v_status; + + v_status.tdb_error = False; + v_status.bad_freelist = False; + v_status.bad_entry = False; + v_status.unknown_key = False; + v_status.success = True; + + if (!tdb) { + v_status.tdb_error = True; + v_status.success = False; + goto out; + } + + /* Check if the tdb's freelist is good. */ + if (tdb_validate_freelist(tdb, &num_entries) == -1) { + v_status.bad_freelist = True; + v_status.success = False; + goto out; + } + + DEBUG(10,("tdb_validate_child: tdb %s freelist has %d entries\n", + tdb_name(tdb), num_entries)); + + /* Now traverse the tdb to validate it. */ + num_entries = tdb_traverse(tdb, validate_fn, (void *)&v_status); + if (!v_status.success) { + goto out; + } else if (num_entries == -1) { + v_status.tdb_error = True; + v_status.success = False; + goto out; + } + + DEBUG(10,("tdb_validate_child: tdb %s is good with %d entries\n", + tdb_name(tdb), num_entries)); + ret = 0; /* Cache is good. */ + +out: + DEBUG(10, ("tdb_validate_child: summary of validation status:\n")); + DEBUGADD(10,(" * tdb error: %s\n", v_status.tdb_error ? "yes" : "no")); + DEBUGADD(10,(" * bad freelist: %s\n",v_status.bad_freelist?"yes":"no")); + DEBUGADD(10,(" * bad entry: %s\n", v_status.bad_entry ? "yes" : "no")); + DEBUGADD(10,(" * unknown key: %s\n", v_status.unknown_key?"yes":"no")); + DEBUGADD(10,(" => overall success: %s\n", v_status.success?"yes":"no")); + + return ret; +} + +/* + * tdb validation function. + * returns 0 if tdb is ok, != 0 if it isn't. + * this function expects an opened tdb. + */ +int tdb_validate(struct tdb_context *tdb, tdb_validate_data_func validate_fn) +{ + pid_t child_pid = -1; + int child_status = 0; + int wait_pid = 0; + int ret = 1; + + if (tdb == NULL) { + DEBUG(1, ("Error: tdb_validate called with tdb == NULL\n")); + return ret; + } + + DEBUG(5, ("tdb_validate called for tdb '%s'\n", tdb_name(tdb))); + + /* fork and let the child do the validation. + * benefit: no need to twist signal handlers and panic functions. + * just let the child panic. we catch the signal. */ + + DEBUG(10, ("tdb_validate: forking to let child do validation.\n")); + child_pid = sys_fork(); + if (child_pid == 0) { + /* child code */ + DEBUG(10, ("tdb_validate (validation child): created\n")); + DEBUG(10, ("tdb_validate (validation child): " + "calling tdb_validate_child\n")); + exit(tdb_validate_child(tdb, validate_fn)); + } + else if (child_pid < 0) { + DEBUG(1, ("tdb_validate: fork for validation failed.\n")); + goto done; + } + + /* parent */ + + DEBUG(10, ("tdb_validate: fork succeeded, child PID = %d\n",child_pid)); + + DEBUG(10, ("tdb_validate: waiting for child to finish...\n")); + while ((wait_pid = sys_waitpid(child_pid, &child_status, 0)) < 0) { + if (errno == EINTR) { + DEBUG(10, ("tdb_validate: got signal during waitpid, " + "retrying\n")); + errno = 0; + continue; + } + DEBUG(1, ("tdb_validate: waitpid failed with error '%s'.\n", + strerror(errno))); + goto done; + } + if (wait_pid != child_pid) { + DEBUG(1, ("tdb_validate: waitpid returned pid %d, " + "but %d was expected\n", wait_pid, child_pid)); + goto done; + } + + DEBUG(10, ("tdb_validate: validating child returned.\n")); + if (WIFEXITED(child_status)) { + DEBUG(10, ("tdb_validate: child exited, code %d.\n", + WEXITSTATUS(child_status))); + ret = WEXITSTATUS(child_status); + } + if (WIFSIGNALED(child_status)) { + DEBUG(10, ("tdb_validate: child terminated by signal %d\n", + WTERMSIG(child_status))); +#ifdef WCOREDUMP + if (WCOREDUMP(child_status)) { + DEBUGADD(10, ("core dumped\n")); + } +#endif + ret = WTERMSIG(child_status); + } + if (WIFSTOPPED(child_status)) { + DEBUG(10, ("tdb_validate: child was stopped by signal %d\n", + WSTOPSIG(child_status))); + ret = WSTOPSIG(child_status); + } + +done: + DEBUG(5, ("tdb_validate returning code '%d' for tdb '%s'\n", ret, + tdb_name(tdb))); + + return ret; +} + +/* + * tdb validation function. + * returns 0 if tdb is ok, != 0 if it isn't. + * this is a wrapper around the actual validation function that opens and closes + * the tdb. + */ +int tdb_validate_open(const char *tdb_path, tdb_validate_data_func validate_fn) +{ + TDB_CONTEXT *tdb = NULL; + int ret = 1; + + DEBUG(5, ("tdb_validate_open called for tdb '%s'\n", tdb_path)); + + tdb = tdb_open_log(tdb_path, 0, TDB_DEFAULT, O_RDONLY, 0); + if (!tdb) { + DEBUG(1, ("Error opening tdb %s\n", tdb_path)); + return ret; + } + + ret = tdb_validate(tdb, validate_fn); + tdb_close(tdb); + return ret; +} + +/* + * tdb backup function and helpers for tdb_validate wrapper with backup + * handling. + */ + +/* this structure eliminates the need for a global overall status for + * the traverse-copy */ +struct tdb_copy_data { + struct tdb_context *dst; + bool success; +}; + +static int traverse_copy_fn(struct tdb_context *tdb, TDB_DATA key, + TDB_DATA dbuf, void *private_data) +{ + struct tdb_copy_data *data = (struct tdb_copy_data *)private_data; + + if (tdb_store(data->dst, key, dbuf, TDB_INSERT) != 0) { + DEBUG(4, ("Failed to insert into %s: %s\n", tdb_name(data->dst), + strerror(errno))); + data->success = False; + return 1; + } + return 0; +} + +static int tdb_copy(struct tdb_context *src, struct tdb_context *dst) +{ + struct tdb_copy_data data; + int count; + + data.dst = dst; + data.success = True; + + count = tdb_traverse(src, traverse_copy_fn, (void *)(&data)); + if ((count < 0) || (data.success == False)) { + return -1; + } + return count; +} + +static int tdb_verify_basic(struct tdb_context *tdb) +{ + return tdb_traverse(tdb, NULL, NULL); +} + +/* this backup function is essentially taken from lib/tdb/tools/tdbbackup.tdb + */ +static int tdb_backup(TALLOC_CTX *ctx, const char *src_path, + const char *dst_path, int hash_size) +{ + struct tdb_context *src_tdb = NULL; + struct tdb_context *dst_tdb = NULL; + char *tmp_path = NULL; + struct stat st; + int count1, count2; + int saved_errno = 0; + int ret = -1; + + if (stat(src_path, &st) != 0) { + DEBUG(3, ("Could not stat '%s': %s\n", src_path, + strerror(errno))); + goto done; + } + + /* open old tdb RDWR - so we can lock it */ + src_tdb = tdb_open_log(src_path, 0, TDB_DEFAULT, O_RDWR, 0); + if (src_tdb == NULL) { + DEBUG(3, ("Failed to open tdb '%s'\n", src_path)); + goto done; + } + + if (tdb_lockall(src_tdb) != 0) { + DEBUG(3, ("Failed to lock tdb '%s'\n", src_path)); + goto done; + } + + tmp_path = talloc_asprintf(ctx, "%s%s", dst_path, ".tmp"); + unlink(tmp_path); + dst_tdb = tdb_open_log(tmp_path, + hash_size ? hash_size : tdb_hash_size(src_tdb), + TDB_DEFAULT, O_RDWR | O_CREAT | O_EXCL, + st.st_mode & 0777); + if (dst_tdb == NULL) { + DEBUG(3, ("Error creating tdb '%s': %s\n", tmp_path, + strerror(errno))); + saved_errno = errno; + unlink(tmp_path); + goto done; + } + + count1 = tdb_copy(src_tdb, dst_tdb); + if (count1 < 0) { + DEBUG(3, ("Failed to copy tdb '%s': %s\n", src_path, + strerror(errno))); + tdb_close(dst_tdb); + goto done; + } + + /* reopen ro and do basic verification */ + tdb_close(dst_tdb); + dst_tdb = tdb_open_log(tmp_path, 0, TDB_DEFAULT, O_RDONLY, 0); + if (!dst_tdb) { + DEBUG(3, ("Failed to reopen tdb '%s': %s\n", tmp_path, + strerror(errno))); + goto done; + } + count2 = tdb_verify_basic(dst_tdb); + if (count2 != count1) { + DEBUG(3, ("Failed to verify result of copying tdb '%s'.\n", + src_path)); + tdb_close(dst_tdb); + goto done; + } + + DEBUG(10, ("tdb_backup: successfully copied %d entries\n", count1)); + + /* make sure the new tdb has reached stable storage + * then rename it to its destination */ + fsync(tdb_fd(dst_tdb)); + tdb_close(dst_tdb); + unlink(dst_path); + if (rename(tmp_path, dst_path) != 0) { + DEBUG(3, ("Failed to rename '%s' to '%s': %s\n", + tmp_path, dst_path, strerror(errno))); + goto done; + } + + /* success */ + ret = 0; + +done: + if (src_tdb != NULL) { + tdb_close(src_tdb); + } + if (tmp_path != NULL) { + unlink(tmp_path); + TALLOC_FREE(tmp_path); + } + if (saved_errno != 0) { + errno = saved_errno; + } + return ret; +} + +static int rename_file_with_suffix(TALLOC_CTX *ctx, const char *path, + const char *suffix) +{ + int ret = -1; + char *dst_path; + + dst_path = talloc_asprintf(ctx, "%s%s", path, suffix); + + ret = (rename(path, dst_path) != 0); + + if (ret == 0) { + DEBUG(5, ("moved '%s' to '%s'\n", path, dst_path)); + } else if (errno == ENOENT) { + DEBUG(3, ("file '%s' does not exist - so not moved\n", path)); + ret = 0; + } else { + DEBUG(3, ("error renaming %s to %s: %s\n", path, dst_path, + strerror(errno))); + } + + TALLOC_FREE(dst_path); + return ret; +} + +/* + * do a backup of a tdb, moving the destination out of the way first + */ +static int tdb_backup_with_rotate(TALLOC_CTX *ctx, const char *src_path, + const char *dst_path, int hash_size, + const char *rotate_suffix, + bool retry_norotate_if_nospc, + bool rename_as_last_resort_if_nospc) +{ + int ret; + + rename_file_with_suffix(ctx, dst_path, rotate_suffix); + + ret = tdb_backup(ctx, src_path, dst_path, hash_size); + + if (ret != 0) { + DEBUG(10, ("backup of %s failed: %s\n", src_path, strerror(errno))); + } + if ((ret != 0) && (errno == ENOSPC) && retry_norotate_if_nospc) + { + char *rotate_path = talloc_asprintf(ctx, "%s%s", dst_path, + rotate_suffix); + DEBUG(10, ("backup of %s failed due to lack of space\n", + src_path)); + DEBUGADD(10, ("trying to free some space by removing rotated " + "dst %s\n", rotate_path)); + if (unlink(rotate_path) == -1) { + DEBUG(10, ("unlink of %s failed: %s\n", rotate_path, + strerror(errno))); + } else { + ret = tdb_backup(ctx, src_path, dst_path, hash_size); + } + TALLOC_FREE(rotate_path); + } + + if ((ret != 0) && (errno == ENOSPC) && rename_as_last_resort_if_nospc) + { + DEBUG(10, ("backup of %s failed due to lack of space\n", + src_path)); + DEBUGADD(10, ("using 'rename' as a last resort\n")); + ret = rename(src_path, dst_path); + } + + return ret; +} + +/* + * validation function with backup handling: + * + * - calls tdb_validate + * - if the tdb is ok, create a backup "name.bak", possibly moving + * existing backup to name.bak.old, + * return 0 (success) even if the backup fails + * - if the tdb is corrupt: + * - move the tdb to "name.corrupt" + * - check if there is valid backup. + * if so, restore the backup. + * if restore is successful, return 0 (success), + * - otherwise return -1 (failure) + */ +int tdb_validate_and_backup(const char *tdb_path, + tdb_validate_data_func validate_fn) +{ + int ret = -1; + const char *backup_suffix = ".bak"; + const char *corrupt_suffix = ".corrupt"; + const char *rotate_suffix = ".old"; + char *tdb_path_backup; + struct stat st; + TALLOC_CTX *ctx = NULL; + + ctx = talloc_new(NULL); + if (ctx == NULL) { + DEBUG(0, ("tdb_validate_and_backup: out of memory\n")); + goto done; + } + + tdb_path_backup = talloc_asprintf(ctx, "%s%s", tdb_path, backup_suffix); + + ret = tdb_validate_open(tdb_path, validate_fn); + + if (ret == 0) { + DEBUG(1, ("tdb '%s' is valid\n", tdb_path)); + ret = tdb_backup_with_rotate(ctx, tdb_path, tdb_path_backup, 0, + rotate_suffix, True, False); + if (ret != 0) { + DEBUG(1, ("Error creating backup of tdb '%s'\n", + tdb_path)); + /* the actual validation was successful: */ + ret = 0; + } else { + DEBUG(1, ("Created backup '%s' of tdb '%s'\n", + tdb_path_backup, tdb_path)); + } + } else { + DEBUG(1, ("tdb '%s' is invalid\n", tdb_path)); + + ret =stat(tdb_path_backup, &st); + if (ret != 0) { + DEBUG(5, ("Could not stat '%s': %s\n", tdb_path_backup, + strerror(errno))); + DEBUG(1, ("No backup found.\n")); + } else { + DEBUG(1, ("backup '%s' found.\n", tdb_path_backup)); + ret = tdb_validate_open(tdb_path_backup, validate_fn); + if (ret != 0) { + DEBUG(1, ("Backup '%s' is invalid.\n", + tdb_path_backup)); + } + } + + if (ret != 0) { + int renamed = rename_file_with_suffix(ctx, tdb_path, + corrupt_suffix); + if (renamed != 0) { + DEBUG(1, ("Error moving tdb to '%s%s'\n", + tdb_path, corrupt_suffix)); + } else { + DEBUG(1, ("Corrupt tdb stored as '%s%s'\n", + tdb_path, corrupt_suffix)); + } + goto done; + } + + DEBUG(1, ("valid backup '%s' found\n", tdb_path_backup)); + ret = tdb_backup_with_rotate(ctx, tdb_path_backup, tdb_path, 0, + corrupt_suffix, True, True); + if (ret != 0) { + DEBUG(1, ("Error restoring backup from '%s'\n", + tdb_path_backup)); + } else { + DEBUG(1, ("Restored tdb backup from '%s'\n", + tdb_path_backup)); + } + } + +done: + TALLOC_FREE(ctx); + return ret; +} diff --git a/source3/lib/tdb_validate.h b/source3/lib/tdb_validate.h new file mode 100644 index 0000000000..1a207fa669 --- /dev/null +++ b/source3/lib/tdb_validate.h @@ -0,0 +1,78 @@ +/* + * Unix SMB/CIFS implementation. + * + * A general tdb content validation mechanism + * + * Copyright (C) Michael Adam 2007 + * + * 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 . + */ + +#ifndef __TDB_VALIDATE_H__ +#define __TDB_VALIDATE_H__ + +#include "includes.h" + +/** + * Flag field for keeping track of the status of a validation. + */ +struct tdb_validation_status { + bool tdb_error; + bool bad_freelist; + bool bad_entry; + bool unknown_key; + bool success; +}; + +/** + * Callback function type for the validation mechanism. + */ +typedef int (*tdb_validate_data_func)(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, + TDB_DATA dbuf, void *state); + +/** + * tdb validation function. + * returns 0 if tdb is ok, != 0 if it isn't. + * this function expects an opened tdb. + */ +int tdb_validate(struct tdb_context *tdb, + tdb_validate_data_func validate_fn); + +/** + * tdb validation function. + * returns 0 if tdb is ok, != 0 if it isn't. + * This is a wrapper around the actual validation function that + * opens and closes the tdb. + */ +int tdb_validate_open(const char *tdb_path, + tdb_validate_data_func validate_fn); + +/** + * validation function with backup handling: + * + * - calls tdb_validate + * - if the tdb is ok, create a backup "name.bak", possibly moving + * existing backup to name.bak.old, + * return 0 (success) even if the backup fails + * - if the tdb is corrupt: + * - move the tdb to "name.corrupt" + * - check if there is valid backup. + * if so, restore the backup. + * if restore is successful, return 0 (success), + * - otherwise return -1 (failure) + */ +int tdb_validate_and_backup(const char *tdb_path, + tdb_validate_data_func validate_fn); + +#endif /* __TDB_VALIDATE_H__ */ diff --git a/source3/lib/util_tdb.c b/source3/lib/util_tdb.c index 2dbdd57947..78fa7cd0a1 100644 --- a/source3/lib/util_tdb.c +++ b/source3/lib/util_tdb.c @@ -630,487 +630,3 @@ NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err) return NT_STATUS_INTERNAL_ERROR; } - - -/********************************************************************* - * the following is a generic validation mechanism for tdbs. - *********************************************************************/ - -/* - * internal validation function, executed by the child. - */ -static int tdb_validate_child(struct tdb_context *tdb, - tdb_validate_data_func validate_fn) -{ - int ret = 1; - int num_entries = 0; - struct tdb_validation_status v_status; - - v_status.tdb_error = False; - v_status.bad_freelist = False; - v_status.bad_entry = False; - v_status.unknown_key = False; - v_status.success = True; - - if (!tdb) { - v_status.tdb_error = True; - v_status.success = False; - goto out; - } - - /* Check if the tdb's freelist is good. */ - if (tdb_validate_freelist(tdb, &num_entries) == -1) { - v_status.bad_freelist = True; - v_status.success = False; - goto out; - } - - DEBUG(10,("tdb_validate_child: tdb %s freelist has %d entries\n", - tdb_name(tdb), num_entries)); - - /* Now traverse the tdb to validate it. */ - num_entries = tdb_traverse(tdb, validate_fn, (void *)&v_status); - if (!v_status.success) { - goto out; - } else if (num_entries == -1) { - v_status.tdb_error = True; - v_status.success = False; - goto out; - } - - DEBUG(10,("tdb_validate_child: tdb %s is good with %d entries\n", - tdb_name(tdb), num_entries)); - ret = 0; /* Cache is good. */ - -out: - DEBUG(10, ("tdb_validate_child: summary of validation status:\n")); - DEBUGADD(10,(" * tdb error: %s\n", v_status.tdb_error ? "yes" : "no")); - DEBUGADD(10,(" * bad freelist: %s\n",v_status.bad_freelist?"yes":"no")); - DEBUGADD(10,(" * bad entry: %s\n", v_status.bad_entry ? "yes" : "no")); - DEBUGADD(10,(" * unknown key: %s\n", v_status.unknown_key?"yes":"no")); - DEBUGADD(10,(" => overall success: %s\n", v_status.success?"yes":"no")); - - return ret; -} - -/* - * tdb validation function. - * returns 0 if tdb is ok, != 0 if it isn't. - * this function expects an opened tdb. - */ -int tdb_validate(struct tdb_context *tdb, tdb_validate_data_func validate_fn) -{ - pid_t child_pid = -1; - int child_status = 0; - int wait_pid = 0; - int ret = 1; - - if (tdb == NULL) { - DEBUG(1, ("Error: tdb_validate called with tdb == NULL\n")); - return ret; - } - - DEBUG(5, ("tdb_validate called for tdb '%s'\n", tdb_name(tdb))); - - /* fork and let the child do the validation. - * benefit: no need to twist signal handlers and panic functions. - * just let the child panic. we catch the signal. */ - - DEBUG(10, ("tdb_validate: forking to let child do validation.\n")); - child_pid = sys_fork(); - if (child_pid == 0) { - /* child code */ - DEBUG(10, ("tdb_validate (validation child): created\n")); - DEBUG(10, ("tdb_validate (validation child): " - "calling tdb_validate_child\n")); - exit(tdb_validate_child(tdb, validate_fn)); - } - else if (child_pid < 0) { - DEBUG(1, ("tdb_validate: fork for validation failed.\n")); - goto done; - } - - /* parent */ - - DEBUG(10, ("tdb_validate: fork succeeded, child PID = %d\n",child_pid)); - - DEBUG(10, ("tdb_validate: waiting for child to finish...\n")); - while ((wait_pid = sys_waitpid(child_pid, &child_status, 0)) < 0) { - if (errno == EINTR) { - DEBUG(10, ("tdb_validate: got signal during waitpid, " - "retrying\n")); - errno = 0; - continue; - } - DEBUG(1, ("tdb_validate: waitpid failed with error '%s'.\n", - strerror(errno))); - goto done; - } - if (wait_pid != child_pid) { - DEBUG(1, ("tdb_validate: waitpid returned pid %d, " - "but %d was expected\n", wait_pid, child_pid)); - goto done; - } - - DEBUG(10, ("tdb_validate: validating child returned.\n")); - if (WIFEXITED(child_status)) { - DEBUG(10, ("tdb_validate: child exited, code %d.\n", - WEXITSTATUS(child_status))); - ret = WEXITSTATUS(child_status); - } - if (WIFSIGNALED(child_status)) { - DEBUG(10, ("tdb_validate: child terminated by signal %d\n", - WTERMSIG(child_status))); -#ifdef WCOREDUMP - if (WCOREDUMP(child_status)) { - DEBUGADD(10, ("core dumped\n")); - } -#endif - ret = WTERMSIG(child_status); - } - if (WIFSTOPPED(child_status)) { - DEBUG(10, ("tdb_validate: child was stopped by signal %d\n", - WSTOPSIG(child_status))); - ret = WSTOPSIG(child_status); - } - -done: - DEBUG(5, ("tdb_validate returning code '%d' for tdb '%s'\n", ret, - tdb_name(tdb))); - - return ret; -} - -/* - * tdb validation function. - * returns 0 if tdb is ok, != 0 if it isn't. - * this is a wrapper around the actual validation function that opens and closes - * the tdb. - */ -int tdb_validate_open(const char *tdb_path, tdb_validate_data_func validate_fn) -{ - TDB_CONTEXT *tdb = NULL; - int ret = 1; - - DEBUG(5, ("tdb_validate_open called for tdb '%s'\n", tdb_path)); - - tdb = tdb_open_log(tdb_path, 0, TDB_DEFAULT, O_RDONLY, 0); - if (!tdb) { - DEBUG(1, ("Error opening tdb %s\n", tdb_path)); - return ret; - } - - ret = tdb_validate(tdb, validate_fn); - tdb_close(tdb); - return ret; -} - -/* - * tdb backup function and helpers for tdb_validate wrapper with backup - * handling. - */ - -/* this structure eliminates the need for a global overall status for - * the traverse-copy */ -struct tdb_copy_data { - struct tdb_context *dst; - bool success; -}; - -static int traverse_copy_fn(struct tdb_context *tdb, TDB_DATA key, - TDB_DATA dbuf, void *private_data) -{ - struct tdb_copy_data *data = (struct tdb_copy_data *)private_data; - - if (tdb_store(data->dst, key, dbuf, TDB_INSERT) != 0) { - DEBUG(4, ("Failed to insert into %s: %s\n", tdb_name(data->dst), - strerror(errno))); - data->success = False; - return 1; - } - return 0; -} - -static int tdb_copy(struct tdb_context *src, struct tdb_context *dst) -{ - struct tdb_copy_data data; - int count; - - data.dst = dst; - data.success = True; - - count = tdb_traverse(src, traverse_copy_fn, (void *)(&data)); - if ((count < 0) || (data.success == False)) { - return -1; - } - return count; -} - -static int tdb_verify_basic(struct tdb_context *tdb) -{ - return tdb_traverse(tdb, NULL, NULL); -} - -/* this backup function is essentially taken from lib/tdb/tools/tdbbackup.tdb - */ -static int tdb_backup(TALLOC_CTX *ctx, const char *src_path, - const char *dst_path, int hash_size) -{ - struct tdb_context *src_tdb = NULL; - struct tdb_context *dst_tdb = NULL; - char *tmp_path = NULL; - struct stat st; - int count1, count2; - int saved_errno = 0; - int ret = -1; - - if (stat(src_path, &st) != 0) { - DEBUG(3, ("Could not stat '%s': %s\n", src_path, - strerror(errno))); - goto done; - } - - /* open old tdb RDWR - so we can lock it */ - src_tdb = tdb_open_log(src_path, 0, TDB_DEFAULT, O_RDWR, 0); - if (src_tdb == NULL) { - DEBUG(3, ("Failed to open tdb '%s'\n", src_path)); - goto done; - } - - if (tdb_lockall(src_tdb) != 0) { - DEBUG(3, ("Failed to lock tdb '%s'\n", src_path)); - goto done; - } - - tmp_path = talloc_asprintf(ctx, "%s%s", dst_path, ".tmp"); - unlink(tmp_path); - dst_tdb = tdb_open_log(tmp_path, - hash_size ? hash_size : tdb_hash_size(src_tdb), - TDB_DEFAULT, O_RDWR | O_CREAT | O_EXCL, - st.st_mode & 0777); - if (dst_tdb == NULL) { - DEBUG(3, ("Error creating tdb '%s': %s\n", tmp_path, - strerror(errno))); - saved_errno = errno; - unlink(tmp_path); - goto done; - } - - count1 = tdb_copy(src_tdb, dst_tdb); - if (count1 < 0) { - DEBUG(3, ("Failed to copy tdb '%s': %s\n", src_path, - strerror(errno))); - tdb_close(dst_tdb); - goto done; - } - - /* reopen ro and do basic verification */ - tdb_close(dst_tdb); - dst_tdb = tdb_open_log(tmp_path, 0, TDB_DEFAULT, O_RDONLY, 0); - if (!dst_tdb) { - DEBUG(3, ("Failed to reopen tdb '%s': %s\n", tmp_path, - strerror(errno))); - goto done; - } - count2 = tdb_verify_basic(dst_tdb); - if (count2 != count1) { - DEBUG(3, ("Failed to verify result of copying tdb '%s'.\n", - src_path)); - tdb_close(dst_tdb); - goto done; - } - - DEBUG(10, ("tdb_backup: successfully copied %d entries\n", count1)); - - /* make sure the new tdb has reached stable storage - * then rename it to its destination */ - fsync(tdb_fd(dst_tdb)); - tdb_close(dst_tdb); - unlink(dst_path); - if (rename(tmp_path, dst_path) != 0) { - DEBUG(3, ("Failed to rename '%s' to '%s': %s\n", - tmp_path, dst_path, strerror(errno))); - goto done; - } - - /* success */ - ret = 0; - -done: - if (src_tdb != NULL) { - tdb_close(src_tdb); - } - if (tmp_path != NULL) { - unlink(tmp_path); - TALLOC_FREE(tmp_path); - } - if (saved_errno != 0) { - errno = saved_errno; - } - return ret; -} - -static int rename_file_with_suffix(TALLOC_CTX *ctx, const char *path, - const char *suffix) -{ - int ret = -1; - char *dst_path; - - dst_path = talloc_asprintf(ctx, "%s%s", path, suffix); - - ret = (rename(path, dst_path) != 0); - - if (ret == 0) { - DEBUG(5, ("moved '%s' to '%s'\n", path, dst_path)); - } else if (errno == ENOENT) { - DEBUG(3, ("file '%s' does not exist - so not moved\n", path)); - ret = 0; - } else { - DEBUG(3, ("error renaming %s to %s: %s\n", path, dst_path, - strerror(errno))); - } - - TALLOC_FREE(dst_path); - return ret; -} - -/* - * do a backup of a tdb, moving the destination out of the way first - */ -static int tdb_backup_with_rotate(TALLOC_CTX *ctx, const char *src_path, - const char *dst_path, int hash_size, - const char *rotate_suffix, - bool retry_norotate_if_nospc, - bool rename_as_last_resort_if_nospc) -{ - int ret; - - rename_file_with_suffix(ctx, dst_path, rotate_suffix); - - ret = tdb_backup(ctx, src_path, dst_path, hash_size); - - if (ret != 0) { - DEBUG(10, ("backup of %s failed: %s\n", src_path, strerror(errno))); - } - if ((ret != 0) && (errno == ENOSPC) && retry_norotate_if_nospc) - { - char *rotate_path = talloc_asprintf(ctx, "%s%s", dst_path, - rotate_suffix); - DEBUG(10, ("backup of %s failed due to lack of space\n", - src_path)); - DEBUGADD(10, ("trying to free some space by removing rotated " - "dst %s\n", rotate_path)); - if (unlink(rotate_path) == -1) { - DEBUG(10, ("unlink of %s failed: %s\n", rotate_path, - strerror(errno))); - } else { - ret = tdb_backup(ctx, src_path, dst_path, hash_size); - } - TALLOC_FREE(rotate_path); - } - - if ((ret != 0) && (errno == ENOSPC) && rename_as_last_resort_if_nospc) - { - DEBUG(10, ("backup of %s failed due to lack of space\n", - src_path)); - DEBUGADD(10, ("using 'rename' as a last resort\n")); - ret = rename(src_path, dst_path); - } - - return ret; -} - -/* - * validation function with backup handling: - * - * - calls tdb_validate - * - if the tdb is ok, create a backup "name.bak", possibly moving - * existing backup to name.bak.old, - * return 0 (success) even if the backup fails - * - if the tdb is corrupt: - * - move the tdb to "name.corrupt" - * - check if there is valid backup. - * if so, restore the backup. - * if restore is successful, return 0 (success), - * - otherwise return -1 (failure) - */ -int tdb_validate_and_backup(const char *tdb_path, - tdb_validate_data_func validate_fn) -{ - int ret = -1; - const char *backup_suffix = ".bak"; - const char *corrupt_suffix = ".corrupt"; - const char *rotate_suffix = ".old"; - char *tdb_path_backup; - struct stat st; - TALLOC_CTX *ctx = NULL; - - ctx = talloc_new(NULL); - if (ctx == NULL) { - DEBUG(0, ("tdb_validate_and_backup: out of memory\n")); - goto done; - } - - tdb_path_backup = talloc_asprintf(ctx, "%s%s", tdb_path, backup_suffix); - - ret = tdb_validate_open(tdb_path, validate_fn); - - if (ret == 0) { - DEBUG(1, ("tdb '%s' is valid\n", tdb_path)); - ret = tdb_backup_with_rotate(ctx, tdb_path, tdb_path_backup, 0, - rotate_suffix, True, False); - if (ret != 0) { - DEBUG(1, ("Error creating backup of tdb '%s'\n", - tdb_path)); - /* the actual validation was successful: */ - ret = 0; - } else { - DEBUG(1, ("Created backup '%s' of tdb '%s'\n", - tdb_path_backup, tdb_path)); - } - } else { - DEBUG(1, ("tdb '%s' is invalid\n", tdb_path)); - - ret =stat(tdb_path_backup, &st); - if (ret != 0) { - DEBUG(5, ("Could not stat '%s': %s\n", tdb_path_backup, - strerror(errno))); - DEBUG(1, ("No backup found.\n")); - } else { - DEBUG(1, ("backup '%s' found.\n", tdb_path_backup)); - ret = tdb_validate_open(tdb_path_backup, validate_fn); - if (ret != 0) { - DEBUG(1, ("Backup '%s' is invalid.\n", - tdb_path_backup)); - } - } - - if (ret != 0) { - int renamed = rename_file_with_suffix(ctx, tdb_path, - corrupt_suffix); - if (renamed != 0) { - DEBUG(1, ("Error moving tdb to '%s%s'\n", - tdb_path, corrupt_suffix)); - } else { - DEBUG(1, ("Corrupt tdb stored as '%s%s'\n", - tdb_path, corrupt_suffix)); - } - goto done; - } - - DEBUG(1, ("valid backup '%s' found\n", tdb_path_backup)); - ret = tdb_backup_with_rotate(ctx, tdb_path_backup, tdb_path, 0, - corrupt_suffix, True, True); - if (ret != 0) { - DEBUG(1, ("Error restoring backup from '%s'\n", - tdb_path_backup)); - } else { - DEBUG(1, ("Restored tdb backup from '%s'\n", - tdb_path_backup)); - } - } - -done: - TALLOC_FREE(ctx); - return ret; -} diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index a0df81eb6e..8326aba40a 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -25,6 +25,7 @@ #include "includes.h" #include "winbindd.h" +#include "tdb_validate.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_WINBIND -- cgit From eccbc32ae36790ad9471aaa89d115a8dffd7fb4c Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 28 Jan 2009 08:56:17 +0100 Subject: s3:tdb_validate: clean up leading tabs/spaces and trailing spaces. Michael --- source3/lib/tdb_validate.c | 56 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/source3/lib/tdb_validate.c b/source3/lib/tdb_validate.c index c1ca97787c..948201a5f2 100644 --- a/source3/lib/tdb_validate.c +++ b/source3/lib/tdb_validate.c @@ -22,8 +22,8 @@ #include "includes.h" #include "tdb_validate.h" -/* - * internal validation function, executed by the child. +/* + * internal validation function, executed by the child. */ static int tdb_validate_child(struct tdb_context *tdb, tdb_validate_data_func validate_fn) @@ -364,46 +364,46 @@ static int rename_file_with_suffix(TALLOC_CTX *ctx, const char *path, * do a backup of a tdb, moving the destination out of the way first */ static int tdb_backup_with_rotate(TALLOC_CTX *ctx, const char *src_path, - const char *dst_path, int hash_size, + const char *dst_path, int hash_size, const char *rotate_suffix, bool retry_norotate_if_nospc, bool rename_as_last_resort_if_nospc) { int ret; - rename_file_with_suffix(ctx, dst_path, rotate_suffix); + rename_file_with_suffix(ctx, dst_path, rotate_suffix); - ret = tdb_backup(ctx, src_path, dst_path, hash_size); + ret = tdb_backup(ctx, src_path, dst_path, hash_size); if (ret != 0) { DEBUG(10, ("backup of %s failed: %s\n", src_path, strerror(errno))); } - if ((ret != 0) && (errno == ENOSPC) && retry_norotate_if_nospc) - { - char *rotate_path = talloc_asprintf(ctx, "%s%s", dst_path, - rotate_suffix); - DEBUG(10, ("backup of %s failed due to lack of space\n", + if ((ret != 0) && (errno == ENOSPC) && retry_norotate_if_nospc) + { + char *rotate_path = talloc_asprintf(ctx, "%s%s", dst_path, + rotate_suffix); + DEBUG(10, ("backup of %s failed due to lack of space\n", src_path)); - DEBUGADD(10, ("trying to free some space by removing rotated " + DEBUGADD(10, ("trying to free some space by removing rotated " "dst %s\n", rotate_path)); - if (unlink(rotate_path) == -1) { - DEBUG(10, ("unlink of %s failed: %s\n", rotate_path, + if (unlink(rotate_path) == -1) { + DEBUG(10, ("unlink of %s failed: %s\n", rotate_path, strerror(errno))); - } else { - ret = tdb_backup(ctx, src_path, dst_path, hash_size); - } - TALLOC_FREE(rotate_path); - } - - if ((ret != 0) && (errno == ENOSPC) && rename_as_last_resort_if_nospc) - { - DEBUG(10, ("backup of %s failed due to lack of space\n", + } else { + ret = tdb_backup(ctx, src_path, dst_path, hash_size); + } + TALLOC_FREE(rotate_path); + } + + if ((ret != 0) && (errno == ENOSPC) && rename_as_last_resort_if_nospc) + { + DEBUG(10, ("backup of %s failed due to lack of space\n", src_path)); - DEBUGADD(10, ("using 'rename' as a last resort\n")); - ret = rename(src_path, dst_path); - } + DEBUGADD(10, ("using 'rename' as a last resort\n")); + ret = rename(src_path, dst_path); + } - return ret; + return ret; } /* @@ -416,8 +416,8 @@ static int tdb_backup_with_rotate(TALLOC_CTX *ctx, const char *src_path, * - if the tdb is corrupt: * - move the tdb to "name.corrupt" * - check if there is valid backup. - * if so, restore the backup. - * if restore is successful, return 0 (success), + * if so, restore the backup. + * if restore is successful, return 0 (success), * - otherwise return -1 (failure) */ int tdb_validate_and_backup(const char *tdb_path, -- cgit From 11b66ccaa10d260a00a4992ce3f9bb2861af953d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 28 Jan 2009 09:42:42 +0100 Subject: s3:build: don't use $(FLAGS) in linking targets - it is useless Michael --- source3/Makefile.in | 116 ++++++++++++++++++++++++++-------------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/source3/Makefile.in b/source3/Makefile.in index a0ec9a7452..947fdc9f28 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1345,7 +1345,7 @@ bin/.dummy: bin/smbd@EXEEXT@: $(BINARY_PREREQS) $(SMBD_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @BUILD_POPT@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(LDAP_LIBS) \ + @$(CC) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(LDAP_LIBS) \ $(KRB5LIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \ $(ACL_LIBS) $(PASSDB_LIBS) $(LIBS) $(DNSSD_LIBS) \ $(POPT_LIBS) @SMBD_LIBS@ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) \ @@ -1353,33 +1353,33 @@ bin/smbd@EXEEXT@: $(BINARY_PREREQS) $(SMBD_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARE bin/nmbd@EXEEXT@: $(BINARY_PREREQS) $(NMBD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(NMBD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ + @$(CC) -o $@ $(NMBD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(POPT_LIBS) \ $(KRB5LIBS) $(LDAP_LIBS) $(ZLIB_LIBS) bin/swat@EXEEXT@: $(BINARY_PREREQS) $(SWAT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SWAT_OBJ) $(LDFLAGS) $(DYNEXP) $(PRINT_LIBS) \ + @$(CC) -o $@ $(SWAT_OBJ) $(LDFLAGS) $(DYNEXP) $(PRINT_LIBS) \ $(AUTH_LIBS) $(LIBS) $(PASSDB_LIBS) $(POPT_LIBS) $(KRB5LIBS) \ $(LDAP_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/rpcclient@EXEEXT@: $(BINARY_PREREQS) $(RPCCLIENT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(PASSDB_LIBS) $(RPCCLIENT_OBJ) \ + @$(CC) -o $@ $(LDFLAGS) $(PASSDB_LIBS) $(RPCCLIENT_OBJ) \ $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) $(POPT_LIBS) \ $(KRB5LIBS) $(LDAP_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) \ $(WINBIND_LIBS) $(ZLIB_LIBS) bin/smbclient@EXEEXT@: $(BINARY_PREREQS) $(CLIENT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(DYNEXP) \ + @$(CC) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(DYNEXP) \ $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) $(POPT_LIBS) \ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) $(DNSSD_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/net@EXEEXT@: $(BINARY_PREREQS) $(NET_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @LIBNETAPI_SHARED@ @LIBLUA_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ + @$(CC) -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ $(POPT_LIBS) $(KRB5LIBS) $(UUID_LIBS) $(LDAP_LIBS) \ $(PASSDB_LIBS) $(TERMLDFLAGS) $(TERMLIBS) $(NSCD_LIBS) \ @INIPARSERLIBS@ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(LIBNETAPI_LIBS) $(LIBLUA_LIBS) -lm \ @@ -1387,153 +1387,153 @@ bin/net@EXEEXT@: $(BINARY_PREREQS) $(NET_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @L bin/profiles@EXEEXT@: $(BINARY_PREREQS) $(PROFILES_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(PROFILES_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ + @$(CC) -o $@ $(PROFILES_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ $(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) bin/smbspool@EXEEXT@: $(BINARY_PREREQS) $(CUPS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(CUPS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ + @$(CC) -o $@ $(CUPS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) \ $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/mount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_MOUNT_OBJ) @BUILD_POPT@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(CIFS_MOUNT_OBJ) $(DYNEXP) $(LDFLAGS) $(POPT_LIBS) + @$(CC) -o $@ $(CIFS_MOUNT_OBJ) $(DYNEXP) $(LDFLAGS) $(POPT_LIBS) bin/umount.cifs@EXEEXT@: $(BINARY_PREREQS) $(CIFS_UMOUNT_OBJ) @BUILD_POPT@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(CIFS_UMOUNT_OBJ) $(DYNEXP) $(LDFLAGS) $(POPT_LIBS) + @$(CC) -o $@ $(CIFS_UMOUNT_OBJ) $(DYNEXP) $(LDFLAGS) $(POPT_LIBS) bin/cifs.upcall@EXEEXT@: $(BINARY_PREREQS) $(CIFS_UPCALL_OBJ) $(LIBSMBCLIENT_OBJ1) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(CIFS_UPCALL_OBJ) $(DYNEXP) $(LDFLAGS) \ + @$(CC) -o $@ $(CIFS_UPCALL_OBJ) $(DYNEXP) $(LDFLAGS) \ -lkeyutils $(LIBS) $(LIBSMBCLIENT_OBJ1) $(KRB5LIBS) \ $(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) $(WINBIND_LIBS) \ $(LIBTDB_LIBS) $(NSCD_LIBS) bin/testparm@EXEEXT@: $(BINARY_PREREQS) $(TESTPARM_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(TESTPARM_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ + @$(CC) -o $@ $(TESTPARM_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ $(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) bin/smbstatus@EXEEXT@: $(BINARY_PREREQS) $(STATUS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(STATUS_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ + @$(CC) -o $@ $(STATUS_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ $(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) bin/smbcontrol@EXEEXT@: $(BINARY_PREREQS) $(SMBCONTROL_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) -DUSING_SMBCONTROL $(FLAGS) -o $@ \ + @$(CC) -DUSING_SMBCONTROL -o $@ \ $(SMBCONTROL_OBJ) $(DYNEXP) $(LDFLAGS) \ $(LIBS) $(LDAP_LIBS) @LIBUNWIND_PTRACE@ $(POPT_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) bin/smbtree@EXEEXT@: $(BINARY_PREREQS) $(SMBTREE_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBTREE_OBJ) $(LDFLAGS) $(DYNEXP) \ + @$(CC) -o $@ $(SMBTREE_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/smbpasswd@EXEEXT@: $(BINARY_PREREQS) $(SMBPASSWD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBPASSWD_OBJ) $(LDFLAGS) $(PASSDB_LIBS) \ + @$(CC) -o $@ $(SMBPASSWD_OBJ) $(LDFLAGS) $(PASSDB_LIBS) \ $(DYNEXP) $(LIBS) $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/pdbedit@EXEEXT@: $(BINARY_PREREQS) $(PDBEDIT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(PDBEDIT_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ + @$(CC) -o $@ $(PDBEDIT_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ $(POPT_LIBS) $(PASSDB_LIBS) $(LDAP_LIBS) $(LIBTALLOC_LIBS) \ $(LIBTDB_LIBS) $(WINBIND_LIBS) bin/smbget@EXEEXT@: $(BINARY_PREREQS) $(SMBGET_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBGET_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ + @$(CC) -o $@ $(SMBGET_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/nmblookup@EXEEXT@: $(BINARY_PREREQS) $(NMBLOOKUP_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(NMBLOOKUP_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ + @$(CC) -o $@ $(NMBLOOKUP_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ $(POPT_LIBS) $(LDAP_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) bin/smbtorture@EXEEXT@: $(BINARY_PREREQS) $(SMBTORTURE_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBTORTURE_OBJ) $(LDFLAGS) $(DYNEXP) \ + @$(CC) -o $@ $(SMBTORTURE_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) \ $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/talloctort@EXEEXT@: $(BINARY_PREREQS) $(TALLOCTORT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(TALLOCTORT_OBJ) $(LDFLAGS) \ + @$(CC) -o $@ $(TALLOCTORT_OBJ) $(LDFLAGS) \ $(DYNEXP) $(LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) bin/replacetort@EXEEXT@: $(REPLACETORT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(REPLACETORT_OBJ) $(LDFLAGS) \ + @$(CC) @PIE_LDFLAGS@ -o $@ $(REPLACETORT_OBJ) $(LDFLAGS) \ $(DYNEXP) $(LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) bin/smbconftort@EXEEXT@: $(SMBCONFTORT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(SMBCONFTORT_OBJ) $(LDFLAGS) \ + @$(CC) @PIE_LDFLAGS@ -o $@ $(SMBCONFTORT_OBJ) $(LDFLAGS) \ $(DYNEXP) $(LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) bin/masktest@EXEEXT@: $(BINARY_PREREQS) $(MASKTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(MASKTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ + @$(CC) -o $@ $(MASKTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/msgtest@EXEEXT@: $(BINARY_PREREQS) $(MSGTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(MSGTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ + @$(CC) -o $@ $(MSGTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/smbcacls@EXEEXT@: $(BINARY_PREREQS) $(SMBCACLS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBCACLS_OBJ) $(DYNEXP) $(LDFLAGS) \ + @$(CC) -o $@ $(SMBCACLS_OBJ) $(DYNEXP) $(LDFLAGS) \ $(LIBS) $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/smbcquotas@EXEEXT@: $(BINARY_PREREQS) $(SMBCQUOTAS_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBCQUOTAS_OBJ) $(DYNEXP) $(LDFLAGS) \ + @$(CC) -o $@ $(SMBCQUOTAS_OBJ) $(DYNEXP) $(LDFLAGS) \ $(LIBS) $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/eventlogadm@EXEEXT@: $(BINARY_PREREQS) $(EVTLOGADM_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(EVTLOGADM_OBJ) $(DYNEXP) $(LDFLAGS) \ + @$(CC) -o $@ $(EVTLOGADM_OBJ) $(DYNEXP) $(LDFLAGS) \ $(LIBS) $(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) bin/sharesec@EXEEXT@: $(BINARY_PREREQS) $(SHARESEC_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SHARESEC_OBJ) $(DYNEXP) $(LDFLAGS) \ + @$(CC) -o $@ $(SHARESEC_OBJ) $(DYNEXP) $(LDFLAGS) \ $(LIBS) $(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) bin/locktest@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCKTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ + @$(CC) -o $@ $(LOCKTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/nsstest@EXEEXT@: $(BINARY_PREREQS) $(NSSTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(NSSTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ + @$(CC) -o $@ $(NSSTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/pdbtest@EXEEXT@: $(BINARY_PREREQS) $(PDBTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(PDBTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ + @$(CC) -o $@ $(PDBTEST_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \ $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) $(ZLIB_LIBS) bin/vfstest@EXEEXT@: $(BINARY_PREREQS) $(VFSTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(VFSTEST_OBJ) $(LDFLAGS) $(TERMLDFLAGS) \ + @$(CC) -o $@ $(VFSTEST_OBJ) $(LDFLAGS) $(TERMLDFLAGS) \ $(TERMLIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \ $(ACL_LIBS) $(LIBS) $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) \ @SMBD_LIBS@ $(NSCD_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) \ @@ -1541,59 +1541,59 @@ bin/vfstest@EXEEXT@: $(BINARY_PREREQS) $(VFSTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SH bin/smbiconv@EXEEXT@: $(BINARY_PREREQS) $(SMBICONV_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBICONV_OBJ) $(LDFLAGS) $(TERMLDFLAGS) \ + @$(CC) -o $@ $(SMBICONV_OBJ) $(LDFLAGS) $(TERMLDFLAGS) \ $(TERMLIBS) $(DYNEXP) $(LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) bin/log2pcap@EXEEXT@: $(BINARY_PREREQS) $(LOG2PCAP_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOG2PCAP_OBJ) $(LDFLAGS) $(DYNEXP) \ + @$(CC) -o $@ $(LOG2PCAP_OBJ) $(LDFLAGS) $(DYNEXP) \ $(POPT_LIBS) $(LIBS) $(LIBTALLOC_LIBS) bin/locktest2@EXEEXT@: $(BINARY_PREREQS) $(LOCKTEST2_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LOCKTEST2_OBJ) $(LDFLAGS) $(DYNEXP) \ + @$(CC) -o $@ $(LOCKTEST2_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/debug2html@EXEEXT@: $(BINARY_PREREQS) $(DEBUG2HTML_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(DEBUG2HTML_OBJ) $(LDFLAGS) $(DYNEXP) \ + @$(CC) -o $@ $(DEBUG2HTML_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(LIBTALLOC_LIBS) bin/smbfilter@EXEEXT@: $(BINARY_PREREQS) $(SMBFILTER_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBFILTER_OBJ) $(LDFLAGS) $(LIBS) \ + @$(CC) -o $@ $(SMBFILTER_OBJ) $(LDFLAGS) $(LIBS) \ $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(ZLIB_LIBS) bin/ldbedit: $(BINARY_PREREQS) $(LDBEDIT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDBEDIT_OBJ) $(DYNEXP) $(LDFLAGS) \ + @$(CC) -o $@ $(LDBEDIT_OBJ) $(DYNEXP) $(LDFLAGS) \ $(LIBS) $(POPT_LIBS) $(LDAP_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) bin/ldbsearch: $(BINARY_PREREQS) $(LDBSEARCH_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDBSEARCH_OBJ) $(DYNEXP) $(LDFLAGS) \ + @$(CC) -o $@ $(LDBSEARCH_OBJ) $(DYNEXP) $(LDFLAGS) \ $(LIBS) $(POPT_LIBS) $(LDAP_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) bin/ldbadd: $(BINARY_PREREQS) $(LDBADD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDBADD_OBJ) $(DYNEXP) $(LDFLAGS) \ + @$(CC) -o $@ $(LDBADD_OBJ) $(DYNEXP) $(LDFLAGS) \ $(LIBS) $(POPT_LIBS) $(LDAP_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) bin/ldbmodify: $(BINARY_PREREQS) $(LDBMODIFY_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDBMODIFY_OBJ) $(DYNEXP) $(LDFLAGS) \ + @$(CC) -o $@ $(LDBMODIFY_OBJ) $(DYNEXP) $(LDFLAGS) \ $(LIBS) $(POPT_LIBS) $(LDAP_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) bin/ldbdel: $(BINARY_PREREQS) $(LDBDEL_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDBDEL_OBJ) $(DYNEXP) $(LDFLAGS) \ + @$(CC) -o $@ $(LDBDEL_OBJ) $(DYNEXP) $(LDFLAGS) \ $(LIBS) $(POPT_LIBS) $(LDAP_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) @@ -2263,14 +2263,14 @@ bin/librpc_echo.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_ECHO_OBJ) bin/winbindd@EXEEXT@: $(BINARY_PREREQS) $(WINBINDD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo "Linking $@" - @$(CC) $(FLAGS) -o $@ $(WINBINDD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ + @$(CC) -o $@ $(WINBINDD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \ $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) \ $(PASSDB_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) \ $(ZLIB_LIBS) bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo "Linking $@" - @$(CC) $(FLAGS) -o $@ $(VLP_OBJ) $(LDFLAGS) $(DYNEXP) \ + @$(CC) -o $@ $(VLP_OBJ) $(LDFLAGS) $(DYNEXP) \ $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) $(POPT_LIBS) \ $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) \ @@ -2561,14 +2561,14 @@ bin/security.@SHLIBEXT@: $(BINARY_PREREQS) libgpo/gpext/security.o bin/wbinfo@EXEEXT@: $(BINARY_PREREQS) $(WBINFO_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(WBINFO_OBJ) $(DYNEXP) $(LIBS) \ + @$(CC) -o $@ $(LDFLAGS) $(WBINFO_OBJ) $(DYNEXP) $(LIBS) \ $(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) \ $(WINBIND_LIBS) bin/ntlm_auth@EXEEXT@: $(BINARY_PREREQS) $(NTLM_AUTH_OBJ) $(PARAM_OBJ) \ $(LIB_NONSMBD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(DYNEXP) $(NTLM_AUTH_OBJ) \ + @$(CC) -o $@ $(LDFLAGS) $(DYNEXP) $(NTLM_AUTH_OBJ) \ $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(LIBS) \ $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) $(WINBIND_LIBS) @@ -2581,53 +2581,53 @@ bin/pam_smbpass.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_SMBPASS_OBJ) @LIBTALLOC_SHAR bin/tdbbackup@EXEEXT@: $(BINARY_PREREQS) $(TDBBACKUP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBBACKUP_OBJ) $(DYNEXP) \ + @$(CC) -o $@ $(LDFLAGS) $(TDBBACKUP_OBJ) $(DYNEXP) \ $(LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) bin/tdbtool@EXEEXT@: $(BINARY_PREREQS) $(TDBTOOL_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTOOL_OBJ) $(DYNEXP) \ + @$(CC) -o $@ $(LDFLAGS) $(TDBTOOL_OBJ) $(DYNEXP) \ $(LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) bin/tdbdump@EXEEXT@: $(BINARY_PREREQS) $(TDBDUMP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBDUMP_OBJ) $(DYNEXP) \ + @$(CC) -o $@ $(LDFLAGS) $(TDBDUMP_OBJ) $(DYNEXP) \ $(LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) bin/tdbtorture@EXEEXT@: $(BINARY_PREREQS) $(TDBTORTURE_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(LDFLAGS) $(TDBTORTURE_OBJ) $(DYNEXP) \ + @$(CC) -o $@ $(LDFLAGS) $(TDBTORTURE_OBJ) $(DYNEXP) \ $(LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) bin/t_strcmp@EXEEXT@: $(BINARY_PREREQS) @LIBTALLOC_SHARED@ bin/libbigballofmud.@SHLIBEXT@ torture/t_strcmp.o - $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) $(LIBTALLOC_LIBS) \ + $(CC) -o $@ $(DYNEXP) $(LIBS) $(LIBTALLOC_LIBS) \ torture/t_strcmp.o -L ./bin -lbigballofmud bin/t_strstr@EXEEXT@: $(BINARY_PREREQS) @LIBTALLOC_SHARED@ bin/libbigballofmud.@SHLIBEXT@ torture/t_strstr.o - $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) $(LIBTALLOC_LIBS) \ + $(CC) -o $@ $(DYNEXP) $(LIBS) $(LIBTALLOC_LIBS) \ torture/t_strstr.o -L ./bin -lbigballofmud bin/t_strappend@EXEEXT@: $(BINARY_PREREQS) @LIBTALLOC_SHARED@ bin/libbigballofmud.@SHLIBEXT@ torture/t_strappend.o - $(CC) $(FLAGS) -o $@ $(DYNEXP) $(LIBS) $(LIBTALLOC_LIBS) \ + $(CC) -o $@ $(DYNEXP) $(LIBS) $(LIBTALLOC_LIBS) \ torture/t_strappend.o -L ./bin -lbigballofmud bin/t_stringoverflow@EXEEXT@: $(BINARY_PREREQS) bin/libbigballofmud.@SHLIBEXT@ torture/t_stringoverflow.o - $(CC) $(FLAGS) -o $@ $(DYNEXP) torture/t_stringoverflow.o \ + $(CC) -o $@ $(DYNEXP) torture/t_stringoverflow.o \ -L./bin -lbigballofmud bin/timelimit@EXEEXT@: script/tests/timelimit.o @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(DYNEXP) script/tests/timelimit.o + @$(CC) -o $@ $(DYNEXP) script/tests/timelimit.o bin/rpc_open_tcp@EXEEXT@: $(BINARY_PREREQS) $(RPC_OPEN_TCP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo "Linking $@" - @$(CC) $(FLAGS) -o $@ $(RPC_OPEN_TCP_OBJ) $(LDFLAGS) $(DYNEXP) \ + @$(CC) -o $@ $(RPC_OPEN_TCP_OBJ) $(LDFLAGS) $(DYNEXP) \ $(LIBS) $(LIBTALLOC_LIBS) @LIBTDB_SHARED@ $(WINBIND_LIBS) \ $(LDAP_LIBS) $(KRB5LIBS) $(NSCD_LIBS) bin/test_lp_load@EXEEXT@: $(BINARY_PREREQS) $(TEST_LP_LOAD_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @echo "Linking $@" - @$(CC) $(FLAGS) -o $@ $(TEST_LP_LOAD_OBJ) \ + @$(CC) -o $@ $(TEST_LP_LOAD_OBJ) \ $(LDFLAGS) $(DYNEEXP) $(LIBS) \ $(LDAP_LIBS) \ $(POPT_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) -- cgit From db7ee3733fbca937612247ad5d821121b4792112 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Jan 2009 09:35:44 +0100 Subject: s3: try to make 'make selftest' work again metze --- selftest/target/Samba3.pm | 40 ++++++++++++++++++++-------------------- source3/Makefile.in | 7 +++++-- source3/samba4.mk | 4 ++-- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index eb6db1a407..7c3c0b0ea9 100644 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -179,26 +179,26 @@ sub check_or_start($$$$) { write_pid($env_vars, "nmbd", $pid); print "DONE\n"; -# disable winbindd until the build-farm faked_users work with it -# unlink($env_vars->{WINBINDD_TEST_LOG}); -# print "STARTING WINBINDD..."; -# $pid = fork(); -# if ($pid == 0) { -# open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}"; -# open STDERR, '>&STDOUT'; -# -# $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR}; -# -# my @optargs = ("-d0"); -# if (defined($ENV{WINBINDD_OPTIONS})) { -# @optargs = split(/ /, $ENV{WINBINDD_OPTIONS}); -# } -# -# $ENV{MAKE_TEST_BINARY} = $self->binpath("winbindd"); -# exec($self->binpath("timelimit"), $winbindd_maxtime, $ENV{WINBINDD_VALGRIND}, $self->binpath("winbindd"), "-F", "-S", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!"); -# } -# write_pid($env_vars, "winbindd", $pid); -# print "DONE\n"; + unlink($env_vars->{WINBINDD_TEST_LOG}); + print "STARTING WINBINDD..."; + $pid = fork(); + if ($pid == 0) { + open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}"; + open STDERR, '>&STDOUT'; + + $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR}; + + my @optargs = ("-d0"); + if (defined($ENV{WINBINDD_OPTIONS})) { + @optargs = split(/ /, $ENV{WINBINDD_OPTIONS}); + } + + $ENV{$ENV{LIB_PATH_VAR}} = $self->{bindir}; + $ENV{MAKE_TEST_BINARY} = $self->binpath("winbindd"); + exec($self->binpath("timelimit"), $winbindd_maxtime, $ENV{WINBINDD_VALGRIND}, $self->binpath("winbindd"), "-F", "-S", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!"); + } + write_pid($env_vars, "winbindd", $pid); + print "DONE\n"; unlink($env_vars->{SMBD_TEST_LOG}); print "STARTING SMBD..."; diff --git a/source3/Makefile.in b/source3/Makefile.in index 947fdc9f28..607044fd83 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -2951,12 +2951,15 @@ valgrindtest:: all torture timelimit SELFTEST_FORMAT = plain selftestdir = ../selftest +S3_LD_LIBPATH_OVERRIDE = $(LIB_PATH_VAR)="$(builddir)/bin" + selftest:: all torture timelimit - @$(selftestdir)/selftest.pl --prefix=st --target=samba3 \ + @$(S3_LD_LIBPATH_OVERRIDE) $(selftestdir)/selftest.pl \ + --prefix=${selftest_prefix} --target=samba3 \ --testlist="$(srcdir)/selftest/tests.sh|" \ --expected-failures=$(srcdir)/selftest/knownfail \ --exclude=$(srcdir)/selftest/skip \ - --socket-wrapper $(TESTS) --format=$(SELFTEST_FORMAT) + --socket-wrapper $(TESTS) --format=$(SELFTEST_FORMAT) --immediate selftest-%: $(MAKE) selftest TESTS=$* diff --git a/source3/samba4.mk b/source3/samba4.mk index 49afa3a2e2..715961e4de 100644 --- a/source3/samba4.mk +++ b/source3/samba4.mk @@ -170,9 +170,9 @@ everything:: $(patsubst %,%4,$(BINARIES)) setup: @ln -sf ../source4/setup setup -LD_LIBPATH_OVERRIDE = $(LIB_PATH_VAR)="$(builddir)/bin/shared" +S4_LD_LIBPATH_OVERRIDE = $(LIB_PATH_VAR)="$(builddir)/bin/shared" -SELFTEST4 = $(LD_LIBPATH_OVERRIDE) EXEEXT="4" $(PERL) $(selftestdir)/selftest.pl --prefix=st4 \ +SELFTEST4 = $(S4_LD_LIBPATH_OVERRIDE) EXEEXT="4" $(PERL) $(selftestdir)/selftest.pl --prefix=st4 \ --builddir=$(builddir) --srcdir=$(samba4srcdir) \ --exeext=4 \ --expected-failures=$(samba4srcdir)/selftest/knownfail \ -- cgit From ac6cf387fff69581940988a65a660c744fa08e99 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 28 Jan 2009 10:35:17 +0100 Subject: s3:util_tdb: remove duplicate prototypes (from ../lib/util/util_tdb.h) Michael --- source3/include/util_tdb.h | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/source3/include/util_tdb.h b/source3/include/util_tdb.h index 21f64fa3d3..c79436434f 100644 --- a/source3/include/util_tdb.h +++ b/source3/include/util_tdb.h @@ -24,6 +24,7 @@ #include "talloc.h" /* for tdb_wrap_open() */ #include "../libcli/util/ntstatus.h" /* for map_nt_error_from_tdb() */ +#include "../../lib/util/util_tdb.h" struct tdb_wrap { struct tdb_context *tdb; @@ -31,37 +32,15 @@ struct tdb_wrap { struct tdb_wrap *next, *prev; }; -TDB_DATA make_tdb_data(const uint8_t *dptr, size_t dsize); -TDB_DATA string_tdb_data(const char *string); -TDB_DATA string_term_tdb_data(const char *string); - int tdb_chainlock_with_timeout( struct tdb_context *tdb, TDB_DATA key, unsigned int timeout); -int tdb_lock_bystring(struct tdb_context *tdb, const char *keyval); int tdb_lock_bystring_with_timeout(struct tdb_context *tdb, const char *keyval, int timeout); -void tdb_unlock_bystring(struct tdb_context *tdb, const char *keyval); int tdb_read_lock_bystring_with_timeout(TDB_CONTEXT *tdb, const char *keyval, unsigned int timeout); -void tdb_read_unlock_bystring(struct tdb_context *tdb, const char *keyval); - -int32_t tdb_fetch_int32_byblob(struct tdb_context *tdb, TDB_DATA key); -int32_t tdb_fetch_int32(struct tdb_context *tdb, const char *keystr); -bool tdb_store_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t value); -bool tdb_store_uint32(struct tdb_context *tdb, const char *keystr, uint32_t value); -int tdb_store_int32_byblob(struct tdb_context *tdb, TDB_DATA key, int32_t v); -int tdb_store_int32(struct tdb_context *tdb, const char *keystr, int32_t v); -bool tdb_fetch_uint32_byblob(struct tdb_context *tdb, TDB_DATA key, uint32_t *value); -bool tdb_fetch_uint32(struct tdb_context *tdb, const char *keystr, uint32_t *value); -int32_t tdb_change_int32_atomic(struct tdb_context *tdb, const char *keystr, int32_t *oldval, int32_t change_val); -bool tdb_change_uint32_atomic(struct tdb_context *tdb, const char *keystr, - uint32_t *oldval, uint32_t change_val); -int tdb_store_bystring(struct tdb_context *tdb, const char *keystr, TDB_DATA data, int flags); int tdb_trans_store_bystring(TDB_CONTEXT *tdb, const char *keystr, TDB_DATA data, int flags); -TDB_DATA tdb_fetch_bystring(struct tdb_context *tdb, const char *keystr); -int tdb_delete_bystring(struct tdb_context *tdb, const char *keystr); int tdb_trans_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag); int tdb_trans_delete(struct tdb_context *tdb, TDB_DATA key); -- cgit From c2a2006f8a8fdb8941158fc121ce551604cd1bae Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Jan 2009 10:50:55 +0100 Subject: s3:torture: support SMB_CONF_PATH envvar in smbtorture metze --- source3/torture/torture.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 8a1a61e79a..85233bc0ae 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -5831,6 +5831,11 @@ static void usage(void) load_case_tables(); + if (is_default_dyn_CONFIGFILE()) { + if(getenv("SMB_CONF_PATH")) { + set_dyn_CONFIGFILE(getenv("SMB_CONF_PATH")); + } + } lp_load(get_dyn_CONFIGFILE(),True,False,False,True); load_interfaces(); -- cgit From ab63bad94bfc378aca08d3314692de90e1aa1bf3 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Sat, 24 Jan 2009 10:00:13 +0100 Subject: async_sock: Move to top level --- lib/async_req/async_sock.c | 703 +++++++++++++++++++++++++++++++++++++++++++ lib/async_req/async_sock.h | 51 ++++ lib/async_req/config.mk | 2 +- source3/Makefile.in | 2 +- source3/include/async_sock.h | 51 ---- source3/include/includes.h | 2 +- source3/lib/async_sock.c | 693 ------------------------------------------ 7 files changed, 757 insertions(+), 747 deletions(-) create mode 100644 lib/async_req/async_sock.c create mode 100644 lib/async_req/async_sock.h delete mode 100644 source3/include/async_sock.h delete mode 100644 source3/lib/async_sock.c diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c new file mode 100644 index 0000000000..7febc54fd4 --- /dev/null +++ b/lib/async_req/async_sock.c @@ -0,0 +1,703 @@ +/* + Unix SMB/CIFS implementation. + async socket syscalls + Copyright (C) Volker Lendecke 2008 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 . +*/ + +#include "includes.h" +#include "lib/talloc/talloc.h" +#include "lib/tevent/tevent.h" +#include "lib/async_req/async_req.h" +#include "lib/async_req/async_sock.h" +#include + +#ifndef TALLOC_FREE +#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_SENDALL, + ASYNC_SYSCALL_RECV, + ASYNC_SYSCALL_RECVALL, + ASYNC_SYSCALL_CONNECT +}; + +/** + * 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_sendall { + int fd; + const void *buffer; + size_t length; + int flags; + size_t sent; + } param_sendall; + struct param_recv { + int fd; + void *buffer; + size_t length; + int flags; + } param_recv; + struct param_recvall { + int fd; + void *buffer; + size_t length; + int flags; + size_t received; + } param_recvall; + struct param_connect { + /** + * connect needs to be done on a nonblocking + * socket. Keep the old flags around + */ + long old_sockflags; + int fd; + const struct sockaddr *address; + socklen_t address_len; + } param_connect; + } param; + + union { + ssize_t result_ssize_t; + size_t result_size_t; + int result_int; + } result; + int sys_errno; +}; + +/** + * @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, NT_STATUS_INTERNAL_ERROR); + 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 "sendall" syscall group + * @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_sendall_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_sendall *p = &state->param.param_sendall; + + if (state->syscall_type != ASYNC_SYSCALL_SENDALL) { + async_req_error(req, NT_STATUS_INTERNAL_ERROR); + return; + } + + state->result.result_ssize_t = send(p->fd, + (const char *)p->buffer + p->sent, + p->length - p->sent, p->flags); + state->sys_errno = errno; + + if (state->result.result_ssize_t == -1) { + async_req_error(req, map_nt_error_from_unix(state->sys_errno)); + return; + } + + if (state->result.result_ssize_t == 0) { + async_req_error(req, NT_STATUS_END_OF_FILE); + return; + } + + p->sent += state->result.result_ssize_t; + if (p->sent > p->length) { + async_req_error(req, NT_STATUS_INTERNAL_ERROR); + return; + } + + if (p->sent == p->length) { + TALLOC_FREE(state->fde); + async_req_done(req); + } +} + +/** + * @brief Send all bytes to a socket + * @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) + * + * async_sendall calls send(2) as long as it is necessary to send all of the + * "length" bytes + */ + +struct async_req *sendall_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_SENDALL, + fd, TEVENT_FD_WRITE, async_sendall_callback, + &state); + if (result == NULL) { + return NULL; + } + + state->param.param_sendall.fd = fd; + state->param.param_sendall.buffer = buffer; + state->param.param_sendall.length = length; + state->param.param_sendall.flags = flags; + state->param.param_sendall.sent = 0; + + return result; +} + +NTSTATUS sendall_recv(struct async_req *req) +{ + return async_req_simple_recv(req); +} + +/** + * 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, NT_STATUS_INTERNAL_ERROR); + 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; +} + +/** + * fde event handler for the "recvall" syscall group + * @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_recvall_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_recvall *p = &state->param.param_recvall; + + if (state->syscall_type != ASYNC_SYSCALL_RECVALL) { + async_req_error(req, NT_STATUS_INTERNAL_ERROR); + return; + } + + state->result.result_ssize_t = recv(p->fd, + (char *)p->buffer + p->received, + p->length - p->received, p->flags); + state->sys_errno = errno; + + if (state->result.result_ssize_t == -1) { + async_req_error(req, map_nt_error_from_unix(state->sys_errno)); + return; + } + + if (state->result.result_ssize_t == 0) { + async_req_error(req, NT_STATUS_END_OF_FILE); + return; + } + + p->received += state->result.result_ssize_t; + if (p->received > p->length) { + async_req_error(req, NT_STATUS_INTERNAL_ERROR); + return; + } + + if (p->received == p->length) { + TALLOC_FREE(state->fde); + async_req_done(req); + } +} + +/** + * Receive a specified number of bytes from a socket + * @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) + * + * async_recvall will call recv(2) until "length" bytes are received + */ + +struct async_req *recvall_send(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_RECVALL, + fd, TEVENT_FD_READ, async_recvall_callback, + &state); + if (result == NULL) { + return NULL; + } + + state->param.param_recvall.fd = fd; + state->param.param_recvall.buffer = buffer; + state->param.param_recvall.length = length; + state->param.param_recvall.flags = flags; + state->param.param_recvall.received = 0; + + return result; +} + +NTSTATUS recvall_recv(struct async_req *req) +{ + return async_req_simple_recv(req); +} + +struct async_connect_state { + int fd; + int result; + int sys_errno; + long old_sockflags; +}; + +static void async_connect_connected(struct tevent_context *ev, + struct tevent_fd *fde, uint16_t flags, + void *priv); + +/** + * @brief async version of connect(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] address Where to connect? + * @param[in] address_len Length of *address + * @retval The async request + * + * This function sets the socket into non-blocking state to be able to call + * connect in an async state. This will be reset when the request is finished. + */ + +struct async_req *async_connect_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + int fd, const struct sockaddr *address, + socklen_t address_len) +{ + struct async_req *result; + struct async_connect_state *state; + struct tevent_fd *fde; + NTSTATUS status; + + if (!async_req_setup(mem_ctx, &result, &state, + struct async_connect_state)) { + return NULL; + } + + /** + * We have to set the socket to nonblocking for async connect(2). Keep + * the old sockflags around. + */ + + state->fd = fd; + state->sys_errno = 0; + + state->old_sockflags = fcntl(fd, F_GETFL, 0); + if (state->old_sockflags == -1) { + goto post_errno; + } + + set_blocking(fd, false); + + state->result = connect(fd, address, address_len); + if (state->result == 0) { + state->sys_errno = 0; + status = NT_STATUS_OK; + goto post_status; + } + + /** + * A number of error messages show that something good is progressing + * and that we have to wait for readability. + * + * If none of them are present, bail out. + */ + + if (!(errno == EINPROGRESS || errno == EALREADY || +#ifdef EISCONN + errno == EISCONN || +#endif + errno == EAGAIN || errno == EINTR)) { + goto post_errno; + } + + fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ | TEVENT_FD_WRITE, + async_connect_connected, result); + if (fde == NULL) { + status = NT_STATUS_NO_MEMORY; + goto post_status; + } + return result; + + post_errno: + state->sys_errno = errno; + status = map_nt_error_from_unix(state->sys_errno); + post_status: + fcntl(fd, F_SETFL, state->old_sockflags); + if (!async_post_status(result, ev, status)) { + goto fail; + } + return result; + fail: + TALLOC_FREE(result); + return NULL; +} + +/** + * fde event handler for connect(2) + * @param[in] ev The event context that sent us here + * @param[in] fde The file descriptor event associated with the connect + * @param[in] flags Indicate read/writeability of the socket + * @param[in] priv private data, "struct async_req *" in this case + */ + +static void async_connect_connected(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_connect_state *state = talloc_get_type_abort( + req->private_data, struct async_connect_state); + + TALLOC_FREE(fde); + + /* + * Stevens, Network Programming says that if there's a + * successful connect, the socket is only writable. Upon an + * error, it's both readable and writable. + */ + if ((flags & (TEVENT_FD_READ|TEVENT_FD_WRITE)) + == (TEVENT_FD_READ|TEVENT_FD_WRITE)) { + int sockerr; + socklen_t err_len = sizeof(sockerr); + + if (getsockopt(state->fd, SOL_SOCKET, SO_ERROR, + (void *)&sockerr, &err_len) == 0) { + errno = sockerr; + } + + state->sys_errno = errno; + + DEBUG(10, ("connect returned %s\n", strerror(errno))); + + fcntl(state->fd, F_SETFL, state->old_sockflags); + async_req_error(req, map_nt_error_from_unix(state->sys_errno)); + return; + } + + state->sys_errno = 0; + async_req_done(req); +} + +NTSTATUS async_connect_recv(struct async_req *req, int *perrno) +{ + struct async_connect_state *state = talloc_get_type_abort( + req->private_data, struct async_connect_state); + NTSTATUS status; + + fcntl(state->fd, F_SETFL, state->old_sockflags); + + *perrno = state->sys_errno; + + if (async_req_is_error(req, &status)) { + return status; + } + if (state->sys_errno == 0) { + return NT_STATUS_OK; + } + return map_nt_error_from_unix(state->sys_errno); +} diff --git a/lib/async_req/async_sock.h b/lib/async_req/async_sock.h new file mode 100644 index 0000000000..fd41acacbb --- /dev/null +++ b/lib/async_req/async_sock.h @@ -0,0 +1,51 @@ +/* + Unix SMB/CIFS implementation. + async socket operations + Copyright (C) Volker Lendecke 2008 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 . +*/ + +#ifndef __ASYNC_SOCK_H__ +#define __ASYNC_SOCK_H__ + +#include "includes.h" + +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 async_req *async_connect_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + int fd, const struct sockaddr *address, + socklen_t address_len); +NTSTATUS async_connect_recv(struct async_req *req, int *perrno); + +struct async_req *sendall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, + int fd, const void *buffer, size_t length, + int flags); +NTSTATUS sendall_recv(struct async_req *req); + +struct async_req *recvall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, + int fd, void *buffer, size_t length, + int flags); +NTSTATUS recvall_recv(struct async_req *req); + +#endif diff --git a/lib/async_req/config.mk b/lib/async_req/config.mk index 08d5288a48..8cc594082c 100644 --- a/lib/async_req/config.mk +++ b/lib/async_req/config.mk @@ -1,3 +1,3 @@ [SUBSYSTEM::LIBASYNC_REQ] -LIBASYNC_REQ_OBJ_FILES = $(addprefix ../lib/async_req/, async_req.o) +LIBASYNC_REQ_OBJ_FILES = $(addprefix ../lib/async_req/, async_req.o async_sock.o) diff --git a/source3/Makefile.in b/source3/Makefile.in index 607044fd83..e786a81efa 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -344,7 +344,7 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \ lib/messages_ctdbd.o lib/packet.o lib/ctdbd_conn.o \ lib/interfaces.o lib/memcache.o \ lib/util_transfer_file.o ../lib/async_req/async_req.o \ - lib/async_sock.o \ + ../lib/async_req/async_sock.o \ $(TDB_LIB_OBJ) \ $(VERSION_OBJ) lib/charcnv.o lib/debug.o lib/fault.o \ lib/interface.o lib/pidfile.o \ diff --git a/source3/include/async_sock.h b/source3/include/async_sock.h deleted file mode 100644 index c6f95d64d5..0000000000 --- a/source3/include/async_sock.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - Unix SMB/CIFS implementation. - async socket operations - Copyright (C) Volker Lendecke 2008 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 . -*/ - -#ifndef __ASYNC_SOCK_H__ -#define __ASYNC_SOCK_H__ - -#include "includes.h" - -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 event_context *ev, - int fd, const void *buffer, size_t length, - int flags); -struct async_req *async_recv(TALLOC_CTX *mem_ctx, struct event_context *ev, - int fd, void *buffer, size_t length, - int flags); -struct async_req *async_connect_send(TALLOC_CTX *mem_ctx, - struct event_context *ev, - int fd, const struct sockaddr *address, - socklen_t address_len); -NTSTATUS async_connect_recv(struct async_req *req, int *perrno); - -struct async_req *sendall_send(TALLOC_CTX *mem_ctx, struct event_context *ev, - int fd, const void *buffer, size_t length, - int flags); -NTSTATUS sendall_recv(struct async_req *req); - -struct async_req *recvall_send(TALLOC_CTX *mem_ctx, struct event_context *ev, - int fd, void *buffer, size_t length, - int flags); -NTSTATUS recvall_recv(struct async_req *req); - -#endif diff --git a/source3/include/includes.h b/source3/include/includes.h index ea856f1c16..7b0b270f60 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -649,7 +649,7 @@ struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx); #include "memcache.h" #include "../lib/async_req/async_req.h" #include "async_smb.h" -#include "async_sock.h" +#include "../lib/async_req/async_sock.h" #include "services.h" #include "eventlog.h" diff --git a/source3/lib/async_sock.c b/source3/lib/async_sock.c deleted file mode 100644 index 73ff6f2870..0000000000 --- a/source3/lib/async_sock.c +++ /dev/null @@ -1,693 +0,0 @@ -/* - Unix SMB/CIFS implementation. - async socket syscalls - Copyright (C) Volker Lendecke 2008 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 . -*/ - -#include "includes.h" - -/** - * Discriminator for async_syscall_state - */ -enum async_syscall_type { - ASYNC_SYSCALL_SEND, - ASYNC_SYSCALL_SENDALL, - ASYNC_SYSCALL_RECV, - ASYNC_SYSCALL_RECVALL, - ASYNC_SYSCALL_CONNECT -}; - -/** - * Holder for syscall arguments and the result - */ - -struct async_syscall_state { - enum async_syscall_type syscall_type; - struct fd_event *fde; - - union { - struct param_send { - int fd; - const void *buffer; - size_t length; - int flags; - } param_send; - struct param_sendall { - int fd; - const void *buffer; - size_t length; - int flags; - size_t sent; - } param_sendall; - struct param_recv { - int fd; - void *buffer; - size_t length; - int flags; - } param_recv; - struct param_recvall { - int fd; - void *buffer; - size_t length; - int flags; - size_t received; - } param_recvall; - struct param_connect { - /** - * connect needs to be done on a nonblocking - * socket. Keep the old flags around - */ - long old_sockflags; - int fd; - const struct sockaddr *address; - socklen_t address_len; - } param_connect; - } param; - - union { - ssize_t result_ssize_t; - size_t result_size_t; - int result_int; - } result; - int sys_errno; -}; - -/** - * @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 event_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 EVENT_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 event_context *ev, - enum async_syscall_type type, - int fd, - uint16_t fde_flags, - void (*fde_cb)(struct event_context *ev, - struct fd_event *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 = event_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 EVENT_FD_WRITE here - * @param[in] priv private data, "struct async_req *" in this case - */ - -static void async_send_callback(struct event_context *ev, - struct fd_event *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, NT_STATUS_INTERNAL_ERROR); - 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 event_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, EVENT_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 "sendall" syscall group - * @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 EVENT_FD_WRITE here - * @param[in] priv private data, "struct async_req *" in this case - */ - -static void async_sendall_callback(struct event_context *ev, - struct fd_event *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_sendall *p = &state->param.param_sendall; - - if (state->syscall_type != ASYNC_SYSCALL_SENDALL) { - async_req_error(req, NT_STATUS_INTERNAL_ERROR); - return; - } - - state->result.result_ssize_t = send(p->fd, (char *)p->buffer + p->sent, - p->length - p->sent, p->flags); - state->sys_errno = errno; - - if (state->result.result_ssize_t == -1) { - async_req_error(req, map_nt_error_from_unix(state->sys_errno)); - return; - } - - if (state->result.result_ssize_t == 0) { - async_req_error(req, NT_STATUS_END_OF_FILE); - return; - } - - p->sent += state->result.result_ssize_t; - if (p->sent > p->length) { - async_req_error(req, NT_STATUS_INTERNAL_ERROR); - return; - } - - if (p->sent == p->length) { - TALLOC_FREE(state->fde); - async_req_done(req); - } -} - -/** - * @brief Send all bytes to a socket - * @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) - * - * async_sendall calls send(2) as long as it is necessary to send all of the - * "length" bytes - */ - -struct async_req *sendall_send(TALLOC_CTX *mem_ctx, struct event_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_SENDALL, - fd, EVENT_FD_WRITE, async_sendall_callback, - &state); - if (result == NULL) { - return NULL; - } - - state->param.param_sendall.fd = fd; - state->param.param_sendall.buffer = buffer; - state->param.param_sendall.length = length; - state->param.param_sendall.flags = flags; - state->param.param_sendall.sent = 0; - - return result; -} - -NTSTATUS sendall_recv(struct async_req *req) -{ - return async_req_simple_recv(req); -} - -/** - * 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 EVENT_FD_READ here - * @param[in] priv private data, "struct async_req *" in this case - */ - -static void async_recv_callback(struct event_context *ev, - struct fd_event *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, NT_STATUS_INTERNAL_ERROR); - 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 event_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, EVENT_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; -} - -/** - * fde event handler for the "recvall" syscall group - * @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 EVENT_FD_READ here - * @param[in] priv private data, "struct async_req *" in this case - */ - -static void async_recvall_callback(struct event_context *ev, - struct fd_event *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_recvall *p = &state->param.param_recvall; - - if (state->syscall_type != ASYNC_SYSCALL_RECVALL) { - async_req_error(req, NT_STATUS_INTERNAL_ERROR); - return; - } - - state->result.result_ssize_t = recv(p->fd, - (char *)p->buffer + p->received, - p->length - p->received, p->flags); - state->sys_errno = errno; - - if (state->result.result_ssize_t == -1) { - async_req_error(req, map_nt_error_from_unix(state->sys_errno)); - return; - } - - if (state->result.result_ssize_t == 0) { - async_req_error(req, NT_STATUS_END_OF_FILE); - return; - } - - p->received += state->result.result_ssize_t; - if (p->received > p->length) { - async_req_error(req, NT_STATUS_INTERNAL_ERROR); - return; - } - - if (p->received == p->length) { - TALLOC_FREE(state->fde); - async_req_done(req); - } -} - -/** - * Receive a specified number of bytes from a socket - * @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) - * - * async_recvall will call recv(2) until "length" bytes are received - */ - -struct async_req *recvall_send(TALLOC_CTX *mem_ctx, struct event_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_RECVALL, - fd, EVENT_FD_READ, async_recvall_callback, - &state); - if (result == NULL) { - return NULL; - } - - state->param.param_recvall.fd = fd; - state->param.param_recvall.buffer = buffer; - state->param.param_recvall.length = length; - state->param.param_recvall.flags = flags; - state->param.param_recvall.received = 0; - - return result; -} - -NTSTATUS recvall_recv(struct async_req *req) -{ - return async_req_simple_recv(req); -} - -struct async_connect_state { - int fd; - int result; - int sys_errno; - long old_sockflags; -}; - -static void async_connect_connected(struct event_context *ev, - struct fd_event *fde, uint16_t flags, - void *priv); - -/** - * @brief async version of connect(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] address Where to connect? - * @param[in] address_len Length of *address - * @retval The async request - * - * This function sets the socket into non-blocking state to be able to call - * connect in an async state. This will be reset when the request is finished. - */ - -struct async_req *async_connect_send(TALLOC_CTX *mem_ctx, - struct event_context *ev, - int fd, const struct sockaddr *address, - socklen_t address_len) -{ - struct async_req *result; - struct async_connect_state *state; - struct fd_event *fde; - NTSTATUS status; - - if (!async_req_setup(mem_ctx, &result, &state, - struct async_connect_state)) { - return NULL; - } - - /** - * We have to set the socket to nonblocking for async connect(2). Keep - * the old sockflags around. - */ - - state->fd = fd; - state->sys_errno = 0; - - state->old_sockflags = sys_fcntl_long(fd, F_GETFL, 0); - if (state->old_sockflags == -1) { - goto post_errno; - } - - set_blocking(fd, false); - - state->result = connect(fd, address, address_len); - if (state->result == 0) { - state->sys_errno = 0; - status = NT_STATUS_OK; - goto post_status; - } - - /** - * A number of error messages show that something good is progressing - * and that we have to wait for readability. - * - * If none of them are present, bail out. - */ - - if (!(errno == EINPROGRESS || errno == EALREADY || -#ifdef EISCONN - errno == EISCONN || -#endif - errno == EAGAIN || errno == EINTR)) { - goto post_errno; - } - - fde = event_add_fd(ev, state, fd, EVENT_FD_READ | EVENT_FD_WRITE, - async_connect_connected, result); - if (fde == NULL) { - status = NT_STATUS_NO_MEMORY; - goto post_status; - } - return result; - - post_errno: - state->sys_errno = errno; - status = map_nt_error_from_unix(state->sys_errno); - post_status: - sys_fcntl_long(fd, F_SETFL, state->old_sockflags); - if (!async_post_status(result, ev, status)) { - goto fail; - } - return result; - fail: - TALLOC_FREE(result); - return NULL; -} - -/** - * fde event handler for connect(2) - * @param[in] ev The event context that sent us here - * @param[in] fde The file descriptor event associated with the connect - * @param[in] flags Indicate read/writeability of the socket - * @param[in] priv private data, "struct async_req *" in this case - */ - -static void async_connect_connected(struct event_context *ev, - struct fd_event *fde, uint16_t flags, - void *priv) -{ - struct async_req *req = talloc_get_type_abort( - priv, struct async_req); - struct async_connect_state *state = talloc_get_type_abort( - req->private_data, struct async_connect_state); - - TALLOC_FREE(fde); - - /* - * Stevens, Network Programming says that if there's a - * successful connect, the socket is only writable. Upon an - * error, it's both readable and writable. - */ - if ((flags & (EVENT_FD_READ|EVENT_FD_WRITE)) - == (EVENT_FD_READ|EVENT_FD_WRITE)) { - int sockerr; - socklen_t err_len = sizeof(sockerr); - - if (getsockopt(state->fd, SOL_SOCKET, SO_ERROR, - (void *)&sockerr, &err_len) == 0) { - errno = sockerr; - } - - state->sys_errno = errno; - - DEBUG(10, ("connect returned %s\n", strerror(errno))); - - sys_fcntl_long(state->fd, F_SETFL, state->old_sockflags); - async_req_error(req, map_nt_error_from_unix(state->sys_errno)); - return; - } - - state->sys_errno = 0; - async_req_done(req); -} - -NTSTATUS async_connect_recv(struct async_req *req, int *perrno) -{ - struct async_connect_state *state = talloc_get_type_abort( - req->private_data, struct async_connect_state); - NTSTATUS status; - - sys_fcntl_long(state->fd, F_SETFL, state->old_sockflags); - - *perrno = state->sys_errno; - - if (async_req_is_error(req, &status)) { - return status; - } - if (state->sys_errno == 0) { - return NT_STATUS_OK; - } - return map_nt_error_from_unix(state->sys_errno); -} -- cgit From ff39e0f6ddf59de2bef43744e295575824a759b6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Jan 2009 11:59:26 +0100 Subject: selftest: set 'lock dir' in client.conf metze --- selftest/selftest.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/selftest/selftest.pl b/selftest/selftest.pl index 6f0883c585..d47261da79 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -552,6 +552,12 @@ sub write_clientconf($$) mkdir("$prefix/client/private", 0777); } + if ( -d "$prefix/client/lock" ) { + unlink <$prefix/client/lockdir/*>; + } else { + mkdir("$prefix/client/lockdir", 0777); + } + open(CF, ">$conffile"); print CF "[global]\n"; if (defined($ENV{VALGRIND})) { @@ -580,6 +586,7 @@ sub write_clientconf($$) } print CF " private dir = $prefix_abs/client/private + lock dir = $prefix_abs/client/lockdir name resolve order = bcast panic action = $RealBin/gdb_backtrace \%PID\% \%PROG\% max xmit = 32K -- cgit From 57a290e9421d4ff7c55188542219b67e881841da Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 28 Jan 2009 12:04:53 +0100 Subject: s3:registry: always provision the registry, not only in smbd. This will make tools like "net registry" also fill the registry with the basic hives and keys. Michael --- source3/registry/reg_init_basic.c | 8 ++++++++ source3/registry/reg_init_full.c | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source3/registry/reg_init_basic.c b/source3/registry/reg_init_basic.c index 60dcabdcf2..eab4ca7f9d 100644 --- a/source3/registry/reg_init_basic.c +++ b/source3/registry/reg_init_basic.c @@ -37,6 +37,14 @@ WERROR registry_init_common(void) if (!W_ERROR_IS_OK(werr)) { DEBUG(0, ("Failed to initialize the reghook cache: %s\n", win_errstr(werr))); + goto done; + } + + /* setup the necessary keys and values */ + + werr = init_registry_data(); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0, ("Failed to initialize data in registry!\n")); } done: diff --git a/source3/registry/reg_init_full.c b/source3/registry/reg_init_full.c index 91e55d76b2..b5a06f2582 100644 --- a/source3/registry/reg_init_full.c +++ b/source3/registry/reg_init_full.c @@ -72,14 +72,6 @@ WERROR registry_init_full(void) goto fail; } - /* setup the necessary keys and values */ - - werr = init_registry_data(); - if (!W_ERROR_IS_OK(werr)) { - DEBUG(0, ("Failed to initialize data in registry!\n")); - goto fail; - } - /* build the cache tree of registry hooks */ for ( i=0; reg_hooks[i].keyname; i++ ) { -- cgit From 5da211b658164a6a585e9e77b7017a62ba16cf51 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Jan 2009 12:03:59 +0100 Subject: s3:selftest: fix warnings with empty *_TEST_LOG variables metze --- source3/script/tests/test_functions.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source3/script/tests/test_functions.sh b/source3/script/tests/test_functions.sh index 407d46aa9e..79642e045b 100644 --- a/source3/script/tests/test_functions.sh +++ b/source3/script/tests/test_functions.sh @@ -197,13 +197,13 @@ testit() { TEST_PCAP="$PREFIX/test_${shname}_${UNIQUE_PID}.pcap" trap "rm -f $TEST_LOG $TEST_PCAP" EXIT - if [ -z "$nmbd_log_size" ]; then + samba3_nmbd_test_log && if [ -z "$nmbd_log_size" ]; then nmbd_log_size=`wc -l < $NMBD_TEST_LOG`; fi - if [ -z "$winbindd_log_size" ]; then + samba3_winbindd_test_log && if [ -z "$winbindd_log_size" ]; then winbindd_log_size=`wc -l < $WINBINDD_TEST_LOG`; fi - if [ -z "$smbd_log_size" ]; then + samba3_smbd_test_log && if [ -z "$smbd_log_size" ]; then smbd_log_size=`wc -l < $SMBD_TEST_LOG`; fi -- cgit From 5ec52659da8282752535d2ef9f7cb875fcaf93f2 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 28 Jan 2009 12:19:06 +0100 Subject: s3:test: exit the net rpc registry tests when give_administrative_rights fails Michael --- source3/script/tests/test_net_registry.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source3/script/tests/test_net_registry.sh b/source3/script/tests/test_net_registry.sh index 5edcb061ee..e9f56a2cf2 100755 --- a/source3/script/tests/test_net_registry.sh +++ b/source3/script/tests/test_net_registry.sh @@ -361,8 +361,11 @@ take_administrative_rights() if test "x${RPC}" = "xrpc" ; then testit "giving user ${USERNAME} administrative rights" \ - give_administrative_rights || \ - failed=`expr $failed + 1` + give_administrative_rights + if [ "x$?" != "x0" ] ; then + failed=`expr $failed + 1` + testok $0 $failed + fi fi testit "enumerate HKLM" \ -- cgit From 1021c752ea4fec887d732ac02b8cfbadc45d8686 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 28 Jan 2009 12:41:04 +0100 Subject: s3:winbind: remove prototype for non-existent function from winbind_proto.h Michael --- source3/winbindd/winbindd_proto.h | 1 - 1 file changed, 1 deletion(-) diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index 87639dc59e..977ee9c6b1 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -498,7 +498,6 @@ void winbindd_lookupname(struct winbindd_cli_state *state); void winbindd_lookuprids(struct winbindd_cli_state *state); void winbindd_sid_to_uid(struct winbindd_cli_state *state); void winbindd_sid_to_gid(struct winbindd_cli_state *state); -void winbindd_sids_to_unixids(struct winbindd_cli_state *state); void winbindd_set_mapping(struct winbindd_cli_state *state); void winbindd_remove_mapping(struct winbindd_cli_state *state); void winbindd_set_hwm(struct winbindd_cli_state *state); -- cgit From c001b456cf0c9fdfd90a5239e3b86168d0fbb5aa Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 27 Jan 2009 19:41:34 +0100 Subject: Fix a valgrind error when the socket dies Don't reference anything that might have been deleted in the async_req_error call. --- source3/libsmb/async_smb.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c index a1fcf8eb07..a4bbe6d79d 100644 --- a/source3/libsmb/async_smb.c +++ b/source3/libsmb/async_smb.c @@ -1022,7 +1022,7 @@ static void cli_state_handler(struct event_context *event_ctx, struct fd_event *event, uint16 flags, void *p) { struct cli_state *cli = (struct cli_state *)p; - struct cli_request *req; + struct cli_request *req, *next; NTSTATUS status; DEBUG(11, ("cli_state_handler called with flags %d\n", flags)); @@ -1128,9 +1128,14 @@ static void cli_state_handler(struct event_context *event_ctx, return; sock_error: - for (req = cli->outstanding_requests; req; req = req->next) { - int i; - for (i=0; inum_async; i++) { + + for (req = cli->outstanding_requests; req; req = next) { + int i, num_async; + + next = req->next; + num_async = req->num_async; + + for (i=0; iasync[i], status); } } -- cgit From 4c7296cc0c0770ea547b67d668d5b42ab00a27da Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 27 Jan 2009 19:45:51 +0100 Subject: Avoid valgrind errors In event handlers, we might destroy other events that are pending in the lists. We can only run one event safely per select call. Yes, I've seen these valgrind errors :-) Jeremy, with ccdd921e61 you had checked in the change to run multiple events. Do you remember why it was necessary and could not be solved in a different way? Volker --- source3/lib/events.c | 48 +++++++++++++----------------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/source3/lib/events.c b/source3/lib/events.c index 4484d5323b..44b4562757 100644 --- a/source3/lib/events.c +++ b/source3/lib/events.c @@ -83,45 +83,24 @@ bool event_add_to_select_args(struct tevent_context *ev, bool run_events(struct tevent_context *ev, int selrtn, fd_set *read_fds, fd_set *write_fds) { - bool fired = false; - struct tevent_fd *fde, *next; + struct tevent_fd *fde; + struct timeval now; if (ev->signal_events && tevent_common_check_signal(ev)) { return true; } - /* Run all events that are pending, not just one (as we - did previously. */ - - while (ev->timer_events) { - struct timeval now; - GetTimeOfDay(&now); - - if (timeval_compare( - &now, &ev->timer_events->next_event) < 0) { - /* Nothing to do yet */ - DEBUG(11, ("run_events: Nothing to do\n")); - break; - } - - DEBUG(10, ("Running event \"%s\" %p\n", - ev->timer_events->handler_name, - ev->timer_events)); + GetTimeOfDay(&now); - ev->timer_events->handler( - ev, - ev->timer_events, now, - ev->timer_events->private_data); + if ((ev->timer_events != NULL) + && (timeval_compare(&now, &ev->timer_events->next_event) >= 0)) { - fired = true; - } + DEBUG(10, ("Running timed event \"%s\" %p\n", + ev->timer_events->handler_name, ev->timer_events)); - if (fired) { - /* - * We might have changed the socket status during the timed - * events, return to run select again. - */ + ev->timer_events->handler(ev, ev->timer_events, now, + ev->timer_events->private_data); return true; } @@ -129,23 +108,22 @@ bool run_events(struct tevent_context *ev, /* * No fd ready */ - return fired; + return false; } - for (fde = ev->fd_events; fde; fde = next) { + for (fde = ev->fd_events; fde; fde = fde->next) { uint16 flags = 0; - next = fde->next; if (FD_ISSET(fde->fd, read_fds)) flags |= EVENT_FD_READ; if (FD_ISSET(fde->fd, write_fds)) flags |= EVENT_FD_WRITE; if (flags & fde->flags) { fde->handler(ev, fde, flags, fde->private_data); - fired = true; + return true; } } - return fired; + return false; } -- cgit From 38b2931cf3ee11dae14b878c1edd289d3a151a62 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Jan 2009 17:05:56 +0100 Subject: Define _GNU_SOURCE, required for comparison_fn_t. --- librpc/ndr.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/librpc/ndr.pc.in b/librpc/ndr.pc.in index 2f4d95006f..9cff0ca218 100644 --- a/librpc/ndr.pc.in +++ b/librpc/ndr.pc.in @@ -8,4 +8,4 @@ Description: Network Data Representation Core Library Requires: samba-hostconfig talloc Version: 0.0.1 Libs: -L${libdir} -lndr -Cflags: -I${includedir} -DHAVE_IMMEDIATE_STRUCTURES=1 +Cflags: -I${includedir} -DHAVE_IMMEDIATE_STRUCTURES=1 -D_GNU_SOURCE=1 -- cgit From d6497aa0894b20392d759e1762ad1bb6ab29f5c8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Jan 2009 17:06:18 +0100 Subject: Stop installing events.h - it contains a broken include itself and should be considered internal now. --- source4/headermap.txt | 1 - source4/lib/events/config.mk | 2 -- 2 files changed, 3 deletions(-) diff --git a/source4/headermap.txt b/source4/headermap.txt index c27ec2f2de..8f3749a3b5 100644 --- a/source4/headermap.txt +++ b/source4/headermap.txt @@ -50,7 +50,6 @@ param/share.h: share.h ../lib/util/util_ldb.h: util_ldb.h ../lib/util/wrap_xattr.h: wrap_xattr.h libcli/ldap/ldap_ndr.h: ldap_ndr.h -lib/events/events.h: events.h ../lib/tevent/tevent.h: tevent.h ../lib/tevent/tevent_internal.h: tevent_internal.h auth/session.h: samba/session.h diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index c07a21bc75..5c7e1b7210 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -3,5 +3,3 @@ PUBLIC_DEPENDENCIES = LIBTEVENT CFLAGS = -Ilib/events LIBEVENTS_OBJ_FILES = $(addprefix $(libeventssrcdir)/, tevent_s4.o) - -PUBLIC_HEADERS += $(addprefix $(libeventssrcdir)/, events.h) -- cgit From a849183f9492d09ccd7e273f955d4d8f2668fdf3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Jan 2009 17:24:38 +0100 Subject: s3:selftest: create BUILTIN\\Administrators at startup And add and remove the alias member via net rpc group instead of net sam. metze --- source3/script/tests/selftest.sh | 7 +++++++ source3/script/tests/test_net_registry.sh | 15 +++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/source3/script/tests/selftest.sh b/source3/script/tests/selftest.sh index 94621841f5..c02e0ee183 100755 --- a/source3/script/tests/selftest.sh +++ b/source3/script/tests/selftest.sh @@ -345,6 +345,13 @@ START=`date` bin/smbclient $CONFIGURATION -L $SERVER_IP -U% -p 139 | head -2 MAKE_TEST_BINARY="" + MAKE_TEST_BINARY="bin/net" + printf "%s" "creating BUILTIN\\Administrators..." + bin/net -s $SERVERCONFFILE sam createbuiltingroup \ + Administrators > /dev/null 2>&1 || exit 1 + echo "DONE" + MAKE_TEST_BINARY="" + failed=0 . $SCRIPTDIR/tests_$SUBTESTS.sh diff --git a/source3/script/tests/test_net_registry.sh b/source3/script/tests/test_net_registry.sh index e9f56a2cf2..22081ec2f6 100755 --- a/source3/script/tests/test_net_registry.sh +++ b/source3/script/tests/test_net_registry.sh @@ -7,8 +7,10 @@ RPC="$1" NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION" +NETREMOTE="${NET} -U${USERNAME}%${PASSWORD} -S ${SERVER} -I ${SERVER_IP}" + if test "x${RPC}" = "xrpc" ; then - NETREG="${NET} -U${USERNAME}%${PASSWORD} -I ${SERVER_IP} rpc registry" + NETREG="${NETREMOTE} rpc registry" else NETREG="${NET} registry" fi @@ -332,14 +334,7 @@ test_setvalue_twice() give_administrative_rights() { - bin/net -s $SERVERCONFFILE sam createbuiltingroup Administrators - if test "x$?" != "x0" ; then - echo "ERROR: creating builtin group Administrators" - false - return - fi - - bin/net -s $SERVERCONFFILE sam addmem BUILTIN\\Administrators $USERNAME + ${NETREMOTE} rpc group addmem BUILTIN\\Administrators $USERNAME if test "x$?" != "x0" ; then echo "ERROR: adding user $USERNAME to BUILTIN\\Administrators" false @@ -350,7 +345,7 @@ give_administrative_rights() take_administrative_rights() { - bin/net -s $SERVERCONFFILE sam delmem BUILTIN\\Administrators $USERNAME + ${NETREMOTE} rpc group delmem BUILTIN\\Administrators $USERNAME if test "x$?" != "x0" ; then echo "ERROR: removing user $USERNAME from BUILTIN\\Administrators" false -- cgit From 8b7c66512d2021e6e7b299adb3e93807b6b3516d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Jan 2009 17:28:51 +0100 Subject: s3:selftest: fix 'make selftest' metze --- selftest/target/Samba3.pm | 128 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 100 insertions(+), 28 deletions(-) diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 7c3c0b0ea9..c43b61e560 100644 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -36,14 +36,14 @@ sub teardown_env($$) my $smbdpid = read_pid($envvars, "smbd"); my $nmbdpid = read_pid($envvars, "nmbd"); -# my $winbinddpid = read_pid($envvars, "winbindd"); + my $winbinddpid = read_pid($envvars, "winbindd"); $self->stop_sig_term($smbdpid); $self->stop_sig_term($nmbdpid); -# $self->stop_sig_term($winbinddpid); + $self->stop_sig_term($winbinddpid); $self->stop_sig_kill($smbdpid); $self->stop_sig_kill($nmbdpid); -# $self->stop_sig_kill($winbinddpid); + $self->stop_sig_kill($winbinddpid); return 0; } @@ -76,7 +76,7 @@ sub getlog_env($$) $ret .= $self->getlog_env_app($envvars, "SMBD"); $ret .= $self->getlog_env_app($envvars, "NMBD"); -# $ret .= $self->getlog_env_app($envvars, "WINBINDD"); + $ret .= $self->getlog_env_app($envvars, "WINBINDD"); return $ret; } @@ -160,8 +160,13 @@ sub check_or_start($$$$) { open STDOUT, ">$env_vars->{NMBD_TEST_LOG}"; open STDERR, '>&STDOUT'; + SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE}); + $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR}; + $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD}; + $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP}; + my @optargs = ("-d0"); if (defined($ENV{NMBD_OPTIONS})) { @optargs = split(/ /, $ENV{NMBD_OPTIONS}); @@ -186,16 +191,26 @@ sub check_or_start($$$$) { open STDOUT, ">$env_vars->{WINBINDD_TEST_LOG}"; open STDERR, '>&STDOUT'; + SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE}); + $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR}; + $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD}; + $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP}; + my @optargs = ("-d0"); if (defined($ENV{WINBINDD_OPTIONS})) { @optargs = split(/ /, $ENV{WINBINDD_OPTIONS}); } - $ENV{$ENV{LIB_PATH_VAR}} = $self->{bindir}; $ENV{MAKE_TEST_BINARY} = $self->binpath("winbindd"); - exec($self->binpath("timelimit"), $winbindd_maxtime, $ENV{WINBINDD_VALGRIND}, $self->binpath("winbindd"), "-F", "-S", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!"); + + my @preargs = ($self->binpath("timelimit"), $winbindd_maxtime); + if(defined($ENV{WINBINDD_VALGRIND})) { + @preargs = split(/ /, $ENV{WINBINDD_VALGRIND}); + } + + exec(@preargs, $self->binpath("winbindd"), "-F", "-S", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!"); } write_pid($env_vars, "winbindd", $pid); print "DONE\n"; @@ -207,8 +222,13 @@ sub check_or_start($$$$) { open STDOUT, ">$env_vars->{SMBD_TEST_LOG}"; open STDERR, '>&STDOUT'; + SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE}); + $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR}; + $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD}; + $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP}; + $ENV{MAKE_TEST_BINARY} = $self->binpath("smbd"); my @optargs = ("-d0"); if (defined($ENV{SMBD_OPTIONS})) { @@ -273,13 +293,17 @@ sub provision($$$) my $server_ip = "127.0.0.2"; my $domain = "SAMBA-TEST"; - my $username = `PATH=/usr/ucb:$ENV{PATH} whoami`; - chomp $username; + my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`); + chomp $unix_name; + my $unix_uid = $>; + my $unix_gids_str = $); + my @unix_gids = split(" ", $unix_gids_str); my $password = "test"; my $srcdir="$RealBin/.."; my $scriptdir="$srcdir/selftest"; my $prefix_abs = abs_path($prefix); + my $bindir_abs = abs_path($self->{bindir}); my @dirs = (); @@ -315,9 +339,18 @@ sub provision($$$) my $conffile="$libdir/server.conf"; + my $nss_wrapper_pl = "$ENV{PERL} $srcdir/../lib/nss_wrapper/nss_wrapper.pl"; + my $nss_wrapper_passwd = "$privatedir/passwd"; + my $nss_wrapper_group = "$privatedir/group"; + open(CONF, ">$conffile") or die("Unable to open $conffile"); print CONF " [global] + netbios name = $server + interfaces = $server_ip/8 + bind interfaces only = yes + panic action = $scriptdir/gdb_backtrace %d %\$(MAKE_TEST_BINARY) + workgroup = $domain private dir = $privatedir @@ -328,42 +361,51 @@ sub provision($$$) name resolve order = bcast - netbios name = $server - interfaces = $server_ip/8 - bind interfaces only = yes - panic action = $scriptdir/gdb_backtrace %d %\$(MAKE_TEST_BINARY) + state directory = $lockdir + cache directory = $lockdir passdb backend = tdbsam - ; Necessary to add the build farm hacks - add user script = /bin/false - add machine script = /bin/false - - kernel oplocks = no - kernel change notify = no - - syslog = no - printing = bsd - printcap name = /dev/null - "; if ($role eq "dc") { - print CONF "\tdomain logons = yes\n"; print CONF "\tdomain master = yes\n"; + print CONF "\tdomain logons = yes\n"; } print CONF " + time server = yes + + add user script = $nss_wrapper_pl --path $nss_wrapper_passwd --type passwd --action add --name %u + add machine script = $nss_wrapper_pl --path $nss_wrapper_passwd --type passwd --action add --name %u + delete user script = $nss_wrapper_pl --path $nss_wrapper_passwd --type passwd --action delete --name %u + + kernel oplocks = no + kernel change notify = no + + syslog = no + printing = bsd + printcap name = /dev/null winbindd:socket dir = $wbsockdir + idmap uid = 100000-200000 + idmap gid = 100000-200000 + +# min receivefile size = 4000 -[tmp] - path = $shrdir read only = no smbd:sharedelay = 100000 + smbd:writetimeupdatedelay = 500000 map hidden = yes map system = yes create mask = 755 + vfs objects = $bindir_abs/xattr_tdb.so $bindir_abs/streams_depot.so + + #Include user defined custom parameters if set + $ENV{INCLUDE_CUSTOM_CONF} + +[tmp] + path = $shrdir [hideunread] copy = tmp hide unreadable = yes @@ -387,10 +429,31 @@ print CONF " ## create a test account ## - open(PWD, "|".$self->binpath("smbpasswd")." -c $conffile -L -s -a $username >/dev/null"); + open(PASSWD, ">$nss_wrapper_passwd") or die("Unable to open $nss_wrapper_passwd"); + print PASSWD " +nobody:x:65534:65533:nobody gecos:$prefix_abs:/bin/false +$unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false +"; + close(PASSWD); + + open(GROUP, ">$nss_wrapper_group") or die("Unable to open $nss_wrapper_group"); + print GROUP " +nobody:x:65533: +nogroup:x:65534:nobody +$unix_name-group:x:$unix_gids[0]: +"; + close(GROUP); + + $ENV{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd; + $ENV{NSS_WRAPPER_GROUP} = $nss_wrapper_group; + + open(PWD, "|".$self->binpath("smbpasswd")." -c $conffile -L -s -a $unix_name >/dev/null"); print PWD "$password\n$password\n"; close(PWD) or die("Unable to set password for test account"); + $ENV{NSS_WRAPPER_PASSWD} = undef; + $ENV{NSS_WRAPPER_GROUP} = undef; + print "DONE\n"; $ret{SERVER_IP} = $server_ip; @@ -400,13 +463,17 @@ print CONF " $ret{SERVERCONFFILE} = $conffile; $ret{CONFIGURATION} ="-s $conffile"; $ret{SERVER} = $server; - $ret{USERNAME} = $username; + $ret{USERNAME} = $unix_name; $ret{DOMAIN} = $domain; $ret{NETBIOSNAME} = $server; $ret{PASSWORD} = $password; $ret{PIDDIR} = $piddir; $ret{WINBINDD_SOCKET_DIR} = $wbsockdir; $ret{WINBINDD_PRIV_PIPE_DIR} = $wbsockprivdir; + $ret{SOCKET_WRAPPER_DEFAULT_IFACE} => 2, + $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd; + $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group; + return \%ret; } @@ -428,6 +495,11 @@ sub wait_for_start($$) system($self->binpath("smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER_IP} -U% -p 139 | head -2"); system($self->binpath("smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER_IP} -U% -p 139 | head -2"); + print "creating BUILTIN\\Administrators\n"; + $ENV{WINBINDD_SOCKET_DIR} = $envvars->{WINBINDD_SOCKET_DIR}; + system($self->binpath("net") ." $envvars->{CONFIGURATION} sam createbuiltingroup Administrators"); + $ENV{WINBINDD_SOCKET_DIR} = undef; + print $self->getlog_env($envvars); } -- cgit From 6a41a2de8d2f44fc3a654416edb04538e125350c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Jan 2009 20:30:16 +0100 Subject: selftest: abstract Samba3 provision a bit metze --- selftest/target/Samba3.pm | 34 ++++++++++++++++++++-------------- source3/script/tests/test_net_misc.sh | 2 +- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index c43b61e560..0a9dd79fc8 100644 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -104,7 +104,18 @@ sub setup_dc($$) { my ($self, $path) = @_; - my $vars = $self->provision($path, "dc"); + print "PROVISIONING DC..."; + + my $dc_options = " + domain master = yes + domain logons = yes +"; + + my $vars = $self->provision($path, + "LOCALDC2", + 2, + "localdc2pass", + $dc_options); $self->check_or_start($vars, ($ENV{NMBD_MAXTIME} or 2700), @@ -280,17 +291,16 @@ sub create_clientconf($$$) close(CONF); } -sub provision($$$) +sub provision($$$$$$) { - my ($self, $prefix, $role) = @_; + my ($self, $prefix, $server, $swiface, $password, $extra_options) = @_; ## ## setup the various environment variables we need ## my %ret = (); - my $server = "LOCALHOST2"; - my $server_ip = "127.0.0.2"; + my $server_ip = "127.0.0.$swiface"; my $domain = "SAMBA-TEST"; my $unix_name = ($ENV{USER} or $ENV{LOGNAME} or `PATH=/usr/ucb:$ENV{PATH} whoami`); @@ -366,14 +376,6 @@ sub provision($$$) passdb backend = tdbsam -"; - - if ($role eq "dc") { - print CONF "\tdomain master = yes\n"; - print CONF "\tdomain logons = yes\n"; - } - -print CONF " time server = yes add user script = $nss_wrapper_pl --path $nss_wrapper_passwd --type passwd --action add --name %u @@ -401,6 +403,10 @@ print CONF " create mask = 755 vfs objects = $bindir_abs/xattr_tdb.so $bindir_abs/streams_depot.so + # Begin extra options + $extra_options + # End extra options + #Include user defined custom parameters if set $ENV{INCLUDE_CUSTOM_CONF} @@ -470,7 +476,7 @@ $unix_name-group:x:$unix_gids[0]: $ret{PIDDIR} = $piddir; $ret{WINBINDD_SOCKET_DIR} = $wbsockdir; $ret{WINBINDD_PRIV_PIPE_DIR} = $wbsockprivdir; - $ret{SOCKET_WRAPPER_DEFAULT_IFACE} => 2, + $ret{SOCKET_WRAPPER_DEFAULT_IFACE} => $swiface, $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd; $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group; diff --git a/source3/script/tests/test_net_misc.sh b/source3/script/tests/test_net_misc.sh index 0a0636ac8a..9f5fdfe925 100755 --- a/source3/script/tests/test_net_misc.sh +++ b/source3/script/tests/test_net_misc.sh @@ -16,7 +16,7 @@ test_time() { PARAM="$1" - ${NETTIME} ${PARAM} -S localhost2 + ${NETTIME} -S ${SERVER} ${PARAM} } test_lookup() -- cgit From 9f8d80c69921ee5c3941fde08aba3a12d3194415 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Jan 2009 22:13:11 +0100 Subject: selftest: Samba4 remove unused variable metze --- selftest/target/Samba4.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index 83f62d45ec..97f9878828 100644 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -520,7 +520,6 @@ sub provision($$$$$$) my $unix_uid = $>; my $unix_gids_str = $); my @unix_gids = split(" ", $unix_gids_str); - my $srcdir="$RealBin/.."; -d $prefix or mkdir($prefix, 0777) or die("Unable to create $prefix"); my $prefix_abs = abs_path($prefix); my $tmpdir = "$prefix_abs/tmp"; -- cgit From 67bf7a2396051d10c07aeaa2d8b373a96a44d892 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Jan 2009 22:15:44 +0100 Subject: selftest: fix Samba3 bugs metze --- selftest/selftest.pl | 1 + selftest/target/Samba3.pm | 34 ++++++++++++++++++---------------- source3/Makefile.in | 3 ++- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/selftest/selftest.pl b/selftest/selftest.pl index d47261da79..dc754efa17 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -580,6 +580,7 @@ sub write_clientconf($$) } if (defined($vars->{WINBINDD_SOCKET_DIR})) { print CF "\twinbindd socket directory = $vars->{WINBINDD_SOCKET_DIR}\n"; + print CF "\twinbindd:socket dir = $vars->{WINBINDD_SOCKET_DIR}\n"; } if ($opt_socket_wrapper) { print CF "\tinterfaces = $interfaces\n"; diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 0a9dd79fc8..2b2f6a51b5 100644 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -265,7 +265,6 @@ sub create_clientconf($$$) my $logdir = "$prefix/logs"; my $piddir = "$prefix/pid"; my $privatedir = "$prefix/private"; - my $scriptdir = "$RealBin/.."; my $conffile = "$prefix/smb.conf"; my $torture_interfaces='127.0.0.6/8,127.0.0.7/8,127.0.0.8/8,127.0.0.9/8,127.0.0.10/8,127.0.0.11/8'; @@ -284,7 +283,7 @@ sub create_clientconf($$$) netbios name = TORTURE_6 interfaces = $torture_interfaces - panic action = $scriptdir/gdb_backtrace \%d %\$(MAKE_TEST_BINARY) + panic action = $RealBin/gdb_backtrace \%d %\$(MAKE_TEST_BINARY) passdb backend = tdbsam "; @@ -308,10 +307,7 @@ sub provision($$$$$$) my $unix_uid = $>; my $unix_gids_str = $); my @unix_gids = split(" ", $unix_gids_str); - my $password = "test"; - my $srcdir="$RealBin/.."; - my $scriptdir="$srcdir/selftest"; my $prefix_abs = abs_path($prefix); my $bindir_abs = abs_path($self->{bindir}); @@ -349,7 +345,7 @@ sub provision($$$$$$) my $conffile="$libdir/server.conf"; - my $nss_wrapper_pl = "$ENV{PERL} $srcdir/../lib/nss_wrapper/nss_wrapper.pl"; + my $nss_wrapper_pl = "$ENV{PERL} $RealBin/../lib/nss_wrapper/nss_wrapper.pl"; my $nss_wrapper_passwd = "$privatedir/passwd"; my $nss_wrapper_group = "$privatedir/group"; @@ -359,7 +355,7 @@ sub provision($$$$$$) netbios name = $server interfaces = $server_ip/8 bind interfaces only = yes - panic action = $scriptdir/gdb_backtrace %d %\$(MAKE_TEST_BINARY) + panic action = $RealBin/gdb_backtrace %d %\$(MAKE_TEST_BINARY) workgroup = $domain @@ -408,8 +404,13 @@ sub provision($$$$$$) # End extra options #Include user defined custom parameters if set - $ENV{INCLUDE_CUSTOM_CONF} +"; + + if (defined($ENV{INCLUDE_CUSTOM_CONF})) { + print CONF "\t$ENV{INCLUDE_CUSTOM_CONF}\n"; + } + print CONF " [tmp] path = $shrdir [hideunread] @@ -436,15 +437,13 @@ sub provision($$$$$$) ## open(PASSWD, ">$nss_wrapper_passwd") or die("Unable to open $nss_wrapper_passwd"); - print PASSWD " -nobody:x:65534:65533:nobody gecos:$prefix_abs:/bin/false + print PASSWD "nobody:x:65534:65533:nobody gecos:$prefix_abs:/bin/false $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false "; close(PASSWD); open(GROUP, ">$nss_wrapper_group") or die("Unable to open $nss_wrapper_group"); - print GROUP " -nobody:x:65533: + print GROUP "nobody:x:65533: nogroup:x:65534:nobody $unix_name-group:x:$unix_gids[0]: "; @@ -457,15 +456,18 @@ $unix_name-group:x:$unix_gids[0]: print PWD "$password\n$password\n"; close(PWD) or die("Unable to set password for test account"); - $ENV{NSS_WRAPPER_PASSWD} = undef; - $ENV{NSS_WRAPPER_GROUP} = undef; + delete $ENV{NSS_WRAPPER_PASSWD}; + delete $ENV{NSS_WRAPPER_GROUP}; print "DONE\n"; $ret{SERVER_IP} = $server_ip; $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log"; + $ret{NMBD_TEST_LOG_POS} = 0; $ret{WINBINDD_TEST_LOG} = "$prefix/winbindd_test.log"; + $ret{WINBINDD_TEST_LOG_POS} = 0; $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log"; + $ret{SMBD_TEST_LOG_POS} = 0; $ret{SERVERCONFFILE} = $conffile; $ret{CONFIGURATION} ="-s $conffile"; $ret{SERVER} = $server; @@ -476,7 +478,7 @@ $unix_name-group:x:$unix_gids[0]: $ret{PIDDIR} = $piddir; $ret{WINBINDD_SOCKET_DIR} = $wbsockdir; $ret{WINBINDD_PRIV_PIPE_DIR} = $wbsockprivdir; - $ret{SOCKET_WRAPPER_DEFAULT_IFACE} => $swiface, + $ret{SOCKET_WRAPPER_DEFAULT_IFACE} = $swiface; $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd; $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group; @@ -504,7 +506,7 @@ sub wait_for_start($$) print "creating BUILTIN\\Administrators\n"; $ENV{WINBINDD_SOCKET_DIR} = $envvars->{WINBINDD_SOCKET_DIR}; system($self->binpath("net") ." $envvars->{CONFIGURATION} sam createbuiltingroup Administrators"); - $ENV{WINBINDD_SOCKET_DIR} = undef; + delete $ENV{WINBINDD_SOCKET_DIR}; print $self->getlog_env($envvars); } diff --git a/source3/Makefile.in b/source3/Makefile.in index e786a81efa..b3978eae40 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -2954,7 +2954,8 @@ selftestdir = ../selftest S3_LD_LIBPATH_OVERRIDE = $(LIB_PATH_VAR)="$(builddir)/bin" selftest:: all torture timelimit - @$(S3_LD_LIBPATH_OVERRIDE) $(selftestdir)/selftest.pl \ + @$(S3_LD_LIBPATH_OVERRIDE) PERL="$(PERL)" \ + $(PERL) $(selftestdir)/selftest.pl \ --prefix=${selftest_prefix} --target=samba3 \ --testlist="$(srcdir)/selftest/tests.sh|" \ --expected-failures=$(srcdir)/selftest/knownfail \ -- cgit From 77bb2d6d0b6ba994aa5f9295ed42b1dbf98898b6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 29 Jan 2009 10:29:35 +0100 Subject: s3:seltest: make test_smbclient_s3.sh more strict metze --- source3/script/tests/test_smbclient_s3.sh | 43 +++++++++++++++++++++--------- source3/script/tests/tests_all.sh | 4 +-- source3/script/tests/tests_smbclient_s3.sh | 2 +- source3/selftest/tests.sh | 2 +- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh index c10aed0ee6..1d55087c88 100755 --- a/source3/script/tests/test_smbclient_s3.sh +++ b/source3/script/tests/test_smbclient_s3.sh @@ -2,17 +2,19 @@ # this runs the file serving tests that are expected to pass with samba3 -if [ $# -lt 2 ]; then +if [ $# -lt 4 ]; then cat <&1 | \ - grep $prompt + cmd='echo du | $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS 2>&1' + eval echo "$cmd" + out=`eval $cmd` + + if [ $? != 0 ] ; then + echo "$out" + echo "command failed" + false + return + fi + + echo "$out" | grep $prompt >/dev/null 2>&1 if [ $? = 0 ] ; then # got a prompt .. fail @@ -49,18 +60,26 @@ du quit EOF - CLI_FORCE_INTERACTIVE=yes \ - $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP \ - $ADDARGS < $tmpfile 2>/dev/null | \ - grep $prompt + cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1' + eval echo "$cmd" + out=`eval $cmd` + ret=$? + rm -f $tmpfile + + if [ $ret != 0 ] ; then + echo "$out" + echo "command failed" + false + return + fi + + echo "$out" | grep $prompt >/dev/null 2>&1 if [ $? = 0 ] ; then # got a prompt .. succeed - rm -f $tmpfile true else echo failed to match interactive prompt on stdout - rm -f $tmpfile false fi } diff --git a/source3/script/tests/tests_all.sh b/source3/script/tests/tests_all.sh index 2b46da0e77..11d315b198 100755 --- a/source3/script/tests/tests_all.sh +++ b/source3/script/tests/tests_all.sh @@ -20,13 +20,13 @@ smbtorture_s3_encrypted() { smbclient_s3() { echo "RUNNING TESTS smbclient_s3" - $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP \ + $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP $USERNAME $PASSWORD \ || failed=`expr $failed + $?` } smbclient_s3_encrypted() { echo "RUNNING TESTS smbclient_s3_encrypted" - $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP "-e" \ + $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP $USERNAME $PASSWORD "-e" \ || failed=`expr $failed + $?` } diff --git a/source3/script/tests/tests_smbclient_s3.sh b/source3/script/tests/tests_smbclient_s3.sh index d48a692d4b..40edf2296f 100644 --- a/source3/script/tests/tests_smbclient_s3.sh +++ b/source3/script/tests/tests_smbclient_s3.sh @@ -1 +1 @@ -. $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP +. $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP $USERNAME $PASSWORD diff --git a/source3/selftest/tests.sh b/source3/selftest/tests.sh index 98568b6bb3..3a53fa1df2 100755 --- a/source3/selftest/tests.sh +++ b/source3/selftest/tests.sh @@ -65,6 +65,6 @@ for t in $tests; do plantest "$name" dc $VALGRIND $BINDIR/smbtorture //\$SERVER/tmp -U\$USERNAME%\$PASSWORD $t done -plantest "blackbox.smbclient" dc BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP +plantest "blackbox.smbclient" dc BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$USERNAME \$PASSWORD plantest "blackbox.wbinfo" dc BINDIR="$BINDIR" script/tests/test_wbinfo_s3.sh \$DOMAIN \$SERVER \$USERNAME \$PASSWORD plantest "blackbox.net" dc BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" script/tests/test_net_s3.sh -- cgit From 439172dc067a8295a6f5d50f6a604e2307d9944a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Jan 2009 21:01:04 +0100 Subject: selftest: add "member" environment for Samba3 metze --- selftest/selftest.pl | 2 +- selftest/target/Samba3.pm | 48 +++++++++++++++++++++++++++++++++++++++++++++++ source3/selftest/tests.sh | 4 ++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/selftest/selftest.pl b/selftest/selftest.pl index dc754efa17..97cf697179 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -457,7 +457,7 @@ if ($opt_target eq "samba4") { if ($opt_socket_wrapper and `$bindir/smbd -b | grep SOCKET_WRAPPER` eq "") { die("You must include --enable-socket-wrapper when compiling Samba in order to execute 'make test'. Exiting...."); } - $testenv_default = "dc"; + $testenv_default = "member"; require target::Samba3; $target = new Samba3($bindir); } elsif ($opt_target eq "win") { diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 2b2f6a51b5..bb074b7b6e 100644 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -95,6 +95,11 @@ sub setup_env($$$) if ($envname eq "dc") { return $self->setup_dc("$path/dc"); + } elsif ($envname eq "member") { + if (not defined($self->{vars}->{dc})) { + $self->setup_dc("$path/dc"); + } + return $self->setup_member("$path/member", $self->{vars}->{dc}); } else { return undef; } @@ -124,9 +129,52 @@ sub setup_dc($$) $self->wait_for_start($vars); + $self->{vars}->{dc} = $vars; + return $vars; } +sub setup_member($$$) +{ + my ($self, $prefix, $dcvars) = @_; + + print "PROVISIONING MEMBER..."; + + my $member_options = " + security = domain +"; + my $ret = $self->provision($prefix, + "LOCALMEMBER3", + 3, + "localmember3pass", + $member_options); + + $ret or die("Unable to provision"); + + my $net = $self->binpath("net"); + my $cmd = ""; + $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" "; + $cmd .= "$net join $ret->{CONFIGURATION} $dcvars->{DOMAIN} member"; + $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}"; + + system($cmd) == 0 or die("Join failed\n$cmd"); + + $self->check_or_start($ret, + ($ENV{NMBD_MAXTIME} or 2700), + ($ENV{WINBINDD_MAXTIME} or 2700), + ($ENV{SMBD_MAXTIME} or 2700)); + + $self->wait_for_start($ret); + + $ret->{DC_SERVER} = $dcvars->{SERVER}; + $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP}; + $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME}; + $ret->{DC_USERNAME} = $dcvars->{USERNAME}; + $ret->{DC_PASSWORD} = $dcvars->{PASSWORD}; + + return $ret; +} + sub stop($) { my ($self) = @_; diff --git a/source3/selftest/tests.sh b/source3/selftest/tests.sh index 3a53fa1df2..28a02d659e 100755 --- a/source3/selftest/tests.sh +++ b/source3/selftest/tests.sh @@ -66,5 +66,9 @@ for t in $tests; do done plantest "blackbox.smbclient" dc BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$USERNAME \$PASSWORD +plantest "blackbox.smbclient member creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD +plantest "blackbox.smbclient domain creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$DOMAIN\\\\\$DC_USERNAME \$DC_PASSWORD + plantest "blackbox.wbinfo" dc BINDIR="$BINDIR" script/tests/test_wbinfo_s3.sh \$DOMAIN \$SERVER \$USERNAME \$PASSWORD plantest "blackbox.net" dc BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" script/tests/test_net_s3.sh + -- cgit From 88278cf23f1886e949c9500276be5dae9dfd76da Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 29 Jan 2009 10:30:45 +0100 Subject: s3:selftest: import more tests from 'make test' metze --- source3/selftest/tests.sh | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/source3/selftest/tests.sh b/source3/selftest/tests.sh index 28a02d659e..7f2c8f2203 100755 --- a/source3/selftest/tests.sh +++ b/source3/selftest/tests.sh @@ -48,10 +48,10 @@ BINDIR=`dirname $0`/../bin SCRIPTDIR=`dirname $0`/../script/tests export SCRIPTDIR -plantest "talloctort" none $VALGRIND $BINDIR/talloctort -plantest "replacetort" none $VALGRIND $BINDIR/replacetort -plantest "tdbtorture" none $VALGRIND $BINDIR/tdbtorture -plantest "smbconftort" none $VALGRIND $BINDIR/smbconftort $CONFIGURATION +plantest "talloctort3" none $VALGRIND $BINDIR/talloctort +plantest "replacetort3" none $VALGRIND $BINDIR/replacetort +plantest "tdbtorture3" none $VALGRIND $BINDIR/tdbtorture +plantest "smbconftort3" none $VALGRIND $BINDIR/smbconftort $CONFIGURATION tests="FDPASS LOCK1 LOCK2 LOCK3 LOCK4 LOCK5 LOCK6 LOCK7" tests="$tests UNLINK BROWSE ATTR TRANS2 TORTURE " @@ -61,14 +61,27 @@ tests="$tests OPEN XCOPY RENAME DELETE PROPERTIES W2K" tests="$tests TCON2 IOCTL CHKPATH FDSESS LOCAL-SUBSTITUTE" for t in $tests; do - name=`normalize_testname $t` + name=`normalize_testname smbtorture3.plain.$t` plantest "$name" dc $VALGRIND $BINDIR/smbtorture //\$SERVER/tmp -U\$USERNAME%\$PASSWORD $t done -plantest "blackbox.smbclient" dc BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$USERNAME \$PASSWORD -plantest "blackbox.smbclient member creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD -plantest "blackbox.smbclient domain creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$DOMAIN\\\\\$DC_USERNAME \$DC_PASSWORD +for t in $tests; do + name=`normalize_testname smbtorture3.crypt.$t` + plantest "$name" dc $VALGRIND $BINDIR/smbtorture //\$SERVER/tmp -U\$USERNAME%\$PASSWORD $t +done + +# plain +plantest "blackbox.smbclient3.plain" dc BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$USERNAME \$PASSWORD +plantest "blackbox.smbclient3.plain member creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD +plantest "blackbox.smbclient3.plain domain creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$DOMAIN\\\\\$DC_USERNAME \$DC_PASSWORD + +# encrypted +plantest "blackbox.smbclient3.crypt" dc BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$USERNAME \$PASSWORD "-e" + +# these don't work yet +#plantest "blackbox.smbclient3.crypt member creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD "-e" +#plantest "blackbox.smbclient3.crypt domain creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$DOMAIN\\\\\$DC_USERNAME \$DC_PASSWORD "-e" -plantest "blackbox.wbinfo" dc BINDIR="$BINDIR" script/tests/test_wbinfo_s3.sh \$DOMAIN \$SERVER \$USERNAME \$PASSWORD -plantest "blackbox.net" dc BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" script/tests/test_net_s3.sh +plantest "blackbox.wbinfo3" dc BINDIR="$BINDIR" script/tests/test_wbinfo_s3.sh \$DOMAIN \$SERVER \$USERNAME \$PASSWORD +plantest "blackbox.net3" dc BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" script/tests/test_net_s3.sh -- cgit From 27408de5337afe2e17378a09e9865c62c7b4862b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 29 Jan 2009 13:04:01 +0100 Subject: s3: fix bug #6073: prevent ads_connect() from using SSL unless explicitly requested This fixes "net ads join". It copes with the changed default "ldap ssl = start tls". A new boolean option "ldap ssl : ads" is added to allow for explicitly requesting ssl with ads. Michael --- source3/libads/ldap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index f6da54f35b..bb2b58e237 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -672,9 +672,11 @@ got_connection: ldap_set_option(ads->ldap.ld, LDAP_OPT_PROTOCOL_VERSION, &version); - status = ADS_ERROR(smb_ldap_start_tls(ads->ldap.ld, version)); - if (!ADS_ERR_OK(status)) { - goto out; + if (lp_parm_bool(-1, "ldap ssl", "ads", false)) { + status = ADS_ERROR(smb_ldap_start_tls(ads->ldap.ld, version)); + if (!ADS_ERR_OK(status)) { + goto out; + } } /* fill in the current time and offsets */ -- cgit From 1ea6ed3fc203875b0364e95174569310fe33d1c5 Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Fri, 9 Jan 2009 12:05:55 +0100 Subject: quote ' inside '...' and make sure shell isn't eating \ by using perl here. Signed-off-by: Stefan Metzmacher --- source4/build/m4/public.m4 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/source4/build/m4/public.m4 b/source4/build/m4/public.m4 index ffd112f5f1..1823f1ba97 100644 --- a/source4/build/m4/public.m4 +++ b/source4/build/m4/public.m4 @@ -201,11 +201,9 @@ CEOF for ac_var in $ac_subst_vars do - eval ac_val=\$$ac_var - if test "$ac_var" != "ECHO_C" - then - echo "$ac_var => '$ac_val'," >> $1 - fi + eval ac_val=\$$ac_var + # quote ' (\x27) inside '...' and make sure \ isn't eaten by shells, so use perl: + QAC_VAL=$ac_val QAC_VAR=$ac_var perl -e '$myval="$ENV{QAC_VAL}"; $myval =~ s/\x27/\\\x27/g ; print $ENV{QAC_VAR}." => \x27$myval\x27,\n"' >> $1 done cat >>$1< Date: Thu, 29 Jan 2009 15:30:38 +0100 Subject: s3:smbd: ignore open_socket_in() failures This restores the pre e0232934fbf69a9e72de1d9844b14d70b34a2d6a behavior. metze --- source3/smbd/server.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 7644cebe69..474c5b2fa5 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -445,7 +445,10 @@ bool smbd_open_one_socket(struct smbd_parent_context *parent, "%s\n", strerror(errno))); close(s->fd); TALLOC_FREE(s); - return false; + /* + * We ignore an error here, as we've done before + */ + return true; } /* ready to listen */ -- cgit From ba482e6b8d375449bcce52bfa383b95046d89fc1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 29 Jan 2009 15:42:10 +0100 Subject: s3:smbd: make smbd_open_one_socket() static Michael --- source3/smbd/server.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 474c5b2fa5..5f6783e05c 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -423,9 +423,9 @@ static void smbd_accept_connection(struct tevent_context *ev, force_check_log_size(); } -bool smbd_open_one_socket(struct smbd_parent_context *parent, - const struct sockaddr_storage *ifss, - uint16_t port) +static bool smbd_open_one_socket(struct smbd_parent_context *parent, + const struct sockaddr_storage *ifss, + uint16_t port) { struct smbd_open_socket *s; -- cgit From 7540d13956a8a69d25f6fbbc4f9a3417e91db1d2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Jan 2009 18:55:13 +0100 Subject: s3:ctdbd_conn: canonicalize ips before sending them to ctdbd This makes samba work with older ctdb versions. metze --- source3/lib/ctdbd_conn.c | 50 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index f8dae8fbd6..88d82caab8 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -1176,46 +1176,76 @@ NTSTATUS ctdbd_traverse(uint32 db_id, return status; } +/* + This is used to canonicalize a ctdb_sock_addr structure. +*/ +static void smbd_ctdb_canonicalize_ip(const struct sockaddr_storage *in, + struct sockaddr_storage *out) +{ + memcpy(out, in, sizeof (*out)); + +#ifdef HAVE_IPV6 + if (in->ss_family == AF_INET6) { + const char prefix[12] = { 0,0,0,0,0,0,0,0,0,0,0xff,0xff }; + const struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)in; + struct sockaddr_in *out4 = (struct sockaddr_in *)out; + if (memcmp(&in6->sin6_addr, prefix, 12) == 0) { + memset(out, 0, sizeof(*out)); +#ifdef HAVE_SOCK_SIN_LEN + out4->sin_len = sizeof(*out); +#endif + out4->sin_family = AF_INET; + out4->sin_port = in6->sin6_port; + memcpy(&out4->sin_addr, &in6->sin6_addr.s6_addr32[3], 4); + } + } +#endif +} + /* * Register us as a server for a particular tcp connection */ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn, - const struct sockaddr_storage *server, - const struct sockaddr_storage *client, + const struct sockaddr_storage *_server, + const struct sockaddr_storage *_client, void (*release_ip_handler)(const char *ip_addr, void *private_data), void *private_data) { - struct sockaddr *sock = (struct sockaddr *)client; /* * we still use ctdb_control_tcp for ipv4 * because we want to work against older ctdb * versions at runtime */ struct ctdb_control_tcp p4; -#ifdef HAVE_IPV6 +#ifdef HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR struct ctdb_control_tcp_addr p; #endif TDB_DATA data; NTSTATUS status; + struct sockaddr_storage client; + struct sockaddr_storage server; /* * Only one connection so far */ SMB_ASSERT(conn->release_ip_handler == NULL); - switch (sock->sa_family) { + smbd_ctdb_canonicalize_ip(_client, &client); + smbd_ctdb_canonicalize_ip(_server, &server); + + switch (client.ss_family) { case AF_INET: - p4.dest = *(struct sockaddr_in *)server; - p4.src = *(struct sockaddr_in *)client; + p4.dest = *(struct sockaddr_in *)&server; + p4.src = *(struct sockaddr_in *)&client; data.dptr = (uint8_t *)&p4; data.dsize = sizeof(p4); break; -#ifdef HAVE_IPV6 +#ifdef HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR case AF_INET6: - p.dest.ip6 = *(struct sockaddr_in6 *)server; - p.src.ip6 = *(struct sockaddr_in6 *)client; + p.dest.ip6 = *(struct sockaddr_in6 *)&server; + p.src.ip6 = *(struct sockaddr_in6 *)&client; data.dptr = (uint8_t *)&p; data.dsize = sizeof(p); break; -- cgit From 11163720e6f30e83f523c5009e1e60b5cf28cda6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Jan 2009 17:36:36 +0100 Subject: s3:configure: autodetect ctdb/cluster support We need to make sure ctdb has transaction support and we autodetect ipv6 support. metze --- source3/Makefile.in | 1 - source3/configure.in | 119 +++++++++++++++++++++++++++++++++++++++++++++-- source3/m4/check_path.m4 | 14 ------ 3 files changed, 115 insertions(+), 19 deletions(-) diff --git a/source3/Makefile.in b/source3/Makefile.in index b3978eae40..5448643c1d 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -130,7 +130,6 @@ INSTALLPERMS_DATA = 0644 LOGFILEBASE = @logfilebase@ CONFIGFILE = $(CONFIGDIR)/smb.conf LMHOSTSFILE = $(CONFIGDIR)/lmhosts -CTDBDIR = @ctdbdir@ NCALRPCDIR = @ncalrpcdir@ # This is where smbpasswd et al go diff --git a/source3/configure.in b/source3/configure.in index b4c021cd0d..40130fb300 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -5152,17 +5152,128 @@ AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT]) ################################################# # check for cluster extensions -AC_MSG_CHECKING(whether to include cluster support) +CTDB_CFLAGS="" +AC_SUBST(CTDB_CFLAGS) +AC_ARG_WITH(ctdb, +[AS_HELP_STRING([--with-ctdb=DIR], [Where to find ctdb sources])], +[ case "$withval" in + yes|no) + AC_MSG_WARN([--with-ctdb called without argument]) + ;; + *) + CTDB_CPPFLAGS="-I$withval/include" + ;; + esac]) + +SAVED_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $CTDB_CPPFLAGS" +ctdb_broken="missing or broken headers" + +AC_CHECK_HEADERS(ctdb.h ctdb_private.h,,,[ +#include "confdefs.h" +#define NO_CONFIG_H +#include "replace.h" +#include "system/wait.h" +#include "system/network.h" +#define private #error __USED_RESERVED_WORD_private__ +#include +#include +#include +]) + +AC_HAVE_DECL(CTDB_CONTROL_TRANS2_COMMIT_RETRY,[ +#include "confdefs.h" +#define NO_CONFIG_H +#include "replace.h" +#include "system/wait.h" +#include "system/network.h" +#include +#include +#include +#include +]) +if test x"$ac_cv_have_CTDB_CONTROL_TRANS2_COMMIT_RETRY_decl" = x"yes"; then + ctdb_broken=no +else + ctdb_broken="missing transaction support" +fi + +# in ctdb 1.0.57 ctdb_control_tcp was temparary renamed to ctdb_tcp_client +AC_CHECK_TYPE(struct ctdb_tcp_client,[ + AC_DEFINE([ctdb_control_tcp],[ctdb_tcp_client],[ctdb ipv4 support]) +],,[ +#include "confdefs.h" +#define NO_CONFIG_H +#include "replace.h" +#include "system/wait.h" +#include "system/network.h" +#include +#include +#include +#include +]) + +AC_CHECK_TYPE(struct ctdb_control_tcp,[ + AC_DEFINE([HAVE_STRUCT_CTDB_CONTROL_TCP],[1],[ctdb ipv4 support]) +],[ + ctdb_broken="missing struct ctdb_control_tcp" +],[ +#include "confdefs.h" +#define NO_CONFIG_H +#include "replace.h" +#include "system/wait.h" +#include "system/network.h" +#include +#include +#include +#include +]) + +AC_CHECK_TYPE(struct ctdb_control_tcp_addr,[ + AC_DEFINE([HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR],[1],[ctdb ipv6 support]) +],,[ +#include "confdefs.h" +#define NO_CONFIG_H +#include "replace.h" +#include "system/wait.h" +#include "system/network.h" +#include +#include +#include +#include +]) +CPPFLAGS="$SAVED_CPPFLAGS" + +AC_MSG_CHECKING(cluster support) AC_ARG_WITH(cluster-support, -[AS_HELP_STRING([--with-cluster-support], [Enable cluster extensions (default=no)])]) -if test "x$with_cluster_support" = "xyes"; then +[AS_HELP_STRING([--with-cluster-support], [Enable cluster extensions (default=auto)])]) + +if test x"$with_cluster_support" = x ; then + with_cluster_support="auto" +fi + +if test x"$ac_cv_header_ctdb_private_h" != x"yes"; then + if test "x$with_cluster_support" = "xyes"; then + AC_MSG_ERROR("ctdb_private.h is required for cluster support") + fi + with_cluster_support=no +fi + +if test x"$ctdb_broken" != x"no"; then + if test "x$with_cluster_support" = "xyes"; then + AC_MSG_ERROR(["cluster support: $ctdb_broken"]) + fi + with_cluster_support=no +fi + +if test "x$with_cluster_support" != "xno"; then AC_DEFINE(CLUSTER_SUPPORT,1,[Whether to enable cluster extensions]) + SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${CTDB_CPPFLAGS}" AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi - ################################################# # check for ACL support diff --git a/source3/m4/check_path.m4 b/source3/m4/check_path.m4 index 2a468d7002..12b998747a 100644 --- a/source3/m4/check_path.m4 +++ b/source3/m4/check_path.m4 @@ -214,19 +214,6 @@ AC_ARG_WITH(logfilebase, esac]) -################################################# -# set ctdb source directory location -AC_ARG_WITH(ctdb, -[AS_HELP_STRING([--with-ctdb=DIR], [Where to find ctdb sources])], -[ case "$withval" in - yes|no) - AC_MSG_WARN([--with-ctdb called without argument]) - ;; - * ) - ctdbdir="$withval" - ;; - esac]) - ################################################# # set shared modules (internal lib) directory location AC_ARG_WITH(modulesdir, @@ -297,7 +284,6 @@ AC_SUBST(lockdir) AC_SUBST(piddir) AC_SUBST(ncalrpcdir) AC_SUBST(logfilebase) -AC_SUBST(ctdbdir) AC_SUBST(privatedir) AC_SUBST(swatdir) AC_SUBST(bindir) -- cgit From bc84bd7b718e5cf46cbdc49557d2d18d544a2626 Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Thu, 29 Jan 2009 00:17:12 +0100 Subject: give configure check "sub-second timestamps without struct timespec" a chance to succeed --- source3/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/configure.in b/source3/configure.in index 40130fb300..0de44f384f 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -1423,7 +1423,7 @@ AC_CACHE_CHECK([whether struct stat has sub-second timestamps without struct tim t.tv_sec = s.st_atime; t.tv_nsec = s.st_atimensec; ], - samba_cv_stat_hires=yes, samba_cv_stat_hires=no) + samba_cv_stat_hires_notimespec=yes, samba_cv_stat_hires_notimespec=no) ]) if test x"$samba_cv_stat_hires_notimespec" = x"yes" ; then -- cgit From f9926a4944171759cdd129ae07962765d658f711 Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Thu, 29 Jan 2009 00:20:00 +0100 Subject: rather cosmetic fix for failed birthtime configure checks --- source3/configure.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source3/configure.in b/source3/configure.in index 0de44f384f..4ce9207a9e 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -1457,7 +1457,7 @@ AC_CACHE_CHECK([whether struct stat has st_birthtimespec], samba_cv_stat_st_birt struct stat s = {0}; t = s.st_birthtimespec; ], - samba_cv_stat_st_birthtimespec=yes, samba_cv_stat_birthtimespec=no) + samba_cv_stat_st_birthtimespec=yes, samba_cv_stat_st_birthtimespec=no) ]) if test x"$samba_cv_stat_st_birthtimespec" = x"yes" ; then @@ -1487,7 +1487,7 @@ AC_CACHE_CHECK([whether struct stat has st_birthtimensec], samba_cv_stat_st_birt struct stat s = {0}; t.tv_nsec = s.st_birthtimensec; ], - samba_cv_stat_st_birthtimensec=yes, samba_cv_stat_birthtimensec=no) + samba_cv_stat_st_birthtimensec=yes, samba_cv_stat_st_birthtimensec=no) ]) if test x"$samba_cv_stat_st_birthtimensec" = x"yes" ; then @@ -1517,7 +1517,7 @@ AC_CACHE_CHECK([whether struct stat has st_birthtime], samba_cv_stat_st_birthtim struct stat s = {0}; t = s.st_birthtime; ], - samba_cv_stat_st_birthtime=yes, samba_cv_stat_birthtime=no) + samba_cv_stat_st_birthtime=yes, samba_cv_stat_st_birthtime=no) ]) if test x"$samba_cv_stat_st_birthtime" = x"yes" ; then -- cgit From 11f32204f8e6c5e90e8e242116d3f74808184884 Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Thu, 29 Jan 2009 00:33:19 +0100 Subject: add configure check for AIX style sub-second resolution support --- source3/configure.in | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/source3/configure.in b/source3/configure.in index 4ce9207a9e..f44fb9b8c4 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -1395,7 +1395,7 @@ if test x"$samba_cv_stat_hires" = x"yes" ; then [whether struct stat has sub-second timestamps]) fi -AC_CACHE_CHECK([whether struct stat has sub-second timestamps without struct timespec], samba_cv_stat_hires_notimespec, +AC_CACHE_CHECK([whether struct stat has sub-second timestamps without struct timespec suffixed nsec], samba_cv_stat_hires_notimespec, [ AC_TRY_COMPILE( [ @@ -1431,7 +1431,47 @@ if test x"$samba_cv_stat_hires_notimespec" = x"yes" ; then AC_DEFINE(HAVE_STAT_ST_ATIMENSEC, 1, [whether struct stat contains st_atimensec]) AC_DEFINE(HAVE_STAT_ST_CTIMENSEC, 1, [whether struct stat contains st_ctimensec]) AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1, - [whether struct stat has sub-second timestamps without struct timespec]) + [whether struct stat has sub-second timestamps without struct timespec suffixed nsec]) +fi + +dnl AIX stype sub-second timestamps: +AC_CACHE_CHECK([whether struct stat has sub-second timestamps without struct timespec suffixed _n], samba_cv_stat_hires_notimespec_n, + [ + AC_TRY_COMPILE( + [ +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif + ], + [ + struct timespec t; + struct stat s = {0}; + t.tv_sec = s.st_mtime; + t.tv_nsec = s.st_mtime_n; + t.tv_sec = s.st_ctime; + t.tv_nsec = s.st_ctime_n; + t.tv_sec = s.st_atime; + t.tv_nsec = s.st_atime_n; + ], + samba_cv_stat_hires_notimespec_n=yes, samba_cv_stat_hires_notimespec_n=no) + ]) + +if test x"$samba_cv_stat_hires_notimespec_n" = x"yes" ; then + AC_DEFINE(HAVE_STAT_ST_MTIME_N, 1, [whether struct stat contains st_mtime_n]) + AC_DEFINE(HAVE_STAT_ST_ATIME_N, 1, [whether struct stat contains st_atime_n]) + AC_DEFINE(HAVE_STAT_ST_CTIME_N, 1, [whether struct stat contains st_ctime_n]) + AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1, + [whether struct stat has sub-second timestamps without struct timespec suffixed _n]) fi AC_CACHE_CHECK([whether struct stat has st_birthtimespec], samba_cv_stat_st_birthtimespec, -- cgit From 3639e525a92c1c91dd8d6f9286f1da4a33ee7656 Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Thu, 29 Jan 2009 00:35:26 +0100 Subject: add AIX sub-second resolution timestamp support --- source3/lib/time.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/source3/lib/time.c b/source3/lib/time.c index 7dd0da8fa8..1466471639 100644 --- a/source3/lib/time.c +++ b/source3/lib/time.c @@ -404,6 +404,11 @@ struct timespec get_atimespec(const SMB_STRUCT_STAT *pst) ret.tv_sec = pst->st_atime; ret.tv_nsec = pst->st_atimensec; return ret; +#elif defined(HAVE_STAT_ST_ATIME_N) + struct timespec ret; + ret.tv_sec = pst->st_atime; + ret.tv_nsec = pst->st_atime_n; + return ret; #elif defined(HAVE_STAT_ST_ATIMESPEC) return pst->st_atimespec; #else @@ -423,6 +428,9 @@ void set_atimespec(SMB_STRUCT_STAT *pst, struct timespec ts) #elif defined(HAVE_STAT_ST_ATIMENSEC) pst->st_atime = ts.tv_sec; pst->st_atimensec = ts.tv_nsec +#elif defined(HAVE_STAT_ST_ATIME_N) + pst->st_atime = ts.tv_sec; + pst->st_atime_n = ts.tv_nsec #elif defined(HAVE_STAT_ST_ATIMESPEC) pst->st_atimespec = ts; #else @@ -448,6 +456,11 @@ struct timespec get_mtimespec(const SMB_STRUCT_STAT *pst) ret.tv_sec = pst->st_mtime; ret.tv_nsec = pst->st_mtimensec; return ret; +#elif defined(HAVE_STAT_ST_MTIME_N) + struct timespec ret; + ret.tv_sec = pst->st_mtime; + ret.tv_nsec = pst->st_mtime_n; + return ret; #elif defined(HAVE_STAT_ST_MTIMESPEC) return pst->st_mtimespec; #else @@ -467,6 +480,9 @@ void set_mtimespec(SMB_STRUCT_STAT *pst, struct timespec ts) #elif defined(HAVE_STAT_ST_MTIMENSEC) pst->st_mtime = ts.tv_sec; pst->st_mtimensec = ts.tv_nsec +#elif defined(HAVE_STAT_ST_MTIME_N) + pst->st_mtime = ts.tv_sec; + pst->st_mtime_n = ts.tv_nsec #elif defined(HAVE_STAT_ST_ATIMESPEC) pst->st_atimespec = ts; #else @@ -492,6 +508,11 @@ struct timespec get_ctimespec(const SMB_STRUCT_STAT *pst) ret.tv_sec = pst->st_ctime; ret.tv_nsec = pst->st_ctimensec; return ret; +#elif defined(HAVE_STAT_ST_CTIME_N) + struct timespec ret; + ret.tv_sec = pst->st_ctime; + ret.tv_nsec = pst->st_ctime_n; + return ret; #elif defined(HAVE_STAT_ST_CTIMESPEC) return pst->st_ctimespec; #else @@ -511,6 +532,9 @@ void set_ctimespec(SMB_STRUCT_STAT *pst, struct timespec ts) #elif defined(HAVE_STAT_ST_CTIMENSEC) pst->st_ctime = ts.tv_sec; pst->st_ctimensec = ts.tv_nsec +#elif defined(HAVE_STAT_ST_CTIME_N) + pst->st_ctime = ts.tv_sec; + pst->st_ctime_n = ts.tv_nsec #elif defined(HAVE_STAT_ST_CTIMESPEC) pst->st_ctimespec = ts; #else -- cgit From 12f57f95b504af63634978e6faabb9a1859a4e82 Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Thu, 29 Jan 2009 13:23:26 +0100 Subject: setting mtime setted atime on BSD systems, fix this --- source3/lib/time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/lib/time.c b/source3/lib/time.c index 1466471639..d3b85433ea 100644 --- a/source3/lib/time.c +++ b/source3/lib/time.c @@ -483,8 +483,8 @@ void set_mtimespec(SMB_STRUCT_STAT *pst, struct timespec ts) #elif defined(HAVE_STAT_ST_MTIME_N) pst->st_mtime = ts.tv_sec; pst->st_mtime_n = ts.tv_nsec -#elif defined(HAVE_STAT_ST_ATIMESPEC) - pst->st_atimespec = ts; +#elif defined(HAVE_STAT_ST_MTIMESPEC) + pst->st_mtimespec = ts; #else #error CONFIGURE_ERROR_IN_DETECTING_TIMESPEC_IN_STAT #endif -- cgit From 29ab9ed933ff12d593414d13b5ce584e008f158c Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Thu, 29 Jan 2009 20:56:51 +0100 Subject: add missing semicolons the fixed configure check led to a missing semicolon in the now activated BSD code. Then this error was even copypasted into the new AIX code. grrr --- source3/lib/time.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source3/lib/time.c b/source3/lib/time.c index d3b85433ea..682d96c7db 100644 --- a/source3/lib/time.c +++ b/source3/lib/time.c @@ -427,10 +427,10 @@ void set_atimespec(SMB_STRUCT_STAT *pst, struct timespec ts) pst->st_atim = ts; #elif defined(HAVE_STAT_ST_ATIMENSEC) pst->st_atime = ts.tv_sec; - pst->st_atimensec = ts.tv_nsec + pst->st_atimensec = ts.tv_nsec; #elif defined(HAVE_STAT_ST_ATIME_N) pst->st_atime = ts.tv_sec; - pst->st_atime_n = ts.tv_nsec + pst->st_atime_n = ts.tv_nsec; #elif defined(HAVE_STAT_ST_ATIMESPEC) pst->st_atimespec = ts; #else @@ -479,10 +479,10 @@ void set_mtimespec(SMB_STRUCT_STAT *pst, struct timespec ts) pst->st_mtim = ts; #elif defined(HAVE_STAT_ST_MTIMENSEC) pst->st_mtime = ts.tv_sec; - pst->st_mtimensec = ts.tv_nsec + pst->st_mtimensec = ts.tv_nsec; #elif defined(HAVE_STAT_ST_MTIME_N) pst->st_mtime = ts.tv_sec; - pst->st_mtime_n = ts.tv_nsec + pst->st_mtime_n = ts.tv_nsec; #elif defined(HAVE_STAT_ST_MTIMESPEC) pst->st_mtimespec = ts; #else @@ -531,10 +531,10 @@ void set_ctimespec(SMB_STRUCT_STAT *pst, struct timespec ts) pst->st_ctim = ts; #elif defined(HAVE_STAT_ST_CTIMENSEC) pst->st_ctime = ts.tv_sec; - pst->st_ctimensec = ts.tv_nsec + pst->st_ctimensec = ts.tv_nsec; #elif defined(HAVE_STAT_ST_CTIME_N) pst->st_ctime = ts.tv_sec; - pst->st_ctime_n = ts.tv_nsec + pst->st_ctime_n = ts.tv_nsec; #elif defined(HAVE_STAT_ST_CTIMESPEC) pst->st_ctimespec = ts; #else -- cgit From 1a87568d99e35c7d028d742c59a3f811a67731e3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 29 Jan 2009 20:07:58 +0100 Subject: Fix the build on "opi" It did not like to include "includes.h" twice --- source3/lib/tdb_validate.c | 2 +- source3/lib/tdb_validate.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source3/lib/tdb_validate.c b/source3/lib/tdb_validate.c index 948201a5f2..1f5dfe4d25 100644 --- a/source3/lib/tdb_validate.c +++ b/source3/lib/tdb_validate.c @@ -19,8 +19,8 @@ * along with this program. If not, see . */ -#include "includes.h" #include "tdb_validate.h" +#include "includes.h" /* * internal validation function, executed by the child. diff --git a/source3/lib/tdb_validate.h b/source3/lib/tdb_validate.h index 1a207fa669..9eda79d7db 100644 --- a/source3/lib/tdb_validate.h +++ b/source3/lib/tdb_validate.h @@ -22,7 +22,8 @@ #ifndef __TDB_VALIDATE_H__ #define __TDB_VALIDATE_H__ -#include "includes.h" +#include "lib/replace/replace.h" +#include "tdb.h" /** * Flag field for keeping track of the status of a validation. -- cgit From 89caa0e86be9e20702a24fea4f94a11e6e02cc93 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 25 Jan 2009 21:55:05 +0100 Subject: cli_ucs2 --- source3/include/proto.h | 1 + source3/libsmb/clientgen.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/source3/include/proto.h b/source3/include/proto.h index f8a9dbce66..e2aeb197d0 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2462,6 +2462,7 @@ struct async_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev, DATA_BLOB data); NTSTATUS cli_echo_recv(struct async_req *req); NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data); +bool cli_ucs2(struct cli_state *cli); /* The following definitions come from libsmb/clierror.c */ diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 0bec24202c..d841bcff8d 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -55,6 +55,16 @@ void cli_set_port(struct cli_state *cli, int port) cli->port = port; } +/**************************************************************************** + convenience routine to find if we negotiated ucs2 +****************************************************************************/ + +bool cli_ucs2(struct cli_state *cli) +{ + return ((cli->capabilities & CAP_UNICODE) != 0); +} + + /**************************************************************************** Read an smb from a fd ignoring all keepalive packets. The timeout is in milliseconds -- cgit From 37da26a06ee0a51f2e6c7b93e2fefc2342613c84 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 26 Jan 2009 20:45:09 +0100 Subject: Add the strlen to push to smb_bytes_push_str, return the converted size The pushed strlen replaces the STR_TERMINATE flag which I personally always find very confusing. --- source3/include/proto.h | 3 ++- source3/libsmb/cliconnect.c | 5 ++++- source3/libsmb/clifile.c | 19 +++++++++++-------- source3/libsmb/clitrans.c | 6 +++--- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index e2aeb197d0..e00d644852 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2501,7 +2501,8 @@ int cli_nt_create_full(struct cli_state *cli, const char *fname, uint32 CreateDisposition, uint32 CreateOptions, uint8 SecuityFlags); int cli_nt_create(struct cli_state *cli, const char *fname, uint32 DesiredAccess); -uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str); +uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str, + size_t strlen, size_t *pconverted_size); struct async_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev, struct cli_state *cli, const char *fname, int flags, int share_mode); diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index bc690f2e02..5778e7f6a3 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -1294,7 +1294,10 @@ struct async_req *cli_negprot_send(TALLOC_CTX *mem_ctx, if (bytes == NULL) { return NULL; } - bytes = smb_bytes_push_str(bytes, false, prots[numprots].name); + bytes = smb_bytes_push_str(bytes, false, + prots[numprots].name, + strlen(prots[numprots].name)+1, + NULL); if (bytes == NULL) { return NULL; } diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 02cd2108bf..3b6585b7e7 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -781,7 +781,9 @@ int cli_nt_create(struct cli_state *cli, const char *fname, uint32 DesiredAccess FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0); } -uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str) +uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, + const char *str, size_t str_len, + size_t *pconverted_size) { size_t buflen; char *converted; @@ -806,7 +808,7 @@ uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str) if (!convert_string_allocate(talloc_tos(), CH_UNIX, ucs2 ? CH_UTF16LE : CH_DOS, - str, strlen(str)+1, &converted, + str, str_len, &converted, &converted_size, true)) { return NULL; } @@ -821,6 +823,11 @@ uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str) memcpy(buf + buflen, converted, converted_size); TALLOC_FREE(converted); + + if (pconverted_size) { + *pconverted_size = converted_size; + } + return buf; } @@ -890,12 +897,8 @@ struct async_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev, } bytes = talloc_array(talloc_tos(), uint8_t, 0); - if (bytes == NULL) { - return NULL; - } - - bytes = smb_bytes_push_str( - bytes, (cli->capabilities & CAP_UNICODE) != 0, fname); + bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), fname, + strlen(fname)+1, NULL); if (bytes == NULL) { return NULL; } diff --git a/source3/libsmb/clitrans.c b/source3/libsmb/clitrans.c index baa73aeb14..4a0fc5f6e9 100644 --- a/source3/libsmb/clitrans.c +++ b/source3/libsmb/clitrans.c @@ -765,9 +765,9 @@ static struct async_req *cli_ship_trans(TALLOC_CTX *mem_ctx, if (bytes == NULL) { goto fail; } - bytes = smb_bytes_push_str( - bytes, (state->cli->capabilities & CAP_UNICODE) != 0, - state->pipe_name); + bytes = smb_bytes_push_str(bytes, cli_ucs2(state->cli), + state->pipe_name, + strlen(state->pipe_name)+1, NULL); if (bytes == NULL) { goto fail; } -- cgit From a44649cf98ea8f45537ff9a65be69d621c002505 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 30 Jan 2009 00:16:41 +0100 Subject: s3:build: fix build on AIX - only test for splice on linux Michael --- source3/configure.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source3/configure.in b/source3/configure.in index f44fb9b8c4..87707a2f7f 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -5875,6 +5875,8 @@ fi ############################################ # See if we have the Linux splice syscall. +case "$host_os" in +*linux*) AC_CACHE_CHECK([for Linux splice], samba_cv_HAVE_LINUX_SPLICE,[ AC_TRY_LINK([ @@ -5885,6 +5887,11 @@ AC_CACHE_CHECK([for Linux splice], [long ret = splice(0,0,1,0,400,0);], samba_cv_HAVE_LINUX_SPLICE=yes, samba_cv_HAVE_LINUX_SPLICE=no)]) +;; +*) +samba_cv_HAVE_LINUX_SPLICE=no +;; +esac if test x"$samba_cv_HAVE_LINUX_SPLICE" = x"yes"; then AC_DEFINE(HAVE_LINUX_SPLICE,1, -- cgit From f2224e53b23ffdc0157330527585649c0e5ca635 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 22 Jan 2009 10:24:40 +0100 Subject: s3:idmap: move IDMAP_VERSION to the idmap tdb backend, where it belogns. Michael --- source3/include/idmap.h | 5 ----- source3/winbindd/idmap_tdb.c | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source3/include/idmap.h b/source3/include/idmap.h index 4322192155..672e373108 100644 --- a/source3/include/idmap.h +++ b/source3/include/idmap.h @@ -22,11 +22,6 @@ along with this program. If not, see . */ -/* idmap version determines auto-conversion - this is the database - structure version specifier. */ - -#define IDMAP_VERSION 2 - /* The interface version specifier. Updated to 3 for enum types by JRA. */ diff --git a/source3/winbindd/idmap_tdb.c b/source3/winbindd/idmap_tdb.c index 99821ae501..481ac1b9ad 100644 --- a/source3/winbindd/idmap_tdb.c +++ b/source3/winbindd/idmap_tdb.c @@ -28,6 +28,11 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_IDMAP +/* idmap version determines auto-conversion - this is the database + structure version specifier. */ + +#define IDMAP_VERSION 2 + /* High water mark keys */ #define HWM_GROUP "GROUP HWM" #define HWM_USER "USER HWM" -- cgit From aeb23872e25fb720140a10ce01a4211d228b6555 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 22 Jan 2009 12:34:43 +0100 Subject: s3:proto.h: remove duplicate prototypes. Michael --- source3/include/proto.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index e00d644852..af5181eca6 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1674,8 +1674,6 @@ bool winbind_lookup_rids(TALLOC_CTX *mem_ctx, int num_rids, uint32 *rids, const char **domain_name, const char ***names, enum lsa_SidType **types); -bool winbind_allocate_uid(uid_t *uid); -bool winbind_allocate_gid(gid_t *gid); /* The following definitions come from lib/wins_srv.c */ -- cgit From ede173219541fd67db42376bb7979bcf2febcaf0 Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Thu, 29 Jan 2009 21:59:44 +0100 Subject: add configure check for Tru64 sub-second timestamp resolution --- source3/configure.in | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/source3/configure.in b/source3/configure.in index 87707a2f7f..3ae2c8c9d3 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -1474,6 +1474,46 @@ if test x"$samba_cv_stat_hires_notimespec_n" = x"yes" ; then [whether struct stat has sub-second timestamps without struct timespec suffixed _n]) fi +dnl Tru64 has _micro_second_ resolution: +AC_CACHE_CHECK([whether struct stat has sub-second timestamps in st_uXtime], samba_cv_stat_hires_uxtime, + [ + AC_TRY_COMPILE( + [ +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif + ], + [ + struct timespec t; + struct stat s = {0}; + t.tv_sec = s.st_mtime; + t.tv_nsec = s.st_umtime * 1000; + t.tv_sec = s.st_ctime; + t.tv_nsec = s.st_uctime * 1000; + t.tv_sec = s.st_atime; + t.tv_nsec = s.st_uatime * 1000; + ], + samba_cv_stat_hires_uxtime=yes, samba_cv_stat_hires_uxtime=no) + ]) + +if test x"$samba_cv_stat_hires_uxtime" = x"yes" ; then + AC_DEFINE(HAVE_STAT_ST_UMTIME, 1, [whether struct stat contains st_umtime]) + AC_DEFINE(HAVE_STAT_ST_UATIME, 1, [whether struct stat contains st_uatime]) + AC_DEFINE(HAVE_STAT_ST_UCTIME, 1, [whether struct stat contains st_uctime]) + AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1, + [whether struct stat has sub-second timestamps in st_uXtime]) +fi + AC_CACHE_CHECK([whether struct stat has st_birthtimespec], samba_cv_stat_st_birthtimespec, [ AC_TRY_COMPILE( -- cgit From d177015a6d43fcc26a823e52b86850a82261ad4d Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Thu, 29 Jan 2009 22:59:00 +0100 Subject: add Tru64 sub-second resolution timestamp support --- source3/lib/time.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/source3/lib/time.c b/source3/lib/time.c index 682d96c7db..e2cfe687b2 100644 --- a/source3/lib/time.c +++ b/source3/lib/time.c @@ -409,6 +409,11 @@ struct timespec get_atimespec(const SMB_STRUCT_STAT *pst) ret.tv_sec = pst->st_atime; ret.tv_nsec = pst->st_atime_n; return ret; +#elif defined(HAVE_STAT_ST_UATIME) + struct timespec ret; + ret.tv_sec = pst->st_atime; + ret.tv_nsec = pst->st_uatime * 1000; + return ret; #elif defined(HAVE_STAT_ST_ATIMESPEC) return pst->st_atimespec; #else @@ -431,6 +436,9 @@ void set_atimespec(SMB_STRUCT_STAT *pst, struct timespec ts) #elif defined(HAVE_STAT_ST_ATIME_N) pst->st_atime = ts.tv_sec; pst->st_atime_n = ts.tv_nsec; +#elif defined(HAVE_STAT_ST_UATIME) + pst->st_atime = ts.tv_sec; + pst->st_uatime = ts.tv_nsec / 1000; #elif defined(HAVE_STAT_ST_ATIMESPEC) pst->st_atimespec = ts; #else @@ -461,6 +469,11 @@ struct timespec get_mtimespec(const SMB_STRUCT_STAT *pst) ret.tv_sec = pst->st_mtime; ret.tv_nsec = pst->st_mtime_n; return ret; +#elif defined(HAVE_STAT_ST_UMTIME) + struct timespec ret; + ret.tv_sec = pst->st_mtime; + ret.tv_nsec = pst->st_umtime * 1000; + return ret; #elif defined(HAVE_STAT_ST_MTIMESPEC) return pst->st_mtimespec; #else @@ -483,6 +496,9 @@ void set_mtimespec(SMB_STRUCT_STAT *pst, struct timespec ts) #elif defined(HAVE_STAT_ST_MTIME_N) pst->st_mtime = ts.tv_sec; pst->st_mtime_n = ts.tv_nsec; +#elif defined(HAVE_STAT_ST_UMTIME) + pst->st_mtime = ts.tv_sec; + pst->st_umtime = ts.tv_nsec / 1000; #elif defined(HAVE_STAT_ST_MTIMESPEC) pst->st_mtimespec = ts; #else @@ -513,6 +529,11 @@ struct timespec get_ctimespec(const SMB_STRUCT_STAT *pst) ret.tv_sec = pst->st_ctime; ret.tv_nsec = pst->st_ctime_n; return ret; +#elif defined(HAVE_STAT_ST_UCTIME) + struct timespec ret; + ret.tv_sec = pst->st_ctime; + ret.tv_nsec = pst->st_uctime * 1000; + return ret; #elif defined(HAVE_STAT_ST_CTIMESPEC) return pst->st_ctimespec; #else @@ -535,6 +556,9 @@ void set_ctimespec(SMB_STRUCT_STAT *pst, struct timespec ts) #elif defined(HAVE_STAT_ST_CTIME_N) pst->st_ctime = ts.tv_sec; pst->st_ctime_n = ts.tv_nsec; +#elif defined(HAVE_STAT_ST_UCTIME) + pst->st_ctime = ts.tv_sec; + pst->st_uctime = ts.tv_nsec / 1000; #elif defined(HAVE_STAT_ST_CTIMESPEC) pst->st_ctimespec = ts; #else -- cgit From b8f7cdbd79918bba0fea181f97fff5ab0c79192d Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Mon, 26 Jan 2009 15:39:40 -0800 Subject: s3: Add a new SMB_VFS_GET_ALLOC_SIZE vfs operation This allows module implementors to customize what allocation size is returned to the client. --- source3/include/proto.h | 2 +- source3/include/smbprofile.h | 4 +++ source3/include/vfs.h | 4 +++ source3/include/vfs_macros.h | 3 +++ source3/lib/util.c | 11 +++++++- source3/modules/onefs_streams.c | 8 +++--- source3/modules/vfs_default.c | 37 +++++++++++++++++++++++++- source3/modules/vfs_full_audit.c | 17 ++++++++++++ source3/modules/vfs_streams_depot.c | 8 +++--- source3/modules/vfs_streams_xattr.c | 4 +-- source3/smbd/nttrans.c | 4 +-- source3/smbd/reply.c | 4 +-- source3/smbd/trans2.c | 52 ++++++++++--------------------------- 13 files changed, 102 insertions(+), 56 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index af5181eca6..71e2145b83 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1128,6 +1128,7 @@ bool add_gid_to_array_unique(TALLOC_CTX *mem_ctx, gid_t gid, bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf); bool socket_exist(const char *fname); bool directory_exist_stat(char *dname,SMB_STRUCT_STAT *st); +uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf); SMB_OFF_T get_file_size(char *file_name); char *attrib_string(uint16 mode); void show_msg(char *buf); @@ -7377,7 +7378,6 @@ int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf); /* The following definitions come from smbd/trans2.c */ uint64_t smb_roundup(connection_struct *conn, uint64_t val); -uint64_t get_allocation_size(connection_struct *conn, files_struct *fsp, const SMB_STRUCT_STAT *sbuf); NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn, files_struct *fsp, const char *fname, const char *ea_name, struct ea_struct *pea); diff --git a/source3/include/smbprofile.h b/source3/include/smbprofile.h index 8945708ca3..131416b685 100644 --- a/source3/include/smbprofile.h +++ b/source3/include/smbprofile.h @@ -127,6 +127,10 @@ enum profile_stats_values #define syscall_lstat_count __profile_stats_value(PR_VALUE_SYSCALL_LSTAT, count) #define syscall_lstat_time __profile_stats_value(PR_VALUE_SYSCALL_LSTAT, time) + PR_VALUE_SYSCALL_GET_ALLOC_SIZE, +#define syscall_get_alloc_size_count __profile_stats_value(PR_VALUE_SYSCALL_GET_ALLOC_SIZE, count) +#define syscall_get_alloc_size_time __profile_stats_value(PR_VALUE_SYSCALL_GET_ALLOC_SIZE, time) + PR_VALUE_SYSCALL_UNLINK, #define syscall_unlink_count __profile_stats_value(PR_VALUE_SYSCALL_UNLINK, count) #define syscall_unlink_time __profile_stats_value(PR_VALUE_SYSCALL_UNLINK, time) diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 5df71da905..e9115ab807 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -112,6 +112,7 @@ /* Changed to version 25 - Jelmer's change from SMB_BIG_UINT to uint64_t. */ /* Leave at 25 - not yet released. Add create_file call. -- tprouty. */ /* Leave at 25 - not yet released. Add create time to ntimes. -- tstecher. */ +/* Leave at 25 - not yet released. Add get_alloc_size call. -- tprouty. */ #define SMB_VFS_INTERFACE_VERSION 25 @@ -189,6 +190,7 @@ typedef enum _vfs_op_type { SMB_VFS_OP_STAT, SMB_VFS_OP_FSTAT, SMB_VFS_OP_LSTAT, + SMB_VFS_OP_GET_ALLOC_SIZE, SMB_VFS_OP_UNLINK, SMB_VFS_OP_CHMOD, SMB_VFS_OP_FCHMOD, @@ -342,6 +344,7 @@ struct vfs_ops { int (*stat)(struct vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf); int (*fstat)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_STAT *sbuf); int (*lstat)(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf); + uint64_t (*get_alloc_size)(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_STAT *sbuf); int (*unlink)(struct vfs_handle_struct *handle, const char *path); int (*chmod)(struct vfs_handle_struct *handle, const char *path, mode_t mode); int (*fchmod)(struct vfs_handle_struct *handle, struct files_struct *fsp, mode_t mode); @@ -496,6 +499,7 @@ struct vfs_ops { struct vfs_handle_struct *stat; struct vfs_handle_struct *fstat; struct vfs_handle_struct *lstat; + struct vfs_handle_struct *get_alloc_size; struct vfs_handle_struct *unlink; struct vfs_handle_struct *chmod; struct vfs_handle_struct *fchmod; diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index c6ccd4912a..e7a9cfdc76 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -62,6 +62,7 @@ #define SMB_VFS_STAT(conn, fname, sbuf) ((conn)->vfs.ops.stat((conn)->vfs.handles.stat, (fname), (sbuf))) #define SMB_VFS_FSTAT(fsp, sbuf) ((fsp)->conn->vfs.ops.fstat((fsp)->conn->vfs.handles.fstat, (fsp), (sbuf))) #define SMB_VFS_LSTAT(conn, path, sbuf) ((conn)->vfs.ops.lstat((conn)->vfs.handles.lstat, (path), (sbuf))) +#define SMB_VFS_GET_ALLOC_SIZE(conn, fsp, sbuf) ((conn)->vfs.ops.get_alloc_size((conn)->vfs.handles.get_alloc_size, (fsp), (sbuf))) #define SMB_VFS_UNLINK(conn, path) ((conn)->vfs.ops.unlink((conn)->vfs.handles.unlink, (path))) #define SMB_VFS_CHMOD(conn, path, mode) ((conn)->vfs.ops.chmod((conn)->vfs.handles.chmod, (path), (mode))) #define SMB_VFS_FCHMOD(fsp, mode) ((fsp)->conn->vfs.ops.fchmod((fsp)->conn->vfs.handles.fchmod, (fsp), (mode))) @@ -189,6 +190,7 @@ #define SMB_VFS_OPAQUE_STAT(conn, fname, sbuf) ((conn)->vfs_opaque.ops.stat((conn)->vfs_opaque.handles.stat, (fname), (sbuf))) #define SMB_VFS_OPAQUE_FSTAT(fsp, sbuf) ((fsp)->conn->vfs_opaque.ops.fstat((fsp)->conn->vfs_opaque.handles.fstat, (fsp), (sbuf))) #define SMB_VFS_OPAQUE_LSTAT(conn, path, sbuf) ((conn)->vfs_opaque.ops.lstat((conn)->vfs_opaque.handles.lstat, (path), (sbuf))) +#define SMB_VFS_OPAQUE_GET_ALLOC_SIZE(conn, fsp, sbuf) ((conn)->vfs_opaque.ops.get_alloc_size((conn)->vfs_opaque.handles.get_alloc_size, (fsp), (sbuf))) #define SMB_VFS_OPAQUE_UNLINK(conn, path) ((conn)->vfs_opaque.ops.unlink((conn)->vfs_opaque.handles.unlink, (path))) #define SMB_VFS_OPAQUE_CHMOD(conn, path, mode) ((conn)->vfs_opaque.ops.chmod((conn)->vfs_opaque.handles.chmod, (path), (mode))) #define SMB_VFS_OPAQUE_FCHMOD(fsp, mode) ((fsp)->conn->vfs_opaque.ops.fchmod((fsp)->conn->vfs_opaque.handles.fchmod, (fsp), (mode))) @@ -317,6 +319,7 @@ #define SMB_VFS_NEXT_STAT(handle, fname, sbuf) ((handle)->vfs_next.ops.stat((handle)->vfs_next.handles.stat, (fname), (sbuf))) #define SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf) ((handle)->vfs_next.ops.fstat((handle)->vfs_next.handles.fstat, (fsp), (sbuf))) #define SMB_VFS_NEXT_LSTAT(handle, path, sbuf) ((handle)->vfs_next.ops.lstat((handle)->vfs_next.handles.lstat, (path), (sbuf))) +#define SMB_VFS_NEXT_GET_ALLOC_SIZE(conn, fsp, sbuf) ((conn)->vfs_next.ops.get_alloc_size((conn)->vfs_next.handles.get_alloc_size, (fsp), (sbuf))) #define SMB_VFS_NEXT_UNLINK(handle, path) ((handle)->vfs_next.ops.unlink((handle)->vfs_next.handles.unlink, (path))) #define SMB_VFS_NEXT_CHMOD(handle, path, mode) ((handle)->vfs_next.ops.chmod((handle)->vfs_next.handles.chmod, (path), (mode))) #define SMB_VFS_NEXT_FCHMOD(handle, fsp, mode) ((handle)->vfs_next.ops.fchmod((handle)->vfs_next.handles.fchmod, (fsp), (mode))) diff --git a/source3/lib/util.c b/source3/lib/util.c index 2485d1def5..195065a1e0 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -541,6 +541,15 @@ bool directory_exist_stat(char *dname,SMB_STRUCT_STAT *st) return ret; } +/******************************************************************* + Returns the size in bytes of the named given the stat struct. +********************************************************************/ + +uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf) +{ + return sbuf->st_size; +} + /******************************************************************* Returns the size in bytes of the named file. ********************************************************************/ @@ -551,7 +560,7 @@ SMB_OFF_T get_file_size(char *file_name) buf.st_size = 0; if(sys_stat(file_name,&buf) != 0) return (SMB_OFF_T)-1; - return(buf.st_size); + return get_file_size_stat(&buf); } /******************************************************************* diff --git a/source3/modules/onefs_streams.c b/source3/modules/onefs_streams.c index e9543e237f..78b0fd61bf 100644 --- a/source3/modules/onefs_streams.c +++ b/source3/modules/onefs_streams.c @@ -533,8 +533,8 @@ static NTSTATUS walk_onefs_streams(connection_struct *conn, files_struct *fsp, if (!add_one_stream(state->mem_ctx, &state->num_streams, &state->streams, dp->d_name, stream_sbuf.st_size, - get_allocation_size(conn, NULL, - &stream_sbuf))) { + SMB_VFS_GET_ALLOC_SIZE(conn, NULL, + &stream_sbuf))) { state->status = NT_STATUS_NO_MEMORY; break; } @@ -594,8 +594,8 @@ NTSTATUS onefs_streaminfo(vfs_handle_struct *handle, if (!add_one_stream(mem_ctx, &state.num_streams, &state.streams, "", sbuf.st_size, - get_allocation_size(handle->conn, fsp, - &sbuf))) { + SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp, + &sbuf))) { return NT_STATUS_NO_MEMORY; } } diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index a9aabab768..f8ac3e85d3 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -551,6 +551,39 @@ int vfswrap_lstat(vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT return result; } +/******************************************************************** + Given a stat buffer return the allocated size on disk, taking into + account sparse files. +********************************************************************/ +static uint64_t vfswrap_get_alloc_size(vfs_handle_struct *handle, + struct files_struct *fsp, + const SMB_STRUCT_STAT *sbuf) +{ + uint64_t result; + + START_PROFILE(syscall_get_alloc_size); + + if(S_ISDIR(sbuf->st_mode)) { + result = 0; + goto out; + } + +#if defined(HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE) + result = (uint64_t)STAT_ST_BLOCKSIZE * (uint64_t)sbuf->st_blocks; +#else + result = get_file_size_stat(sbuf); +#endif + + if (fsp && fsp->initial_allocation_size) + result = MAX(result,fsp->initial_allocation_size); + + result = smb_roundup(handle->conn, result); + + out: + END_PROFILE(syscall_get_alloc_size); + return result; +} + static int vfswrap_unlink(vfs_handle_struct *handle, const char *path) { int result; @@ -1043,7 +1076,7 @@ static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle, } streams->size = sbuf.st_size; - streams->alloc_size = get_allocation_size(handle->conn, fsp, &sbuf); + streams->alloc_size = SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp, &sbuf); streams->name = talloc_strdup(streams, "::$DATA"); if (streams->name == NULL) { @@ -1443,6 +1476,8 @@ static vfs_op_tuple vfs_default_ops[] = { SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(vfswrap_lstat), SMB_VFS_OP_LSTAT, SMB_VFS_LAYER_OPAQUE}, + {SMB_VFS_OP(vfswrap_get_alloc_size), SMB_VFS_OP_GET_ALLOC_SIZE, + SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(vfswrap_unlink), SMB_VFS_OP_UNLINK, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(vfswrap_chmod), SMB_VFS_OP_CHMOD, diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 73758a2d9d..c6d62fdd87 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -155,6 +155,8 @@ static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf); static int smb_full_audit_lstat(vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf); +static int smb_full_audit_get_alloc_size(vfs_handle_struct *handle, + files_struct *fsp, const SMB_STRUCT_STAT *sbuf); static int smb_full_audit_unlink(vfs_handle_struct *handle, const char *path); static int smb_full_audit_chmod(vfs_handle_struct *handle, @@ -403,6 +405,8 @@ static vfs_op_tuple audit_op_tuples[] = { SMB_VFS_LAYER_LOGGER}, {SMB_VFS_OP(smb_full_audit_lstat), SMB_VFS_OP_LSTAT, SMB_VFS_LAYER_LOGGER}, + {SMB_VFS_OP(smb_full_audit_get_alloc_size), SMB_VFS_OP_GET_ALLOC_SIZE, + SMB_VFS_LAYER_LOGGER}, {SMB_VFS_OP(smb_full_audit_unlink), SMB_VFS_OP_UNLINK, SMB_VFS_LAYER_LOGGER}, {SMB_VFS_OP(smb_full_audit_chmod), SMB_VFS_OP_CHMOD, @@ -597,6 +601,7 @@ static struct { { SMB_VFS_OP_STAT, "stat" }, { SMB_VFS_OP_FSTAT, "fstat" }, { SMB_VFS_OP_LSTAT, "lstat" }, + { SMB_VFS_OP_GET_ALLOC_SIZE, "get_alloc_size" }, { SMB_VFS_OP_UNLINK, "unlink" }, { SMB_VFS_OP_CHMOD, "chmod" }, { SMB_VFS_OP_FCHMOD, "fchmod" }, @@ -1325,6 +1330,18 @@ static int smb_full_audit_lstat(vfs_handle_struct *handle, return result; } +static int smb_full_audit_get_alloc_size(vfs_handle_struct *handle, + files_struct *fsp, const SMB_STRUCT_STAT *sbuf) +{ + int result; + + result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf); + + do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result >= 0), handle, "%d", result); + + return result; +} + static int smb_full_audit_unlink(vfs_handle_struct *handle, const char *path) { diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index 54c17db1ce..77efb277de 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -648,8 +648,8 @@ static bool collect_one_stream(const char *dirname, if (!add_one_stream(state->mem_ctx, &state->num_streams, &state->streams, dirent, sbuf.st_size, - get_allocation_size( - state->handle->conn, NULL, &sbuf))) { + SMB_VFS_GET_ALLOC_SIZE(state->handle->conn, NULL, + &sbuf))) { state->status = NT_STATUS_NO_MEMORY; return false; } @@ -693,8 +693,8 @@ static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle, if (!add_one_stream(mem_ctx, &state.num_streams, &state.streams, "::$DATA", sbuf.st_size, - get_allocation_size(handle->conn, fsp, - &sbuf))) { + SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp, + &sbuf))) { return NT_STATUS_NO_MEMORY; } } diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 1df4932167..37473439dd 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -732,8 +732,8 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle, if (!add_one_stream(mem_ctx, &state.num_streams, &state.streams, "::$DATA", sbuf.st_size, - get_allocation_size(handle->conn, fsp, - &sbuf))) { + SMB_VFS_GET_ALLOC_SIZE(handle->conn, fsp, + &sbuf))) { return NT_STATUS_NO_MEMORY; } } diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 1ee3edbdbe..0ad4df6e90 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -621,7 +621,7 @@ void reply_ntcreate_and_X(struct smb_request *req) p += 8; SIVAL(p,0,fattr); /* File Attributes. */ p += 4; - SOFF_T(p, 0, get_allocation_size(conn,fsp,&sbuf)); + SOFF_T(p, 0, SMB_VFS_GET_ALLOC_SIZE(conn,fsp,&sbuf)); p += 8; SOFF_T(p,0,file_len); p += 8; @@ -1086,7 +1086,7 @@ static void call_nt_transact_create(connection_struct *conn, p += 8; SIVAL(p,0,fattr); /* File Attributes. */ p += 4; - SOFF_T(p, 0, get_allocation_size(conn,fsp,&sbuf)); + SOFF_T(p, 0, SMB_VFS_GET_ALLOC_SIZE(conn,fsp,&sbuf)); p += 8; SOFF_T(p,0,file_len); p += 8; diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 52dab0a013..25d50470ff 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -1816,7 +1816,7 @@ void reply_open_and_X(struct smb_request *req) END_PROFILE(SMBopenX); return; } - sbuf.st_size = get_allocation_size(conn,fsp,&sbuf); + sbuf.st_size = SMB_VFS_GET_ALLOC_SIZE(conn,fsp,&sbuf); } fattr = dos_mode(conn,fsp->fsp_name,&sbuf); @@ -7281,7 +7281,7 @@ void reply_getattrE(struct smb_request *req) SIVAL(req->outbuf, smb_vwv6, 0); SIVAL(req->outbuf, smb_vwv8, 0); } else { - uint32 allocation_size = get_allocation_size(conn,fsp, &sbuf); + uint32 allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn,fsp, &sbuf); SIVAL(req->outbuf, smb_vwv6, (uint32)sbuf.st_size); SIVAL(req->outbuf, smb_vwv8, allocation_size); } diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 1b161d5338..6c082a8273 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -29,7 +29,6 @@ extern enum protocol_types Protocol; -#define get_file_size(sbuf) ((sbuf).st_size) #define DIR_ENTRY_SAFETY_MARGIN 4096 static char *store_file_unix_basic(connection_struct *conn, @@ -59,31 +58,6 @@ uint64_t smb_roundup(connection_struct *conn, uint64_t val) return val; } -/******************************************************************** - Given a stat buffer return the allocated size on disk, taking into - account sparse files. -********************************************************************/ - -uint64_t get_allocation_size(connection_struct *conn, files_struct *fsp, const SMB_STRUCT_STAT *sbuf) -{ - uint64_t ret; - - if(S_ISDIR(sbuf->st_mode)) { - return 0; - } - -#if defined(HAVE_STAT_ST_BLOCKS) && defined(STAT_ST_BLOCKSIZE) - ret = (uint64_t)STAT_ST_BLOCKSIZE * (uint64_t)sbuf->st_blocks; -#else - ret = (uint64_t)get_file_size(*sbuf); -#endif - - if (fsp && fsp->initial_allocation_size) - ret = MAX(ret,fsp->initial_allocation_size); - - return smb_roundup(conn, ret); -} - /**************************************************************************** Utility functions for dealing with extended attributes. ****************************************************************************/ @@ -1034,7 +1008,7 @@ static void call_trans2open(connection_struct *conn, return; } - size = get_file_size(sbuf); + size = get_file_size_stat(&sbuf); fattr = dos_mode(conn,fsp->fsp_name,&sbuf); mtime = sbuf.st_mtime; inode = sbuf.st_ino; @@ -1424,9 +1398,9 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx, } if (!(mode & aDIR)) { - file_size = get_file_size(sbuf); + file_size = get_file_size_stat(&sbuf); } - allocation_size = get_allocation_size(conn,NULL,&sbuf); + allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn,NULL,&sbuf); mdate_ts = get_mtimespec(&sbuf); adate_ts = get_atimespec(&sbuf); @@ -3523,10 +3497,10 @@ static char *store_file_unix_basic(connection_struct *conn, DEBUG(10,("store_file_unix_basic: SMB_QUERY_FILE_UNIX_BASIC\n")); DEBUG(4,("store_file_unix_basic: st_mode=%o\n",(int)psbuf->st_mode)); - SOFF_T(pdata,0,get_file_size(*psbuf)); /* File size 64 Bit */ + SOFF_T(pdata,0,get_file_size_stat(psbuf)); /* File size 64 Bit */ pdata += 8; - SOFF_T(pdata,0,get_allocation_size(conn,fsp,psbuf)); /* Number of bytes used on disk - 64 Bit */ + SOFF_T(pdata,0,SMB_VFS_GET_ALLOC_SIZE(conn,fsp,psbuf)); /* Number of bytes used on disk - 64 Bit */ pdata += 8; put_long_date_timespec(pdata,get_ctimespec(psbuf)); /* Change Time 64 Bit */ @@ -4094,7 +4068,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn, fullpathname = fname; if (!(mode & aDIR)) - file_size = get_file_size(sbuf); + file_size = get_file_size_stat(&sbuf); /* Pull out any data sent here before we realloc. */ switch (info_level) { @@ -4180,7 +4154,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd mtime_ts = get_mtimespec(&sbuf); atime_ts = get_atimespec(&sbuf); - allocation_size = get_allocation_size(conn,fsp,&sbuf); + allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn,fsp,&sbuf); if (!fsp) { /* Do we have this path open ? */ @@ -4188,7 +4162,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd fileid = vfs_file_id_from_sbuf(conn, &sbuf); fsp1 = file_find_di_first(fileid); if (fsp1 && fsp1->initial_allocation_size) { - allocation_size = get_allocation_size(conn, fsp1, &sbuf); + allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn, fsp1, &sbuf); } } @@ -5044,7 +5018,7 @@ static NTSTATUS smb_set_file_size(connection_struct *conn, DEBUG(6,("smb_set_file_size: size: %.0f ", (double)size)); - if (size == get_file_size(*psbuf)) { + if (size == get_file_size_stat(psbuf)) { return NT_STATUS_OK; } @@ -5832,7 +5806,7 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn, if (fsp && fsp->fh->fd != -1) { /* Open file handle. */ /* Only change if needed. */ - if (allocation_size != get_file_size(*psbuf)) { + if (allocation_size != get_file_size_stat(psbuf)) { if (vfs_allocate_file_space(fsp, allocation_size) == -1) { return map_nt_error_from_unix(errno); } @@ -5874,7 +5848,7 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn, } /* Only change if needed. */ - if (allocation_size != get_file_size(*psbuf)) { + if (allocation_size != get_file_size_stat(psbuf)) { if (vfs_allocate_file_space(new_fsp, allocation_size) == -1) { status = map_nt_error_from_unix(errno); close_file(req, new_fsp, NORMAL_CLOSE); @@ -6101,7 +6075,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n", /* Ensure we don't try and change anything else. */ raw_unixmode = SMB_MODE_NO_CHANGE; - size = get_file_size(*psbuf); + size = get_file_size_stat(psbuf); ft.atime = get_atimespec(psbuf); ft.mtime = get_mtimespec(psbuf); /* @@ -6117,7 +6091,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n", * */ if (!size) { - size = get_file_size(*psbuf); + size = get_file_size_stat(psbuf); } #endif -- cgit From 60d058442ee8a95a3d5c3f8e04cf15249509ceb2 Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Mon, 26 Jan 2009 17:19:40 -0800 Subject: s3 onefs: Add the OneFS implementation of SMB_VFS_GET_ALLOC_SIZE --- source3/modules/vfs_onefs.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/source3/modules/vfs_onefs.c b/source3/modules/vfs_onefs.c index e048e89589..e2f272aa11 100644 --- a/source3/modules/vfs_onefs.c +++ b/source3/modules/vfs_onefs.c @@ -40,6 +40,31 @@ static int onefs_open(vfs_handle_struct *handle, const char *fname, return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); } +static uint64_t onefs_get_alloc_size(struct vfs_handle_struct *handle, files_struct *fsp, + const SMB_STRUCT_STAT *sbuf) +{ + uint64_t result; + + START_PROFILE(syscall_get_alloc_size); + + if(S_ISDIR(sbuf->st_mode)) { + result = 0; + goto out; + } + + /* Just use the file size since st_blocks is unreliable on OneFS. */ + result = get_file_size_stat(sbuf); + + if (fsp && fsp->initial_allocation_size) + result = MAX(result,fsp->initial_allocation_size); + + result = smb_roundup(handle->conn, result); + + out: + END_PROFILE(syscall_get_alloc_size); + return result; +} + static int onefs_statvfs(vfs_handle_struct *handle, const char *path, vfs_statvfs_struct *statbuf) { @@ -123,6 +148,8 @@ static vfs_op_tuple onefs_ops[] = { SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(onefs_lstat), SMB_VFS_OP_LSTAT, SMB_VFS_LAYER_TRANSPARENT}, + {SMB_VFS_OP(onefs_get_alloc_size), SMB_VFS_OP_GET_ALLOC_SIZE, + SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(onefs_unlink), SMB_VFS_OP_UNLINK, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(onefs_ntimes), SMB_VFS_OP_NTIMES, -- cgit From d1ab1b6482d7413337b42de83d7de1ae016d33e1 Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Thu, 29 Jan 2009 14:50:18 -0800 Subject: s3 build: Fix "shadows global declaration warning" --- source3/include/proto.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 71e2145b83..8276847706 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2501,7 +2501,7 @@ int cli_nt_create_full(struct cli_state *cli, const char *fname, uint8 SecuityFlags); int cli_nt_create(struct cli_state *cli, const char *fname, uint32 DesiredAccess); uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str, - size_t strlen, size_t *pconverted_size); + size_t str_len, size_t *pconverted_size); struct async_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev, struct cli_state *cli, const char *fname, int flags, int share_mode); -- cgit From 864852a4ae1b0c0d1cf1afdcd042c9113f51acd6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Jan 2009 15:58:50 -0800 Subject: Upgrade POSIX inheritance storage to a new format (version 2). Stores the Windows ACL type and flags if "map acl inherit" is set. Jeremy. --- source3/smbd/posix_acls.c | 560 +++++++++++++++++++++++++++++----------------- 1 file changed, 360 insertions(+), 200 deletions(-) diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index 72f5c94bc5..7ea6e39fcb 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -1,7 +1,7 @@ /* Unix SMB/CIFS implementation. SMB NT Security Descriptor / Unix permission conversion. - Copyright (C) Jeremy Allison 1994-2000. + Copyright (C) Jeremy Allison 1994-2009. Copyright (C) Andreas Gruenbacher 2002. This program is free software; you can redistribute it and/or modify @@ -47,30 +47,65 @@ typedef struct canon_ace { enum ace_owner owner_type; enum ace_attribute attr; posix_id unix_ug; - bool inherited; + uint8_t ace_flags; /* From windows ACE entry. */ } canon_ace; #define ALL_ACE_PERMS (S_IRUSR|S_IWUSR|S_IXUSR) /* * EA format of user.SAMBA_PAI (Samba_Posix_Acl_Interitance) - * attribute on disk. + * attribute on disk - version 1. + * All values are little endian. * - * | 1 | 1 | 2 | 2 | .... + * | 1 | 1 | 2 | 2 | .... * +------+------+-------------+---------------------+-------------+--------------------+ * | vers | flag | num_entries | num_default_entries | ..entries.. | default_entries... | * +------+------+-------------+---------------------+-------------+--------------------+ + * + * Entry format is : + * + * | 1 | 4 | + * +------+-------------------+ + * | value| uid/gid or world | + * | type | value | + * +------+-------------------+ + * + * Version 2 format. Stores extra Windows metadata about an ACL. + * + * | 1 | 2 | 2 | 2 | .... + * +------+----------+-------------+---------------------+-------------+--------------------+ + * | vers | ace | num_entries | num_default_entries | ..entries.. | default_entries... | + * | 2 | type | | | | | + * +------+----------+-------------+---------------------+-------------+--------------------+ + * + * Entry format is : + * + * | 1 | 1 | 4 | + * +------+------+-------------------+ + * | ace | value| uid/gid or world | + * | flag | type | value | + * +------+-------------------+------+ + * */ -#define PAI_VERSION_OFFSET 0 -#define PAI_FLAG_OFFSET 1 -#define PAI_NUM_ENTRIES_OFFSET 2 -#define PAI_NUM_DEFAULT_ENTRIES_OFFSET 4 -#define PAI_ENTRIES_BASE 6 +#define PAI_VERSION_OFFSET 0 + +#define PAI_V1_FLAG_OFFSET 1 +#define PAI_V1_NUM_ENTRIES_OFFSET 2 +#define PAI_V1_NUM_DEFAULT_ENTRIES_OFFSET 4 +#define PAI_V1_ENTRIES_BASE 6 +#define PAI_V1_ACL_FLAG_PROTECTED 0x1 +#define PAI_V1_ENTRY_LENGTH 5 + +#define PAI_V1_VERSION 1 -#define PAI_VERSION 1 -#define PAI_ACL_FLAG_PROTECTED 0x1 -#define PAI_ENTRY_LENGTH 5 +#define PAI_V2_TYPE_OFFSET 1 +#define PAI_V2_NUM_ENTRIES_OFFSET 3 +#define PAI_V2_NUM_DEFAULT_ENTRIES_OFFSET 5 +#define PAI_V2_ENTRIES_BASE 7 +#define PAI_V2_ENTRY_LENGTH 6 + +#define PAI_V2_VERSION 2 /* * In memory format of user.SAMBA_PAI attribute. @@ -78,12 +113,13 @@ typedef struct canon_ace { struct pai_entry { struct pai_entry *next, *prev; + uint8_t ace_flags; enum ace_owner owner_type; posix_id unix_ug; }; struct pai_val { - bool pai_protected; + uint16_t sd_type; unsigned int num_entries; struct pai_entry *entry_list; unsigned int num_def_entries; @@ -94,19 +130,19 @@ struct pai_val { Return a uint32 of the pai_entry principal. ************************************************************************/ -static uint32 get_pai_entry_val(struct pai_entry *paie) +static uint32_t get_pai_entry_val(struct pai_entry *paie) { switch (paie->owner_type) { case UID_ACE: DEBUG(10,("get_pai_entry_val: uid = %u\n", (unsigned int)paie->unix_ug.uid )); - return (uint32)paie->unix_ug.uid; + return (uint32_t)paie->unix_ug.uid; case GID_ACE: DEBUG(10,("get_pai_entry_val: gid = %u\n", (unsigned int)paie->unix_ug.gid )); - return (uint32)paie->unix_ug.gid; + return (uint32_t)paie->unix_ug.gid; case WORLD_ACE: default: DEBUG(10,("get_pai_entry_val: world ace\n")); - return (uint32)-1; + return (uint32_t)-1; } } @@ -114,41 +150,30 @@ static uint32 get_pai_entry_val(struct pai_entry *paie) Return a uint32 of the entry principal. ************************************************************************/ -static uint32 get_entry_val(canon_ace *ace_entry) +static uint32_t get_entry_val(canon_ace *ace_entry) { switch (ace_entry->owner_type) { case UID_ACE: DEBUG(10,("get_entry_val: uid = %u\n", (unsigned int)ace_entry->unix_ug.uid )); - return (uint32)ace_entry->unix_ug.uid; + return (uint32_t)ace_entry->unix_ug.uid; case GID_ACE: DEBUG(10,("get_entry_val: gid = %u\n", (unsigned int)ace_entry->unix_ug.gid )); - return (uint32)ace_entry->unix_ug.gid; + return (uint32_t)ace_entry->unix_ug.gid; case WORLD_ACE: default: DEBUG(10,("get_entry_val: world ace\n")); - return (uint32)-1; + return (uint32_t)-1; } } /************************************************************************ - Count the inherited entries. -************************************************************************/ - -static unsigned int num_inherited_entries(canon_ace *ace_list) -{ - unsigned int num_entries = 0; - - for (; ace_list; ace_list = ace_list->next) - if (ace_list->inherited) - num_entries++; - return num_entries; -} - -/************************************************************************ - Create the on-disk format. Caller must free. + Create the on-disk format (always v2 now). Caller must free. ************************************************************************/ -static char *create_pai_buf(canon_ace *file_ace_list, canon_ace *dir_ace_list, bool pai_protected, size_t *store_size) +static char *create_pai_buf_v2(canon_ace *file_ace_list, + canon_ace *dir_ace_list, + uint16_t sd_type, + size_t *store_size) { char *pai_buf = NULL; canon_ace *ace_list = NULL; @@ -156,17 +181,18 @@ static char *create_pai_buf(canon_ace *file_ace_list, canon_ace *dir_ace_list, b unsigned int num_entries = 0; unsigned int num_def_entries = 0; - for (ace_list = file_ace_list; ace_list; ace_list = ace_list->next) - if (ace_list->inherited) - num_entries++; + for (ace_list = file_ace_list; ace_list; ace_list = ace_list->next) { + num_entries++; + } - for (ace_list = dir_ace_list; ace_list; ace_list = ace_list->next) - if (ace_list->inherited) - num_def_entries++; + for (ace_list = dir_ace_list; ace_list; ace_list = ace_list->next) { + num_def_entries++; + } - DEBUG(10,("create_pai_buf: num_entries = %u, num_def_entries = %u\n", num_entries, num_def_entries )); + DEBUG(10,("create_pai_buf_v2: num_entries = %u, num_def_entries = %u\n", num_entries, num_def_entries )); - *store_size = PAI_ENTRIES_BASE + ((num_entries + num_def_entries)*PAI_ENTRY_LENGTH); + *store_size = PAI_V2_ENTRIES_BASE + + ((num_entries + num_def_entries)*PAI_V2_ENTRY_LENGTH); pai_buf = (char *)SMB_MALLOC(*store_size); if (!pai_buf) { @@ -174,34 +200,32 @@ static char *create_pai_buf(canon_ace *file_ace_list, canon_ace *dir_ace_list, b } /* Set up the header. */ - memset(pai_buf, '\0', PAI_ENTRIES_BASE); - SCVAL(pai_buf,PAI_VERSION_OFFSET,PAI_VERSION); - SCVAL(pai_buf,PAI_FLAG_OFFSET,(pai_protected ? PAI_ACL_FLAG_PROTECTED : 0)); - SSVAL(pai_buf,PAI_NUM_ENTRIES_OFFSET,num_entries); - SSVAL(pai_buf,PAI_NUM_DEFAULT_ENTRIES_OFFSET,num_def_entries); + memset(pai_buf, '\0', PAI_V2_ENTRIES_BASE); + SCVAL(pai_buf,PAI_VERSION_OFFSET,PAI_V2_VERSION); + SSVAL(pai_buf,PAI_V2_TYPE_OFFSET, sd_type); + SSVAL(pai_buf,PAI_V2_NUM_ENTRIES_OFFSET,num_entries); + SSVAL(pai_buf,PAI_V2_NUM_DEFAULT_ENTRIES_OFFSET,num_def_entries); - entry_offset = pai_buf + PAI_ENTRIES_BASE; + entry_offset = pai_buf + PAI_V2_ENTRIES_BASE; for (ace_list = file_ace_list; ace_list; ace_list = ace_list->next) { - if (ace_list->inherited) { - uint8 type_val = (unsigned char)ace_list->owner_type; - uint32 entry_val = get_entry_val(ace_list); + uint8_t type_val = (uint8_t)ace_list->owner_type; + uint32_t entry_val = get_entry_val(ace_list); - SCVAL(entry_offset,0,type_val); - SIVAL(entry_offset,1,entry_val); - entry_offset += PAI_ENTRY_LENGTH; - } + SCVAL(entry_offset,0,ace_list->ace_flags); + SCVAL(entry_offset,1,type_val); + SIVAL(entry_offset,2,entry_val); + entry_offset += PAI_V2_ENTRY_LENGTH; } for (ace_list = dir_ace_list; ace_list; ace_list = ace_list->next) { - if (ace_list->inherited) { - uint8 type_val = (unsigned char)ace_list->owner_type; - uint32 entry_val = get_entry_val(ace_list); + uint8_t type_val = (uint8_t)ace_list->owner_type; + uint32_t entry_val = get_entry_val(ace_list); - SCVAL(entry_offset,0,type_val); - SIVAL(entry_offset,1,entry_val); - entry_offset += PAI_ENTRY_LENGTH; - } + SCVAL(entry_offset,0,ace_list->ace_flags); + SCVAL(entry_offset,1,type_val); + SIVAL(entry_offset,2,entry_val); + entry_offset += PAI_V2_ENTRY_LENGTH; } return pai_buf; @@ -211,44 +235,39 @@ static char *create_pai_buf(canon_ace *file_ace_list, canon_ace *dir_ace_list, b Store the user.SAMBA_PAI attribute on disk. ************************************************************************/ -static void store_inheritance_attributes(files_struct *fsp, canon_ace *file_ace_list, - canon_ace *dir_ace_list, bool pai_protected) +static void store_inheritance_attributes(files_struct *fsp, + canon_ace *file_ace_list, + canon_ace *dir_ace_list, + uint16_t sd_type) { int ret; size_t store_size; char *pai_buf; - if (!lp_map_acl_inherit(SNUM(fsp->conn))) - return; - - /* - * Don't store if this ACL isn't protected and - * none of the entries in it are marked as inherited. - */ - - if (!pai_protected && num_inherited_entries(file_ace_list) == 0 && num_inherited_entries(dir_ace_list) == 0) { - /* Instead just remove the attribute if it exists. */ - if (fsp->fh->fd != -1) - SMB_VFS_FREMOVEXATTR(fsp, SAMBA_POSIX_INHERITANCE_EA_NAME); - else - SMB_VFS_REMOVEXATTR(fsp->conn, fsp->fsp_name, SAMBA_POSIX_INHERITANCE_EA_NAME); + if (!lp_map_acl_inherit(SNUM(fsp->conn))) { return; } - pai_buf = create_pai_buf(file_ace_list, dir_ace_list, pai_protected, &store_size); + pai_buf = create_pai_buf_v2(file_ace_list, dir_ace_list, + sd_type, &store_size); - if (fsp->fh->fd != -1) + if (fsp->fh->fd != -1) { ret = SMB_VFS_FSETXATTR(fsp, SAMBA_POSIX_INHERITANCE_EA_NAME, pai_buf, store_size, 0); - else + } else { ret = SMB_VFS_SETXATTR(fsp->conn,fsp->fsp_name, SAMBA_POSIX_INHERITANCE_EA_NAME, pai_buf, store_size, 0); + } SAFE_FREE(pai_buf); - DEBUG(10,("store_inheritance_attribute:%s for file %s\n", pai_protected ? " (protected)" : "", fsp->fsp_name)); - if (ret == -1 && !no_acl_syscall_error(errno)) + DEBUG(10,("store_inheritance_attribute: type 0x%x for file %s\n", + (unsigned int)sd_type, + fsp->fsp_name)); + + if (ret == -1 && !no_acl_syscall_error(errno)) { DEBUG(1,("store_inheritance_attribute: Error %s\n", strerror(errno) )); + } } /************************************************************************ @@ -272,160 +291,289 @@ static void free_inherited_info(struct pai_val *pal) } /************************************************************************ - Was this ACL protected ? -************************************************************************/ - -static bool get_protected_flag(struct pai_val *pal) -{ - if (!pal) - return False; - return pal->pai_protected; -} - -/************************************************************************ - Was this ACE inherited ? + Get any stored ACE flags. ************************************************************************/ -static bool get_inherited_flag(struct pai_val *pal, canon_ace *ace_entry, bool default_ace) +static uint16_t get_pai_flags(struct pai_val *pal, canon_ace *ace_entry, bool default_ace) { struct pai_entry *paie; - if (!pal) - return False; + if (!pal) { + return 0; + } /* If the entry exists it is inherited. */ for (paie = (default_ace ? pal->def_entry_list : pal->entry_list); paie; paie = paie->next) { if (ace_entry->owner_type == paie->owner_type && get_entry_val(ace_entry) == get_pai_entry_val(paie)) - return True; + return paie->ace_flags; } - return False; + return 0; } /************************************************************************ - Ensure an attribute just read is valid. + Ensure an attribute just read is valid - v1. ************************************************************************/ -static bool check_pai_ok(char *pai_buf, size_t pai_buf_data_size) +static bool check_pai_ok_v1(const char *pai_buf, size_t pai_buf_data_size) { uint16 num_entries; uint16 num_def_entries; - if (pai_buf_data_size < PAI_ENTRIES_BASE) { + if (pai_buf_data_size < PAI_V1_ENTRIES_BASE) { /* Corrupted - too small. */ - return False; + return false; } - if (CVAL(pai_buf,PAI_VERSION_OFFSET) != PAI_VERSION) - return False; + if (CVAL(pai_buf,PAI_VERSION_OFFSET) != PAI_V1_VERSION) { + return false; + } - num_entries = SVAL(pai_buf,PAI_NUM_ENTRIES_OFFSET); - num_def_entries = SVAL(pai_buf,PAI_NUM_DEFAULT_ENTRIES_OFFSET); + num_entries = SVAL(pai_buf,PAI_V1_NUM_ENTRIES_OFFSET); + num_def_entries = SVAL(pai_buf,PAI_V1_NUM_DEFAULT_ENTRIES_OFFSET); /* Check the entry lists match. */ /* Each entry is 5 bytes (type plus 4 bytes of uid or gid). */ - if (((num_entries + num_def_entries)*PAI_ENTRY_LENGTH) + PAI_ENTRIES_BASE != pai_buf_data_size) - return False; + if (((num_entries + num_def_entries)*PAI_V1_ENTRY_LENGTH) + + PAI_V1_ENTRIES_BASE != pai_buf_data_size) { + return false; + } - return True; + return true; +} + +/************************************************************************ + Ensure an attribute just read is valid - v2. +************************************************************************/ + +static bool check_pai_ok_v2(const char *pai_buf, size_t pai_buf_data_size) +{ + uint16 num_entries; + uint16 num_def_entries; + + if (pai_buf_data_size < PAI_V2_ENTRIES_BASE) { + /* Corrupted - too small. */ + return false; + } + + if (CVAL(pai_buf,PAI_VERSION_OFFSET) != PAI_V2_VERSION) { + return false; + } + + num_entries = SVAL(pai_buf,PAI_V2_NUM_ENTRIES_OFFSET); + num_def_entries = SVAL(pai_buf,PAI_V2_NUM_DEFAULT_ENTRIES_OFFSET); + + /* Check the entry lists match. */ + /* Each entry is 6 bytes (flags + type + 4 bytes of uid or gid). */ + + if (((num_entries + num_def_entries)*PAI_V2_ENTRY_LENGTH) + + PAI_V2_ENTRIES_BASE != pai_buf_data_size) { + return false; + } + + return true; } +/************************************************************************ + Decode the owner. +************************************************************************/ + +static bool get_pai_owner_type(struct pai_entry *paie, const char *entry_offset) +{ + paie->owner_type = (enum ace_owner)CVAL(entry_offset,0); + switch( paie->owner_type) { + case UID_ACE: + paie->unix_ug.uid = (uid_t)IVAL(entry_offset,1); + DEBUG(10,("get_pai_owner_type: uid = %u\n", + (unsigned int)paie->unix_ug.uid )); + break; + case GID_ACE: + paie->unix_ug.gid = (gid_t)IVAL(entry_offset,1); + DEBUG(10,("get_pai_owner_type: gid = %u\n", + (unsigned int)paie->unix_ug.gid )); + break; + case WORLD_ACE: + paie->unix_ug.world = -1; + DEBUG(10,("get_pai_owner_type: world ace\n")); + break; + default: + return false; + } + return true; +} /************************************************************************ - Convert to in-memory format. + Process v2 entries. ************************************************************************/ -static struct pai_val *create_pai_val(char *buf, size_t size) +static const char *create_pai_v1_entries(struct pai_val *paiv, + const char *entry_offset, + bool def_entry) { - char *entry_offset; - struct pai_val *paiv = NULL; int i; - if (!check_pai_ok(buf, size)) + for (i = 0; i < paiv->num_entries; i++) { + struct pai_entry *paie = SMB_MALLOC_P(struct pai_entry); + if (!paie) { + return NULL; + } + + paie->ace_flags = SEC_ACE_FLAG_INHERITED_ACE; + if (!get_pai_owner_type(paie, entry_offset)) { + return NULL; + } + + if (!def_entry) { + DLIST_ADD(paiv->entry_list, paie); + } else { + DLIST_ADD(paiv->def_entry_list, paie); + } + entry_offset += PAI_V1_ENTRY_LENGTH; + } + return entry_offset; +} + +/************************************************************************ + Convert to in-memory format from version 1. +************************************************************************/ + +static struct pai_val *create_pai_val_v1(const char *buf, size_t size) +{ + const char *entry_offset; + struct pai_val *paiv = NULL; + + if (!check_pai_ok_v1(buf, size)) { return NULL; + } paiv = SMB_MALLOC_P(struct pai_val); - if (!paiv) + if (!paiv) { return NULL; + } memset(paiv, '\0', sizeof(struct pai_val)); - paiv->pai_protected = (CVAL(buf,PAI_FLAG_OFFSET) == PAI_ACL_FLAG_PROTECTED); + paiv->sd_type = (CVAL(buf,PAI_V1_FLAG_OFFSET) == PAI_V1_ACL_FLAG_PROTECTED) ? + SE_DESC_DACL_PROTECTED : 0; - paiv->num_entries = SVAL(buf,PAI_NUM_ENTRIES_OFFSET); - paiv->num_def_entries = SVAL(buf,PAI_NUM_DEFAULT_ENTRIES_OFFSET); + paiv->num_entries = SVAL(buf,PAI_V1_NUM_ENTRIES_OFFSET); + paiv->num_def_entries = SVAL(buf,PAI_V1_NUM_DEFAULT_ENTRIES_OFFSET); - entry_offset = buf + PAI_ENTRIES_BASE; + entry_offset = buf + PAI_V1_ENTRIES_BASE; - DEBUG(10,("create_pai_val:%s num_entries = %u, num_def_entries = %u\n", - paiv->pai_protected ? " (pai_protected)" : "", paiv->num_entries, paiv->num_def_entries )); + DEBUG(10,("create_pai_val: num_entries = %u, num_def_entries = %u\n", + paiv->num_entries, paiv->num_def_entries )); - for (i = 0; i < paiv->num_entries; i++) { - struct pai_entry *paie; + entry_offset = create_pai_v1_entries(paiv, entry_offset, false); + if (entry_offset == NULL) { + free_inherited_info(paiv); + return NULL; + } + entry_offset = create_pai_v1_entries(paiv, entry_offset, true); + if (entry_offset == NULL) { + free_inherited_info(paiv); + return NULL; + } + + return paiv; +} + +/************************************************************************ + Process v2 entries. +************************************************************************/ + +static const char *create_pai_v2_entries(struct pai_val *paiv, + const char *entry_offset, + bool def_entry) +{ + int i; - paie = SMB_MALLOC_P(struct pai_entry); + for (i = 0; i < paiv->num_entries; i++) { + struct pai_entry *paie = SMB_MALLOC_P(struct pai_entry); if (!paie) { - free_inherited_info(paiv); return NULL; } - paie->owner_type = (enum ace_owner)CVAL(entry_offset,0); - switch( paie->owner_type) { - case UID_ACE: - paie->unix_ug.uid = (uid_t)IVAL(entry_offset,1); - DEBUG(10,("create_pai_val: uid = %u\n", (unsigned int)paie->unix_ug.uid )); - break; - case GID_ACE: - paie->unix_ug.gid = (gid_t)IVAL(entry_offset,1); - DEBUG(10,("create_pai_val: gid = %u\n", (unsigned int)paie->unix_ug.gid )); - break; - case WORLD_ACE: - paie->unix_ug.world = -1; - DEBUG(10,("create_pai_val: world ace\n")); - break; - default: - free_inherited_info(paiv); - return NULL; - } - entry_offset += PAI_ENTRY_LENGTH; - DLIST_ADD(paiv->entry_list, paie); - } + paie->ace_flags = CVAL(entry_offset,0); - for (i = 0; i < paiv->num_def_entries; i++) { - struct pai_entry *paie; + entry_offset++; - paie = SMB_MALLOC_P(struct pai_entry); - if (!paie) { - free_inherited_info(paiv); + if (!get_pai_owner_type(paie, entry_offset)) { return NULL; } - - paie->owner_type = (enum ace_owner)CVAL(entry_offset,0); - switch( paie->owner_type) { - case UID_ACE: - paie->unix_ug.uid = (uid_t)IVAL(entry_offset,1); - DEBUG(10,("create_pai_val: (def) uid = %u\n", (unsigned int)paie->unix_ug.uid )); - break; - case GID_ACE: - paie->unix_ug.gid = (gid_t)IVAL(entry_offset,1); - DEBUG(10,("create_pai_val: (def) gid = %u\n", (unsigned int)paie->unix_ug.gid )); - break; - case WORLD_ACE: - paie->unix_ug.world = -1; - DEBUG(10,("create_pai_val: (def) world ace\n")); - break; - default: - free_inherited_info(paiv); - return NULL; + if (!def_entry) { + DLIST_ADD(paiv->entry_list, paie); + } else { + DLIST_ADD(paiv->def_entry_list, paie); } - entry_offset += PAI_ENTRY_LENGTH; - DLIST_ADD(paiv->def_entry_list, paie); + entry_offset += PAI_V2_ENTRY_LENGTH; + } + return entry_offset; +} + +/************************************************************************ + Convert to in-memory format from version 2. +************************************************************************/ + +static struct pai_val *create_pai_val_v2(const char *buf, size_t size) +{ + const char *entry_offset; + struct pai_val *paiv = NULL; + + if (!check_pai_ok_v2(buf, size)) { + return NULL; + } + + paiv = SMB_MALLOC_P(struct pai_val); + if (!paiv) { + return NULL; + } + + memset(paiv, '\0', sizeof(struct pai_val)); + + paiv->sd_type = SVAL(buf,PAI_V2_TYPE_OFFSET); + + paiv->num_entries = SVAL(buf,PAI_V2_NUM_ENTRIES_OFFSET); + paiv->num_def_entries = SVAL(buf,PAI_V2_NUM_DEFAULT_ENTRIES_OFFSET); + + entry_offset = buf + PAI_V2_ENTRIES_BASE; + + DEBUG(10,("create_pai_val_v2: num_entries = %u, num_def_entries = %u\n", + paiv->num_entries, paiv->num_def_entries )); + + entry_offset = create_pai_v2_entries(paiv, entry_offset, false); + if (entry_offset == NULL) { + free_inherited_info(paiv); + return NULL; + } + entry_offset = create_pai_v2_entries(paiv, entry_offset, true); + if (entry_offset == NULL) { + free_inherited_info(paiv); + return NULL; } return paiv; } +/************************************************************************ + Convert to in-memory format - from either version 1 or 2. +************************************************************************/ + +static struct pai_val *create_pai_val(const char *buf, size_t size) +{ + if (size < 1) { + return NULL; + } + if (CVAL(buf,PAI_VERSION_OFFSET) == PAI_V1_VERSION) { + return create_pai_val_v1(buf, size); + } else if (CVAL(buf,PAI_VERSION_OFFSET) == PAI_V2_VERSION) { + return create_pai_val_v2(buf, size); + } else { + return NULL; + } +} + /************************************************************************ Load the user.SAMBA_PAI attribute. ************************************************************************/ @@ -437,19 +585,22 @@ static struct pai_val *fload_inherited_info(files_struct *fsp) struct pai_val *paiv = NULL; ssize_t ret; - if (!lp_map_acl_inherit(SNUM(fsp->conn))) + if (!lp_map_acl_inherit(SNUM(fsp->conn))) { return NULL; + } - if ((pai_buf = (char *)SMB_MALLOC(pai_buf_size)) == NULL) + if ((pai_buf = (char *)SMB_MALLOC(pai_buf_size)) == NULL) { return NULL; + } do { - if (fsp->fh->fd != -1) + if (fsp->fh->fd != -1) { ret = SMB_VFS_FGETXATTR(fsp, SAMBA_POSIX_INHERITANCE_EA_NAME, pai_buf, pai_buf_size); - else + } else { ret = SMB_VFS_GETXATTR(fsp->conn,fsp->fsp_name,SAMBA_POSIX_INHERITANCE_EA_NAME, pai_buf, pai_buf_size); + } if (ret == -1) { if (errno != ERANGE) { @@ -483,8 +634,11 @@ static struct pai_val *fload_inherited_info(files_struct *fsp) paiv = create_pai_val(pai_buf, ret); - if (paiv && paiv->pai_protected) - DEBUG(10,("load_inherited_info: ACL is protected for file %s\n", fsp->fsp_name)); + if (paiv) { + DEBUG(10,("load_inherited_info: ACL type is 0x%x for file %s\n", + (unsigned int)paiv->sd_type, + fsp->fsp_name)); + } SAFE_FREE(pai_buf); return paiv; @@ -547,8 +701,10 @@ static struct pai_val *load_inherited_info(const struct connection_struct *conn, paiv = create_pai_val(pai_buf, ret); - if (paiv && paiv->pai_protected) { - DEBUG(10,("load_inherited_info: ACL is protected for file %s\n", fname)); + if (paiv) { + DEBUG(10,("load_inherited_info: ACL type 0x%x for file %s\n", + (unsigned int)paiv->sd_type, + fname)); } SAFE_FREE(pai_buf); @@ -641,8 +797,8 @@ static void print_canon_ace(canon_ace *pace, int num) dbgtext( "MASK " ); break; } - if (pace->inherited) - dbgtext( "(inherited) "); + + dbgtext( "ace_flags = 0x%x ", (unsigned int)pace->ace_flags); dbgtext( "perms "); dbgtext( "%c", pace->perms & S_IRUSR ? 'r' : '-'); dbgtext( "%c", pace->perms & S_IWUSR ? 'w' : '-'); @@ -1519,7 +1675,9 @@ static bool create_canon_ace_lists(files_struct *fsp, current_ace->perms |= map_nt_perms( &psa->access_mask, S_IRUSR); current_ace->attr = (psa->type == SEC_ACE_TYPE_ACCESS_ALLOWED) ? ALLOW_ACE : DENY_ACE; - current_ace->inherited = ((psa->flags & SEC_ACE_FLAG_INHERITED_ACE) ? True : False); + + /* Store the ace_flag. */ + current_ace->ace_flags = psa->flags; /* * Now add the created ace to either the file list, the directory @@ -2160,7 +2318,7 @@ static void arrange_posix_perms(const char *filename, canon_ace **pp_list_head) other_ace = ace; } } - + if (!owner_ace || !other_ace) { DEBUG(0,("arrange_posix_perms: Invalid POSIX permissions for file %s, missing owner or other.\n", filename )); @@ -2184,7 +2342,7 @@ static void arrange_posix_perms(const char *filename, canon_ace **pp_list_head) *pp_list_head = list_head; } - + /**************************************************************************** Create a linked list of canonical ACE entries. ****************************************************************************/ @@ -2297,7 +2455,7 @@ static canon_ace *canonicalise_acl(struct connection_struct *conn, ace->trustee = sid; ace->unix_ug = unix_ug; ace->owner_type = owner_type; - ace->inherited = get_inherited_flag(pal, ace, (the_acl_type == SMB_ACL_TYPE_DEFAULT)); + ace->ace_flags = get_pai_flags(pal, ace, (the_acl_type == SMB_ACL_TYPE_DEFAULT)); DLIST_ADD(list_head, ace); } @@ -2968,8 +3126,7 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn, &ace->trustee, nt_acl_type, acc, - ace->inherited ? - SEC_ACE_FLAG_INHERITED_ACE : 0); + ace->ace_flags); } /* The User must have access to a profile share - even @@ -2990,11 +3147,10 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn, &ace->trustee, nt_acl_type, acc, + ace->ace_flags | SEC_ACE_FLAG_OBJECT_INHERIT| SEC_ACE_FLAG_CONTAINER_INHERIT| - SEC_ACE_FLAG_INHERIT_ONLY| - (ace->inherited ? - SEC_ACE_FLAG_INHERITED_ACE : 0)); + SEC_ACE_FLAG_INHERIT_ONLY); } /* The User must have access to a profile share - even @@ -3045,8 +3201,10 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn, * flag doesn't seem to bother Windows NT. * Always set this if map acl inherit is turned off. */ - if (get_protected_flag(pal) || !lp_map_acl_inherit(SNUM(conn))) { - psd->type |= SE_DESC_DACL_PROTECTED; + if (pal == NULL || !lp_map_acl_inherit(SNUM(conn))) { + psd->type |= SEC_DESC_DACL_PROTECTED; + } else { + psd->type |= pal->sd_type; } if (psd->dacl) { @@ -3236,7 +3394,7 @@ NTSTATUS append_parent_acl(files_struct *fsp, int info; unsigned int i, j; SEC_DESC *psd = dup_sec_desc(talloc_tos(), pcsd); - bool is_dacl_protected = (pcsd->type & SE_DESC_DACL_PROTECTED); + bool is_dacl_protected = (pcsd->type & SEC_DESC_DACL_PROTECTED); ZERO_STRUCT(sbuf); @@ -3617,8 +3775,10 @@ NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const SEC_DESC if (set_acl_as_root) { become_root(); } - store_inheritance_attributes(fsp, file_ace_list, dir_ace_list, - (psd->type & SE_DESC_DACL_PROTECTED) ? True : False); + store_inheritance_attributes(fsp, + file_ace_list, + dir_ace_list, + psd->type); if (set_acl_as_root) { unbecome_root(); } -- cgit From 77bac5b78c10d816e02a8a407b0a4653d72868a0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Jan 2009 17:16:34 -0800 Subject: Fix coverity CID#66. Resource leak in error path. Jeremy. --- lib/util/xfile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/util/xfile.c b/lib/util/xfile.c index cf195706db..16499e1736 100644 --- a/lib/util/xfile.c +++ b/lib/util/xfile.c @@ -112,6 +112,7 @@ XFILE *x_fopen(const char *fname, int flags, mode_t mode) if ((flags & O_ACCMODE) == O_RDWR) { /* we don't support RDWR in XFILE - use file descriptors instead */ + SAFE_FREE(ret); errno = EINVAL; return NULL; } -- cgit From 734647bd85560ed02691d79c0a613543043d8625 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Jan 2009 17:27:47 -0800 Subject: Fix coverity CID#115. Resource leak in error path. Jeremy. --- source3/libnet/libnet_samsync_ldif.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source3/libnet/libnet_samsync_ldif.c b/source3/libnet/libnet_samsync_ldif.c index 3068f8d3eb..4286331893 100644 --- a/source3/libnet/libnet_samsync_ldif.c +++ b/source3/libnet/libnet_samsync_ldif.c @@ -776,7 +776,10 @@ static NTSTATUS fetch_alias_info_to_ldif(TALLOC_CTX *mem_ctx, g_rid = r->rid; groupmap->gidNumber = ldif_gid; groupmap->sambaSID = talloc_asprintf(mem_ctx, "%s-%d", sid, g_rid); - NT_STATUS_HAVE_NO_MEMORY(groupmap->sambaSID); + if (groupmap->sambaSID == NULL) { + SAFE_FREE(group_attr); + return NT_STATUS_NO_MEMORY; + } /* Write the data to the temporary add ldif file */ fprintf(add_fd, "# %s, %s, %s\n", aliasname, group_attr, -- cgit From 08802db8dbbbf842b7c006e5ff57ba1c2d0d6439 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Jan 2009 17:31:12 -0800 Subject: Fix coverity CID#116. Resource leak on error path. Jeremy. --- source3/libnet/libnet_samsync_ldif.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source3/libnet/libnet_samsync_ldif.c b/source3/libnet/libnet_samsync_ldif.c index 4286331893..cee0e17e37 100644 --- a/source3/libnet/libnet_samsync_ldif.c +++ b/source3/libnet/libnet_samsync_ldif.c @@ -542,8 +542,10 @@ static NTSTATUS fetch_group_info_to_ldif(TALLOC_CTX *mem_ctx, groupmap->sambaSID = talloc_asprintf(mem_ctx, "%s-%d", sid, g_rid); groupmap->group_dn = talloc_asprintf(mem_ctx, "cn=%s,ou=%s,%s", groupname, group_attr, suffix); - NT_STATUS_HAVE_NO_MEMORY(groupmap->sambaSID); - NT_STATUS_HAVE_NO_MEMORY(groupmap->group_dn); + if (groupmap->sambaSID == NULL || groupmap->group_dn == NULL) { + SAFE_FREE(group_attr); + return NT_STATUS_NO_MEMORY; + } /* Write the data to the temporary add ldif file */ fprintf(add_fd, "# %s, %s, %s\n", groupname, group_attr, -- cgit From a5f0640bf99e6f7e38b0b1e7a7a56f8f58ec7e47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Jan 2009 17:56:40 -0800 Subject: Fix coverity CID#117 - resource leak in error path. Jeremy. --- source3/libnet/libnet_samsync_ldif.c | 77 +++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 24 deletions(-) diff --git a/source3/libnet/libnet_samsync_ldif.c b/source3/libnet/libnet_samsync_ldif.c index cee0e17e37..dc3bc75541 100644 --- a/source3/libnet/libnet_samsync_ldif.c +++ b/source3/libnet/libnet_samsync_ldif.c @@ -345,100 +345,129 @@ static NTSTATUS map_populate_groups(TALLOC_CTX *mem_ctx, groupmap[0].sambaSID = talloc_asprintf(mem_ctx, "%s-512", sid); groupmap[0].group_dn = talloc_asprintf(mem_ctx, "cn=Domain Admins,ou=%s,%s", group_attr, suffix); - NT_STATUS_HAVE_NO_MEMORY(groupmap[0].sambaSID); - NT_STATUS_HAVE_NO_MEMORY(groupmap[0].group_dn); + if (groupmap[0].sambaSID == NULL || groupmap[0].group_dn == NULL) { + goto err; + } accountmap[0].rid = 512; accountmap[0].cn = talloc_strdup(mem_ctx, "Domain Admins"); - NT_STATUS_HAVE_NO_MEMORY(accountmap[0].cn); + if (accountmap[0].cn == NULL) { + goto err; + } groupmap[1].rid = 513; groupmap[1].gidNumber = 513; groupmap[1].sambaSID = talloc_asprintf(mem_ctx, "%s-513", sid); groupmap[1].group_dn = talloc_asprintf(mem_ctx, "cn=Domain Users,ou=%s,%s", group_attr, suffix); - NT_STATUS_HAVE_NO_MEMORY(groupmap[1].sambaSID); - NT_STATUS_HAVE_NO_MEMORY(groupmap[1].group_dn); + if (groupmap[1].sambaSID == NULL || groupmap[1].group_dn == NULL) { + goto err; + } accountmap[1].rid = 513; accountmap[1].cn = talloc_strdup(mem_ctx, "Domain Users"); - NT_STATUS_HAVE_NO_MEMORY(accountmap[1].cn); + if (accountmap[1].cn == NULL) { + goto err; + } groupmap[2].rid = 514; groupmap[2].gidNumber = 514; groupmap[2].sambaSID = talloc_asprintf(mem_ctx, "%s-514", sid); groupmap[2].group_dn = talloc_asprintf(mem_ctx, "cn=Domain Guests,ou=%s,%s", group_attr, suffix); - NT_STATUS_HAVE_NO_MEMORY(groupmap[2].sambaSID); - NT_STATUS_HAVE_NO_MEMORY(groupmap[2].group_dn); + if (groupmap[2].sambaSID == NULL || groupmap[2].group_dn == NULL) { + goto err; + } accountmap[2].rid = 514; accountmap[2].cn = talloc_strdup(mem_ctx, "Domain Guests"); - NT_STATUS_HAVE_NO_MEMORY(accountmap[2].cn); + if (accountmap[2].cn == NULL) { + goto err; + } groupmap[3].rid = 515; groupmap[3].gidNumber = 515; groupmap[3].sambaSID = talloc_asprintf(mem_ctx, "%s-515", sid); groupmap[3].group_dn = talloc_asprintf(mem_ctx, "cn=Domain Computers,ou=%s,%s", group_attr, suffix); - NT_STATUS_HAVE_NO_MEMORY(groupmap[3].sambaSID); - NT_STATUS_HAVE_NO_MEMORY(groupmap[3].group_dn); + if (groupmap[3].sambaSID == NULL || groupmap[3].group_dn == NULL) { + goto err; + } accountmap[3].rid = 515; accountmap[3].cn = talloc_strdup(mem_ctx, "Domain Computers"); - NT_STATUS_HAVE_NO_MEMORY(accountmap[3].cn); + if (accountmap[3].cn == NULL) { + goto err; + } groupmap[4].rid = 544; groupmap[4].gidNumber = 544; groupmap[4].sambaSID = talloc_asprintf(mem_ctx, "%s-544", builtin_sid); groupmap[4].group_dn = talloc_asprintf(mem_ctx, "cn=Administrators,ou=%s,%s", group_attr, suffix); - NT_STATUS_HAVE_NO_MEMORY(groupmap[4].sambaSID); - NT_STATUS_HAVE_NO_MEMORY(groupmap[4].group_dn); + if (groupmap[4].sambaSID == NULL || groupmap[4].group_dn == NULL) { + goto err; + } accountmap[4].rid = 515; accountmap[4].cn = talloc_strdup(mem_ctx, "Administrators"); - NT_STATUS_HAVE_NO_MEMORY(accountmap[4].cn); + if (accountmap[4].cn == NULL) { + goto err; + } groupmap[5].rid = 550; groupmap[5].gidNumber = 550; groupmap[5].sambaSID = talloc_asprintf(mem_ctx, "%s-550", builtin_sid); groupmap[5].group_dn = talloc_asprintf(mem_ctx, "cn=Print Operators,ou=%s,%s", group_attr, suffix); - NT_STATUS_HAVE_NO_MEMORY(groupmap[5].sambaSID); - NT_STATUS_HAVE_NO_MEMORY(groupmap[5].group_dn); + if (groupmap[5].sambaSID == NULL || groupmap[5].group_dn == NULL) { + goto err; + } accountmap[5].rid = 550; accountmap[5].cn = talloc_strdup(mem_ctx, "Print Operators"); - NT_STATUS_HAVE_NO_MEMORY(accountmap[5].cn); + if (accountmap[5].cn == NULL) { + goto err; + } groupmap[6].rid = 551; groupmap[6].gidNumber = 551; groupmap[6].sambaSID = talloc_asprintf(mem_ctx, "%s-551", builtin_sid); groupmap[6].group_dn = talloc_asprintf(mem_ctx, "cn=Backup Operators,ou=%s,%s", group_attr, suffix); - NT_STATUS_HAVE_NO_MEMORY(groupmap[6].sambaSID); - NT_STATUS_HAVE_NO_MEMORY(groupmap[6].group_dn); + if (groupmap[6].sambaSID == NULL || groupmap[6].group_dn == NULL) { + goto err; + } accountmap[6].rid = 551; accountmap[6].cn = talloc_strdup(mem_ctx, "Backup Operators"); - NT_STATUS_HAVE_NO_MEMORY(accountmap[6].cn); + if (accountmap[6].cn == NULL) { + goto err; + } groupmap[7].rid = 552; groupmap[7].gidNumber = 552; groupmap[7].sambaSID = talloc_asprintf(mem_ctx, "%s-552", builtin_sid); groupmap[7].group_dn = talloc_asprintf(mem_ctx, "cn=Replicators,ou=%s,%s", group_attr, suffix); - NT_STATUS_HAVE_NO_MEMORY(groupmap[7].sambaSID); - NT_STATUS_HAVE_NO_MEMORY(groupmap[7].group_dn); + if (groupmap[7].sambaSID == NULL || groupmap[7].group_dn == NULL) { + goto err; + } accountmap[7].rid = 551; accountmap[7].cn = talloc_strdup(mem_ctx, "Replicators"); - NT_STATUS_HAVE_NO_MEMORY(accountmap[7].cn); + if (accountmap[7].cn == NULL) { + goto err; + } SAFE_FREE(group_attr); return NT_STATUS_OK; + + err: + + SAFE_FREE(group_attr); + return NT_STATUS_NO_MEMORY; } /* -- cgit From 380874ef863866c94c999ef53252b9d30df65e88 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 29 Jan 2009 18:39:30 -0500 Subject: Fix the mess with ldb includes. Separate again the public from the private headers. Add a new header specific for modules. Also add service function for modules as now ldb_context and ldb_module are opaque structures for them. --- source4/dsdb/repl/drepl_periodic.c | 2 +- source4/dsdb/samdb/ldb_modules/anr.c | 41 +++--- source4/dsdb/samdb/ldb_modules/config.mk | 2 +- source4/dsdb/samdb/ldb_modules/instancetype.c | 23 ++-- source4/dsdb/samdb/ldb_modules/objectguid.c | 22 ++-- source4/dsdb/samdb/ldb_modules/partition.c | 2 +- source4/dsdb/samdb/ldb_modules/ranged_results.c | 27 ++-- source4/dsdb/samdb/ldb_modules/subtree_delete.c | 16 ++- source4/dsdb/samdb/ldb_modules/subtree_rename.c | 21 +++- source4/dsdb/samdb/ldb_modules/update_keytab.c | 67 ++++++---- source4/lib/ldb-samba/ldif_handlers.c | 2 +- source4/lib/ldb/common/attrib_handlers.c | 2 +- source4/lib/ldb/common/ldb.c | 17 ++- source4/lib/ldb/common/ldb_attributes.c | 2 +- source4/lib/ldb/common/ldb_controls.c | 2 +- source4/lib/ldb/common/ldb_debug.c | 2 +- source4/lib/ldb/common/ldb_dn.c | 2 +- source4/lib/ldb/common/ldb_ldif.c | 2 +- source4/lib/ldb/common/ldb_match.c | 2 +- source4/lib/ldb/common/ldb_modules.c | 37 +++++- source4/lib/ldb/common/ldb_msg.c | 2 +- source4/lib/ldb/common/ldb_parse.c | 2 +- source4/lib/ldb/common/ldb_utf8.c | 2 +- source4/lib/ldb/common/qsort.c | 2 +- source4/lib/ldb/examples/ldbreader.c | 2 - source4/lib/ldb/examples/ldifreader.c | 2 - source4/lib/ldb/include/dlinklist.h | 4 + source4/lib/ldb/include/ldb.h | 6 +- source4/lib/ldb/include/ldb_includes.h | 2 - source4/lib/ldb/include/ldb_module.h | 160 ++++++++++++++++++++++++ source4/lib/ldb/include/ldb_private.h | 105 +--------------- source4/lib/ldb/ldb_ildap/ldb_ildap.c | 62 +++++---- source4/lib/ldb/ldb_ldap/ldb_ldap.c | 110 +++++++++------- source4/lib/ldb/ldb_map/ldb_map.c | 83 ++++++++---- source4/lib/ldb/ldb_map/ldb_map_inbound.c | 72 ++++++++--- source4/lib/ldb/ldb_map/ldb_map_outbound.c | 33 +++-- source4/lib/ldb/ldb_map/ldb_map_private.h | 2 +- source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c | 2 +- source4/lib/ldb/ldb_tdb/ldb_cache.c | 59 ++++++--- source4/lib/ldb/ldb_tdb/ldb_index.c | 100 +++++++++------ source4/lib/ldb/ldb_tdb/ldb_pack.c | 8 +- source4/lib/ldb/ldb_tdb/ldb_search.c | 39 +++--- source4/lib/ldb/ldb_tdb/ldb_tdb.c | 129 ++++++++++--------- source4/lib/ldb/ldb_tdb/ldb_tdb.h | 2 + source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c | 2 - source4/lib/ldb/modules/asq.c | 36 ++++-- source4/lib/ldb/modules/operational.c | 12 +- source4/lib/ldb/modules/paged_results.c | 19 ++- source4/lib/ldb/modules/paged_searches.c | 27 ++-- source4/lib/ldb/modules/rdn_name.c | 26 ++-- source4/lib/ldb/modules/skel.c | 15 ++- source4/lib/ldb/modules/sort.c | 32 +++-- source4/lib/ldb/pyldb.c | 2 +- source4/lib/ldb/tests/sample_module.c | 4 +- source4/lib/ldb/tools/cmdline.c | 8 +- source4/lib/ldb/tools/ldbadd.c | 2 +- source4/lib/ldb/tools/ldbdel.c | 2 +- source4/lib/ldb/tools/ldbedit.c | 2 +- source4/lib/ldb/tools/ldbmodify.c | 2 +- source4/lib/ldb/tools/ldbrename.c | 2 +- source4/lib/ldb/tools/ldbsearch.c | 2 +- source4/lib/ldb/tools/ldbtest.c | 2 +- source4/libcli/ldap/config.mk | 2 +- source4/libcli/ldap/ldap.h | 43 +------ source4/libcli/ldap/ldap_errors.h | 66 ++++++++++ source4/libcli/security/security_token.c | 1 - source4/libcli/util/nterr.c | 2 +- source4/nbt_server/config.mk | 2 +- source4/nbt_server/wins/wins_ldb.c | 1 + source4/ntvfs/ipc/rap_server.c | 1 + source4/ntvfs/posix/vfs_posix.c | 1 - source4/ntvfs/posix/vfs_posix.h | 2 +- source4/rpc_server/config.mk | 1 + source4/smb_server/smb_samba3.c | 1 - source4/utils/ad2oLschema.c | 2 +- source4/utils/net/net_machinepw.c | 2 +- source4/utils/oLschema2ldif.c | 2 +- 77 files changed, 1031 insertions(+), 578 deletions(-) create mode 100644 source4/lib/ldb/include/ldb_module.h create mode 100644 source4/libcli/ldap/ldap_errors.h diff --git a/source4/dsdb/repl/drepl_periodic.c b/source4/dsdb/repl/drepl_periodic.c index 4a6de8d700..b88d2cee1e 100644 --- a/source4/dsdb/repl/drepl_periodic.c +++ b/source4/dsdb/repl/drepl_periodic.c @@ -20,10 +20,10 @@ */ #include "includes.h" +#include "lib/events/events.h" #include "dsdb/samdb/samdb.h" #include "auth/auth.h" #include "smbd/service.h" -#include "lib/events/events.h" #include "lib/messaging/irpc.h" #include "dsdb/repl/drepl_service.h" #include "lib/ldb/include/ldb_errors.h" diff --git a/source4/dsdb/samdb/ldb_modules/anr.c b/source4/dsdb/samdb/ldb_modules/anr.c index 49e453ffa1..a04f5ebfa6 100644 --- a/source4/dsdb/samdb/ldb_modules/anr.c +++ b/source4/dsdb/samdb/ldb_modules/anr.c @@ -30,7 +30,7 @@ */ #include "includes.h" -#include "ldb_includes.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" /** @@ -40,11 +40,14 @@ static struct ldb_parse_tree *make_parse_list(struct ldb_module *module, TALLOC_CTX *mem_ctx, enum ldb_parse_op op, struct ldb_parse_tree *first_arm, struct ldb_parse_tree *second_arm) { + struct ldb_context *ldb; struct ldb_parse_tree *list; + ldb = ldb_module_get_ctx(module); + list = talloc(mem_ctx, struct ldb_parse_tree); if (list == NULL){ - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } list->operation = op; @@ -52,7 +55,7 @@ static struct ldb_parse_tree *make_parse_list(struct ldb_module *module, list->u.list.num_elements = 2; list->u.list.elements = talloc_array(list, struct ldb_parse_tree *, 2); if (!list->u.list.elements) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } list->u.list.elements[0] = talloc_steal(list, first_arm); @@ -67,8 +70,11 @@ static struct ldb_parse_tree *make_match_tree(struct ldb_module *module, TALLOC_CTX *mem_ctx, enum ldb_parse_op op, const char *attr, const DATA_BLOB *match) { + struct ldb_context *ldb; struct ldb_parse_tree *match_tree; + ldb = ldb_module_get_ctx(module); + match_tree = talloc(mem_ctx, struct ldb_parse_tree); /* Depending on what type of match was selected, fill in the right part of the union */ @@ -83,7 +89,7 @@ static struct ldb_parse_tree *make_match_tree(struct ldb_module *module, match_tree->u.substring.chunks = talloc_array(match_tree, struct ldb_val *, 2); if (match_tree->u.substring.chunks == NULL){ - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } match_tree->u.substring.chunks[0] = match; @@ -120,12 +126,16 @@ static int anr_replace_value(struct anr_context *ac, struct ldb_module *module = ac->module; struct ldb_parse_tree *match_tree; struct dsdb_attribute *cur; - const struct dsdb_schema *schema = dsdb_get_schema(module->ldb); + const struct dsdb_schema *schema; + struct ldb_context *ldb; uint8_t *p; enum ldb_parse_op op; + ldb = ldb_module_get_ctx(module); + + schema = dsdb_get_schema(ldb); if (!schema) { - ldb_asprintf_errstring(module->ldb, "no schema with which to construct anr filter"); + ldb_asprintf_errstring(ldb, "no schema with which to construct anr filter"); return LDB_ERR_OPERATIONS_ERROR; } @@ -135,7 +145,7 @@ static int anr_replace_value(struct anr_context *ac, DATA_BLOB *match2 = talloc(mem_ctx, DATA_BLOB); *match2 = data_blob_const(match->data+1, match->length - 1); if (match2 == NULL){ - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } match = match2; @@ -151,7 +161,7 @@ static int anr_replace_value(struct anr_context *ac, /* Inject an 'or' with the current tree */ tree = make_parse_list(module, mem_ctx, LDB_OP_OR, tree, match_tree); if (tree == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } } else { @@ -170,7 +180,7 @@ static int anr_replace_value(struct anr_context *ac, DATA_BLOB *first_match = talloc(tree, DATA_BLOB); DATA_BLOB *second_match = talloc(tree, DATA_BLOB); if (!first_match || !second_match) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } *first_match = data_blob_const(match->data, p-match->data); @@ -183,7 +193,7 @@ static int anr_replace_value(struct anr_context *ac, first_split_filter = make_parse_list(module, ac, LDB_OP_AND, match_tree_1, match_tree_2); if (first_split_filter == NULL){ - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -192,14 +202,14 @@ static int anr_replace_value(struct anr_context *ac, second_split_filter = make_parse_list(module, ac, LDB_OP_AND, match_tree_1, match_tree_2); if (second_split_filter == NULL){ - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } split_filters = make_parse_list(module, mem_ctx, LDB_OP_OR, first_split_filter, second_split_filter); if (split_filters == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -305,14 +315,17 @@ static int anr_search_callback(struct ldb_request *req, struct ldb_reply *ares) /* search */ static int anr_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_parse_tree *anr_tree; struct ldb_request *down_req; struct anr_context *ac; int ret; + ldb = ldb_module_get_ctx(module); + ac = talloc(req, struct anr_context); if (!ac) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -335,7 +348,7 @@ static int anr_search(struct ldb_module *module, struct ldb_request *req) } ret = ldb_build_search_req_ex(&down_req, - module->ldb, ac, + ldb, ac, req->op.search.base, req->op.search.scope, anr_tree, diff --git a/source4/dsdb/samdb/ldb_modules/config.mk b/source4/dsdb/samdb/ldb_modules/config.mk index 1c50923eba..01f5188b6f 100644 --- a/source4/dsdb/samdb/ldb_modules/config.mk +++ b/source4/dsdb/samdb/ldb_modules/config.mk @@ -2,7 +2,7 @@ # Start MODULE ldb_objectguid [MODULE::ldb_objectguid] SUBSYSTEM = LIBLDB -PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBNDR +PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBEVENTS LIBNDR INIT_FUNCTION = LDB_MODULE(objectguid) # End MODULE ldb_objectguid ################################################ diff --git a/source4/dsdb/samdb/ldb_modules/instancetype.c b/source4/dsdb/samdb/ldb_modules/instancetype.c index a8c45dee4c..8d648d6d82 100644 --- a/source4/dsdb/samdb/ldb_modules/instancetype.c +++ b/source4/dsdb/samdb/ldb_modules/instancetype.c @@ -35,7 +35,7 @@ */ #include "includes.h" -#include "ldb/include/ldb_includes.h" +#include "ldb_module.h" #include "librpc/gen_ndr/ndr_misc.h" #include "dsdb/samdb/samdb.h" #include "dsdb/common/flags.h" @@ -47,10 +47,11 @@ struct it_context { static int it_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct it_context *ac; ac = talloc_get_type(req->context, struct it_context); - + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -62,7 +63,7 @@ static int it_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(req->handle->ldb, "Invalid reply type!"); + ldb_set_errstring(ldb, "Invalid reply type!"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -74,6 +75,7 @@ static int it_callback(struct ldb_request *req, struct ldb_reply *ares) /* add_record: add instancetype attribute */ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *down_req; struct ldb_message *msg; struct it_context *ac; @@ -81,9 +83,10 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) int ret; const struct ldb_control *partition_ctrl; const struct dsdb_control_current_partition *partition; - - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "instancetype_add_record\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "instancetype_add_record\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.add.message->dn)) { @@ -92,7 +95,7 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) partition_ctrl = ldb_request_get_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID); if (!partition_ctrl) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "instancetype_add: no current partition control found"); return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -111,7 +114,7 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) /* we have to copy the message as the caller might have it as a const */ msg = ldb_msg_copy_shallow(ac, req->op.add.message); if (msg == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -121,18 +124,18 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req) instance_type = INSTANCE_TYPE_WRITE; if (ldb_dn_compare(partition->dn, msg->dn) == 0) { instance_type |= INSTANCE_TYPE_IS_NC_HEAD; - if (ldb_dn_compare(msg->dn, samdb_base_dn(module->ldb)) != 0) { + if (ldb_dn_compare(msg->dn, samdb_base_dn(ldb)) != 0) { instance_type |= INSTANCE_TYPE_NC_ABOVE; } } ret = ldb_msg_add_fmt(msg, "instanceType", "%u", instance_type); if (ret != LDB_SUCCESS) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_add_req(&down_req, module->ldb, ac, + ret = ldb_build_add_req(&down_req, ldb, ac, msg, req->controls, ac, it_callback, diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c index 3d725686e7..46ba8ebdb3 100644 --- a/source4/dsdb/samdb/ldb_modules/objectguid.c +++ b/source4/dsdb/samdb/ldb_modules/objectguid.c @@ -34,7 +34,7 @@ */ #include "includes.h" -#include "ldb/include/ldb_includes.h" +#include "ldb_module.h" #include "librpc/gen_ndr/ndr_misc.h" #include "param/param.h" @@ -136,6 +136,7 @@ static int og_op_callback(struct ldb_request *req, struct ldb_reply *ares) /* add_record: add objectGUID attribute */ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *down_req; struct ldb_message_element *attribute; struct ldb_message *msg; @@ -147,7 +148,9 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) time_t t = time(NULL); struct og_context *ac; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.add.message->dn)) { @@ -176,7 +179,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) guid = GUID_random(); ndr_err = ndr_push_struct_blob(&v, msg, - lp_iconv_convenience(ldb_get_opaque(module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &guid, (ndr_push_flags_fn_t)ndr_push_GUID); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -196,7 +199,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) /* Get a sequence number from the backend */ /* FIXME: ldb_sequence_number is a semi-async call, * make sure this function is split and a callback is used */ - ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num); + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret == LDB_SUCCESS) { if (add_uint64_element(msg, "uSNCreated", seq_num) != 0 || add_uint64_element(msg, "uSNChanged", seq_num) != 0) { @@ -204,7 +207,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) } } - ret = ldb_build_add_req(&down_req, module->ldb, ac, + ret = ldb_build_add_req(&down_req, ldb, ac, msg, req->controls, ac, og_op_callback, @@ -220,6 +223,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req) /* modify_record: update timestamps */ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *down_req; struct ldb_message *msg; int ret; @@ -227,7 +231,9 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req) uint64_t seq_num; struct og_context *ac; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.add.message->dn)) { @@ -252,14 +258,14 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req) } /* Get a sequence number from the backend */ - ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num); + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret == LDB_SUCCESS) { if (add_uint64_element(msg, "uSNChanged", seq_num) != 0) { return LDB_ERR_OPERATIONS_ERROR; } } - ret = ldb_build_mod_req(&down_req, module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, msg, req->controls, ac, og_op_callback, diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c index 0000c87f72..71a1b8e942 100644 --- a/source4/dsdb/samdb/ldb_modules/partition.c +++ b/source4/dsdb/samdb/ldb_modules/partition.c @@ -34,7 +34,7 @@ */ #include "includes.h" -#include "ldb/include/ldb_includes.h" +#include "ldb_private.h" #include "dsdb/samdb/samdb.h" struct partition_private_data { diff --git a/source4/dsdb/samdb/ldb_modules/ranged_results.c b/source4/dsdb/samdb/ldb_modules/ranged_results.c index eeb161bdde..8f36baa7d6 100644 --- a/source4/dsdb/samdb/ldb_modules/ranged_results.c +++ b/source4/dsdb/samdb/ldb_modules/ranged_results.c @@ -29,7 +29,7 @@ * Author: Andrew Bartlett */ -#include "ldb_includes.h" +#include "ldb_module.h" struct rr_context { struct ldb_module *module; @@ -43,7 +43,7 @@ static struct rr_context *rr_init_context(struct ldb_module *module, ac = talloc_zero(req, struct rr_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb_module_get_ctx(module), "Out of Memory"); return NULL; } @@ -55,10 +55,12 @@ static struct rr_context *rr_init_context(struct ldb_module *module, static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct rr_context *ac; int i, j; ac = talloc_get_type(req->context, struct rr_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -106,7 +108,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) (size_t)(p - ac->req->op.search.attrs[i])); if (!new_attr) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -123,7 +125,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) } else { end_str = talloc_asprintf(el, "%u", end); if (!end_str) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -137,7 +139,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) orig_num_values = el->num_values; if ((start + end < start) || (start + end < end)) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "range request error: start or end would overflow!"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_UNWILLING_TO_PERFORM); @@ -147,7 +149,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) el->values = talloc_array(el, struct ldb_val, (end - start) + 1); if (!el->values) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -158,7 +160,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) } el->name = talloc_asprintf(el, "%s;range=%u-%s", el->name, start, end_str); if (!el->name) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -170,6 +172,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares) /* search */ static int rr_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; int i; unsigned int start, end; const char **new_attrs = NULL; @@ -178,6 +181,8 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) struct rr_context *ac; int ret; + ldb = ldb_module_get_ctx(module); + /* Strip the range request from the attribute */ for (i = 0; req->op.search.attrs && req->op.search.attrs[i]; i++) { char *p; @@ -194,14 +199,14 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) end = (unsigned int)-1; if (sscanf(p, ";range=%u-*", &start) != 1) { if (sscanf(p, ";range=%u-%u", &start, &end) != 2) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "range request error: " "range request malformed"); return LDB_ERR_UNWILLING_TO_PERFORM; } } if (start > end) { - ldb_asprintf_errstring(module->ldb, "range request error: start must not be greater than end"); + ldb_asprintf_errstring(ldb, "range request error: start must not be greater than end"); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -210,7 +215,7 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) (size_t)(p - new_attrs[i])); if (!new_attrs[i]) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } } @@ -221,7 +226,7 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req_ex(&down_req, module->ldb, ac, + ret = ldb_build_search_req_ex(&down_req, ldb, ac, req->op.search.base, req->op.search.scope, req->op.search.tree, diff --git a/source4/dsdb/samdb/ldb_modules/subtree_delete.c b/source4/dsdb/samdb/ldb_modules/subtree_delete.c index 10e2dc25ce..55a24549dd 100644 --- a/source4/dsdb/samdb/ldb_modules/subtree_delete.c +++ b/source4/dsdb/samdb/ldb_modules/subtree_delete.c @@ -29,7 +29,7 @@ * Author: Andrew Bartlett */ -#include "ldb_includes.h" +#include "ldb_module.h" struct subtree_delete_context { struct ldb_module *module; @@ -41,11 +41,14 @@ struct subtree_delete_context { static struct subtree_delete_context *subdel_ctx_init(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct subtree_delete_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct subtree_delete_context); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } @@ -58,10 +61,12 @@ static struct subtree_delete_context *subdel_ctx_init(struct ldb_module *module, static int subtree_delete_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct subtree_delete_context *ac; int ret; ac = talloc_get_type(req->context, struct subtree_delete_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -89,7 +94,7 @@ static int subtree_delete_search_callback(struct ldb_request *req, if (ac->num_children > 0) { talloc_free(ares); - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "Cannot delete %s, not a leaf node " "(has %d children)\n", ldb_dn_get_linearized(ac->req->op.del.dn), @@ -112,6 +117,7 @@ static int subtree_delete_search_callback(struct ldb_request *req, static int subtree_delete(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; static const char * const attrs[2] = { "distinguishedName", NULL }; struct ldb_request *search_req; struct subtree_delete_context *ac; @@ -120,6 +126,8 @@ static int subtree_delete(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } + ldb = ldb_module_get_ctx(module); + /* This gets complex: We need to: - Do a search for all entires under this entry - Wait for these results to appear @@ -135,7 +143,7 @@ static int subtree_delete(struct ldb_module *module, struct ldb_request *req) /* we do not really need to find all descendents, * if there is even one single direct child, that's * enough to bail out */ - ret = ldb_build_search_req(&search_req, module->ldb, ac, + ret = ldb_build_search_req(&search_req, ldb, ac, req->op.del.dn, LDB_SCOPE_ONELEVEL, "(objectClass=*)", attrs, req->controls, diff --git a/source4/dsdb/samdb/ldb_modules/subtree_rename.c b/source4/dsdb/samdb/ldb_modules/subtree_rename.c index d3ceb8ad97..e2f6b1d059 100644 --- a/source4/dsdb/samdb/ldb_modules/subtree_rename.c +++ b/source4/dsdb/samdb/ldb_modules/subtree_rename.c @@ -28,7 +28,7 @@ * Author: Andrew Bartlett */ -#include "ldb_includes.h" +#include "ldb_module.h" struct subren_msg_store { struct subren_msg_store *next; @@ -47,11 +47,14 @@ struct subtree_rename_context { static struct subtree_rename_context *subren_ctx_init(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct subtree_rename_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct subtree_rename_context); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } @@ -66,10 +69,12 @@ static int subtree_rename_next_request(struct subtree_rename_context *ac); static int subtree_rename_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct subtree_rename_context *ac; int ret; ac = talloc_get_type(req->context, struct subtree_rename_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -82,7 +87,7 @@ static int subtree_rename_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, "Invalid reply type!\n"); + ldb_set_errstring(ldb, "Invalid reply type!\n"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -104,14 +109,17 @@ static int subtree_rename_callback(struct ldb_request *req, static int subtree_rename_next_request(struct subtree_rename_context *ac) { + struct ldb_context *ldb; struct ldb_request *req; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (ac->current == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_rename_req(&req, ac->module->ldb, ac->current, + ret = ldb_build_rename_req(&req, ldb, ac->current, ac->current->olddn, ac->current->newdn, ac->req->controls, @@ -204,6 +212,7 @@ static int subtree_rename_search_callback(struct ldb_request *req, /* rename */ static int subtree_rename(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; static const char *attrs[2] = { "distinguishedName", NULL }; struct ldb_request *search_req; struct subtree_rename_context *ac; @@ -212,6 +221,8 @@ static int subtree_rename(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } + ldb = ldb_module_get_ctx(module); + /* This gets complex: We need to: - Do a search for all entires under this entry - Wait for these results to appear @@ -235,7 +246,7 @@ static int subtree_rename(struct ldb_module *module, struct ldb_request *req) ac->current->newdn = req->op.rename.newdn; ac->list = ac->current; - ret = ldb_build_search_req(&search_req, module->ldb, ac, + ret = ldb_build_search_req(&search_req, ldb, ac, req->op.rename.olddn, LDB_SCOPE_SUBTREE, "(objectClass=*)", diff --git a/source4/dsdb/samdb/ldb_modules/update_keytab.c b/source4/dsdb/samdb/ldb_modules/update_keytab.c index 7b82763403..e178ebb9dc 100644 --- a/source4/dsdb/samdb/ldb_modules/update_keytab.c +++ b/source4/dsdb/samdb/ldb_modules/update_keytab.c @@ -28,7 +28,7 @@ */ #include "includes.h" -#include "ldb/include/ldb_includes.h" +#include "ldb_module.h" #include "auth/credentials/credentials.h" #include "auth/credentials/credentials_krb5.h" #include "system/kerberos.h" @@ -60,7 +60,7 @@ static struct update_kt_ctx *update_kt_ctx_init(struct ldb_module *module, ac = talloc_zero(req, struct update_kt_ctx); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb_module_get_ctx(module)); return NULL; } @@ -76,7 +76,8 @@ static struct update_kt_ctx *update_kt_ctx_init(struct ldb_module *module, * of async issues). -SSS */ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delete) { - struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private); + struct ldb_context *ldb = ldb_module_get_ctx(module); + struct update_kt_private *data = talloc_get_type(ldb_module_get_private(module), struct update_kt_private); struct dn_list *item; char *filter; struct ldb_result *res; @@ -87,11 +88,11 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet filter = talloc_asprintf(data, "(&(dn=%s)(&(objectClass=kerberosSecret)(privateKeytab=*)))", ldb_dn_get_linearized(dn)); if (!filter) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_search(module->ldb, data, &res, + ret = ldb_search(ldb, data, &res, dn, LDB_SCOPE_BASE, attrs, "%s", filter); if (ret != LDB_SUCCESS) { talloc_free(filter); @@ -109,7 +110,7 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet item = talloc(data->changed_dns? (void *)data->changed_dns: (void *)data, struct dn_list); if (!item) { talloc_free(filter); - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -117,12 +118,12 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet if (!item->creds) { DEBUG(1, ("cli_credentials_init failed!")); talloc_free(filter); - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - cli_credentials_set_conf(item->creds, ldb_get_opaque(module->ldb, "loadparm")); - status = cli_credentials_set_secrets(item->creds, ldb_get_event_context(module->ldb), ldb_get_opaque(module->ldb, "loadparm"), module->ldb, NULL, filter); + cli_credentials_set_conf(item->creds, ldb_get_opaque(ldb, "loadparm")); + status = cli_credentials_set_secrets(item->creds, ldb_get_event_context(ldb), ldb_get_opaque(ldb, "loadparm"), ldb, NULL, filter); talloc_free(filter); if (NT_STATUS_IS_OK(status)) { if (delete) { @@ -142,10 +143,12 @@ static int ukt_search_modified(struct update_kt_ctx *ac); static int update_kt_op_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct update_kt_ctx *ac; int ret; ac = talloc_get_type(req->context, struct update_kt_ctx); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -157,7 +160,7 @@ static int update_kt_op_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, "Invalid request type!\n"); + ldb_set_errstring(ldb, "Invalid request type!\n"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -179,10 +182,13 @@ static int update_kt_op_callback(struct ldb_request *req, static int ukt_del_op(struct update_kt_ctx *ac) { + struct ldb_context *ldb; struct ldb_request *down_req; int ret; - ret = ldb_build_del_req(&down_req, ac->module->ldb, ac, + ldb = ldb_module_get_ctx(ac->module); + + ret = ldb_build_del_req(&down_req, ldb, ac, ac->dn, ac->req->controls, ac, update_kt_op_callback, @@ -246,11 +252,14 @@ static int ukt_search_modified_callback(struct ldb_request *req, static int ukt_search_modified(struct update_kt_ctx *ac) { + struct ldb_context *ldb; static const char * const attrs[] = { "distinguishedName", NULL }; struct ldb_request *search_req; int ret; - ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ldb = ldb_module_get_ctx(ac->module); + + ret = ldb_build_search_req(&search_req, ldb, ac, ac->dn, LDB_SCOPE_BASE, "(&(objectClass=kerberosSecret)" "(privateKeytab=*))", attrs, @@ -267,10 +276,13 @@ static int ukt_search_modified(struct update_kt_ctx *ac) /* add */ static int update_kt_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct update_kt_ctx *ac; struct ldb_request *down_req; int ret; + ldb = ldb_module_get_ctx(module); + ac = update_kt_ctx_init(module, req); if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -278,7 +290,7 @@ static int update_kt_add(struct ldb_module *module, struct ldb_request *req) ac->dn = req->op.add.message->dn; - ret = ldb_build_add_req(&down_req, module->ldb, ac, + ret = ldb_build_add_req(&down_req, ldb, ac, req->op.add.message, req->controls, ac, update_kt_op_callback, @@ -293,10 +305,13 @@ static int update_kt_add(struct ldb_module *module, struct ldb_request *req) /* modify */ static int update_kt_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct update_kt_ctx *ac; struct ldb_request *down_req; int ret; + ldb = ldb_module_get_ctx(module); + ac = update_kt_ctx_init(module, req); if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -304,7 +319,7 @@ static int update_kt_modify(struct ldb_module *module, struct ldb_request *req) ac->dn = req->op.mod.message->dn; - ret = ldb_build_mod_req(&down_req, module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, req->op.mod.message, req->controls, ac, update_kt_op_callback, @@ -335,10 +350,13 @@ static int update_kt_delete(struct ldb_module *module, struct ldb_request *req) /* rename */ static int update_kt_rename(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct update_kt_ctx *ac; struct ldb_request *down_req; int ret; + ldb = ldb_module_get_ctx(module); + ac = update_kt_ctx_init(module, req); if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -346,7 +364,7 @@ static int update_kt_rename(struct ldb_module *module, struct ldb_request *req) ac->dn = req->op.rename.newdn; - ret = ldb_build_rename_req(&down_req, module->ldb, ac, + ret = ldb_build_rename_req(&down_req, ldb, ac, req->op.rename.olddn, req->op.rename.newdn, req->controls, @@ -362,16 +380,19 @@ static int update_kt_rename(struct ldb_module *module, struct ldb_request *req) /* end a transaction */ static int update_kt_end_trans(struct ldb_module *module) { - struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private); + struct ldb_context *ldb; + struct update_kt_private *data = talloc_get_type(ldb_module_get_private(module), struct update_kt_private); struct dn_list *p; + ldb = ldb_module_get_ctx(module); + for (p=data->changed_dns; p; p = p->next) { int kret; - kret = cli_credentials_update_keytab(p->creds, ldb_get_event_context(module->ldb), ldb_get_opaque(module->ldb, "loadparm")); + kret = cli_credentials_update_keytab(p->creds, ldb_get_event_context(ldb), ldb_get_opaque(ldb, "loadparm")); if (kret != 0) { talloc_free(data->changed_dns); data->changed_dns = NULL; - ldb_asprintf_errstring(module->ldb, "Failed to update keytab: %s", error_message(kret)); + ldb_asprintf_errstring(ldb, "Failed to update keytab: %s", error_message(kret)); return LDB_ERR_OPERATIONS_ERROR; } } @@ -385,7 +406,7 @@ static int update_kt_end_trans(struct ldb_module *module) /* end a transaction */ static int update_kt_del_trans(struct ldb_module *module) { - struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private); + struct update_kt_private *data = talloc_get_type(ldb_module_get_private(module), struct update_kt_private); talloc_free(data->changed_dns); data->changed_dns = NULL; @@ -395,17 +416,21 @@ static int update_kt_del_trans(struct ldb_module *module) static int update_kt_init(struct ldb_module *module) { + struct ldb_context *ldb; struct update_kt_private *data; + ldb = ldb_module_get_ctx(module); + data = talloc(module, struct update_kt_private); if (data == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - module->private_data = data; data->changed_dns = NULL; + ldb_module_set_private(module, data); + return ldb_next_init(module); } diff --git a/source4/lib/ldb-samba/ldif_handlers.c b/source4/lib/ldb-samba/ldif_handlers.c index 5ab31d771b..d92f211946 100644 --- a/source4/lib/ldb-samba/ldif_handlers.c +++ b/source4/lib/ldb-samba/ldif_handlers.c @@ -22,7 +22,7 @@ */ #include "includes.h" -#include "lib/ldb/include/ldb_includes.h" +#include "ldb_private.h" #include "dsdb/samdb/samdb.h" #include "librpc/gen_ndr/ndr_security.h" #include "librpc/gen_ndr/ndr_misc.h" diff --git a/source4/lib/ldb/common/attrib_handlers.c b/source4/lib/ldb/common/attrib_handlers.c index 5ec86b5b8f..80725ec04f 100644 --- a/source4/lib/ldb/common/attrib_handlers.c +++ b/source4/lib/ldb/common/attrib_handlers.c @@ -25,7 +25,7 @@ see rfc2252 */ -#include "ldb_includes.h" +#include "ldb_private.h" #include "system/locale.h" #include "ldb_handlers.h" diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index fe55d1499a..2fb5a8f9be 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -32,7 +32,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb_private.h" /* initialise a ldb context @@ -481,6 +481,11 @@ void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms) ldb->create_perms = perms; } +unsigned int ldb_get_create_perms(struct ldb_context *ldb) +{ + return ldb->create_perms; +} + void ldb_set_event_context(struct ldb_context *ldb, struct tevent_context *ev) { ldb->ev_ctx = ev; @@ -491,6 +496,16 @@ struct tevent_context * ldb_get_event_context(struct ldb_context *ldb) return ldb->ev_ctx; } +void ldb_request_set_state(struct ldb_request *req, int state) +{ + req->handle->state = state; +} + +int ldb_request_get_status(struct ldb_request *req) +{ + return req->handle->status; +} + /* start an ldb request NOTE: the request must be a talloc context. diff --git a/source4/lib/ldb/common/ldb_attributes.c b/source4/lib/ldb/common/ldb_attributes.c index 001bc45ee1..4d688a4d7e 100644 --- a/source4/lib/ldb/common/ldb_attributes.c +++ b/source4/lib/ldb/common/ldb_attributes.c @@ -28,7 +28,7 @@ message matching logic generic */ -#include "ldb_includes.h" +#include "ldb_private.h" /* add a attribute to the ldb_schema diff --git a/source4/lib/ldb/common/ldb_controls.c b/source4/lib/ldb/common/ldb_controls.c index 6fad5012b6..0c587e0905 100644 --- a/source4/lib/ldb/common/ldb_controls.c +++ b/source4/lib/ldb/common/ldb_controls.c @@ -31,7 +31,7 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_private.h" /* check if a control with the specified "oid" exist and return it */ /* returns NULL if not found */ diff --git a/source4/lib/ldb/common/ldb_debug.c b/source4/lib/ldb/common/ldb_debug.c index 0f78e37c1c..f8009eb8a3 100644 --- a/source4/lib/ldb/common/ldb_debug.c +++ b/source4/lib/ldb/common/ldb_debug.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb_private.h" /* this allows the user to choose their own debug function diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c index 02e21a2b25..402d629501 100644 --- a/source4/lib/ldb/common/ldb_dn.c +++ b/source4/lib/ldb/common/ldb_dn.c @@ -33,7 +33,7 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_private.h" #include #define LDB_DN_NULL_FAILED(x) if (!(x)) goto failed diff --git a/source4/lib/ldb/common/ldb_ldif.c b/source4/lib/ldb/common/ldb_ldif.c index 619c10e11e..400fb352ff 100644 --- a/source4/lib/ldb/common/ldb_ldif.c +++ b/source4/lib/ldb/common/ldb_ldif.c @@ -35,7 +35,7 @@ see RFC2849 for the LDIF format definition */ -#include "ldb_includes.h" +#include "ldb_private.h" #include "system/locale.h" /* diff --git a/source4/lib/ldb/common/ldb_match.c b/source4/lib/ldb/common/ldb_match.c index 4cde739d67..c622701d30 100644 --- a/source4/lib/ldb/common/ldb_match.c +++ b/source4/lib/ldb/common/ldb_match.c @@ -32,7 +32,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb_private.h" /* check if the scope matches in a search result diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index 8db28d262c..03d1e6ebe2 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -31,7 +31,7 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_private.h" #if (_SAMBA_BUILD_ >= 4) #include "includes.h" @@ -486,6 +486,41 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[]) } while (0) +struct ldb_module *ldb_module_new(TALLOC_CTX *memctx, + struct ldb_context *ldb, + const char *module_name, + const struct ldb_module_ops *ops) +{ + struct ldb_module *module; + + module = talloc(memctx, struct ldb_module); + if (!module) { + ldb_oom(ldb); + return NULL; + } + talloc_set_name_const(module, module_name); + module->ldb = ldb; + module->prev = module->next = NULL; + module->ops = ops; + + return module; +} + +struct ldb_context *ldb_module_get_ctx(struct ldb_module *module) +{ + return module->ldb; +} + +void *ldb_module_get_private(struct ldb_module *module) +{ + return module->private_data; +} + +void ldb_module_set_private(struct ldb_module *module, void *private_data) +{ + module->private_data = private_data; +} + /* helper functions to call the next module in chain */ diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c index 2f5fe1d18c..ad53a3d29d 100644 --- a/source4/lib/ldb/common/ldb_msg.c +++ b/source4/lib/ldb/common/ldb_msg.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb_private.h" /* create a new ldb_message in a given memory context (NULL for top level) diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c index b233975220..654a635abf 100644 --- a/source4/lib/ldb/common/ldb_parse.c +++ b/source4/lib/ldb/common/ldb_parse.c @@ -40,7 +40,7 @@ */ -#include "ldb_includes.h" +#include "ldb_private.h" #include "system/locale.h" /* diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c index 69ee2b6964..0a8a89ac1d 100644 --- a/source4/lib/ldb/common/ldb_utf8.c +++ b/source4/lib/ldb/common/ldb_utf8.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb_private.h" #include "system/locale.h" diff --git a/source4/lib/ldb/common/qsort.c b/source4/lib/ldb/common/qsort.c index 0fa76d3b47..1a0b886b8c 100644 --- a/source4/lib/ldb/common/qsort.c +++ b/source4/lib/ldb/common/qsort.c @@ -23,7 +23,7 @@ * Simo Sorce 2005 */ -#include "ldb_includes.h" +#include "ldb_private.h" /* Byte-wise swap two items of size SIZE. */ #define SWAP(a, b, size) \ diff --git a/source4/lib/ldb/examples/ldbreader.c b/source4/lib/ldb/examples/ldbreader.c index e48b3d338a..3496baf4ce 100644 --- a/source4/lib/ldb/examples/ldbreader.c +++ b/source4/lib/ldb/examples/ldbreader.c @@ -29,9 +29,7 @@ It lists / dumps the records in a LDB database to standard output. */ -#include "ldb_includes.h" #include "ldb.h" -#include "ldb_errors.h" /* ldb_ldif_write takes a function pointer to a custom output diff --git a/source4/lib/ldb/examples/ldifreader.c b/source4/lib/ldb/examples/ldifreader.c index 12e7a1a6fd..dcd9daf812 100644 --- a/source4/lib/ldb/examples/ldifreader.c +++ b/source4/lib/ldb/examples/ldifreader.c @@ -29,9 +29,7 @@ It lists / dumps the entries in an LDIF file to standard output. */ -#include "ldb_includes.h" #include "ldb.h" -#include "ldb_errors.h" /* ldb_ldif_write takes a function pointer to a custom output diff --git a/source4/lib/ldb/include/dlinklist.h b/source4/lib/ldb/include/dlinklist.h index d3252751db..acab9fa043 100644 --- a/source4/lib/ldb/include/dlinklist.h +++ b/source4/lib/ldb/include/dlinklist.h @@ -20,6 +20,8 @@ /* To use these macros you must have a structure containing a next and prev pointer */ +#ifndef _DLINKLIST_H +#define _DLINKLIST_H /* hook into the front of the list */ #define DLIST_ADD(list, p) \ @@ -108,3 +110,5 @@ do { \ } \ } \ } while (0) + +#endif /* _DLINKLIST_H */ diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 28c54f5a3c..589887b4c5 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -46,18 +46,18 @@ #define _LDB_H_ 1 /*! \endcond */ +#include "ldb_includes.h" + /* major restrictions as compared to normal LDAP: - - no async calls. - each record must have a unique key field - the key must be representable as a NULL terminated C string and may not contain a comma or braces major restrictions as compared to tdb: - - no explicit locking calls - UPDATE: we have transactions now, better than locking --SSS. + - no explicit locking calls, but we have transactions when using ldb_tdb */ diff --git a/source4/lib/ldb/include/ldb_includes.h b/source4/lib/ldb/include/ldb_includes.h index 8356404409..a2927139c8 100644 --- a/source4/lib/ldb/include/ldb_includes.h +++ b/source4/lib/ldb/include/ldb_includes.h @@ -21,9 +21,7 @@ #include "system/time.h" #include #include -#include "ldb.h" #include "ldb_errors.h" -#include "ldb_private.h" #include "dlinklist.h" #endif /*_LDB_PRIVATE_INCLUDES_H_*/ diff --git a/source4/lib/ldb/include/ldb_module.h b/source4/lib/ldb/include/ldb_module.h new file mode 100644 index 0000000000..8742b1058c --- /dev/null +++ b/source4/lib/ldb/include/ldb_module.h @@ -0,0 +1,160 @@ +/* + ldb database library + + Copyright (C) Simo Sorce 2008 + + ** NOTE! The following LGPL license applies to the ldb + ** 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 . +*/ + +/* + * Name: ldb + * + * Component: ldb module header + * + * Description: defines ldb modules structures and helpers + * + */ + +#ifndef _LDB_MODULE_H_ +#define _LDB_MODULE_H_ + +#include "ldb.h" + +struct ldb_context; +struct ldb_module; + +/* + these function pointers define the operations that a ldb module can intercept +*/ +struct ldb_module_ops { + const char *name; + int (*init_context) (struct ldb_module *); + int (*search)(struct ldb_module *, struct ldb_request *); /* search */ + int (*add)(struct ldb_module *, struct ldb_request *); /* add */ + int (*modify)(struct ldb_module *, struct ldb_request *); /* modify */ + int (*del)(struct ldb_module *, struct ldb_request *); /* delete */ + int (*rename)(struct ldb_module *, struct ldb_request *); /* rename */ + int (*request)(struct ldb_module *, struct ldb_request *); /* match any other operation */ + int (*extended)(struct ldb_module *, struct ldb_request *); /* extended operations */ + int (*start_transaction)(struct ldb_module *); + int (*end_transaction)(struct ldb_module *); + int (*del_transaction)(struct ldb_module *); + int (*sequence_number)(struct ldb_module *, struct ldb_request *); + void *private_data; +}; + + +/* The following definitions come from lib/ldb/common/ldb_debug.c */ +void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); +void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level, + const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); + +#define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__) + +/* The following definitions come from lib/ldb/common/ldb.c */ + +void ldb_request_set_state(struct ldb_request *req, int state); +int ldb_request_get_status(struct ldb_request *req); + +unsigned int ldb_get_create_perms(struct ldb_context *ldb); + +const struct ldb_schema_syntax *ldb_standard_syntax_by_name(struct ldb_context *ldb, + const char *syntax); + +/* The following definitions come from lib/ldb/common/ldb_attributes.c */ + +int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb, + const char *name, + unsigned flags, + const struct ldb_schema_syntax *syntax); +int ldb_schema_attribute_add(struct ldb_context *ldb, + const char *name, + unsigned flags, + const char *syntax); +void ldb_schema_attribute_remove(struct ldb_context *ldb, const char *name); + +/* The following definitions come from lib/ldb/common/ldb_controls.c */ +struct ldb_control *get_control_from_list(struct ldb_control **controls, const char *oid); +int save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver); +int check_critical_controls(struct ldb_control **controls); + +/* The following definitions come from lib/ldb/common/ldb_ldif.c */ +int ldb_should_b64_encode(const struct ldb_val *val); + +/* The following definitions come from lib/ldb/common/ldb_match.c */ +int ldb_match_msg(struct ldb_context *ldb, + const struct ldb_message *msg, + const struct ldb_parse_tree *tree, + struct ldb_dn *base, + enum ldb_scope scope); + +/* The following definitions come from lib/ldb/common/ldb_modules.c */ + +struct ldb_module *ldb_module_new(TALLOC_CTX *memctx, + struct ldb_context *ldb, + const char *module_name, + const struct ldb_module_ops *ops); + +struct ldb_context *ldb_module_get_ctx(struct ldb_module *module); +void *ldb_module_get_private(struct ldb_module *module); +void ldb_module_set_private(struct ldb_module *module, void *private_data); + +int ldb_next_request(struct ldb_module *module, struct ldb_request *request); +int ldb_next_start_trans(struct ldb_module *module); +int ldb_next_end_trans(struct ldb_module *module); +int ldb_next_del_trans(struct ldb_module *module); +int ldb_next_init(struct ldb_module *module); + +void ldb_set_errstring(struct ldb_context *ldb, const char *err_string); +void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3); +void ldb_reset_err_string(struct ldb_context *ldb); + +const char *ldb_default_modules_dir(void); + +int ldb_register_module(const struct ldb_module_ops *); + +typedef int (*ldb_connect_fn)(struct ldb_context *ldb, const char *url, + unsigned int flags, const char *options[], + struct ldb_module **module); + +struct ldb_backend_ops { + const char *name; + ldb_connect_fn connect_fn; +}; + +const char *ldb_default_modules_dir(void); + +int ldb_register_backend(const char *url_prefix, ldb_connect_fn); + +struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb); + +int ldb_module_send_entry(struct ldb_request *req, + struct ldb_message *msg, + struct ldb_control **ctrls); + +int ldb_module_send_referral(struct ldb_request *req, + char *ref); + +int ldb_module_done(struct ldb_request *req, + struct ldb_control **ctrls, + struct ldb_extended *response, + int error); + +int ldb_mod_register_control(struct ldb_module *module, const char *oid); + +#endif diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index cf4017ef14..04ee002dd5 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -37,6 +37,9 @@ #ifndef _LDB_PRIVATE_H_ #define _LDB_PRIVATE_H_ 1 +#include "ldb.h" +#include "ldb_module.h" + struct ldb_context; struct ldb_module_ops; @@ -57,26 +60,6 @@ struct ldb_module { const struct ldb_module_ops *ops; }; -/* - these function pointers define the operations that a ldb module can intercept -*/ -struct ldb_module_ops { - const char *name; - int (*init_context) (struct ldb_module *); - int (*search)(struct ldb_module *, struct ldb_request *); /* search */ - int (*add)(struct ldb_module *, struct ldb_request *); /* add */ - int (*modify)(struct ldb_module *, struct ldb_request *); /* modify */ - int (*del)(struct ldb_module *, struct ldb_request *); /* delete */ - int (*rename)(struct ldb_module *, struct ldb_request *); /* rename */ - int (*request)(struct ldb_module *, struct ldb_request *); /* match any other operation */ - int (*extended)(struct ldb_module *, struct ldb_request *); /* extended operations */ - int (*start_transaction)(struct ldb_module *); - int (*end_transaction)(struct ldb_module *); - int (*del_transaction)(struct ldb_module *); - int (*sequence_number)(struct ldb_module *, struct ldb_request *); - void *private_data; -}; - /* schema related information needed for matching rules */ @@ -130,24 +113,12 @@ struct ldb_context { #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) #endif -/* - simplify out of memory handling -*/ -#define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__) - /* The following definitions come from lib/ldb/common/ldb.c */ int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *options[], struct ldb_module **backend_module); void ldb_set_default_dns(struct ldb_context *ldb); -/* The following definitions come from lib/ldb/common/ldb_debug.c */ -void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); -void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level, - const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); - -/* The following definitions come from lib/ldb/common/ldb_ldif.c */ -int ldb_should_b64_encode(const struct ldb_val *val); extern const struct ldb_module_ops ldb_objectclass_module_ops; extern const struct ldb_module_ops ldb_operational_module_ops; @@ -173,26 +144,6 @@ extern const struct ldb_backend_ops ldb_ldap_backend_ops; extern const struct ldb_backend_ops ldb_ldapi_backend_ops; extern const struct ldb_backend_ops ldb_ldaps_backend_ops; -int ldb_match_msg(struct ldb_context *ldb, - const struct ldb_message *msg, - const struct ldb_parse_tree *tree, - struct ldb_dn *base, - enum ldb_scope scope); - -const struct ldb_schema_syntax *ldb_standard_syntax_by_name(struct ldb_context *ldb, - const char *syntax); - -/* The following definitions come from lib/ldb/common/ldb_attributes.c */ - -int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb, - const char *name, - unsigned flags, - const struct ldb_schema_syntax *syntax); -int ldb_schema_attribute_add(struct ldb_context *ldb, - const char *name, - unsigned flags, - const char *syntax); -void ldb_schema_attribute_remove(struct ldb_context *ldb, const char *name); int ldb_setup_wellknown_attributes(struct ldb_context *ldb); const char **ldb_subclass_list(struct ldb_context *ldb, const char *classname); @@ -204,11 +155,6 @@ int ldb_handler_copy(struct ldb_context *ldb, void *mem_ctx, int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx, const struct ldb_val *v1, const struct ldb_val *v2); -/* The following definitions come from lib/ldb/common/ldb_controls.c */ -struct ldb_control *get_control_from_list(struct ldb_control **controls, const char *oid); -int save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver); -int check_critical_controls(struct ldb_control **controls); - /* The following definitions come from lib/ldb/common/ldb_utf8.c */ char *ldb_casefold_default(void *context, void *mem_ctx, const char *s, size_t n); @@ -227,57 +173,12 @@ int ldb_sequence_number(struct ldb_context *ldb, enum ldb_sequence_type type, ui #define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02 -/* MODULES specific headers -- SSS */ - /* The following definitions come from lib/ldb/common/ldb_modules.c */ const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *string); int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, struct ldb_module *backend, struct ldb_module **out); int ldb_load_modules(struct ldb_context *ldb, const char *options[]); int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module); -int ldb_next_request(struct ldb_module *module, struct ldb_request *request); -int ldb_next_start_trans(struct ldb_module *module); -int ldb_next_end_trans(struct ldb_module *module); -int ldb_next_del_trans(struct ldb_module *module); -int ldb_next_init(struct ldb_module *module); - -void ldb_set_errstring(struct ldb_context *ldb, const char *err_string); -void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3); -void ldb_reset_err_string(struct ldb_context *ldb); - -const char *ldb_default_modules_dir(void); - -int ldb_register_module(const struct ldb_module_ops *); - -typedef int (*ldb_connect_fn)(struct ldb_context *ldb, const char *url, - unsigned int flags, const char *options[], - struct ldb_module **module); - -struct ldb_backend_ops { - const char *name; - ldb_connect_fn connect_fn; -}; - -const char *ldb_default_modules_dir(void); - -int ldb_register_backend(const char *url_prefix, ldb_connect_fn); - -struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb); - -int ldb_module_send_entry(struct ldb_request *req, - struct ldb_message *msg, - struct ldb_control **ctrls); - -int ldb_module_send_referral(struct ldb_request *req, - char *ref); - -int ldb_module_done(struct ldb_request *req, - struct ldb_control **ctrls, - struct ldb_extended *response, - int error); - -int ldb_mod_register_control(struct ldb_module *module, const char *oid); - struct ldb_val ldb_binary_decode(void *mem_ctx, const char *str); diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c index 791cc75dc1..3901b9b436 100644 --- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c +++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c @@ -42,7 +42,7 @@ #include "includes.h" -#include "ldb_includes.h" +#include "ldb_module.h" #include "tevent.h" #include "libcli/ldap/ldap.h" @@ -70,8 +70,11 @@ struct ildb_context { static void ildb_request_done(struct ildb_context *ctx, struct ldb_control **ctrls, int error) { + struct ldb_context *ldb; struct ldb_reply *ares; + ldb = ldb_module_get_ctx(ctx->module); + ctx->done = true; if (ctx->req == NULL) { @@ -81,7 +84,7 @@ static void ildb_request_done(struct ildb_context *ctx, ares = talloc_zero(ctx->req, struct ldb_reply); if (!ares) { - ldb_oom(ctx->req->handle->ldb); + ldb_oom(ldb); ctx->req->callback(ctx->req, NULL); return; } @@ -163,17 +166,21 @@ failed: */ static int ildb_map_error(struct ldb_module *module, NTSTATUS status) { - struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private); + struct ildb_private *ildb; + struct ldb_context *ldb; + + ildb = talloc_get_type(ldb_module_get_private(module), struct ildb_private); + ldb = ldb_module_get_ctx(module); TALLOC_CTX *mem_ctx = talloc_new(ildb); if (NT_STATUS_IS_OK(status)) { return LDB_SUCCESS; } if (!mem_ctx) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ldb_set_errstring(module->ldb, + ldb_set_errstring(ldb, ldap_errstr(ildb->ldap, mem_ctx, status)); talloc_free(mem_ctx); if (NT_STATUS_IS_LDAP(status)) { @@ -196,6 +203,7 @@ static void ildb_request_timeout(struct tevent_context *ev, struct tevent_timer static void ildb_callback(struct ldap_request *req) { + struct ldb_context *ldb; struct ildb_context *ac; NTSTATUS status; struct ldap_SearchResEntry *search; @@ -209,6 +217,7 @@ static void ildb_callback(struct ldap_request *req) int i; ac = talloc_get_type(req->async.private_data, struct ildb_context); + ldb = ldb_module_get_ctx(ac->module); callback_failed = false; request_done = false; controls = NULL; @@ -285,7 +294,7 @@ static void ildb_callback(struct ldap_request *req) controls = talloc_steal(ac, msg->controls); if (msg->r.SearchResultDone.resultcode) { if (msg->r.SearchResultDone.errormessage) { - ldb_set_errstring(ac->module->ldb, msg->r.SearchResultDone.errormessage); + ldb_set_errstring(ldb, msg->r.SearchResultDone.errormessage); } } @@ -303,7 +312,7 @@ static void ildb_callback(struct ldap_request *req) search = &(msg->r.SearchResultEntry); - ldbmsg->dn = ldb_dn_new(ldbmsg, ac->module->ldb, search->dn); + ldbmsg->dn = ldb_dn_new(ldbmsg, ldb, search->dn); if ( ! ldb_dn_validate(ldbmsg->dn)) { ret = LDB_ERR_OPERATIONS_ERROR; break; @@ -368,21 +377,24 @@ static void ildb_callback(struct ldap_request *req) static int ildb_request_send(struct ildb_context *ac, struct ldap_message *msg) { + struct ldb_context *ldb; struct ldap_request *req; if (!ac) { return LDB_ERR_OPERATIONS_ERROR; } + ldb = ldb_module_get_ctx(ac->module); + req = ldap_request_send(ac->ildb->ldap, msg); if (req == NULL) { - ldb_set_errstring(ac->module->ldb, "async send request failed"); + ldb_set_errstring(ldb, "async send request failed"); return LDB_ERR_OPERATIONS_ERROR; } ac->ireq = talloc_steal(ac, req); if (!ac->ireq->conn) { - ldb_set_errstring(ac->module->ldb, "connection to remote LDAP server dropped?"); + ldb_set_errstring(ldb, "connection to remote LDAP server dropped?"); return LDB_ERR_OPERATIONS_ERROR; } @@ -405,23 +417,26 @@ static int ildb_request_send(struct ildb_context *ac, struct ldap_message *msg) */ static int ildb_search(struct ildb_context *ac) { + struct ldb_context *ldb; struct ldb_request *req = ac->req; struct ldap_message *msg; int n; + ldb = ldb_module_get_ctx(ac->module); + if (!req->callback || !req->context) { - ldb_set_errstring(ac->module->ldb, "Async interface called with NULL callback function or NULL context"); + ldb_set_errstring(ldb, "Async interface called with NULL callback function or NULL context"); return LDB_ERR_OPERATIONS_ERROR; } if (req->op.search.tree == NULL) { - ldb_set_errstring(ac->module->ldb, "Invalid expression parse tree"); + ldb_set_errstring(ldb, "Invalid expression parse tree"); return LDB_ERR_OPERATIONS_ERROR; } msg = new_ldap_message(req); if (msg == NULL) { - ldb_set_errstring(ac->module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } @@ -433,7 +448,7 @@ static int ildb_search(struct ildb_context *ac) msg->r.SearchRequest.basedn = ldb_dn_get_extended_linearized(msg, req->op.search.base, 0); } if (msg->r.SearchRequest.basedn == NULL) { - ldb_set_errstring(ac->module->ldb, "Unable to determine baseDN"); + ldb_set_errstring(ldb, "Unable to determine baseDN"); talloc_free(msg); return LDB_ERR_OPERATIONS_ERROR; } @@ -659,21 +674,23 @@ static bool ildb_dn_is_special(struct ldb_request *req) static int ildb_handle_request(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ildb_private *ildb; struct ildb_context *ac; struct tevent_timer *te; int ret; - ildb = talloc_get_type(module->private_data, struct ildb_private); + ildb = talloc_get_type(ldb_module_get_private(module), struct ildb_private); + ldb = ldb_module_get_ctx(module); if (req->starttime == 0 || req->timeout == 0) { - ldb_set_errstring(module->ldb, "Invalid timeout settings"); + ldb_set_errstring(ldb, "Invalid timeout settings"); return LDB_ERR_TIME_LIMIT_EXCEEDED; } ac = talloc_zero(req, struct ildb_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } @@ -743,22 +760,15 @@ static int ildb_connect(struct ldb_context *ldb, const char *url, NTSTATUS status; struct cli_credentials *creds; - module = talloc(ldb, struct ldb_module); - if (!module) { - ldb_oom(ldb); - return -1; - } - talloc_set_name_const(module, "ldb_ildap backend"); - module->ldb = ldb; - module->prev = module->next = NULL; - module->ops = &ildb_ops; + module = ldb_module_new(ldb, ldb, "ldb_ildap backend", &ildb_ops); + if (!module) return -1; ildb = talloc(module, struct ildb_private); if (!ildb) { ldb_oom(ldb); goto failed; } - module->private_data = ildb; + ldb_module_set_private(module, ildb); ildb->event_ctx = ldb_get_event_context(ldb); diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c index 8e053818e5..e1fcdb1353 100644 --- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c +++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c @@ -38,7 +38,7 @@ * author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_module.h" #define LDAP_DEPRECATED 1 #include @@ -195,6 +195,7 @@ static int lldb_add_msg_attr(struct ldb_context *ldb, */ static int lldb_search(struct lldb_context *lldb_ac) { + struct ldb_context *ldb; struct lldb_private *lldb = lldb_ac->lldb; struct ldb_module *module = lldb_ac->module; struct ldb_request *req = lldb_ac->req; @@ -204,21 +205,23 @@ static int lldb_search(struct lldb_context *lldb_ac) char *expression; int ret; + ldb = ldb_module_get_ctx(module); + if (!req->callback || !req->context) { - ldb_set_errstring(module->ldb, "Async interface called with NULL callback function or NULL context"); + ldb_set_errstring(ldb, "Async interface called with NULL callback function or NULL context"); return LDB_ERR_OPERATIONS_ERROR; } if (req->op.search.tree == NULL) { - ldb_set_errstring(module->ldb, "Invalid expression parse tree"); + ldb_set_errstring(ldb, "Invalid expression parse tree"); return LDB_ERR_OPERATIONS_ERROR; } if (req->controls != NULL) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Controls are not yet supported by ldb_ldap backend!\n"); + ldb_debug(ldb, LDB_DEBUG_WARNING, "Controls are not yet supported by ldb_ldap backend!\n"); } - req->handle->state = LDB_ASYNC_PENDING; + ldb_request_set_state(req, LDB_ASYNC_PENDING); search_base = ldb_dn_alloc_linearized(lldb_ac, req->op.search.base); if (req->op.search.base == NULL) { @@ -259,7 +262,7 @@ static int lldb_search(struct lldb_context *lldb_ac) &lldb_ac->msgid); if (ret != LDAP_SUCCESS) { - ldb_set_errstring(module->ldb, ldap_err2string(ret)); + ldb_set_errstring(ldb, ldap_err2string(ret)); } return lldb_ldap_to_ldb(ret); @@ -270,6 +273,7 @@ static int lldb_search(struct lldb_context *lldb_ac) */ static int lldb_add(struct lldb_context *lldb_ac) { + struct ldb_context *ldb; struct lldb_private *lldb = lldb_ac->lldb; struct ldb_module *module = lldb_ac->module; struct ldb_request *req = lldb_ac->req; @@ -277,7 +281,9 @@ static int lldb_add(struct lldb_context *lldb_ac) char *dn; int ret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_module_get_ctx(module); + + ldb_request_set_state(req, LDB_ASYNC_PENDING); mods = lldb_msg_to_mods(lldb_ac, req->op.add.message, 0); if (mods == NULL) { @@ -295,7 +301,7 @@ static int lldb_add(struct lldb_context *lldb_ac) &lldb_ac->msgid); if (ret != LDAP_SUCCESS) { - ldb_set_errstring(module->ldb, ldap_err2string(ret)); + ldb_set_errstring(ldb, ldap_err2string(ret)); } return lldb_ldap_to_ldb(ret); @@ -306,6 +312,7 @@ static int lldb_add(struct lldb_context *lldb_ac) */ static int lldb_modify(struct lldb_context *lldb_ac) { + struct ldb_context *ldb; struct lldb_private *lldb = lldb_ac->lldb; struct ldb_module *module = lldb_ac->module; struct ldb_request *req = lldb_ac->req; @@ -313,7 +320,9 @@ static int lldb_modify(struct lldb_context *lldb_ac) char *dn; int ret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_module_get_ctx(module); + + ldb_request_set_state(req, LDB_ASYNC_PENDING); mods = lldb_msg_to_mods(lldb_ac, req->op.mod.message, 1); if (mods == NULL) { @@ -331,7 +340,7 @@ static int lldb_modify(struct lldb_context *lldb_ac) &lldb_ac->msgid); if (ret != LDAP_SUCCESS) { - ldb_set_errstring(module->ldb, ldap_err2string(ret)); + ldb_set_errstring(ldb, ldap_err2string(ret)); } return lldb_ldap_to_ldb(ret); @@ -342,13 +351,16 @@ static int lldb_modify(struct lldb_context *lldb_ac) */ static int lldb_delete(struct lldb_context *lldb_ac) { + struct ldb_context *ldb; struct lldb_private *lldb = lldb_ac->lldb; struct ldb_module *module = lldb_ac->module; struct ldb_request *req = lldb_ac->req; char *dnstr; int ret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_module_get_ctx(module); + + ldb_request_set_state(req, LDB_ASYNC_PENDING); dnstr = ldb_dn_alloc_linearized(lldb_ac, req->op.del.dn); @@ -358,7 +370,7 @@ static int lldb_delete(struct lldb_context *lldb_ac) &lldb_ac->msgid); if (ret != LDAP_SUCCESS) { - ldb_set_errstring(module->ldb, ldap_err2string(ret)); + ldb_set_errstring(ldb, ldap_err2string(ret)); } return lldb_ldap_to_ldb(ret); @@ -369,6 +381,7 @@ static int lldb_delete(struct lldb_context *lldb_ac) */ static int lldb_rename(struct lldb_context *lldb_ac) { + struct ldb_context *ldb; struct lldb_private *lldb = lldb_ac->lldb; struct ldb_module *module = lldb_ac->module; struct ldb_request *req = lldb_ac->req; @@ -377,7 +390,9 @@ static int lldb_rename(struct lldb_context *lldb_ac) char *parentdn; int ret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_module_get_ctx(module); + + ldb_request_set_state(req, LDB_ASYNC_PENDING); old_dn = ldb_dn_alloc_linearized(lldb_ac, req->op.rename.olddn); if (old_dn == NULL) { @@ -401,7 +416,7 @@ static int lldb_rename(struct lldb_context *lldb_ac) &lldb_ac->msgid); if (ret != LDAP_SUCCESS) { - ldb_set_errstring(module->ldb, ldap_err2string(ret)); + ldb_set_errstring(ldb, ldap_err2string(ret)); } return lldb_ldap_to_ldb(ret); @@ -428,14 +443,17 @@ static int lldb_del_trans(struct ldb_module *module) return LDB_SUCCESS; } -void lldb_request_done(struct ldb_request *req, +void lldb_request_done(struct lldb_context *ac, struct ldb_control **ctrls, int error) { + struct ldb_request *req; struct ldb_reply *ares; + req = ac->req; + ares = talloc_zero(req, struct ldb_reply); if (!ares) { - ldb_oom(req->handle->ldb); + ldb_oom(ldb_module_get_ctx(ac->module)); req->callback(req, NULL); return; } @@ -451,6 +469,7 @@ void lldb_request_done(struct ldb_request *req, */ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) { + struct ldb_context *ldb; struct lldb_private *lldb = ac->lldb; LDAPControl **serverctrlsp = NULL; char **referralsp = NULL; @@ -466,6 +485,8 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) int ret; int i; + ldb = ldb_module_get_ctx(ac->module); + type = ldap_msgtype(result); callback_failed = false; request_done = false; @@ -490,7 +511,7 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) ret = LDB_ERR_OPERATIONS_ERROR; break; } - ldbmsg->dn = ldb_dn_new(ldbmsg, ac->module->ldb, dn); + ldbmsg->dn = ldb_dn_new(ldbmsg, ldb, dn); if ( ! ldb_dn_validate(ldbmsg->dn)) { talloc_free(ldbmsg); ret = LDB_ERR_OPERATIONS_ERROR; @@ -509,7 +530,7 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) bval = ldap_get_values_len(lldb->ldap, msg, attr); if (bval) { - lldb_add_msg_attr(ac->module->ldb, ldbmsg, attr, bval); + lldb_add_msg_attr(ldb, ldbmsg, attr, bval); ldap_value_free_len(bval); } } @@ -595,7 +616,7 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result) } if (request_done) { - lldb_request_done(ac->req, ac->controls, ret); + lldb_request_done(ac, ac->controls, ret); lret = true; goto free_and_return; } @@ -606,7 +627,7 @@ free_and_return: if (matcheddnp) ldap_memfree(matcheddnp); if (errmsgp && *errmsgp) { - ldb_set_errstring(ac->module->ldb, errmsgp); + ldb_set_errstring(ldb, errmsgp); } if (errmsgp) { ldap_memfree(errmsgp); @@ -627,7 +648,7 @@ static void lldb_timeout(struct tevent_context *ev, struct lldb_context *ac; ac = talloc_get_type(private_data, struct lldb_context); - lldb_request_done(ac->req, NULL, LDB_ERR_TIME_LIMIT_EXCEEDED); + lldb_request_done(ac, NULL, LDB_ERR_TIME_LIMIT_EXCEEDED); } static void lldb_callback(struct tevent_context *ev, @@ -644,7 +665,7 @@ static void lldb_callback(struct tevent_context *ev, ac = talloc_get_type(private_data, struct lldb_context); if (!ac->msgid) { - lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR); + lldb_request_done(ac, NULL, LDB_ERR_OPERATIONS_ERROR); return; } @@ -655,7 +676,7 @@ static void lldb_callback(struct tevent_context *ev, goto respin; } if (lret == -1) { - lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR); + lldb_request_done(ac, NULL, LDB_ERR_OPERATIONS_ERROR); return; } @@ -668,9 +689,9 @@ static void lldb_callback(struct tevent_context *ev, respin: tv.tv_sec = 0; tv.tv_usec = 100; - lte = event_add_timed(ev, ac, tv, lldb_callback, ac); + lte = tevent_add_timer(ev, ac, tv, lldb_callback, ac); if (NULL == lte) { - lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR); + lldb_request_done(ac, NULL, LDB_ERR_OPERATIONS_ERROR); } } @@ -709,11 +730,12 @@ static void lldb_auto_done_callback(struct tevent_context *ev, struct lldb_context *ac; ac = talloc_get_type(private_data, struct lldb_context); - lldb_request_done(ac->req, NULL, LDB_SUCCESS); + lldb_request_done(ac, NULL, LDB_SUCCESS); } static int lldb_handle_request(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct lldb_private *lldb; struct lldb_context *ac; struct tevent_context *ev; @@ -721,21 +743,22 @@ static int lldb_handle_request(struct ldb_module *module, struct ldb_request *re struct timeval tv; int ret; - lldb = talloc_get_type(module->private_data, struct lldb_private); + lldb = talloc_get_type(ldb_module_get_private(module), struct lldb_private); + ldb = ldb_module_get_ctx(module); if (req->starttime == 0 || req->timeout == 0) { - ldb_set_errstring(module->ldb, "Invalid timeout settings"); + ldb_set_errstring(ldb, "Invalid timeout settings"); return LDB_ERR_TIME_LIMIT_EXCEEDED; } - ev = ldb_get_event_context(module->ldb); + ev = ldb_get_event_context(ldb); if (NULL == ev) { return LDB_ERR_OPERATIONS_ERROR; } - ac = talloc_zero(module->ldb, struct lldb_context); + ac = talloc_zero(ldb, struct lldb_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } @@ -747,7 +770,7 @@ static int lldb_handle_request(struct ldb_module *module, struct ldb_request *re if (lldb_dn_is_special(req)) { tv.tv_sec = 0; tv.tv_usec = 0; - te = event_add_timed(ev, ac, tv, + te = tevent_add_timer(ev, ac, tv, lldb_auto_done_callback, ac); if (NULL == te) { return LDB_ERR_OPERATIONS_ERROR; @@ -779,13 +802,13 @@ static int lldb_handle_request(struct ldb_module *module, struct ldb_request *re } if (ret != LDB_SUCCESS) { - lldb_request_done(req, NULL, ret); + lldb_request_done(ac, NULL, ret); return ret; } tv.tv_sec = 0; tv.tv_usec = 0; - te = event_add_timed(ev, ac, tv, lldb_callback, ac); + te = tevent_add_timer(ev, ac, tv, lldb_callback, ac); if (NULL == te) { return LDB_ERR_OPERATIONS_ERROR; } @@ -793,7 +816,7 @@ static int lldb_handle_request(struct ldb_module *module, struct ldb_request *re tv.tv_sec = req->starttime + req->timeout; tv.tv_usec = 0; - te = event_add_timed(ev, ac, tv, lldb_timeout, ac); + te = tevent_add_timer(ev, ac, tv, lldb_timeout, ac); if (NULL == te) { return LDB_ERR_OPERATIONS_ERROR; } @@ -835,24 +858,15 @@ static int lldb_connect(struct ldb_context *ldb, int version = 3; int ret; - module = talloc(ldb, struct ldb_module); - if (module == NULL) { - ldb_oom(ldb); - talloc_free(lldb); - return -1; - } - talloc_set_name_const(module, "ldb_ldap backend"); - module->ldb = ldb; - module->prev = module->next = NULL; - module->ops = &lldb_ops; + module = ldb_module_new(ldb, ldb, "ldb_ldap backend", &lldb_ops); + if (!module) return -1; - lldb = talloc(module, struct lldb_private); + lldb = talloc_zero(module, struct lldb_private); if (!lldb) { ldb_oom(ldb); goto failed; } - module->private_data = lldb; - lldb->ldap = NULL; + ldb_module_set_private(module, lldb); ret = ldap_initialize(&lldb->ldap, url); if (ret != LDAP_SUCCESS) { diff --git a/source4/lib/ldb/ldb_map/ldb_map.c b/source4/lib/ldb/ldb_map/ldb_map.c index 72d8378a07..ea2bfd1dc1 100644 --- a/source4/lib/ldb/ldb_map/ldb_map.c +++ b/source4/lib/ldb/ldb_map/ldb_map.c @@ -35,7 +35,7 @@ * Author: Jelmer Vernooij, Martin Kuehl */ -#include "ldb_includes.h" +#include "ldb_module.h" #include "ldb_map.h" #include "ldb_map_private.h" @@ -102,7 +102,7 @@ /* Extract mappings from private data. */ const struct ldb_map_context *map_get_context(struct ldb_module *module) { - const struct map_private *data = talloc_get_type(module->private_data, struct map_private); + const struct map_private *data = talloc_get_type(ldb_module_get_private(module), struct map_private); return data->context; } @@ -110,11 +110,14 @@ const struct ldb_map_context *map_get_context(struct ldb_module *module) struct map_context *map_init_context(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct map_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct map_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return NULL; } @@ -202,8 +205,11 @@ static struct ldb_dn *ldb_dn_rebase_remote(void *mem_ctx, const struct ldb_map_c int ldb_next_remote_request(struct ldb_module *module, struct ldb_request *request) { const struct ldb_map_context *data = map_get_context(module); + struct ldb_context *ldb; struct ldb_message *msg; + ldb = ldb_module_get_ctx(module); + switch (request->operation) { case LDB_SEARCH: if (request->op.search.base) { @@ -236,7 +242,7 @@ int ldb_next_remote_request(struct ldb_module *module, struct ldb_request *reque break; default: - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "Invalid remote request!\n"); return LDB_ERR_OPERATIONS_ERROR; } @@ -462,6 +468,7 @@ bool ldb_dn_check_local(struct ldb_module *module, struct ldb_dn *dn) struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn) { const struct ldb_map_context *data = map_get_context(module); + struct ldb_context *ldb; struct ldb_dn *newdn; const struct ldb_map_attribute *map; enum ldb_map_attr_type map_type; @@ -473,6 +480,8 @@ struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct return NULL; } + ldb = ldb_module_get_ctx(module); + newdn = ldb_dn_copy(mem_ctx, dn); if (newdn == NULL) { map_oom(module); @@ -493,14 +502,14 @@ struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct switch (map_type) { case MAP_IGNORE: case MAP_GENERATE: - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "MAP_IGNORE/MAP_GENERATE attribute '%s' " "used in DN!\n", ldb_dn_get_component_name(dn, i)); goto failed; case MAP_CONVERT: if (map->u.convert.convert_local == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "'convert_local' not set for attribute '%s' " "used in DN!\n", ldb_dn_get_component_name(dn, i)); goto failed; @@ -534,6 +543,7 @@ failed: struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn) { const struct ldb_map_context *data = map_get_context(module); + struct ldb_context *ldb; struct ldb_dn *newdn; const struct ldb_map_attribute *map; enum ldb_map_attr_type map_type; @@ -545,6 +555,8 @@ struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struc return NULL; } + ldb = ldb_module_get_ctx(module); + newdn = ldb_dn_copy(mem_ctx, dn); if (newdn == NULL) { map_oom(module); @@ -565,14 +577,14 @@ struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struc switch (map_type) { case MAP_IGNORE: case MAP_GENERATE: - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "MAP_IGNORE/MAP_GENERATE attribute '%s' " "used in DN!\n", ldb_dn_get_component_name(dn, i)); goto failed; case MAP_CONVERT: if (map->u.convert.convert_remote == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "'convert_remote' not set for attribute '%s' " "used in DN!\n", ldb_dn_get_component_name(dn, i)); goto failed; @@ -623,10 +635,13 @@ struct ldb_dn *ldb_dn_map_rebase_remote(struct ldb_module *module, void *mem_ctx /* Map a DN contained in an ldb value into the remote partition. */ static struct ldb_val ldb_dn_convert_local(struct ldb_module *module, void *mem_ctx, const struct ldb_val *val) { + struct ldb_context *ldb; struct ldb_dn *dn, *newdn; struct ldb_val newval; - dn = ldb_dn_from_ldb_val(mem_ctx, module->ldb, val); + ldb = ldb_module_get_ctx(module); + + dn = ldb_dn_from_ldb_val(mem_ctx, ldb, val); if (! ldb_dn_validate(dn)) { newval.length = 0; newval.data = NULL; @@ -649,10 +664,13 @@ static struct ldb_val ldb_dn_convert_local(struct ldb_module *module, void *mem_ /* Map a DN contained in an ldb value into the local partition. */ static struct ldb_val ldb_dn_convert_remote(struct ldb_module *module, void *mem_ctx, const struct ldb_val *val) { + struct ldb_context *ldb; struct ldb_dn *dn, *newdn; struct ldb_val newval; - dn = ldb_dn_from_ldb_val(mem_ctx, module->ldb, val); + ldb = ldb_module_get_ctx(module); + + dn = ldb_dn_from_ldb_val(mem_ctx, ldb, val); if (! ldb_dn_validate(dn)) { newval.length = 0; newval.data = NULL; @@ -693,11 +711,14 @@ static struct ldb_val map_objectclass_convert_local(struct ldb_module *module, v static void map_objectclass_generate_remote(struct ldb_module *module, const char *local_attr, const struct ldb_message *old, struct ldb_message *remote, struct ldb_message *local) { const struct ldb_map_context *data = map_get_context(module); + struct ldb_context *ldb; struct ldb_message_element *el, *oc; struct ldb_val val; bool found_extensibleObject = false; int i; + ldb = ldb_module_get_ctx(module); + /* Find old local objectClass */ oc = ldb_msg_find_element(old, "objectClass"); if (oc == NULL) { @@ -707,7 +728,7 @@ static void map_objectclass_generate_remote(struct ldb_module *module, const cha /* Prepare new element */ el = talloc_zero(remote, struct ldb_message_element); if (el == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return; /* TODO: fail? */ } @@ -716,7 +737,7 @@ static void map_objectclass_generate_remote(struct ldb_module *module, const cha el->values = talloc_array(el, struct ldb_val, el->num_values); if (el->values == NULL) { talloc_free(el); - ldb_oom(module->ldb); + ldb_oom(ldb); return; /* TODO: fail? */ } @@ -766,10 +787,13 @@ static struct ldb_val map_objectclass_convert_remote(struct ldb_module *module, static struct ldb_message_element *map_objectclass_generate_local(struct ldb_module *module, void *mem_ctx, const char *local_attr, const struct ldb_message *remote) { const struct ldb_map_context *data = map_get_context(module); + struct ldb_context *ldb; struct ldb_message_element *el, *oc; struct ldb_val val; int i; + ldb = ldb_module_get_ctx(module); + /* Find old remote objectClass */ oc = ldb_msg_find_element(remote, "objectClass"); if (oc == NULL) { @@ -779,7 +803,7 @@ static struct ldb_message_element *map_objectclass_generate_local(struct ldb_mod /* Prepare new element */ el = talloc_zero(mem_ctx, struct ldb_message_element); if (el == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } @@ -788,7 +812,7 @@ static struct ldb_message_element *map_objectclass_generate_local(struct ldb_mod el->values = talloc_array(el, struct ldb_val, el->num_values); if (el->values == NULL) { talloc_free(el); - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } @@ -809,7 +833,7 @@ static struct ldb_message_element *map_objectclass_generate_local(struct ldb_mod el->values = talloc_realloc(el, el->values, struct ldb_val, el->num_values); if (el->values == NULL) { talloc_free(el); - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } } @@ -847,9 +871,12 @@ static int map_objectclass_convert_operator(struct ldb_module *module, void *mem struct ldb_request *map_search_base_req(struct map_context *ac, struct ldb_dn *dn, const char * const *attrs, const struct ldb_parse_tree *tree, void *context, ldb_map_callback_t callback) { const struct ldb_parse_tree *search_tree; + struct ldb_context *ldb; struct ldb_request *req; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (tree) { search_tree = tree; } else { @@ -859,7 +886,7 @@ struct ldb_request *map_search_base_req(struct map_context *ac, struct ldb_dn *d } } - ret = ldb_build_search_req_ex(&req, ac->module->ldb, ac, + ret = ldb_build_search_req_ex(&req, ldb, ac, dn, LDB_SCOPE_BASE, search_tree, attrs, NULL, @@ -879,11 +906,14 @@ struct ldb_request *map_build_fixup_req(struct map_context *ac, void *context, ldb_map_callback_t callback) { + struct ldb_context *ldb; struct ldb_request *req; struct ldb_message *msg; const char *dn; int ret; + ldb = ldb_module_get_ctx(ac->module); + /* Prepare message */ msg = ldb_msg_new(ac); if (msg == NULL) { @@ -905,7 +935,7 @@ struct ldb_request *map_build_fixup_req(struct map_context *ac, } /* Prepare request */ - ret = ldb_build_mod_req(&req, ac->module->ldb, + ret = ldb_build_mod_req(&req, ldb, ac, msg, NULL, context, callback, ac->req); @@ -961,6 +991,7 @@ static const struct ldb_map_attribute objectclass_attribute_map = { static int map_init_dns(struct ldb_module *module, struct ldb_map_context *data, const char *name) { static const char * const attrs[] = { MAP_DN_FROM, MAP_DN_TO, NULL }; + struct ldb_context *ldb; struct ldb_dn *dn; struct ldb_message *msg; struct ldb_result *res; @@ -972,34 +1003,36 @@ static int map_init_dns(struct ldb_module *module, struct ldb_map_context *data, return LDB_SUCCESS; } - dn = ldb_dn_new_fmt(data, module->ldb, "%s=%s", MAP_DN_NAME, name); + ldb = ldb_module_get_ctx(module); + + dn = ldb_dn_new_fmt(data, ldb, "%s=%s", MAP_DN_NAME, name); if ( ! ldb_dn_validate(dn)) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "Failed to construct '%s' DN!\n", MAP_DN_NAME); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_search(module->ldb, data, &res, dn, LDB_SCOPE_BASE, attrs, NULL); + ret = ldb_search(ldb, data, &res, dn, LDB_SCOPE_BASE, attrs, NULL); talloc_free(dn); if (ret != LDB_SUCCESS) { return ret; } if (res->count == 0) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "No results for '%s=%s'!\n", MAP_DN_NAME, name); talloc_free(res); return LDB_ERR_CONSTRAINT_VIOLATION; } if (res->count > 1) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "Too many results for '%s=%s'!\n", MAP_DN_NAME, name); talloc_free(res); return LDB_ERR_CONSTRAINT_VIOLATION; } msg = res->msgs[0]; - data->local_base_dn = ldb_msg_find_attr_as_dn(module->ldb, data, msg, MAP_DN_FROM); - data->remote_base_dn = ldb_msg_find_attr_as_dn(module->ldb, data, msg, MAP_DN_TO); + data->local_base_dn = ldb_msg_find_attr_as_dn(ldb, data, msg, MAP_DN_FROM); + data->remote_base_dn = ldb_msg_find_attr_as_dn(ldb, data, msg, MAP_DN_TO); talloc_free(res); return LDB_SUCCESS; @@ -1075,7 +1108,7 @@ _PUBLIC_ int ldb_map_init(struct ldb_module *module, const struct ldb_map_attrib return LDB_ERR_OPERATIONS_ERROR; } - module->private_data = data; + ldb_module_set_private(module, data); data->context = talloc_zero(data, struct ldb_map_context); if (!data->context) { diff --git a/source4/lib/ldb/ldb_map/ldb_map_inbound.c b/source4/lib/ldb/ldb_map/ldb_map_inbound.c index 96605f23eb..e915a5f46a 100644 --- a/source4/lib/ldb/ldb_map/ldb_map_inbound.c +++ b/source4/lib/ldb/ldb_map/ldb_map_inbound.c @@ -24,7 +24,7 @@ */ -#include "ldb_includes.h" +#include "ldb_module.h" #include "ldb_map.h" #include "ldb_map_private.h" @@ -69,10 +69,11 @@ static int ldb_msg_el_partition(struct ldb_module *module, struct ldb_message *l const struct ldb_map_context *data = map_get_context(module); const struct ldb_map_attribute *map = map_attr_find_local(data, attr_name); struct ldb_message_element *el=NULL; + struct ldb_context *ldb = ldb_module_get_ctx(module); /* Unknown attribute: ignore */ if (map == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: " "Not mapping attribute '%s': no mapping found\n", old->name); goto local; @@ -84,7 +85,7 @@ static int ldb_msg_el_partition(struct ldb_module *module, struct ldb_message *l case MAP_CONVERT: if (map->u.convert.convert_local == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: " "Not mapping attribute '%s': " "'convert_local' not set\n", map->local_name); @@ -98,7 +99,7 @@ static int ldb_msg_el_partition(struct ldb_module *module, struct ldb_message *l case MAP_GENERATE: if (map->u.generate.generate_remote == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: " "Not mapping attribute '%s': " "'generate_remote' not set\n", map->local_name); @@ -158,12 +159,15 @@ static bool ldb_msg_check_remote(struct ldb_module *module, const struct ldb_mes static int ldb_msg_partition(struct ldb_module *module, struct ldb_message *local, struct ldb_message *remote, const struct ldb_message *msg) { /* const char * const names[]; */ + struct ldb_context *ldb; int i, ret; + ldb = ldb_module_get_ctx(module); + for (i = 0; i < msg->num_elements; i++) { /* Skip 'IS_MAPPED' */ if (ldb_attr_cmp(msg->elements[i].name, IS_MAPPED) == 0) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: " "Skipping attribute '%s'\n", msg->elements[i].name); continue; @@ -195,10 +199,12 @@ static int map_rename_local_callback(struct ldb_request *req, /* Store the DN of a single search result in context. */ static int map_search_self_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct map_context *ac; int ret; ac = talloc_get_type(req->context, struct map_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -214,7 +220,7 @@ static int map_search_self_callback(struct ldb_request *req, struct ldb_reply *a case LDB_REPLY_ENTRY: /* We have already found a remote DN */ if (ac->local_dn) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Too many results!"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -284,10 +290,12 @@ static int map_search_self_req(struct ldb_request **req, static int map_op_local_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct map_context *ac; int ret; ac = talloc_get_type(req->context, struct map_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -299,7 +307,7 @@ static int map_op_local_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(req->handle->ldb, "Invalid reply type!"); + ldb_set_errstring(ldb, "Invalid reply type!"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -317,9 +325,11 @@ static int map_op_local_callback(struct ldb_request *req, static int map_op_remote_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct map_context *ac; ac = talloc_get_type(req->context, struct map_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -331,7 +341,7 @@ static int map_op_remote_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(req->handle->ldb, "Invalid reply type!"); + ldb_set_errstring(ldb, "Invalid reply type!"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -350,11 +360,14 @@ static int map_op_remote_callback(struct ldb_request *req, int map_add(struct ldb_module *module, struct ldb_request *req) { const struct ldb_message *msg = req->op.add.message; + struct ldb_context *ldb; struct map_context *ac; struct ldb_message *remote_msg; const char *dn; int ret; + ldb = ldb_module_get_ctx(module); + /* Do not manipulate our control entries */ if (ldb_dn_is_special(msg->dn)) { return ldb_next_request(module, req); @@ -397,7 +410,7 @@ int map_add(struct ldb_module *module, struct ldb_request *req) ldb_msg_partition(module, ac->local_msg, remote_msg, msg); /* Prepare the remote operation */ - ret = ldb_build_add_req(&ac->remote_req, module->ldb, + ret = ldb_build_add_req(&ac->remote_req, ldb, ac, remote_msg, req->controls, ac, map_op_remote_callback, @@ -426,10 +439,13 @@ int map_add(struct ldb_module *module, struct ldb_request *req) static int map_add_do_local(struct map_context *ac) { struct ldb_request *local_req; + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(ac->module); + /* Prepare the local operation */ - ret = ldb_build_add_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_add_req(&local_req, ldb, ac, ac->local_msg, ac->req->controls, ac, @@ -451,9 +467,12 @@ int map_modify(struct ldb_module *module, struct ldb_request *req) const struct ldb_message *msg = req->op.mod.message; struct ldb_request *search_req; struct ldb_message *remote_msg; + struct ldb_context *ldb; struct map_context *ac; int ret; + ldb = ldb_module_get_ctx(module); + /* Do not manipulate our control entries */ if (ldb_dn_is_special(msg->dn)) { return ldb_next_request(module, req); @@ -498,7 +517,7 @@ int map_modify(struct ldb_module *module, struct ldb_request *req) ldb_msg_partition(module, ac->local_msg, remote_msg, msg); /* Prepare the remote operation */ - ret = ldb_build_mod_req(&ac->remote_req, module->ldb, + ret = ldb_build_mod_req(&ac->remote_req, ldb, ac, remote_msg, req->controls, ac, map_op_remote_callback, @@ -526,9 +545,12 @@ int map_modify(struct ldb_module *module, struct ldb_request *req) static int map_modify_do_local(struct map_context *ac) { struct ldb_request *local_req; + struct ldb_context *ldb; char *dn; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (ac->local_dn == NULL) { /* No local record present, add it instead */ /* Add local 'IS_MAPPED' */ @@ -544,7 +566,7 @@ static int map_modify_do_local(struct map_context *ac) } /* Prepare the local operation */ - ret = ldb_build_add_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_add_req(&local_req, ldb, ac, ac->local_msg, ac->req->controls, ac, @@ -555,7 +577,7 @@ static int map_modify_do_local(struct map_context *ac) } } else { /* Prepare the local operation */ - ret = ldb_build_mod_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_mod_req(&local_req, ldb, ac, ac->local_msg, ac->req->controls, ac, @@ -577,9 +599,12 @@ static int map_modify_do_local(struct map_context *ac) int map_delete(struct ldb_module *module, struct ldb_request *req) { struct ldb_request *search_req; + struct ldb_context *ldb; struct map_context *ac; int ret; + ldb = ldb_module_get_ctx(module); + /* Do not manipulate our control entries */ if (ldb_dn_is_special(req->op.del.dn)) { return ldb_next_request(module, req); @@ -598,7 +623,7 @@ int map_delete(struct ldb_module *module, struct ldb_request *req) } /* Prepare the remote operation */ - ret = ldb_build_del_req(&ac->remote_req, module->ldb, ac, + ret = ldb_build_del_req(&ac->remote_req, ldb, ac, ldb_dn_map_local(module, ac, req->op.del.dn), req->controls, ac, @@ -628,8 +653,11 @@ int map_delete(struct ldb_module *module, struct ldb_request *req) static int map_delete_do_local(struct map_context *ac) { struct ldb_request *local_req; + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(ac->module); + /* No local record, continue remotely */ if (ac->local_dn == NULL) { /* Do the remote request. */ @@ -637,7 +665,7 @@ static int map_delete_do_local(struct map_context *ac) } /* Prepare the local operation */ - ret = ldb_build_del_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_del_req(&local_req, ldb, ac, ac->req->op.del.dn, ac->req->controls, ac, @@ -657,9 +685,12 @@ static int map_delete_do_local(struct map_context *ac) int map_rename(struct ldb_module *module, struct ldb_request *req) { struct ldb_request *search_req; + struct ldb_context *ldb; struct map_context *ac; int ret; + ldb = ldb_module_get_ctx(module); + /* Do not manipulate our control entries */ if (ldb_dn_is_special(req->op.rename.olddn)) { return ldb_next_request(module, req); @@ -685,7 +716,7 @@ int map_rename(struct ldb_module *module, struct ldb_request *req) } /* Prepare the remote operation */ - ret = ldb_build_rename_req(&ac->remote_req, module->ldb, ac, + ret = ldb_build_rename_req(&ac->remote_req, ldb, ac, ldb_dn_map_local(module, ac, req->op.rename.olddn), ldb_dn_map_local(module, ac, req->op.rename.newdn), req->controls, @@ -715,8 +746,11 @@ int map_rename(struct ldb_module *module, struct ldb_request *req) static int map_rename_do_local(struct map_context *ac) { struct ldb_request *local_req; + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(ac->module); + /* No local record, continue remotely */ if (ac->local_dn == NULL) { /* Do the remote request. */ @@ -724,7 +758,7 @@ static int map_rename_do_local(struct map_context *ac) } /* Prepare the local operation */ - ret = ldb_build_rename_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_rename_req(&local_req, ldb, ac, ac->req->op.rename.olddn, ac->req->op.rename.newdn, ac->req->controls, @@ -741,10 +775,12 @@ static int map_rename_do_local(struct map_context *ac) static int map_rename_local_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct map_context *ac; int ret; ac = talloc_get_type(req->context, struct map_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -756,7 +792,7 @@ static int map_rename_local_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(req->handle->ldb, "Invalid reply type!"); + ldb_set_errstring(ldb, "Invalid reply type!"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } diff --git a/source4/lib/ldb/ldb_map/ldb_map_outbound.c b/source4/lib/ldb/ldb_map/ldb_map_outbound.c index 5588eaaf46..327fa92f8d 100644 --- a/source4/lib/ldb/ldb_map/ldb_map_outbound.c +++ b/source4/lib/ldb/ldb_map/ldb_map_outbound.c @@ -25,7 +25,7 @@ */ -#include "ldb_includes.h" +#include "ldb_module.h" #include "ldb_map.h" #include "ldb_map_private.h" @@ -264,6 +264,9 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local const struct ldb_map_attribute *map; struct ldb_message_element *old, *el=NULL; const char *remote_name = NULL; + struct ldb_context *ldb; + + ldb = ldb_module_get_ctx(module); /* We handle wildcards in ldb_msg_el_merge_wildcard */ if (ldb_attr_cmp(attr_name, "*") == 0) { @@ -300,7 +303,7 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local case MAP_CONVERT: if (map->u.convert.convert_remote == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "Skipping attribute '%s': " "'convert_remote' not set\n", attr_name); @@ -319,7 +322,7 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local case MAP_GENERATE: if (map->u.generate.generate_local == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: " "Skipping attribute '%s': " "'generate_local' not set\n", attr_name); @@ -869,6 +872,9 @@ static int map_subtree_collect_remote(struct ldb_module *module, void *mem_ctx, { const struct ldb_map_context *data = map_get_context(module); const struct ldb_map_attribute *map; + struct ldb_context *ldb; + + ldb = ldb_module_get_ctx(module); if (tree == NULL) { return 0; @@ -893,7 +899,7 @@ static int map_subtree_collect_remote(struct ldb_module *module, void *mem_ctx, } if (map->type == MAP_GENERATE) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: " "Skipping attribute '%s': " "'convert_operator' not set\n", tree->u.equality.attr); @@ -1045,14 +1051,17 @@ int map_return_entry(struct map_context *ac, struct ldb_reply *ares) { struct ldb_message_element *el; const char * const *attrs; + struct ldb_context *ldb; int i; + ldb = ldb_module_get_ctx(ac->module); + /* Merged result doesn't match original query, skip */ - if (!ldb_match_msg(ac->module->ldb, ares->message, + if (!ldb_match_msg(ldb, ares->message, ac->req->op.search.tree, ac->req->op.search.base, ac->req->op.search.scope)) { - ldb_debug(ac->module->ldb, LDB_DEBUG_TRACE, "ldb_map: " + ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_map: " "Skipping record '%s': " "doesn't match original search\n", ldb_dn_get_linearized(ares->message->dn)); @@ -1086,13 +1095,17 @@ int map_search(struct ldb_module *module, struct ldb_request *req) struct ldb_parse_tree *remote_tree; struct ldb_parse_tree *local_tree; struct ldb_request *remote_req; + struct ldb_context *ldb; struct map_context *ac; int ret; const char *wildcard[] = { "*", NULL }; const char * const *attrs; - if (!module->private_data) /* if we're not yet initialized, go to the next module */ + ldb = ldb_module_get_ctx(module); + + /* if we're not yet initialized, go to the next module */ + if (!ldb_module_get_private(module)) return ldb_next_request(module, req); /* Do not manipulate our control entries */ @@ -1165,7 +1178,7 @@ int map_search(struct ldb_module *module, struct ldb_request *req) ac->local_tree = local_tree; /* Prepare the remote operation */ - ret = ldb_build_search_req_ex(&remote_req, module->ldb, ac, + ret = ldb_build_search_req_ex(&remote_req, ldb, ac, req->op.search.base, req->op.search.scope, remote_tree, @@ -1282,10 +1295,12 @@ static int map_search_local(struct map_context *ac) /* Merge the remote and local parts of a search result. */ int map_local_merge_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct map_context *ac; int ret; ac = talloc_get_type(req->context, struct map_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -1301,7 +1316,7 @@ int map_local_merge_callback(struct ldb_request *req, struct ldb_reply *ares) /* We have already found a local record */ if (ac->r_current->local) { talloc_free(ares); - ldb_set_errstring(ac->module->ldb, "ldb_map: Too many results!"); + ldb_set_errstring(ldb, "ldb_map: Too many results!"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } diff --git a/source4/lib/ldb/ldb_map/ldb_map_private.h b/source4/lib/ldb/ldb_map/ldb_map_private.h index 0543ba71b9..0c46443253 100644 --- a/source4/lib/ldb/ldb_map/ldb_map_private.h +++ b/source4/lib/ldb/ldb_map/ldb_map_private.h @@ -1,6 +1,6 @@ /* A handy macro to report Out of Memory conditions */ -#define map_oom(module) ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); +#define map_oom(module) ldb_set_errstring(ldb_module_get_ctx(module), talloc_asprintf(module, "Out of Memory")); /* The type of search callback functions */ typedef int (*ldb_map_callback_t)(struct ldb_request *, struct ldb_reply *); diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c index be99c29d1e..39a77a5505 100644 --- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c +++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c @@ -32,7 +32,7 @@ * Author: Derrell Lipman (based on Andrew Tridgell's LDAP backend) */ -#include "ldb_includes.h" +#include "ldb_module.h" #include diff --git a/source4/lib/ldb/ldb_tdb/ldb_cache.c b/source4/lib/ldb/ldb_tdb/ldb_cache.c index 2576e2c7bd..43b965f239 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_cache.c +++ b/source4/lib/ldb/ldb_tdb/ldb_cache.c @@ -31,8 +31,6 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" - #include "ldb_tdb.h" #define LTDB_FLAG_CASE_INSENSITIVE (1<<0) @@ -57,10 +55,14 @@ static const struct { */ static void ltdb_attributes_unload(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + struct ldb_context *ldb; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct ldb_message *msg; int i; + ldb = ldb_module_get_ctx(module); + if (ltdb->cache->attributes == NULL) { /* no previously loaded attributes */ return; @@ -68,7 +70,7 @@ static void ltdb_attributes_unload(struct ldb_module *module) msg = ltdb->cache->attributes; for (i=0;inum_elements;i++) { - ldb_schema_attribute_remove(module->ldb, msg->elements[i].name); + ldb_schema_attribute_remove(ldb, msg->elements[i].name); } talloc_free(ltdb->cache->attributes); @@ -104,12 +106,16 @@ static int ltdb_attributes_flags(struct ldb_message_element *el, unsigned *v) */ static int ltdb_attributes_load(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + struct ldb_context *ldb; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct ldb_message *msg = ltdb->cache->attributes; struct ldb_dn *dn; int i, r; - dn = ldb_dn_new(module, module->ldb, LTDB_ATTRIBUTES); + ldb = ldb_module_get_ctx(module); + + dn = ldb_dn_new(module, ldb, LTDB_ATTRIBUTES); if (dn == NULL) goto failed; r = ltdb_search_dn1(module, dn, msg); @@ -128,7 +134,7 @@ static int ltdb_attributes_load(struct ldb_module *module) const struct ldb_schema_syntax *s; if (ltdb_attributes_flags(&msg->elements[i], &flags) != 0) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Invalid @ATTRIBUTES element for '%s'\n", msg->elements[i].name); + ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid @ATTRIBUTES element for '%s'\n", msg->elements[i].name); goto failed; } switch (flags & ~LTDB_FLAG_HIDDEN) { @@ -142,22 +148,22 @@ static int ltdb_attributes_load(struct ldb_module *module) syntax = LDB_SYNTAX_INTEGER; break; default: - ldb_debug(module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid flag combination 0x%x for '%s' in @ATTRIBUTES\n", flags, msg->elements[i].name); goto failed; } - s = ldb_standard_syntax_by_name(module->ldb, syntax); + s = ldb_standard_syntax_by_name(ldb, syntax); if (s == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid attribute syntax '%s' for '%s' in @ATTRIBUTES\n", syntax, msg->elements[i].name); goto failed; } flags |= LDB_ATTR_FLAG_ALLOCATED; - if (ldb_schema_attribute_add_with_syntax(module->ldb, msg->elements[i].name, flags, s) != 0) { + if (ldb_schema_attribute_add_with_syntax(ldb, msg->elements[i].name, flags, s) != 0) { goto failed; } } @@ -173,7 +179,9 @@ failed: */ static int ltdb_baseinfo_init(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + struct ldb_context *ldb; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct ldb_message *msg; struct ldb_message_element el; struct ldb_val val; @@ -183,6 +191,8 @@ static int ltdb_baseinfo_init(struct ldb_module *module) out. */ const char *initial_sequence_number = "1"; + ldb = ldb_module_get_ctx(module); + ltdb->sequence_number = atof(initial_sequence_number); msg = talloc(ltdb, struct ldb_message); @@ -192,7 +202,7 @@ static int ltdb_baseinfo_init(struct ldb_module *module) msg->num_elements = 1; msg->elements = ⪙ - msg->dn = ldb_dn_new(msg, module->ldb, LTDB_BASEINFO); + msg->dn = ldb_dn_new(msg, ldb, LTDB_BASEINFO); if (!msg->dn) { goto failed; } @@ -226,7 +236,8 @@ failed: */ static void ltdb_cache_free(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); ltdb->sequence_number = 0; talloc_free(ltdb->cache); @@ -248,13 +259,17 @@ int ltdb_cache_reload(struct ldb_module *module) */ int ltdb_cache_load(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + struct ldb_context *ldb; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct ldb_dn *baseinfo_dn = NULL, *options_dn = NULL; struct ldb_dn *indexlist_dn = NULL; uint64_t seq; struct ldb_message *baseinfo = NULL, *options = NULL; int r; + ldb = ldb_module_get_ctx(module); + /* a very fast check to avoid extra database reads */ if (ltdb->cache != NULL && tdb_get_seqnum(ltdb->tdb) == ltdb->tdb_seqnum) { @@ -275,7 +290,7 @@ int ltdb_cache_load(struct ldb_module *module) baseinfo = talloc(ltdb->cache, struct ldb_message); if (baseinfo == NULL) goto failed; - baseinfo_dn = ldb_dn_new(module, module->ldb, LTDB_BASEINFO); + baseinfo_dn = ldb_dn_new(module, ldb, LTDB_BASEINFO); if (baseinfo_dn == NULL) goto failed; r= ltdb_search_dn1(module, baseinfo_dn, baseinfo); @@ -307,7 +322,7 @@ int ltdb_cache_load(struct ldb_module *module) options = talloc(ltdb->cache, struct ldb_message); if (options == NULL) goto failed; - options_dn = ldb_dn_new(options, module->ldb, LTDB_OPTIONS); + options_dn = ldb_dn_new(options, ldb, LTDB_OPTIONS); if (options_dn == NULL) goto failed; r= ltdb_search_dn1(module, options_dn, options); @@ -336,7 +351,7 @@ int ltdb_cache_load(struct ldb_module *module) goto failed; } - indexlist_dn = ldb_dn_new(module, module->ldb, LTDB_INDEXLIST); + indexlist_dn = ldb_dn_new(module, ldb, LTDB_INDEXLIST); if (indexlist_dn == NULL) goto failed; r = ltdb_search_dn1(module, indexlist_dn, ltdb->cache->indexlist); @@ -369,7 +384,9 @@ failed: */ int ltdb_increase_sequence_number(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + struct ldb_context *ldb; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct ldb_message *msg; struct ldb_message_element el[2]; struct ldb_val val; @@ -378,6 +395,8 @@ int ltdb_increase_sequence_number(struct ldb_module *module) char *s = NULL; int ret; + ldb = ldb_module_get_ctx(module); + msg = talloc(ltdb, struct ldb_message); if (msg == NULL) { errno = ENOMEM; @@ -392,7 +411,7 @@ int ltdb_increase_sequence_number(struct ldb_module *module) msg->num_elements = ARRAY_SIZE(el); msg->elements = el; - msg->dn = ldb_dn_new(msg, module->ldb, LTDB_BASEINFO); + msg->dn = ldb_dn_new(msg, ldb, LTDB_BASEINFO); if (msg->dn == NULL) { talloc_free(msg); errno = ENOMEM; diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index c4c23022f8..cdbef3944b 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -31,8 +31,6 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" - #include "ldb_tdb.h" /* @@ -69,8 +67,8 @@ struct ltdb_idxptr { */ static int ltdb_idxptr_add(struct ldb_module *module, const struct ldb_message *msg) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); ltdb->idxptr->dn_list = talloc_realloc(ltdb->idxptr, ltdb->idxptr->dn_list, const char *, ltdb->idxptr->num_dns+1); if (ltdb->idxptr->dn_list == NULL) { @@ -177,8 +175,8 @@ static int ltdb_convert_to_idxptr(struct ldb_module *module, struct ldb_message_ struct ldb_index_pointer *ptr, *tmp; int i; struct ldb_val *val2; - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); ptr = NULL; @@ -216,8 +214,8 @@ static int ltdb_convert_to_idxptr(struct ldb_module *module, struct ldb_message_ /* enable the idxptr mode when transactions start */ int ltdb_index_transaction_start(struct ldb_module *module) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); ltdb->idxptr = talloc_zero(module, struct ltdb_idxptr); return LDB_SUCCESS; } @@ -260,11 +258,14 @@ static int ltdb_search_dn1_index(struct ldb_module *module, */ static int ltdb_idxptr_fix_dn(struct ldb_module *module, const char *strdn) { + struct ldb_context *ldb; struct ldb_dn *dn; struct ldb_message *msg = ldb_msg_new(module); int ret; - dn = ldb_dn_new(msg, module->ldb, strdn); + ldb = ldb_module_get_ctx(module); + + dn = ldb_dn_new(msg, ldb, strdn); if (ltdb_search_dn1_index(module, dn, msg) == LDB_SUCCESS) { ret = ltdb_store(module, msg, TDB_REPLACE); } @@ -276,8 +277,8 @@ static int ltdb_idxptr_fix_dn(struct ldb_module *module, const char *strdn) int ltdb_index_transaction_commit(struct ldb_module *module) { int i; - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); /* fix all the DNs that we have modified */ if (ltdb->idxptr) { @@ -298,8 +299,8 @@ int ltdb_index_transaction_commit(struct ldb_module *module) /* cleanup the idxptr mode when transaction cancels */ int ltdb_index_transaction_cancel(struct ldb_module *module) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); talloc_free(ltdb->idxptr); ltdb->idxptr = NULL; return LDB_SUCCESS; @@ -314,8 +315,8 @@ int ltdb_index_transaction_cancel(struct ldb_module *module) */ int ltdb_store_idxptr(struct ldb_module *module, const struct ldb_message *msg, int flgs) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret; if (ltdb->idxptr) { @@ -510,12 +511,14 @@ static int ltdb_index_dn_simple(struct ldb_module *module, const struct ldb_message *index_list, struct dn_list *list) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; struct ldb_dn *dn; int ret; unsigned int i, j; struct ldb_message *msg; + ldb = ldb_module_get_ctx(module); + list->count = 0; list->dn = NULL; @@ -587,15 +590,18 @@ static int ltdb_index_dn_leaf(struct ldb_module *module, const struct ldb_message *index_list, struct dn_list *list) { + struct ldb_context *ldb; + ldb = ldb_module_get_ctx(module); + if (ldb_attr_dn(tree->u.equality.attr) == 0) { list->dn = talloc_array(list, char *, 1); if (list->dn == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } list->dn[0] = talloc_strdup(list->dn, (char *)tree->u.equality.value.data); if (list->dn[0] == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } list->count = 1; @@ -707,10 +713,12 @@ static int ltdb_index_dn_or(struct ldb_module *module, const struct ldb_message *index_list, struct dn_list *list) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; unsigned int i; int ret; + ldb = ldb_module_get_ctx(module); + ret = LDB_ERR_OPERATIONS_ERROR; list->dn = NULL; list->count = 0; @@ -791,10 +799,12 @@ static int ltdb_index_dn_and(struct ldb_module *module, const struct ldb_message *index_list, struct dn_list *list) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; unsigned int i; int ret; + ldb = ldb_module_get_ctx(module); + ret = LDB_ERR_OPERATIONS_ERROR; list->dn = NULL; list->count = 0; @@ -852,7 +862,7 @@ static int ltdb_index_dn_one(struct ldb_module *module, struct ldb_dn *parent_dn, struct dn_list *list) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; struct dn_list *list2; struct ldb_message *msg; struct ldb_dn *key; @@ -860,6 +870,8 @@ static int ltdb_index_dn_one(struct ldb_module *module, unsigned int i, j; int ret; + ldb = ldb_module_get_ctx(module); + list2 = talloc_zero(module, struct dn_list); if (list2 == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -991,9 +1003,12 @@ static int ltdb_index_dn(struct ldb_module *module, static int ltdb_index_filter(const struct dn_list *dn_list, struct ltdb_context *ac) { + struct ldb_context *ldb; struct ldb_message *msg; unsigned int i; + ldb = ldb_module_get_ctx(ac->module); + for (i = 0; i < dn_list->count; i++) { struct ldb_dn *dn; int ret; @@ -1003,7 +1018,7 @@ static int ltdb_index_filter(const struct dn_list *dn_list, return LDB_ERR_OPERATIONS_ERROR; } - dn = ldb_dn_new(msg, ac->module->ldb, dn_list->dn[i]); + dn = ldb_dn_new(msg, ldb, dn_list->dn[i]); if (dn == NULL) { talloc_free(msg); return LDB_ERR_OPERATIONS_ERROR; @@ -1023,7 +1038,7 @@ static int ltdb_index_filter(const struct dn_list *dn_list, return LDB_ERR_OPERATIONS_ERROR; } - if (!ldb_match_msg(ac->module->ldb, msg, + if (!ldb_match_msg(ldb, msg, ac->tree, ac->base, ac->scope)) { talloc_free(msg); continue; @@ -1054,10 +1069,14 @@ static int ltdb_index_filter(const struct dn_list *dn_list, */ int ltdb_search_indexed(struct ltdb_context *ac) { - struct ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private); + struct ldb_context *ldb; + void *data = ldb_module_get_private(ac->module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct dn_list *dn_list; int ret, idxattr, idxone; + ldb = ldb_module_get_ctx(ac->module); + idxattr = idxone = 0; ret = ldb_msg_find_idx(ltdb->cache->indexlist, NULL, NULL, LTDB_IDXATTR); if (ret == 0 ) { @@ -1087,12 +1106,12 @@ int ltdb_search_indexed(struct ltdb_context *ac) /* with BASE searches only one DN can match */ dn_list->dn = talloc_array(dn_list, char *, 1); if (dn_list->dn == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } dn_list->dn[0] = ldb_dn_alloc_linearized(dn_list, ac->base); if (dn_list->dn[0] == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } dn_list->count = 1; @@ -1198,12 +1217,14 @@ static int ltdb_index_add1_add(struct ldb_context *ldb, static int ltdb_index_add1(struct ldb_module *module, const char *dn, struct ldb_message_element *el, int v_idx) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; struct ldb_message *msg; struct ldb_dn *dn_key; int ret; unsigned int i; + ldb = ldb_module_get_ctx(module); + msg = talloc(module, struct ldb_message); if (msg == NULL) { errno = ENOMEM; @@ -1253,7 +1274,8 @@ static int ltdb_index_add1(struct ldb_module *module, const char *dn, static int ltdb_index_add0(struct ldb_module *module, const char *dn, struct ldb_message_element *elements, int num_el) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret; unsigned int i, j; @@ -1308,12 +1330,14 @@ int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg) int ltdb_index_del_value(struct ldb_module *module, const char *dn, struct ldb_message_element *el, int v_idx) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; struct ldb_message *msg; struct ldb_dn *dn_key; int ret, i; unsigned int j; + ldb = ldb_module_get_ctx(module); + if (dn[0] == '@') { return LDB_SUCCESS; } @@ -1351,7 +1375,7 @@ int ltdb_index_del_value(struct ldb_module *module, const char *dn, ldb_dn_get_linearized(dn_key)); ldif.changetype = LDB_CHANGETYPE_NONE; ldif.msg = msg; - ldb_ldif_write_file(module->ldb, stdout, &ldif); + ldb_ldif_write_file(ldb, stdout, &ldif); sleep(100); /* it ain't there. hmmm */ talloc_free(dn_key); @@ -1383,7 +1407,8 @@ int ltdb_index_del_value(struct ldb_module *module, const char *dn, */ int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret; const char *dn; unsigned int i, j; @@ -1425,7 +1450,8 @@ int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg) */ int ltdb_index_one(struct ldb_module *module, const struct ldb_message *msg, int add) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct ldb_message_element el; struct ldb_val val; struct ldb_dn *pdn; @@ -1489,12 +1515,15 @@ static int delete_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, vo */ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state) { + struct ldb_context *ldb; struct ldb_module *module = (struct ldb_module *)state; struct ldb_message *msg; const char *dn = NULL; int ret; TDB_DATA key2; + ldb = ldb_module_get_ctx(module); + if (strncmp((char *)key.dptr, "DN=@", 4) == 0 || strncmp((char *)key.dptr, "DN=", 3) != 0) { return 0; @@ -1516,7 +1545,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void * key2 = ltdb_key(module, msg->dn); if (key2.dptr == NULL) { /* probably a corrupt record ... darn */ - ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Invalid DN in re_index: %s\n", + ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid DN in re_index: %s\n", ldb_dn_get_linearized(msg->dn)); talloc_free(msg); return 0; @@ -1537,7 +1566,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void * if (ret == LDB_SUCCESS) { ret = ltdb_index_add0(module, dn, msg->elements, msg->num_elements); } else { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "Adding special ONE LEVEL index failed (%s)!\n", ldb_dn_get_linearized(msg->dn)); } @@ -1554,7 +1583,8 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void * */ int ltdb_reindex(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret; if (ltdb_cache_reload(module) != 0) { diff --git a/source4/lib/ldb/ldb_tdb/ldb_pack.c b/source4/lib/ldb/ldb_tdb/ldb_pack.c index afb07dcbca..1995606f88 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_pack.c +++ b/source4/lib/ldb/ldb_tdb/ldb_pack.c @@ -31,7 +31,6 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" #include "ldb_tdb.h" /* change this if the data format ever changes */ @@ -79,13 +78,15 @@ int ltdb_pack_data(struct ldb_module *module, const struct ldb_message *message, struct TDB_DATA *data) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; unsigned int i, j, real_elements=0; size_t size; const char *dn; uint8_t *p; size_t len; + ldb = ldb_module_get_ctx(module); + dn = ldb_dn_get_linearized(message->dn); if (dn == NULL) { errno = ENOMEM; @@ -159,13 +160,14 @@ int ltdb_unpack_data(struct ldb_module *module, const struct TDB_DATA *data, struct ldb_message *message) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; uint8_t *p; unsigned int remaining; unsigned int i, j; unsigned format; size_t len; + ldb = ldb_module_get_ctx(module); message->elements = NULL; p = data->dptr; diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c index 35149c4b77..0f595267fc 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_search.c +++ b/source4/lib/ldb/ldb_tdb/ldb_search.c @@ -31,8 +31,6 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" - #include "ldb_tdb.h" /* @@ -112,10 +110,12 @@ static int msg_add_distinguished_name(struct ldb_message *msg) static int msg_add_all_elements(struct ldb_module *module, struct ldb_message *ret, const struct ldb_message *msg) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb; unsigned int i; int check_duplicates = (ret->num_elements != 0); + ldb = ldb_module_get_ctx(module); + if (msg_add_distinguished_name(ret) != 0) { return -1; } @@ -207,7 +207,8 @@ static struct ldb_message *ltdb_pull_attrs(struct ldb_module *module, */ static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); TDB_DATA tdb_key, tdb_data; if (ldb_dn_is_null(dn)) { @@ -239,7 +240,8 @@ static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn) */ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret; TDB_DATA tdb_key, tdb_data; @@ -371,11 +373,13 @@ int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs) */ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state) { + struct ldb_context *ldb; struct ltdb_context *ac; struct ldb_message *msg; int ret; ac = talloc_get_type(state, struct ltdb_context); + ldb = ldb_module_get_ctx(ac->module); if (key.dsize < 4 || strncmp((char *)key.dptr, "DN=", 3) != 0) { @@ -395,7 +399,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi } if (!msg->dn) { - msg->dn = ldb_dn_new(msg, ac->module->ldb, + msg->dn = ldb_dn_new(msg, ldb, (char *)key.dptr + 3); if (msg->dn == NULL) { talloc_free(msg); @@ -404,7 +408,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi } /* see if it matches the given expression */ - if (!ldb_match_msg(ac->module->ldb, msg, + if (!ldb_match_msg(ldb, msg, ac->tree, ac->base, ac->scope)) { talloc_free(msg); return 0; @@ -435,7 +439,8 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi */ static int ltdb_search_full(struct ltdb_context *ctx) { - struct ltdb_private *ltdb = talloc_get_type(ctx->module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(ctx->module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret; if (ltdb->in_transaction != 0) { @@ -457,12 +462,16 @@ static int ltdb_search_full(struct ltdb_context *ctx) */ int ltdb_search(struct ltdb_context *ctx) { + struct ldb_context *ldb; struct ldb_module *module = ctx->module; struct ldb_request *req = ctx->req; - struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret; - req->handle->state = LDB_ASYNC_PENDING; + ldb = ldb_module_get_ctx(module); + + ldb_request_set_state(req, LDB_ASYNC_PENDING); if (ltdb_lock_read(module) != 0) { return LDB_ERR_OPERATIONS_ERROR; @@ -483,12 +492,12 @@ int ltdb_search(struct ltdb_context *ctx) /* Check what we should do with a NULL dn */ switch (req->op.search.scope) { case LDB_SCOPE_BASE: - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "NULL Base DN invalid for a base search"); ret = LDB_ERR_INVALID_DN_SYNTAX; break; case LDB_SCOPE_ONELEVEL: - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "NULL Base DN invalid for a one-level search"); ret = LDB_ERR_INVALID_DN_SYNTAX; break; @@ -500,7 +509,7 @@ int ltdb_search(struct ltdb_context *ctx) } else if (ldb_dn_is_valid(req->op.search.base) == false) { /* We don't want invalid base DNs here */ - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "Invalid Base DN: %s", ldb_dn_get_linearized(req->op.search.base)); ret = LDB_ERR_INVALID_DN_SYNTAX; @@ -510,7 +519,7 @@ int ltdb_search(struct ltdb_context *ctx) ret = ltdb_search_base(module, req->op.search.base); if (ret == LDB_ERR_NO_SUCH_OBJECT) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "No such Base DN: %s", ldb_dn_get_linearized(req->op.search.base)); } @@ -539,7 +548,7 @@ int ltdb_search(struct ltdb_context *ctx) /* Not indexed, so we need to do a full scan */ ret = ltdb_search_full(ctx); if (ret != LDB_SUCCESS) { - ldb_set_errstring(module->ldb, "Indexed and full searches both failed!\n"); + ldb_set_errstring(ldb, "Indexed and full searches both failed!\n"); } } } diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index 9528f5a662..d6276c4b86 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -45,8 +45,6 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" - #include "ldb_tdb.h" @@ -84,7 +82,8 @@ static int ltdb_err_map(enum TDB_ERROR tdb_code) */ int ltdb_lock_read(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); if (ltdb->in_transaction == 0) { return tdb_lockall_read(ltdb->tdb); } @@ -96,7 +95,8 @@ int ltdb_lock_read(struct ldb_module *module) */ int ltdb_unlock_read(struct ldb_module *module) { - struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); if (ltdb->in_transaction == 0) { return tdb_unlockall_read(ltdb->tdb); } @@ -113,7 +113,7 @@ int ltdb_unlock_read(struct ldb_module *module) */ struct TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb = ldb_module_get_ctx(module); TDB_DATA key; char *key_str = NULL; const char *dn_folded = NULL; @@ -164,6 +164,7 @@ failed: static int ltdb_check_special_dn(struct ldb_module *module, const struct ldb_message *msg) { + struct ldb_context *ldb = ldb_module_get_ctx(module); int i, j; if (! ldb_dn_is_special(msg->dn) || @@ -176,7 +177,7 @@ static int ltdb_check_special_dn(struct ldb_module *module, for (i = 0; i < msg->num_elements; i++) { for (j = 0; j < msg->elements[i].num_values; j++) { if (ltdb_check_at_attributes_values(&msg->elements[i].values[j]) != 0) { - ldb_set_errstring(module->ldb, "Invalid attribute value in an @ATTRIBUTES entry"); + ldb_set_errstring(ldb, "Invalid attribute value in an @ATTRIBUTES entry"); return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX; } } @@ -214,8 +215,8 @@ static int ltdb_modified(struct ldb_module *module, struct ldb_dn *dn) */ int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); TDB_DATA tdb_key, tdb_data; int ret; @@ -252,6 +253,7 @@ done: static int ltdb_add_internal(struct ldb_module *module, const struct ldb_message *msg) { + struct ldb_context *ldb = ldb_module_get_ctx(module); int ret; ret = ltdb_check_special_dn(module, msg); @@ -266,7 +268,7 @@ static int ltdb_add_internal(struct ldb_module *module, ret = ltdb_store(module, msg, TDB_INSERT); if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "Entry %s already exists", ldb_dn_get_linearized(msg->dn)); return ret; @@ -296,7 +298,7 @@ static int ltdb_add(struct ltdb_context *ctx) struct ldb_request *req = ctx->req; int tret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_request_set_state(req, LDB_ASYNC_PENDING); tret = ltdb_add_internal(module, req->op.add.message); if (tret != LDB_SUCCESS) { @@ -312,8 +314,8 @@ static int ltdb_add(struct ltdb_context *ctx) */ int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); TDB_DATA tdb_key; int ret; @@ -386,7 +388,7 @@ static int ltdb_delete(struct ltdb_context *ctx) struct ldb_request *req = ctx->req; int tret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_request_set_state(req, LDB_ASYNC_PENDING); if (ltdb_cache_load(module) != 0) { return LDB_ERR_OPERATIONS_ERROR; @@ -514,7 +516,7 @@ static int msg_delete_element(struct ldb_module *module, const char *name, const struct ldb_val *val) { - struct ldb_context *ldb = module->ldb; + struct ldb_context *ldb = ldb_module_get_ctx(module); unsigned int i; int found; struct ldb_message_element *el; @@ -560,9 +562,9 @@ static int msg_delete_element(struct ldb_module *module, int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg) { - struct ldb_context *ldb = module->ldb; - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + struct ldb_context *ldb = ldb_module_get_ctx(module); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); TDB_DATA tdb_key, tdb_data; struct ldb_message *msg2; unsigned i, j; @@ -625,12 +627,12 @@ int ltdb_modify_internal(struct ldb_module *module, for (j=0;jnum_values;j++) { if (ldb_msg_find_val(el2, &el->values[j])) { - ldb_asprintf_errstring(module->ldb, "%s: value #%d already exists", el->name, j); + ldb_asprintf_errstring(ldb, "%s: value #%d already exists", el->name, j); ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; goto failed; } if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) { - ldb_asprintf_errstring(module->ldb, "%s: value #%d provided more than once", el->name, j); + ldb_asprintf_errstring(ldb, "%s: value #%d provided more than once", el->name, j); ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; goto failed; } @@ -661,7 +663,7 @@ int ltdb_modify_internal(struct ldb_module *module, for (j=0;jnum_values;j++) { if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) { - ldb_asprintf_errstring(module->ldb, "%s: value #%d provided more than once", el->name, j); + ldb_asprintf_errstring(ldb, "%s: value #%d provided more than once", el->name, j); ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; goto failed; } @@ -688,7 +690,7 @@ int ltdb_modify_internal(struct ldb_module *module, if (msg->elements[i].num_values == 0) { if (msg_delete_attribute(module, ldb, msg2, msg->elements[i].name) != 0) { - ldb_asprintf_errstring(module->ldb, "No such attribute: %s for delete on %s", msg->elements[i].name, dn); + ldb_asprintf_errstring(ldb, "No such attribute: %s for delete on %s", msg->elements[i].name, dn); ret = LDB_ERR_NO_SUCH_ATTRIBUTE; goto failed; } @@ -699,7 +701,7 @@ int ltdb_modify_internal(struct ldb_module *module, msg2, msg->elements[i].name, &msg->elements[i].values[j]) != 0) { - ldb_asprintf_errstring(module->ldb, "No matching attribute value when deleting attribute: %s on %s", msg->elements[i].name, dn); + ldb_asprintf_errstring(ldb, "No matching attribute value when deleting attribute: %s on %s", msg->elements[i].name, dn); ret = LDB_ERR_NO_SUCH_ATTRIBUTE; goto failed; } @@ -710,7 +712,7 @@ int ltdb_modify_internal(struct ldb_module *module, } break; default: - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "Invalid ldb_modify flags on %s: 0x%x", msg->elements[i].name, msg->elements[i].flags & LDB_FLAG_MOD_MASK); @@ -750,7 +752,7 @@ static int ltdb_modify(struct ltdb_context *ctx) struct ldb_request *req = ctx->req; int tret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_request_set_state(req, LDB_ASYNC_PENDING); tret = ltdb_check_special_dn(module, req->op.mod.message); if (tret != LDB_SUCCESS) { @@ -779,7 +781,7 @@ static int ltdb_rename(struct ltdb_context *ctx) struct ldb_message *msg; int tret; - req->handle->state = LDB_ASYNC_PENDING; + ldb_request_set_state(req, LDB_ASYNC_PENDING); if (ltdb_cache_load(ctx->module) != 0) { return LDB_ERR_OPERATIONS_ERROR; @@ -841,8 +843,8 @@ static int ltdb_rename(struct ltdb_context *ctx) static int ltdb_start_trans(struct ldb_module *module) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); if (tdb_transaction_start(ltdb->tdb) != 0) { return ltdb_err_map(tdb_error(ltdb->tdb)); @@ -857,8 +859,8 @@ static int ltdb_start_trans(struct ldb_module *module) static int ltdb_end_trans(struct ldb_module *module) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); ltdb->in_transaction--; @@ -875,8 +877,8 @@ static int ltdb_end_trans(struct ldb_module *module) static int ltdb_del_trans(struct ldb_module *module) { - struct ltdb_private *ltdb = - talloc_get_type(module->private_data, struct ltdb_private); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); ltdb->in_transaction--; @@ -897,6 +899,7 @@ static int ltdb_del_trans(struct ldb_module *module) static int ltdb_sequence_number(struct ltdb_context *ctx, struct ldb_extended **ext) { + struct ldb_context *ldb; struct ldb_module *module = ctx->module; struct ldb_request *req = ctx->req; TALLOC_CTX *tmp_ctx; @@ -907,13 +910,15 @@ static int ltdb_sequence_number(struct ltdb_context *ctx, const char *date; int ret; + ldb = ldb_module_get_ctx(module); + seq = talloc_get_type(req->op.extended.data, struct ldb_seqnum_request); if (seq == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - req->handle->state = LDB_ASYNC_PENDING; + ldb_request_set_state(req, LDB_ASYNC_PENDING); if (ltdb_lock_read(module) != 0) { return LDB_ERR_OPERATIONS_ERROR; @@ -930,7 +935,7 @@ static int ltdb_sequence_number(struct ltdb_context *ctx, goto done; } - dn = ldb_dn_new(tmp_ctx, module->ldb, LTDB_BASEINFO); + dn = ldb_dn_new(tmp_ctx, ldb, LTDB_BASEINFO); msg = talloc(tmp_ctx, struct ldb_message); if (msg == NULL) { @@ -978,18 +983,23 @@ done: return ret; } -static void ltdb_request_done(struct ldb_request *req, int error) +static void ltdb_request_done(struct ltdb_context *ctx, int error) { + struct ldb_context *ldb; + struct ldb_request *req; struct ldb_reply *ares; + ldb = ldb_module_get_ctx(ctx->module); + req = ctx->req; + /* if we already returned an error just return */ - if (req->handle->status != LDB_SUCCESS) { + if (ldb_request_get_status(req) != LDB_SUCCESS) { return; } ares = talloc_zero(req, struct ldb_reply); if (!ares) { - ldb_oom(req->handle->ldb); + ldb_oom(ldb); req->callback(req, NULL); return; } @@ -1007,23 +1017,28 @@ static void ltdb_timeout(struct tevent_context *ev, struct ltdb_context *ctx; ctx = talloc_get_type(private_data, struct ltdb_context); - ltdb_request_done(ctx->req, LDB_ERR_TIME_LIMIT_EXCEEDED); + ltdb_request_done(ctx, LDB_ERR_TIME_LIMIT_EXCEEDED); } -static void ltdb_request_extended_done(struct ldb_request *req, +static void ltdb_request_extended_done(struct ltdb_context *ctx, struct ldb_extended *ext, int error) { + struct ldb_context *ldb; + struct ldb_request *req; struct ldb_reply *ares; + ldb = ldb_module_get_ctx(ctx->module); + req = ctx->req; + /* if we already returned an error just return */ - if (req->handle->status != LDB_SUCCESS) { + if (ldb_request_get_status(req) != LDB_SUCCESS) { return; } ares = talloc_zero(req, struct ldb_reply); if (!ares) { - ldb_oom(req->handle->ldb); + ldb_oom(ldb); req->callback(req, NULL); return; } @@ -1048,7 +1063,7 @@ static void ltdb_handle_extended(struct ltdb_context *ctx) ret = LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; } - ltdb_request_extended_done(ctx->req, ext, ret); + ltdb_request_extended_done(ctx, ext, ret); } static void ltdb_callback(struct tevent_context *ev, @@ -1088,13 +1103,14 @@ static void ltdb_callback(struct tevent_context *ev, if (!ctx->callback_failed) { /* Once we are done, we do not need timeout events */ talloc_free(ctx->timeout_event); - ltdb_request_done(ctx->req, ret); + ltdb_request_done(ctx, ret); } } static int ltdb_handle_request(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct tevent_context *ev; struct ltdb_context *ac; struct tevent_timer *te; @@ -1104,16 +1120,18 @@ static int ltdb_handle_request(struct ldb_module *module, return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; } + ldb = ldb_module_get_ctx(module); + if (req->starttime == 0 || req->timeout == 0) { - ldb_set_errstring(module->ldb, "Invalid timeout settings"); + ldb_set_errstring(ldb, "Invalid timeout settings"); return LDB_ERR_TIME_LIMIT_EXCEEDED; } - ev = ldb_get_event_context(module->ldb); + ev = ldb_get_event_context(ldb); ac = talloc_zero(req, struct ltdb_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } @@ -1154,8 +1172,9 @@ static const struct ldb_module_ops ltdb_ops = { */ static int ltdb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[], - struct ldb_module **module) + struct ldb_module **_module) { + struct ldb_module *module; const char *path; int tdb_flags, open_flags; struct ltdb_private *ltdb; @@ -1199,7 +1218,7 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, /* note that we use quite a large default hash size */ ltdb->tdb = ltdb_wrap_open(ltdb, path, 10000, tdb_flags, open_flags, - ldb->create_perms, ldb); + ldb_get_create_perms(ldb), ldb); if (!ltdb->tdb) { ldb_debug(ldb, LDB_DEBUG_ERROR, "Unable to open tdb '%s'\n", path); @@ -1209,24 +1228,20 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, ltdb->sequence_number = 0; - *module = talloc(ldb, struct ldb_module); - if ((*module) == NULL) { - ldb_oom(ldb); + module = ldb_module_new(ldb, ldb, "ldb_tdb backend", <db_ops); + if (!module) { talloc_free(ltdb); return -1; } - talloc_set_name_const(*module, "ldb_tdb backend"); - (*module)->ldb = ldb; - (*module)->prev = (*module)->next = NULL; - (*module)->private_data = ltdb; - (*module)->ops = <db_ops; + ldb_module_set_private(module, ltdb); - if (ltdb_cache_load(*module) != 0) { - talloc_free(*module); + if (ltdb_cache_load(module) != 0) { + talloc_free(module); talloc_free(ltdb); return -1; } + *_module = module; return 0; } diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h index b373d37b7e..7ebf199f6f 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h @@ -6,6 +6,8 @@ #include "tdb.h" #endif +#include "ldb_module.h" + /* this private structure is used by the ltdb backend in the ldb_context */ struct ltdb_private { diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c b/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c index 4fea43c8c8..6ee8417e25 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c @@ -21,8 +21,6 @@ License along with this library; if not, see . */ -#include "ldb_includes.h" - #include "ldb_tdb.h" /* diff --git a/source4/lib/ldb/modules/asq.c b/source4/lib/ldb/modules/asq.c index c650970af4..475b609e41 100644 --- a/source4/lib/ldb/modules/asq.c +++ b/source4/lib/ldb/modules/asq.c @@ -32,7 +32,7 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_module.h" struct asq_context { @@ -63,11 +63,14 @@ struct asq_context { static struct asq_context *asq_context_init(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct asq_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct asq_context); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } @@ -206,9 +209,12 @@ static int asq_reqs_callback(struct ldb_request *req, struct ldb_reply *ares) static int asq_build_first_request(struct asq_context *ac, struct ldb_request **base_req) { + struct ldb_context *ldb; const char **base_attrs; int ret; + ldb = ldb_module_get_ctx(ac->module); + ac->req_attrs = ac->req->op.search.attrs; ac->req_attribute = talloc_strdup(ac, ac->asq_ctrl->source_attribute); if (ac->req_attribute == NULL) @@ -222,7 +228,7 @@ static int asq_build_first_request(struct asq_context *ac, struct ldb_request ** base_attrs[1] = NULL; - ret = ldb_build_search_req(base_req, ac->module->ldb, ac, + ret = ldb_build_search_req(base_req, ldb, ac, ac->req->op.search.base, LDB_SCOPE_BASE, NULL, @@ -239,6 +245,7 @@ static int asq_build_first_request(struct asq_context *ac, struct ldb_request ** static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated) { + struct ldb_context *ldb; struct ldb_control **saved_controls; struct ldb_control *control; struct ldb_dn *dn; @@ -249,6 +256,8 @@ static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated) return LDB_ERR_NO_SUCH_OBJECT; } + ldb = ldb_module_get_ctx(ac->module); + el = ldb_msg_find_element(ac->base_res->message, ac->req_attribute); /* no values found */ if (el == NULL) { @@ -266,7 +275,7 @@ static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated) for (i = 0; i < el->num_values; i++) { - dn = ldb_dn_new(ac, ac->module->ldb, + dn = ldb_dn_new(ac, ldb, (const char *)el->values[i].data); if ( ! ldb_dn_validate(dn)) { ac->asq_ret = ASQ_CTRL_INVALID_ATTRIBUTE_SYNTAX; @@ -275,7 +284,7 @@ static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated) } ret = ldb_build_search_req_ex(&ac->reqs[i], - ac->module->ldb, ac, + ldb, ac, dn, LDB_SCOPE_BASE, ac->req->op.search.tree, ac->req_attrs, @@ -298,9 +307,12 @@ static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated) static int asq_search_continue(struct asq_context *ac) { + struct ldb_context *ldb; bool terminated = false; int ret; + ldb = ldb_module_get_ctx(ac->module); + switch (ac->step) { case ASQ_SEARCH_BASE: @@ -312,7 +324,7 @@ static int asq_search_continue(struct asq_context *ac) ac->step = ASQ_SEARCH_MULTI; - return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]); + return ldb_request(ldb, ac->reqs[ac->cur_req]); case ASQ_SEARCH_MULTI: @@ -323,7 +335,7 @@ static int asq_search_continue(struct asq_context *ac) return asq_search_terminate(ac); } - return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]); + return ldb_request(ldb, ac->reqs[ac->cur_req]); } return LDB_ERR_OPERATIONS_ERROR; @@ -331,11 +343,14 @@ static int asq_search_continue(struct asq_context *ac) static int asq_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *base_req; struct ldb_control *control; struct asq_context *ac; int ret; + ldb = ldb_module_get_ctx(module); + /* check if there's a paged request control */ control = ldb_request_get_control(req, LDB_CONTROL_ASQ_OID); if (control == NULL) { @@ -366,16 +381,19 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req) ac->step = ASQ_SEARCH_BASE; - return ldb_request(module->ldb, base_req); + return ldb_request(ldb, base_req); } static int asq_init(struct ldb_module *module) { + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(module); + ret = ldb_mod_register_control(module, LDB_CONTROL_ASQ_OID); if (ret != LDB_SUCCESS) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "asq: Unable to register control with rootdse!\n"); + ldb_debug(ldb, LDB_DEBUG_WARNING, "asq: Unable to register control with rootdse!\n"); } return ldb_next_init(module); diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c index 11c06c81bb..d862638389 100644 --- a/source4/lib/ldb/modules/operational.c +++ b/source4/lib/ldb/modules/operational.c @@ -73,7 +73,7 @@ modifiersName: not supported by w2k3? */ -#include "ldb_includes.h" +#include "ldb_module.h" /* construct a canonical name from a message @@ -126,8 +126,11 @@ static int operational_search_post_process(struct ldb_module *module, struct ldb_message *msg, const char * const *attrs) { + struct ldb_context *ldb; int i, a=0; + ldb = ldb_module_get_ctx(module); + for (a=0;attrs && attrs[a];a++) { for (i=0;ildb, LDB_DEBUG_WARNING, + ldb_debug_set(ldb, LDB_DEBUG_WARNING, "operational_search_post_process failed for attribute '%s'\n", attrs[a]); return -1; @@ -224,12 +227,15 @@ static int operational_callback(struct ldb_request *req, struct ldb_reply *ares) static int operational_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct operational_context *ac; struct ldb_request *down_req; const char **search_attrs = NULL; int i, a; int ret; + ldb = ldb_module_get_ctx(module); + ac = talloc(req, struct operational_context); if (ac == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -268,7 +274,7 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req } } - ret = ldb_build_search_req_ex(&down_req, module->ldb, ac, + ret = ldb_build_search_req_ex(&down_req, ldb, ac, req->op.search.base, req->op.search.scope, req->op.search.tree, diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c index dfc565fef8..7d7cdf66a0 100644 --- a/source4/lib/ldb/modules/paged_results.c +++ b/source4/lib/ldb/modules/paged_results.c @@ -32,7 +32,7 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_module.h" struct message_store { /* keep the whole ldb_reply as an optimization @@ -290,6 +290,7 @@ static int paged_search_callback(struct ldb_request *req, struct ldb_reply *ares static int paged_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_control *control; struct private_data *private_data; struct ldb_paged_control *paged_ctrl; @@ -298,6 +299,8 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) struct paged_context *ac; int ret; + ldb = ldb_module_get_ctx(module); + /* check if there's a paged request control */ control = ldb_request_get_control(req, LDB_CONTROL_PAGED_RESULTS_OID); if (control == NULL) { @@ -310,11 +313,12 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_PROTOCOL_ERROR; } - private_data = talloc_get_type(module->private_data, struct private_data); + private_data = talloc_get_type(ldb_module_get_private(module), + struct private_data); ac = talloc_zero(req, struct paged_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } @@ -333,7 +337,7 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req_ex(&search_req, module->ldb, ac, + ret = ldb_build_search_req_ex(&search_req, ldb, ac, req->op.search.base, req->op.search.scope, req->op.search.tree, @@ -385,9 +389,12 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) static int paged_request_init(struct ldb_module *module) { + struct ldb_context *ldb; struct private_data *data; int ret; + ldb = ldb_module_get_ctx(module); + data = talloc(module, struct private_data); if (data == NULL) { return LDB_ERR_OTHER; @@ -395,11 +402,11 @@ static int paged_request_init(struct ldb_module *module) data->next_free_id = 1; data->store = NULL; - module->private_data = data; + ldb_module_set_private(module, data); ret = ldb_mod_register_control(module, LDB_CONTROL_PAGED_RESULTS_OID); if (ret != LDB_SUCCESS) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "paged_request:" "Unable to register control with rootdse!\n"); } diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 56f9b1cac3..01e77cb22c 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -33,7 +33,7 @@ */ #include "includes.h" -#include "ldb_includes.h" +#include "ldb_module.h" #define PS_DEFAULT_PAGE_SIZE 500 /* 500 objects per query seem to be a decent compromise @@ -211,10 +211,12 @@ static int ps_callback(struct ldb_request *req, struct ldb_reply *ares) static int ps_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct private_data *private_data; struct ps_context *ac; - private_data = talloc_get_type(module->private_data, struct private_data); + private_data = talloc_get_type(ldb_module_get_private(module), struct private_data); + ldb = ldb_module_get_ctx(module); /* check if paging is supported and if there is a any control */ if (!private_data || !private_data->paged_supported || req->controls) { @@ -226,7 +228,7 @@ static int ps_search(struct ldb_module *module, struct ldb_request *req) ac = talloc_zero(req, struct ps_context); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -241,11 +243,14 @@ static int ps_search(struct ldb_module *module, struct ldb_request *req) static int ps_next_request(struct ps_context *ac) { + struct ldb_context *ldb; struct ldb_paged_control *control; struct ldb_control **controls; struct ldb_request *new_req; int ret; + ldb = ldb_module_get_ctx(ac->module); + controls = talloc_array(ac, struct ldb_control *, 2); if (!controls) { return LDB_ERR_OPERATIONS_ERROR; @@ -270,7 +275,7 @@ static int ps_next_request(struct ps_context *ac) { controls[0]->data = control; controls[1] = NULL; - ret = ldb_build_search_req_ex(&new_req, ac->module->ldb, ac, + ret = ldb_build_search_req_ex(&new_req, ldb, ac, ac->req->op.search.base, ac->req->op.search.scope, ac->req->op.search.tree, @@ -324,26 +329,30 @@ static int check_supported_paged(struct ldb_request *req, static int ps_init(struct ldb_module *module) { + struct ldb_context *ldb; static const char *attrs[] = { "supportedControl", NULL }; struct private_data *data; struct ldb_dn *base; int ret; struct ldb_request *req; + ldb = ldb_module_get_ctx(module); + data = talloc(module, struct private_data); if (data == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - module->private_data = data; data->paged_supported = false; - base = ldb_dn_new(module, module->ldb, ""); + ldb_module_set_private(module, data); + + base = ldb_dn_new(module, ldb, ""); if (base == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&req, module->ldb, module, + ret = ldb_build_search_req(&req, ldb, module, base, LDB_SCOPE_BASE, "(objectClass=*)", attrs, NULL, diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c index 62b8ce5112..a5ffcc034a 100644 --- a/source4/lib/ldb/modules/rdn_name.c +++ b/source4/lib/ldb/modules/rdn_name.c @@ -36,7 +36,7 @@ * Simo Sorce Mar 2006 */ -#include "ldb_includes.h" +#include "ldb_module.h" struct rename_context { @@ -86,6 +86,7 @@ static int rdn_name_add_callback(struct ldb_request *req, static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *down_req; struct rename_context *ac; struct ldb_message *msg; @@ -95,7 +96,8 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) struct ldb_val rdn_val; int i, ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_add_record\n"); + ldb = ldb_module_get_ctx(module); + ldb_debug(ldb, LDB_DEBUG_TRACE, "rdn_name_add_record\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.add.message->dn)) { @@ -141,10 +143,10 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } } else { - a = ldb_schema_attribute_by_name(module->ldb, rdn_name); + a = ldb_schema_attribute_by_name(ldb, rdn_name); for (i = 0; i < attribute->num_values; i++) { - ret = a->syntax->comparison_fn(module->ldb, msg, + ret = a->syntax->comparison_fn(ldb, msg, &rdn_val, &attribute->values[i]); if (ret == 0) { /* overwrite so it matches in case */ @@ -153,7 +155,7 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) } } if (i == attribute->num_values) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "RDN mismatch on %s: %s (%s)", ldb_dn_get_linearized(msg->dn), rdn_name, rdn_val.data); talloc_free(ac); @@ -162,7 +164,7 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) } } - ret = ldb_build_add_req(&down_req, module->ldb, req, + ret = ldb_build_add_req(&down_req, ldb, req, msg, req->controls, ac, rdn_name_add_callback, @@ -205,6 +207,7 @@ static int rdn_modify_callback(struct ldb_request *req, struct ldb_reply *ares) static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct rename_context *ac; struct ldb_request *mod_req; const char *rdn_name; @@ -213,6 +216,7 @@ static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares) int ret; ac = talloc_get_type(req->context, struct rename_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { goto error; @@ -258,7 +262,7 @@ static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares) goto error; } - ret = ldb_build_mod_req(&mod_req, ac->module->ldb, + ret = ldb_build_mod_req(&mod_req, ldb, ac, msg, NULL, ac, rdn_modify_callback, req); @@ -268,7 +272,7 @@ static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares) talloc_steal(mod_req, msg); /* do the mod call */ - return ldb_request(ac->module->ldb, mod_req); + return ldb_request(ldb, mod_req); error: return ldb_module_done(ac->req, NULL, NULL, @@ -277,11 +281,13 @@ error: static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct rename_context *ac; struct ldb_request *down_req; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n"); + ldb = ldb_module_get_ctx(module); + ldb_debug(ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.rename.newdn)) { @@ -297,7 +303,7 @@ static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req) ac->req = req; ret = ldb_build_rename_req(&down_req, - module->ldb, + ldb, ac, req->op.rename.olddn, req->op.rename.newdn, diff --git a/source4/lib/ldb/modules/skel.c b/source4/lib/ldb/modules/skel.c index 0cd29ac4b7..248f9b346b 100644 --- a/source4/lib/ldb/modules/skel.c +++ b/source4/lib/ldb/modules/skel.c @@ -31,7 +31,7 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_module.h" struct private_data { @@ -87,9 +87,13 @@ static int skel_del_trans(struct ldb_module *module) static int skel_destructor(struct ldb_module *ctx) { - struct private_data *data = talloc_get_type(ctx->private_data, struct private_data); + struct private_data *data; + + data = talloc_get_type(ldb_module_get_private(ctx), struct private_data); + /* put your clean-up functions here */ if (data->some_private_data) talloc_free(data->some_private_data); + return 0; } @@ -100,16 +104,19 @@ static int skel_request(struct ldb_module *module, struct ldb_request *req) static int skel_init(struct ldb_module *module) { + struct ldb_context *ldb; struct private_data *data; + ldb = ldb_module_get_ctx(module); + data = talloc(module, struct private_data); if (data == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } data->some_private_data = NULL; - module->private_data = data; + ldb_module_set_private(module, data); talloc_set_destructor (module, skel_destructor); diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c index 25e56b24c8..2b2a1ab1e3 100644 --- a/source4/lib/ldb/modules/sort.c +++ b/source4/lib/ldb/modules/sort.c @@ -31,7 +31,7 @@ * Author: Simo Sorce */ -#include "ldb_includes.h" +#include "ldb_module.h" struct opaque { struct ldb_context *ldb; @@ -104,6 +104,9 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo { struct sort_context *ac = talloc_get_type(opaque, struct sort_context); struct ldb_message_element *el1, *el2; + struct ldb_context *ldb; + + ldb = ldb_module_get_ctx(ac->module); if (!ac || ac->sort_result != 0) { /* an error occurred previously, @@ -122,17 +125,20 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo } if (ac->reverse) - return ac->a->syntax->comparison_fn(ac->module->ldb, ac, &el2->values[0], &el1->values[0]); + return ac->a->syntax->comparison_fn(ldb, ac, &el2->values[0], &el1->values[0]); - return ac->a->syntax->comparison_fn(ac->module->ldb, ac, &el1->values[0], &el2->values[0]); + return ac->a->syntax->comparison_fn(ldb, ac, &el1->values[0], &el2->values[0]); } static int server_sort_results(struct sort_context *ac) { + struct ldb_context *ldb; struct ldb_reply *ares; int i, ret; - ac->a = ldb_schema_attribute_by_name(ac->module->ldb, ac->attributeName); + ldb = ldb_module_get_ctx(ac->module); + + ac->a = ldb_schema_attribute_by_name(ldb, ac->attributeName); ac->sort_result = 0; ldb_qsort(ac->msgs, ac->num_msgs, @@ -179,9 +185,11 @@ static int server_sort_results(struct sort_context *ac) static int server_sort_search_callback(struct ldb_request *req, struct ldb_reply *ares) { struct sort_context *ac; + struct ldb_context *ldb; int ret; ac = talloc_get_type(req->context, struct sort_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -197,7 +205,7 @@ static int server_sort_search_callback(struct ldb_request *req, struct ldb_reply ac->msgs = talloc_realloc(ac, ac->msgs, struct ldb_message *, ac->num_msgs + 2); if (! ac->msgs) { talloc_free(ares); - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -212,7 +220,7 @@ static int server_sort_search_callback(struct ldb_request *req, struct ldb_reply ac->referrals = talloc_realloc(ac, ac->referrals, char *, ac->num_refs + 2); if (! ac->referrals) { talloc_free(ares); - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -242,8 +250,11 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req struct ldb_control **controls; struct ldb_request *down_req; struct sort_context *ac; + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(module); + /* check if there's a paged request control */ control = ldb_request_get_control(req, LDB_CONTROL_SERVER_SORT_OID); if (control == NULL) { @@ -253,7 +264,7 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req ac = talloc_zero(req, struct sort_context); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -291,7 +302,7 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req ac->orderingRule = sort_ctrls[0]->orderingRule; ac->reverse = sort_ctrls[0]->reverse; - ret = ldb_build_search_req_ex(&down_req, module->ldb, ac, + ret = ldb_build_search_req_ex(&down_req, ldb, ac, req->op.search.base, req->op.search.scope, req->op.search.tree, @@ -316,11 +327,14 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req static int server_sort_init(struct ldb_module *module) { + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(module); + ret = ldb_mod_register_control(module, LDB_CONTROL_SERVER_SORT_OID); if (ret != LDB_SUCCESS) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "server_sort:" "Unable to register control with rootdse!\n"); } diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index 9e98363c6f..f71ee23340 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -25,7 +25,7 @@ License along with this library; if not, see . */ -#include "ldb_includes.h" +#include "ldb_private.h" #include #include "pyldb.h" diff --git a/source4/lib/ldb/tests/sample_module.c b/source4/lib/ldb/tests/sample_module.c index 1a9e72c907..bbe4419b59 100644 --- a/source4/lib/ldb/tests/sample_module.c +++ b/source4/lib/ldb/tests/sample_module.c @@ -21,9 +21,7 @@ License along with this library; if not, see . */ -#include "ldb_includes.h" -#include "ldb.h" -#include "ldb_errors.h" +#include "ldb_module.h" int sample_add(struct ldb_module *mod, struct ldb_request *req) { diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c index 765d8b9edf..3dce9b187b 100644 --- a/source4/lib/ldb/tools/cmdline.c +++ b/source4/lib/ldb/tools/cmdline.c @@ -21,7 +21,7 @@ License along with this library; if not, see . */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" #if (_SAMBA_BUILD_ >= 4) @@ -91,7 +91,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, ret = talloc_zero(ldb, struct ldb_cmdline); if (ret == NULL) { - ldb_oom(ldb); + fprintf(stderr, "Out of memory!\n"); goto failed; } @@ -139,7 +139,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, options.options = talloc_realloc(ret, options.options, const char *, num_options+3); if (options.options == NULL) { - ldb_oom(ldb); + fprintf(stderr, "Out of memory!\n"); goto failed; } options.options[num_options] = poptGetOptArg(pc); @@ -156,7 +156,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, options.controls = talloc_array(ret, char *, cc + 1); if (options.controls == NULL) { - ldb_oom(ldb); + fprintf(stderr, "Out of memory!\n"); goto failed; } for (p = cs, cc = 0; p != NULL; cc++) { diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index f32a4fa9bc..be02334797 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" static int failures; diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c index 22d4aa6976..232f51681a 100644 --- a/source4/lib/ldb/tools/ldbdel.c +++ b/source4/lib/ldb/tools/ldbdel.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn) diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c index 1a684c5c2d..3a915f8bea 100644 --- a/source4/lib/ldb/tools/ldbedit.c +++ b/source4/lib/ldb/tools/ldbedit.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" static struct ldb_cmdline *options; diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c index 6e355a10cf..c3f55c6096 100644 --- a/source4/lib/ldb/tools/ldbmodify.c +++ b/source4/lib/ldb/tools/ldbmodify.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" static int failures; diff --git a/source4/lib/ldb/tools/ldbrename.c b/source4/lib/ldb/tools/ldbrename.c index a5feb7a091..01ed3d9835 100644 --- a/source4/lib/ldb/tools/ldbrename.c +++ b/source4/lib/ldb/tools/ldbrename.c @@ -33,7 +33,7 @@ * Author: Stefan Metzmacher */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" static void usage(void) diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c index ceabd5cd78..35d4ac7002 100644 --- a/source4/lib/ldb/tools/ldbsearch.c +++ b/source4/lib/ldb/tools/ldbsearch.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" static void usage(void) diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c index f3d6d621a9..edaa9fb85c 100644 --- a/source4/lib/ldb/tools/ldbtest.c +++ b/source4/lib/ldb/tools/ldbtest.c @@ -31,7 +31,7 @@ * Author: Andrew Tridgell */ -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" static struct timeval tp1,tp2; diff --git a/source4/libcli/ldap/config.mk b/source4/libcli/ldap/config.mk index 11157c5b63..2708c66b68 100644 --- a/source4/libcli/ldap/config.mk +++ b/source4/libcli/ldap/config.mk @@ -13,6 +13,6 @@ PUBLIC_HEADERS += $(libclisrcdir)/ldap/ldap.h $(libclisrcdir)/ldap/ldap_ndr.h $(eval $(call proto_header_template,$(libclisrcdir)/ldap/ldap_proto.h,$(LIBCLI_LDAP_OBJ_FILES:.o=.c))) [SUBSYSTEM::LDAP_ENCODE] -# FIXME PRIVATE_DEPENDENCIES = LIBLDB +PRIVATE_DEPENDENCIES = LIBLDB LDAP_ENCODE_OBJ_FILES = $(libclisrcdir)/ldap/ldap_ndr.o diff --git a/source4/libcli/ldap/ldap.h b/source4/libcli/ldap/ldap.h index 5538c9dc06..abb4617c48 100644 --- a/source4/libcli/ldap/ldap.h +++ b/source4/libcli/ldap/ldap.h @@ -21,6 +21,7 @@ #ifndef _SMB_LDAP_H_ #define _SMB_LDAP_H_ +#include "libcli/ldap/ldap_errors.h" #include "lib/ldb/include/ldb.h" #include "librpc/gen_ndr/misc.h" @@ -52,48 +53,6 @@ enum ldap_auth_mechanism { LDAP_AUTH_MECH_SASL = 3 }; -enum ldap_result_code { - LDAP_SUCCESS = 0, - LDAP_OPERATIONS_ERROR = 1, - LDAP_PROTOCOL_ERROR = 2, - LDAP_TIME_LIMIT_EXCEEDED = 3, - LDAP_SIZE_LIMIT_EXCEEDED = 4, - LDAP_COMPARE_FALSE = 5, - LDAP_COMPARE_TRUE = 6, - LDAP_AUTH_METHOD_NOT_SUPPORTED = 7, - LDAP_STRONG_AUTH_REQUIRED = 8, - LDAP_REFERRAL = 10, - LDAP_ADMIN_LIMIT_EXCEEDED = 11, - LDAP_UNAVAILABLE_CRITICAL_EXTENSION = 12, - LDAP_CONFIDENTIALITY_REQUIRED = 13, - LDAP_SASL_BIND_IN_PROGRESS = 14, - LDAP_NO_SUCH_ATTRIBUTE = 16, - LDAP_UNDEFINED_ATTRIBUTE_TYPE = 17, - LDAP_INAPPROPRIATE_MATCHING = 18, - LDAP_CONSTRAINT_VIOLATION = 19, - LDAP_ATTRIBUTE_OR_VALUE_EXISTS = 20, - LDAP_INVALID_ATTRIBUTE_SYNTAX = 21, - LDAP_NO_SUCH_OBJECT = 32, - LDAP_ALIAS_PROBLEM = 33, - LDAP_INVALID_DN_SYNTAX = 34, - LDAP_ALIAS_DEREFERENCING_PROBLEM = 36, - LDAP_INAPPROPRIATE_AUTHENTICATION = 48, - LDAP_INVALID_CREDENTIALS = 49, - LDAP_INSUFFICIENT_ACCESS_RIGHTS = 50, - LDAP_BUSY = 51, - LDAP_UNAVAILABLE = 52, - LDAP_UNWILLING_TO_PERFORM = 53, - LDAP_LOOP_DETECT = 54, - LDAP_NAMING_VIOLATION = 64, - LDAP_OBJECT_CLASS_VIOLATION = 65, - LDAP_NOT_ALLOWED_ON_NON_LEAF = 66, - LDAP_NOT_ALLOWED_ON_RDN = 67, - LDAP_ENTRY_ALREADY_EXISTS = 68, - LDAP_OBJECT_CLASS_MODS_PROHIBITED = 69, - LDAP_AFFECTS_MULTIPLE_DSAS = 71, - LDAP_OTHER = 80 -}; - struct ldap_Result { int resultcode; const char *dn; diff --git a/source4/libcli/ldap/ldap_errors.h b/source4/libcli/ldap/ldap_errors.h new file mode 100644 index 0000000000..17ac43814c --- /dev/null +++ b/source4/libcli/ldap/ldap_errors.h @@ -0,0 +1,66 @@ +/* + Unix SMB/CIFS Implementation. + LDAP protocol helper functions for SAMBA + Copyright (C) Volker Lendecke 2004 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + +#ifndef _SMB_LDAP_ERRORS_H_ +#define _SMB_LDAP_ERRORS_H_ + +enum ldap_result_code { + LDAP_SUCCESS = 0, + LDAP_OPERATIONS_ERROR = 1, + LDAP_PROTOCOL_ERROR = 2, + LDAP_TIME_LIMIT_EXCEEDED = 3, + LDAP_SIZE_LIMIT_EXCEEDED = 4, + LDAP_COMPARE_FALSE = 5, + LDAP_COMPARE_TRUE = 6, + LDAP_AUTH_METHOD_NOT_SUPPORTED = 7, + LDAP_STRONG_AUTH_REQUIRED = 8, + LDAP_REFERRAL = 10, + LDAP_ADMIN_LIMIT_EXCEEDED = 11, + LDAP_UNAVAILABLE_CRITICAL_EXTENSION = 12, + LDAP_CONFIDENTIALITY_REQUIRED = 13, + LDAP_SASL_BIND_IN_PROGRESS = 14, + LDAP_NO_SUCH_ATTRIBUTE = 16, + LDAP_UNDEFINED_ATTRIBUTE_TYPE = 17, + LDAP_INAPPROPRIATE_MATCHING = 18, + LDAP_CONSTRAINT_VIOLATION = 19, + LDAP_ATTRIBUTE_OR_VALUE_EXISTS = 20, + LDAP_INVALID_ATTRIBUTE_SYNTAX = 21, + LDAP_NO_SUCH_OBJECT = 32, + LDAP_ALIAS_PROBLEM = 33, + LDAP_INVALID_DN_SYNTAX = 34, + LDAP_ALIAS_DEREFERENCING_PROBLEM = 36, + LDAP_INAPPROPRIATE_AUTHENTICATION = 48, + LDAP_INVALID_CREDENTIALS = 49, + LDAP_INSUFFICIENT_ACCESS_RIGHTS = 50, + LDAP_BUSY = 51, + LDAP_UNAVAILABLE = 52, + LDAP_UNWILLING_TO_PERFORM = 53, + LDAP_LOOP_DETECT = 54, + LDAP_NAMING_VIOLATION = 64, + LDAP_OBJECT_CLASS_VIOLATION = 65, + LDAP_NOT_ALLOWED_ON_NON_LEAF = 66, + LDAP_NOT_ALLOWED_ON_RDN = 67, + LDAP_ENTRY_ALREADY_EXISTS = 68, + LDAP_OBJECT_CLASS_MODS_PROHIBITED = 69, + LDAP_AFFECTS_MULTIPLE_DSAS = 71, + LDAP_OTHER = 80 +}; + +#endif /* _SMB_LDAP_ERRORS_H_ */ diff --git a/source4/libcli/security/security_token.c b/source4/libcli/security/security_token.c index 0680c54258..e1349e06f8 100644 --- a/source4/libcli/security/security_token.c +++ b/source4/libcli/security/security_token.c @@ -21,7 +21,6 @@ */ #include "includes.h" -#include "dsdb/samdb/samdb.h" #include "libcli/security/security.h" #include "auth/session.h" diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c index e94ed36d39..8371837dcb 100644 --- a/source4/libcli/util/nterr.c +++ b/source4/libcli/util/nterr.c @@ -20,7 +20,7 @@ /* NT error codes. please read nterr.h */ #include "includes.h" -#include "libcli/ldap/ldap.h" +#include "libcli/ldap/ldap_errors.h" #undef strcasecmp typedef struct diff --git a/source4/nbt_server/config.mk b/source4/nbt_server/config.mk index b6db2090d2..afd9242188 100644 --- a/source4/nbt_server/config.mk +++ b/source4/nbt_server/config.mk @@ -18,7 +18,7 @@ $(eval $(call proto_header_template,$(nbt_serversrcdir)/wins/winsdb_proto.h,$(WI SUBSYSTEM = LIBLDB INIT_FUNCTION = LDB_MODULE(wins_ldb) PRIVATE_DEPENDENCIES = \ - LIBNETIF LIBSAMBA-HOSTCONFIG LIBSAMBA-UTIL + LIBLDB LIBNETIF LIBSAMBA-HOSTCONFIG LIBSAMBA-UTIL # End MODULE ldb_wins_ldb ####################### diff --git a/source4/nbt_server/wins/wins_ldb.c b/source4/nbt_server/wins/wins_ldb.c index 557c0f1dc6..7effb9b842 100644 --- a/source4/nbt_server/wins/wins_ldb.c +++ b/source4/nbt_server/wins/wins_ldb.c @@ -28,6 +28,7 @@ */ #include "includes.h" +#include "lib/events/events.h" #include "nbt_server/nbt_server.h" #include "nbt_server/wins/winsdb.h" #include "lib/ldb/include/ldb.h" diff --git a/source4/ntvfs/ipc/rap_server.c b/source4/ntvfs/ipc/rap_server.c index df065eb5e2..2bc07c3e7b 100644 --- a/source4/ntvfs/ipc/rap_server.c +++ b/source4/ntvfs/ipc/rap_server.c @@ -21,6 +21,7 @@ #include "includes.h" #include "param/share.h" #include "libcli/rap/rap.h" +#include "libcli/raw/interfaces.h" #include "librpc/gen_ndr/srvsvc.h" #include "rpc_server/common/common.h" #include "param/param.h" diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c index 601c876cfb..6b0f32e65a 100644 --- a/source4/ntvfs/posix/vfs_posix.c +++ b/source4/ntvfs/posix/vfs_posix.c @@ -28,7 +28,6 @@ #include "librpc/gen_ndr/security.h" #include "../tdb/include/tdb.h" #include "tdb_wrap.h" -#include "../lib/util/util_ldb.h" #include "libcli/security/security.h" #include "lib/events/events.h" #include "param/param.h" diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h index 342d28325e..b032ab3f93 100644 --- a/source4/ntvfs/posix/vfs_posix.h +++ b/source4/ntvfs/posix/vfs_posix.h @@ -27,7 +27,7 @@ #include "ntvfs/ntvfs.h" #include "ntvfs/common/ntvfs_common.h" #include "libcli/wbclient/wbclient.h" -#include "dsdb/samdb/samdb.h" +#include "lib/events/events.h" struct pvfs_wait; struct pvfs_oplock; diff --git a/source4/rpc_server/config.mk b/source4/rpc_server/config.mk index f00c975cca..a7d03ca22d 100644 --- a/source4/rpc_server/config.mk +++ b/source4/rpc_server/config.mk @@ -3,6 +3,7 @@ ################################################ # Start SUBSYSTEM DCERPC_COMMON [SUBSYSTEM::DCERPC_COMMON] +PRIVATE_DEPENDENCIES = LIBLDB # # End SUBSYSTEM DCERPC_COMMON ################################################ diff --git a/source4/smb_server/smb_samba3.c b/source4/smb_server/smb_samba3.c index c3675c1ba5..1c84392b0c 100644 --- a/source4/smb_server/smb_samba3.c +++ b/source4/smb_server/smb_samba3.c @@ -31,7 +31,6 @@ #include "system/network.h" #include "lib/socket/netif.h" #include "param/share.h" -#include "dsdb/samdb/samdb.h" #include "param/param.h" #include "dynconfig/dynconfig.h" #include "smbd/process_model.h" diff --git a/source4/utils/ad2oLschema.c b/source4/utils/ad2oLschema.c index 29fda09f3c..236b1fa350 100644 --- a/source4/utils/ad2oLschema.c +++ b/source4/utils/ad2oLschema.c @@ -32,7 +32,7 @@ */ #include "includes.h" -#include "ldb_includes.h" +#include "ldb.h" #include "system/locale.h" #include "lib/ldb/tools/cmdline.h" #include "param/param.h" diff --git a/source4/utils/net/net_machinepw.c b/source4/utils/net/net_machinepw.c index 4e3165dbfd..390eb8df0b 100644 --- a/source4/utils/net/net_machinepw.c +++ b/source4/utils/net/net_machinepw.c @@ -19,12 +19,12 @@ */ #include "includes.h" +#include "lib/events/events.h" #include "utils/net/net.h" #include "libnet/libnet.h" #include "libcli/security/security.h" #include "param/secrets.h" #include "param/param.h" -#include "lib/events/events.h" #include "lib/util/util_ldb.h" int net_machinepw_usage(struct net_context *ctx, int argc, const char **argv) diff --git a/source4/utils/oLschema2ldif.c b/source4/utils/oLschema2ldif.c index 6c4e6a9c80..701d221046 100644 --- a/source4/utils/oLschema2ldif.c +++ b/source4/utils/oLschema2ldif.c @@ -32,7 +32,7 @@ */ #include "includes.h" -#include "ldb_includes.h" +#include "ldb.h" #include "tools/cmdline.h" #include "dsdb/samdb/samdb.h" -- cgit From 4e0a61970120e10a6309251a97e660697818fa8a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 30 Jan 2009 01:01:05 -0500 Subject: Fix standalone configure scripts --- lib/tevent/build_macros.m4 | 1 + source4/lib/ldb/build_macros.m4 | 1 + source4/lib/ldb/external/libevents.m4 | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tevent/build_macros.m4 b/lib/tevent/build_macros.m4 index c036668cd1..bb7fad8f7a 100644 --- a/lib/tevent/build_macros.m4 +++ b/lib/tevent/build_macros.m4 @@ -7,6 +7,7 @@ AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR, if test x"$with_shared_build_dir" != x; then sharedbuilddir=$with_shared_build_dir CFLAGS="$CFLAGS -I$with_shared_build_dir/include" + CPPFLAGS="$CPPFLAGS -I$with_shared_build_dir/include" LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib" fi AC_SUBST(sharedbuilddir) diff --git a/source4/lib/ldb/build_macros.m4 b/source4/lib/ldb/build_macros.m4 index c036668cd1..bb7fad8f7a 100644 --- a/source4/lib/ldb/build_macros.m4 +++ b/source4/lib/ldb/build_macros.m4 @@ -7,6 +7,7 @@ AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR, if test x"$with_shared_build_dir" != x; then sharedbuilddir=$with_shared_build_dir CFLAGS="$CFLAGS -I$with_shared_build_dir/include" + CPPFLAGS="$CPPFLAGS -I$with_shared_build_dir/include" LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib" fi AC_SUBST(sharedbuilddir) diff --git a/source4/lib/ldb/external/libevents.m4 b/source4/lib/ldb/external/libevents.m4 index 24534f2c21..6a0e36af8b 100644 --- a/source4/lib/ldb/external/libevents.m4 +++ b/source4/lib/ldb/external/libevents.m4 @@ -3,5 +3,5 @@ AC_SUBST(TEVENT_CFLAGS) AC_SUBST(TEVENT_LIBS) AC_CHECK_HEADER(tevent.h, - [AC_CHECK_LIB(tevent, event_context_init, [TEVENT_LIBS="-ltevent"]) ], + [AC_CHECK_LIB(tevent, tevent_context_init, [TEVENT_LIBS="-ltevent"]) ], [PKG_CHECK_MODULES(TEVENT, tevent)]) -- cgit From 52a49b448e4a9ccd3044b47a9efaf15f30fbd032 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 08:25:27 +0100 Subject: selftest: allow environment options We support "local" and "client" (default) now. We can decide if we want to run a client against the server (with a special client.conf) or if we want to run tests localy on the server with the same config as the server. metze --- selftest/selftest.pl | 58 +++++++++++++++++++++++++++++++---------------- selftest/target/Samba4.pm | 11 ++++----- source4/selftest/tests.sh | 4 ++-- 3 files changed, 44 insertions(+), 29 deletions(-) diff --git a/selftest/selftest.pl b/selftest/selftest.pl index 97cf697179..7d40db5371 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -572,16 +572,6 @@ sub write_clientconf($$) if (defined($vars->{REALM})) { print CF "\trealm = $vars->{REALM}\n"; } - if (defined($vars->{NCALRPCDIR})) { - print CF "\tncalrpc dir = $vars->{NCALRPCDIR}\n"; - } - if (defined($vars->{PIDDIR})) { - print CF "\tpid directory = $vars->{PIDDIR}\n"; - } - if (defined($vars->{WINBINDD_SOCKET_DIR})) { - print CF "\twinbindd socket directory = $vars->{WINBINDD_SOCKET_DIR}\n"; - print CF "\twinbindd:socket dir = $vars->{WINBINDD_SOCKET_DIR}\n"; - } if ($opt_socket_wrapper) { print CF "\tinterfaces = $interfaces\n"; } @@ -706,6 +696,17 @@ $| = 1; my %running_envs = (); +sub get_running_env($) +{ + my ($name) = @_; + + my $envname = $name; + + $envname =~ s/:.*//; + + return $running_envs{$envname}; +} + my @exported_envvars = ( # domain stuff "DOMAIN", @@ -743,13 +744,22 @@ $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub { sub setup_env($) { - my ($envname) = @_; + my ($name) = @_; + + my $testenv_vars = undef; + + my $envname = $name; + my $option = $name; + + $envname =~ s/:.*//; + $option =~ s/^[^:]*://; + + $option = "client" if $option eq ""; - my $testenv_vars; if ($envname eq "none") { - $testenv_vars = {}; - } elsif (defined($running_envs{$envname})) { - $testenv_vars = $running_envs{$envname}; + $testenv_vars = \{}; + } elsif (defined(get_running_env($envname))) { + $testenv_vars = get_running_env($envname); if (not $target->check_env($testenv_vars)) { $testenv_vars = undef; } @@ -761,8 +771,16 @@ sub setup_env($) $running_envs{$envname} = $testenv_vars; - SocketWrapper::set_default_iface(6); - write_clientconf($conffile, $testenv_vars); + if ($option eq "local") { + SocketWrapper::set_default_iface($testenv_vars->{SOCKET_WRAPPER_DEFAULT_IFACE}); + $ENV{SMB_CONF_PATH} = $testenv_vars->{SERVERCONFFILE}; + } elsif ($option eq "client") { + SocketWrapper::set_default_iface(6); + write_clientconf($conffile, $testenv_vars); + $ENV{SMB_CONF_PATH} = $conffile; + } else { + die("Unknown option[$option] for envname[$envname]"); + } foreach (@exported_envvars) { if (defined($testenv_vars->{$_})) { @@ -792,21 +810,21 @@ sub getlog_env($) { my ($envname) = @_; return "" if ($envname eq "none"); - return $target->getlog_env($running_envs{$envname}); + return $target->getlog_env(get_running_env($envname)); } sub check_env($) { my ($envname) = @_; return 1 if ($envname eq "none"); - return $target->check_env($running_envs{$envname}); + return $target->check_env(get_running_env($envname)); } sub teardown_env($) { my ($envname) = @_; return if ($envname eq "none"); - $target->teardown_env($running_envs{$envname}); + $target->teardown_env(get_running_env($envname)); delete $running_envs{$envname}; } diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index 97f9878828..208824d6b2 100644 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -751,10 +751,14 @@ nogroup:x:65534:nobody WINBINDD_SOCKET_DIR => $winbindd_socket_dir, NCALRPCDIR => $ncalrpcdir, LOCKDIR => $lockdir, + SERVERCONFFILE => $conffile, CONFIGURATION => $configuration, SOCKET_WRAPPER_DEFAULT_IFACE => $swiface, NSS_WRAPPER_PASSWD => $nsswrap_passwd, NSS_WRAPPER_GROUP => $nsswrap_group, + SMBD_TEST_FIFO => "$prefix/smbd_test.fifo", + SMBD_TEST_LOG => "$prefix/smbd_test.log", + SMBD_TEST_LOG_POS => 0, }; if (defined($self->{ldap})) { @@ -812,10 +816,6 @@ sub provision_member($$$) system($cmd) == 0 or die("Join failed\n$cmd"); - $ret->{SMBD_TEST_FIFO} = "$prefix/smbd_test.fifo"; - $ret->{SMBD_TEST_LOG} = "$prefix/smbd_test.log"; - $ret->{SMBD_TEST_LOG_POS} = 0; - $ret->{DC_SERVER} = $dcvars->{SERVER}; $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP}; $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME}; @@ -841,9 +841,6 @@ sub provision_dc($$) $self->add_wins_config("$prefix/private") or die("Unable to add wins configuration"); - $ret->{SMBD_TEST_FIFO} = "$prefix/server_test.fifo"; - $ret->{SMBD_TEST_LOG} = "$prefix/server_test.log"; - $ret->{SMBD_TEST_LOG_POS} = 0; return $ret; } diff --git a/source4/selftest/tests.sh b/source4/selftest/tests.sh index 88b83631ba..5c2b0792eb 100755 --- a/source4/selftest/tests.sh +++ b/source4/selftest/tests.sh @@ -298,8 +298,8 @@ plantest "blackbox.nmblookup" member $samba4srcdir/utils/tests/test_nmblookup.sh plantest "blackbox.locktest" dc $samba4srcdir/torture/tests/test_locktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX" plantest "blackbox.masktest" dc $samba4srcdir/torture/tests/test_masktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX" plantest "blackbox.gentest" dc $samba4srcdir/torture/tests/test_gentest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX" -plantest "blackbox.wbinfo" dc $samba4srcdir/../nsswitch/tests/test_wbinfo.sh "\$DOMAIN" "\$USERNAME" "\$PASSWORD" "dc" -plantest "blackbox.wbinfo" member $samba4srcdir/../nsswitch/tests/test_wbinfo.sh "\$DOMAIN" "\$DC_USERNAME" "\$DC_PASSWORD" "member" +plantest "blackbox.wbinfo" dc:local $samba4srcdir/../nsswitch/tests/test_wbinfo.sh "\$DOMAIN" "\$USERNAME" "\$PASSWORD" "dc" +plantest "blackbox.wbinfo" member:local $samba4srcdir/../nsswitch/tests/test_wbinfo.sh "\$DOMAIN" "\$DC_USERNAME" "\$DC_PASSWORD" "member" # Tests using the "Simple" NTVFS backend -- cgit From 27e4032287e72bd3b1299210a487a5c16c8ae143 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 09:36:12 +0100 Subject: s4:fix the build after 380874ef863866c94c999ef53252b9d30df65e88 metze --- source4/dsdb/samdb/ldb_modules/objectguid.c | 1 + source4/lib/ldb/ldb_map/ldb_map_outbound.c | 1 + 2 files changed, 2 insertions(+) diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c index 46ba8ebdb3..afd878877b 100644 --- a/source4/dsdb/samdb/ldb_modules/objectguid.c +++ b/source4/dsdb/samdb/ldb_modules/objectguid.c @@ -35,6 +35,7 @@ #include "includes.h" #include "ldb_module.h" +#include "ldb_private.h" #include "librpc/gen_ndr/ndr_misc.h" #include "param/param.h" diff --git a/source4/lib/ldb/ldb_map/ldb_map_outbound.c b/source4/lib/ldb/ldb_map/ldb_map_outbound.c index 327fa92f8d..edd3f77b66 100644 --- a/source4/lib/ldb/ldb_map/ldb_map_outbound.c +++ b/source4/lib/ldb/ldb_map/ldb_map_outbound.c @@ -26,6 +26,7 @@ */ #include "ldb_module.h" +#include "ldb_private.h" #include "ldb_map.h" #include "ldb_map_private.h" -- cgit From fd82f593d75363e3d38f314425bc95ee192299b8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 10:01:48 +0100 Subject: selftest: fix default option name metze --- selftest/selftest.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/selftest/selftest.pl b/selftest/selftest.pl index 7d40db5371..cf25fa149a 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -752,7 +752,8 @@ sub setup_env($) my $option = $name; $envname =~ s/:.*//; - $option =~ s/^[^:]*://; + $option =~ s/^[^:]*//; + $option =~ s/^://; $option = "client" if $option eq ""; -- cgit From b88a0adbeda88729302bc8c8b027e197ebfc7015 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 10:29:39 +0100 Subject: selftest: fix "none" test metze --- selftest/selftest.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selftest/selftest.pl b/selftest/selftest.pl index cf25fa149a..b4cc4c1719 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -758,7 +758,7 @@ sub setup_env($) $option = "client" if $option eq ""; if ($envname eq "none") { - $testenv_vars = \{}; + $testenv_vars = {}; } elsif (defined(get_running_env($envname))) { $testenv_vars = get_running_env($envname); if (not $target->check_env($testenv_vars)) { -- cgit From fb7b92abc2bea4b3d91cdd896f02db88065a4b8f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 22 Jan 2009 19:31:22 +0100 Subject: s3-docs: fix typo in eventlogadm manpage. Guenther --- docs-xml/manpages-3/eventlogadm.8.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs-xml/manpages-3/eventlogadm.8.xml b/docs-xml/manpages-3/eventlogadm.8.xml index 04ba022032..51a066fc85 100644 --- a/docs-xml/manpages-3/eventlogadm.8.xml +++ b/docs-xml/manpages-3/eventlogadm.8.xml @@ -91,7 +91,7 @@ The -o write reads event log - records from standard input and writes them to theSamba + records from standard input and writes them to the Samba event log store named by EVENTLOG. @@ -180,7 +180,7 @@ - SRN - he name of the machine on + SRN - The name of the machine on which the eventlog was generated. This is typically the host name. -- cgit From 7b934c6af3f80c9d75151906eed929045cec28a2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 25 Jan 2009 21:54:55 +0100 Subject: Make cli_session_setup_guest async --- source3/include/proto.h | 4 ++ source3/libsmb/cliconnect.c | 140 ++++++++++++++++++++++++++++++++------------ 2 files changed, 107 insertions(+), 37 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 8276847706..943ab5e3f1 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2323,6 +2323,10 @@ NTSTATUS cli_session_setup(struct cli_state *cli, const char *pass, int passlen, const char *ntpass, int ntpasslen, const char *workgroup); +struct async_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct cli_state *cli); +NTSTATUS cli_session_setup_guest_recv(struct async_req *req); bool cli_ulogoff(struct cli_state *cli); bool cli_send_tconX(struct cli_state *cli, const char *share, const char *dev, const char *pass, int passlen); diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 5778e7f6a3..e1bba90329 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -161,50 +161,79 @@ static uint32 cli_session_setup_capabilities(struct cli_state *cli) Do a NT1 guest session setup. ****************************************************************************/ -static NTSTATUS cli_session_setup_guest(struct cli_state *cli) +struct async_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct cli_state *cli) { - char *p; - uint32 capabilities = cli_session_setup_capabilities(cli); + struct async_req *result; + uint16_t vwv[13]; + uint8_t *bytes; - memset(cli->outbuf, '\0', smb_size); - cli_set_message(cli->outbuf,13,0,True); - SCVAL(cli->outbuf,smb_com,SMBsesssetupX); - cli_setup_packet(cli); - - SCVAL(cli->outbuf,smb_vwv0,0xFF); - SSVAL(cli->outbuf,smb_vwv2,CLI_BUFFER_SIZE); - SSVAL(cli->outbuf,smb_vwv3,2); - SSVAL(cli->outbuf,smb_vwv4,cli->pid); - SIVAL(cli->outbuf,smb_vwv5,cli->sesskey); - SSVAL(cli->outbuf,smb_vwv7,0); - SSVAL(cli->outbuf,smb_vwv8,0); - SIVAL(cli->outbuf,smb_vwv11,capabilities); - p = smb_buf(cli->outbuf); - p += clistr_push(cli, p, "", -1, STR_TERMINATE); /* username */ - p += clistr_push(cli, p, "", -1, STR_TERMINATE); /* workgroup */ - p += clistr_push(cli, p, "Unix", -1, STR_TERMINATE); - p += clistr_push(cli, p, "Samba", -1, STR_TERMINATE); - cli_setup_bcc(cli, p); + SCVAL(vwv+0, 0, 0xFF); + SCVAL(vwv+0, 1, 0); + SSVAL(vwv+1, 0, 0); + SSVAL(vwv+2, 0, CLI_BUFFER_SIZE); + SSVAL(vwv+3, 0, 2); + SSVAL(vwv+4, 0, cli->pid); + SIVAL(vwv+5, 0, cli->sesskey); + SSVAL(vwv+7, 0, 0); + SSVAL(vwv+8, 0, 0); + SSVAL(vwv+9, 0, 0); + SSVAL(vwv+10, 0, 0); + SIVAL(vwv+11, 0, cli_session_setup_capabilities(cli)); + + bytes = talloc_array(talloc_tos(), uint8_t, 0); + + bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), "", 1, /* username */ + NULL); + bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), "", 1, /* workgroup */ + NULL); + bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), "Unix", + strlen("Unix")+1, NULL); + bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), "Samba", + strlen("Samba")+1, NULL); + + if (bytes == NULL) { + return NULL; + } + + result = cli_request_send(mem_ctx, ev, cli, SMBsesssetupX, 0, + 13, vwv, 0, talloc_get_size(bytes), bytes); + TALLOC_FREE(bytes); + return result; +} - if (!cli_send_smb(cli) || !cli_receive_smb(cli)) { - return cli_nt_error(cli); +NTSTATUS cli_session_setup_guest_recv(struct async_req *req) +{ + struct cli_request *cli_req = talloc_get_type_abort( + req->private_data, struct cli_request); + struct cli_state *cli = cli_req->cli; + uint8_t wct; + uint16_t *vwv; + uint16_t num_bytes; + uint8_t *bytes; + uint8_t *p; + NTSTATUS status; + + if (async_req_is_error(req, &status)) { + return status; } - - show_msg(cli->inbuf); - - if (cli_is_error(cli)) { - return cli_nt_error(cli); + + status = cli_pull_reply(req, &wct, &vwv, &num_bytes, &bytes); + if (!NT_STATUS_IS_OK(status)) { + return status; } - cli->vuid = SVAL(cli->inbuf,smb_uid); + p = bytes; - p = smb_buf(cli->inbuf); - p += clistr_pull(cli->inbuf, cli->server_os, p, sizeof(fstring), - -1, STR_TERMINATE); - p += clistr_pull(cli->inbuf, cli->server_type, p, sizeof(fstring), - -1, STR_TERMINATE); - p += clistr_pull(cli->inbuf, cli->server_domain, p, sizeof(fstring), - -1, STR_TERMINATE); + cli->vuid = SVAL(cli_req->inbuf, smb_uid); + + p += clistr_pull(cli_req->inbuf, cli->server_os, (char *)p, + sizeof(fstring), bytes+num_bytes-p, STR_TERMINATE); + p += clistr_pull(cli_req->inbuf, cli->server_type, (char *)p, + sizeof(fstring), bytes+num_bytes-p, STR_TERMINATE); + p += clistr_pull(cli_req->inbuf, cli->server_domain, (char *)p, + sizeof(fstring), bytes+num_bytes-p, STR_TERMINATE); if (strstr(cli->server_type, "Samba")) { cli->is_samba = True; @@ -215,6 +244,43 @@ static NTSTATUS cli_session_setup_guest(struct cli_state *cli) return NT_STATUS_OK; } +static NTSTATUS cli_session_setup_guest(struct cli_state *cli) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct event_context *ev; + struct async_req *req; + NTSTATUS status; + + if (cli->fd_event != NULL) { + /* + * Can't use sync call while an async call is in flight + */ + status = NT_STATUS_INVALID_PARAMETER; + goto fail; + } + + ev = event_context_init(frame); + if (ev == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + + req = cli_session_setup_guest_send(frame, ev, cli); + if (req == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + + while (req->state < ASYNC_REQ_DONE) { + event_loop_once(ev); + } + + status = cli_session_setup_guest_recv(req); + fail: + TALLOC_FREE(frame); + return status; +} + /**************************************************************************** Do a NT1 plaintext session setup. ****************************************************************************/ -- cgit From 0bd92281e49b91a9b9a14486adbe6f44affb7a13 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 26 Jan 2009 08:37:13 +0100 Subject: Make cli_tcon_andx async --- source3/client/smbspool.c | 9 +- source3/include/proto.h | 10 ++- source3/libsmb/cliconnect.c | 197 ++++++++++++++++++++++++++++++----------- source3/libsmb/clidfs.c | 9 +- source3/libsmb/libsmb_server.c | 17 ++-- source3/libsmb/passchange.c | 10 +-- source3/nmbd/nmbd_synclists.c | 2 +- source3/torture/locktest.c | 7 +- source3/torture/masktest.c | 7 +- source3/torture/torture.c | 20 +++-- source3/utils/net_rpc.c | 4 +- source3/utils/smbcacls.c | 10 ++- source3/winbindd/winbindd_cm.c | 9 +- 13 files changed, 210 insertions(+), 101 deletions(-) diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c index 1910ccd4fe..7943cf5828 100644 --- a/source3/client/smbspool.c +++ b/source3/client/smbspool.c @@ -432,10 +432,13 @@ smb_complete_connection(const char *myname, return NULL; } - if (!cli_send_tconX(cli, share, "?????", password, strlen(password) + 1)) { - fprintf(stderr, "ERROR: Tree connect failed (%s)\n", cli_errstr(cli)); + nt_status = cli_tcon_andx(cli, share, "?????", password, + strlen(password) + 1); + if (!NT_STATUS_IS_OK(nt_status)) { + fprintf(stderr, "ERROR: Tree connect failed (%s)\n", + nt_errstr(nt_status)); - if (get_exit_code(cli, cli_nt_error(cli)) == 2) { + if (get_exit_code(cli, nt_status) == 2) { *need_auth = true; } diff --git a/source3/include/proto.h b/source3/include/proto.h index 943ab5e3f1..b06d8d6758 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2328,8 +2328,14 @@ struct async_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx, struct cli_state *cli); NTSTATUS cli_session_setup_guest_recv(struct async_req *req); bool cli_ulogoff(struct cli_state *cli); -bool cli_send_tconX(struct cli_state *cli, - const char *share, const char *dev, const char *pass, int passlen); +struct async_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct cli_state *cli, + const char *share, const char *dev, + const char *pass, int passlen); +NTSTATUS cli_tcon_andx_recv(struct async_req *req); +NTSTATUS cli_tcon_andx(struct cli_state *cli, const char *share, + const char *dev, const char *pass, int passlen); bool cli_tdis(struct cli_state *cli); void cli_negprot_sendsync(struct cli_state *cli); NTSTATUS cli_negprot(struct cli_state *cli); diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index e1bba90329..ed5adc5694 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -1173,13 +1173,17 @@ bool cli_ulogoff(struct cli_state *cli) Send a tconX. ****************************************************************************/ -bool cli_send_tconX(struct cli_state *cli, - const char *share, const char *dev, const char *pass, int passlen) +struct async_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct cli_state *cli, + const char *share, const char *dev, + const char *pass, int passlen) { - fstring fullshare, pword; - char *p; - memset(cli->outbuf,'\0',smb_size); - memset(cli->inbuf,'\0',smb_size); + fstring pword; + char *tmp = NULL; + struct async_req *result; + uint16_t vwv[4]; + uint8_t *bytes; fstrcpy(cli->share, share); @@ -1187,9 +1191,10 @@ bool cli_send_tconX(struct cli_state *cli, if (cli->sec_mode & NEGOTIATE_SECURITY_USER_LEVEL) { passlen = 1; pass = ""; - } else if (!pass) { - DEBUG(1, ("Server not using user level security and no password supplied.\n")); - return False; + } else if (pass == NULL) { + DEBUG(1, ("Server not using user level security and no " + "password supplied.\n")); + goto access_denied; } if ((cli->sec_mode & NEGOTIATE_SECURITY_CHALLENGE_RESPONSE) && @@ -1198,28 +1203,32 @@ bool cli_send_tconX(struct cli_state *cli, DEBUG(1, ("Server requested LANMAN password " "(share-level security) but " "'client lanman auth' is disabled\n")); - return False; + goto access_denied; } /* - * Non-encrypted passwords - convert to DOS codepage before encryption. + * Non-encrypted passwords - convert to DOS codepage before + * encryption. */ passlen = 24; - SMBencrypt(pass,cli->secblob.data,(uchar *)pword); + SMBencrypt(pass, cli->secblob.data, (uchar *)pword); } else { - if((cli->sec_mode & (NEGOTIATE_SECURITY_USER_LEVEL|NEGOTIATE_SECURITY_CHALLENGE_RESPONSE)) == 0) { + if((cli->sec_mode & (NEGOTIATE_SECURITY_USER_LEVEL + |NEGOTIATE_SECURITY_CHALLENGE_RESPONSE)) + == 0) { if (!lp_client_plaintext_auth() && (*pass)) { DEBUG(1, ("Server requested plaintext " "password but 'client plaintext " "auth' is disabled\n")); - return False; + goto access_denied; } /* - * Non-encrypted passwords - convert to DOS codepage before using. + * Non-encrypted passwords - convert to DOS codepage + * before using. */ - passlen = clistr_push(cli, pword, pass, sizeof(pword), STR_TERMINATE); - + passlen = clistr_push(cli, pword, pass, sizeof(pword), + STR_TERMINATE); } else { if (passlen) { memcpy(pword, pass, passlen); @@ -1227,52 +1236,139 @@ bool cli_send_tconX(struct cli_state *cli, } } - slprintf(fullshare, sizeof(fullshare)-1, - "\\\\%s\\%s", cli->desthost, share); + SCVAL(vwv+0, 0, 0xFF); + SCVAL(vwv+0, 1, 0); + SSVAL(vwv+1, 0, 0); + SSVAL(vwv+2, 0, TCONX_FLAG_EXTENDED_RESPONSE); + SSVAL(vwv+3, 0, passlen); - cli_set_message(cli->outbuf,4, 0, True); - SCVAL(cli->outbuf,smb_com,SMBtconX); - cli_setup_packet(cli); + if (passlen) { + bytes = (uint8_t *)talloc_memdup(talloc_tos(), pword, passlen); + } else { + bytes = talloc_array(talloc_tos(), uint8_t, 0); + } - SSVAL(cli->outbuf,smb_vwv0,0xFF); - SSVAL(cli->outbuf,smb_vwv2,TCONX_FLAG_EXTENDED_RESPONSE); - SSVAL(cli->outbuf,smb_vwv3,passlen); + /* + * Add the sharename + */ + tmp = talloc_asprintf_strupper_m(talloc_tos(), "\\\\%s\\%s", + cli->desthost, share); + if (tmp == NULL) { + TALLOC_FREE(bytes); + return NULL; + } + bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), tmp, strlen(tmp)+1, + NULL); + TALLOC_FREE(tmp); - p = smb_buf(cli->outbuf); - if (passlen) { - memcpy(p,pword,passlen); + /* + * Add the devicetype + */ + tmp = talloc_strdup_upper(talloc_tos(), dev); + if (tmp == NULL) { + TALLOC_FREE(bytes); + return NULL; } - p += passlen; - p += clistr_push(cli, p, fullshare, -1, STR_TERMINATE |STR_UPPER); - p += clistr_push(cli, p, dev, -1, STR_TERMINATE |STR_UPPER | STR_ASCII); + bytes = smb_bytes_push_str(bytes, false, tmp, strlen(tmp)+1, NULL); + TALLOC_FREE(tmp); - cli_setup_bcc(cli, p); + if (bytes == NULL) { + return NULL; + } - cli_send_smb(cli); - if (!cli_receive_smb(cli)) - return False; + result = cli_request_send(mem_ctx, ev, cli, SMBtconX, 0, + 4, vwv, 0, talloc_get_size(bytes), bytes); + TALLOC_FREE(bytes); + return result; - if (cli_is_error(cli)) - return False; + access_denied: + result = async_req_new(mem_ctx); + if (async_post_status(result, ev, NT_STATUS_ACCESS_DENIED)) { + return result; + } + TALLOC_FREE(result); + return NULL; +} - clistr_pull(cli->inbuf, cli->dev, smb_buf(cli->inbuf), sizeof(fstring), - -1, STR_TERMINATE|STR_ASCII); +NTSTATUS cli_tcon_andx_recv(struct async_req *req) +{ + struct cli_request *cli_req = talloc_get_type_abort( + req->private_data, struct cli_request); + struct cli_state *cli = cli_req->cli; + uint8_t wct; + uint16_t *vwv; + uint16_t num_bytes; + uint8_t *bytes; + NTSTATUS status; - if (cli->protocol >= PROTOCOL_NT1 && - smb_buflen(cli->inbuf) == 3) { + if (async_req_is_error(req, &status)) { + return status; + } + + status = cli_pull_reply(req, &wct, &vwv, &num_bytes, &bytes); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + clistr_pull(cli_req->inbuf, cli->dev, bytes, sizeof(fstring), + num_bytes, STR_TERMINATE|STR_ASCII); + + if ((cli->protocol >= PROTOCOL_NT1) && (num_bytes == 3)) { /* almost certainly win95 - enable bug fixes */ cli->win95 = True; } - /* Make sure that we have the optional support 16-bit field. WCT > 2 */ - /* Avoids issues when connecting to Win9x boxes sharing files */ + /* + * Make sure that we have the optional support 16-bit field. WCT > 2. + * Avoids issues when connecting to Win9x boxes sharing files + */ - cli->dfsroot = False; - if ( (CVAL(cli->inbuf, smb_wct))>2 && cli->protocol >= PROTOCOL_LANMAN2 ) - cli->dfsroot = (SVAL( cli->inbuf, smb_vwv2 ) & SMB_SHARE_IN_DFS) ? True : False; + cli->dfsroot = false; - cli->cnum = SVAL(cli->inbuf,smb_tid); - return True; + if ((wct > 2) && (cli->protocol >= PROTOCOL_LANMAN2)) { + cli->dfsroot = ((SVAL(vwv+2, 0) & SMB_SHARE_IN_DFS) != 0); + } + + cli->cnum = SVAL(cli_req->inbuf,smb_tid); + return NT_STATUS_OK; +} + +NTSTATUS cli_tcon_andx(struct cli_state *cli, const char *share, + const char *dev, const char *pass, int passlen) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct event_context *ev; + struct async_req *req; + NTSTATUS status; + + if (cli->fd_event != NULL) { + /* + * Can't use sync call while an async call is in flight + */ + status = NT_STATUS_INVALID_PARAMETER; + goto fail; + } + + ev = event_context_init(frame); + if (ev == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + + req = cli_tcon_andx_send(frame, ev, cli, share, dev, pass, passlen); + if (req == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + + while (req->state < ASYNC_REQ_DONE) { + event_loop_once(ev); + } + + status = cli_tcon_andx_recv(req); + fail: + TALLOC_FREE(frame); + return status; } /**************************************************************************** @@ -1956,8 +2052,9 @@ NTSTATUS cli_full_connection(struct cli_state **output_cli, } if (service) { - if (!cli_send_tconX(cli, service, service_type, password, pw_len)) { - nt_status = cli_nt_error(cli); + nt_status = cli_tcon_andx(cli, service, service_type, password, + pw_len); + if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(1,("failed tcon_X with %s\n", nt_errstr(nt_status))); cli_shutdown(cli); if (NT_STATUS_IS_OK(nt_status)) { diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c index f853e4e670..e642f169f9 100644 --- a/source3/libsmb/clidfs.c +++ b/source3/libsmb/clidfs.c @@ -275,9 +275,10 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx, /* must be a normal share */ - if (!cli_send_tconX(c, sharename, "?????", - password, strlen(password)+1)) { - d_printf("tree connect failed: %s\n", cli_errstr(c)); + status = cli_tcon_andx(c, sharename, "?????", + password, strlen(password)+1); + if (!NT_STATUS_IS_OK(status)) { + d_printf("tree connect failed: %s\n", nt_errstr(status)); cli_shutdown(c); return NULL; } @@ -1077,7 +1078,7 @@ static bool cli_check_msdfs_proxy(TALLOC_CTX *ctx, /* check for the referral */ - if (!cli_send_tconX(cli, "IPC$", "IPC", NULL, 0)) { + if (!NT_STATUS_IS_OK(cli_tcon_andx(cli, "IPC$", "IPC", NULL, 0))) { return false; } diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index 0ece5bb649..6d7a86241a 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -300,11 +300,11 @@ SMBC_server(TALLOC_CTX *ctx, * tid. */ - if (!cli_send_tconX(srv->cli, share, "?????", - *pp_password, - strlen(*pp_password)+1)) { - - errno = SMBC_errno(context, srv->cli); + status = cli_tcon_andx(srv->cli, share, "?????", + *pp_password, + strlen(*pp_password)+1); + if (!NT_STATUS_IS_OK(status)) { + errno = map_errno_from_nt_status(status); cli_shutdown(srv->cli); srv->cli = NULL; smbc_getFunctionRemoveCachedServer(context)(context, @@ -501,9 +501,10 @@ again: DEBUG(4,(" session setup ok\n")); - if (!cli_send_tconX(c, share, "?????", - *pp_password, strlen(*pp_password)+1)) { - errno = SMBC_errno(context, c); + status = cli_tcon_andx(c, share, "?????", *pp_password, + strlen(*pp_password)+1); + if (!NT_STATUS_IS_OK(status)) { + errno = map_errno_from_nt_status(status); cli_shutdown(c); return NULL; } diff --git a/source3/libsmb/passchange.c b/source3/libsmb/passchange.c index 76b06088d6..f9ff4b3191 100644 --- a/source3/libsmb/passchange.c +++ b/source3/libsmb/passchange.c @@ -138,13 +138,13 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam cli_init_creds(cli, user_name, "", old_passwd); } - if (!cli_send_tconX(cli, "IPC$", "IPC", "", 1)) { - if (asprintf(err_str, "machine %s rejected the tconX on the IPC$ " - "share. Error was : %s.\n", - remote_machine, cli_errstr(cli)) == -1) { + result = cli_tcon_andx(cli, "IPC$", "IPC", "", 1); + if (!NT_STATUS_IS_OK(result)) { + if (asprintf(err_str, "machine %s rejected the tconX on the " + "IPC$ share. Error was : %s.\n", + remote_machine, nt_errstr(result))) { *err_str = NULL; } - result = cli_nt_error(cli); cli_shutdown(cli); return result; } diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c index 3e672aef25..5da0da81e5 100644 --- a/source3/nmbd/nmbd_synclists.c +++ b/source3/nmbd/nmbd_synclists.c @@ -109,7 +109,7 @@ static void sync_child(char *name, int nm_type, return; } - if (!cli_send_tconX(cli, "IPC$", "IPC", "", 1)) { + if (!NT_STATUS_IS_OK(cli_tcon_andx(cli, "IPC$", "IPC", "", 1))) { cli_shutdown(cli); return; } diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c index 1bff95f4f3..4e8dcdd09a 100644 --- a/source3/torture/locktest.c +++ b/source3/torture/locktest.c @@ -257,9 +257,10 @@ static struct cli_state *connect_one(char *share, int snum) DEBUG(4,(" session setup ok\n")); - if (!cli_send_tconX(c, share, "?????", - password[snum], strlen(password[snum])+1)) { - DEBUG(0,("tree connect failed: %s\n", cli_errstr(c))); + status = cli_tcon_andx(c, share, "?????", password[snum], + strlen(password[snum])+1); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("tree connect failed: %s\n", nt_errstr(status))); cli_shutdown(c); return NULL; } diff --git a/source3/torture/masktest.c b/source3/torture/masktest.c index 2c3bda1d43..fb562c8075 100644 --- a/source3/torture/masktest.c +++ b/source3/torture/masktest.c @@ -249,9 +249,10 @@ static struct cli_state *connect_one(char *share) DEBUG(4,(" session setup ok\n")); - if (!cli_send_tconX(c, share, "?????", - password, strlen(password)+1)) { - DEBUG(0,("tree connect failed: %s\n", cli_errstr(c))); + status = cli_tcon_andx(c, share, "?????", password, + strlen(password)+1); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("tree connect failed: %s\n", nt_errstr(status))); cli_shutdown(c); return NULL; } diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 85233bc0ae..1210a36a39 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -1101,6 +1101,7 @@ static bool run_tcon_test(int dummy) uint16 vuid1, vuid2; char buf[4]; bool ret = True; + NTSTATUS status; memset(buf, '\0', sizeof(buf)); @@ -1127,10 +1128,11 @@ static bool run_tcon_test(int dummy) return False; } - if (!cli_send_tconX(cli, share, "?????", - password, strlen(password)+1)) { + status = cli_tcon_andx(cli, share, "?????", + password, strlen(password)+1); + if (!NT_STATUS_IS_OK(status)) { printf("%s refused 2nd tree connect (%s)\n", host, - cli_errstr(cli)); + nt_errstr(status)); cli_shutdown(cli); return False; } @@ -1239,14 +1241,14 @@ static bool tcon_devtest(struct cli_state *cli, const char *return_devtype, NTSTATUS expected_error) { - bool status; + NTSTATUS status; bool ret; - status = cli_send_tconX(cli, myshare, devtype, - password, strlen(password)+1); + status = cli_tcon_andx(cli, myshare, devtype, + password, strlen(password)+1); if (NT_STATUS_IS_OK(expected_error)) { - if (status) { + if (NT_STATUS_IS_OK(status)) { if (strcmp(cli->dev, return_devtype) == 0) { ret = True; } else { @@ -1264,7 +1266,7 @@ static bool tcon_devtest(struct cli_state *cli, } cli_tdis(cli); } else { - if (status) { + if (NT_STATUS_IS_OK(status)) { printf("tconx to share %s with type %s " "should have failed but succeeded\n", myshare, devtype); @@ -2157,7 +2159,7 @@ static bool run_fdsesstest(int dummy) return False; saved_cnum = cli->cnum; - if (!cli_send_tconX(cli, share, "?????", "", 1)) + if (!NT_STATUS_IS_OK(cli_tcon_andx(cli, share, "?????", "", 1))) return False; new_cnum = cli->cnum; cli->cnum = saved_cnum; diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 0f59f02746..a37bbbd566 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -3022,7 +3022,7 @@ static int rpc_share_list(struct net_context *c, int argc, const char **argv) static bool check_share_availability(struct cli_state *cli, const char *netname) { - if (!cli_send_tconX(cli, netname, "A:", "", 0)) { + if (!NT_STATUS_IS_OK(cli_tcon_andx(cli, netname, "A:", "", 0))) { d_printf("skipping [%s]: not a file share.\n", netname); return false; } @@ -4281,7 +4281,7 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd, cnum = cli->cnum; - if (!cli_send_tconX(cli, netname, "A:", "", 0)) { + if (!NT_STATUS_IS_OK(cli_tcon_andx(cli, netname, "A:", "", 0))) { return; } diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index f07b5011c8..c12778f8c7 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -76,8 +76,9 @@ static NTSTATUS cli_lsa_lookup_sid(struct cli_state *cli, char **domains; char **names; - if (!cli_send_tconX(cli, "IPC$", "?????", "", 0)) { - return cli_nt_error(cli); + status = cli_tcon_andx(cli, "IPC$", "?????", "", 0); + if (!NT_STATUS_IS_OK(status)) { + return status; } status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id, @@ -124,8 +125,9 @@ static NTSTATUS cli_lsa_lookup_name(struct cli_state *cli, DOM_SID *sids; enum lsa_SidType *types; - if (!cli_send_tconX(cli, "IPC$", "?????", "", 0)) { - return cli_nt_error(cli); + status = cli_tcon_andx(cli, "IPC$", "?????", "", 0); + if (!NT_STATUS_IS_OK(status)) { + return status; } status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id, diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index ab1218c560..35768fe7f2 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -961,15 +961,10 @@ static NTSTATUS cm_prepare_connection(const struct winbindd_domain *domain, winbindd_set_locator_kdc_envs(domain); - if (!cli_send_tconX(*cli, "IPC$", "IPC", "", 0)) { - - result = cli_nt_error(*cli); + result = cli_tcon_andx(*cli, "IPC$", "IPC", "", 0); + if (!NT_STATUS_IS_OK(result)) { DEBUG(1,("failed tcon_X with %s\n", nt_errstr(result))); - - if (NT_STATUS_IS_OK(result)) - result = NT_STATUS_UNSUCCESSFUL; - goto done; } -- cgit From a0d52e7d54da450a734d7bc7f3827a2791e802b1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 26 Jan 2009 20:45:19 +0100 Subject: Add async cli_ntcreate --- source3/include/proto.h | 22 ++++++++ source3/libsmb/clifile.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) diff --git a/source3/include/proto.h b/source3/include/proto.h index b06d8d6758..04740f5cae 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2509,6 +2509,28 @@ int cli_nt_create_full(struct cli_state *cli, const char *fname, uint32 FileAttributes, uint32 ShareAccess, uint32 CreateDisposition, uint32 CreateOptions, uint8 SecuityFlags); +struct async_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct cli_state *cli, + const char *fname, + uint32_t CreatFlags, + uint32_t DesiredAccess, + uint32_t FileAttributes, + uint32_t ShareAccess, + uint32_t CreateDisposition, + uint32_t CreateOptions, + uint8_t SecurityFlags); +NTSTATUS cli_ntcreate_recv(struct async_req *req, uint16_t *pfnum); +NTSTATUS cli_ntcreate(struct cli_state *cli, + const char *fname, + uint32_t CreatFlags, + uint32_t DesiredAccess, + uint32_t FileAttributes, + uint32_t ShareAccess, + uint32_t CreateDisposition, + uint32_t CreateOptions, + uint8_t SecurityFlags, + uint16_t *pfid); int cli_nt_create(struct cli_state *cli, const char *fname, uint32 DesiredAccess); uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str, size_t str_len, size_t *pconverted_size); diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 3b6585b7e7..91f13a79ac 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -771,6 +771,138 @@ int cli_nt_create_full(struct cli_state *cli, const char *fname, return SVAL(cli->inbuf,smb_vwv2 + 1); } +struct async_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct cli_state *cli, + const char *fname, + uint32_t CreatFlags, + uint32_t DesiredAccess, + uint32_t FileAttributes, + uint32_t ShareAccess, + uint32_t CreateDisposition, + uint32_t CreateOptions, + uint8_t SecurityFlags) +{ + struct async_req *result; + uint8_t *bytes; + size_t converted_len; + uint16_t vwv[24]; + + SCVAL(vwv+0, 0, 0xFF); + SCVAL(vwv+0, 1, 0); + SSVAL(vwv+1, 0, 0); + SCVAL(vwv+2, 0, 0); + + if (cli->use_oplocks) { + CreatFlags |= (REQUEST_OPLOCK|REQUEST_BATCH_OPLOCK); + } + SIVAL(vwv+3, 1, CreatFlags); + SIVAL(vwv+5, 1, 0x0); /* RootDirectoryFid */ + SIVAL(vwv+7, 1, DesiredAccess); + SIVAL(vwv+9, 1, 0x0); /* AllocationSize */ + SIVAL(vwv+11, 1, 0x0); /* AllocationSize */ + SIVAL(vwv+13, 1, FileAttributes); + SIVAL(vwv+15, 1, ShareAccess); + SIVAL(vwv+17, 1, CreateDisposition); + SIVAL(vwv+19, 1, CreateOptions); + SIVAL(vwv+21, 1, 0x02); /* ImpersonationLevel */ + SCVAL(vwv+23, 1, SecurityFlags); + + bytes = talloc_array(talloc_tos(), uint8_t, 0); + bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), + fname, strlen(fname)+1, + &converted_len); + + /* sigh. this copes with broken netapp filer behaviour */ + bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), "", 1, NULL); + + if (bytes == NULL) { + return NULL; + } + + SIVAL(vwv+2, 1, converted_len); + + result = cli_request_send(mem_ctx, ev, cli, SMBntcreateX, 0, + 24, vwv, 0, talloc_get_size(bytes), bytes); + TALLOC_FREE(bytes); + return result; +} + +NTSTATUS cli_ntcreate_recv(struct async_req *req, uint16_t *pfnum) +{ + uint8_t wct; + uint16_t *vwv; + uint16_t num_bytes; + uint8_t *bytes; + NTSTATUS status; + + if (async_req_is_error(req, &status)) { + return status; + } + + status = cli_pull_reply(req, &wct, &vwv, &num_bytes, &bytes); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (wct < 3) { + return NT_STATUS_INVALID_NETWORK_RESPONSE; + } + + *pfnum = SVAL(vwv+2, 1); + + return NT_STATUS_OK; +} + +NTSTATUS cli_ntcreate(struct cli_state *cli, + const char *fname, + uint32_t CreatFlags, + uint32_t DesiredAccess, + uint32_t FileAttributes, + uint32_t ShareAccess, + uint32_t CreateDisposition, + uint32_t CreateOptions, + uint8_t SecurityFlags, + uint16_t *pfid) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct event_context *ev; + struct async_req *req; + NTSTATUS status; + + if (cli->fd_event != NULL) { + /* + * Can't use sync call while an async call is in flight + */ + status = NT_STATUS_INVALID_PARAMETER; + goto fail; + } + + ev = event_context_init(frame); + if (ev == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + + req = cli_ntcreate_send(frame, ev, cli, fname, CreatFlags, + DesiredAccess, FileAttributes, ShareAccess, + CreateDisposition, CreateOptions, + SecurityFlags); + if (req == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + + while (req->state < ASYNC_REQ_DONE) { + event_loop_once(ev); + } + + status = cli_ntcreate_recv(req, pfid); + fail: + TALLOC_FREE(frame); + return status; +} + /**************************************************************************** Open a file. ****************************************************************************/ -- cgit From b873ede89d3155438f7f9938d9a027cb4e3791e7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 29 Jan 2009 22:41:33 +0100 Subject: Make rpc_transport_np_init async --- source3/include/proto.h | 7 ++ source3/rpc_client/rpc_transport_np.c | 153 +++++++++++++++++++++++++++------- 2 files changed, 128 insertions(+), 32 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 04740f5cae..60e80bd87d 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5329,6 +5329,13 @@ NTSTATUS cli_get_session_key(TALLOC_CTX *mem_ctx, /* The following definitions come from rpc_client/rpc_transport_np.c */ +struct async_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct cli_state *cli, + const struct ndr_syntax_id *abstract_syntax); +NTSTATUS rpc_transport_np_init_recv(struct async_req *req, + TALLOC_CTX *mem_ctx, + struct rpc_cli_transport **presult); NTSTATUS rpc_transport_np_init(TALLOC_CTX *mem_ctx, struct cli_state *cli, const struct ndr_syntax_id *abstract_syntax, struct rpc_cli_transport **presult); diff --git a/source3/rpc_client/rpc_transport_np.c b/source3/rpc_client/rpc_transport_np.c index e8a333e509..68aae6a0cc 100644 --- a/source3/rpc_client/rpc_transport_np.c +++ b/source3/rpc_client/rpc_transport_np.c @@ -272,51 +272,140 @@ static NTSTATUS rpc_np_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } -NTSTATUS rpc_transport_np_init(TALLOC_CTX *mem_ctx, struct cli_state *cli, - const struct ndr_syntax_id *abstract_syntax, - struct rpc_cli_transport **presult) +struct rpc_transport_np_init_state { + struct rpc_cli_transport *transport; + struct rpc_transport_np_state *transport_np; +}; + +static void rpc_transport_np_init_pipe_open(struct async_req *subreq); + +struct async_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct cli_state *cli, + const struct ndr_syntax_id *abstract_syntax) { - struct rpc_cli_transport *result; - struct rpc_transport_np_state *state; - int fnum; + struct async_req *result, *subreq; + struct rpc_transport_np_init_state *state; + NTSTATUS status; - result = talloc(mem_ctx, struct rpc_cli_transport); - if (result == NULL) { - return NT_STATUS_NO_MEMORY; + if (!async_req_setup(mem_ctx, &result, &state, + struct rpc_transport_np_init_state)) { + return NULL; } - state = talloc(result, struct rpc_transport_np_state); - if (state == NULL) { - TALLOC_FREE(result); - return NT_STATUS_NO_MEMORY; + + state->transport = talloc(state, struct rpc_cli_transport); + if (state->transport == NULL) { + goto fail; + } + state->transport_np = talloc(state->transport, + struct rpc_transport_np_state); + if (state->transport_np == NULL) { + goto fail; } - result->priv = state; + state->transport->priv = state->transport_np; - state->cli = cli; - state->pipe_name = cli_get_pipe_name_from_iface( + state->transport_np->pipe_name = cli_get_pipe_name_from_iface( state, abstract_syntax); + if (state->transport_np->pipe_name == NULL) { + status = NT_STATUS_PIPE_NOT_AVAILABLE; + goto post_status; + } + state->transport_np->cli = cli; + + subreq = cli_ntcreate_send( + state, ev, cli, state->transport_np->pipe_name, 0, + DESIRED_ACCESS_PIPE, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_OPEN, 0, 0); + if (subreq == NULL) { + goto fail; + } + subreq->async.fn = rpc_transport_np_init_pipe_open; + subreq->async.priv = result; + return result; + + post_status: + if (async_post_status(result, ev, status)) { + return result; + } + fail: + TALLOC_FREE(result); + return NULL; +} + +static void rpc_transport_np_init_pipe_open(struct async_req *subreq) +{ + struct async_req *req = talloc_get_type_abort( + subreq->async.priv, struct async_req); + struct rpc_transport_np_init_state *state = talloc_get_type_abort( + req->private_data, struct rpc_transport_np_init_state); + NTSTATUS status; + + status = cli_ntcreate_recv(subreq, &state->transport_np->fnum); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status)) { + async_req_error(req, status); + return; + } + + talloc_set_destructor(state->transport_np, + rpc_transport_np_state_destructor); + async_req_done(req); +} + +NTSTATUS rpc_transport_np_init_recv(struct async_req *req, + TALLOC_CTX *mem_ctx, + struct rpc_cli_transport **presult) +{ + struct rpc_transport_np_init_state *state = talloc_get_type_abort( + req->private_data, struct rpc_transport_np_init_state); + NTSTATUS status; - fnum = cli_nt_create(cli, state->pipe_name, DESIRED_ACCESS_PIPE); - if (fnum == -1) { - DEBUG(3,("rpc_pipe_open_np: cli_nt_create failed on pipe %s " - "to machine %s. Error was %s\n", state->pipe_name, - cli->desthost, cli_errstr(cli))); - TALLOC_FREE(result); - return cli_get_nt_error(cli); + if (async_req_is_error(req, &status)) { + return status; } - state->fnum = fnum; - talloc_set_destructor(state, rpc_transport_np_state_destructor); - result->write_send = rpc_np_write_send; - result->write_recv = rpc_np_write_recv; - result->read_send = rpc_np_read_send; - result->read_recv = rpc_np_read_recv; - result->trans_send = rpc_np_trans_send; - result->trans_recv = rpc_np_trans_recv; + state->transport->write_send = rpc_np_write_send; + state->transport->write_recv = rpc_np_write_recv; + state->transport->read_send = rpc_np_read_send; + state->transport->read_recv = rpc_np_read_recv; + state->transport->trans_send = rpc_np_trans_send; + state->transport->trans_recv = rpc_np_trans_recv; - *presult = result; + *presult = talloc_move(mem_ctx, &state->transport); return NT_STATUS_OK; } +NTSTATUS rpc_transport_np_init(TALLOC_CTX *mem_ctx, struct cli_state *cli, + const struct ndr_syntax_id *abstract_syntax, + struct rpc_cli_transport **presult) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct event_context *ev; + struct async_req *req; + NTSTATUS status; + + ev = event_context_init(frame); + if (ev == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + + req = rpc_transport_np_init_send(frame, ev, cli, abstract_syntax); + if (req == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + + while (req->state < ASYNC_REQ_DONE) { + event_loop_once(ev); + } + + status = rpc_transport_np_init_recv(req, mem_ctx, presult); + fail: + TALLOC_FREE(frame); + return status; +} + struct cli_state *rpc_pipe_np_smb_conn(struct rpc_pipe_client *p) { struct rpc_transport_np_state *state = talloc_get_type( -- cgit From 22e3004829fe742efdbf750611749b9aaf585515 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 29 Jan 2009 22:54:55 +0100 Subject: Add the "SMBD" rpc transport The idea of this is that all client utils like smbpasswd and also for example "net join" do not access our internal databases like passdb and secrets.tdb directly anymore but pass everything throught the well-established RPC interfaces. The way you use this is the following: With rpc_cli_smbd_conn_init() or its async variant you initialize a "struct rpc_cli_smbd_conn". This structure is the link to a freshly forked smbd, ready to be used for RPC services. You should only ever have one such structure in your program. More don't hurt, but are plainly unnecessary. If you want to use the SAMR pipe to change a passwort, you connect to that pipe with rpc_pipe_open_local. Do you normal rpccli_samr calls on that and your locally forked smbd will connect to passdb for you. GD, this might make the distinction between the _l and _r calls in libnetapi mostly unnecessary. At least it is intended to do so... :-) --- source3/Makefile.in | 2 +- source3/include/proto.h | 34 ++ source3/include/smb.h | 1 + source3/rpc_client/cli_pipe.c | 55 +++ source3/rpc_client/rpc_transport_smbd.c | 694 ++++++++++++++++++++++++++++++++ 5 files changed, 785 insertions(+), 1 deletion(-) create mode 100644 source3/rpc_client/rpc_transport_smbd.c diff --git a/source3/Makefile.in b/source3/Makefile.in index 5448643c1d..9bc6329f82 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -579,7 +579,7 @@ RPC_PARSE_OBJ = $(RPC_PARSE_OBJ2) \ rpc_parse/parse_eventlog.o rpc_parse/parse_buffer.o RPC_CLIENT_OBJ = rpc_client/cli_pipe.o rpc_client/rpc_transport_np.o \ - rpc_client/rpc_transport_sock.o + rpc_client/rpc_transport_sock.o rpc_client/rpc_transport_smbd.o LOCKING_OBJ = locking/locking.o locking/brlock.o locking/posix.o diff --git a/source3/include/proto.h b/source3/include/proto.h index 60e80bd87d..d30eb09f6a 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5326,6 +5326,10 @@ NTSTATUS cli_rpc_pipe_open_krb5(struct cli_state *cli, NTSTATUS cli_get_session_key(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *cli, DATA_BLOB *session_key); +NTSTATUS rpc_pipe_open_local(TALLOC_CTX *mem_ctx, + struct rpc_cli_smbd_conn *conn, + const struct ndr_syntax_id *syntax, + struct rpc_pipe_client **presult); /* The following definitions come from rpc_client/rpc_transport_np.c */ @@ -5341,6 +5345,36 @@ NTSTATUS rpc_transport_np_init(TALLOC_CTX *mem_ctx, struct cli_state *cli, struct rpc_cli_transport **presult); struct cli_state *rpc_pipe_np_smb_conn(struct rpc_pipe_client *p); +/* The following definitions come from rpc_client/rpc_transport_smbd.c */ + +struct async_req *rpc_cli_smbd_conn_init_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + void (*stdout_callback)(char *buf, + size_t len, + void *priv), + void *priv); +NTSTATUS rpc_cli_smbd_conn_init_recv(struct async_req *req, + TALLOC_CTX *mem_ctx, + struct rpc_cli_smbd_conn **pconn); +NTSTATUS rpc_cli_smbd_conn_init(TALLOC_CTX *mem_ctx, + struct rpc_cli_smbd_conn **pconn, + void (*stdout_callback)(char *buf, + size_t len, + void *priv), + void *priv); + +struct async_req *rpc_transport_smbd_init_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct rpc_cli_smbd_conn *conn, + const struct ndr_syntax_id *abstract_syntax); +NTSTATUS rpc_transport_smbd_init_recv(struct async_req *req, + TALLOC_CTX *mem_ctx, + struct rpc_cli_transport **presult); +NTSTATUS rpc_transport_smbd_init(TALLOC_CTX *mem_ctx, + struct rpc_cli_smbd_conn *conn, + const struct ndr_syntax_id *abstract_syntax, + struct rpc_cli_transport **presult); + /* The following definitions come from rpc_client/rpc_transport_sock.c */ NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd, diff --git a/source3/include/smb.h b/source3/include/smb.h index 3f71cde395..9451710255 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -367,6 +367,7 @@ struct uuid; struct named_mutex; struct pcap_cache; struct wb_context; +struct rpc_cli_smbd_conn; struct vfs_fsp_data { struct vfs_fsp_data *next; diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index 5a53c0d940..83247df46b 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -3511,6 +3511,61 @@ static NTSTATUS rpc_pipe_open_np(struct cli_state *cli, return NT_STATUS_OK; } +NTSTATUS rpc_pipe_open_local(TALLOC_CTX *mem_ctx, + struct rpc_cli_smbd_conn *conn, + const struct ndr_syntax_id *syntax, + struct rpc_pipe_client **presult) +{ + struct rpc_pipe_client *result; + struct cli_pipe_auth_data *auth; + NTSTATUS status; + + result = talloc(mem_ctx, struct rpc_pipe_client); + if (result == NULL) { + return NT_STATUS_NO_MEMORY; + } + result->abstract_syntax = *syntax; + result->transfer_syntax = ndr_transfer_syntax; + result->dispatch = cli_do_rpc_ndr; + result->max_xmit_frag = RPC_MAX_PDU_FRAG_LEN; + result->max_recv_frag = RPC_MAX_PDU_FRAG_LEN; + + result->desthost = talloc_strdup(result, global_myname()); + result->srv_name_slash = talloc_asprintf_strupper_m( + result, "\\\\%s", global_myname()); + if ((result->desthost == NULL) || (result->srv_name_slash == NULL)) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + status = rpc_transport_smbd_init(result, conn, syntax, + &result->transport); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("rpc_transport_smbd_init failed: %s\n", + nt_errstr(status))); + TALLOC_FREE(result); + return status; + } + + status = rpccli_anon_bind_data(result, &auth); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("rpccli_anon_bind_data failed: %s\n", + nt_errstr(status))); + TALLOC_FREE(result); + return status; + } + + status = rpc_pipe_bind(result, auth); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("rpc_pipe_bind failed: %s\n", nt_errstr(status))); + TALLOC_FREE(result); + return status; + } + + *presult = result; + return NT_STATUS_OK; +} + /**************************************************************************** Open a pipe to a remote server. ****************************************************************************/ diff --git a/source3/rpc_client/rpc_transport_smbd.c b/source3/rpc_client/rpc_transport_smbd.c new file mode 100644 index 0000000000..0ff4ebd468 --- /dev/null +++ b/source3/rpc_client/rpc_transport_smbd.c @@ -0,0 +1,694 @@ +/* + * Unix SMB/CIFS implementation. + * RPC client transport over named pipes to a child smbd + * Copyright (C) Volker Lendecke 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 . + */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_CLI + +/** + * struct rpc_cli_smbd_conn represents a forked smbd. This structure should + * exist only once per process which does the rpc calls. + * + * RPC pipe handles can be attached to this smbd connection with + * rpc_pipe_open_local(). + * + * For this to work right, we can not use rpc_transport_np directly, because + * the child smbd wants to write its DEBUG output somewhere. We redirect the + * child's output to rpc_cli_smbd_conn->stdout_fd. While the RPC calls are + * active, we have an event context available and attach a fd event to the + * stdout_df. + */ + +struct rpc_cli_smbd_conn { + /** + * The smb connection to handle the named pipe traffic over + */ + struct cli_state *cli; + + /** + * Attached to stdout in the forked smbd, this is where smbd will + * print its DEBUG. + */ + int stdout_fd; + + /** + * Custom callback provided by the owner of the + * rpc_cli_smbd_conn. Here we send the smbd DEBUG output. Can be NULL. + */ + struct { + void (*fn)(char *buf, size_t len, void *priv); + void *priv; + } stdout_callback ; +}; + +/** + * Event handler to be called whenever the forked smbd prints debugging + * output. + */ + +static void rpc_cli_smbd_stdout_reader(struct event_context *ev, + struct fd_event *fde, + uint16_t flags, void *priv) +{ + struct rpc_cli_smbd_conn *conn = talloc_get_type_abort( + priv, struct rpc_cli_smbd_conn); + char buf[1024]; + ssize_t nread; + + if ((flags & EVENT_FD_READ) == 0) { + return; + } + + nread = read(conn->stdout_fd, buf, sizeof(buf)-1); + if (nread < 0) { + DEBUG(0, ("Could not read from smbd stdout: %s\n", + strerror(errno))); + TALLOC_FREE(fde); + return; + } + if (nread == 0) { + DEBUG(0, ("EOF from smbd stdout\n")); + TALLOC_FREE(fde); + return; + } + + if (conn->stdout_callback.fn != NULL) { + conn->stdout_callback.fn(buf, nread, + conn->stdout_callback.priv); + } +} + +/** + * struct rpc_transport_smbd_state is the link from a struct rpc_pipe_client + * to the rpc_cli_smbd_conn. We use a named pipe transport as a subtransport. + */ + +struct rpc_transport_smbd_state { + struct rpc_cli_smbd_conn *conn; + struct rpc_cli_transport *sub_transp; +}; + +static int rpc_cli_smbd_conn_destructor(struct rpc_cli_smbd_conn *conn) +{ + if (conn->cli != NULL) { + cli_shutdown(conn->cli); + conn->cli = NULL; + } + if (conn->stdout_fd != -1) { + close(conn->stdout_fd); + conn->stdout_fd = -1; + } + return 0; +} + +/* + * Do the negprot/sesssetup/tcon to an anonymous ipc$ connection + */ + +struct get_anon_ipc_state { + struct event_context *ev; + struct cli_state *cli; +}; + +static void get_anon_ipc_negprot_done(struct async_req *subreq); +static void get_anon_ipc_sesssetup_done(struct async_req *subreq); +static void get_anon_ipc_tcon_done(struct async_req *subreq); + +static struct async_req *get_anon_ipc_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct cli_state *cli) +{ + struct async_req *result, *subreq; + struct get_anon_ipc_state *state; + + if (!async_req_setup(mem_ctx, &result, &state, + struct get_anon_ipc_state)) { + return NULL; + } + + state->ev = ev; + state->cli = cli; + + subreq = cli_negprot_send(state, ev, cli); + if (subreq == NULL) { + goto fail; + } + subreq->async.fn = get_anon_ipc_negprot_done; + subreq->async.priv = result; + return result; + fail: + TALLOC_FREE(result); + return NULL; +} + +static void get_anon_ipc_negprot_done(struct async_req *subreq) +{ + struct async_req *req = talloc_get_type_abort( + subreq->async.priv, struct async_req); + struct get_anon_ipc_state *state = talloc_get_type_abort( + req->private_data, struct get_anon_ipc_state); + NTSTATUS status; + + status = cli_negprot_recv(subreq); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status)) { + async_req_error(req, status); + return; + } + + subreq = cli_session_setup_guest_send(state, state->ev, state->cli); + if (async_req_nomem(subreq, req)) { + return; + } + subreq->async.fn = get_anon_ipc_sesssetup_done; + subreq->async.priv = req; +} + +static void get_anon_ipc_sesssetup_done(struct async_req *subreq) +{ + struct async_req *req = talloc_get_type_abort( + subreq->async.priv, struct async_req); + struct get_anon_ipc_state *state = talloc_get_type_abort( + req->private_data, struct get_anon_ipc_state); + NTSTATUS status; + + status = cli_session_setup_guest_recv(subreq); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status)) { + async_req_error(req, status); + return; + } + + subreq = cli_tcon_andx_send(state, state->ev, state->cli, + "IPC$", "IPC", NULL, 0); + if (async_req_nomem(subreq, req)) { + return; + } + subreq->async.fn = get_anon_ipc_tcon_done; + subreq->async.priv = req; +} + +static void get_anon_ipc_tcon_done(struct async_req *subreq) +{ + struct async_req *req = talloc_get_type_abort( + subreq->async.priv, struct async_req); + NTSTATUS status; + + status = cli_tcon_andx_recv(subreq); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status)) { + async_req_error(req, status); + return; + } + async_req_done(req); +} + +static NTSTATUS get_anon_ipc_recv(struct async_req *req) +{ + return async_req_simple_recv(req); +} + +struct rpc_cli_smbd_conn_init_state { + struct event_context *ev; + struct rpc_cli_smbd_conn *conn; +}; + +static void rpc_cli_smbd_conn_init_done(struct async_req *subreq); + +struct async_req *rpc_cli_smbd_conn_init_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + void (*stdout_callback)(char *buf, + size_t len, + void *priv), + void *priv) +{ + struct async_req *result, *subreq; + struct rpc_cli_smbd_conn_init_state *state; + int smb_sock[2]; + int stdout_pipe[2]; + NTSTATUS status; + pid_t pid; + int ret; + + smb_sock[0] = smb_sock[1] = stdout_pipe[0] = stdout_pipe[1] = -1; + + if (!async_req_setup(mem_ctx, &result, &state, + struct rpc_cli_smbd_conn_init_state)) { + return NULL; + } + state->ev = ev; + + state->conn = talloc(state, struct rpc_cli_smbd_conn); + if (state->conn == NULL) { + goto nomem; + } + + state->conn->cli = cli_initialise(); + if (state->conn->cli == NULL) { + goto nomem; + } + state->conn->stdout_fd = -1; + state->conn->stdout_callback.fn = stdout_callback; + state->conn->stdout_callback.priv = priv; + talloc_set_destructor(state->conn, rpc_cli_smbd_conn_destructor); + + ret = socketpair(AF_UNIX, SOCK_STREAM, 0, smb_sock); + if (ret == -1) { + status = map_nt_error_from_unix(errno); + goto post_status; + } + ret = pipe(stdout_pipe); + if (ret == -1) { + status = map_nt_error_from_unix(errno); + goto post_status; + } + + pid = sys_fork(); + if (pid == -1) { + status = map_nt_error_from_unix(errno); + goto post_status; + } + if (pid == 0) { + char *smbd_cmd; + + close(smb_sock[0]); + close(stdout_pipe[0]); + close(0); + if (dup(smb_sock[1]) == -1) { + exit(1); + } + close(smb_sock[1]); + close(1); + if (dup(stdout_pipe[1]) == -1) { + exit(1); + } + close(stdout_pipe[1]); + + smbd_cmd = getenv("SMB_PATH"); + + if ((smbd_cmd == NULL) + && (asprintf(&smbd_cmd, "%s/smbd", get_dyn_SBINDIR()) + == -1)) { + printf("no memory"); + exit(1); + } + if (asprintf(&smbd_cmd, "%s -F -S", smbd_cmd) == -1) { + printf("no memory"); + exit(1); + } + + exit(system(smbd_cmd)); + } + + state->conn->cli->fd = smb_sock[0]; + smb_sock[0] = -1; + close(smb_sock[1]); + smb_sock[1] = -1; + + state->conn->stdout_fd = stdout_pipe[0]; + stdout_pipe[0] = -1; + close(stdout_pipe[1]); + stdout_pipe[1] = -1; + + subreq = get_anon_ipc_send(state, ev, state->conn->cli); + if (subreq == NULL) { + goto nomem; + } + + if (event_add_fd(ev, subreq, state->conn->stdout_fd, EVENT_FD_READ, + rpc_cli_smbd_stdout_reader, state->conn) == NULL) { + goto nomem; + } + + subreq->async.fn = rpc_cli_smbd_conn_init_done; + subreq->async.priv = result; + return result; + + nomem: + status = NT_STATUS_NO_MEMORY; + post_status: + if (smb_sock[0] != -1) { + close(smb_sock[0]); + } + if (smb_sock[1] != -1) { + close(smb_sock[1]); + } + if (stdout_pipe[0] != -1) { + close(stdout_pipe[0]); + } + if (stdout_pipe[1] != -1) { + close(stdout_pipe[1]); + } + if (async_post_status(result, ev, status)) { + return result; + } + TALLOC_FREE(result); + return NULL; +} + +static void rpc_cli_smbd_conn_init_done(struct async_req *subreq) +{ + struct async_req *req = talloc_get_type_abort( + subreq->async.priv, struct async_req); + NTSTATUS status; + + status = get_anon_ipc_recv(subreq); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status)) { + async_req_error(req, status); + return; + } + async_req_done(req); +} + +NTSTATUS rpc_cli_smbd_conn_init_recv(struct async_req *req, + TALLOC_CTX *mem_ctx, + struct rpc_cli_smbd_conn **pconn) +{ + struct rpc_cli_smbd_conn_init_state *state = talloc_get_type_abort( + req->private_data, struct rpc_cli_smbd_conn_init_state); + NTSTATUS status; + + if (async_req_is_error(req, &status)) { + return status; + } + *pconn = talloc_move(mem_ctx, &state->conn); + return NT_STATUS_OK; +} + +NTSTATUS rpc_cli_smbd_conn_init(TALLOC_CTX *mem_ctx, + struct rpc_cli_smbd_conn **pconn, + void (*stdout_callback)(char *buf, + size_t len, + void *priv), + void *priv) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct event_context *ev; + struct async_req *req; + NTSTATUS status; + + ev = event_context_init(frame); + if (ev == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + + req = rpc_cli_smbd_conn_init_send(frame, ev, stdout_callback, priv); + if (req == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + + while (req->state < ASYNC_REQ_DONE) { + event_loop_once(ev); + } + + status = rpc_cli_smbd_conn_init_recv(req, mem_ctx, pconn); + fail: + TALLOC_FREE(frame); + return status; +} + +struct rpc_smbd_write_state { + struct rpc_cli_transport *sub_transp; + ssize_t written; +}; + +static void rpc_smbd_write_done(struct async_req *subreq); + +static struct async_req *rpc_smbd_write_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + const uint8_t *data, size_t size, + void *priv) +{ + struct rpc_transport_smbd_state *transp = talloc_get_type_abort( + priv, struct rpc_transport_smbd_state); + struct async_req *result, *subreq; + struct rpc_smbd_write_state *state; + + if (!async_req_setup(mem_ctx, &result, &state, + struct rpc_smbd_write_state)) { + return NULL; + } + state->sub_transp = transp->sub_transp; + + subreq = transp->sub_transp->write_send(state, ev, data, size, + transp->sub_transp->priv); + if (subreq == NULL) { + goto fail; + } + + if (event_add_fd(ev, subreq, transp->conn->stdout_fd, EVENT_FD_READ, + rpc_cli_smbd_stdout_reader, transp->conn) == NULL) { + goto fail; + } + + subreq->async.fn = rpc_smbd_write_done; + subreq->async.priv = result; + return result; + + fail: + TALLOC_FREE(result); + return NULL; +} + +static void rpc_smbd_write_done(struct async_req *subreq) +{ + struct async_req *req = talloc_get_type_abort( + subreq->async.priv, struct async_req); + struct rpc_smbd_write_state *state = talloc_get_type_abort( + req->private_data, struct rpc_smbd_write_state); + NTSTATUS status; + + status = state->sub_transp->write_recv(subreq, &state->written); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status)) { + async_req_error(req, status); + return; + } + async_req_done(req); +} + +static NTSTATUS rpc_smbd_write_recv(struct async_req *req, ssize_t *pwritten) +{ + struct rpc_smbd_write_state *state = talloc_get_type_abort( + req->private_data, struct rpc_smbd_write_state); + NTSTATUS status; + + if (async_req_is_error(req, &status)) { + return status; + } + *pwritten = state->written; + return NT_STATUS_OK; +} + +struct rpc_smbd_read_state { + struct rpc_cli_transport *sub_transp; + ssize_t received; +}; + +static void rpc_smbd_read_done(struct async_req *subreq); + +static struct async_req *rpc_smbd_read_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + uint8_t *data, size_t size, + void *priv) +{ + struct rpc_transport_smbd_state *transp = talloc_get_type_abort( + priv, struct rpc_transport_smbd_state); + struct async_req *result, *subreq; + struct rpc_smbd_read_state *state; + + if (!async_req_setup(mem_ctx, &result, &state, + struct rpc_smbd_read_state)) { + return NULL; + } + state->sub_transp = transp->sub_transp; + + subreq = transp->sub_transp->read_send(state, ev, data, size, + transp->sub_transp->priv); + if (subreq == NULL) { + goto fail; + } + + if (event_add_fd(ev, subreq, transp->conn->stdout_fd, EVENT_FD_READ, + rpc_cli_smbd_stdout_reader, transp->conn) == NULL) { + goto fail; + } + + subreq->async.fn = rpc_smbd_read_done; + subreq->async.priv = result; + return result; + + fail: + TALLOC_FREE(result); + return NULL; +} + +static void rpc_smbd_read_done(struct async_req *subreq) +{ + struct async_req *req = talloc_get_type_abort( + subreq->async.priv, struct async_req); + struct rpc_smbd_read_state *state = talloc_get_type_abort( + req->private_data, struct rpc_smbd_read_state); + NTSTATUS status; + + status = state->sub_transp->read_recv(subreq, &state->received); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status)) { + async_req_error(req, status); + return; + } + async_req_done(req); +} + +static NTSTATUS rpc_smbd_read_recv(struct async_req *req, ssize_t *preceived) +{ + struct rpc_smbd_read_state *state = talloc_get_type_abort( + req->private_data, struct rpc_smbd_read_state); + NTSTATUS status; + + if (async_req_is_error(req, &status)) { + return status; + } + *preceived = state->received; + return NT_STATUS_OK; +} + +struct rpc_transport_smbd_init_state { + struct rpc_cli_transport *transport; + struct rpc_transport_smbd_state *transport_smbd; +}; + +static void rpc_transport_smbd_init_done(struct async_req *subreq); + +struct async_req *rpc_transport_smbd_init_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct rpc_cli_smbd_conn *conn, + const struct ndr_syntax_id *abstract_syntax) +{ + struct async_req *result, *subreq; + struct rpc_transport_smbd_init_state *state; + + if (!async_req_setup(mem_ctx, &result, &state, + struct rpc_transport_smbd_init_state)) { + return NULL; + } + + state->transport = talloc(state, struct rpc_cli_transport); + if (state->transport == NULL) { + goto fail; + } + state->transport_smbd = talloc(state->transport, + struct rpc_transport_smbd_state); + if (state->transport_smbd == NULL) { + goto fail; + } + state->transport_smbd->conn = conn; + state->transport->priv = state->transport_smbd; + + subreq = rpc_transport_np_init_send(state, ev, conn->cli, + abstract_syntax); + if (subreq == NULL) { + goto fail; + } + subreq->async.fn = rpc_transport_smbd_init_done; + subreq->async.priv = result; + return result; + + fail: + TALLOC_FREE(result); + return NULL; +} + +static void rpc_transport_smbd_init_done(struct async_req *subreq) +{ + struct async_req *req = talloc_get_type_abort( + subreq->async.priv, struct async_req); + struct rpc_transport_smbd_init_state *state = talloc_get_type_abort( + req->private_data, struct rpc_transport_smbd_init_state); + NTSTATUS status; + + status = rpc_transport_np_init_recv( + subreq, state->transport_smbd, + &state->transport_smbd->sub_transp); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status)) { + async_req_error(req, status); + return; + } + async_req_done(req); +} + +NTSTATUS rpc_transport_smbd_init_recv(struct async_req *req, + TALLOC_CTX *mem_ctx, + struct rpc_cli_transport **presult) +{ + struct rpc_transport_smbd_init_state *state = talloc_get_type_abort( + req->private_data, struct rpc_transport_smbd_init_state); + NTSTATUS status; + + if (async_req_is_error(req, &status)) { + return status; + } + + state->transport->write_send = rpc_smbd_write_send; + state->transport->write_recv = rpc_smbd_write_recv; + state->transport->read_send = rpc_smbd_read_send; + state->transport->read_recv = rpc_smbd_read_recv; + state->transport->trans_send = NULL; + state->transport->trans_recv = NULL; + + *presult = talloc_move(mem_ctx, &state->transport); + return NT_STATUS_OK; +} + +NTSTATUS rpc_transport_smbd_init(TALLOC_CTX *mem_ctx, + struct rpc_cli_smbd_conn *conn, + const struct ndr_syntax_id *abstract_syntax, + struct rpc_cli_transport **presult) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct event_context *ev; + struct async_req *req; + NTSTATUS status; + + ev = event_context_init(frame); + if (ev == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + + req = rpc_transport_smbd_init_send(frame, ev, conn, abstract_syntax); + if (req == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + + while (req->state < ASYNC_REQ_DONE) { + event_loop_once(ev); + } + + status = rpc_transport_smbd_init_recv(req, mem_ctx, presult); + fail: + TALLOC_FREE(frame); + return status; +} -- cgit From 4b541c6f030e9459df35337bce3d8ce7ba92a2c6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 13:22:31 +0100 Subject: pidl: fix samba3-cli test after change to cli->dispatch() metze --- pidl/tests/samba3-cli.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pidl/tests/samba3-cli.pl b/pidl/tests/samba3-cli.pl index d762954159..5a551630c9 100755 --- a/pidl/tests/samba3-cli.pl +++ b/pidl/tests/samba3-cli.pl @@ -42,7 +42,7 @@ is($x->{res}, \t\tNDR_PRINT_IN_DEBUG(bar, &r); \t} - status = cli_do_rpc_ndr(cli, + status = cli->dispatch(cli, mem_ctx, &ndr_table_foo, NDR_BAR, @@ -86,7 +86,7 @@ is($x->{res}, \t\tNDR_PRINT_IN_DEBUG(bar, &r); \t} - status = cli_do_rpc_ndr(cli, + status = cli->dispatch(cli, mem_ctx, &ndr_table_foo, NDR_BAR, -- cgit From 6b128f03d500b13468c666db51c87eb2e194f2ca Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 11:03:45 +0100 Subject: selftest: don't export $CONFIGURATION anymore only $SMB_CONF_PATH metze --- selftest/selftest.pl | 3 +-- source3/selftest/tests.sh | 2 +- source4/selftest/tests.sh | 9 ++------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/selftest/selftest.pl b/selftest/selftest.pl index b4cc4c1719..d4fd57e494 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -648,7 +648,6 @@ if ($opt_quick) { } $ENV{SELFTEST_TARGET} = $opt_target; $ENV{SELFTEST_MAXTIME} = $torture_maxtime; -$ENV{SELFTEST_CONFFILE} = $conffile; my @available = (); foreach my $fn (@testlists) { @@ -852,7 +851,7 @@ server is pid `cat \$PIDDIR/samba.pid` Some useful environment variables: TORTURE_OPTIONS=\$TORTURE_OPTIONS -CONFIGURATION=\$CONFIGURATION +SMB_CONF_PATH=\$SMB_CONF_PATH $envvarstr \" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash'"); diff --git a/source3/selftest/tests.sh b/source3/selftest/tests.sh index 7f2c8f2203..e07dee6f8a 100755 --- a/source3/selftest/tests.sh +++ b/source3/selftest/tests.sh @@ -51,7 +51,7 @@ export SCRIPTDIR plantest "talloctort3" none $VALGRIND $BINDIR/talloctort plantest "replacetort3" none $VALGRIND $BINDIR/replacetort plantest "tdbtorture3" none $VALGRIND $BINDIR/tdbtorture -plantest "smbconftort3" none $VALGRIND $BINDIR/smbconftort $CONFIGURATION +plantest "smbconftort3" none $VALGRIND $BINDIR/smbconftort -s \$SMB_CONF_PATH tests="FDPASS LOCK1 LOCK2 LOCK3 LOCK4 LOCK5 LOCK6 LOCK7" tests="$tests UNLINK BROWSE ATTR TRANS2 TORTURE " diff --git a/source4/selftest/tests.sh b/source4/selftest/tests.sh index 5c2b0792eb..a45a3bf3e0 100755 --- a/source4/selftest/tests.sh +++ b/source4/selftest/tests.sh @@ -60,12 +60,12 @@ smb4torture="$samba4bindir/smbtorture${EXEEXT}" $smb4torture -V prefix_abs="$SELFTEST_PREFIX/s4client" +CONFIGURATION="--configfile=\$SMB_CONF_PATH" test -d "$prefix_abs" || mkdir "$prefix_abs" -conffile="$SELFTEST_CONFFILE" TORTURE_OPTIONS="" -TORTURE_OPTIONS="$TORTURE_OPTIONS --configfile=$conffile" +TORTURE_OPTIONS="$TORTURE_OPTIONS $CONFIGURATION" TORTURE_OPTIONS="$TORTURE_OPTIONS --maximum-runtime=$SELFTEST_MAXTIME" TORTURE_OPTIONS="$TORTURE_OPTIONS --target=$SELFTEST_TARGET" TORTURE_OPTIONS="$TORTURE_OPTIONS --basedir=$prefix_abs" @@ -80,11 +80,6 @@ smb4torture="$smb4torture $TORTURE_OPTIONS" echo "OPTIONS $TORTURE_OPTIONS" -SMB_CONF_PATH="$conffile" -export SMB_CONF_PATH -CONFIGURATION="--configfile=$conffile" -export CONFIGURATION - # Simple tests for LDAP and CLDAP for options in "" "--option=socket:testnonblock=true" "-U\$USERNAME%\$PASSWORD --option=socket:testnonblock=true" "-U\$USERNAME%\$PASSWORD"; do -- cgit From 3f967153c0f87febb2e0d75d24080faa9d647666 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 10:30:13 +0100 Subject: s4:selftest: run ncalrpc tests in dc:local mode metze --- source4/selftest/tests.sh | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/source4/selftest/tests.sh b/source4/selftest/tests.sh index a45a3bf3e0..60fa79e54a 100755 --- a/source4/selftest/tests.sh +++ b/source4/selftest/tests.sh @@ -128,15 +128,16 @@ done for bindoptions in seal,padcheck $VALIDATE bigendian; do for transport in ncalrpc ncacn_np ncacn_ip_tcp; do + env="dc" case $transport in - ncalrpc) tests=$ncalrpc_tests ;; + ncalrpc) tests=$ncalrpc_tests;env="dc:local" ;; ncacn_np) tests=$ncacn_np_tests ;; ncacn_ip_tcp) tests=$ncacn_ip_tcp_tests ;; esac for t in $tests; do - plantest "`normalize_testname $t` on $transport with $bindoptions" dc $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*" + plantest "`normalize_testname $t` on $transport with $bindoptions" $env $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*" done - plantest "rpc.samba3.sharesec on $transport with $bindoptions" dc $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN --option=torture:share=tmp RPC-SAMBA3-SHARESEC "$*" + plantest "rpc.samba3.sharesec on $transport with $bindoptions" $env $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN --option=torture:share=tmp RPC-SAMBA3-SHARESEC "$*" done done @@ -148,13 +149,14 @@ done for bindoptions in connect $VALIDATE ; do for transport in ncalrpc ncacn_np ncacn_ip_tcp; do + env="dc" case $transport in - ncalrpc) tests=$slow_ncalrpc_tests ;; + ncalrpc) tests=$slow_ncalrpc_tests; env="dc:local" ;; ncacn_np) tests=$slow_ncacn_np_tests ;; ncacn_ip_tcp) tests=$slow_ncacn_ip_tcp_tests ;; esac for t in $tests; do - plantest "`normalize_testname $t` on $transport with $bindoptions" dc $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*" + plantest "`normalize_testname $t` on $transport with $bindoptions" $env $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*" done done done @@ -201,7 +203,11 @@ for transport in $transports; do for bindoptions in connect spnego spnego,sign spnego,seal $VALIDATE padcheck bigendian bigendian,seal; do for ntlmoptions in \ "--option=socket:testnonblock=True --option=torture:quick=yes"; do - plantest "rpc.echo on $transport with $bindoptions and $ntlmoptions" dc $smb4torture $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" RPC-ECHO "$*" + env="dc" + if test x"$transport" = x"ncalrpc"; then + env="dc:local" + fi + plantest "rpc.echo on $transport with $bindoptions and $ntlmoptions" $env $smb4torture $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" RPC-ECHO "$*" done done done @@ -219,7 +225,11 @@ for transport in $transports; do "--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=yes --option=torture:quick=yes" \ "--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes" \ ; do - plantest "rpc.echo on $transport with $bindoptions and $ntlmoptions" dc $smb4torture $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN RPC-ECHO "$*" + env="dc" + if test x"$transport" = x"ncalrpc"; then + env="dc:local" + fi + plantest "rpc.echo on $transport with $bindoptions and $ntlmoptions" $env $smb4torture $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN RPC-ECHO "$*" done done done @@ -394,16 +404,16 @@ plantest "upgrade.python" none $SUBUNITRUN samba.tests.upgrade plantest "samba.python" none $SUBUNITRUN samba.tests plantest "provision.python" none $SUBUNITRUN samba.tests.provision plantest "samba3.python" none $SUBUNITRUN samba.tests.samba3 -plantest "samr.python" dc $SUBUNITRUN samba.tests.dcerpc.sam -plantest "dcerpc.bare.python" dc $SUBUNITRUN samba.tests.dcerpc.bare -plantest "unixinfo.python" dc $SUBUNITRUN samba.tests.dcerpc.unix +plantest "samr.python" dc:local $SUBUNITRUN samba.tests.dcerpc.sam +plantest "dcerpc.bare.python" dc:local $SUBUNITRUN samba.tests.dcerpc.bare +plantest "unixinfo.python" dc:local $SUBUNITRUN samba.tests.dcerpc.unix plantest "samdb.python" none $SUBUNITRUN samba.tests.samdb plantest "tevent.python" none PYTHONPATH="$PYTHONPATH:../lib/tevent" $SUBUNITRUN tests plantest "messaging.python" none PYTHONPATH="$PYTHONPATH:lib/messaging/tests" $SUBUNITRUN bindings plantest "samba3sam.python" none PYTHONPATH="$PYTHONPATH:dsdb/samdb/ldb_modules/tests" $SUBUNITRUN samba3sam plantest "subunit.python" none $SUBUNITRUN subunit -plantest "rpcecho.python" dc $SUBUNITRUN samba.tests.dcerpc.rpcecho -plantest "winreg.python" dc $SUBUNITRUN -U\$USERNAME%\$PASSWORD samba.tests.dcerpc.registry +plantest "rpcecho.python" dc:local $SUBUNITRUN samba.tests.dcerpc.rpcecho +plantest "winreg.python" dc:local $SUBUNITRUN -U\$USERNAME%\$PASSWORD samba.tests.dcerpc.registry plantest "ldap.python" dc $PYTHON $samba4srcdir/lib/ldb/tests/python/ldap.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN plantest "blackbox.samba3dump" none $PYTHON scripting/bin/samba3dump $samba4srcdir/../testdata/samba3 rm -rf $PREFIX/upgrade -- cgit From 01f30a5e8e6d860391e79896f6d1de782e239f68 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 13:33:45 +0100 Subject: s4:selftest: run RPC-COUNTCALLS as dc:local metze --- source4/selftest/tests.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source4/selftest/tests.sh b/source4/selftest/tests.sh index 60fa79e54a..2acd376d01 100755 --- a/source4/selftest/tests.sh +++ b/source4/selftest/tests.sh @@ -114,7 +114,7 @@ slow_ncacn_np_tests="RPC-SAMLOGON RPC-SAMR RPC-SAMR-USERS RPC-SAMR-PASSWORDS" slow_ncalrpc_tests="RPC-SAMR RPC-SAMR-PASSWORDS" slow_ncacn_ip_tcp_tests="RPC-SAMR RPC-SAMR-PASSWORDS RPC-CRACKNAMES" -all_tests="$ncalrpc_tests $ncacn_np_tests $ncacn_ip_tcp_tests $slow_ncalrpc_tests $slow_ncacn_np_tests $slow_ncacn_ip_tcp_tests RPC-SECRETS RPC-SAMBA3-SHARESEC" +all_tests="$ncalrpc_tests $ncacn_np_tests $ncacn_ip_tcp_tests $slow_ncalrpc_tests $slow_ncacn_np_tests $slow_ncacn_ip_tcp_tests RPC-SECRETS RPC-SAMBA3-SHARESEC RPC-COUNTCALLS" # Make sure all tests get run for t in `$smb4torture --list | grep "^RPC-"` @@ -147,6 +147,9 @@ for bindoptions in "" $VALIDATE bigendian; do done done +t="RPC-COUNTCALLS" +plantest "`normalize_testname $t`" dc:local $VALGRIND $smb4torture "\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*" + for bindoptions in connect $VALIDATE ; do for transport in ncalrpc ncacn_np ncacn_ip_tcp; do env="dc" -- cgit From d93634b7dd753109a5a3621ea7ab610acba8cb65 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 30 Jan 2009 09:24:48 -0500 Subject: Fix misfiled headers. Some public functions were mistakenly put into ldb_private.h Revert all modules to only include ldb_module.h --- source4/dsdb/samdb/ldb_modules/objectguid.c | 1 - source4/lib/ldb/include/ldb.h | 15 ++++++++++++--- source4/lib/ldb/include/ldb_private.h | 9 --------- source4/lib/ldb/ldb_map/ldb_map_outbound.c | 1 - 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c index afd878877b..46ba8ebdb3 100644 --- a/source4/dsdb/samdb/ldb_modules/objectguid.c +++ b/source4/dsdb/samdb/ldb_modules/objectguid.c @@ -35,7 +35,6 @@ #include "includes.h" #include "ldb_module.h" -#include "ldb_private.h" #include "librpc/gen_ndr/ndr_misc.h" #include "param/param.h" diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 589887b4c5..68146499af 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1232,6 +1232,11 @@ int ldb_extended(struct ldb_context *ldb, void *data,/* NULL or a valid talloc pointer! talloc_get_type() will be used on it */ struct ldb_result **res); +/** + Obtain current/next database sequence number +*/ +int ldb_sequence_number(struct ldb_context *ldb, enum ldb_sequence_type type, uint64_t *seq_num); + /** start a transaction */ @@ -1633,6 +1638,8 @@ int ldb_msg_add_fmt(struct ldb_message *msg, */ int ldb_msg_element_compare(struct ldb_message_element *el1, struct ldb_message_element *el2); +int ldb_msg_element_compare_name(struct ldb_message_element *el1, + struct ldb_message_element *el2); /** Find elements in a message. @@ -1746,14 +1753,16 @@ const char **ldb_attr_list_copy(TALLOC_CTX *mem_ctx, const char * const *attrs); const char **ldb_attr_list_copy_add(TALLOC_CTX *mem_ctx, const char * const *attrs, const char *new_attr); int ldb_attr_in_list(const char * const *attrs, const char *attr); +int ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); +int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); +void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr); +void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element *el); + void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree, const char *attr, const char *replace); -int ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); -int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); -void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr); /** Convert a time structure to a string diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 04ee002dd5..10977088e5 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -158,17 +158,8 @@ int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx, /* The following definitions come from lib/ldb/common/ldb_utf8.c */ char *ldb_casefold_default(void *context, void *mem_ctx, const char *s, size_t n); -void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element *el); - -int ldb_msg_element_compare_name(struct ldb_message_element *el1, - struct ldb_message_element *el2); void ldb_dump_results(struct ldb_context *ldb, struct ldb_result *result, FILE *f); -/** - Obtain current/next database sequence number -*/ -int ldb_sequence_number(struct ldb_context *ldb, enum ldb_sequence_type type, uint64_t *seq_num); - #define LDB_SEQ_GLOBAL_SEQUENCE 0x01 #define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02 diff --git a/source4/lib/ldb/ldb_map/ldb_map_outbound.c b/source4/lib/ldb/ldb_map/ldb_map_outbound.c index edd3f77b66..327fa92f8d 100644 --- a/source4/lib/ldb/ldb_map/ldb_map_outbound.c +++ b/source4/lib/ldb/ldb_map/ldb_map_outbound.c @@ -26,7 +26,6 @@ */ #include "ldb_module.h" -#include "ldb_private.h" #include "ldb_map.h" #include "ldb_map_private.h" -- cgit From 1f2b5ea97c7957f4f49fdea67960e7c08888e505 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 30 Jan 2009 10:18:52 -0500 Subject: Add helper function to get a module name, may be useful for debugging. --- source4/lib/ldb/common/ldb_modules.c | 5 +++++ source4/lib/ldb/include/ldb_module.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index 03d1e6ebe2..99a47767e1 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -506,6 +506,11 @@ struct ldb_module *ldb_module_new(TALLOC_CTX *memctx, return module; } +const char * ldb_module_get_name(struct ldb_module *module) +{ + return module->ops->name; +} + struct ldb_context *ldb_module_get_ctx(struct ldb_module *module) { return module->ldb; diff --git a/source4/lib/ldb/include/ldb_module.h b/source4/lib/ldb/include/ldb_module.h index 8742b1058c..4e1019184d 100644 --- a/source4/lib/ldb/include/ldb_module.h +++ b/source4/lib/ldb/include/ldb_module.h @@ -55,7 +55,7 @@ struct ldb_module_ops { int (*end_transaction)(struct ldb_module *); int (*del_transaction)(struct ldb_module *); int (*sequence_number)(struct ldb_module *, struct ldb_request *); - void *private_data; + void *private_data; }; @@ -110,6 +110,7 @@ struct ldb_module *ldb_module_new(TALLOC_CTX *memctx, const char *module_name, const struct ldb_module_ops *ops); +const char * ldb_module_get_name(struct ldb_module *module); struct ldb_context *ldb_module_get_ctx(struct ldb_module *module); void *ldb_module_get_private(struct ldb_module *module); void ldb_module_set_private(struct ldb_module *module, void *private_data); -- cgit From 94cb0835ca690cc7eb115693e672ea9a662fc671 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 17:03:10 +0100 Subject: s4:build: kill DEFAULT_HEADERS variable metze --- lib/util/config.mk | 1 + source4/Makefile | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/util/config.mk b/lib/util/config.mk index 22f22b5771..02f476b97b 100644 --- a/lib/util/config.mk +++ b/lib/util/config.mk @@ -30,6 +30,7 @@ LIBSAMBA-UTIL_OBJ_FILES = $(addprefix $(libutilsrcdir)/, \ params.o) PUBLIC_HEADERS += $(addprefix $(libutilsrcdir)/, util.h \ + dlinklist.h attr.h \ byteorder.h \ data_blob.h \ diff --git a/source4/Makefile b/source4/Makefile index 7d4540ae6a..b342d671f6 100644 --- a/source4/Makefile +++ b/source4/Makefile @@ -145,12 +145,11 @@ endif clean:: @find ../lib ../libcli ../librpc ../nsswitch -name '*.o' -o -name '*.ho' | xargs rm -f -DEFAULT_HEADERS = $(srcdir)/../lib/util/dlinklist.h \ - $(srcdir)/version.h +PUBLIC_HEADES += $(srcdir)/version.h libraries:: $(STATIC_LIBS) $(SHARED_LIBS) modules:: $(PLUGINS) -headers:: $(PUBLIC_HEADERS) $(DEFAULT_HEADERS) +headers:: $(PUBLIC_HEADERS) manpages:: $(MANPAGES) all:: showflags $(ALL_PREDEP) binaries modules pythonmods libraries headers everything:: all @@ -233,7 +232,7 @@ installlib:: $(SHARED_LIBS) $(STATIC_LIBS) installdirs #@$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(libdir) "$(STLIBEXT)" $(STATIC_LIBS) installheader:: headers installdirs - @srcdir=$(srcdir) builddir=$(builddir) $(PERL) $(srcdir)/script/installheader.pl $(DESTDIR)$(includedir) $(PUBLIC_HEADERS) $(DEFAULT_HEADERS) + @srcdir=$(srcdir) builddir=$(builddir) $(PERL) $(srcdir)/script/installheader.pl $(DESTDIR)$(includedir) $(PUBLIC_HEADERS) installdat:: installdirs @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(datadir) $(srcdir) -- cgit From 73dbbe0d5406d1852f85a17b506a4b943ad1926f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 17:34:00 +0100 Subject: heimdal: don't include without knowing it's there metze --- source4/heimdal/lib/krb5/get_addrs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source4/heimdal/lib/krb5/get_addrs.c b/source4/heimdal/lib/krb5/get_addrs.c index fb45d08d29..ce16785319 100644 --- a/source4/heimdal/lib/krb5/get_addrs.c +++ b/source4/heimdal/lib/krb5/get_addrs.c @@ -43,7 +43,9 @@ struct mbuf; #ifdef HAVE_NET_IF_H #include #endif +#ifdef HAVE_IFADDR_H #include +#endif static krb5_error_code gethostname_fallback (krb5_context context, krb5_addresses *res) -- cgit From cdca75dee67ebfee62b44273d7d5ae5f123c477b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 17:34:49 +0100 Subject: heimdal: don't include without knowing it's there metze --- source4/heimdal/lib/roken/vis.hin | 2 ++ source4/heimdal_build/vis.h | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/source4/heimdal/lib/roken/vis.hin b/source4/heimdal/lib/roken/vis.hin index 64274526e4..06a250c6d8 100644 --- a/source4/heimdal/lib/roken/vis.hin +++ b/source4/heimdal/lib/roken/vis.hin @@ -80,7 +80,9 @@ */ #define UNVIS_END 1 /* no more characters */ +#ifdef HAVE_SYS_CDEFS_H #include +#endif __BEGIN_DECLS char * ROKEN_LIB_FUNCTION diff --git a/source4/heimdal_build/vis.h b/source4/heimdal_build/vis.h index 13b39aa184..4389993ebd 100644 --- a/source4/heimdal_build/vis.h +++ b/source4/heimdal_build/vis.h @@ -1,4 +1,15 @@ #ifndef _HEIMDAL_BUILD_VIS_H #define _HEIMDAL_BUILD_VIS_H + +#include "system/locale.h" + +#ifndef __BEGIN_DECLS +#define __BEGIN_DECLS +#endif + +#ifndef __END_DECLS +#define __END_DECLS +#endif + #include "heimdal/lib/roken/vis.hin" #endif -- cgit From 9cf1175d331369a5552b770f6189f49e4bff44b8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 17:52:37 +0100 Subject: heimdal:camellia-ntt.c: include config.h as first header metze --- source4/heimdal/lib/hcrypto/camellia-ntt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source4/heimdal/lib/hcrypto/camellia-ntt.c b/source4/heimdal/lib/hcrypto/camellia-ntt.c index 70b0268833..c6e3485e26 100644 --- a/source4/heimdal/lib/hcrypto/camellia-ntt.c +++ b/source4/heimdal/lib/hcrypto/camellia-ntt.c @@ -23,6 +23,9 @@ * http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include -- cgit From 334c6e6b78de8529fce0061efd5249f8fe2d256f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 17:53:04 +0100 Subject: s4:heimdal_build: include "system/network.h" via config.h wrapper This fixes build problems on Tru64. metze --- source4/heimdal_build/config.h | 1 + 1 file changed, 1 insertion(+) diff --git a/source4/heimdal_build/config.h b/source4/heimdal_build/config.h index e15c6effa8..5f21da2d91 100644 --- a/source4/heimdal_build/config.h +++ b/source4/heimdal_build/config.h @@ -8,6 +8,7 @@ #include "include/config.h" #include "../replace/replace.h" +#include "system/network.h" #define RCSID(msg) struct __rcsid { int __rcsdi; } #define KRB5 -- cgit From 3f09dd0d824c3e35423d68e2fb1f14dbd0875dd2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 17:58:16 +0100 Subject: heimdal:roken: arg_printusage() should not try to return a value. This should fix problems with the IRIX build. metze --- source4/heimdal/lib/roken/getarg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source4/heimdal/lib/roken/getarg.c b/source4/heimdal/lib/roken/getarg.c index 3884fa83d6..7679d7f7f8 100644 --- a/source4/heimdal/lib/roken/getarg.c +++ b/source4/heimdal/lib/roken/getarg.c @@ -216,8 +216,8 @@ arg_printusage (struct getargs *args, const char *progname, const char *extra_string) { - return arg_printusage_i18n(args, num_args, "Usage", - progname, extra_string, builtin_i18n); + arg_printusage_i18n(args, num_args, "Usage", + progname, extra_string, builtin_i18n); } void ROKEN_LIB_FUNCTION -- cgit From e592718c43d14ddb1f97be3a10d02b6a8deaa269 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 18:02:21 +0100 Subject: heimdal:roken: arg_match_long() should return a value This should fix a build problem on IRIX. metze --- source4/heimdal/lib/roken/getarg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source4/heimdal/lib/roken/getarg.c b/source4/heimdal/lib/roken/getarg.c index 7679d7f7f8..3168ccc53d 100644 --- a/source4/heimdal/lib/roken/getarg.c +++ b/source4/heimdal/lib/roken/getarg.c @@ -478,6 +478,9 @@ arg_match_long(struct getargs *args, size_t num_args, default: abort (); } + + /* not reached */ + return ARG_ERR_NO_MATCH; } static int -- cgit From 24a1b556fc0296c289a0a83fafc7815fff528cfb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 18:41:07 +0100 Subject: s4:lib/util: fix the build metze --- lib/util/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/config.mk b/lib/util/config.mk index 02f476b97b..14bdb2a277 100644 --- a/lib/util/config.mk +++ b/lib/util/config.mk @@ -30,7 +30,7 @@ LIBSAMBA-UTIL_OBJ_FILES = $(addprefix $(libutilsrcdir)/, \ params.o) PUBLIC_HEADERS += $(addprefix $(libutilsrcdir)/, util.h \ - dlinklist.h + dlinklist.h \ attr.h \ byteorder.h \ data_blob.h \ -- cgit From c28952c55505ce09e3cc082ad59692d4977ed26e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 18:38:00 +0100 Subject: lib/replace: check if we have dirfd() Note: we only use this internally and don't replace it by default. metze --- lib/replace/repdir.m4 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/replace/repdir.m4 b/lib/replace/repdir.m4 index f53a4c2974..fb3f414c95 100644 --- a/lib/replace/repdir.m4 +++ b/lib/replace/repdir.m4 @@ -7,6 +7,9 @@ AC_CACHE_CHECK([for broken readdir],libreplace_cv_READDIR_NEEDED,[ [libreplace_cv_READDIR_NEEDED="assuming not"]) ]) +AC_CHECK_FUNCS(dirfd) +AC_HAVE_DECL(dirfd, [#include ]) + # # try to replace with getdirentries() if needed # -- cgit From 9fa2e564886525dd82b3283da2c467bc8d576225 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 18:41:34 +0100 Subject: s4:heimdal_build: add a dummy define for dirfd() metze --- source4/heimdal_build/config.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source4/heimdal_build/config.h b/source4/heimdal_build/config.h index 5f21da2d91..114e53643c 100644 --- a/source4/heimdal_build/config.h +++ b/source4/heimdal_build/config.h @@ -10,6 +10,10 @@ #include "../replace/replace.h" #include "system/network.h" +#if !defined(HAVE_DIRFD) && !defined(HAVE_DIRFD_DECL) && !defined(dirfd) +#define dirfd(d) (-1) +#endif + #define RCSID(msg) struct __rcsid { int __rcsdi; } #define KRB5 -- cgit From e8c2ed1d489ad67451459c69877ccba41b157e88 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 19:24:50 +0100 Subject: Revert "s4:heimdal_build: include "system/network.h" via config.h wrapper" This reverts commit 334c6e6b78de8529fce0061efd5249f8fe2d256f. This breaks the build later in the ntvfs code... metze --- source4/heimdal_build/config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/source4/heimdal_build/config.h b/source4/heimdal_build/config.h index 114e53643c..6a82637b2d 100644 --- a/source4/heimdal_build/config.h +++ b/source4/heimdal_build/config.h @@ -8,7 +8,6 @@ #include "include/config.h" #include "../replace/replace.h" -#include "system/network.h" #if !defined(HAVE_DIRFD) && !defined(HAVE_DIRFD_DECL) && !defined(dirfd) #define dirfd(d) (-1) -- cgit From 55f663a04b791baf5a7a0bc635bd6f626498d8fc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 19:37:06 +0100 Subject: heimdal:camellia: include roken.h metze --- source4/heimdal/lib/hcrypto/camellia-ntt.c | 2 ++ source4/heimdal/lib/hcrypto/camellia.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/source4/heimdal/lib/hcrypto/camellia-ntt.c b/source4/heimdal/lib/hcrypto/camellia-ntt.c index c6e3485e26..358221162f 100644 --- a/source4/heimdal/lib/hcrypto/camellia-ntt.c +++ b/source4/heimdal/lib/hcrypto/camellia-ntt.c @@ -27,6 +27,8 @@ #include "config.h" #endif +#include + #include #include diff --git a/source4/heimdal/lib/hcrypto/camellia.c b/source4/heimdal/lib/hcrypto/camellia.c index 00635c9fed..d78bbd4c0e 100644 --- a/source4/heimdal/lib/hcrypto/camellia.c +++ b/source4/heimdal/lib/hcrypto/camellia.c @@ -37,6 +37,8 @@ RCSID("$Id: aes.c 20466 2007-04-20 08:29:05Z lha $"); #endif +#include + #ifdef KRB5 #include #endif -- cgit From 2f8a39829611da0ba4661744ff189f66907b43e6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 19:38:09 +0100 Subject: lib/talloc: include replace.h in pytalloc.c This fixes the build on Tru64. metze --- lib/talloc/pytalloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/talloc/pytalloc.c b/lib/talloc/pytalloc.c index 51d087b6d3..30da9ee5c2 100644 --- a/lib/talloc/pytalloc.c +++ b/lib/talloc/pytalloc.c @@ -17,6 +17,7 @@ along with this program. If not, see . */ +#include "replace.h" #include #include -- cgit From 3718cf294ad1f3e00178cb34b2c914c9aecf2016 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 19:38:59 +0100 Subject: lib/tdb: include replace.h and system/filesys.h in pytdb.c This fixes the build on Tru64. metze --- lib/tdb/pytdb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c index 15a8d8a3e2..60aae9fd86 100644 --- a/lib/tdb/pytdb.c +++ b/lib/tdb/pytdb.c @@ -24,6 +24,9 @@ License along with this library; if not, see . */ +#include "replace.h" +#include "system/filesys.h" + #include #ifndef Py_RETURN_NONE #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None @@ -34,11 +37,7 @@ #endif /* Include tdb headers */ -#include -#include #include -#include -#include typedef struct { PyObject_HEAD -- cgit From 84ca20a6b5e63f4bd73e2e2586d88ccb2adca123 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 19:39:34 +0100 Subject: lib/tevent: include replace.h in pytevent.c This fixes the build on Tru64. metze --- lib/tevent/pytevent.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tevent/pytevent.c b/lib/tevent/pytevent.c index 5d10554531..5c34064004 100644 --- a/lib/tevent/pytevent.c +++ b/lib/tevent/pytevent.c @@ -16,6 +16,7 @@ along with this program. If not, see . */ +#include "replace.h" #include #ifndef Py_RETURN_NONE -- cgit From d129507ee472b884d42d1bf301be6f235b0ac5a7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 19:41:33 +0100 Subject: s4:lib/ldb: include replace.h in pyldb.c This fixes the build on Tru64. metze --- source4/lib/ldb/pyldb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index f71ee23340..ef2af060f2 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -25,6 +25,7 @@ License along with this library; if not, see . */ +#include "replace.h" #include "ldb_private.h" #include #include "pyldb.h" -- cgit From 2fe137e7bce425adf9cc64664eb493dfa8a7e885 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 19:44:20 +0100 Subject: heimdal:hdb: always include "config.h" first metze --- source4/heimdal/lib/hdb/hdb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source4/heimdal/lib/hdb/hdb.c b/source4/heimdal/lib/hdb/hdb.c index 15a1024267..ad2c35a43a 100644 --- a/source4/heimdal/lib/hdb/hdb.c +++ b/source4/heimdal/lib/hdb/hdb.c @@ -31,6 +31,10 @@ * SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "krb5.h" #include "krb5_locl.h" #include "hdb_locl.h" -- cgit From 50db8ede23dd9bf28a4f329edebb9105be215d3e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 14:36:48 +0100 Subject: s3:smbconftort: don't use reserved words ('test:', 'failure:', 'success:') Temporary results printfs should not contain reserved subunit words. metze --- source3/lib/smbconf/testsuite.c | 60 ++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/source3/lib/smbconf/testsuite.c b/source3/lib/smbconf/testsuite.c index 3d3c2d0ff0..b31dec0438 100644 --- a/source3/lib/smbconf/testsuite.c +++ b/source3/lib/smbconf/testsuite.c @@ -41,11 +41,11 @@ static bool test_get_includes(struct smbconf_ctx *ctx) char **includes = NULL; TALLOC_CTX *mem_ctx = talloc_stackframe(); - printf("test: get_includes\n"); + printf("TEST: get_includes\n"); werr = smbconf_get_global_includes(ctx, mem_ctx, &num_includes, &includes); if (!W_ERROR_IS_OK(werr)) { - printf("failure: get_includes - %s\n", win_errstr(werr)); + printf("FAIL: get_includes - %s\n", win_errstr(werr)); goto done; } @@ -53,7 +53,7 @@ static bool test_get_includes(struct smbconf_ctx *ctx) (num_includes > 0) ? ":" : "."); print_strings("", num_includes, (const char **)includes); - printf("success: get_includes\n"); + printf("OK: get_includes\n"); ret = true; done: @@ -75,11 +75,11 @@ static bool test_set_get_includes(struct smbconf_ctx *ctx) uint32_t get_num_includes = 0; TALLOC_CTX *mem_ctx = talloc_stackframe(); - printf("test: set_get_includes\n"); + printf("TEST: set_get_includes\n"); werr = smbconf_set_global_includes(ctx, set_num_includes, set_includes); if (!W_ERROR_IS_OK(werr)) { - printf("failure: get_set_includes (setting includes) - %s\n", + printf("FAIL: get_set_includes (setting includes) - %s\n", win_errstr(werr)); goto done; } @@ -87,13 +87,13 @@ static bool test_set_get_includes(struct smbconf_ctx *ctx) werr = smbconf_get_global_includes(ctx, mem_ctx, &get_num_includes, &get_includes); if (!W_ERROR_IS_OK(werr)) { - printf("failure: get_set_includes (getting includes) - %s\n", + printf("FAIL: get_set_includes (getting includes) - %s\n", win_errstr(werr)); goto done; } if (get_num_includes != set_num_includes) { - printf("failure: get_set_includes - set %d includes, got %d\n", + printf("FAIL: get_set_includes - set %d includes, got %d\n", set_num_includes, get_num_includes); goto done; } @@ -105,12 +105,12 @@ static bool test_set_get_includes(struct smbconf_ctx *ctx) printf("got: \n"); print_strings("* ", get_num_includes, (const char **)get_includes); - printf("failure: get_set_includes - data mismatch:\n"); + printf("FAIL: get_set_includes - data mismatch:\n"); goto done; } } - printf("success: set_includes\n"); + printf("OK: set_includes\n"); ret = true; done: @@ -130,18 +130,18 @@ static bool test_delete_includes(struct smbconf_ctx *ctx) uint32_t get_num_includes = 0; TALLOC_CTX *mem_ctx = talloc_stackframe(); - printf("test: delete_includes\n"); + printf("TEST: delete_includes\n"); werr = smbconf_set_global_includes(ctx, set_num_includes, set_includes); if (!W_ERROR_IS_OK(werr)) { - printf("failure: delete_includes (setting includes) - %s\n", + printf("FAIL: delete_includes (setting includes) - %s\n", win_errstr(werr)); goto done; } werr = smbconf_delete_global_includes(ctx); if (!W_ERROR_IS_OK(werr)) { - printf("failure: delete_includes (deleting includes) - %s\n", + printf("FAIL: delete_includes (deleting includes) - %s\n", win_errstr(werr)); goto done; } @@ -149,24 +149,24 @@ static bool test_delete_includes(struct smbconf_ctx *ctx) werr = smbconf_get_global_includes(ctx, mem_ctx, &get_num_includes, &get_includes); if (!W_ERROR_IS_OK(werr)) { - printf("failure: delete_includes (getting includes) - %s\n", + printf("FAIL: delete_includes (getting includes) - %s\n", win_errstr(werr)); goto done; } if (get_num_includes != 0) { - printf("failure: delete_includes (not empty after delete)\n"); + printf("FAIL: delete_includes (not empty after delete)\n"); goto done; } werr = smbconf_delete_global_includes(ctx); if (!W_ERROR_IS_OK(werr)) { - printf("failuer: delete_includes (delete empty includes) - " + printf("FAIL: delete_includes (delete empty includes) - " "%s\n", win_errstr(werr)); goto done; } - printf("success: delete_includes\n"); + printf("OK: delete_includes\n"); ret = true; done: @@ -177,7 +177,7 @@ static bool create_conf_file(const char *filename) { FILE *f; - printf("creating file\n"); + printf("TEST: creating file\n"); f = sys_fopen(filename, "w"); if (!f) { printf("failure: failed to open %s for writing: %s\n", @@ -192,7 +192,7 @@ static bool create_conf_file(const char *filename) fclose(f); - printf("success: create file\n"); + printf("OK: create file\n"); return true; } @@ -211,30 +211,29 @@ static bool torture_smbconf_txt(void) goto done; } - printf("test: init\n"); + printf("TEST: init\n"); werr = smbconf_init_txt(mem_ctx, &conf_ctx, filename); if (!W_ERROR_IS_OK(werr)) { - printf("failure: init failed: %s\n", win_errstr(werr)); + printf("FAIL: text backend\[ failed: %s\n", win_errstr(werr)); ret = false; goto done; } - printf("success: init\n"); + printf("OK: init\n"); ret &= test_get_includes(conf_ctx); smbconf_shutdown(conf_ctx); - printf("unlinking file\n"); + printf("TEST: unlink file\n"); if (unlink(filename) != 0) { - printf("failure: unlink failed: %s\n", strerror(errno)); + printf("OK: unlink failed: %s\n", strerror(errno)); ret = false; goto done; } - printf("success: unlink file\n"); - - printf("%s: text backend\n", ret ? "success" : "failure"); + printf("OK: unlink file\n"); done: + printf("%s: text backend\n", ret ? "success" : "failure"); talloc_free(mem_ctx); return ret; } @@ -248,14 +247,14 @@ static bool torture_smbconf_reg(void) printf("test: registry backend\n"); - printf("test: init\n"); + printf("TEST: init\n"); werr = smbconf_init_reg(mem_ctx, &conf_ctx, NULL); if (!W_ERROR_IS_OK(werr)) { - printf("failure: init failed: %s\n", win_errstr(werr)); + printf("FAIL: init failed: %s\n", win_errstr(werr)); ret = false; goto done; } - printf("success: init\n"); + printf("OK: init\n"); ret &= test_get_includes(conf_ctx); ret &= test_set_get_includes(conf_ctx); @@ -263,9 +262,8 @@ static bool torture_smbconf_reg(void) smbconf_shutdown(conf_ctx); - printf("%s: registry backend\n", ret ? "success" : "failure"); - done: + printf("%s: registry backend\n", ret ? "success" : "failure"); talloc_free(mem_ctx); return ret; } -- cgit From c0fdc71ecdf437c978ade36603f0280afb1addb5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 13:57:24 +0100 Subject: s3:tests: add a guard arround . $incdir/test_functions.sh So that caller can overwrite the functions. metze --- source3/script/tests/test_functions.sh | 1 + source3/script/tests/test_local_s3.sh | 2 ++ source3/script/tests/test_net_misc.sh | 2 ++ source3/script/tests/test_net_registry.sh | 2 ++ source3/script/tests/test_net_s3.sh | 2 ++ source3/script/tests/test_ntlm_auth_s3.sh | 2 ++ source3/script/tests/test_posix_s3.sh | 2 ++ source3/script/tests/test_smbclient_s3.sh | 2 ++ source3/script/tests/test_smbtorture_s3.sh | 2 ++ source3/script/tests/test_testparm_s3.sh | 2 ++ source3/script/tests/test_wbinfo_s3.sh | 2 ++ 11 files changed, 21 insertions(+) diff --git a/source3/script/tests/test_functions.sh b/source3/script/tests/test_functions.sh index 79642e045b..bddae18c10 100644 --- a/source3/script/tests/test_functions.sh +++ b/source3/script/tests/test_functions.sh @@ -1,3 +1,4 @@ +TEST_FUNCTIONS_SH="INCLUDED" samba3_stop_sig_term() { RET=0 diff --git a/source3/script/tests/test_local_s3.sh b/source3/script/tests/test_local_s3.sh index aed8637abd..1840779085 100755 --- a/source3/script/tests/test_local_s3.sh +++ b/source3/script/tests/test_local_s3.sh @@ -9,8 +9,10 @@ EOF exit 1; fi +test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0` . $incdir/test_functions.sh +} failed=0 diff --git a/source3/script/tests/test_net_misc.sh b/source3/script/tests/test_net_misc.sh index 9f5fdfe925..8d092f4fe1 100755 --- a/source3/script/tests/test_net_misc.sh +++ b/source3/script/tests/test_net_misc.sh @@ -7,8 +7,10 @@ NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION" NETTIME="${NET} time" NETLOOKUP="${NET} lookup" +test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0` . $incdir/test_functions.sh +} failed=0 diff --git a/source3/script/tests/test_net_registry.sh b/source3/script/tests/test_net_registry.sh index 22081ec2f6..a3d1a24fd8 100755 --- a/source3/script/tests/test_net_registry.sh +++ b/source3/script/tests/test_net_registry.sh @@ -15,8 +15,10 @@ else NETREG="${NET} registry" fi +test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0` . $incdir/test_functions.sh +} failed=0 diff --git a/source3/script/tests/test_net_s3.sh b/source3/script/tests/test_net_s3.sh index f7dc2b7e10..a0e83a65b1 100755 --- a/source3/script/tests/test_net_s3.sh +++ b/source3/script/tests/test_net_s3.sh @@ -2,8 +2,10 @@ # tests for the "net" command +test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0` . $incdir/test_functions.sh +} failed=0 diff --git a/source3/script/tests/test_ntlm_auth_s3.sh b/source3/script/tests/test_ntlm_auth_s3.sh index 6c97f2e650..c7ebc03c80 100755 --- a/source3/script/tests/test_ntlm_auth_s3.sh +++ b/source3/script/tests/test_ntlm_auth_s3.sh @@ -1,7 +1,9 @@ #!/bin/sh +test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0` . $incdir/test_functions.sh +} failed=0 diff --git a/source3/script/tests/test_posix_s3.sh b/source3/script/tests/test_posix_s3.sh index 3e9998666c..0885b139bb 100755 --- a/source3/script/tests/test_posix_s3.sh +++ b/source3/script/tests/test_posix_s3.sh @@ -16,8 +16,10 @@ start="$4" shift 4 ADDARGS="$*" +test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0` . $incdir/test_functions.sh +} base="BASE-ATTR BASE-CHARSET BASE-CHKPATH BASE-DEFER_OPEN BASE-DELAYWRITE BASE-DELETE" base="$base BASE-DENY1 BASE-DENY2 BASE-DENY3 BASE-DENYDOS BASE-DIR1 BASE-DIR2" diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh index 1d55087c88..f60c7d7c0b 100755 --- a/source3/script/tests/test_smbclient_s3.sh +++ b/source3/script/tests/test_smbclient_s3.sh @@ -17,8 +17,10 @@ SMBCLIENT="$VALGRIND ${SMBCLIENT:-$BINDIR/smbclient} $CONFIGURATION" shift 4 ADDARGS="$*" +test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0` . $incdir/test_functions.sh +} failed=0 diff --git a/source3/script/tests/test_smbtorture_s3.sh b/source3/script/tests/test_smbtorture_s3.sh index 2ec20dc6ac..842277b357 100755 --- a/source3/script/tests/test_smbtorture_s3.sh +++ b/source3/script/tests/test_smbtorture_s3.sh @@ -16,8 +16,10 @@ start="$4" shift 4 ADDARGS="$*" +test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0` . $incdir/test_functions.sh +} tests="FDPASS LOCK1 LOCK2 LOCK3 LOCK4 LOCK5 LOCK6 LOCK7" #tests="$tests UNLINK BROWSE ATTR TRANS2 MAXFID TORTURE " diff --git a/source3/script/tests/test_testparm_s3.sh b/source3/script/tests/test_testparm_s3.sh index 6ea2794537..c88fc2d9d5 100755 --- a/source3/script/tests/test_testparm_s3.sh +++ b/source3/script/tests/test_testparm_s3.sh @@ -8,8 +8,10 @@ TEMP_CONFFILE=${LIBDIR}/smb.conf.tmp TESTPARM="$VALGRIND ${TESTPARM:-$BINDIR/testparm} --suppress-prompt --skip-logic-checks" +test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0` . $incdir/test_functions.sh +} failed=0 diff --git a/source3/script/tests/test_wbinfo_s3.sh b/source3/script/tests/test_wbinfo_s3.sh index e3bf1b9e70..fa6e20fc72 100755 --- a/source3/script/tests/test_wbinfo_s3.sh +++ b/source3/script/tests/test_wbinfo_s3.sh @@ -14,8 +14,10 @@ password="$4" shift 4 ADDARGS="$*" +test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && { incdir=`dirname $0` . $incdir/test_functions.sh +} OLDIFS=$IFS; -- cgit From c96534cd6e3eb3bef88ee538838519437870a085 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 14:00:32 +0100 Subject: s3:selftest: run the same tests as 'make test' Only the tests with samba4's smbtorture are missing. metze --- source3/selftest/tests.sh | 102 +++++++++++++++++++++++++++++++++------------- 1 file changed, 73 insertions(+), 29 deletions(-) diff --git a/source3/selftest/tests.sh b/source3/selftest/tests.sh index e07dee6f8a..c4907a159f 100755 --- a/source3/selftest/tests.sh +++ b/source3/selftest/tests.sh @@ -44,44 +44,88 @@ normalize_testname() { echo $name | tr "A-Z-" "a-z." } -BINDIR=`dirname $0`/../bin -SCRIPTDIR=`dirname $0`/../script/tests -export SCRIPTDIR +TEST_FUNCTIONS_SH="INCLUDED" +testit() { + name=$1 + shift 1 + cmdline="$*" -plantest "talloctort3" none $VALGRIND $BINDIR/talloctort -plantest "replacetort3" none $VALGRIND $BINDIR/replacetort -plantest "tdbtorture3" none $VALGRIND $BINDIR/tdbtorture -plantest "smbconftort3" none $VALGRIND $BINDIR/smbconftort -s \$SMB_CONF_PATH + plantest "`normalize_testname $testitprefix$name`" $testitenv $cmdline + return +} + +testok() { + true + return +} -tests="FDPASS LOCK1 LOCK2 LOCK3 LOCK4 LOCK5 LOCK6 LOCK7" -tests="$tests UNLINK BROWSE ATTR TRANS2 TORTURE " -tests="$tests OPLOCK1 OPLOCK2 OPLOCK3" -tests="$tests DIR DIR1 TCON TCONDEV RW1 RW2 RW3" -tests="$tests OPEN XCOPY RENAME DELETE PROPERTIES W2K" -tests="$tests TCON2 IOCTL CHKPATH FDSESS LOCAL-SUBSTITUTE" +BINDIR=`dirname $0`/../bin +export BINDIR -for t in $tests; do - name=`normalize_testname smbtorture3.plain.$t` - plantest "$name" dc $VALGRIND $BINDIR/smbtorture //\$SERVER/tmp -U\$USERNAME%\$PASSWORD $t -done +SCRIPTDIR=`dirname $0`/../script/tests +export SCRIPTDIR -for t in $tests; do - name=`normalize_testname smbtorture3.crypt.$t` - plantest "$name" dc $VALGRIND $BINDIR/smbtorture //\$SERVER/tmp -U\$USERNAME%\$PASSWORD $t -done +CONFIGURATION="--configfile \$SMB_CONF_PATH" +export CONFIGURATION + +CONFFILE="\$SMB_CONF_PATH" +export CONFFILE + +SERVER="\$SERVER" +export SERVER + +USERNAME="\$USERNAME" +export USERNAME + +PASSWORD="\$PASSWORD" +export PASSWORD + +( + shift $# + testitprefix="local_s3." + testitenv="none" + . $SCRIPTDIR/test_local_s3.sh +) + +( + shift $# + testitprefix="smbtorture_s3.plain." + testitenv="dc" + . $SCRIPTDIR/test_smbtorture_s3.sh //\$SERVER_IP/tmp \$USERNAME \$PASSWORD "" +) + +( + shift $# + testitprefix="smbtorture_s3.crypt." + testitenv="dc" + . $SCRIPTDIR/test_smbtorture_s3.sh //\$SERVER_IP/tmp \$USERNAME \$PASSWORD "-e" +) + +( + shift $# + testitprefix="wbinfo_s3." + testitenv="dc:local" + . $SCRIPTDIR/test_wbinfo_s3.sh \$WORKGROUP \$SERVER \$USERNAME \$PASSWORD +) + +( + shift $# + testitprefix="ntlm_auth_s3." + testitenv="dc:local" + . $SCRIPTDIR/test_ntlm_auth_s3.sh +) # plain -plantest "blackbox.smbclient3.plain" dc BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$USERNAME \$PASSWORD -plantest "blackbox.smbclient3.plain member creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD -plantest "blackbox.smbclient3.plain domain creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$DOMAIN\\\\\$DC_USERNAME \$DC_PASSWORD +plantest "blackbox.smbclient_s3.plain" dc BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$USERNAME \$PASSWORD +plantest "blackbox.smbclient_s3.plain member creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD +plantest "blackbox.smbclient_s3.plain domain creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$DOMAIN\\\\\$DC_USERNAME \$DC_PASSWORD # encrypted -plantest "blackbox.smbclient3.crypt" dc BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$USERNAME \$PASSWORD "-e" +plantest "blackbox.smbclient_s3.crypt" dc BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$USERNAME \$PASSWORD "-e" # these don't work yet -#plantest "blackbox.smbclient3.crypt member creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD "-e" -#plantest "blackbox.smbclient3.crypt domain creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$DOMAIN\\\\\$DC_USERNAME \$DC_PASSWORD "-e" +#plantest "blackbox.smbclient_s3.crypt member creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD "-e" +#plantest "blackbox.smbclient_s3.crypt domain creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$DOMAIN\\\\\$DC_USERNAME \$DC_PASSWORD "-e" -plantest "blackbox.wbinfo3" dc BINDIR="$BINDIR" script/tests/test_wbinfo_s3.sh \$DOMAIN \$SERVER \$USERNAME \$PASSWORD -plantest "blackbox.net3" dc BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" script/tests/test_net_s3.sh +plantest "blackbox.net_s3" dc BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" script/tests/test_net_s3.sh -- cgit From 40b67c3426042ea46d2497e459807ef9551e62f1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 20:38:27 +0100 Subject: selftest: pass down the path to python for provisioning samba4 metze --- selftest/target/Samba4.pm | 3 +++ source4/selftest/config.mk | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index 208824d6b2..5ca1a6a305 100644 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -717,6 +717,9 @@ nogroup:x:65534:nobody if (defined($ENV{VALGRIND_PROVISION})) { push (@provision_options, "valgrind"); } + if (defined($ENV{PYTHON})) { + push (@provision_options, $ENV{PYTHON}); + } push (@provision_options, "$self->{setupdir}/provision"); push (@provision_options, split(' ', $configuration)); push (@provision_options, "--host-name=$netbiosname"); diff --git a/source4/selftest/config.mk b/source4/selftest/config.mk index c5f7c5adb4..324532c22a 100644 --- a/source4/selftest/config.mk +++ b/source4/selftest/config.mk @@ -1,6 +1,7 @@ TEST_FORMAT = plain -SELFTEST = $(LD_LIBPATH_OVERRIDE) $(PERL) $(selftestdir)/selftest.pl --prefix=${selftest_prefix} \ +SELFTEST = $(LD_LIBPATH_OVERRIDE) PYTHON=$(PYTHON) \ + $(PERL) $(selftestdir)/selftest.pl --prefix=${selftest_prefix} \ --builddir=$(builddir) --srcdir=$(srcdir) \ --expected-failures=$(srcdir)/selftest/knownfail \ --format=$(TEST_FORMAT) \ -- cgit From aef749b53fb835226d4e879234b3ac3da1e33557 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 30 Jan 2009 21:25:37 +0100 Subject: pass NULL to prs_give_memory, that is a pointer --- source3/rpc_client/cli_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index 83247df46b..e620c13b04 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -1252,7 +1252,7 @@ static struct async_req *rpc_api_pipe_send(TALLOC_CTX *mem_ctx, prs_init_empty(&state->incoming_pdu, state, UNMARSHALL); /* Make incoming_pdu dynamic with no memory. */ - prs_give_memory(&state->incoming_pdu, 0, 0, true); + prs_give_memory(&state->incoming_pdu, NULL, 0, true); talloc_set_destructor(state, rpc_api_pipe_state_destructor); -- cgit From f6d08849e11775eb2530f04ecb055269ea445539 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 30 Jan 2009 21:25:50 +0100 Subject: Fix memleaks --- source3/rpc_client/cli_pipe.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index e620c13b04..a741dec706 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -2604,6 +2604,7 @@ static void rpc_pipe_bind_step_one_done(struct async_req *subreq) /* Unmarshall the RPC header */ if (!smb_io_rpc_hdr("hdr", &hdr, &reply_pdu, 0)) { DEBUG(0, ("rpc_pipe_bind: failed to unmarshall RPC_HDR.\n")); + prs_mem_free(&reply_pdu); async_req_error(req, NT_STATUS_BUFFER_TOO_SMALL); return; } @@ -2611,12 +2612,14 @@ static void rpc_pipe_bind_step_one_done(struct async_req *subreq) if (!smb_io_rpc_hdr_ba("", &hdr_ba, &reply_pdu, 0)) { DEBUG(0, ("rpc_pipe_bind: Failed to unmarshall " "RPC_HDR_BA.\n")); + prs_mem_free(&reply_pdu); async_req_error(req, NT_STATUS_BUFFER_TOO_SMALL); return; } if (!check_bind_response(&hdr_ba, &state->cli->transfer_syntax)) { DEBUG(2, ("rpc_pipe_bind: check_bind_response failed.\n")); + prs_mem_free(&reply_pdu); async_req_error(req, NT_STATUS_BUFFER_TOO_SMALL); return; } @@ -2633,6 +2636,7 @@ static void rpc_pipe_bind_step_one_done(struct async_req *subreq) case PIPE_AUTH_TYPE_NONE: case PIPE_AUTH_TYPE_SCHANNEL: /* Bind complete. */ + prs_mem_free(&reply_pdu); async_req_done(req); break; @@ -2640,6 +2644,7 @@ static void rpc_pipe_bind_step_one_done(struct async_req *subreq) /* Need to send AUTH3 packet - no reply. */ status = rpc_finish_auth3_bind_send(req, state, &hdr, &reply_pdu); + prs_mem_free(&reply_pdu); if (!NT_STATUS_IS_OK(status)) { async_req_error(req, status); } @@ -2649,6 +2654,7 @@ static void rpc_pipe_bind_step_one_done(struct async_req *subreq) /* Need to send alter context request and reply. */ status = rpc_finish_spnego_ntlmssp_bind_send(req, state, &hdr, &reply_pdu); + prs_mem_free(&reply_pdu); if (!NT_STATUS_IS_OK(status)) { async_req_error(req, status); } @@ -2660,6 +2666,7 @@ static void rpc_pipe_bind_step_one_done(struct async_req *subreq) default: DEBUG(0,("cli_finish_bind_auth: unknown auth type %u\n", (unsigned int)state->cli->auth->auth_type)); + prs_mem_free(&reply_pdu); async_req_error(req, NT_STATUS_INTERNAL_ERROR); } } -- cgit From 03bd9b2683ab7abf967118b5970f6a59c101782a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 22:19:10 +0100 Subject: s4:heimdal_build: heimdal requires u_int32_t and u_char metze --- source4/heimdal_build/internal.m4 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source4/heimdal_build/internal.m4 b/source4/heimdal_build/internal.m4 index 06e798ce27..b2f64a6825 100644 --- a/source4/heimdal_build/internal.m4 +++ b/source4/heimdal_build/internal.m4 @@ -33,6 +33,9 @@ esac ]) +AC_CHECK_TYPE(u_char, uint8_t) +AC_CHECK_TYPE(u_int32_t, uint32_t) + dnl Not all systems have err.h, so we provide a replacement. Heimdal dnl unconditionally #includes , so we need to create an err.h, dnl but we can't just have a static one because we don't want to use -- cgit From 4519eae158e7821dcd2f818eea830cfcdd4a0105 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 22:19:50 +0100 Subject: s4:lib/socket: don't use gethostbyname2() metze --- source4/lib/socket/config.m4 | 1 - source4/lib/socket/socket_ip.c | 33 +++++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/source4/lib/socket/config.m4 b/source4/lib/socket/config.m4 index 9c0072dd8b..fa987a1f46 100644 --- a/source4/lib/socket/config.m4 +++ b/source4/lib/socket/config.m4 @@ -1,6 +1,5 @@ AC_CHECK_FUNCS(writev) AC_CHECK_FUNCS(readv) -AC_CHECK_FUNCS(gethostbyname2) ############################################ # check for unix domain sockets diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c index bca0aab924..cdb75fe021 100644 --- a/source4/lib/socket/socket_ip.c +++ b/source4/lib/socket/socket_ip.c @@ -549,19 +549,36 @@ _PUBLIC_ const struct socket_ops *socket_ipv4_ops(enum socket_type type) static struct in6_addr interpret_addr6(const char *name) { - struct hostent *he; - - if (name == NULL) return in6addr_any; + char addr[INET6_ADDRSTRLEN]; + struct in6_addr dest6; + const char *sp = name; + char *p = strchr_m(sp, '%'); + int ret; + + if (sp == NULL) return in6addr_any; - if (strcasecmp(name, "localhost") == 0) { - name = "::1"; + if (strcasecmp(sp, "localhost") == 0) { + sp = "::1"; } - he = gethostbyname2(name, PF_INET6); + /* + * Cope with link-local. + * This is IP:v6:addr%ifname. + */ + + if (p && (p > sp) && (if_nametoindex(p+1) != 0)) { + strlcpy(addr, sp, + MIN(PTR_DIFF(p,sp)+1, + sizeof(addr))); + sp = addr; + } - if (he == NULL) return in6addr_any; + ret = inet_pton(AF_INET6, sp, &dest6); + if (ret > 0) { + return dest6; + } - return *((struct in6_addr *)he->h_addr); + return in6addr_any; } static NTSTATUS ipv6_init(struct socket_context *sock) -- cgit From d4aeed879b21db41643250a23b1009b543e6c99f Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 30 Jan 2009 16:31:19 -0500 Subject: Fix all other modules to use ldb_module.h instead of ldb_private.h The only 2 modules escaping the rule so far are rootdse and partitions --- source4/dsdb/samdb/ldb_modules/kludge_acl.c | 58 +++-- source4/dsdb/samdb/ldb_modules/linked_attributes.c | 102 +++++--- source4/dsdb/samdb/ldb_modules/local_password.c | 105 +++++--- source4/dsdb/samdb/ldb_modules/naming_fsmo.c | 39 +-- source4/dsdb/samdb/ldb_modules/objectclass.c | 135 +++++----- source4/dsdb/samdb/ldb_modules/password_hash.c | 276 ++++++++++++--------- source4/dsdb/samdb/ldb_modules/pdc_fsmo.c | 37 +-- source4/dsdb/samdb/ldb_modules/proxy.c | 60 ++--- source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 155 +++++++----- source4/dsdb/samdb/ldb_modules/rootdse.c | 62 +++-- source4/dsdb/samdb/ldb_modules/samba3sam.c | 15 +- source4/dsdb/samdb/ldb_modules/samldb.c | 176 ++++++++----- source4/dsdb/samdb/ldb_modules/schema_fsmo.c | 92 +++---- source4/dsdb/samdb/ldb_modules/show_deleted.c | 16 +- source4/dsdb/samdb/ldb_modules/simple_ldap_map.c | 27 +- source4/dsdb/schema/schema_set.c | 4 +- source4/lib/ldb/include/ldb.h | 3 + source4/lib/ldb/include/ldb_private.h | 3 - source4/nbt_server/wins/wins_ldb.c | 26 +- 19 files changed, 817 insertions(+), 574 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/kludge_acl.c b/source4/dsdb/samdb/ldb_modules/kludge_acl.c index bb95c7ee5a..1597f687a4 100644 --- a/source4/dsdb/samdb/ldb_modules/kludge_acl.c +++ b/source4/dsdb/samdb/ldb_modules/kludge_acl.c @@ -31,9 +31,7 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb_private.h" +#include "ldb_module.h" #include "auth/auth.h" #include "libcli/security/security.h" #include "dsdb/samdb/samdb.h" @@ -52,15 +50,17 @@ struct kludge_private_data { static enum security_user_level what_is_user(struct ldb_module *module) { + struct ldb_context *ldb = ldb_module_get_ctx(module); struct auth_session_info *session_info - = (struct auth_session_info *)ldb_get_opaque(module->ldb, "sessionInfo"); + = (struct auth_session_info *)ldb_get_opaque(ldb, "sessionInfo"); return security_session_user_level(session_info); } static const char *user_name(TALLOC_CTX *mem_ctx, struct ldb_module *module) { + struct ldb_context *ldb = ldb_module_get_ctx(module); struct auth_session_info *session_info - = (struct auth_session_info *)ldb_get_opaque(module->ldb, "sessionInfo"); + = (struct auth_session_info *)ldb_get_opaque(ldb, "sessionInfo"); if (!session_info) { return "UNKNOWN (NULL)"; } @@ -209,12 +209,14 @@ static int kludge_acl_childClasses(struct ldb_context *ldb, struct ldb_message * static int kludge_acl_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct kludge_acl_context *ac; struct kludge_private_data *data; int i, ret; ac = talloc_get_type(req->context, struct kludge_acl_context); - data = talloc_get_type(ac->module->private_data, struct kludge_private_data); + data = talloc_get_type(ldb_module_get_private(ac->module), struct kludge_private_data); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -228,7 +230,7 @@ static int kludge_acl_callback(struct ldb_request *req, struct ldb_reply *ares) switch (ares->type) { case LDB_REPLY_ENTRY: if (ac->allowedAttributes) { - ret = kludge_acl_allowedAttributes(ac->module->ldb, + ret = kludge_acl_allowedAttributes(ldb, ares->message, "allowedAttributes"); if (ret != LDB_SUCCESS) { @@ -236,7 +238,7 @@ static int kludge_acl_callback(struct ldb_request *req, struct ldb_reply *ares) } } if (ac->allowedChildClasses) { - ret = kludge_acl_childClasses(ac->module->ldb, + ret = kludge_acl_childClasses(ldb, ares->message, "allowedChildClasses"); if (ret != LDB_SUCCESS) { @@ -249,14 +251,14 @@ static int kludge_acl_callback(struct ldb_request *req, struct ldb_reply *ares) switch (ac->user_type) { case SECURITY_SYSTEM: if (ac->allowedAttributesEffective) { - ret = kludge_acl_allowedAttributes(ac->module->ldb, ares->message, + ret = kludge_acl_allowedAttributes(ldb, ares->message, "allowedAttributesEffective"); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, NULL, NULL, ret); } } if (ac->allowedChildClassesEffective) { - ret = kludge_acl_childClasses(ac->module->ldb, ares->message, + ret = kludge_acl_childClasses(ldb, ares->message, "allowedChildClassesEffective"); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, NULL, NULL, ret); @@ -266,14 +268,14 @@ static int kludge_acl_callback(struct ldb_request *req, struct ldb_reply *ares) case SECURITY_ADMINISTRATOR: if (ac->allowedAttributesEffective) { - ret = kludge_acl_allowedAttributes(ac->module->ldb, ares->message, + ret = kludge_acl_allowedAttributes(ldb, ares->message, "allowedAttributesEffective"); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, NULL, NULL, ret); } } if (ac->allowedChildClassesEffective) { - ret = kludge_acl_childClasses(ac->module->ldb, ares->message, + ret = kludge_acl_childClasses(ldb, ares->message, "allowedChildClassesEffective"); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, NULL, NULL, ret); @@ -316,6 +318,7 @@ static int kludge_acl_callback(struct ldb_request *req, struct ldb_reply *ares) static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct kludge_acl_context *ac; struct ldb_request *down_req; struct kludge_private_data *data; @@ -324,13 +327,15 @@ static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req) struct ldb_control *sd_control; struct ldb_control **sd_saved_controls; + ldb = ldb_module_get_ctx(module); + ac = talloc(req, struct kludge_acl_context); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - data = talloc_get_type(module->private_data, struct kludge_private_data); + data = talloc_get_type(ldb_module_get_private(module), struct kludge_private_data); ac->module = module; ac->req = req; @@ -372,7 +377,7 @@ static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req) } ret = ldb_build_search_req_ex(&down_req, - module->ldb, ac, + ldb, ac, req->op.search.base, req->op.search.scope, req->op.search.tree, @@ -402,13 +407,14 @@ static int kludge_acl_search(struct ldb_module *module, struct ldb_request *req) /* ANY change type */ static int kludge_acl_change(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb = ldb_module_get_ctx(module); enum security_user_level user_type = what_is_user(module); switch (user_type) { case SECURITY_SYSTEM: case SECURITY_ADMINISTRATOR: return ldb_next_request(module, req); default: - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "kludge_acl_change: " "attempted database modify not permitted. " "User %s is not SYSTEM or an administrator", @@ -419,6 +425,7 @@ static int kludge_acl_change(struct ldb_module *module, struct ldb_request *req) static int kludge_acl_extended(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb = ldb_module_get_ctx(module); enum security_user_level user_type; /* allow everybody to read the sequence number */ @@ -434,7 +441,7 @@ static int kludge_acl_extended(struct ldb_module *module, struct ldb_request *re case SECURITY_ADMINISTRATOR: return ldb_next_request(module, req); default: - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "kludge_acl_change: " "attempted database modify not permitted. " "User %s is not SYSTEM or an administrator", @@ -445,6 +452,7 @@ static int kludge_acl_extended(struct ldb_module *module, struct ldb_request *re static int kludge_acl_init(struct ldb_module *module) { + struct ldb_context *ldb; int ret, i; TALLOC_CTX *mem_ctx = talloc_new(module); static const char *attrs[] = { "passwordAttribute", NULL }; @@ -454,22 +462,24 @@ static int kludge_acl_init(struct ldb_module *module) struct kludge_private_data *data; + ldb = ldb_module_get_ctx(module); + data = talloc(module, struct kludge_private_data); if (data == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } data->password_attrs = NULL; - module->private_data = data; + ldb_module_set_private(module, data); if (!mem_ctx) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_search(module->ldb, mem_ctx, &res, - ldb_dn_new(mem_ctx, module->ldb, "@KLUDGEACL"), + ret = ldb_search(ldb, mem_ctx, &res, + ldb_dn_new(mem_ctx, ldb, "@KLUDGEACL"), LDB_SCOPE_BASE, attrs, NULL); if (ret != LDB_SUCCESS) { goto done; @@ -492,7 +502,7 @@ static int kludge_acl_init(struct ldb_module *module) data->password_attrs = talloc_array(data, const char *, password_attributes->num_values + 1); if (!data->password_attrs) { talloc_free(mem_ctx); - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } for (i=0; i < password_attributes->num_values; i++) { @@ -503,7 +513,7 @@ static int kludge_acl_init(struct ldb_module *module) ret = ldb_mod_register_control(module, LDB_CONTROL_SD_FLAGS_OID); if (ret != LDB_SUCCESS) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "partition: Unable to register control with rootdse!\n"); return LDB_ERR_OPERATIONS_ERROR; } diff --git a/source4/dsdb/samdb/ldb_modules/linked_attributes.c b/source4/dsdb/samdb/ldb_modules/linked_attributes.c index a3318ccabd..2365a58f78 100644 --- a/source4/dsdb/samdb/ldb_modules/linked_attributes.c +++ b/source4/dsdb/samdb/ldb_modules/linked_attributes.c @@ -29,10 +29,7 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb_private.h" -#include "ldb/include/dlinklist.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" struct la_op_store { @@ -65,15 +62,18 @@ struct la_context { static struct la_context *linked_attributes_init(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct la_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct la_context); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } - ac->schema = dsdb_get_schema(module->ldb); + ac->schema = dsdb_get_schema(ldb); ac->module = module; ac->req = req; @@ -86,19 +86,22 @@ static int la_store_op(struct la_context *ac, enum la_op op, struct ldb_val *dn, const char *name) { + struct ldb_context *ldb; struct la_op_store *os; struct ldb_dn *op_dn; - op_dn = ldb_dn_from_ldb_val(ac, ac->module->ldb, dn); + ldb = ldb_module_get_ctx(ac->module); + + op_dn = ldb_dn_from_ldb_val(ac, ldb, dn); if (!op_dn) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "could not parse attribute as a DN"); return LDB_ERR_INVALID_DN_SYNTAX; } os = talloc_zero(ac, struct la_op_store); if (!os) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -108,7 +111,7 @@ static int la_store_op(struct la_context *ac, os->name = talloc_strdup(os, name); if (!os->name) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -136,12 +139,15 @@ static int la_down_req(struct la_context *ac); /* add */ static int linked_attributes_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; const struct dsdb_attribute *target_attr; struct la_context *ac; const char *attr_name; int ret; int i, j; + ldb = ldb_module_get_ctx(module); + if (ldb_dn_is_special(req->op.add.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); @@ -164,7 +170,7 @@ static int linked_attributes_add(struct ldb_module *module, struct ldb_request * const struct dsdb_attribute *schema_attr = dsdb_attribute_by_lDAPDisplayName(ac->schema, el->name); if (!schema_attr) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "attribute %s is not a valid attribute in schema", el->name); return LDB_ERR_OBJECT_CLASS_VIOLATION; } @@ -175,7 +181,7 @@ static int linked_attributes_add(struct ldb_module *module, struct ldb_request * if ((schema_attr->linkID & 1) == 1) { /* Odd is for the target. Illigal to modify */ - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "attribute %s must not be modified directly, it is a linked attribute", el->name); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -222,6 +228,7 @@ static int linked_attributes_add(struct ldb_module *module, struct ldb_request * static int la_mod_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; const struct dsdb_attribute *schema_attr; const struct dsdb_attribute *target_attr; struct ldb_message_element *search_el; @@ -232,6 +239,7 @@ static int la_mod_search_callback(struct ldb_request *req, struct ldb_reply *are int ret = LDB_SUCCESS; ac = talloc_get_type(req->context, struct la_context); + ldb = ldb_module_get_ctx(ac->module); rc = ac->rc; if (!ares) { @@ -248,7 +256,7 @@ static int la_mod_search_callback(struct ldb_request *req, struct ldb_reply *are case LDB_REPLY_ENTRY: if (ldb_dn_compare(ares->message->dn, ac->req->op.mod.message->dn) != 0) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "linked_attributes: %s is not the DN we were looking for", ldb_dn_get_linearized(ares->message->dn)); /* Guh? We only asked for this DN */ talloc_free(ares); @@ -263,7 +271,7 @@ static int la_mod_search_callback(struct ldb_request *req, struct ldb_reply *are schema_attr = dsdb_attribute_by_lDAPDisplayName(ac->schema, rc->el[i].name); if (!schema_attr) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "attribute %s is not a valid attribute in schema", rc->el[i].name); talloc_free(ares); @@ -348,6 +356,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques /* Determine the effect of the modification */ /* Apply the modify to the linked entry */ + struct ldb_context *ldb; int i, j; struct la_context *ac; struct ldb_request *search_req; @@ -355,6 +364,8 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques int ret; + ldb = ldb_module_get_ctx(module); + if (ldb_dn_is_special(req->op.mod.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); @@ -372,7 +383,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques ac->rc = talloc_zero(ac, struct replace_context); if (!ac->rc) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -384,7 +395,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques const struct dsdb_attribute *schema_attr = dsdb_attribute_by_lDAPDisplayName(ac->schema, el->name); if (!schema_attr) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "attribute %s is not a valid attribute in schema", el->name); return LDB_ERR_OBJECT_CLASS_VIOLATION; } @@ -395,7 +406,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques if ((schema_attr->linkID & 1) == 1) { /* Odd is for the target. Illegal to modify */ - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "attribute %s must not be modified directly, it is a linked attribute", el->name); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -466,7 +477,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques struct ldb_message_element, ac->rc->num_elements +1); if (!search_el) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } ac->rc->el = search_el; @@ -482,7 +493,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques attrs = talloc_array(ac->rc, const char *, ac->rc->num_elements + 1); if (!attrs) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } for (i = 0; ac->rc && i < ac->rc->num_elements; i++) { @@ -491,7 +502,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques attrs[i] = NULL; /* The callback does all the hard work here */ - ret = ldb_build_search_req(&search_req, module->ldb, ac, + ret = ldb_build_search_req(&search_req, ldb, ac, req->op.mod.message->dn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, @@ -523,6 +534,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques /* delete, rename */ static int linked_attributes_del(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *search_req; struct la_context *ac; const char **attrs; @@ -538,6 +550,8 @@ static int linked_attributes_del(struct ldb_module *module, struct ldb_request * - Regain our sainity */ + ldb = ldb_module_get_ctx(module); + ac = linked_attributes_init(module, req); if (!ac) { return LDB_ERR_OPERATIONS_ERROR; @@ -553,7 +567,7 @@ static int linked_attributes_del(struct ldb_module *module, struct ldb_request * return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&search_req, module->ldb, req, + ret = ldb_build_search_req(&search_req, ldb, req, req->op.del.dn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, NULL, @@ -601,6 +615,7 @@ static int linked_attributes_rename(struct ldb_module *module, struct ldb_reques static int la_op_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct la_context *ac; const struct dsdb_attribute *schema_attr; const struct dsdb_attribute *target_attr; @@ -610,6 +625,7 @@ static int la_op_search_callback(struct ldb_request *req, int ret; ac = talloc_get_type(req->context, struct la_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -647,7 +663,7 @@ static int la_op_search_callback(struct ldb_request *req, break; default: talloc_free(ares); - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "operations must be delete or rename"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -658,7 +674,7 @@ static int la_op_search_callback(struct ldb_request *req, schema_attr = dsdb_attribute_by_lDAPDisplayName(ac->schema, el->name); if (!schema_attr) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "attribute %s is not a valid attribute" " in schema", el->name); talloc_free(ares); @@ -737,7 +753,7 @@ static int la_op_search_callback(struct ldb_request *req, default: talloc_free(ares); - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "operations must be delete or rename"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -764,7 +780,7 @@ static int la_do_mod_request(struct la_context *ac) ac->op_response, LDB_SUCCESS); } - ldb = ac->module->ldb; + ldb = ldb_module_get_ctx(ac->module); /* Create the modify request */ new_msg = ldb_msg_new(ac); @@ -797,7 +813,7 @@ static int la_do_mod_request(struct la_context *ac) } #if 0 - ldb_debug(ac->module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "link on %s %s: %s %s\n", ldb_dn_get_linearized(new_msg->dn), ret_el->name, ret_el->values[0].data, ac->ops->op == LA_OP_ADD ? "added" : "deleted"); @@ -822,9 +838,11 @@ static int la_do_mod_request(struct la_context *ac) static int la_mod_callback(struct ldb_request *req, struct ldb_reply *ares) { struct la_context *ac; + struct ldb_context *ldb; struct la_op_store *os; ac = talloc_get_type(req->context, struct la_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -836,7 +854,7 @@ static int la_mod_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "invalid ldb_reply_type in callback"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, @@ -860,7 +878,10 @@ static int la_mod_del_callback(struct ldb_request *req, struct ldb_reply *ares) { int ret; struct la_context *ac; + struct ldb_context *ldb; + ac = talloc_get_type(req->context, struct la_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -872,7 +893,7 @@ static int la_mod_del_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "invalid ldb_reply_type in callback"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, @@ -903,7 +924,10 @@ static int la_rename_callback(struct ldb_request *req, struct ldb_reply *ares) struct ldb_request *search_req; const char **attrs; WERROR werr; + struct ldb_context *ldb; + ac = talloc_get_type(req->context, struct la_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -915,7 +939,7 @@ static int la_rename_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "invalid ldb_reply_type in callback"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, @@ -927,7 +951,7 @@ static int la_rename_callback(struct ldb_request *req, struct ldb_reply *ares) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&search_req, ac->module->ldb, req, + ret = ldb_build_search_req(&search_req, ldb, req, ac->req->op.rename.newdn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, NULL, @@ -964,7 +988,10 @@ static int la_add_callback(struct ldb_request *req, struct ldb_reply *ares) { int ret; struct la_context *ac; + struct ldb_context *ldb; + ac = talloc_get_type(req->context, struct la_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -976,7 +1003,7 @@ static int la_add_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "invalid ldb_reply_type in callback"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, @@ -989,7 +1016,7 @@ static int la_add_callback(struct ldb_request *req, struct ldb_reply *ares) /* The callback does all the hard work here - we need * the objectGUID and SID of the added record */ - ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ret = ldb_build_search_req(&search_req, ldb, ac, ac->req->op.add.message->dn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, @@ -1023,31 +1050,34 @@ static int la_down_req(struct la_context *ac) { struct ldb_request *down_req; int ret; + struct ldb_context *ldb; + + ldb = ldb_module_get_ctx(ac->module); switch (ac->req->operation) { case LDB_ADD: - ret = ldb_build_add_req(&down_req, ac->module->ldb, ac, + ret = ldb_build_add_req(&down_req, ldb, ac, ac->req->op.add.message, ac->req->controls, ac, la_add_callback, ac->req); break; case LDB_MODIFY: - ret = ldb_build_mod_req(&down_req, ac->module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, ac->req->op.mod.message, ac->req->controls, ac, la_mod_del_callback, ac->req); break; case LDB_DELETE: - ret = ldb_build_del_req(&down_req, ac->module->ldb, ac, + ret = ldb_build_del_req(&down_req, ldb, ac, ac->req->op.del.dn, ac->req->controls, ac, la_mod_del_callback, ac->req); break; case LDB_RENAME: - ret = ldb_build_rename_req(&down_req, ac->module->ldb, ac, + ret = ldb_build_rename_req(&down_req, ldb, ac, ac->req->op.rename.olddn, ac->req->op.rename.newdn, ac->req->controls, diff --git a/source4/dsdb/samdb/ldb_modules/local_password.c b/source4/dsdb/samdb/ldb_modules/local_password.c index 55d895791a..58c0f1f0d5 100644 --- a/source4/dsdb/samdb/ldb_modules/local_password.c +++ b/source4/dsdb/samdb/ldb_modules/local_password.c @@ -31,8 +31,7 @@ #include "includes.h" #include "libcli/ldap/ldap.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb_private.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" #include "librpc/ndr/libndr.h" #include "dsdb/samdb/ldb_modules/password_modules.h" @@ -89,11 +88,14 @@ struct lpdb_context { static struct lpdb_context *lpdb_init_context(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct lpdb_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct lpdb_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return NULL; } @@ -105,9 +107,11 @@ static struct lpdb_context *lpdb_init_context(struct ldb_module *module, static int lpdb_local_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct lpdb_context *ac; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -119,7 +123,7 @@ static int lpdb_local_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, "Unexpected reply type"); + ldb_set_errstring(ldb, "Unexpected reply type"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -141,6 +145,7 @@ static int lpdb_add_callback(struct ldb_request *req, static int local_password_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_message *remote_message; struct ldb_request *remote_req; struct lpdb_context *ac; @@ -148,14 +153,15 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req int ret; int i; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "local_password_add\n"); + ldb = ldb_module_get_ctx(module); + ldb_debug(ldb, LDB_DEBUG_TRACE, "local_password_add\n"); if (ldb_dn_is_special(req->op.add.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); } /* If the caller is manipulating the local passwords directly, let them pass */ - if (ldb_dn_compare_base(ldb_dn_new(req, module->ldb, LOCAL_BASE), + if (ldb_dn_compare_base(ldb_dn_new(req, ldb, LOCAL_BASE), req->op.add.message->dn) == 0) { return ldb_next_request(module, req); } @@ -173,7 +179,7 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req /* TODO: remove this when userPassword will be in schema */ if (!ldb_msg_check_string_attribute(req->op.add.message, "objectClass", "person")) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "Cannot relocate a password on entry: %s, does not have objectClass 'person'", ldb_dn_get_linearized(req->op.add.message->dn)); return LDB_ERR_OBJECT_CLASS_VIOLATION; @@ -213,7 +219,7 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req * to add the password. This may be changed to an 'add and * search', to allow the directory to create the objectGUID */ if (ldb_msg_find_ldb_val(req->op.add.message, "objectGUID") == NULL) { - ldb_set_errstring(module->ldb, + ldb_set_errstring(ldb, "no objectGUID found in search: " "local_password module must be " "onfigured below objectGUID module!\n"); @@ -221,7 +227,7 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req } ac->local_message->dn = ldb_dn_new(ac->local_message, - module->ldb, LOCAL_BASE); + ldb, LOCAL_BASE); if ((ac->local_message->dn == NULL) || ( ! ldb_dn_add_child_fmt(ac->local_message->dn, PASSWORD_GUID_ATTR "=%s", @@ -230,7 +236,7 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_add_req(&remote_req, module->ldb, ac, + ret = ldb_build_add_req(&remote_req, ldb, ac, remote_message, req->controls, ac, lpdb_add_callback, @@ -247,11 +253,13 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req static int lpdb_add_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct ldb_request *local_req; struct lpdb_context *ac; int ret; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -263,7 +271,7 @@ static int lpdb_add_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, "Unexpected reply type"); + ldb_set_errstring(ldb, "Unexpected reply type"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -271,7 +279,7 @@ static int lpdb_add_callback(struct ldb_request *req, ac->remote_done = talloc_steal(ac, ares); - ret = ldb_build_add_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_add_req(&local_req, ldb, ac, ac->local_message, NULL, ac, lpdb_local_callback, @@ -298,20 +306,22 @@ static int lpdb_mod_search_callback(struct ldb_request *req, static int local_password_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct lpdb_context *ac; struct ldb_message *remote_message; struct ldb_request *remote_req; int ret; int i; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "local_password_modify\n"); + ldb = ldb_module_get_ctx(module); + ldb_debug(ldb, LDB_DEBUG_TRACE, "local_password_modify\n"); if (ldb_dn_is_special(req->op.mod.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); } /* If the caller is manipulating the local passwords directly, let them pass */ - if (ldb_dn_compare_base(ldb_dn_new(req, module->ldb, LOCAL_BASE), + if (ldb_dn_compare_base(ldb_dn_new(req, ldb, LOCAL_BASE), req->op.mod.message->dn) == 0) { return ldb_next_request(module, req); } @@ -354,7 +364,7 @@ static int local_password_modify(struct ldb_module *module, struct ldb_request * ldb_msg_remove_attr(ac->local_message, remote_message->elements[i].name); } - ret = ldb_build_mod_req(&remote_req, module->ldb, ac, + ret = ldb_build_mod_req(&remote_req, ldb, ac, remote_message, req->controls, ac, lpdb_modify_callabck, @@ -371,12 +381,14 @@ static int local_password_modify(struct ldb_module *module, struct ldb_request * static int lpdb_modify_callabck(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; static const char * const attrs[] = { "objectGUID", "objectClass", NULL }; struct ldb_request *search_req; struct lpdb_context *ac; int ret; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -388,7 +400,7 @@ static int lpdb_modify_callabck(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, "Unexpected reply type"); + ldb_set_errstring(ldb, "Unexpected reply type"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -397,7 +409,7 @@ static int lpdb_modify_callabck(struct ldb_request *req, ac->remote_done = talloc_steal(ac, ares); /* prepare the search operation */ - ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ret = ldb_build_search_req(&search_req, ldb, ac, ac->req->op.mod.message->dn, LDB_SCOPE_BASE, "(objectclass=*)", attrs, NULL, @@ -421,6 +433,7 @@ static int lpdb_modify_callabck(struct ldb_request *req, static int lpdb_mod_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct ldb_request *local_req; struct lpdb_context *ac; struct ldb_dn *local_dn; @@ -428,6 +441,7 @@ static int lpdb_mod_search_callback(struct ldb_request *req, int ret = LDB_SUCCESS; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -441,7 +455,7 @@ static int lpdb_mod_search_callback(struct ldb_request *req, switch (ares->type) { case LDB_REPLY_ENTRY: if (ac->remote != NULL) { - ldb_set_errstring(ac->module->ldb, "Too many results"); + ldb_set_errstring(ldb, "Too many results"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -465,7 +479,7 @@ static int lpdb_mod_search_callback(struct ldb_request *req, /* if it is not an entry of type person this is an error */ /* TODO: remove this when sambaPassword will be in schema */ if (ac->remote == NULL) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "entry just modified (%s) not found!", ldb_dn_get_linearized(req->op.search.base)); return ldb_module_done(ac->req, NULL, NULL, @@ -482,7 +496,7 @@ static int lpdb_mod_search_callback(struct ldb_request *req, if (ldb_msg_find_ldb_val(ac->remote->message, "objectGUID") == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "no objectGUID found in search: " "local_password module must be " "configured below objectGUID " @@ -494,7 +508,7 @@ static int lpdb_mod_search_callback(struct ldb_request *req, objectGUID = samdb_result_guid(ac->remote->message, "objectGUID"); - local_dn = ldb_dn_new(ac, ac->module->ldb, LOCAL_BASE); + local_dn = ldb_dn_new(ac, ldb, LOCAL_BASE); if ((local_dn == NULL) || ( ! ldb_dn_add_child_fmt(local_dn, PASSWORD_GUID_ATTR "=%s", @@ -504,7 +518,7 @@ static int lpdb_mod_search_callback(struct ldb_request *req, } ac->local_message->dn = local_dn; - ret = ldb_build_mod_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_mod_req(&local_req, ldb, ac, ac->local_message, NULL, ac, lpdb_local_callback, @@ -535,11 +549,13 @@ static int lpdb_del_search_callback(struct ldb_request *req, static int local_password_delete(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *remote_req; struct lpdb_context *ac; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "local_password_delete\n"); + ldb = ldb_module_get_ctx(module); + ldb_debug(ldb, LDB_DEBUG_TRACE, "local_password_delete\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.mod.message->dn)) { @@ -548,7 +564,7 @@ static int local_password_delete(struct ldb_module *module, /* If the caller is manipulating the local passwords directly, * let them pass */ - if (ldb_dn_compare_base(ldb_dn_new(req, module->ldb, LOCAL_BASE), + if (ldb_dn_compare_base(ldb_dn_new(req, ldb, LOCAL_BASE), req->op.del.dn) == 0) { return ldb_next_request(module, req); } @@ -559,7 +575,7 @@ static int local_password_delete(struct ldb_module *module, return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_del_req(&remote_req, module->ldb, ac, + ret = ldb_build_del_req(&remote_req, ldb, ac, req->op.del.dn, req->controls, ac, lpdb_delete_callabck, @@ -576,12 +592,14 @@ static int local_password_delete(struct ldb_module *module, static int lpdb_delete_callabck(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; static const char * const attrs[] = { "objectGUID", "objectClass", NULL }; struct ldb_request *search_req; struct lpdb_context *ac; int ret; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -593,7 +611,7 @@ static int lpdb_delete_callabck(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, "Unexpected reply type"); + ldb_set_errstring(ldb, "Unexpected reply type"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -602,7 +620,7 @@ static int lpdb_delete_callabck(struct ldb_request *req, ac->remote_done = talloc_steal(ac, ares); /* prepare the search operation */ - ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ret = ldb_build_search_req(&search_req, ldb, ac, ac->req->op.del.dn, LDB_SCOPE_BASE, "(objectclass=*)", attrs, NULL, @@ -626,6 +644,7 @@ static int lpdb_delete_callabck(struct ldb_request *req, static int lpdb_del_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct ldb_request *local_req; struct lpdb_context *ac; struct ldb_dn *local_dn; @@ -633,6 +652,7 @@ static int lpdb_del_search_callback(struct ldb_request *req, int ret = LDB_SUCCESS; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -646,7 +666,7 @@ static int lpdb_del_search_callback(struct ldb_request *req, switch (ares->type) { case LDB_REPLY_ENTRY: if (ac->remote != NULL) { - ldb_set_errstring(ac->module->ldb, "Too many results"); + ldb_set_errstring(ldb, "Too many results"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -686,7 +706,7 @@ static int lpdb_del_search_callback(struct ldb_request *req, if (ldb_msg_find_ldb_val(ac->remote->message, "objectGUID") == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "no objectGUID found in search: " "local_password module must be " "configured below objectGUID " @@ -698,7 +718,7 @@ static int lpdb_del_search_callback(struct ldb_request *req, objectGUID = samdb_result_guid(ac->remote->message, "objectGUID"); - local_dn = ldb_dn_new(ac, ac->module->ldb, LOCAL_BASE); + local_dn = ldb_dn_new(ac, ldb, LOCAL_BASE); if ((local_dn == NULL) || ( ! ldb_dn_add_child_fmt(local_dn, PASSWORD_GUID_ATTR "=%s", @@ -707,7 +727,7 @@ static int lpdb_del_search_callback(struct ldb_request *req, LDB_ERR_OPERATIONS_ERROR); } - ret = ldb_build_del_req(&local_req, ac->module->ldb, ac, + ret = ldb_build_del_req(&local_req, ldb, ac, local_dn, NULL, ac, lpdb_local_callback, @@ -736,10 +756,13 @@ static int lpdb_local_search_callback(struct ldb_request *req, static int lpdb_local_search(struct lpdb_context *ac) { + struct ldb_context *ldb; struct ldb_request *local_req; int ret; - ret = ldb_build_search_req(&local_req, ac->module->ldb, ac, + ldb = ldb_module_get_ctx(ac->module); + + ret = ldb_build_search_req(&local_req, ldb, ac, ac->current->local_dn, LDB_SCOPE_BASE, "(objectclass=*)", @@ -757,6 +780,7 @@ static int lpdb_local_search(struct lpdb_context *ac) static int lpdb_local_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct lpdb_context *ac; struct ldb_reply *merge; struct lpdb_reply *lr; @@ -764,6 +788,7 @@ static int lpdb_local_search_callback(struct ldb_request *req, int i; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -781,7 +806,7 @@ static int lpdb_local_search_callback(struct ldb_request *req, case LDB_REPLY_ENTRY: if (lr->remote == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Too many results for password entry search!"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, @@ -868,6 +893,7 @@ static int lpdb_local_search_callback(struct ldb_request *req, static int lpdb_remote_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct lpdb_context *ac; struct ldb_dn *local_dn; struct GUID objectGUID; @@ -875,6 +901,7 @@ static int lpdb_remote_search_callback(struct ldb_request *req, int ret; ac = talloc_get_type(req->context, struct lpdb_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -903,7 +930,7 @@ static int lpdb_remote_search_callback(struct ldb_request *req, } if (ldb_msg_find_ldb_val(ares->message, "objectGUID") == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "no objectGUID found in search: local_password module must be configured below objectGUID module!\n"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -919,7 +946,7 @@ static int lpdb_remote_search_callback(struct ldb_request *req, ldb_msg_remove_attr(ares->message, "objectClass"); } - local_dn = ldb_dn_new(ac, ac->module->ldb, LOCAL_BASE); + local_dn = ldb_dn_new(ac, ldb, LOCAL_BASE); if ((local_dn == NULL) || (! ldb_dn_add_child_fmt(local_dn, PASSWORD_GUID_ATTR "=%s", @@ -984,13 +1011,15 @@ static int lpdb_remote_search_callback(struct ldb_request *req, static int local_password_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *remote_req; struct lpdb_context *ac; int i; int ret; const char * const *search_attrs = NULL; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "local_password_search\n"); + ldb = ldb_module_get_ctx(module); + ldb_debug(ldb, LDB_DEBUG_TRACE, "local_password_search\n"); if (ldb_dn_is_special(req->op.search.base)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); @@ -999,7 +1028,7 @@ static int local_password_search(struct ldb_module *module, struct ldb_request * search_attrs = NULL; /* If the caller is searching for the local passwords directly, let them pass */ - if (ldb_dn_compare_base(ldb_dn_new(req, module->ldb, LOCAL_BASE), + if (ldb_dn_compare_base(ldb_dn_new(req, ldb, LOCAL_BASE), req->op.search.base) == 0) { return ldb_next_request(module, req); } @@ -1044,7 +1073,7 @@ static int local_password_search(struct ldb_module *module, struct ldb_request * search_attrs = req->op.search.attrs; } - ret = ldb_build_search_req_ex(&remote_req, module->ldb, ac, + ret = ldb_build_search_req_ex(&remote_req, ldb, ac, req->op.search.base, req->op.search.scope, req->op.search.tree, diff --git a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c index d90c2547a6..607bf054d2 100644 --- a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c @@ -22,9 +22,7 @@ */ #include "includes.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb_private.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" @@ -33,6 +31,7 @@ static int naming_fsmo_init(struct ldb_module *module) { + struct ldb_context *ldb; TALLOC_CTX *mem_ctx; struct ldb_dn *naming_dn; struct dsdb_naming_fsmo *naming_fsmo; @@ -43,15 +42,17 @@ static int naming_fsmo_init(struct ldb_module *module) NULL }; + ldb = ldb_module_get_ctx(module); + mem_ctx = talloc_new(module); if (!mem_ctx) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - naming_dn = samdb_partitions_dn(module->ldb, mem_ctx); + naming_dn = samdb_partitions_dn(ldb, mem_ctx); if (!naming_dn) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "naming_fsmo_init: no partitions dn present: (skip loading of naming contexts details)\n"); talloc_free(mem_ctx); return ldb_next_init(module); @@ -59,55 +60,55 @@ static int naming_fsmo_init(struct ldb_module *module) naming_fsmo = talloc_zero(mem_ctx, struct dsdb_naming_fsmo); if (!naming_fsmo) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - module->private_data = naming_fsmo; + ldb_module_set_private(module, naming_fsmo); - ret = ldb_search(module->ldb, mem_ctx, &naming_res, + ret = ldb_search(ldb, mem_ctx, &naming_res, naming_dn, LDB_SCOPE_BASE, naming_attrs, NULL); if (ret == LDB_ERR_NO_SUCH_OBJECT) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "naming_fsmo_init: no partitions dn present: (skip loading of naming contexts details)\n"); talloc_free(mem_ctx); return ldb_next_init(module); } if (ret != LDB_SUCCESS) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "naming_fsmo_init: failed to search the cross-ref container: %s: %s", - ldb_strerror(ret), ldb_errstring(module->ldb)); + ldb_strerror(ret), ldb_errstring(ldb)); talloc_free(mem_ctx); return ret; } if (naming_res->count == 0) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "naming_fsmo_init: no cross-ref container present: (skip loading of naming contexts details)\n"); talloc_free(mem_ctx); return ldb_next_init(module); } else if (naming_res->count > 1) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "naming_fsmo_init: [%u] cross-ref containers found on a base search", naming_res->count); talloc_free(mem_ctx); return LDB_ERR_CONSTRAINT_VIOLATION; } - naming_fsmo->master_dn = ldb_msg_find_attr_as_dn(module->ldb, naming_fsmo, naming_res->msgs[0], "fSMORoleOwner"); - if (ldb_dn_compare(samdb_ntds_settings_dn(module->ldb), naming_fsmo->master_dn) == 0) { + naming_fsmo->master_dn = ldb_msg_find_attr_as_dn(ldb, naming_fsmo, naming_res->msgs[0], "fSMORoleOwner"); + if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), naming_fsmo->master_dn) == 0) { naming_fsmo->we_are_master = true; } else { naming_fsmo->we_are_master = false; } - if (ldb_set_opaque(module->ldb, "dsdb_naming_fsmo", naming_fsmo) != LDB_SUCCESS) { - ldb_oom(module->ldb); + if (ldb_set_opaque(ldb, "dsdb_naming_fsmo", naming_fsmo) != LDB_SUCCESS) { + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } talloc_steal(module, naming_fsmo); - ldb_debug(module->ldb, LDB_DEBUG_TRACE, + ldb_debug(ldb, LDB_DEBUG_TRACE, "naming_fsmo_init: we are master: %s\n", (naming_fsmo->we_are_master?"yes":"no")); diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c index 1d240a33fe..0261bb32e9 100644 --- a/source4/dsdb/samdb/ldb_modules/objectclass.c +++ b/source4/dsdb/samdb/ldb_modules/objectclass.c @@ -34,11 +34,8 @@ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb_private.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" -#include "../lib/util/dlinklist.h" #include "librpc/ndr/libndr.h" #include "librpc/gen_ndr/ndr_security.h" #include "libcli/security/security.h" @@ -63,11 +60,14 @@ struct class_list { static struct oc_context *oc_init_context(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct oc_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct oc_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return NULL; } @@ -89,11 +89,14 @@ static int objectclass_sort(struct ldb_module *module, struct ldb_message_element *objectclass_element, struct class_list **sorted_out) { + struct ldb_context *ldb; int i; int layer; struct class_list *sorted = NULL, *parent_class = NULL, *subclass = NULL, *unsorted = NULL, *current, *poss_subclass, *poss_parent, *new_parent; + ldb = ldb_module_get_ctx(module); + /* DESIGN: * * We work on 4 different 'bins' (implemented here as linked lists): @@ -127,12 +130,12 @@ static int objectclass_sort(struct ldb_module *module, for (i=0; i < objectclass_element->num_values; i++) { current = talloc(mem_ctx, struct class_list); if (!current) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } current->objectclass = dsdb_class_by_lDAPDisplayName(schema, (const char *)objectclass_element->values[i].data); if (!current->objectclass) { - ldb_asprintf_errstring(module->ldb, "objectclass %s is not a valid objectClass in schema", (const char *)objectclass_element->values[i].data); + ldb_asprintf_errstring(ldb, "objectclass %s is not a valid objectClass in schema", (const char *)objectclass_element->values[i].data); return LDB_ERR_OBJECT_CLASS_VIOLATION; } @@ -222,19 +225,20 @@ static int objectclass_sort(struct ldb_module *module, * was no 'top', a conflict in the objectClasses or some other * schema error? */ - ldb_asprintf_errstring(module->ldb, "objectclass %s is not a valid objectClass in objectClass chain", unsorted->objectclass->lDAPDisplayName); + ldb_asprintf_errstring(ldb, "objectclass %s is not a valid objectClass in objectClass chain", unsorted->objectclass->lDAPDisplayName); return LDB_ERR_OBJECT_CLASS_VIOLATION; } static DATA_BLOB *get_sd(struct ldb_module *module, TALLOC_CTX *mem_ctx, const struct dsdb_class *objectclass) { + struct ldb_context *ldb = ldb_module_get_ctx(module); enum ndr_err_code ndr_err; DATA_BLOB *linear_sd; struct auth_session_info *session_info - = ldb_get_opaque(module->ldb, "sessionInfo"); + = ldb_get_opaque(ldb, "sessionInfo"); struct security_descriptor *sd; - const struct dom_sid *domain_sid = samdb_domain_sid(module->ldb); + const struct dom_sid *domain_sid = samdb_domain_sid(ldb); if (!objectclass->defaultSecurityDescriptor || !domain_sid) { return NULL; @@ -257,7 +261,7 @@ static DATA_BLOB *get_sd(struct ldb_module *module, TALLOC_CTX *mem_ctx, } ndr_err = ndr_push_struct_blob(linear_sd, mem_ctx, - lp_iconv_convenience(ldb_get_opaque(module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), sd, (ndr_push_flags_fn_t)ndr_push_security_descriptor); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -270,10 +274,12 @@ static DATA_BLOB *get_sd(struct ldb_module *module, TALLOC_CTX *mem_ctx, static int get_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct oc_context *ac; int ret; ac = talloc_get_type(req->context, struct oc_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -288,7 +294,7 @@ static int get_search_callback(struct ldb_request *req, struct ldb_reply *ares) switch (ares->type) { case LDB_REPLY_ENTRY: if (ac->search_res != NULL) { - ldb_set_errstring(ac->module->ldb, "Too many results"); + ldb_set_errstring(ldb, "Too many results"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -402,12 +408,15 @@ static int objectclass_do_add(struct oc_context *ac); static int objectclass_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_request *search_req; struct oc_context *ac; struct ldb_dn *parent_dn; int ret; - - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectclass_add\n"); + + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "objectclass_add\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.add.message->dn)) { @@ -433,11 +442,11 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req) /* get copy of parent DN */ parent_dn = ldb_dn_get_parent(ac, ac->req->op.add.message->dn); if (parent_dn == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&search_req, module->ldb, + ret = ldb_build_search_req(&search_req, ldb, ac, parent_dn, LDB_SCOPE_BASE, "(objectClass=*)", NULL, NULL, @@ -455,6 +464,7 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req) static int objectclass_do_add(struct oc_context *ac) { + struct ldb_context *ldb; const struct dsdb_schema *schema; struct ldb_request *add_req; char *value; @@ -464,7 +474,8 @@ static int objectclass_do_add(struct oc_context *ac) struct class_list *sorted, *current; int ret; - schema = dsdb_get_schema(ac->module->ldb); + ldb = ldb_module_get_ctx(ac->module); + schema = dsdb_get_schema(ldb); mem_ctx = talloc_new(ac); if (mem_ctx == NULL) { @@ -475,14 +486,14 @@ static int objectclass_do_add(struct oc_context *ac) /* Check we have a valid parent */ if (ac->search_res == NULL) { - if (ldb_dn_compare(ldb_get_root_basedn(ac->module->ldb), + if (ldb_dn_compare(ldb_get_root_basedn(ldb), msg->dn) == 0) { /* Allow the tree to be started */ /* but don't keep any error string, it's meaningless */ - ldb_set_errstring(ac->module->ldb, NULL); + ldb_set_errstring(ldb, NULL); } else { - ldb_asprintf_errstring(ac->module->ldb, "objectclass: Cannot add %s, parent does not exist!", + ldb_asprintf_errstring(ldb, "objectclass: Cannot add %s, parent does not exist!", ldb_dn_get_linearized(msg->dn)); talloc_free(mem_ctx); return LDB_ERR_UNWILLING_TO_PERFORM; @@ -496,7 +507,7 @@ static int objectclass_do_add(struct oc_context *ac) &msg->dn); if (ret != LDB_SUCCESS) { - ldb_asprintf_errstring(ac->module->ldb, "Could not munge DN %s into normal form", + ldb_asprintf_errstring(ldb, "Could not munge DN %s into normal form", ldb_dn_get_linearized(ac->req->op.add.message->dn)); talloc_free(mem_ctx); return ret; @@ -509,7 +520,7 @@ static int objectclass_do_add(struct oc_context *ac) } if (schema) { - ret = fix_attributes(ac->module->ldb, schema, msg); + ret = fix_attributes(ldb, schema, msg); if (ret != LDB_SUCCESS) { talloc_free(mem_ctx); return ret; @@ -544,13 +555,13 @@ static int objectclass_do_add(struct oc_context *ac) for (current = sorted; current; current = current->next) { value = talloc_strdup(msg, current->objectclass->lDAPDisplayName); if (value == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } ret = ldb_msg_add_string(msg, "objectClass", value); if (ret != LDB_SUCCESS) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "objectclass: could not re-add sorted " "objectclass to modify msg"); talloc_free(mem_ctx); @@ -563,7 +574,7 @@ static int objectclass_do_add(struct oc_context *ac) if (!ldb_msg_find_element(msg, "objectCategory")) { value = talloc_strdup(msg, current->objectclass->defaultObjectCategory); if (value == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } @@ -612,21 +623,21 @@ static int objectclass_do_add(struct oc_context *ac) /* TODO: If parent object is site or subnet, also add (SYSTEM_FLAG_CONFIG_ALLOW_RENAME) */ if (el || systemFlags != 0) { - samdb_msg_add_int(ac->module->ldb, msg, msg, "systemFlags", systemFlags); + samdb_msg_add_int(ldb, msg, msg, "systemFlags", systemFlags); } } } } talloc_free(mem_ctx); - ret = ldb_msg_sanity_check(ac->module->ldb, msg); + ret = ldb_msg_sanity_check(ldb, msg); if (ret != LDB_SUCCESS) { return ret; } - ret = ldb_build_add_req(&add_req, ac->module->ldb, ac, + ret = ldb_build_add_req(&add_req, ldb, ac, msg, ac->req->controls, ac, oc_op_callback, @@ -645,9 +656,10 @@ static int objectclass_do_mod(struct oc_context *ac); static int objectclass_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb = ldb_module_get_ctx(module); struct ldb_message_element *objectclass_element; struct ldb_message *msg; - const struct dsdb_schema *schema = dsdb_get_schema(module->ldb); + const struct dsdb_schema *schema = dsdb_get_schema(ldb); struct class_list *sorted, *current; struct ldb_request *down_req; struct oc_context *ac; @@ -655,7 +667,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req char *value; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectclass_modify\n"); + ldb_debug(ldb, LDB_DEBUG_TRACE, "objectclass_modify\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.mod.message->dn)) { @@ -684,12 +696,12 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req return LDB_ERR_OPERATIONS_ERROR; } - ret = fix_attributes(module->ldb, schema, msg); + ret = fix_attributes(ldb, schema, msg); if (ret != LDB_SUCCESS) { return ret; } - ret = ldb_build_mod_req(&down_req, module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, msg, req->controls, ac, oc_op_callback, @@ -721,7 +733,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req return LDB_ERR_OPERATIONS_ERROR; } - ret = fix_attributes(module->ldb, schema, msg); + ret = fix_attributes(ldb, schema, msg); if (ret != LDB_SUCCESS) { talloc_free(mem_ctx); return ret; @@ -752,13 +764,13 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req value = talloc_strdup(msg, current->objectclass->lDAPDisplayName); if (value == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } ret = ldb_msg_add_string(msg, "objectClass", value); if (ret != LDB_SUCCESS) { - ldb_set_errstring(module->ldb, + ldb_set_errstring(ldb, "objectclass: could not re-add sorted " "objectclass to modify msg"); talloc_free(mem_ctx); @@ -768,12 +780,12 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req talloc_free(mem_ctx); - ret = ldb_msg_sanity_check(module->ldb, msg); + ret = ldb_msg_sanity_check(ldb, msg); if (ret != LDB_SUCCESS) { return ret; } - ret = ldb_build_mod_req(&down_req, module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, msg, req->controls, ac, oc_op_callback, @@ -793,17 +805,17 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req msg = ldb_msg_copy_shallow(ac, req->op.mod.message); if (msg == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = fix_attributes(module->ldb, schema, msg); + ret = fix_attributes(ldb, schema, msg); if (ret != LDB_SUCCESS) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ret; } - ret = ldb_build_mod_req(&down_req, module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, msg, req->controls, ac, oc_modify_callback, @@ -817,12 +829,14 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req static int oc_modify_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; static const char * const attrs[] = { "objectClass", NULL }; struct ldb_request *search_req; struct oc_context *ac; int ret; ac = talloc_get_type(req->context, struct oc_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -839,7 +853,7 @@ static int oc_modify_callback(struct ldb_request *req, struct ldb_reply *ares) LDB_ERR_OPERATIONS_ERROR); } - ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ret = ldb_build_search_req(&search_req, ldb, ac, ac->req->op.mod.message->dn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, NULL, @@ -860,7 +874,7 @@ static int oc_modify_callback(struct ldb_request *req, struct ldb_reply *ares) static int objectclass_do_mod(struct oc_context *ac) { - + struct ldb_context *ldb; const struct dsdb_schema *schema; struct ldb_request *mod_req; char *value; @@ -870,10 +884,12 @@ static int objectclass_do_mod(struct oc_context *ac) struct class_list *sorted, *current; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (ac->search_res == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - schema = dsdb_get_schema(ac->module->ldb); + schema = dsdb_get_schema(ldb); mem_ctx = talloc_new(ac); if (mem_ctx == NULL) { @@ -883,7 +899,7 @@ static int objectclass_do_mod(struct oc_context *ac) /* use a new message structure */ msg = ldb_msg_new(ac); if (msg == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "objectclass: could not create new modify msg"); talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; @@ -912,7 +928,7 @@ static int objectclass_do_mod(struct oc_context *ac) ret = ldb_msg_add_empty(msg, "objectClass", LDB_FLAG_MOD_REPLACE, NULL); if (ret != LDB_SUCCESS) { - ldb_set_errstring(ac->module->ldb, "objectclass: could not clear objectclass in modify msg"); + ldb_set_errstring(ldb, "objectclass: could not clear objectclass in modify msg"); talloc_free(mem_ctx); return ret; } @@ -921,24 +937,24 @@ static int objectclass_do_mod(struct oc_context *ac) for (current = sorted; current; current = current->next) { value = talloc_strdup(msg, current->objectclass->lDAPDisplayName); if (value == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } ret = ldb_msg_add_string(msg, "objectClass", value); if (ret != LDB_SUCCESS) { - ldb_set_errstring(ac->module->ldb, "objectclass: could not re-add sorted objectclass to modify msg"); + ldb_set_errstring(ldb, "objectclass: could not re-add sorted objectclass to modify msg"); talloc_free(mem_ctx); return ret; } } - ret = ldb_msg_sanity_check(ac->module->ldb, msg); + ret = ldb_msg_sanity_check(ldb, msg); if (ret != LDB_SUCCESS) { talloc_free(mem_ctx); return ret; } - ret = ldb_build_mod_req(&mod_req, ac->module->ldb, ac, + ret = ldb_build_mod_req(&mod_req, ldb, ac, msg, ac->req->controls, ac, oc_op_callback, @@ -958,13 +974,15 @@ static int objectclass_do_rename(struct oc_context *ac); static int objectclass_rename(struct ldb_module *module, struct ldb_request *req) { static const char * const attrs[] = { NULL }; - + struct ldb_context *ldb; struct ldb_request *search_req; struct oc_context *ac; struct ldb_dn *parent_dn; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectclass_rename\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "objectclass_rename\n"); if (ldb_dn_is_special(req->op.rename.newdn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); @@ -973,7 +991,7 @@ static int objectclass_rename(struct ldb_module *module, struct ldb_request *req /* Firstly ensure we are not trying to rename it to be a child of itself */ if ((ldb_dn_compare_base(req->op.rename.olddn, req->op.rename.newdn) == 0) && (ldb_dn_compare(req->op.rename.olddn, req->op.rename.newdn) != 0)) { - ldb_asprintf_errstring(module->ldb, "Cannot rename %s to be a child of itself", + ldb_asprintf_errstring(ldb, "Cannot rename %s to be a child of itself", ldb_dn_get_linearized(req->op.rename.olddn)); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -985,10 +1003,10 @@ static int objectclass_rename(struct ldb_module *module, struct ldb_request *req parent_dn = ldb_dn_get_parent(ac, req->op.rename.newdn); if (parent_dn == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&search_req, module->ldb, + ret = ldb_build_search_req(&search_req, ldb, ac, parent_dn, LDB_SCOPE_BASE, "(objectClass=*)", attrs, NULL, @@ -1005,13 +1023,16 @@ static int objectclass_rename(struct ldb_module *module, struct ldb_request *req static int objectclass_do_rename(struct oc_context *ac) { + struct ldb_context *ldb; struct ldb_request *rename_req; struct ldb_dn *fixed_dn; int ret; + ldb = ldb_module_get_ctx(ac->module); + /* Check we have a valid parent */ if (ac->search_res == NULL) { - ldb_asprintf_errstring(ac->module->ldb, "objectclass: Cannot rename %s, parent does not exist!", + ldb_asprintf_errstring(ldb, "objectclass: Cannot rename %s, parent does not exist!", ldb_dn_get_linearized(ac->req->op.rename.newdn)); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -1030,7 +1051,7 @@ static int objectclass_do_rename(struct oc_context *ac) * by reading the allowedChildClasses and * allowedChildClasssesEffective attributes */ - ret = ldb_build_rename_req(&rename_req, ac->module->ldb, ac, + ret = ldb_build_rename_req(&rename_req, ldb, ac, ac->req->op.rename.olddn, fixed_dn, ac->req->controls, ac, oc_op_callback, diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c index 1707baba58..2c07fa1be6 100644 --- a/source4/dsdb/samdb/ldb_modules/password_hash.c +++ b/source4/dsdb/samdb/ldb_modules/password_hash.c @@ -33,9 +33,7 @@ #include "includes.h" #include "libcli/ldap/ldap_ndr.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_private.h" +#include "ldb_module.h" #include "librpc/gen_ndr/misc.h" #include "librpc/gen_ndr/samr.h" #include "libcli/auth/libcli_auth.h" @@ -150,9 +148,11 @@ struct setup_password_fields_io { static int setup_nt_fields(struct setup_password_fields_io *io) { + struct ldb_context *ldb; uint32_t i; io->g.nt_hash = io->n.nt_hash; + ldb = ldb_module_get_ctx(io->ac->module); if (io->domain->pwdHistoryLength == 0) { return LDB_SUCCESS; @@ -163,7 +163,7 @@ static int setup_nt_fields(struct setup_password_fields_io *io) struct samr_Password, io->domain->pwdHistoryLength); if (!io->g.nt_history) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -190,9 +190,11 @@ static int setup_nt_fields(struct setup_password_fields_io *io) static int setup_lm_fields(struct setup_password_fields_io *io) { + struct ldb_context *ldb; uint32_t i; io->g.lm_hash = io->n.lm_hash; + ldb = ldb_module_get_ctx(io->ac->module); if (io->domain->pwdHistoryLength == 0) { return LDB_SUCCESS; @@ -203,7 +205,7 @@ static int setup_lm_fields(struct setup_password_fields_io *io) struct samr_Password, io->domain->pwdHistoryLength); if (!io->g.lm_history) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -223,12 +225,14 @@ static int setup_lm_fields(struct setup_password_fields_io *io) static int setup_kerberos_keys(struct setup_password_fields_io *io) { + struct ldb_context *ldb; krb5_error_code krb5_ret; Principal *salt_principal; krb5_salt salt; krb5_keyblock key; krb5_data cleartext_data; + ldb = ldb_module_get_ctx(io->ac->module); cleartext_data.data = io->n.cleartext_utf8->data; cleartext_data.length = io->n.cleartext_utf8->length; @@ -245,7 +249,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) name = talloc_strdup(io->ac, io->u.sAMAccountName); if (!name) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -255,7 +259,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) saltbody = talloc_asprintf(io->ac, "%s.%s", name, io->domain->dns_domain); if (!saltbody) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -269,7 +273,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) user_principal_name = talloc_strdup(io->ac, io->u.user_principal_name); if (!user_principal_name) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -289,7 +293,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) NULL); } if (krb5_ret) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_kerberos_keys: " "generation of a salting principal failed: %s", smb_get_krb5_error_message(io->smb_krb5_context->krb5_context, krb5_ret, io->ac)); @@ -303,7 +307,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) salt_principal, &salt); krb5_free_principal(io->smb_krb5_context->krb5_context, salt_principal); if (krb5_ret) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_kerberos_keys: " "generation of krb5_salt failed: %s", smb_get_krb5_error_message(io->smb_krb5_context->krb5_context, krb5_ret, io->ac)); @@ -315,7 +319,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) salt.saltvalue.length); krb5_free_salt(io->smb_krb5_context->krb5_context, salt); if (!io->g.salt) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } salt.saltvalue.data = discard_const(io->g.salt); @@ -331,7 +335,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) salt, &key); if (krb5_ret) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_kerberos_keys: " "generation of a aes256-cts-hmac-sha1-96 key failed: %s", smb_get_krb5_error_message(io->smb_krb5_context->krb5_context, krb5_ret, io->ac)); @@ -342,7 +346,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) key.keyvalue.length); krb5_free_keyblock_contents(io->smb_krb5_context->krb5_context, &key); if (!io->g.aes_256.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -356,7 +360,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) salt, &key); if (krb5_ret) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_kerberos_keys: " "generation of a aes128-cts-hmac-sha1-96 key failed: %s", smb_get_krb5_error_message(io->smb_krb5_context->krb5_context, krb5_ret, io->ac)); @@ -367,7 +371,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) key.keyvalue.length); krb5_free_keyblock_contents(io->smb_krb5_context->krb5_context, &key); if (!io->g.aes_128.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -381,7 +385,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) salt, &key); if (krb5_ret) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_kerberos_keys: " "generation of a des-cbc-md5 key failed: %s", smb_get_krb5_error_message(io->smb_krb5_context->krb5_context, krb5_ret, io->ac)); @@ -392,7 +396,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) key.keyvalue.length); krb5_free_keyblock_contents(io->smb_krb5_context->krb5_context, &key); if (!io->g.des_md5.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -406,7 +410,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) salt, &key); if (krb5_ret) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_kerberos_keys: " "generation of a des-cbc-crc key failed: %s", smb_get_krb5_error_message(io->smb_krb5_context->krb5_context, krb5_ret, io->ac)); @@ -417,7 +421,7 @@ static int setup_kerberos_keys(struct setup_password_fields_io *io) key.keyvalue.length); krb5_free_keyblock_contents(io->smb_krb5_context->krb5_context, &key); if (!io->g.des_crc.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -428,6 +432,7 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io, const struct supplementalCredentialsBlob *old_scb, struct package_PrimaryKerberosBlob *pkb) { + struct ldb_context *ldb; struct package_PrimaryKerberosCtr3 *pkb3 = &pkb->ctr.ctr3; struct supplementalCredentialsPackage *old_scp = NULL; struct package_PrimaryKerberosBlob _old_pkb; @@ -435,6 +440,8 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io, uint32_t i; enum ndr_err_code ndr_err; + ldb = ldb_module_get_ctx(io->ac->module); + /* * prepare generation of keys * @@ -448,7 +455,7 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io, struct package_PrimaryKerberosKey3, pkb3->num_keys); if (!pkb3->keys) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -484,16 +491,16 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io, blob = strhex_to_data_blob(io->ac, old_scp->data); if (!blob.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } /* TODO: use ndr_pull_struct_blob_all(), when the ndr layer handles it correct with relative pointers */ - ndr_err = ndr_pull_struct_blob(&blob, io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), &_old_pkb, + ndr_err = ndr_pull_struct_blob(&blob, io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &_old_pkb, (ndr_pull_flags_fn_t)ndr_pull_package_PrimaryKerberosBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_primary_kerberos: " "failed to pull old package_PrimaryKerberosBlob: %s", nt_errstr(status)); @@ -501,7 +508,7 @@ static int setup_primary_kerberos(struct setup_password_fields_io *io, } if (_old_pkb.version != 3) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_primary_kerberos: " "package_PrimaryKerberosBlob version[%u] expected[3]", _old_pkb.version); @@ -527,6 +534,7 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io, const struct supplementalCredentialsBlob *old_scb, struct package_PrimaryKerberosBlob *pkb) { + struct ldb_context *ldb; struct package_PrimaryKerberosCtr4 *pkb4 = &pkb->ctr.ctr4; struct supplementalCredentialsPackage *old_scp = NULL; struct package_PrimaryKerberosBlob _old_pkb; @@ -534,6 +542,8 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io, uint32_t i; enum ndr_err_code ndr_err; + ldb = ldb_module_get_ctx(io->ac->module); + /* * prepare generation of keys * @@ -551,7 +561,7 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io, struct package_PrimaryKerberosKey4, pkb4->num_keys); if (!pkb4->keys) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -597,18 +607,18 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io, blob = strhex_to_data_blob(io->ac, old_scp->data); if (!blob.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } /* TODO: use ndr_pull_struct_blob_all(), when the ndr layer handles it correct with relative pointers */ ndr_err = ndr_pull_struct_blob(&blob, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &_old_pkb, (ndr_pull_flags_fn_t)ndr_pull_package_PrimaryKerberosBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_primary_kerberos_newer: " "failed to pull old package_PrimaryKerberosBlob: %s", nt_errstr(status)); @@ -616,7 +626,7 @@ static int setup_primary_kerberos_newer(struct setup_password_fields_io *io, } if (_old_pkb.version != 4) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_primary_kerberos_newer: " "package_PrimaryKerberosBlob version[%u] expected[4]", _old_pkb.version); @@ -644,6 +654,7 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, const struct supplementalCredentialsBlob *old_scb, struct package_PrimaryWDigestBlob *pdb) { + struct ldb_context *ldb = ldb_module_get_ctx(io->ac->module); DATA_BLOB sAMAccountName; DATA_BLOB sAMAccountName_l; DATA_BLOB sAMAccountName_u; @@ -890,12 +901,12 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, sAMAccountName = data_blob_string_const(io->u.sAMAccountName); sAMAccountName_l = data_blob_string_const(strlower_talloc(io->ac, io->u.sAMAccountName)); if (!sAMAccountName_l.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } sAMAccountName_u = data_blob_string_const(strupper_talloc(io->ac, io->u.sAMAccountName)); if (!sAMAccountName_u.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -905,31 +916,31 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, io->u.sAMAccountName, io->domain->dns_domain); if (!user_principal_name) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } } userPrincipalName = data_blob_string_const(user_principal_name); userPrincipalName_l = data_blob_string_const(strlower_talloc(io->ac, user_principal_name)); if (!userPrincipalName_l.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } userPrincipalName_u = data_blob_string_const(strupper_talloc(io->ac, user_principal_name)); if (!userPrincipalName_u.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } netbios_domain = data_blob_string_const(io->domain->netbios_domain); netbios_domain_l = data_blob_string_const(strlower_talloc(io->ac, io->domain->netbios_domain)); if (!netbios_domain_l.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } netbios_domain_u = data_blob_string_const(strupper_talloc(io->ac, io->domain->netbios_domain)); if (!netbios_domain_u.data) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -945,7 +956,7 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, pdb->num_hashes = ARRAY_SIZE(wdigest); pdb->hashes = talloc_array(io->ac, struct package_PrimaryWDigestHash, pdb->num_hashes); if (!pdb->hashes) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -971,6 +982,7 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io, static int setup_supplemental_field(struct setup_password_fields_io *io) { + struct ldb_context *ldb; struct supplementalCredentialsBlob scb; struct supplementalCredentialsBlob _old_scb; struct supplementalCredentialsBlob *old_scb = NULL; @@ -1017,6 +1029,8 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) ZERO_STRUCT(zero16); ZERO_STRUCT(names); + ldb = ldb_module_get_ctx(io->ac->module); + if (!io->n.cleartext_utf8) { /* * when we don't have a cleartext password @@ -1028,12 +1042,12 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) /* if there's an old supplementaCredentials blob then parse it */ if (io->o.supplemental) { ndr_err = ndr_pull_struct_blob_all(io->o.supplemental, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &_old_scb, (ndr_pull_flags_fn_t)ndr_pull_supplementalCredentialsBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_supplemental_field: " "failed to pull old supplementalCredentialsBlob: %s", nt_errstr(status)); @@ -1043,7 +1057,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) if (_old_scb.sub.signature == SUPPLEMENTAL_CREDENTIALS_SIGNATURE) { old_scb = &_old_scb; } else { - ldb_debug(io->ac->module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "setup_supplemental_field: " "supplementalCredentialsBlob signature[0x%04X] expected[0x%04X]", _old_scb.sub.signature, SUPPLEMENTAL_CREDENTIALS_SIGNATURE); @@ -1051,7 +1065,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } /* TODO: do the correct check for this, it maybe depends on the functional level? */ - do_newer_keys = lp_parm_bool(ldb_get_opaque(io->ac->module->ldb, "loadparm"), + do_newer_keys = lp_parm_bool(ldb_get_opaque(ldb, "loadparm"), NULL, "password_hash", "create_aes_key", false); if (io->domain->store_cleartext && @@ -1110,12 +1124,12 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } ndr_err = ndr_push_struct_blob(&pknb_blob, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &pknb, (ndr_push_flags_fn_t)ndr_push_package_PrimaryKerberosBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_supplemental_field: " "failed to push package_PrimaryKerberosNeverBlob: %s", nt_errstr(status)); @@ -1123,7 +1137,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pknb_hexstr = data_blob_hex_string(io->ac, &pknb_blob); if (!pknb_hexstr) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } pkn->name = "Primary:Kerberos-Newer-Keys"; @@ -1142,12 +1156,12 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } ndr_err = ndr_push_struct_blob(&pkb_blob, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &pkb, (ndr_push_flags_fn_t)ndr_push_package_PrimaryKerberosBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_supplemental_field: " "failed to push package_PrimaryKerberosBlob: %s", nt_errstr(status)); @@ -1155,7 +1169,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pkb_hexstr = data_blob_hex_string(io->ac, &pkb_blob); if (!pkb_hexstr) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } pk->name = "Primary:Kerberos"; @@ -1173,12 +1187,12 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } ndr_err = ndr_push_struct_blob(&pdb_blob, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &pdb, (ndr_push_flags_fn_t)ndr_push_package_PrimaryWDigestBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_supplemental_field: " "failed to push package_PrimaryWDigestBlob: %s", nt_errstr(status)); @@ -1186,7 +1200,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pdb_hexstr = data_blob_hex_string(io->ac, &pdb_blob); if (!pdb_hexstr) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } pd->name = "Primary:WDigest"; @@ -1202,12 +1216,12 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) pcb.cleartext = *io->n.cleartext_utf16; ndr_err = ndr_push_struct_blob(&pcb_blob, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &pcb, (ndr_push_flags_fn_t)ndr_push_package_PrimaryCLEARTEXTBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_supplemental_field: " "failed to push package_PrimaryCLEARTEXTBlob: %s", nt_errstr(status)); @@ -1215,7 +1229,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pcb_hexstr = data_blob_hex_string(io->ac, &pcb_blob); if (!pcb_hexstr) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } pc->name = "Primary:CLEARTEXT"; @@ -1228,12 +1242,12 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) */ pb.names = names; ndr_err = ndr_push_struct_blob(&pb_blob, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &pb, (ndr_push_flags_fn_t)ndr_push_package_PackagesBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_supplemental_field: " "failed to push package_PackagesBlob: %s", nt_errstr(status)); @@ -1241,7 +1255,7 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) } pb_hexstr = data_blob_hex_string(io->ac, &pb_blob); if (!pb_hexstr) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } pp->name = "Packages"; @@ -1256,12 +1270,12 @@ static int setup_supplemental_field(struct setup_password_fields_io *io) scb.sub.packages = packages; ndr_err = ndr_push_struct_blob(&io->g.supplemental, io->ac, - lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &scb, (ndr_push_flags_fn_t)ndr_push_supplementalCredentialsBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS status = ndr_map_error2ntstatus(ndr_err); - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_supplemental_field: " "failed to push supplementalCredentialsBlob: %s", nt_errstr(status)); @@ -1289,23 +1303,26 @@ static int setup_kvno_field(struct setup_password_fields_io *io) static int setup_password_fields(struct setup_password_fields_io *io) { + struct ldb_context *ldb; bool ok; int ret; ssize_t converted_pw_len; - + + ldb = ldb_module_get_ctx(io->ac->module); + /* * refuse the change if someone want to change the cleartext * and supply his own hashes at the same time... */ if ((io->n.cleartext_utf8 || io->n.cleartext_utf16) && (io->n.nt_hash || io->n.lm_hash)) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_password_fields: " "it's only allowed to set the cleartext password or the password hashes"); return LDB_ERR_UNWILLING_TO_PERFORM; } if (io->n.cleartext_utf8 && io->n.cleartext_utf16) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_password_fields: " "it's only allowed to set the cleartext password as userPassword or clearTextPasssword, not both at once"); return LDB_ERR_UNWILLING_TO_PERFORM; @@ -1316,14 +1333,14 @@ static int setup_password_fields(struct setup_password_fields_io *io) struct ldb_val *cleartext_utf16_blob; io->n.cleartext_utf16 = cleartext_utf16_blob = talloc(io->ac, struct ldb_val); if (!io->n.cleartext_utf16) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), CH_UTF8, CH_UTF16, io->n.cleartext_utf8->data, io->n.cleartext_utf8->length, (void **)&cleartext_utf16_str); if (converted_pw_len == -1) { - ldb_asprintf_errstring(io->ac->module->ldb, + ldb_asprintf_errstring(ldb, "setup_password_fields: " "failed to generate UTF16 password from cleartext UTF8 password"); return LDB_ERR_OPERATIONS_ERROR; @@ -1334,10 +1351,10 @@ static int setup_password_fields(struct setup_password_fields_io *io) struct ldb_val *cleartext_utf8_blob; io->n.cleartext_utf8 = cleartext_utf8_blob = talloc(io->ac, struct ldb_val); if (!io->n.cleartext_utf8) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), CH_UTF16MUNGED, CH_UTF8, io->n.cleartext_utf16->data, io->n.cleartext_utf16->length, (void **)&cleartext_utf8_str); if (converted_pw_len == -1) { @@ -1351,7 +1368,7 @@ static int setup_password_fields(struct setup_password_fields_io *io) struct samr_Password *nt_hash; nt_hash = talloc(io->ac, struct samr_Password); if (!nt_hash) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } io->n.nt_hash = nt_hash; @@ -1363,13 +1380,13 @@ static int setup_password_fields(struct setup_password_fields_io *io) if (io->n.cleartext_utf8) { struct samr_Password *lm_hash; char *cleartext_unix; - converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(io->ac->module->ldb, "loadparm")), + converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), CH_UTF8, CH_UNIX, io->n.cleartext_utf8->data, io->n.cleartext_utf8->length, (void **)&cleartext_unix); if (converted_pw_len != -1) { lm_hash = talloc(io->ac, struct samr_Password); if (!lm_hash) { - ldb_oom(io->ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -1419,11 +1436,14 @@ static int setup_password_fields(struct setup_password_fields_io *io) static struct ph_context *ph_init_context(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ph_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct ph_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return NULL; } @@ -1467,6 +1487,7 @@ static int password_hash_mod_do_mod(struct ph_context *ac); static int get_domain_data_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct domain_data *data; struct ph_context *ac; int ret; @@ -1474,6 +1495,7 @@ static int get_domain_data_callback(struct ldb_request *req, char *p; ac = talloc_get_type(req->context, struct ph_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -1487,7 +1509,7 @@ static int get_domain_data_callback(struct ldb_request *req, switch (ares->type) { case LDB_REPLY_ENTRY: if (ac->domain != NULL) { - ldb_set_errstring(ac->module->ldb, "Too many results"); + ldb_set_errstring(ldb, "Too many results"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -1521,13 +1543,13 @@ static int get_domain_data_callback(struct ldb_request *req, data->dns_domain = strlower_talloc(data, tmp); if (data->dns_domain == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } data->realm = strupper_talloc(data, tmp); if (data->realm == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -1538,7 +1560,7 @@ static int get_domain_data_callback(struct ldb_request *req, } data->netbios_domain = strupper_talloc(data, tmp); if (data->netbios_domain == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -1581,19 +1603,22 @@ static int build_domain_data_request(struct ph_context *ac) /* attrs[] is returned from this function in ac->dom_req->op.search.attrs, so it must be static, as otherwise the compiler can put it on the stack */ + struct ldb_context *ldb; static const char * const attrs[] = { "pwdProperties", "pwdHistoryLength", NULL }; char *filter; + ldb = ldb_module_get_ctx(ac->module); + filter = talloc_asprintf(ac, "(&(objectSid=%s)(|(|(objectClass=domain)(objectClass=builtinDomain))(objectClass=samba4LocalDomain)))", ldap_encode_ndr_dom_sid(ac, ac->domain_sid)); if (filter == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - return ldb_build_search_req(&ac->dom_req, ac->module->ldb, ac, - ldb_get_default_basedn(ac->module->ldb), + return ldb_build_search_req(&ac->dom_req, ldb, ac, + ldb_get_default_basedn(ldb), LDB_SCOPE_SUBTREE, filter, attrs, NULL, @@ -1603,6 +1628,7 @@ static int build_domain_data_request(struct ph_context *ac) static int password_hash_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ph_context *ac; struct ldb_message_element *sambaAttr; struct ldb_message_element *clearTextPasswordAttr; @@ -1610,14 +1636,16 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) struct ldb_message_element *lmAttr; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "password_hash_add\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "password_hash_add\n"); if (ldb_dn_is_special(req->op.add.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); } /* If the caller is manipulating the local passwords directly, let them pass */ - if (ldb_dn_compare_base(ldb_dn_new(req, module->ldb, LOCAL_BASE), + if (ldb_dn_compare_base(ldb_dn_new(req, ldb, LOCAL_BASE), req->op.add.message->dn) == 0) { return ldb_next_request(module, req); } @@ -1648,46 +1676,46 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) /* if it is not an entry of type person its an error */ /* TODO: remove this when userPassword will be in schema */ if (!ldb_msg_check_string_attribute(req->op.add.message, "objectClass", "person")) { - ldb_set_errstring(module->ldb, "Cannot set a password on entry that does not have objectClass 'person'"); + ldb_set_errstring(ldb, "Cannot set a password on entry that does not have objectClass 'person'"); return LDB_ERR_OBJECT_CLASS_VIOLATION; } /* check userPassword is single valued here */ /* TODO: remove this when userPassword will be single valued in schema */ if (sambaAttr && sambaAttr->num_values > 1) { - ldb_set_errstring(module->ldb, "mupltiple values for userPassword not allowed!\n"); + ldb_set_errstring(ldb, "mupltiple values for userPassword not allowed!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } if (clearTextPasswordAttr && clearTextPasswordAttr->num_values > 1) { - ldb_set_errstring(module->ldb, "mupltiple values for clearTextPassword not allowed!\n"); + ldb_set_errstring(ldb, "mupltiple values for clearTextPassword not allowed!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } if (ntAttr && (ntAttr->num_values > 1)) { - ldb_set_errstring(module->ldb, "mupltiple values for unicodePwd not allowed!\n"); + ldb_set_errstring(ldb, "mupltiple values for unicodePwd not allowed!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } if (lmAttr && (lmAttr->num_values > 1)) { - ldb_set_errstring(module->ldb, "mupltiple values for dBCSPwd not allowed!\n"); + ldb_set_errstring(ldb, "mupltiple values for dBCSPwd not allowed!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } if (sambaAttr && sambaAttr->num_values == 0) { - ldb_set_errstring(module->ldb, "userPassword must have a value!\n"); + ldb_set_errstring(ldb, "userPassword must have a value!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } if (clearTextPasswordAttr && clearTextPasswordAttr->num_values == 0) { - ldb_set_errstring(module->ldb, "clearTextPassword must have a value!\n"); + ldb_set_errstring(ldb, "clearTextPassword must have a value!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } if (ntAttr && (ntAttr->num_values == 0)) { - ldb_set_errstring(module->ldb, "unicodePwd must have a value!\n"); + ldb_set_errstring(ldb, "unicodePwd must have a value!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } if (lmAttr && (lmAttr->num_values == 0)) { - ldb_set_errstring(module->ldb, "dBCSPwd must have a value!\n"); + ldb_set_errstring(ldb, "dBCSPwd must have a value!\n"); return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -1699,7 +1727,7 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) /* get user domain data */ ac->domain_sid = samdb_result_sid_prefix(ac, req->op.add.message, "objectSid"); if (ac->domain_sid == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "can't handle entry with missing objectSid!\n"); return LDB_ERR_OPERATIONS_ERROR; } @@ -1712,14 +1740,17 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, ac->dom_req); } -static int password_hash_add_do_add(struct ph_context *ac) { - +static int password_hash_add_do_add(struct ph_context *ac) +{ + struct ldb_context *ldb; struct ldb_request *down_req; struct smb_krb5_context *smb_krb5_context; struct ldb_message *msg; struct setup_password_fields_io io; int ret; + ldb = ldb_module_get_ctx(ac->module); + msg = ldb_msg_copy_shallow(ac, ac->req->op.add.message); if (msg == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -1727,8 +1758,8 @@ static int password_hash_add_do_add(struct ph_context *ac) { /* Some operations below require kerberos contexts */ if (smb_krb5_init_context(ac, - ldb_get_event_context(ac->module->ldb), - (struct loadparm_context *)ldb_get_opaque(ac->module->ldb, "loadparm"), + ldb_get_event_context(ldb), + (struct loadparm_context *)ldb_get_opaque(ldb, "loadparm"), &smb_krb5_context) != 0) { return LDB_ERR_OPERATIONS_ERROR; } @@ -1763,14 +1794,14 @@ static int password_hash_add_do_add(struct ph_context *ac) { } if (io.g.nt_hash) { - ret = samdb_msg_add_hash(ac->module->ldb, ac, msg, + ret = samdb_msg_add_hash(ldb, ac, msg, "unicodePwd", io.g.nt_hash); if (ret != LDB_SUCCESS) { return ret; } } if (io.g.lm_hash) { - ret = samdb_msg_add_hash(ac->module->ldb, ac, msg, + ret = samdb_msg_add_hash(ldb, ac, msg, "dBCSPwd", io.g.lm_hash); if (ret != LDB_SUCCESS) { return ret; @@ -1801,20 +1832,20 @@ static int password_hash_add_do_add(struct ph_context *ac) { return ret; } } - ret = samdb_msg_add_uint64(ac->module->ldb, ac, msg, + ret = samdb_msg_add_uint64(ldb, ac, msg, "pwdLastSet", io.g.last_set); if (ret != LDB_SUCCESS) { return ret; } - ret = samdb_msg_add_uint(ac->module->ldb, ac, msg, + ret = samdb_msg_add_uint(ldb, ac, msg, "msDs-KeyVersionNumber", io.g.kvno); if (ret != LDB_SUCCESS) { return ret; } - ret = ldb_build_add_req(&down_req, ac->module->ldb, ac, + ret = ldb_build_add_req(&down_req, ldb, ac, msg, ac->req->controls, ac, ph_op_callback, @@ -1828,6 +1859,7 @@ static int password_hash_add_do_add(struct ph_context *ac) { static int password_hash_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ph_context *ac; struct ldb_message_element *sambaAttr; struct ldb_message_element *clearTextAttr; @@ -1837,14 +1869,16 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r struct ldb_request *down_req; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "password_hash_modify\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "password_hash_modify\n"); if (ldb_dn_is_special(req->op.mod.message->dn)) { /* do not manipulate our control entries */ return ldb_next_request(module, req); } /* If the caller is manipulating the local passwords directly, let them pass */ - if (ldb_dn_compare_base(ldb_dn_new(req, module->ldb, LOCAL_BASE), + if (ldb_dn_compare_base(ldb_dn_new(req, ldb, LOCAL_BASE), req->op.mod.message->dn) == 0) { return ldb_next_request(module, req); } @@ -1897,7 +1931,7 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r /* use a new message structure so that we can modify it */ msg = ldb_msg_copy_shallow(ac, req->op.mod.message); if (msg == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -1913,7 +1947,7 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r return password_hash_mod_search_self(ac); } - ret = ldb_build_mod_req(&down_req, module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, msg, req->controls, ac, ph_modify_callback, @@ -1958,10 +1992,12 @@ static int ph_modify_callback(struct ldb_request *req, struct ldb_reply *ares) static int ph_mod_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct ph_context *ac; int ret; ac = talloc_get_type(req->context, struct ph_context); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -1977,7 +2013,7 @@ static int ph_mod_search_callback(struct ldb_request *req, struct ldb_reply *are case LDB_REPLY_ENTRY: if (ac->search_res != NULL) { - ldb_set_errstring(ac->module->ldb, "Too many results"); + ldb_set_errstring(ldb, "Too many results"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -1986,7 +2022,7 @@ static int ph_mod_search_callback(struct ldb_request *req, struct ldb_reply *are /* if it is not an entry of type person this is an error */ /* TODO: remove this when sambaPassword will be in schema */ if (!ldb_msg_check_string_attribute(ares->message, "objectClass", "person")) { - ldb_set_errstring(ac->module->ldb, "Object class violation"); + ldb_set_errstring(ldb, "Object class violation"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OBJECT_CLASS_VIOLATION); @@ -2002,7 +2038,7 @@ static int ph_mod_search_callback(struct ldb_request *req, struct ldb_reply *are ac->search_res->message, "objectSid"); if (ac->domain_sid == NULL) { - ldb_debug(ac->module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "can't handle entry without objectSid!\n"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -2025,8 +2061,9 @@ static int ph_mod_search_callback(struct ldb_request *req, struct ldb_reply *are return LDB_SUCCESS; } -static int password_hash_mod_search_self(struct ph_context *ac) { - +static int password_hash_mod_search_self(struct ph_context *ac) +{ + struct ldb_context *ldb; static const char * const attrs[] = { "userAccountControl", "lmPwdHistory", "ntPwdHistory", "objectSid", "msDS-KeyVersionNumber", @@ -2038,7 +2075,9 @@ static int password_hash_mod_search_self(struct ph_context *ac) { struct ldb_request *search_req; int ret; - ret = ldb_build_search_req(&search_req, ac->module->ldb, ac, + ldb = ldb_module_get_ctx(ac->module); + + ret = ldb_build_search_req(&search_req, ldb, ac, ac->req->op.mod.message->dn, LDB_SCOPE_BASE, "(objectclass=*)", @@ -2054,8 +2093,9 @@ static int password_hash_mod_search_self(struct ph_context *ac) { return ldb_next_request(ac->module, search_req); } -static int password_hash_mod_do_mod(struct ph_context *ac) { - +static int password_hash_mod_do_mod(struct ph_context *ac) +{ + struct ldb_context *ldb; struct ldb_request *mod_req; struct smb_krb5_context *smb_krb5_context; struct ldb_message *msg; @@ -2064,6 +2104,8 @@ static int password_hash_mod_do_mod(struct ph_context *ac) { struct setup_password_fields_io io; int ret; + ldb = ldb_module_get_ctx(ac->module); + /* use a new message structure so that we can modify it */ msg = ldb_msg_new(ac); if (msg == NULL) { @@ -2075,8 +2117,8 @@ static int password_hash_mod_do_mod(struct ph_context *ac) { /* Some operations below require kerberos contexts */ if (smb_krb5_init_context(ac, - ldb_get_event_context(ac->module->ldb), - (struct loadparm_context *)ldb_get_opaque(ac->module->ldb, "loadparm"), + ldb_get_event_context(ldb), + (struct loadparm_context *)ldb_get_opaque(ldb, "loadparm"), &smb_krb5_context) != 0) { return LDB_ERR_OPERATIONS_ERROR; } @@ -2119,14 +2161,14 @@ static int password_hash_mod_do_mod(struct ph_context *ac) { ret = ldb_msg_add_empty(msg, "msDs-KeyVersionNumber", LDB_FLAG_MOD_REPLACE, NULL); if (io.g.nt_hash) { - ret = samdb_msg_add_hash(ac->module->ldb, ac, msg, + ret = samdb_msg_add_hash(ldb, ac, msg, "unicodePwd", io.g.nt_hash); if (ret != LDB_SUCCESS) { return ret; } } if (io.g.lm_hash) { - ret = samdb_msg_add_hash(ac->module->ldb, ac, msg, + ret = samdb_msg_add_hash(ldb, ac, msg, "dBCSPwd", io.g.lm_hash); if (ret != LDB_SUCCESS) { return ret; @@ -2157,20 +2199,20 @@ static int password_hash_mod_do_mod(struct ph_context *ac) { return ret; } } - ret = samdb_msg_add_uint64(ac->module->ldb, ac, msg, + ret = samdb_msg_add_uint64(ldb, ac, msg, "pwdLastSet", io.g.last_set); if (ret != LDB_SUCCESS) { return ret; } - ret = samdb_msg_add_uint(ac->module->ldb, ac, msg, + ret = samdb_msg_add_uint(ldb, ac, msg, "msDs-KeyVersionNumber", io.g.kvno); if (ret != LDB_SUCCESS) { return ret; } - ret = ldb_build_mod_req(&mod_req, ac->module->ldb, ac, + ret = ldb_build_mod_req(&mod_req, ldb, ac, msg, ac->req->controls, ac, ph_op_callback, diff --git a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c index 198b667358..fefaef4755 100644 --- a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c @@ -21,9 +21,7 @@ */ #include "includes.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb_private.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" @@ -32,6 +30,7 @@ static int pdc_fsmo_init(struct ldb_module *module) { + struct ldb_context *ldb; TALLOC_CTX *mem_ctx; struct ldb_dn *pdc_dn; struct dsdb_pdc_fsmo *pdc_fsmo; @@ -42,15 +41,17 @@ static int pdc_fsmo_init(struct ldb_module *module) NULL }; + ldb = ldb_module_get_ctx(module); + mem_ctx = talloc_new(module); if (!mem_ctx) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - pdc_dn = samdb_base_dn(module->ldb); + pdc_dn = samdb_base_dn(ldb); if (!pdc_dn) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "pdc_fsmo_init: no domain dn present: (skip loading of domain details)\n"); talloc_free(mem_ctx); return ldb_next_init(module); @@ -58,54 +59,54 @@ static int pdc_fsmo_init(struct ldb_module *module) pdc_fsmo = talloc_zero(mem_ctx, struct dsdb_pdc_fsmo); if (!pdc_fsmo) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - module->private_data = pdc_fsmo; + ldb_module_set_private(module, pdc_fsmo); - ret = ldb_search(module->ldb, mem_ctx, &pdc_res, + ret = ldb_search(ldb, mem_ctx, &pdc_res, pdc_dn, LDB_SCOPE_BASE, pdc_attrs, NULL); if (ret == LDB_ERR_NO_SUCH_OBJECT) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "pdc_fsmo_init: no domain object present: (skip loading of domain details)\n"); talloc_free(mem_ctx); return ldb_next_init(module); } else if (ret != LDB_SUCCESS) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "pdc_fsmo_init: failed to search the domain object: %d:%s", ret, ldb_strerror(ret)); talloc_free(mem_ctx); return ret; } if (pdc_res->count == 0) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_debug(ldb, LDB_DEBUG_WARNING, "pdc_fsmo_init: no domain object present: (skip loading of domain details)\n"); talloc_free(mem_ctx); return ldb_next_init(module); } else if (pdc_res->count > 1) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "pdc_fsmo_init: [%u] domain objects found on a base search", pdc_res->count); talloc_free(mem_ctx); return LDB_ERR_CONSTRAINT_VIOLATION; } - pdc_fsmo->master_dn = ldb_msg_find_attr_as_dn(module->ldb, mem_ctx, pdc_res->msgs[0], "fSMORoleOwner"); - if (ldb_dn_compare(samdb_ntds_settings_dn(module->ldb), pdc_fsmo->master_dn) == 0) { + pdc_fsmo->master_dn = ldb_msg_find_attr_as_dn(ldb, mem_ctx, pdc_res->msgs[0], "fSMORoleOwner"); + if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), pdc_fsmo->master_dn) == 0) { pdc_fsmo->we_are_master = true; } else { pdc_fsmo->we_are_master = false; } - if (ldb_set_opaque(module->ldb, "dsdb_pdc_fsmo", pdc_fsmo) != LDB_SUCCESS) { - ldb_oom(module->ldb); + if (ldb_set_opaque(ldb, "dsdb_pdc_fsmo", pdc_fsmo) != LDB_SUCCESS) { + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } talloc_steal(module, pdc_fsmo); - ldb_debug(module->ldb, LDB_DEBUG_TRACE, + ldb_debug(ldb, LDB_DEBUG_TRACE, "pdc_fsmo_init: we are master: %s\n", (pdc_fsmo->we_are_master?"yes":"no")); diff --git a/source4/dsdb/samdb/ldb_modules/proxy.c b/source4/dsdb/samdb/ldb_modules/proxy.c index 23116be9ac..9a5091ce90 100644 --- a/source4/dsdb/samdb/ldb_modules/proxy.c +++ b/source4/dsdb/samdb/ldb_modules/proxy.c @@ -37,9 +37,7 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb_private.h" +#include "ldb_module.h" #include "auth/credentials/credentials.h" struct proxy_data { @@ -64,7 +62,8 @@ struct proxy_ctx { */ static int load_proxy_info(struct ldb_module *module) { - struct proxy_data *proxy = talloc_get_type(module->private_data, struct proxy_data); + struct ldb = ldb_module_get_ctx(module); + struct proxy_data *proxy = talloc_get_type(ldb_module_get_private(module), struct proxy_data); struct ldb_dn *dn; struct ldb_result *res = NULL; int ret; @@ -76,14 +75,14 @@ static int load_proxy_info(struct ldb_module *module) return LDB_SUCCESS; } - dn = ldb_dn_new(proxy, module->ldb, "@PROXYINFO"); + dn = ldb_dn_new(proxy, ldb, "@PROXYINFO"); if (dn == NULL) { goto failed; } - ret = ldb_search(module->ldb, proxy, &res, dn, LDB_SCOPE_BASE, NULL, NULL); + ret = ldb_search(ldb, proxy, &res, dn, LDB_SCOPE_BASE, NULL, NULL); talloc_free(dn); if (ret != LDB_SUCCESS || res->count != 1) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Can't find @PROXYINFO\n"); + ldb_debug(ldb, LDB_DEBUG_FATAL, "Can't find @PROXYINFO\n"); goto failed; } @@ -96,47 +95,47 @@ static int load_proxy_info(struct ldb_module *module) newstr = ldb_msg_find_attr_as_string(res->msgs[0], "newstr", NULL); if (url == NULL || olddn == NULL || newdn == NULL || username == NULL || password == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Need url, olddn, newdn, oldstr, newstr, username and password in @PROXYINFO\n"); + ldb_debug(ldb, LDB_DEBUG_FATAL, "Need url, olddn, newdn, oldstr, newstr, username and password in @PROXYINFO\n"); goto failed; } - proxy->olddn = ldb_dn_new(proxy, module->ldb, olddn); + proxy->olddn = ldb_dn_new(proxy, ldb, olddn); if (proxy->olddn == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Failed to explode olddn '%s'\n", olddn); + ldb_debug(ldb, LDB_DEBUG_FATAL, "Failed to explode olddn '%s'\n", olddn); goto failed; } - proxy->newdn = ldb_dn_new(proxy, module->ldb, newdn); + proxy->newdn = ldb_dn_new(proxy, ldb, newdn); if (proxy->newdn == NULL) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Failed to explode newdn '%s'\n", newdn); + ldb_debug(ldb, LDB_DEBUG_FATAL, "Failed to explode newdn '%s'\n", newdn); goto failed; } proxy->upstream = ldb_init(proxy, ldb_get_event_context(ldb)); if (proxy->upstream == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); goto failed; } proxy->oldstr = str_list_make(proxy, oldstr, ", "); if (proxy->oldstr == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); goto failed; } proxy->newstr = str_list_make(proxy, newstr, ", "); if (proxy->newstr == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); goto failed; } /* setup credentials for connection */ creds = cli_credentials_init(proxy->upstream); if (creds == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); goto failed; } - cli_credentials_guess(creds, ldb_get_opaque(module->ldb, "loadparm")); + cli_credentials_guess(creds, ldb_get_opaque(ldb, "loadparm")); cli_credentials_set_username(creds, username, CRED_SPECIFIED); cli_credentials_set_password(creds, password, CRED_SPECIFIED); @@ -144,11 +143,11 @@ static int load_proxy_info(struct ldb_module *module) ret = ldb_connect(proxy->upstream, url, 0, NULL); if (ret != 0) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "proxy failed to connect to %s\n", url); + ldb_debug(ldb, LDB_DEBUG_FATAL, "proxy failed to connect to %s\n", url); goto failed; } - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "proxy connected to %s\n", url); + ldb_debug(ldb, LDB_DEBUG_TRACE, "proxy connected to %s\n", url); talloc_free(res); @@ -256,12 +255,14 @@ static void proxy_convert_record(struct ldb_context *ldb, static int proxy_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct proxy_data *proxy; struct proxy_ctx *ac; int ret; ac = talloc_get_type(req->context, struct proxy_ctx); - proxy = talloc_get_type(ac->module->private_data, struct proxy_data); + ldb = ldb_module_get_ctx(ac->module); + proxy = talloc_get_type(private_data, struct proxy_data); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -279,7 +280,7 @@ static int proxy_search_callback(struct ldb_request *req, #ifdef DEBUG_PROXY ac->count++; #endif - proxy_convert_record(ac->module->ldb, proxy, ares->message); + proxy_convert_record(ldb, proxy, ares->message); ret = ldb_module_send_entry(ac->req, ares->message, ares->controls); break; @@ -304,13 +305,16 @@ static int proxy_search_callback(struct ldb_request *req, /* search */ static int proxy_search_bytree(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct proxy_ctx *ac; struct ldb_parse_tree *newtree; - struct proxy_data *proxy = talloc_get_type(module->private_data, struct proxy_data); + struct proxy_data *proxy = talloc_get_type(ldb_module_get_private(module), struct proxy_data); struct ldb_request *newreq; struct ldb_dn *base; int ret, i; + ldb = ldb_module_get_ctx(module); + if (req->op.search.base == NULL || (req->op.search.base->comp_num == 1 && req->op.search.base->components[0].name[0] == '@')) { @@ -347,13 +351,13 @@ static int proxy_search_bytree(struct ldb_module *module, struct ldb_request *re ldb_dn_remove_base_components(base, ldb_dn_get_comp_num(proxy->newdn)); ldb_dn_add_base(base, proxy->olddn); - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "proxying: '%s' with dn '%s' \n", + ldb_debug(ldb, LDB_DEBUG_FATAL, "proxying: '%s' with dn '%s' \n", ldb_filter_from_tree(ac, newreq->op.search.tree), ldb_dn_get_linearized(newreq->op.search.base)); for (i = 0; req->op.search.attrs && req->op.search.attrs[i]; i++) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "attr: '%s'\n", req->op.search.attrs[i]); + ldb_debug(ldb, LDB_DEBUG_FATAL, "attr: '%s'\n", req->op.search.attrs[i]); } - ret = ldb_build_search_req_ex(&newreq, module->ldb, ac, + ret = ldb_build_search_req_ex(&newreq, ldb, ac, base, req->op.search.scope, newtree, req->op.search.attrs, req->controls, @@ -364,16 +368,16 @@ static int proxy_search_bytree(struct ldb_module *module, struct ldb_request *re * for now this makes the module *not* ASYNC */ ret = ldb_request(proxy->upstream, newreq); if (ret != LDB_SUCCESS) { - ldb_set_errstring(module->ldb, ldb_errstring(proxy->upstream)); + ldb_set_errstring(ldb, ldb_errstring(proxy->upstream)); } ret = ldb_wait(newreq->handle, LDB_WAIT_ALL); if (ret != LDB_SUCCESS) { - ldb_set_errstring(module->ldb, ldb_errstring(proxy->upstream)); + ldb_set_errstring(ldb, ldb_errstring(proxy->upstream)); } return ret; failed: - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "proxy failed for %s\n", + ldb_debug(ldb, LDB_DEBUG_TRACE, "proxy failed for %s\n", ldb_dn_get_linearized(req->op.search.base)); passthru: diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index f30748c85c..1ea1ab1b81 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -39,9 +39,7 @@ */ #include "includes.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb_private.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" #include "dsdb/common/flags.h" #include "librpc/gen_ndr/ndr_misc.h" @@ -68,11 +66,14 @@ struct replmd_replicated_request { static struct replmd_replicated_request *replmd_ctx_init(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct replmd_replicated_request *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct replmd_replicated_request); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } @@ -204,9 +205,11 @@ static void replmd_ldb_message_sort(struct ldb_message *msg, static int replmd_op_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct replmd_replicated_request *ac; ac = talloc_get_type(req->context, struct replmd_replicated_request); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -218,7 +221,7 @@ static int replmd_op_callback(struct ldb_request *req, struct ldb_reply *ares) } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "invalid ldb_reply_type in callback"); talloc_free(ares); return ldb_module_done(ac->req, NULL, NULL, @@ -231,6 +234,7 @@ static int replmd_op_callback(struct ldb_request *req, struct ldb_reply *ares) static int replmd_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct replmd_replicated_request *ac; const struct dsdb_schema *schema; enum ndr_err_code ndr_err; @@ -254,11 +258,13 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_add\n"); + ldb = ldb_module_get_ctx(ac->module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "replmd_add\n"); - schema = dsdb_get_schema(module->ldb); + schema = dsdb_get_schema(ldb); if (!schema) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "replmd_modify: no dsdb_schema loaded"); return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -271,13 +277,13 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) ac->schema = schema; if (ldb_msg_find_element(req->op.add.message, "objectGUID") != NULL) { - ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, + ldb_debug_set(ldb, LDB_DEBUG_ERROR, "replmd_add: it's not allowed to add an object with objectGUID\n"); return LDB_ERR_UNWILLING_TO_PERFORM; } /* Get a sequence number from the backend */ - ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num); + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret != LDB_SUCCESS) { return ret; } @@ -286,9 +292,9 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) guid = GUID_random(); /* get our invicationId */ - our_invocation_id = samdb_ntds_invocation_id(module->ldb); + our_invocation_id = samdb_ntds_invocation_id(ldb); if (!our_invocation_id) { - ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, + ldb_debug_set(ldb, LDB_DEBUG_ERROR, "replmd_add: unable to find invocationId\n"); return LDB_ERR_OPERATIONS_ERROR; } @@ -296,7 +302,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) /* we have to copy the message as the caller might have it as a const */ msg = ldb_msg_copy_shallow(ac, req->op.add.message); if (msg == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -321,7 +327,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) */ ret = ldb_msg_add_string(msg, "whenCreated", time_str); if (ret != LDB_SUCCESS) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -333,7 +339,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) struct replPropertyMetaData1, nmd.ctr.ctr1.count); if (!nmd.ctr.ctr1.array) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -346,7 +352,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) sa = dsdb_attribute_by_lDAPDisplayName(schema, e->name); if (!sa) { - ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, + ldb_debug_set(ldb, LDB_DEBUG_ERROR, "replmd_add: attribute '%s' not defined in schema\n", e->name); return LDB_ERR_NO_SUCH_ATTRIBUTE; @@ -386,15 +392,15 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) &guid, (ndr_push_flags_fn_t)ndr_push_GUID); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } ndr_err = ndr_push_struct_blob(&nmd_value, msg, - lp_iconv_convenience(ldb_get_opaque(module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &nmd, (ndr_push_flags_fn_t)ndr_push_replPropertyMetaDataBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -403,27 +409,27 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) */ ret = ldb_msg_add_value(msg, "objectGUID", &guid_value, NULL); if (ret != LDB_SUCCESS) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } ret = ldb_msg_add_string(msg, "whenChanged", time_str); if (ret != LDB_SUCCESS) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = samdb_msg_add_uint64(module->ldb, msg, msg, "uSNCreated", seq_num); + ret = samdb_msg_add_uint64(ldb, msg, msg, "uSNCreated", seq_num); if (ret != LDB_SUCCESS) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = samdb_msg_add_uint64(module->ldb, msg, msg, "uSNChanged", seq_num); + ret = samdb_msg_add_uint64(ldb, msg, msg, "uSNChanged", seq_num); if (ret != LDB_SUCCESS) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } ret = ldb_msg_add_value(msg, "replPropertyMetaData", &nmd_value, NULL); if (ret != LDB_SUCCESS) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -432,7 +438,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) */ replmd_ldb_message_sort(msg, schema); - ret = ldb_build_add_req(&down_req, module->ldb, ac, + ret = ldb_build_add_req(&down_req, ldb, ac, msg, req->controls, ac, replmd_op_callback, @@ -447,6 +453,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) static int replmd_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct replmd_replicated_request *ac; const struct dsdb_schema *schema; struct ldb_request *down_req; @@ -460,11 +467,13 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_modify\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "replmd_modify\n"); - schema = dsdb_get_schema(module->ldb); + schema = dsdb_get_schema(ldb); if (!schema) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "replmd_modify: no dsdb_schema loaded"); return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -501,7 +510,7 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req) } /* Get a sequence number from the backend */ - ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num); + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret == LDB_SUCCESS) { if (add_uint64_element(msg, "uSNChanged", seq_num) != LDB_SUCCESS) { talloc_free(ac); @@ -514,7 +523,7 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req) * - replace the old object with the newly constructed one */ - ret = ldb_build_mod_req(&down_req, module->ldb, ac, + ret = ldb_build_mod_req(&down_req, ldb, ac, msg, req->controls, ac, replmd_op_callback, @@ -545,10 +554,12 @@ static int replmd_replicated_apply_next(struct replmd_replicated_request *ar); static int replmd_replicated_apply_add_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct replmd_replicated_request *ar = talloc_get_type(req->context, struct replmd_replicated_request); int ret; + ldb = ldb_module_get_ctx(ar->module); if (!ares) { return ldb_module_done(ar->req, NULL, NULL, @@ -560,7 +571,7 @@ static int replmd_replicated_apply_add_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ar->module->ldb, "Invalid reply type\n!"); + ldb_set_errstring(ldb, "Invalid reply type\n!"); return ldb_module_done(ar->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -578,6 +589,7 @@ static int replmd_replicated_apply_add_callback(struct ldb_request *req, static int replmd_replicated_apply_add(struct replmd_replicated_request *ar) { + struct ldb_context *ldb; struct ldb_request *change_req; enum ndr_err_code ndr_err; struct ldb_message *msg; @@ -596,10 +608,11 @@ static int replmd_replicated_apply_add(struct replmd_replicated_request *ar) * same name exist */ + ldb = ldb_module_get_ctx(ar->module); msg = ar->objs->objects[ar->index_current].msg; md = ar->objs->objects[ar->index_current].meta_data; - ret = ldb_sequence_number(ar->module->ldb, LDB_SEQ_NEXT, &seq_num); + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret != LDB_SUCCESS) { return replmd_replicated_request_error(ar, ret); } @@ -614,12 +627,12 @@ static int replmd_replicated_apply_add(struct replmd_replicated_request *ar) return replmd_replicated_request_error(ar, ret); } - ret = samdb_msg_add_uint64(ar->module->ldb, msg, msg, "uSNCreated", seq_num); + ret = samdb_msg_add_uint64(ldb, msg, msg, "uSNCreated", seq_num); if (ret != LDB_SUCCESS) { return replmd_replicated_request_error(ar, ret); } - ret = samdb_msg_add_uint64(ar->module->ldb, msg, msg, "uSNChanged", seq_num); + ret = samdb_msg_add_uint64(ldb, msg, msg, "uSNChanged", seq_num); if (ret != LDB_SUCCESS) { return replmd_replicated_request_error(ar, ret); } @@ -631,7 +644,7 @@ static int replmd_replicated_apply_add(struct replmd_replicated_request *ar) md->ctr.ctr1.array[i].local_usn = seq_num; } ndr_err = ndr_push_struct_blob(&md_value, msg, - lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), md, (ndr_push_flags_fn_t)ndr_push_replPropertyMetaDataBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -646,7 +659,7 @@ static int replmd_replicated_apply_add(struct replmd_replicated_request *ar) replmd_ldb_message_sort(msg, ar->schema); ret = ldb_build_add_req(&change_req, - ar->module->ldb, + ldb, ar, msg, ar->controls, @@ -682,10 +695,13 @@ static int replmd_replPropertyMetaData1_conflict_compare(struct replPropertyMeta static int replmd_replicated_apply_merge_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct replmd_replicated_request *ar = talloc_get_type(req->context, struct replmd_replicated_request); int ret; + ldb = ldb_module_get_ctx(ar->module); + if (!ares) { return ldb_module_done(ar->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -696,7 +712,7 @@ static int replmd_replicated_apply_merge_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ar->module->ldb, "Invalid reply type\n!"); + ldb_set_errstring(ldb, "Invalid reply type\n!"); return ldb_module_done(ar->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -714,6 +730,7 @@ static int replmd_replicated_apply_merge_callback(struct ldb_request *req, static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) { + struct ldb_context *ldb; struct ldb_request *change_req; enum ndr_err_code ndr_err; struct ldb_message *msg; @@ -727,6 +744,7 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) uint64_t seq_num; int ret; + ldb = ldb_module_get_ctx(ar->module); msg = ar->objs->objects[ar->index_current].msg; rmd = ar->objs->objects[ar->index_current].meta_data; ZERO_STRUCT(omd); @@ -736,15 +754,15 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) * TODO: add rename conflict handling */ if (ldb_dn_compare(msg->dn, ar->search_msg->dn) != 0) { - ldb_debug_set(ar->module->ldb, LDB_DEBUG_FATAL, "replmd_replicated_apply_merge[%u]: rename not supported", + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "replmd_replicated_apply_merge[%u]: rename not supported", ar->index_current); - ldb_debug(ar->module->ldb, LDB_DEBUG_FATAL, "%s => %s\n", + ldb_debug(ldb, LDB_DEBUG_FATAL, "%s => %s\n", ldb_dn_get_linearized(ar->search_msg->dn), ldb_dn_get_linearized(msg->dn)); return replmd_replicated_request_werror(ar, WERR_NOT_SUPPORTED); } - ret = ldb_sequence_number(ar->module->ldb, LDB_SEQ_NEXT, &seq_num); + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret != LDB_SUCCESS) { return replmd_replicated_request_error(ar, ret); } @@ -753,7 +771,7 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) omd_value = ldb_msg_find_ldb_val(ar->search_msg, "replPropertyMetaData"); if (omd_value) { ndr_err = ndr_pull_struct_blob(omd_value, ar, - lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), &omd, + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &omd, (ndr_pull_flags_fn_t)ndr_pull_replPropertyMetaDataBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err); @@ -837,7 +855,7 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) /* create the meta data value */ ndr_err = ndr_push_struct_blob(&nmd_value, msg, - lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &nmd, (ndr_push_flags_fn_t)ndr_push_replPropertyMetaDataBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -849,14 +867,14 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) * check if some replicated attributes left, otherwise skip the ldb_modify() call */ if (msg->num_elements == 0) { - ldb_debug(ar->module->ldb, LDB_DEBUG_TRACE, "replmd_replicated_apply_merge[%u]: skip replace\n", + ldb_debug(ldb, LDB_DEBUG_TRACE, "replmd_replicated_apply_merge[%u]: skip replace\n", ar->index_current); ar->index_current++; return replmd_replicated_apply_next(ar); } - ldb_debug(ar->module->ldb, LDB_DEBUG_TRACE, "replmd_replicated_apply_merge[%u]: replace %u attributes\n", + ldb_debug(ldb, LDB_DEBUG_TRACE, "replmd_replicated_apply_merge[%u]: replace %u attributes\n", ar->index_current, msg->num_elements); /* @@ -867,7 +885,7 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) if (ret != LDB_SUCCESS) { return replmd_replicated_request_error(ar, ret); } - ret = samdb_msg_add_uint64(ar->module->ldb, msg, msg, "uSNChanged", seq_num); + ret = samdb_msg_add_uint64(ldb, msg, msg, "uSNChanged", seq_num); if (ret != LDB_SUCCESS) { return replmd_replicated_request_error(ar, ret); } @@ -884,7 +902,7 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar) } ret = ldb_build_mod_req(&change_req, - ar->module->ldb, + ldb, ar, msg, ar->controls, @@ -941,6 +959,7 @@ static int replmd_replicated_uptodate_vector(struct replmd_replicated_request *a static int replmd_replicated_apply_next(struct replmd_replicated_request *ar) { + struct ldb_context *ldb; int ret; char *tmp_str; char *filter; @@ -951,6 +970,7 @@ static int replmd_replicated_apply_next(struct replmd_replicated_request *ar) return replmd_replicated_uptodate_vector(ar); } + ldb = ldb_module_get_ctx(ar->module); ar->search_msg = NULL; tmp_str = ldb_binary_encode(ar, ar->objs->objects[ar->index_current].guid_value); @@ -961,7 +981,7 @@ static int replmd_replicated_apply_next(struct replmd_replicated_request *ar) talloc_free(tmp_str); ret = ldb_build_search_req(&search_req, - ar->module->ldb, + ldb, ar, ar->objs->partition_dn, LDB_SCOPE_SUBTREE, @@ -979,8 +999,10 @@ static int replmd_replicated_apply_next(struct replmd_replicated_request *ar) static int replmd_replicated_uptodate_modify_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct replmd_replicated_request *ar = talloc_get_type(req->context, struct replmd_replicated_request); + ldb = ldb_module_get_ctx(ar->module); if (!ares) { return ldb_module_done(ar->req, NULL, NULL, @@ -992,7 +1014,7 @@ static int replmd_replicated_uptodate_modify_callback(struct ldb_request *req, } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ar->module->ldb, "Invalid reply type\n!"); + ldb_set_errstring(ldb, "Invalid reply type\n!"); return ldb_module_done(ar->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); } @@ -1010,6 +1032,7 @@ static int replmd_drsuapi_DsReplicaCursor2_compare(const struct drsuapi_DsReplic static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *ar) { + struct ldb_context *ldb; struct ldb_request *change_req; enum ndr_err_code ndr_err; struct ldb_message *msg; @@ -1031,6 +1054,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a NTTIME now; int ret; + ldb = ldb_module_get_ctx(ar->module); ruv = ar->objs->uptodateness_vector; ZERO_STRUCT(ouv); ouv.version = 2; @@ -1044,7 +1068,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a * because we will do a modify request and this will increment * our highest_usn */ - ret = ldb_sequence_number(ar->module->ldb, LDB_SEQ_NEXT, &seq_num); + ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num); if (ret != LDB_SUCCESS) { return replmd_replicated_request_error(ar, ret); } @@ -1055,7 +1079,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a ouv_value = ldb_msg_find_ldb_val(ar->search_msg, "replUpToDateVector"); if (ouv_value) { ndr_err = ndr_pull_struct_blob(ouv_value, ar, - lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), &ouv, + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &ouv, (ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err); @@ -1087,7 +1111,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a } /* get our invocation_id if we have one already attached to the ldb */ - our_invocation_id = samdb_ntds_invocation_id(ar->module->ldb); + our_invocation_id = samdb_ntds_invocation_id(ldb); /* merge in the source_dsa vector is available */ for (i=0; (ruv && i < ruv->count); i++) { @@ -1181,7 +1205,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a msg->dn = ar->search_msg->dn; ndr_err = ndr_push_struct_blob(&nuv_value, msg, - lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &nuv, (ndr_push_flags_fn_t)ndr_push_replUpToDateVectorBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -1219,7 +1243,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a trf = talloc(ar, struct repsFromToBlob); if (!trf) return replmd_replicated_request_werror(ar, WERR_NOMEM); - ndr_err = ndr_pull_struct_blob(&orf_el->values[i], trf, lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), trf, + ndr_err = ndr_pull_struct_blob(&orf_el->values[i], trf, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), trf, (ndr_pull_flags_fn_t)ndr_pull_repsFromToBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err); @@ -1270,7 +1294,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a /* we now fill the value which is already attached to ldb_message */ ndr_err = ndr_push_struct_blob(nrf_value, msg, - lp_iconv_convenience(ldb_get_opaque(ar->module->ldb, "loadparm")), + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &nrf, (ndr_push_flags_fn_t)ndr_push_repsFromToBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -1286,7 +1310,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a /* prepare the ldb_modify() request */ ret = ldb_build_mod_req(&change_req, - ar->module->ldb, + ldb, ar, msg, ar->controls, @@ -1342,6 +1366,7 @@ static int replmd_replicated_uptodate_search_callback(struct ldb_request *req, static int replmd_replicated_uptodate_vector(struct replmd_replicated_request *ar) { + struct ldb_context *ldb; int ret; static const char *attrs[] = { "replUpToDateVector", @@ -1350,10 +1375,11 @@ static int replmd_replicated_uptodate_vector(struct replmd_replicated_request *a }; struct ldb_request *search_req; + ldb = ldb_module_get_ctx(ar->module); ar->search_msg = NULL; ret = ldb_build_search_req(&search_req, - ar->module->ldb, + ldb, ar, ar->objs->partition_dn, LDB_SCOPE_BASE, @@ -1370,21 +1396,24 @@ static int replmd_replicated_uptodate_vector(struct replmd_replicated_request *a static int replmd_extended_replicated_objects(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct dsdb_extended_replicated_objects *objs; struct replmd_replicated_request *ar; struct ldb_control **ctrls; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "replmd_extended_replicated_objects\n"); + ldb = ldb_module_get_ctx(module); + + ldb_debug(ldb, LDB_DEBUG_TRACE, "replmd_extended_replicated_objects\n"); objs = talloc_get_type(req->op.extended.data, struct dsdb_extended_replicated_objects); if (!objs) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "replmd_extended_replicated_objects: invalid extended data\n"); + ldb_debug(ldb, LDB_DEBUG_FATAL, "replmd_extended_replicated_objects: invalid extended data\n"); return LDB_ERR_PROTOCOL_ERROR; } if (objs->version != DSDB_EXTENDED_REPLICATED_OBJECTS_VERSION) { - ldb_debug(module->ldb, LDB_DEBUG_FATAL, "replmd_extended_replicated_objects: extended data invalid version [%u != %u]\n", + ldb_debug(ldb, LDB_DEBUG_FATAL, "replmd_extended_replicated_objects: extended data invalid version [%u != %u]\n", objs->version, DSDB_EXTENDED_REPLICATED_OBJECTS_VERSION); return LDB_ERR_PROTOCOL_ERROR; } @@ -1394,9 +1423,9 @@ static int replmd_extended_replicated_objects(struct ldb_module *module, struct return LDB_ERR_OPERATIONS_ERROR; ar->objs = objs; - ar->schema = dsdb_get_schema(module->ldb); + ar->schema = dsdb_get_schema(ldb); if (!ar->schema) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, "replmd_ctx_init: no loaded schema found\n"); + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "replmd_ctx_init: no loaded schema found\n"); talloc_free(ar); return LDB_ERR_CONSTRAINT_VIOLATION; } diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c index 461a554ec0..9ae894d55f 100644 --- a/source4/dsdb/samdb/ldb_modules/rootdse.c +++ b/source4/dsdb/samdb/ldb_modules/rootdse.c @@ -21,9 +21,7 @@ */ #include "includes.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb_private.h" +#include "ldb_private.h" #include "system/time.h" #include "dsdb/samdb/samdb.h" #include "version.h" @@ -56,13 +54,15 @@ static int do_attribute_explicit(const char * const *attrs, const char *name) */ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *msg, const char * const *attrs) { - struct private_data *priv = talloc_get_type(module->private_data, struct private_data); + struct ldb_context *ldb; + struct private_data *priv = talloc_get_type(ldb_module_get_private(module), struct private_data); char **server_sasl; const struct dsdb_schema *schema; - schema = dsdb_get_schema(module->ldb); + ldb = ldb_module_get_ctx(module); + schema = dsdb_get_schema(ldb); - msg->dn = ldb_dn_new(msg, module->ldb, NULL); + msg->dn = ldb_dn_new(msg, ldb, NULL); /* don't return the distinduishedName, cn and name attributes */ ldb_msg_remove_attr(msg, "distinguishedName"); @@ -101,7 +101,7 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms } } - server_sasl = talloc_get_type(ldb_get_opaque(module->ldb, "supportedSASLMechanims"), + server_sasl = talloc_get_type(ldb_get_opaque(ldb, "supportedSASLMechanims"), char *); if (server_sasl && do_attribute(attrs, "supportedSASLMechanisms")) { int i; @@ -119,7 +119,7 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms if (do_attribute(attrs, "highestCommittedUSN")) { uint64_t seq_num; - int ret = ldb_sequence_number(module->ldb, LDB_SEQ_HIGHEST_SEQ, &seq_num); + int ret = ldb_sequence_number(ldb, LDB_SEQ_HIGHEST_SEQ, &seq_num); if (ret == LDB_SUCCESS) { if (ldb_msg_add_fmt(msg, "highestCommittedUSN", "%llu", (unsigned long long)seq_num) != 0) { @@ -169,7 +169,7 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms const char *dn_str; if (schema && schema->fsmo.we_are_master) { - dn_str = ldb_dn_get_linearized(samdb_schema_dn(module->ldb)); + dn_str = ldb_dn_get_linearized(samdb_schema_dn(ldb)); if (dn_str && dn_str[0]) { if (ldb_msg_add_fmt(msg, "validFSMOs", "%s", dn_str) != 0) { goto failed; @@ -177,10 +177,10 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms } } - naming_fsmo = talloc_get_type(ldb_get_opaque(module->ldb, "dsdb_naming_fsmo"), + naming_fsmo = talloc_get_type(ldb_get_opaque(ldb, "dsdb_naming_fsmo"), struct dsdb_naming_fsmo); if (naming_fsmo && naming_fsmo->we_are_master) { - dn_str = ldb_dn_get_linearized(samdb_partitions_dn(module->ldb, msg)); + dn_str = ldb_dn_get_linearized(samdb_partitions_dn(ldb, msg)); if (dn_str && dn_str[0]) { if (ldb_msg_add_fmt(msg, "validFSMOs", "%s", dn_str) != 0) { goto failed; @@ -188,10 +188,10 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms } } - pdc_fsmo = talloc_get_type(ldb_get_opaque(module->ldb, "dsdb_pdc_fsmo"), + pdc_fsmo = talloc_get_type(ldb_get_opaque(ldb, "dsdb_pdc_fsmo"), struct dsdb_pdc_fsmo); if (pdc_fsmo && pdc_fsmo->we_are_master) { - dn_str = ldb_dn_get_linearized(samdb_base_dn(module->ldb)); + dn_str = ldb_dn_get_linearized(samdb_base_dn(ldb)); if (dn_str && dn_str[0]) { if (ldb_msg_add_fmt(msg, "validFSMOs", "%s", dn_str) != 0) { goto failed; @@ -227,11 +227,14 @@ struct rootdse_context { static struct rootdse_context *rootdse_init_context(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct rootdse_context *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct rootdse_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return NULL; } @@ -296,10 +299,13 @@ static int rootdse_callback(struct ldb_request *req, struct ldb_reply *ares) static int rootdse_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct rootdse_context *ac; struct ldb_request *down_req; int ret; + ldb = ldb_module_get_ctx(module); + /* see if its for the rootDSE - only a base search on the "" DN qualifies */ if (!(req->op.search.scope == LDB_SCOPE_BASE && ldb_dn_is_null(req->op.search.base))) { /* Otherwise, pass down to the rest of the stack */ @@ -312,8 +318,8 @@ static int rootdse_search(struct ldb_module *module, struct ldb_request *req) } /* in our db we store the rootDSE with a DN of @ROOTDSE */ - ret = ldb_build_search_req(&down_req, module->ldb, ac, - ldb_dn_new(ac, module->ldb, "@ROOTDSE"), + ret = ldb_build_search_req(&down_req, ldb, ac, + ldb_dn_new(ac, ldb, "@ROOTDSE"), LDB_SCOPE_BASE, NULL, req->op.search.attrs, @@ -329,7 +335,7 @@ static int rootdse_search(struct ldb_module *module, struct ldb_request *req) static int rootdse_register_control(struct ldb_module *module, struct ldb_request *req) { - struct private_data *priv = talloc_get_type(module->private_data, struct private_data); + struct private_data *priv = talloc_get_type(ldb_module_get_private(module), struct private_data); char **list; list = talloc_realloc(priv, priv->controls, char *, priv->num_controls + 1); @@ -350,7 +356,7 @@ static int rootdse_register_control(struct ldb_module *module, struct ldb_reques static int rootdse_register_partition(struct ldb_module *module, struct ldb_request *req) { - struct private_data *priv = talloc_get_type(module->private_data, struct private_data); + struct private_data *priv = talloc_get_type(ldb_module_get_private(module), struct private_data); struct ldb_dn **list; list = talloc_realloc(priv, priv->partitions, struct ldb_dn *, priv->num_partitions + 1); @@ -387,8 +393,11 @@ static int rootdse_request(struct ldb_module *module, struct ldb_request *req) static int rootdse_init(struct ldb_module *module) { + struct ldb_context *ldb; struct private_data *data; + ldb = ldb_module_get_ctx(module); + data = talloc(module, struct private_data); if (data == NULL) { return -1; @@ -398,15 +407,16 @@ static int rootdse_init(struct ldb_module *module) data->controls = NULL; data->num_partitions = 0; data->partitions = NULL; - module->private_data = data; + ldb_module_set_private(module, data); - ldb_set_default_dns(module->ldb); + ldb_set_default_dns(ldb); return ldb_next_init(module); } static int rootdse_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_result *ext_res; int ret; struct ldb_dn *schema_dn; @@ -418,7 +428,9 @@ static int rootdse_modify(struct ldb_module *module, struct ldb_request *req) if (!ldb_dn_is_null(req->op.mod.message->dn)) { return ldb_next_request(module, req); } - + + ldb = ldb_module_get_ctx(module); + /* dn is empty so check for schemaUpdateNow attribute "The type of modification and values specified in the LDAP modify operation do not matter." MSDN @@ -428,15 +440,15 @@ static int rootdse_modify(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } - schema_dn = samdb_schema_dn(module->ldb); + schema_dn = samdb_schema_dn(ldb); if (!schema_dn) { - ldb_reset_err_string(module->ldb); - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_reset_err_string(ldb); + ldb_debug(ldb, LDB_DEBUG_WARNING, "rootdse_modify: no schema dn present: (skip ldb_extended call)\n"); return ldb_next_request(module, req); } - ret = ldb_extended(module->ldb, DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID, schema_dn, &ext_res); + ret = ldb_extended(ldb, DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID, schema_dn, &ext_res); if (ret != LDB_SUCCESS) { return LDB_ERR_OPERATIONS_ERROR; } diff --git a/source4/dsdb/samdb/ldb_modules/samba3sam.c b/source4/dsdb/samdb/ldb_modules/samba3sam.c index 7a123c818f..3f10748085 100644 --- a/source4/dsdb/samdb/ldb_modules/samba3sam.c +++ b/source4/dsdb/samdb/ldb_modules/samba3sam.c @@ -6,9 +6,7 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_private.h" -#include "ldb/include/ldb_errors.h" +#include "ldb/include/ldb_module.h" #include "ldb/ldb_map/ldb_map.h" #include "system/passwd.h" @@ -118,20 +116,23 @@ static void generate_sambaPrimaryGroupSID(struct ldb_module *module, const char static struct ldb_val convert_uid_samaccount(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) { struct ldb_val out = data_blob(NULL, 0); - ldb_handler_copy(module->ldb, ctx, val, &out); + out = ldb_val_dup(ctx, val); return out; } static struct ldb_val lookup_homedir(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) { + struct ldb_context *ldb; struct passwd *pwd; struct ldb_val retval; - + + ldb = ldb_module_get_ctx(module); + pwd = getpwnam((char *)val->data); if (!pwd) { - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Unable to lookup '%s' in passwd", (char *)val->data); + ldb_debug(ldb, LDB_DEBUG_WARNING, "Unable to lookup '%s' in passwd", (char *)val->data); return *talloc_zero(ctx, struct ldb_val); } @@ -145,7 +146,7 @@ static struct ldb_val lookup_gid(struct ldb_module *module, TALLOC_CTX *ctx, con { struct passwd *pwd; struct ldb_val retval; - + pwd = getpwnam((char *)val->data); if (!pwd) { diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index 5ab577c33d..65e36416f1 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -34,10 +34,7 @@ #include "includes.h" #include "libcli/ldap/ldap_ndr.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_private.h" -#include "lib/events/events.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" #include "libcli/security/security.h" #include "librpc/gen_ndr/ndr_security.h" @@ -83,11 +80,14 @@ struct samldb_ctx { static struct samldb_ctx *samldb_ctx_init(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct samldb_ctx *ac; + ldb = ldb_module_get_ctx(module); + ac = talloc_zero(req, struct samldb_ctx); if (ac == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return NULL; } @@ -144,10 +144,12 @@ static int samldb_next_step(struct samldb_ctx *ac) static int samldb_search_template_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct samldb_ctx *ac; int ret; ac = talloc_get_type(req->context, struct samldb_ctx); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { ret = LDB_ERR_OPERATIONS_ERROR; @@ -163,7 +165,7 @@ static int samldb_search_template_callback(struct ldb_request *req, /* save entry */ if (ac->ares != NULL) { /* one too many! */ - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Invalid number of results while searching " "for template objects"); ret = LDB_ERR_OPERATIONS_ERROR; @@ -197,6 +199,7 @@ done: static int samldb_search_template(struct samldb_ctx *ac) { + struct ldb_context *ldb; struct tevent_context *ev; struct loadparm_context *lparm_ctx; struct ldb_context *templates_ldb; @@ -206,31 +209,33 @@ static int samldb_search_template(struct samldb_ctx *ac) void *opaque; int ret; - opaque = ldb_get_opaque(ac->module->ldb, "loadparm"); + ldb = ldb_module_get_ctx(ac->module); + + opaque = ldb_get_opaque(ldb, "loadparm"); lparm_ctx = talloc_get_type(opaque, struct loadparm_context); if (lparm_ctx == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Unable to find loadparm context\n"); return LDB_ERR_OPERATIONS_ERROR; } - opaque = ldb_get_opaque(ac->module->ldb, "templates_ldb"); + opaque = ldb_get_opaque(ldb, "templates_ldb"); templates_ldb = talloc_get_type(opaque, struct ldb_context); /* make sure we have the templates ldb */ if (!templates_ldb) { - templates_ldb_path = samdb_relative_path(ac->module->ldb, ac, + templates_ldb_path = samdb_relative_path(ldb, ac, "templates.ldb"); if (!templates_ldb_path) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "samldb_init_template: ERROR: Failed " "to contruct path for template db"); return LDB_ERR_OPERATIONS_ERROR; } - ev = ldb_get_event_context(ac->module->ldb); + ev = ldb_get_event_context(ldb); - templates_ldb = ldb_wrap_connect(ac->module->ldb, ev, + templates_ldb = ldb_wrap_connect(ldb, ev, lparm_ctx, templates_ldb_path, NULL, NULL, 0, NULL); talloc_free(templates_ldb_path); @@ -243,7 +248,7 @@ static int samldb_search_template(struct samldb_ctx *ac) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_set_opaque(ac->module->ldb, + ret = ldb_set_opaque(ldb, "templates_ldb", templates_ldb); if (ret != LDB_SUCCESS) { return ret; @@ -254,7 +259,7 @@ static int samldb_search_template(struct samldb_ctx *ac) basedn = ldb_dn_new_fmt(ac, templates_ldb, "cn=Template%s,cn=Templates", ac->type); if (basedn == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "samldb_init_template: ERROR: Failed " "to contruct DN for template"); return LDB_ERR_OPERATIONS_ERROR; @@ -279,11 +284,13 @@ static int samldb_search_template(struct samldb_ctx *ac) static int samldb_apply_template(struct samldb_ctx *ac) { + struct ldb_context *ldb; struct ldb_message_element *el; struct ldb_message *msg; int i, j; int ret; + ldb = ldb_module_get_ctx(ac->module); msg = ac->ares->message; for (i = 0; i < msg->num_elements; i++) { @@ -300,10 +307,10 @@ static int samldb_apply_template(struct samldb_ctx *ac) } for (j = 0; j < el->num_values; j++) { ret = samdb_find_or_add_attribute( - ac->module->ldb, ac->msg, el->name, + ldb, ac->msg, el->name, (char *)el->values[j].data); if (ret != LDB_SUCCESS) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Failed adding template attribute\n"); return LDB_ERR_OPERATIONS_ERROR; } @@ -318,11 +325,13 @@ static int samldb_get_parent_domain(struct samldb_ctx *ac); static int samldb_get_parent_domain_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct samldb_ctx *ac; const char *nextRid; int ret; ac = talloc_get_type(req->context, struct samldb_ctx); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { ret = LDB_ERR_OPERATIONS_ERROR; @@ -338,7 +347,7 @@ static int samldb_get_parent_domain_callback(struct ldb_request *req, /* save entry */ if (ac->domain_dn != NULL) { /* one too many! */ - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Invalid number of results while searching " "for domain object"); ret = LDB_ERR_OPERATIONS_ERROR; @@ -348,7 +357,7 @@ static int samldb_get_parent_domain_callback(struct ldb_request *req, nextRid = ldb_msg_find_attr_as_string(ares->message, "nextRid", NULL); if (nextRid == NULL) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "while looking for domain above %s attribute nextRid not found in %s\n", ldb_dn_get_linearized(ac->req->op.add.message->dn), ldb_dn_get_linearized(ares->message->dn)); @@ -361,7 +370,7 @@ static int samldb_get_parent_domain_callback(struct ldb_request *req, ac->domain_sid = samdb_result_dom_sid(ac, ares->message, "objectSid"); if (ac->domain_sid == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "error retrieving parent domain domain sid!\n"); ret = LDB_ERR_CONSTRAINT_VIOLATION; break; @@ -370,7 +379,7 @@ static int samldb_get_parent_domain_callback(struct ldb_request *req, talloc_free(ares); ret = LDB_SUCCESS; - ldb_reset_err_string(ac->module->ldb); + ldb_reset_err_string(ldb); break; case LDB_REPLY_REFERRAL: @@ -403,25 +412,28 @@ done: /* Find a domain object in the parents of a particular DN. */ static int samldb_get_parent_domain(struct samldb_ctx *ac) { + struct ldb_context *ldb; static const char * const attrs[3] = { "objectSid", "nextRid", NULL }; struct ldb_request *req; struct ldb_dn *dn; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (ac->check_dn == NULL) { return LDB_ERR_OPERATIONS_ERROR; } dn = ldb_dn_get_parent(ac, ac->check_dn); if (dn == NULL) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Unable to find parent domain object"); return LDB_ERR_CONSTRAINT_VIOLATION; } ac->check_dn = dn; - ret = ldb_build_search_req(&req, ac->module->ldb, ac, + ret = ldb_build_search_req(&req, ldb, ac, dn, LDB_SCOPE_BASE, "(|(objectClass=domain)" "(objectClass=builtinDomain)" @@ -503,11 +515,14 @@ done: static int samldb_check_samAccountName(struct samldb_ctx *ac) { + struct ldb_context *ldb; struct ldb_request *req; const char *name; char *filter; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (ldb_msg_find_element(ac->msg, "samAccountName") == NULL) { ret = samldb_generate_samAccountName(ac->msg); if (ret != LDB_SUCCESS) { @@ -524,7 +539,7 @@ static int samldb_check_samAccountName(struct samldb_ctx *ac) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&req, ac->module->ldb, ac, + ret = ldb_build_search_req(&req, ldb, ac, ac->domain_dn, LDB_SCOPE_SUBTREE, filter, NULL, NULL, @@ -540,14 +555,17 @@ static int samldb_check_samAccountName(struct samldb_ctx *ac) static int samldb_check_samAccountType(struct samldb_ctx *ac) { + struct ldb_context *ldb; unsigned int account_type; unsigned int group_type; unsigned int uac; int ret; + ldb = ldb_module_get_ctx(ac->module); + /* make sure sAMAccountType is not specified */ if (ldb_msg_find_element(ac->msg, "sAMAccountType") != NULL) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "sAMAccountType must not be specified"); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -555,12 +573,12 @@ static int samldb_check_samAccountType(struct samldb_ctx *ac) if (strcmp("user", ac->type) == 0) { uac = samdb_result_uint(ac->msg, "userAccountControl", 0); if (uac == 0) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "userAccountControl invalid"); return LDB_ERR_UNWILLING_TO_PERFORM; } else { account_type = samdb_uf2atype(uac); - ret = samdb_msg_add_uint(ac->module->ldb, + ret = samdb_msg_add_uint(ldb, ac->msg, ac->msg, "sAMAccountType", account_type); @@ -573,12 +591,12 @@ static int samldb_check_samAccountType(struct samldb_ctx *ac) group_type = samdb_result_uint(ac->msg, "groupType", 0); if (group_type == 0) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "groupType invalid"); return LDB_ERR_UNWILLING_TO_PERFORM; } else { account_type = samdb_gtype2atype(group_type); - ret = samdb_msg_add_uint(ac->module->ldb, + ret = samdb_msg_add_uint(ldb, ac->msg, ac->msg, "sAMAccountType", account_type); @@ -594,11 +612,13 @@ static int samldb_check_samAccountType(struct samldb_ctx *ac) static int samldb_get_sid_domain_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct samldb_ctx *ac; const char *nextRid; int ret; ac = talloc_get_type(req->context, struct samldb_ctx); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { ret = LDB_ERR_OPERATIONS_ERROR; @@ -614,7 +634,7 @@ static int samldb_get_sid_domain_callback(struct ldb_request *req, /* save entry */ if (ac->next_rid != 0) { /* one too many! */ - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Invalid number of results while searching " "for domain object"); ret = LDB_ERR_OPERATIONS_ERROR; @@ -624,7 +644,7 @@ static int samldb_get_sid_domain_callback(struct ldb_request *req, nextRid = ldb_msg_find_attr_as_string(ares->message, "nextRid", NULL); if (nextRid == NULL) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "attribute nextRid not found in %s\n", ldb_dn_get_linearized(ares->message->dn)); ret = LDB_ERR_OPERATIONS_ERROR; @@ -648,7 +668,7 @@ static int samldb_get_sid_domain_callback(struct ldb_request *req, case LDB_REPLY_DONE: if (ac->next_rid == 0) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "Unable to get nextRid from domain entry\n"); ret = LDB_ERR_OPERATIONS_ERROR; break; @@ -670,11 +690,14 @@ done: /* Find a domain object in the parents of a particular DN. */ static int samldb_get_sid_domain(struct samldb_ctx *ac) { + struct ldb_context *ldb; static const char * const attrs[2] = { "nextRid", NULL }; struct ldb_request *req; char *filter; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (ac->sid == NULL) { return LDB_ERR_OPERATIONS_ERROR; } @@ -695,8 +718,8 @@ static int samldb_get_sid_domain(struct samldb_ctx *ac) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&req, ac->module->ldb, ac, - ldb_get_default_basedn(ac->module->ldb), + ret = ldb_build_search_req(&req, ldb, ac, + ldb_get_default_basedn(ldb), LDB_SCOPE_SUBTREE, filter, attrs, NULL, @@ -793,6 +816,7 @@ done: static int samldb_check_sid(struct samldb_ctx *ac) { + struct ldb_context *ldb; const char *const attrs[2] = { "objectSid", NULL }; struct ldb_request *req; char *filter; @@ -802,14 +826,16 @@ static int samldb_check_sid(struct samldb_ctx *ac) return LDB_ERR_OPERATIONS_ERROR; } + ldb = ldb_module_get_ctx(ac->module); + filter = talloc_asprintf(ac, "(objectSid=%s)", ldap_encode_ndr_dom_sid(ac, ac->sid)); if (filter == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&req, ac->module->ldb, ac, - ldb_get_default_basedn(ac->module->ldb), + ret = ldb_build_search_req(&req, ldb, ac, + ldb_get_default_basedn(ldb), LDB_SCOPE_SUBTREE, filter, attrs, NULL, @@ -826,10 +852,12 @@ static int samldb_check_sid(struct samldb_ctx *ac) static int samldb_notice_sid_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct samldb_ctx *ac; int ret; ac = talloc_get_type(req->context, struct samldb_ctx); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { ret = LDB_ERR_OPERATIONS_ERROR; @@ -840,7 +868,7 @@ static int samldb_notice_sid_callback(struct ldb_request *req, ares->response, ares->error); } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Invalid reply type!\n"); ret = LDB_ERR_OPERATIONS_ERROR; goto done; @@ -861,6 +889,7 @@ done: *atomically. */ static int samldb_notice_sid(struct samldb_ctx *ac) { + struct ldb_context *ldb; uint32_t old_id, new_id; struct ldb_request *req; struct ldb_message *msg; @@ -868,6 +897,7 @@ static int samldb_notice_sid(struct samldb_ctx *ac) struct ldb_val *vals; int ret; + ldb = ldb_module_get_ctx(ac->module); old_id = ac->next_rid; new_id = ac->sid->sub_auths[ac->sid->num_auths - 1]; @@ -880,17 +910,17 @@ static int samldb_notice_sid(struct samldb_ctx *ac) a race, in case we are not actually on a transaction db */ msg = talloc_zero(ac, struct ldb_message); if (msg == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } els = talloc_array(msg, struct ldb_message_element, 2); if (els == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } vals = talloc_array(msg, struct ldb_val, 2); if (vals == NULL) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } msg->dn = ac->domain_dn; @@ -902,7 +932,7 @@ static int samldb_notice_sid(struct samldb_ctx *ac) els[0].flags = LDB_FLAG_MOD_DELETE; els[0].name = talloc_strdup(msg, "nextRid"); if (!els[0].name) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -913,19 +943,19 @@ static int samldb_notice_sid(struct samldb_ctx *ac) vals[0].data = (uint8_t *)talloc_asprintf(vals, "%u", old_id); if (!vals[0].data) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } vals[0].length = strlen((char *)vals[0].data); vals[1].data = (uint8_t *)talloc_asprintf(vals, "%u", new_id); if (!vals[1].data) { - ldb_oom(ac->module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } vals[1].length = strlen((char *)vals[1].data); - ret = ldb_build_mod_req(&req, ac->module->ldb, ac, + ret = ldb_build_mod_req(&req, ldb, ac, msg, NULL, ac, samldb_notice_sid_callback, ac->req); @@ -939,9 +969,11 @@ static int samldb_notice_sid(struct samldb_ctx *ac) static int samldb_add_entry_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct samldb_ctx *ac; ac = talloc_get_type(req->context, struct samldb_ctx); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -952,7 +984,7 @@ static int samldb_add_entry_callback(struct ldb_request *req, ares->response, ares->error); } if (ares->type != LDB_REPLY_DONE) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Invalid reply type!\n"); return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR); @@ -965,10 +997,13 @@ static int samldb_add_entry_callback(struct ldb_request *req, static int samldb_add_entry(struct samldb_ctx *ac) { + struct ldb_context *ldb; struct ldb_request *req; int ret; - ret = ldb_build_add_req(&req, ac->module->ldb, ac, + ldb = ldb_module_get_ctx(ac->module); + + ret = ldb_build_add_req(&req, ldb, ac, ac->msg, ac->req->controls, ac, samldb_add_entry_callback, @@ -1037,12 +1072,14 @@ static int samldb_fill_object(struct samldb_ctx *ac, const char *type) static int samldb_foreign_notice_sid_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct samldb_ctx *ac; const char *nextRid; const char *name; int ret; ac = talloc_get_type(req->context, struct samldb_ctx); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { ret = LDB_ERR_OPERATIONS_ERROR; @@ -1058,7 +1095,7 @@ static int samldb_foreign_notice_sid_callback(struct ldb_request *req, /* save entry */ if (ac->next_rid != 0) { /* one too many! */ - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "Invalid number of results while searching " "for domain object"); ret = LDB_ERR_OPERATIONS_ERROR; @@ -1068,7 +1105,7 @@ static int samldb_foreign_notice_sid_callback(struct ldb_request *req, nextRid = ldb_msg_find_attr_as_string(ares->message, "nextRid", NULL); if (nextRid == NULL) { - ldb_asprintf_errstring(ac->module->ldb, + ldb_asprintf_errstring(ldb, "while looking for forign sid %s attribute nextRid not found in %s\n", dom_sid_string(ares, ac->sid), ldb_dn_get_linearized(ares->message->dn)); ret = LDB_ERR_OPERATIONS_ERROR; @@ -1080,7 +1117,7 @@ static int samldb_foreign_notice_sid_callback(struct ldb_request *req, ac->domain_dn = talloc_steal(ac, ares->message->dn); name = samdb_result_string(ares->message, "name", NULL); - ldb_debug(ac->module->ldb, LDB_DEBUG_TRACE, + ldb_debug(ldb, LDB_DEBUG_TRACE, "NOTE (strange but valid): Adding foreign SID " "record with SID %s, but this domain (%s) is " "not foreign in the database", @@ -1118,12 +1155,15 @@ done: /* Find a domain object in the parents of a particular DN. */ static int samldb_foreign_notice_sid(struct samldb_ctx *ac) { + struct ldb_context *ldb; static const char * const attrs[3] = { "nextRid", "name", NULL }; struct ldb_request *req; NTSTATUS status; char *filter; int ret; + ldb = ldb_module_get_ctx(ac->module); + if (ac->sid == NULL) { return LDB_ERR_OPERATIONS_ERROR; } @@ -1139,8 +1179,8 @@ static int samldb_foreign_notice_sid(struct samldb_ctx *ac) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_build_search_req(&req, ac->module->ldb, ac, - ldb_get_default_basedn(ac->module->ldb), + ret = ldb_build_search_req(&req, ldb, ac, + ldb_get_default_basedn(ldb), LDB_SCOPE_SUBTREE, filter, attrs, NULL, @@ -1157,14 +1197,17 @@ static int samldb_foreign_notice_sid(struct samldb_ctx *ac) static int samldb_fill_foreignSecurityPrincipal_object(struct samldb_ctx *ac) { + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(ac->module); + ac->sid = samdb_result_dom_sid(ac->msg, ac->msg, "objectSid"); if (ac->sid == NULL) { ac->sid = dom_sid_parse_talloc(ac->msg, (const char *)ldb_dn_get_rdn_val(ac->msg->dn)->data); if (!ac->sid) { - ldb_set_errstring(ac->module->ldb, + ldb_set_errstring(ldb, "No valid found SID in " "ForeignSecurityPrincipal CN!"); talloc_free(ac); @@ -1202,12 +1245,14 @@ static int samldb_fill_foreignSecurityPrincipal_object(struct samldb_ctx *ac) static int samldb_check_rdn(struct ldb_module *module, struct ldb_dn *dn) { + struct ldb_context *ldb; const char *rdn_name; + ldb = ldb_module_get_ctx(module); rdn_name = ldb_dn_get_rdn_name(dn); if (strcasecmp(rdn_name, "cn") != 0) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "Bad RDN (%s=) for samldb object, " "should be CN=!\n", rdn_name); return LDB_ERR_CONSTRAINT_VIOLATION; @@ -1219,10 +1264,12 @@ static int samldb_check_rdn(struct ldb_module *module, struct ldb_dn *dn) /* add_record */ static int samldb_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct samldb_ctx *ac; int ret; - ldb_debug(module->ldb, LDB_DEBUG_TRACE, "samldb_add_record\n"); + ldb = ldb_module_get_ctx(module); + ldb_debug(ldb, LDB_DEBUG_TRACE, "samldb_add_record\n"); /* do not manipulate our control entries */ if (ldb_dn_is_special(req->op.add.message->dn)) { @@ -1238,17 +1285,17 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) ac->msg = ldb_msg_copy(ac, ac->req->op.add.message); if (!ac->msg) { talloc_free(ac); - ldb_debug(ac->module->ldb, LDB_DEBUG_FATAL, + ldb_debug(ldb, LDB_DEBUG_FATAL, "samldb_add: ldb_msg_copy failed!\n"); return LDB_ERR_OPERATIONS_ERROR; } - if (samdb_find_attribute(module->ldb, ac->msg, + if (samdb_find_attribute(ldb, ac->msg, "objectclass", "computer") != NULL) { /* make sure the computer object also has the 'user' * objectclass so it will be handled by the next call */ - ret = samdb_find_or_add_value(module->ldb, ac->msg, + ret = samdb_find_or_add_value(ldb, ac->msg, "objectclass", "user"); if (ret != LDB_SUCCESS) { talloc_free(ac); @@ -1256,7 +1303,7 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) } } - if (samdb_find_attribute(module->ldb, ac->msg, + if (samdb_find_attribute(ldb, ac->msg, "objectclass", "user") != NULL) { ret = samldb_check_rdn(module, ac->req->op.add.message->dn); @@ -1268,7 +1315,7 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) return samldb_fill_object(ac, "user"); } - if (samdb_find_attribute(module->ldb, ac->msg, + if (samdb_find_attribute(ldb, ac->msg, "objectclass", "group") != NULL) { ret = samldb_check_rdn(module, ac->req->op.add.message->dn); @@ -1281,7 +1328,7 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) } /* perhaps a foreignSecurityPrincipal? */ - if (samdb_find_attribute(module->ldb, ac->msg, + if (samdb_find_attribute(ldb, ac->msg, "objectclass", "foreignSecurityPrincipal") != NULL) { @@ -1303,6 +1350,7 @@ static int samldb_add(struct ldb_module *module, struct ldb_request *req) /* modify */ static int samldb_modify(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_message *msg; struct ldb_message_element *el, *el2; int ret; @@ -1311,8 +1359,10 @@ static int samldb_modify(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } + ldb = ldb_module_get_ctx(module); + if (ldb_msg_find_element(req->op.mod.message, "sAMAccountType") != NULL) { - ldb_asprintf_errstring(module->ldb, "sAMAccountType must not be specified"); + ldb_asprintf_errstring(ldb, "sAMAccountType must not be specified"); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -1324,7 +1374,7 @@ static int samldb_modify(struct ldb_module *module, struct ldb_request *req) group_type = strtoul((const char *)el->values[0].data, NULL, 0); account_type = samdb_gtype2atype(group_type); - ret = samdb_msg_add_uint(module->ldb, msg, msg, + ret = samdb_msg_add_uint(ldb, msg, msg, "sAMAccountType", account_type); if (ret != LDB_SUCCESS) { @@ -1340,7 +1390,7 @@ static int samldb_modify(struct ldb_module *module, struct ldb_request *req) user_account_control = strtoul((const char *)el->values[0].data, NULL, 0); account_type = samdb_uf2atype(user_account_control); - ret = samdb_msg_add_uint(module->ldb, msg, msg, + ret = samdb_msg_add_uint(ldb, msg, msg, "sAMAccountType", account_type); if (ret != LDB_SUCCESS) { diff --git a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c index bfcf239f3a..a134a3d4d0 100644 --- a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c @@ -22,14 +22,11 @@ */ #include "includes.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb_private.h" +#include "ldb_module.h" #include "dsdb/samdb/samdb.h" #include "librpc/gen_ndr/ndr_misc.h" #include "librpc/gen_ndr/ndr_drsuapi.h" #include "librpc/gen_ndr/ndr_drsblobs.h" -#include "../lib/util/dlinklist.h" #include "param/param.h" static int generate_objectClasses(struct ldb_context *ldb, struct ldb_message *msg, @@ -82,6 +79,7 @@ struct schema_fsmo_search_data { static int schema_fsmo_init(struct ldb_module *module) { + struct ldb_context *ldb; TALLOC_CTX *mem_ctx; struct ldb_dn *schema_dn; struct dsdb_schema *schema; @@ -89,53 +87,54 @@ static int schema_fsmo_init(struct ldb_module *module) int ret; struct schema_fsmo_private_data *data; - schema_dn = samdb_schema_dn(module->ldb); + ldb = ldb_module_get_ctx(module); + schema_dn = samdb_schema_dn(ldb); if (!schema_dn) { - ldb_reset_err_string(module->ldb); - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_reset_err_string(ldb); + ldb_debug(ldb, LDB_DEBUG_WARNING, "schema_fsmo_init: no schema dn present: (skip schema loading)\n"); return ldb_next_init(module); } data = talloc(module, struct schema_fsmo_private_data); if (data == NULL) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } /* Check to see if this is a result on the CN=Aggregate schema */ data->aggregate_dn = ldb_dn_copy(data, schema_dn); if (!ldb_dn_add_child_fmt(data->aggregate_dn, "CN=Aggregate")) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - module->private_data = data; + ldb_module_set_private(module, data); - if (dsdb_get_schema(module->ldb)) { + if (dsdb_get_schema(ldb)) { return ldb_next_init(module); } mem_ctx = talloc_new(module); if (!mem_ctx) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = dsdb_schema_from_schema_dn(mem_ctx, module->ldb, - lp_iconv_convenience(ldb_get_opaque(module->ldb, "loadparm")), + ret = dsdb_schema_from_schema_dn(mem_ctx, ldb, + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), schema_dn, &schema, &error_string); if (ret == LDB_ERR_NO_SUCH_OBJECT) { - ldb_reset_err_string(module->ldb); - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_reset_err_string(ldb); + ldb_debug(ldb, LDB_DEBUG_WARNING, "schema_fsmo_init: no schema head present: (skip schema loading)\n"); talloc_free(mem_ctx); return ldb_next_init(module); } if (ret != LDB_SUCCESS) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "schema_fsmo_init: dsdb_schema load failed: %s", error_string); talloc_free(mem_ctx); @@ -143,9 +142,9 @@ static int schema_fsmo_init(struct ldb_module *module) } /* dsdb_set_schema() steal schema into the ldb_context */ - ret = dsdb_set_schema(module->ldb, schema); + ret = dsdb_set_schema(ldb, schema); if (ret != LDB_SUCCESS) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "schema_fsmo_init: dsdb_set_schema() failed: %d:%s", ret, ldb_strerror(ret)); talloc_free(mem_ctx); @@ -158,6 +157,7 @@ static int schema_fsmo_init(struct ldb_module *module) static int schema_fsmo_add(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct dsdb_schema *schema; const char *attributeID = NULL; const char *governsID = NULL; @@ -166,6 +166,8 @@ static int schema_fsmo_add(struct ldb_module *module, struct ldb_request *req) uint32_t id32; WERROR status; + ldb = ldb_module_get_ctx(module); + /* special objects should always go through */ if (ldb_dn_is_special(req->op.add.message->dn)) { return ldb_next_request(module, req); @@ -176,13 +178,13 @@ static int schema_fsmo_add(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - schema = dsdb_get_schema(module->ldb); + schema = dsdb_get_schema(ldb); if (!schema) { return ldb_next_request(module, req); } if (!schema->fsmo.we_are_master) { - ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, + ldb_debug_set(ldb, LDB_DEBUG_ERROR, "schema_fsmo_add: we are not master: reject request\n"); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -206,15 +208,15 @@ static int schema_fsmo_add(struct ldb_module *module, struct ldb_request *req) if (W_ERROR_IS_OK(status)) { return ldb_next_request(module, req); } else if (!W_ERROR_EQUAL(WERR_DS_NO_MSDS_INTID, status)) { - ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, + ldb_debug_set(ldb, LDB_DEBUG_ERROR, "schema_fsmo_add: failed to map %s[%s]: %s\n", oid_attr, oid, win_errstr(status)); return LDB_ERR_UNWILLING_TO_PERFORM; } - status = dsdb_create_prefix_mapping(module->ldb, schema, oid); + status = dsdb_create_prefix_mapping(ldb, schema, oid); if (!W_ERROR_IS_OK(status)) { - ldb_debug_set(module->ldb, LDB_DEBUG_ERROR, + ldb_debug_set(ldb, LDB_DEBUG_ERROR, "schema_fsmo_add: failed to create prefix mapping for %s[%s]: %s\n", oid_attr, oid, win_errstr(status)); return LDB_ERR_UNWILLING_TO_PERFORM; @@ -225,44 +227,47 @@ static int schema_fsmo_add(struct ldb_module *module, struct ldb_request *req) static int schema_fsmo_extended(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_dn *schema_dn; struct dsdb_schema *schema; char *error_string = NULL; int ret; TALLOC_CTX *mem_ctx; - + + ldb = ldb_module_get_ctx(module); + if (strcmp(req->op.extended.oid, DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID) != 0) { return ldb_next_request(module, req); } - schema_dn = samdb_schema_dn(module->ldb); + schema_dn = samdb_schema_dn(ldb); if (!schema_dn) { - ldb_reset_err_string(module->ldb); - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_reset_err_string(ldb); + ldb_debug(ldb, LDB_DEBUG_WARNING, "schema_fsmo_extended: no schema dn present: (skip schema loading)\n"); return ldb_next_request(module, req); } mem_ctx = talloc_new(module); if (!mem_ctx) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = dsdb_schema_from_schema_dn(mem_ctx, module->ldb, - lp_iconv_convenience(ldb_get_opaque(module->ldb, "loadparm")), + ret = dsdb_schema_from_schema_dn(mem_ctx, ldb, + lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), schema_dn, &schema, &error_string); if (ret == LDB_ERR_NO_SUCH_OBJECT) { - ldb_reset_err_string(module->ldb); - ldb_debug(module->ldb, LDB_DEBUG_WARNING, + ldb_reset_err_string(ldb); + ldb_debug(ldb, LDB_DEBUG_WARNING, "schema_fsmo_extended: no schema head present: (skip schema loading)\n"); talloc_free(mem_ctx); return ldb_next_request(module, req); } if (ret != LDB_SUCCESS) { - ldb_asprintf_errstring(module->ldb, + ldb_asprintf_errstring(ldb, "schema_fsmo_extended: dsdb_schema load failed: %s", error_string); talloc_free(mem_ctx); @@ -270,9 +275,9 @@ static int schema_fsmo_extended(struct ldb_module *module, struct ldb_request *r } /* Replace the old schema*/ - ret = dsdb_set_schema(module->ldb, schema); + ret = dsdb_set_schema(ldb, schema); if (ret != LDB_SUCCESS) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "schema_fsmo_extended: dsdb_set_schema() failed: %d:%s", ret, ldb_strerror(ret)); talloc_free(mem_ctx); @@ -385,12 +390,14 @@ static int generate_extendedClassInfo(struct ldb_context *ldb, */ static int schema_fsmo_search_callback(struct ldb_request *req, struct ldb_reply *ares) { + struct ldb_context *ldb; struct schema_fsmo_search_data *ac; struct schema_fsmo_private_data *mc; int i, ret; ac = talloc_get_type(req->context, struct schema_fsmo_search_data); - mc = talloc_get_type(ac->module->private_data, struct schema_fsmo_private_data); + mc = talloc_get_type(ldb_module_get_private(ac->module), struct schema_fsmo_private_data); + ldb = ldb_module_get_ctx(ac->module); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -411,7 +418,7 @@ static int schema_fsmo_search_callback(struct ldb_request *req, struct ldb_reply for (i=0; i < ARRAY_SIZE(generated_attrs); i++) { if (ldb_attr_in_list(ac->req->op.search.attrs, generated_attrs[i].attr)) { - ret = generated_attrs[i].fn(ac->module->ldb, ares->message, ac->schema); + ret = generated_attrs[i].fn(ldb, ares->message, ac->schema); if (ret != LDB_SUCCESS) { return ret; } @@ -436,12 +443,13 @@ static int schema_fsmo_search_callback(struct ldb_request *req, struct ldb_reply /* search */ static int schema_fsmo_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb = ldb_module_get_ctx(module); int i, ret; struct schema_fsmo_search_data *search_context; struct ldb_request *down_req; - struct dsdb_schema *schema = dsdb_get_schema(module->ldb); + struct dsdb_schema *schema = dsdb_get_schema(ldb); - if (!schema || !module->private_data) { + if (!schema || !ldb_module_get_private(module)) { /* If there is no schema, there is little we can do */ return ldb_next_request(module, req); } @@ -458,7 +466,7 @@ static int schema_fsmo_search(struct ldb_module *module, struct ldb_request *req search_context = talloc(req, struct schema_fsmo_search_data); if (!search_context) { - ldb_oom(module->ldb); + ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -466,7 +474,7 @@ static int schema_fsmo_search(struct ldb_module *module, struct ldb_request *req search_context->req = req; search_context->schema = schema; - ret = ldb_build_search_req_ex(&down_req, module->ldb, search_context, + ret = ldb_build_search_req_ex(&down_req, ldb, search_context, req->op.search.base, req->op.search.scope, req->op.search.tree, diff --git a/source4/dsdb/samdb/ldb_modules/show_deleted.c b/source4/dsdb/samdb/ldb_modules/show_deleted.c index 0914e51ebe..d619558c21 100644 --- a/source4/dsdb/samdb/ldb_modules/show_deleted.c +++ b/source4/dsdb/samdb/ldb_modules/show_deleted.c @@ -33,9 +33,7 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_errors.h" -#include "ldb/include/ldb_private.h" +#include "ldb/include/ldb_module.h" #include "dsdb/samdb/samdb.h" /* search */ @@ -79,6 +77,7 @@ static int show_deleted_search_callback(struct ldb_request *req, static int show_deleted_search(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; struct ldb_control *control; struct ldb_control **saved_controls; struct show_deleted_search_request *ar; @@ -87,6 +86,8 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re char *new_filter; int ret; + ldb = ldb_module_get_ctx(module); + ar = talloc_zero(req, struct show_deleted_search_request); if (ar == NULL) { return LDB_ERR_OPERATIONS_ERROR; @@ -102,7 +103,7 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re new_filter = talloc_asprintf(ar, "(&(!(isDeleted=TRUE))%s)", old_filter); - ret = ldb_build_search_req(&down_req, module->ldb, ar, + ret = ldb_build_search_req(&down_req, ldb, ar, req->op.search.base, req->op.search.scope, new_filter, @@ -112,7 +113,7 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re req); } else { - ret = ldb_build_search_req_ex(&down_req, module->ldb, ar, + ret = ldb_build_search_req_ex(&down_req, ldb, ar, req->op.search.base, req->op.search.scope, req->op.search.tree, @@ -136,11 +137,14 @@ static int show_deleted_search(struct ldb_module *module, struct ldb_request *re static int show_deleted_init(struct ldb_module *module) { + struct ldb_context *ldb; int ret; + ldb = ldb_module_get_ctx(module); + ret = ldb_mod_register_control(module, LDB_CONTROL_SHOW_DELETED_OID); if (ret != LDB_SUCCESS) { - ldb_debug(module->ldb, LDB_DEBUG_ERROR, + ldb_debug(ldb, LDB_DEBUG_ERROR, "extended_dn: Unable to register control with rootdse!\n"); return LDB_ERR_OPERATIONS_ERROR; } diff --git a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c index 0e42f7869a..948241b094 100644 --- a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c +++ b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c @@ -27,9 +27,7 @@ */ #include "includes.h" -#include "ldb/include/ldb.h" -#include "ldb/include/ldb_private.h" -#include "ldb/include/ldb_errors.h" +#include "ldb/include/ldb_module.h" #include "ldb/ldb_map/ldb_map.h" #include "librpc/gen_ndr/ndr_misc.h" @@ -105,7 +103,7 @@ static struct ldb_val guid_ns_string(struct ldb_module *module, TALLOC_CTX *ctx, static struct ldb_val val_copy(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) { struct ldb_val out = data_blob(NULL, 0); - ldb_handler_copy(module->ldb, ctx, val, &out); + out = ldb_val_dup(ctx, val); return out; } @@ -113,10 +111,11 @@ static struct ldb_val val_copy(struct ldb_module *module, TALLOC_CTX *ctx, const /* Ensure we always convert sids into binary, so the backend doesn't have to know about both forms */ static struct ldb_val sid_always_binary(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) { + struct ldb_context *ldb = ldb_module_get_ctx(module); struct ldb_val out = data_blob(NULL, 0); - const struct ldb_schema_attribute *a = ldb_schema_attribute_by_name(module->ldb, "objectSid"); + const struct ldb_schema_attribute *a = ldb_schema_attribute_by_name(ldb, "objectSid"); - if (a->syntax->canonicalise_fn(module->ldb, ctx, val, &out) != LDB_SUCCESS) { + if (a->syntax->canonicalise_fn(ldb, ctx, val, &out) != LDB_SUCCESS) { return data_blob(NULL, 0); } @@ -126,18 +125,19 @@ static struct ldb_val sid_always_binary(struct ldb_module *module, TALLOC_CTX *c /* Ensure we always convert objectCategory into a DN */ static struct ldb_val objectCategory_always_dn(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val) { + struct ldb_context *ldb = ldb_module_get_ctx(module); struct ldb_dn *dn; struct ldb_val out = data_blob(NULL, 0); - const struct ldb_schema_attribute *a = ldb_schema_attribute_by_name(module->ldb, "objectCategory"); + const struct ldb_schema_attribute *a = ldb_schema_attribute_by_name(ldb, "objectCategory"); - dn = ldb_dn_from_ldb_val(ctx, module->ldb, val); + dn = ldb_dn_from_ldb_val(ctx, ldb, val); if (dn && ldb_dn_validate(dn)) { talloc_free(dn); return val_copy(module, ctx, val); } talloc_free(dn); - if (a->syntax->canonicalise_fn(module->ldb, ctx, val, &out) != LDB_SUCCESS) { + if (a->syntax->canonicalise_fn(ldb, ctx, val, &out) != LDB_SUCCESS) { return data_blob(NULL, 0); } @@ -603,6 +603,7 @@ static int get_seq_callback(struct ldb_request *req, static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; int ret; struct map_private *map_private; struct entryuuid_private *entryuuid_private; @@ -620,16 +621,18 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque struct ldb_seqnum_result *seqr; struct ldb_extended *ext; + ldb = ldb_module_get_ctx(module); + seq = talloc_get_type(req->op.extended.data, struct ldb_seqnum_request); - map_private = talloc_get_type(module->private_data, struct map_private); + map_private = talloc_get_type(ldb_module_get_private(module), struct map_private); entryuuid_private = talloc_get_type(map_private->caller_private, struct entryuuid_private); /* All this to get the DN of the parition, so we can search the right thing */ partition_ctrl = ldb_request_get_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID); if (!partition_ctrl) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "entryuuid_sequence_number: no current partition control found"); return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -638,7 +641,7 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque struct dsdb_control_current_partition); SMB_ASSERT(partition && partition->version == DSDB_CONTROL_CURRENT_PARTITION_VERSION); - ret = ldb_build_search_req(&search_req, module->ldb, req, + ret = ldb_build_search_req(&search_req, ldb, req, partition->dn, LDB_SCOPE_BASE, NULL, contextCSN_attr, NULL, &seq_num, get_seq_callback, diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index d0aae4e221..d6b3e40e1a 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -22,9 +22,7 @@ #include "includes.h" #include "dsdb/samdb/samdb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb_private.h" -#include "../lib/util/dlinklist.h" +#include "lib/ldb/include/ldb_module.h" #include "param/param.h" diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 68146499af..6990397a74 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -695,6 +695,9 @@ enum ldb_sequence_type { LDB_SEQ_NEXT }; +#define LDB_SEQ_GLOBAL_SEQUENCE 0x01 +#define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02 + struct ldb_seqnum_request { enum ldb_sequence_type type; }; diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 10977088e5..2e6590860f 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -160,9 +160,6 @@ char *ldb_casefold_default(void *context, void *mem_ctx, const char *s, size_t n void ldb_dump_results(struct ldb_context *ldb, struct ldb_result *result, FILE *f); -#define LDB_SEQ_GLOBAL_SEQUENCE 0x01 -#define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02 - /* The following definitions come from lib/ldb/common/ldb_modules.c */ diff --git a/source4/nbt_server/wins/wins_ldb.c b/source4/nbt_server/wins/wins_ldb.c index 7effb9b842..93382d7ddc 100644 --- a/source4/nbt_server/wins/wins_ldb.c +++ b/source4/nbt_server/wins/wins_ldb.c @@ -31,16 +31,15 @@ #include "lib/events/events.h" #include "nbt_server/nbt_server.h" #include "nbt_server/wins/winsdb.h" -#include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "lib/ldb/include/ldb_private.h" +#include "lib/ldb/include/ldb_module.h" #include "system/network.h" #include "lib/socket/netif.h" #include "param/param.h" static int wins_ldb_verify(struct ldb_module *module, struct ldb_request *req) { - struct winsdb_handle *h = talloc_get_type(ldb_get_opaque(module->ldb, "winsdb_handle"), + struct ldb_context *ldb = ldb_module_get_ctx(module); + struct winsdb_handle *h = talloc_get_type(ldb_get_opaque(ldb, "winsdb_handle"), struct winsdb_handle); const struct ldb_message *msg; @@ -63,7 +62,7 @@ static int wins_ldb_verify(struct ldb_module *module, struct ldb_request *req) } if (!h) { - ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, "%s", "WINS_LDB: INTERNAL ERROR: no winsdb_handle present!"); + ldb_debug_set(ldb, LDB_DEBUG_FATAL, "%s", "WINS_LDB: INTERNAL ERROR: no winsdb_handle present!"); return LDB_ERR_OTHER; } @@ -74,39 +73,40 @@ static int wins_ldb_verify(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); case WINSDB_HANDLE_CALLER_ADMIN: - ldb_debug(module->ldb, LDB_DEBUG_WARNING, "%s\n", "WINS_LDB: TODO verify add/modify for WINSDB_HANDLE_CALLER_ADMIN"); + ldb_debug(ldb, LDB_DEBUG_WARNING, "%s\n", "WINS_LDB: TODO verify add/modify for WINSDB_HANDLE_CALLER_ADMIN"); return ldb_next_request(module, req); } return LDB_ERR_OTHER; } -static int wins_ldb_init(struct ldb_module *ctx) +static int wins_ldb_init(struct ldb_module *module) { + struct ldb_context *ldb = ldb_module_get_ctx(module); struct winsdb_handle *h; const char *owner; - struct loadparm_context *lp_ctx = ldb_get_opaque(ctx->ldb, "loadparm"); + struct loadparm_context *lp_ctx = ldb_get_opaque(ldb, "loadparm"); - ctx->private_data = NULL; + ldb_module_set_private(module, NULL); owner = lp_parm_string(lp_ctx, NULL, "winsdb", "local_owner"); if (!owner) { struct interface *ifaces; - load_interfaces(ctx, lp_interfaces(lp_ctx), &ifaces); + load_interfaces(module, lp_interfaces(lp_ctx), &ifaces); owner = iface_n_ip(ifaces, 0); if (!owner) { owner = "0.0.0.0"; } } - h = talloc_zero(ctx, struct winsdb_handle); + h = talloc_zero(module, struct winsdb_handle); if (!h) goto failed; - h->ldb = ctx->ldb; + h->ldb = ldb; h->caller = WINSDB_HANDLE_CALLER_ADMIN; h->local_owner = talloc_strdup(h, owner); if (!h->local_owner) goto failed; - return ldb_set_opaque(ctx->ldb, "winsdb_handle", h); + return ldb_set_opaque(ldb, "winsdb_handle", h); failed: talloc_free(h); -- cgit From 2c2545d45af9c7479bf032fff1263e102926a495 Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Fri, 30 Jan 2009 13:53:33 -0800 Subject: s3 build: Remove unused fstat check to fix a bunch of HAVE_FSTAT warnings --- lib/tdb/pytdb.c | 4 ---- source3/configure.in | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c index 60aae9fd86..159bc4dce5 100644 --- a/lib/tdb/pytdb.c +++ b/lib/tdb/pytdb.c @@ -32,10 +32,6 @@ #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None #endif -#ifdef HAVE_FSTAT -#undef HAVE_FSTAT -#endif - /* Include tdb headers */ #include diff --git a/source3/configure.in b/source3/configure.in index 3ae2c8c9d3..615ab9e19f 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -1027,7 +1027,7 @@ fi AC_CHECK_FUNCS(getcwd fchown chmod fchmod mknod mknod64) AC_CHECK_FUNCS(strtol) -AC_CHECK_FUNCS(fstat strchr chflags) +AC_CHECK_FUNCS(strchr chflags) AC_CHECK_FUNCS(getrlimit fsync fdatasync setpgid) AC_CHECK_FUNCS(setsid glob strpbrk crypt16 getauthuid) AC_CHECK_FUNCS(sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent) -- cgit From 15cfc38c255c8caa098ca57774d1ee74b306c813 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 30 Jan 2009 18:17:47 -0500 Subject: Bump up ldb version to 0.9.3 after latest changes --- source4/lib/ldb/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/lib/ldb/configure.ac b/source4/lib/ldb/configure.ac index 7bc081cfe5..d61b31afd4 100644 --- a/source4/lib/ldb/configure.ac +++ b/source4/lib/ldb/configure.ac @@ -11,7 +11,7 @@ AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""]) AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""]) AC_DEFUN([SMB_EXT_LIB], [echo -n ""]) AC_DEFUN([SMB_ENABLE], [echo -n ""]) -AC_INIT(ldb, 0.9.2) +AC_INIT(ldb, 0.9.3) AC_CONFIG_SRCDIR([common/ldb.c]) AC_LIBREPLACE_ALL_CHECKS -- cgit From 8b7a1394aae8c59adb04a8cfc5e38ae0cb4462ab Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Fri, 30 Jan 2009 15:19:55 -0800 Subject: s3 onefs: Fix onefs ACLs to work with updated ACL syscall --- source3/modules/onefs_acl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/modules/onefs_acl.c b/source3/modules/onefs_acl.c index b9ec2d68e0..14b27b80e0 100644 --- a/source3/modules/onefs_acl.c +++ b/source3/modules/onefs_acl.c @@ -667,7 +667,7 @@ onefs_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, } error = ifs_get_security_descriptor(fsp->fh->fd, security_info, - &sd_size, sd); + sd_size, &sd_size, sd); if (error && (errno != EMSGSIZE)) { DEBUG(0, ("Failed getting size of security descriptor! " "errno=%d\n", errno)); -- cgit From 7acea5a032e1c1fa14a5b414992d0f8f0a45a9f2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 30 Jan 2009 20:10:45 -0500 Subject: Fix proxy module --- source4/dsdb/samdb/ldb_modules/proxy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/proxy.c b/source4/dsdb/samdb/ldb_modules/proxy.c index 9a5091ce90..72b47c308d 100644 --- a/source4/dsdb/samdb/ldb_modules/proxy.c +++ b/source4/dsdb/samdb/ldb_modules/proxy.c @@ -62,7 +62,7 @@ struct proxy_ctx { */ static int load_proxy_info(struct ldb_module *module) { - struct ldb = ldb_module_get_ctx(module); + struct ldb_context *ldb = ldb_module_get_ctx(module); struct proxy_data *proxy = talloc_get_type(ldb_module_get_private(module), struct proxy_data); struct ldb_dn *dn; struct ldb_result *res = NULL; @@ -262,7 +262,7 @@ static int proxy_search_callback(struct ldb_request *req, ac = talloc_get_type(req->context, struct proxy_ctx); ldb = ldb_module_get_ctx(ac->module); - proxy = talloc_get_type(private_data, struct proxy_data); + proxy = talloc_get_type(ldb_module_get_private(module), struct proxy_data); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, -- cgit From de4f7c0787498ba0030b67a98a5361900775fca1 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 30 Jan 2009 20:11:16 -0500 Subject: Do not install private headers --- lib/tevent/tevent.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/tevent/tevent.mk b/lib/tevent/tevent.mk index be7e298218..ac5710ff05 100644 --- a/lib/tevent/tevent.mk +++ b/lib/tevent/tevent.mk @@ -22,8 +22,6 @@ installdirs:: installheaders:: installdirs cp $(srcdir)/tevent.h $(DESTDIR)$(includedir) - cp $(srcdir)/tevent_internal.h $(DESTDIR)$(includedir) - cp $(srcdir)/tevent_util.h $(DESTDIR)$(includedir) installlibs:: installdirs cp tevent.pc $(DESTDIR)$(libdir)/pkgconfig -- cgit From 0498a30b223861a9ea10c75848387755ddedd411 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 30 Jan 2009 20:11:37 -0500 Subject: Install mising public headers --- source4/lib/ldb/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in index 6313fc1622..7f00e8ebee 100644 --- a/source4/lib/ldb/Makefile.in +++ b/source4/lib/ldb/Makefile.in @@ -67,7 +67,7 @@ MDLD_FLAGS = @MDLD_FLAGS@ OBJS = $(MODULES_OBJ) $(COMMON_OBJ) $(LDB_TDB_OBJ) $(TDB_OBJ) $(TEVENT_OBJ) $(TALLOC_OBJ) $(POPT_OBJ) $(LDB_MAP_OBJ) @LIBREPLACEOBJ@ $(EXTRA_OBJ) -headers = $(srcdir)/include/ldb.h $(srcdir)/include/ldb_errors.h $(srcdir)/include/ldb_handlers.h +headers = $(srcdir)/include/ldb.h $(srcdir)/include/ldb_errors.h $(srcdir)/include/ldb_handlers.h $(srcdir)/include/ldb_includes.h $(srcdir)/include/ldb_module.h BINS = bin/ldbadd bin/ldbsearch bin/ldbdel bin/ldbmodify bin/ldbedit bin/ldbrename bin/ldbtest -- cgit From 0245b9b97363f08786c25d4412ed293ca6f94cd5 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 30 Jan 2009 20:12:16 -0500 Subject: Explicitly include ldb_handlers.h where necessary --- source4/lib/ldb-samba/ldif_handlers.c | 1 + source4/lib/ldb/common/ldb_attributes.c | 1 + source4/lib/ldb/include/ldb_private.h | 5 ----- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/source4/lib/ldb-samba/ldif_handlers.c b/source4/lib/ldb-samba/ldif_handlers.c index d92f211946..13bb320d6f 100644 --- a/source4/lib/ldb-samba/ldif_handlers.c +++ b/source4/lib/ldb-samba/ldif_handlers.c @@ -23,6 +23,7 @@ #include "includes.h" #include "ldb_private.h" +#include "ldb_handlers.h" #include "dsdb/samdb/samdb.h" #include "librpc/gen_ndr/ndr_security.h" #include "librpc/gen_ndr/ndr_misc.h" diff --git a/source4/lib/ldb/common/ldb_attributes.c b/source4/lib/ldb/common/ldb_attributes.c index 4d688a4d7e..9fa0fb2ccd 100644 --- a/source4/lib/ldb/common/ldb_attributes.c +++ b/source4/lib/ldb/common/ldb_attributes.c @@ -29,6 +29,7 @@ */ #include "ldb_private.h" +#include "ldb_handlers.h" /* add a attribute to the ldb_schema diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index 2e6590860f..1ce9e9ecfd 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -150,11 +150,6 @@ const char **ldb_subclass_list(struct ldb_context *ldb, const char *classname); void ldb_subclass_remove(struct ldb_context *ldb, const char *classname); int ldb_subclass_add(struct ldb_context *ldb, const char *classname, const char *subclass); -int ldb_handler_copy(struct ldb_context *ldb, void *mem_ctx, - const struct ldb_val *in, struct ldb_val *out); -int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx, - const struct ldb_val *v1, const struct ldb_val *v2); - /* The following definitions come from lib/ldb/common/ldb_utf8.c */ char *ldb_casefold_default(void *context, void *mem_ctx, const char *s, size_t n); -- cgit From 6028e8f34626e7443ee58becaf1d27b9e2c56088 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 31 Jan 2009 08:53:26 +0100 Subject: heimdal: void functions should not return a value metze --- source4/heimdal/lib/krb5/error_string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/heimdal/lib/krb5/error_string.c b/source4/heimdal/lib/krb5/error_string.c index db2df4798c..6374fa17ae 100644 --- a/source4/heimdal/lib/krb5/error_string.c +++ b/source4/heimdal/lib/krb5/error_string.c @@ -271,7 +271,7 @@ void KRB5_LIB_FUNCTION krb5_clear_error_string(krb5_context context) __attribute__((deprecated)) { - return krb5_clear_error_message(context); + krb5_clear_error_message(context); } #endif /* !HEIMDAL_SMALLER */ -- cgit From ae19f5acddee6d6507225c0c9a625383255a6d4c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 31 Jan 2009 08:55:49 +0100 Subject: s4:build: require ldb 0.9.3 when building against an external library metze --- source3/samba4.m4 | 2 +- source4/configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/samba4.m4 b/source3/samba4.m4 index fd0cc8305c..ee47fccfb2 100644 --- a/source3/samba4.m4 +++ b/source3/samba4.m4 @@ -71,7 +71,7 @@ SMB_EXT_LIB_FROM_PKGCONFIG(LIBTEVENT, tevent >= 0.9.2, SMB_INCLUDE_MK(../lib/tevent/python.mk) -SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb = 0.9.1, +SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb = 0.9.3, [ SMB_INCLUDE_MK(lib/ldb/ldb_ildap/config.mk) SMB_INCLUDE_MK(lib/ldb/tools/config.mk) diff --git a/source4/configure.ac b/source4/configure.ac index ef3bfd73f6..32778790e5 100644 --- a/source4/configure.ac +++ b/source4/configure.ac @@ -66,7 +66,7 @@ SMB_EXT_LIB_FROM_PKGCONFIG(LIBTEVENT, tevent >= 0.9.2, SMB_INCLUDE_MK(../lib/tevent/python.mk) -SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb = 0.9.1, +SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb = 0.9.3, [ SMB_INCLUDE_MK(lib/ldb/ldb_ildap/config.mk) SMB_INCLUDE_MK(lib/ldb/tools/config.mk) -- cgit From 21522e4a9a3b223d29858cb35fe5e61ef8faf5b0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 31 Jan 2009 09:04:12 +0100 Subject: s4:heimdal_build: fix the build of asn1_compile and compile_et We should not link in heimdal_build/replace.ho twice. HEIMDAL_ROKEN has everything we need.... metze --- source4/heimdal_build/internal.mk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source4/heimdal_build/internal.mk b/source4/heimdal_build/internal.mk index 92bef089e4..9e32898a07 100644 --- a/source4/heimdal_build/internal.mk +++ b/source4/heimdal_build/internal.mk @@ -656,7 +656,7 @@ HEIMDAL_COM_ERR_OBJ_FILES = \ # Start BINARY asn1_compile [BINARY::asn1_compile] USE_HOSTCC = YES -PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN LIBREPLACE_NETWORK +PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN ASN1C = $(builddir)/bin/asn1_compile @@ -682,7 +682,6 @@ asn1_compile_OBJ_FILES = \ $(asn1_compile_ASN1_OBJ_FILES) \ $(heimdalsrcdir)/lib/vers/print_version.ho \ $(socketwrappersrcdir)/socket_wrapper.ho \ - $(heimdalbuildsrcdir)/replace.ho $(asn1_compile_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/asn1 -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir) @@ -700,7 +699,7 @@ $(eval $(call heimdal_proto_header_template, \ # Start BINARY compile_et [BINARY::compile_et] USE_HOSTCC = YES -PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN LIBREPLACE_NETWORK +PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN # End BINARY compile_et ####################### @@ -711,7 +710,6 @@ compile_et_OBJ_FILES = $(heimdalsrcdir)/lib/vers/print_version.ho \ $(heimdalsrcdir)/lib/com_err/lex.ho \ $(heimdalsrcdir)/lib/com_err/compile_et.ho \ $(socketwrappersrcdir)/socket_wrapper.ho \ - $(heimdalbuildsrcdir)/replace.ho $(compile_et_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/com_err -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir) -- cgit From 412b89afbab91e3c104b012a2c1ec8b770ee6ab8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 31 Jan 2009 09:32:14 +0100 Subject: lib/replace: move MAXHOSTNAMELEN to system/network.h Some platforms define it in netdb.h, so we should define the replace after including metdb.h. metze --- lib/replace/replace.h | 12 ------------ lib/replace/system/network.h | 6 +++++- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/replace/replace.h b/lib/replace/replace.h index 688a7466c3..c5b8676acf 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -503,18 +503,6 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) #define _TYPE_MAXIMUM(t) ((t) (~ (t) 0 - _TYPE_MINIMUM (t))) -#ifndef HOST_NAME_MAX -#define HOST_NAME_MAX 255 -#endif - -/* - * Some older systems seem not to have MAXHOSTNAMELEN - * defined. - */ -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN HOST_NAME_MAX -#endif - #ifndef UINT16_MAX #define UINT16_MAX 65535 #endif diff --git a/lib/replace/system/network.h b/lib/replace/system/network.h index 473d79b5f2..40d20db2d4 100644 --- a/lib/replace/system/network.h +++ b/lib/replace/system/network.h @@ -271,7 +271,11 @@ int rep_socketpair(int d, int type, int protocol, int sv[2]); #endif #ifndef HOST_NAME_MAX -#define HOST_NAME_MAX 256 +#define HOST_NAME_MAX 255 +#endif + +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN HOST_NAME_MAX #endif #ifndef HAVE_SA_FAMILY_T -- cgit From ea157f495fec9906736ed3c79a84d9b71ae6ded3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 31 Jan 2009 09:44:27 +0100 Subject: s4:repl_meta_data: fix segfault after ldb changes metze --- source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index 1ea1ab1b81..41f4e8e7d5 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -258,7 +258,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - ldb = ldb_module_get_ctx(ac->module); + ldb = ldb_module_get_ctx(module); ldb_debug(ldb, LDB_DEBUG_TRACE, "replmd_add\n"); -- cgit From b99859b948f31dbe474b6ce0c6cab601e7e7bc56 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 30 Jan 2009 23:29:37 +0100 Subject: Make is_andx_req non-static --- source3/include/proto.h | 1 + source3/libsmb/async_smb.c | 26 -------------------------- source3/libsmb/clientgen.c | 25 +++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index d30eb09f6a..c10db31d2a 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2472,6 +2472,7 @@ struct async_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev, NTSTATUS cli_echo_recv(struct async_req *req); NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data); bool cli_ucs2(struct cli_state *cli); +bool is_andx_req(uint8_t cmd); /* The following definitions come from libsmb/clierror.c */ diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c index a4bbe6d79d..18e5a71ee2 100644 --- a/source3/libsmb/async_smb.c +++ b/source3/libsmb/async_smb.c @@ -151,32 +151,6 @@ bool cli_in_chain(struct cli_state *cli) return (cli->chain_accumulator->num_async != 0); } -/** - * Is the SMB command able to hold an AND_X successor - * @param[in] cmd The SMB command in question - * @retval Can we add a chained request after "cmd"? - */ - -static bool is_andx_req(uint8_t cmd) -{ - switch (cmd) { - case SMBtconX: - case SMBlockingX: - case SMBopenX: - case SMBreadX: - case SMBwriteX: - case SMBsesssetupX: - case SMBulogoffX: - case SMBntcreateX: - return true; - break; - default: - break; - } - - return false; -} - /** * @brief Find the smb_cmd offset of the last command pushed * @param[in] buf The buffer we're building up diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index d841bcff8d..a41aa11f7a 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -775,3 +775,28 @@ NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data) TALLOC_FREE(frame); return status; } + +/** + * Is the SMB command able to hold an AND_X successor + * @param[in] cmd The SMB command in question + * @retval Can we add a chained request after "cmd"? + */ +bool is_andx_req(uint8_t cmd) +{ + switch (cmd) { + case SMBtconX: + case SMBlockingX: + case SMBopenX: + case SMBreadX: + case SMBwriteX: + case SMBsesssetupX: + case SMBulogoffX: + case SMBntcreateX: + return true; + break; + default: + break; + } + + return false; +} -- cgit From d94e9c802ceddeff93168337b6fc5533db7f2d33 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 30 Jan 2009 23:44:21 +0100 Subject: Remove the global variable "chain_size" --- source3/include/proto.h | 2 ++ source3/include/smb.h | 5 ----- source3/include/smb_macros.h | 2 +- source3/lib/util.c | 3 --- source3/smbd/aio.c | 6 ++---- source3/smbd/blocking.c | 7 +------ source3/smbd/process.c | 26 ++++++++++++++++++++++++-- source3/smbd/reply.c | 7 ++++--- 8 files changed, 34 insertions(+), 24 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index c10db31d2a..d58dcef0b4 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -7201,6 +7201,7 @@ void remove_from_common_flags2(uint32 v); void construct_reply_common_req(struct smb_request *req, char *outbuf); size_t req_wct_ofs(struct smb_request *req); void chain_reply(struct smb_request *req); +bool req_is_in_chain(struct smb_request *req); void check_reload(time_t t); void smbd_process(void); @@ -7275,6 +7276,7 @@ NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req, uint32 dirtype, const char *name_in, bool has_wild); void reply_unlink(struct smb_request *req); void send_file_readbraw(connection_struct *conn, + struct smb_request *req, files_struct *fsp, SMB_OFF_T startpos, size_t nread, diff --git a/source3/include/smb.h b/source3/include/smb.h index 9451710255..be6ccbf597 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -1549,11 +1549,6 @@ enum acl_compatibility {ACL_COMPAT_AUTO, ACL_COMPAT_WINNT, ACL_COMPAT_WIN2K}; */ #define COPYBUF_SIZE (8*1024) -/* - * Used in chaining code. - */ -extern int chain_size; - /* * Map the Core and Extended Oplock requesst bits down * to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK). diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 92c60a7530..fd1bba16a7 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -135,7 +135,7 @@ /* Note that chain_size must be available as an extern int to this macro. */ -#define smb_offset(p,buf) (PTR_DIFF(p,buf+4) + chain_size) +#define smb_offset(p,buf) (PTR_DIFF(p,buf+4)) #define smb_len(buf) (PVAL(buf,3)|(PVAL(buf,2)<<8)|((PVAL(buf,1)&1)<<16)) #define _smb_setlen(buf,len) do { buf[0] = 0; buf[1] = ((len)&0x10000)>>16; \ diff --git a/source3/lib/util.c b/source3/lib/util.c index 195065a1e0..df01c0306f 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -57,9 +57,6 @@ extern unsigned int global_clobber_region_line; enum protocol_types Protocol = PROTOCOL_COREPLUS; -/* this is used by the chaining code */ -int chain_size = 0; - static enum remote_arch_types ra_type = RA_UNKNOWN; /*********************************************************************** diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index 4ce43c95e8..64d512d675 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -141,8 +141,7 @@ bool schedule_aio_read_and_X(connection_struct *conn, /* Only do this on non-chained and non-chaining reads not using the * write cache. */ - if (chain_size !=0 || (CVAL(req->vwv+0, 0) != 0xFF) - || (lp_write_cache_size(SNUM(conn)) != 0) ) { + if (req_is_in_chain(req) || (lp_write_cache_size(SNUM(conn)) != 0)) { return False; } @@ -238,8 +237,7 @@ bool schedule_aio_write_and_X(connection_struct *conn, /* Only do this on non-chained and non-chaining reads not using the * write cache. */ - if (chain_size !=0 || (CVAL(req->vwv+0, 0) != 0xFF) - || (lp_write_cache_size(SNUM(conn)) != 0) ) { + if (req_is_in_chain(req) || (lp_write_cache_size(SNUM(conn)) != 0)) { return False; } diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c index 9936fb219f..ac1ff00858 100644 --- a/source3/smbd/blocking.c +++ b/source3/smbd/blocking.c @@ -47,11 +47,6 @@ typedef struct blocking_lock_record { Determine if this is a secondary element of a chained SMB. **************************************************************************/ -static bool in_chained_smb(void) -{ - return (chain_size != 0); -} - static void received_unlock_msg(struct messaging_context *msg, void *private_data, uint32_t msg_type, @@ -144,7 +139,7 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck, blocking_lock_record *blr; NTSTATUS status; - if(in_chained_smb() ) { + if(req_is_in_chain(req)) { DEBUG(0,("push_blocking_lock_request: cannot queue a chained request (currently).\n")); return False; } diff --git a/source3/smbd/process.c b/source3/smbd/process.c index d617ef1915..c9fc1fbb6a 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -1359,8 +1359,6 @@ static void construct_reply(char *inbuf, int size, size_t unread_bytes, bool enc connection_struct *conn; struct smb_request *req; - chain_size = 0; - if (!(req = talloc(talloc_tos(), struct smb_request))) { smb_panic("could not allocate smb_request"); } @@ -2114,3 +2112,27 @@ void smbd_process(void) exit_server_cleanly(NULL); } + +bool req_is_in_chain(struct smb_request *req) +{ + if (req->vwv != (uint16_t *)(req->inbuf+smb_vwv)) { + /* + * We're right now handling a subsequent request, so we must + * be in a chain + */ + return true; + } + + if (!is_andx_req(req->cmd)) { + return false; + } + + if (req->wct < 2) { + /* + * Okay, an illegal request, but definitely not chained :-) + */ + return false; + } + + return (CVAL(req->vwv+0, 0) != 0xFF); +} diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 25d50470ff..eeb6692eb5 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2729,6 +2729,7 @@ static void reply_readbraw_error(void) ****************************************************************************/ void send_file_readbraw(connection_struct *conn, + struct smb_request *req, files_struct *fsp, SMB_OFF_T startpos, size_t nread, @@ -2745,7 +2746,7 @@ void send_file_readbraw(connection_struct *conn, * reply_readbraw has already checked the length. */ - if ( (chain_size == 0) && (nread > 0) && (fsp->base_fsp == NULL) && + if ( !req_is_in_chain(req) && (nread > 0) && (fsp->base_fsp == NULL) && (fsp->wcp == NULL) && lp_use_sendfile(SNUM(conn)) ) { ssize_t sendfile_read = -1; char header[4]; @@ -2963,7 +2964,7 @@ void reply_readbraw(struct smb_request *req) (unsigned long)mincount, (unsigned long)nread ) ); - send_file_readbraw(conn, fsp, startpos, nread, mincount); + send_file_readbraw(conn, req, fsp, startpos, nread, mincount); DEBUG(5,("reply_readbraw finished\n")); END_PROFILE(SMBreadbraw); @@ -3229,7 +3230,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req, * on a train in Germany :-). JRA. */ - if ((chain_size == 0) && (CVAL(req->vwv+0, 0) == 0xFF) && + if (!req_is_in_chain(req) && !is_encrypted_packet(req->inbuf) && (fsp->base_fsp == NULL) && lp_use_sendfile(SNUM(conn)) && (fsp->wcp == NULL) ) { uint8 headerbuf[smb_size + 12 * 2]; -- cgit From cee0d85e0b2be27d9314206f3fe832fc0c75b0f3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 30 Jan 2009 23:45:35 +0100 Subject: make send_file_readbraw static --- source3/include/proto.h | 6 ------ source3/smbd/reply.c | 12 ++++++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index d58dcef0b4..9199d6c0d3 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -7275,12 +7275,6 @@ void reply_ctemp(struct smb_request *req); NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req, uint32 dirtype, const char *name_in, bool has_wild); void reply_unlink(struct smb_request *req); -void send_file_readbraw(connection_struct *conn, - struct smb_request *req, - files_struct *fsp, - SMB_OFF_T startpos, - size_t nread, - ssize_t mincount); void reply_readbraw(struct smb_request *req); void reply_lockread(struct smb_request *req); void reply_read(struct smb_request *req); diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index eeb6692eb5..f2d4ff78a7 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2728,12 +2728,12 @@ static void reply_readbraw_error(void) Use sendfile in readbraw. ****************************************************************************/ -void send_file_readbraw(connection_struct *conn, - struct smb_request *req, - files_struct *fsp, - SMB_OFF_T startpos, - size_t nread, - ssize_t mincount) +static void send_file_readbraw(connection_struct *conn, + struct smb_request *req, + files_struct *fsp, + SMB_OFF_T startpos, + size_t nread, + ssize_t mincount) { char *outbuf = NULL; ssize_t ret=0; -- cgit From 582b27be242ad4453e42020cf5309293710768c4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 31 Jan 2009 11:34:12 +0100 Subject: s4:auth: try to fix the build on Solaris MAXHOSTNAMELEN comes in via system/network.h now. metze --- source4/auth/ntlmssp/ntlmssp_server.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source4/auth/ntlmssp/ntlmssp_server.c b/source4/auth/ntlmssp/ntlmssp_server.c index 37cc5f318f..30bf159df1 100644 --- a/source4/auth/ntlmssp/ntlmssp_server.c +++ b/source4/auth/ntlmssp/ntlmssp_server.c @@ -22,6 +22,7 @@ */ #include "includes.h" +#include "system/network.h" #include "auth/ntlmssp/ntlmssp.h" #include "auth/ntlmssp/msrpc_parse.h" #include "../lib/crypto/crypto.h" -- cgit From e60d69d67d4064d4aa26644c6bca2dfc1b0f4983 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 31 Jan 2009 12:43:25 +0100 Subject: Add an async np_write wrapper --- source3/include/proto.h | 4 ++ source3/rpc_server/srv_pipe_hnd.c | 117 +++++++++++++++++++++++++++++++++----- 2 files changed, 106 insertions(+), 15 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 9199d6c0d3..b308e86af7 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6314,6 +6314,10 @@ 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 fake_file_handle *handle, + const uint8_t *data, size_t len); +NTSTATUS np_write_recv(struct async_req *req, ssize_t *nwritten); NTSTATUS np_write(struct fake_file_handle *handle, const uint8_t *data, size_t len, ssize_t *nwritten); NTSTATUS np_read(struct fake_file_handle *handle, uint8_t *data, size_t len, diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 0753476230..b5b6bbd6eb 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1109,32 +1109,119 @@ NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name, return NT_STATUS_OK; } -NTSTATUS np_write(struct fake_file_handle *handle, const uint8_t *data, - size_t len, ssize_t *nwritten) +struct np_write_state { + ssize_t nwritten; +}; + +static void np_write_done(struct async_req *subreq); + +struct async_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev, + struct fake_file_handle *handle, + const uint8_t *data, size_t len) { - DEBUG(6, ("np_write: len: %d\n", (int)len)); + struct async_req *result, *subreq; + struct np_write_state *state; + NTSTATUS status; + + DEBUG(6, ("np_write_send: len: %d\n", (int)len)); dump_data(50, data, len); - switch (handle->type) { - case FAKE_FILE_TYPE_NAMED_PIPE: { + if (!async_req_setup(mem_ctx, &result, &state, + struct np_write_state)) { + return NULL; + } + + if (handle->type == FAKE_FILE_TYPE_NAMED_PIPE) { struct pipes_struct *p = talloc_get_type_abort( handle->private_data, struct pipes_struct); - *nwritten = write_to_internal_pipe(p, (char *)data, len); - break; + + state->nwritten = write_to_internal_pipe(p, (char *)data, len); + + status = (state->nwritten >= 0) + ? NT_STATUS_OK : NT_STATUS_UNEXPECTED_IO_ERROR; + goto post_status; } - case FAKE_FILE_TYPE_NAMED_PIPE_PROXY: { + + if (handle->type == FAKE_FILE_TYPE_NAMED_PIPE_PROXY) { struct np_proxy_state *p = talloc_get_type_abort( handle->private_data, struct np_proxy_state); - *nwritten = write_data(p->fd, (char *)data, len); - break; + + state->nwritten = len; + + subreq = sendall_send(state, ev, p->fd, data, len, 0); + if (subreq == NULL) { + goto fail; + } + subreq->async.fn = np_write_done; + subreq->async.priv = result; + return result; } - default: - return NT_STATUS_INVALID_HANDLE; - break; + + status = NT_STATUS_INVALID_HANDLE; + post_status: + if (async_post_status(result, ev, status)) { + return result; } + fail: + TALLOC_FREE(result); + return NULL; +} - return ((*nwritten) >= 0) - ? NT_STATUS_OK : NT_STATUS_UNEXPECTED_IO_ERROR; +static void np_write_done(struct async_req *subreq) +{ + struct async_req *req = talloc_get_type_abort( + subreq->async.priv, struct async_req); + NTSTATUS status; + + status = sendall_recv(subreq); + if (!NT_STATUS_IS_OK(status)) { + async_req_error(req, status); + return; + } + return async_req_done(req); +} + +NTSTATUS np_write_recv(struct async_req *req, ssize_t *pnwritten) +{ + struct np_write_state *state = talloc_get_type_abort( + req->private_data, struct np_write_state); + NTSTATUS status; + + if (async_req_is_error(req, &status)) { + return status; + } + *pnwritten = state->nwritten; + return NT_STATUS_OK; +} + +NTSTATUS np_write(struct fake_file_handle *handle, const uint8_t *data, + size_t len, ssize_t *nwritten) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct event_context *ev; + struct async_req *req; + NTSTATUS status; + + ev = event_context_init(frame); + if (ev == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + + req = np_write_send(frame, ev, handle, data, len); + if (req == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } + + while (req->state < ASYNC_REQ_DONE) { + event_loop_once(ev); + } + + status = np_write_recv(req, nwritten); + fail: + TALLOC_FREE(frame); + return status; } NTSTATUS np_read(struct fake_file_handle *handle, uint8_t *data, size_t len, -- cgit From b797c056a60b519da6595ce728846dace5d1dfbd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 31 Jan 2009 13:36:09 +0100 Subject: Add an async np_read wrapper --- source3/include/proto.h | 5 ++ source3/rpc_server/srv_pipe_hnd.c | 124 +++++++++++++++++++++++++++++++------- 2 files changed, 107 insertions(+), 22 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index b308e86af7..ca10b7097f 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6320,6 +6320,11 @@ struct async_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev, NTSTATUS np_write_recv(struct async_req *req, ssize_t *nwritten); NTSTATUS np_write(struct fake_file_handle *handle, const uint8_t *data, size_t len, 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, + bool *is_data_outstanding); NTSTATUS np_read(struct fake_file_handle *handle, uint8_t *data, size_t len, ssize_t *nread, bool *is_data_outstanding); diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index b5b6bbd6eb..6e2bfb8b4a 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1224,38 +1224,118 @@ NTSTATUS np_write(struct fake_file_handle *handle, const uint8_t *data, return status; } -NTSTATUS np_read(struct fake_file_handle *handle, uint8_t *data, size_t len, - ssize_t *nread, bool *is_data_outstanding) +struct np_read_state { + ssize_t nread; + bool is_data_outstanding; +}; + +static void np_read_done(struct async_req *subreq); + +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) { - switch (handle->type) { - case FAKE_FILE_TYPE_NAMED_PIPE: { + struct async_req *result, *subreq; + struct np_read_state *state; + NTSTATUS status; + + if (!async_req_setup(mem_ctx, &result, &state, + struct np_read_state)) { + return NULL; + } + + if (handle->type == FAKE_FILE_TYPE_NAMED_PIPE) { struct pipes_struct *p = talloc_get_type_abort( handle->private_data, struct pipes_struct); - *nread = read_from_internal_pipe(p, (char *)data, len, - is_data_outstanding); - break; + + state->nread = read_from_internal_pipe( + p, (char *)data, len, &state->is_data_outstanding); + + status = (state->nread >= 0) + ? NT_STATUS_OK : NT_STATUS_UNEXPECTED_IO_ERROR; + goto post_status; } - case FAKE_FILE_TYPE_NAMED_PIPE_PROXY: { + + if (handle->type == FAKE_FILE_TYPE_NAMED_PIPE_PROXY) { struct np_proxy_state *p = talloc_get_type_abort( handle->private_data, struct np_proxy_state); - int available = 0; - *nread = sys_read(p->fd, (char *)data, len); + state->nread = len; - /* - * We don't look at the ioctl result. We don't really care - * if there is data available, because this is racy anyway. - */ - ioctl(p->fd, FIONREAD, &available); - *is_data_outstanding = (available > 0); + subreq = recvall_send(state, ev, p->fd, data, len, 0); + if (subreq == NULL) { + goto fail; + } + subreq->async.fn = np_read_done; + subreq->async.priv = result; + return result; + } + + status = NT_STATUS_INVALID_HANDLE; + post_status: + if (async_post_status(result, ev, status)) { + return result; + } + fail: + TALLOC_FREE(result); + return NULL; +} + +static void np_read_done(struct async_req *subreq) +{ + struct async_req *req = talloc_get_type_abort( + subreq->async.priv, struct async_req); + NTSTATUS status; + + status = recvall_recv(subreq); + if (!NT_STATUS_IS_OK(status)) { + async_req_error(req, status); + return; + } + async_req_done(req); +} + +NTSTATUS np_read_recv(struct async_req *req, ssize_t *nread, + bool *is_data_outstanding) +{ + struct np_read_state *state = talloc_get_type_abort( + req->private_data, struct np_read_state); + NTSTATUS status; + + if (async_req_is_error(req, &status)) { + return status; + } + *nread = state->nread; + *is_data_outstanding = state->is_data_outstanding; + return NT_STATUS_OK; +} + +NTSTATUS np_read(struct fake_file_handle *handle, uint8_t *data, size_t len, + ssize_t *nread, bool *is_data_outstanding) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct event_context *ev; + struct async_req *req; + NTSTATUS status; + + ev = event_context_init(frame); + if (ev == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; + } - break; + req = np_read_send(frame, ev, handle, data, len); + if (req == NULL) { + status = NT_STATUS_NO_MEMORY; + goto fail; } - default: - return NT_STATUS_INVALID_HANDLE; - break; + + while (req->state < ASYNC_REQ_DONE) { + event_loop_once(ev); } - return ((*nread) >= 0) - ? NT_STATUS_OK : NT_STATUS_UNEXPECTED_IO_ERROR; + status = np_read_recv(req, nread, is_data_outstanding); + fail: + TALLOC_FREE(frame); + return status; } -- cgit From c2fe28ba598e7db2915b3bb5e7b8d281361a4c95 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 14 Oct 2008 15:53:35 +0200 Subject: Convert api_rpc_trans_reply to async np_* --- source3/include/smb.h | 16 ++++++ source3/smbd/ipc.c | 148 ++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 135 insertions(+), 29 deletions(-) diff --git a/source3/include/smb.h b/source3/include/smb.h index be6ccbf597..491dd763ff 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -624,7 +624,18 @@ struct smb_request { uint16_t buflen; const uint8_t *buf; const uint8 *inbuf; + + /* + * Async handling in the main smb processing loop is directed by + * outbuf: reply_xxx routines indicate sync behaviour by putting their + * reply into "outbuf". If they leave it as NULL, they take of it + * themselves, possibly later. + * + * If async handling is wanted, the reply_xxx routine must make sure + * that it talloc_move()s the smb_req somewhere else. + */ uint8 *outbuf; + size_t unread_bytes; bool encrypted; connection_struct *conn; @@ -638,6 +649,11 @@ struct smb_request { * Here we collect the outbufs from the chain handlers */ uint8_t *chain_outbuf; + + /* + * state information for async smb handling + */ + void *async_priv; }; /* Defines for the sent_oplock_break field above. */ diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index 7c150561b1..9c7528dfa7 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -204,40 +204,137 @@ void send_trans_reply(connection_struct *conn, Start the first part of an RPC reply which began with an SMBtrans request. ****************************************************************************/ -static void api_rpc_trans_reply(connection_struct *conn, - struct smb_request *req, - files_struct *fsp, - int max_trans_reply) +struct dcerpc_cmd_state { + struct fake_file_handle *handle; + uint8_t *data; + size_t num_data; + size_t max_read; +}; + +static void api_dcerpc_cmd_write_done(struct async_req *subreq); +static void api_dcerpc_cmd_read_done(struct async_req *subreq); + +static void api_dcerpc_cmd(connection_struct *conn, struct smb_request *req, + files_struct *fsp, uint8_t *data, size_t length, + size_t max_read) { - bool is_data_outstanding; - uint8_t *rdata = SMB_MALLOC_ARRAY(uint8_t, max_trans_reply); - ssize_t data_len; - NTSTATUS status; + struct async_req *subreq; + struct dcerpc_cmd_state *state; + + if (!fsp_is_np(fsp)) { + api_no_reply(conn, req); + return; + } - if(rdata == NULL) { - DEBUG(0,("api_rpc_trans_reply: malloc fail.\n")); + state = talloc(req, struct dcerpc_cmd_state); + if (state == NULL) { reply_nterror(req, NT_STATUS_NO_MEMORY); return; } + req->async_priv = state; - if (!fsp_is_np(fsp)) { - SAFE_FREE(rdata); - api_no_reply(conn,req); + state->handle = fsp->fake_file_handle; + + /* + * This memdup severely sucks. But doing it properly essentially means + * to rewrite lanman.c, something which I don't really want to do now. + */ + state->data = (uint8_t *)talloc_memdup(state, data, length); + if (state->data == NULL) { + reply_nterror(req, NT_STATUS_NO_MEMORY); return; } + state->num_data = length; + state->max_read = max_read; + + subreq = np_write_send(state, smbd_event_context(), state->handle, + state->data, length); + if (subreq == NULL) { + TALLOC_FREE(state); + reply_nterror(req, NT_STATUS_NO_MEMORY); + return; + } + subreq->async.fn = api_dcerpc_cmd_write_done; + subreq->async.priv = talloc_move(conn, &req); +} + +static void api_dcerpc_cmd_write_done(struct async_req *subreq) +{ + struct smb_request *req = talloc_get_type_abort( + subreq->async.priv, struct smb_request); + struct dcerpc_cmd_state *state = talloc_get_type_abort( + req->async_priv, struct dcerpc_cmd_state); + NTSTATUS status; + ssize_t nwritten = -1; + + status = np_write_recv(subreq, &nwritten); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status) || (nwritten != state->num_data)) { + DEBUG(10, ("Could not write to pipe: %s (%d/%d)\n", + nt_errstr(status), (int)state->num_data, + (int)nwritten)); + reply_nterror(req, NT_STATUS_PIPE_NOT_AVAILABLE); + goto send; + } + + state->data = TALLOC_REALLOC_ARRAY(state, state->data, uint8_t, + state->max_read); + if (state->data == NULL) { + reply_nterror(req, NT_STATUS_NO_MEMORY); + goto send; + } + + subreq = np_read_send(req->conn, smbd_event_context(), + state->handle, state->data, state->max_read); + if (subreq == NULL) { + reply_nterror(req, NT_STATUS_NO_MEMORY); + goto send; + } + + subreq->async.fn = api_dcerpc_cmd_read_done; + subreq->async.priv = req; + return; + + send: + if (!srv_send_smb( + smbd_server_fd(), (char *)req->outbuf, + IS_CONN_ENCRYPTED(req->conn) || req->encrypted)) { + exit_server_cleanly("construct_reply: srv_send_smb failed."); + } + TALLOC_FREE(req); +} + +static void api_dcerpc_cmd_read_done(struct async_req *subreq) +{ + struct smb_request *req = talloc_get_type_abort( + subreq->async.priv, struct smb_request); + struct dcerpc_cmd_state *state = talloc_get_type_abort( + req->async_priv, struct dcerpc_cmd_state); + NTSTATUS status; + ssize_t nread; + bool is_data_outstanding; + + status = np_read_recv(subreq, &nread, &is_data_outstanding); + TALLOC_FREE(subreq); - status = np_read(fsp->fake_file_handle, rdata, max_trans_reply, - &data_len, &is_data_outstanding); if (!NT_STATUS_IS_OK(status)) { - SAFE_FREE(rdata); - api_no_reply(conn,req); + DEBUG(10, ("Could not read from to pipe: %s\n", + nt_errstr(status))); + reply_nterror(req, status); + + if (!srv_send_smb(smbd_server_fd(), (char *)req->outbuf, + IS_CONN_ENCRYPTED(req->conn) + ||req->encrypted)) { + exit_server_cleanly("construct_reply: srv_send_smb " + "failed."); + } + TALLOC_FREE(req); return; } - send_trans_reply(conn, req, NULL, 0, (char *)rdata, data_len, + send_trans_reply(req->conn, req, NULL, 0, (char *)state->data, nread, is_data_outstanding); - SAFE_FREE(rdata); - return; + TALLOC_FREE(req); } /**************************************************************************** @@ -310,7 +407,6 @@ static void api_fd_reply(connection_struct *conn, uint16 vuid, struct files_struct *fsp; int pnum; int subcommand; - NTSTATUS status; DEBUG(5,("api_fd_reply\n")); @@ -360,14 +456,8 @@ static void api_fd_reply(connection_struct *conn, uint16 vuid, switch (subcommand) { case TRANSACT_DCERPCCMD: { /* dce/rpc command */ - ssize_t nwritten; - status = np_write(fsp->fake_file_handle, data, tdscnt, - &nwritten); - if (!NT_STATUS_IS_OK(status)) { - api_no_reply(conn, req); - return; - } - api_rpc_trans_reply(conn, req, fsp, mdrcnt); + api_dcerpc_cmd(conn, req, fsp, (uint8_t *)data, tdscnt, + mdrcnt); break; } case TRANSACT_WAITNAMEDPIPEHANDLESTATE: -- cgit From e8b2b46caeff185faef5491cbbeaf799bcd1b1ec Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 31 Jan 2009 14:33:38 +0100 Subject: Make-np_write-handle-0-byte-writes-as-NT_STATUS_OK --- source3/rpc_server/srv_pipe_hnd.c | 6 ++++ source3/smbd/pipes.c | 70 +++++++++++++++------------------------ 2 files changed, 33 insertions(+), 43 deletions(-) diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 6e2bfb8b4a..c844f6486e 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1131,6 +1131,12 @@ struct async_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev, return NULL; } + if (len == 0) { + state->nwritten = 0; + status = NT_STATUS_OK; + goto post_status; + } + if (handle->type == FAKE_FILE_TYPE_NAMED_PIPE) { struct pipes_struct *p = talloc_get_type_abort( handle->private_data, struct pipes_struct); diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c index b148cff045..cf22eb17f3 100644 --- a/source3/smbd/pipes.c +++ b/source3/smbd/pipes.c @@ -150,6 +150,7 @@ void reply_pipe_write(struct smb_request *req) size_t numtowrite = SVAL(req->vwv+1, 0); ssize_t nwritten; const uint8_t *data; + NTSTATUS status; if (!fsp_is_np(fsp)) { reply_doserror(req, ERRDOS, ERRbadfid); @@ -163,22 +164,12 @@ void reply_pipe_write(struct smb_request *req) data = req->buf + 3; - if (numtowrite == 0) { - nwritten = 0; - } else { - NTSTATUS status; - if (!fsp_is_np(fsp)) { - reply_nterror(req, NT_STATUS_INVALID_HANDLE); - return; - } - DEBUG(6, ("reply_pipe_write: %x name: %s len: %d\n", - (int)fsp->fnum, fsp->fsp_name, (int)numtowrite)); - status = np_write(fsp->fake_file_handle, data, numtowrite, - &nwritten); - if (!NT_STATUS_IS_OK(status)) { - reply_nterror(req, status); - return; - } + DEBUG(6, ("reply_pipe_write: %x name: %s len: %d\n", (int)fsp->fnum, + fsp->fsp_name, (int)numtowrite)); + status = np_write(fsp->fake_file_handle, data, numtowrite, &nwritten); + if (!NT_STATUS_IS_OK(status)) { + reply_nterror(req, status); + return; } if ((nwritten == 0 && numtowrite != 0) || (nwritten < 0)) { @@ -213,6 +204,7 @@ void reply_pipe_write_and_X(struct smb_request *req) ((SVAL(req->vwv+7, 0) & (PIPE_START_MESSAGE|PIPE_RAW_MODE)) == (PIPE_START_MESSAGE|PIPE_RAW_MODE)); uint8_t *data; + NTSTATUS status; if (!fsp_is_np(fsp)) { reply_doserror(req, ERRDOS, ERRbadfid); @@ -229,35 +221,27 @@ void reply_pipe_write_and_X(struct smb_request *req) data = (uint8_t *)smb_base(req->inbuf) + smb_doff; - if (numtowrite == 0) { - nwritten = 0; - } else { - NTSTATUS status; - - if(pipe_start_message_raw) { - /* - * For the start of a message in named pipe byte mode, - * the first two bytes are a length-of-pdu field. Ignore - * them (we don't trust the client). JRA. - */ - if(numtowrite < 2) { - DEBUG(0,("reply_pipe_write_and_X: start of " - "message set and not enough data " - "sent.(%u)\n", - (unsigned int)numtowrite )); - reply_unixerror(req, ERRDOS, ERRnoaccess); - return; - } - - data += 2; - numtowrite -= 2; - } - status = np_write(fsp->fake_file_handle, data, numtowrite, - &nwritten); - if (!NT_STATUS_IS_OK(status)) { - reply_nterror(req, status); + if(pipe_start_message_raw) { + /* + * For the start of a message in named pipe byte mode, + * the first two bytes are a length-of-pdu field. Ignore + * them (we don't trust the client). JRA. + */ + if(numtowrite < 2) { + DEBUG(0,("reply_pipe_write_and_X: start of message " + "set and not enough data sent.(%u)\n", + (unsigned int)numtowrite )); + reply_unixerror(req, ERRDOS, ERRnoaccess); return; } + + data += 2; + numtowrite -= 2; + } + status = np_write(fsp->fake_file_handle, data, numtowrite, &nwritten); + if (!NT_STATUS_IS_OK(status)) { + reply_nterror(req, status); + return; } if ((nwritten == 0 && numtowrite != 0) || (nwritten < 0)) { -- cgit From 8ef92f7e32af73d0cd215e8f259ba5fcd3d9812e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 31 Jan 2009 14:31:31 +0100 Subject: Make reply_pipe_write_and_X async --- source3/smbd/pipes.c | 72 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c index cf22eb17f3..693db521e7 100644 --- a/source3/smbd/pipes.c +++ b/source3/smbd/pipes.c @@ -194,17 +194,20 @@ void reply_pipe_write(struct smb_request *req) wrinkles to handle pipes. ****************************************************************************/ +struct pipe_write_andx_state { + bool pipe_start_message_raw; + size_t numtowrite; +}; + +static void pipe_write_andx_done(struct async_req *subreq); + void reply_pipe_write_and_X(struct smb_request *req) { files_struct *fsp = file_fsp(req, SVAL(req->vwv+2, 0)); - size_t numtowrite = SVAL(req->vwv+10, 0); - ssize_t nwritten; int smb_doff = SVAL(req->vwv+11, 0); - bool pipe_start_message_raw = - ((SVAL(req->vwv+7, 0) & (PIPE_START_MESSAGE|PIPE_RAW_MODE)) - == (PIPE_START_MESSAGE|PIPE_RAW_MODE)); uint8_t *data; - NTSTATUS status; + struct pipe_write_andx_state *state; + struct async_req *subreq; if (!fsp_is_np(fsp)) { reply_doserror(req, ERRDOS, ERRbadfid); @@ -216,47 +219,76 @@ void reply_pipe_write_and_X(struct smb_request *req) return; } + state = talloc(req, struct pipe_write_andx_state); + if (state == NULL) { + reply_nterror(req, NT_STATUS_NO_MEMORY); + return; + } + req->async_priv = state; + + state->numtowrite = SVAL(req->vwv+10, 0); + state->pipe_start_message_raw = + ((SVAL(req->vwv+7, 0) & (PIPE_START_MESSAGE|PIPE_RAW_MODE)) + == (PIPE_START_MESSAGE|PIPE_RAW_MODE)); + DEBUG(6, ("reply_pipe_write_and_X: %x name: %s len: %d\n", - (int)fsp->fnum, fsp->fsp_name, (int)numtowrite)); + (int)fsp->fnum, fsp->fsp_name, (int)state->numtowrite)); data = (uint8_t *)smb_base(req->inbuf) + smb_doff; - if(pipe_start_message_raw) { + if (state->pipe_start_message_raw) { /* * For the start of a message in named pipe byte mode, * the first two bytes are a length-of-pdu field. Ignore * them (we don't trust the client). JRA. */ - if(numtowrite < 2) { + if (state->numtowrite < 2) { DEBUG(0,("reply_pipe_write_and_X: start of message " "set and not enough data sent.(%u)\n", - (unsigned int)numtowrite )); + (unsigned int)state->numtowrite )); reply_unixerror(req, ERRDOS, ERRnoaccess); return; } data += 2; - numtowrite -= 2; + state->numtowrite -= 2; } - status = np_write(fsp->fake_file_handle, data, numtowrite, &nwritten); - if (!NT_STATUS_IS_OK(status)) { - reply_nterror(req, status); + + subreq = np_write_send(state, smbd_event_context(), + fsp->fake_file_handle, data, state->numtowrite); + if (subreq == NULL) { + TALLOC_FREE(state); + reply_nterror(req, NT_STATUS_NO_MEMORY); return; } + subreq->async.fn = pipe_write_andx_done; + subreq->async.priv = talloc_move(req->conn, &req); +} - if ((nwritten == 0 && numtowrite != 0) || (nwritten < 0)) { +static void pipe_write_andx_done(struct async_req *subreq) +{ + struct smb_request *req = talloc_get_type_abort( + subreq->async.priv, struct smb_request); + struct pipe_write_andx_state *state = talloc_get_type_abort( + req->async_priv, struct pipe_write_andx_state); + NTSTATUS status; + ssize_t nwritten = -1; + + status = np_write_recv(subreq, &nwritten); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status) || (nwritten != state->numtowrite)) { reply_unixerror(req, ERRDOS,ERRnoaccess); - return; + goto done; } reply_outbuf(req, 6, 0); - nwritten = (pipe_start_message_raw ? nwritten + 2 : nwritten); + nwritten = (state->pipe_start_message_raw ? nwritten + 2 : nwritten); SSVAL(req->outbuf,smb_vwv2,nwritten); - - DEBUG(3,("writeX-IPC pnum=%04x nwritten=%d\n", fsp->fnum, - (int)nwritten)); + DEBUG(3,("writeX-IPC nwritten=%d\n", (int)nwritten)); + + done: chain_reply(req); } -- cgit From 2d5ec28b3b065940cefdd491ad7c8fd1a58c3a5c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 31 Jan 2009 14:43:06 +0100 Subject: Make reply_pipe_write async --- source3/smbd/pipes.c | 61 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c index 693db521e7..abbcf67d55 100644 --- a/source3/smbd/pipes.c +++ b/source3/smbd/pipes.c @@ -144,13 +144,18 @@ void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req) Reply to a write on a pipe. ****************************************************************************/ +struct pipe_write_state { + size_t numtowrite; +}; + +static void pipe_write_done(struct async_req *subreq); + void reply_pipe_write(struct smb_request *req) { files_struct *fsp = file_fsp(req, SVAL(req->vwv+0, 0)); - size_t numtowrite = SVAL(req->vwv+1, 0); - ssize_t nwritten; const uint8_t *data; - NTSTATUS status; + struct pipe_write_state *state; + struct async_req *subreq; if (!fsp_is_np(fsp)) { reply_doserror(req, ERRDOS, ERRbadfid); @@ -162,29 +167,59 @@ void reply_pipe_write(struct smb_request *req) return; } + state = talloc(req, struct pipe_write_state); + if (state == NULL) { + reply_nterror(req, NT_STATUS_NO_MEMORY); + return; + } + req->async_priv = state; + + state->numtowrite = SVAL(req->vwv+1, 0); + data = req->buf + 3; DEBUG(6, ("reply_pipe_write: %x name: %s len: %d\n", (int)fsp->fnum, - fsp->fsp_name, (int)numtowrite)); - status = np_write(fsp->fake_file_handle, data, numtowrite, &nwritten); - if (!NT_STATUS_IS_OK(status)) { - reply_nterror(req, status); + fsp->fsp_name, (int)state->numtowrite)); + + subreq = np_write_send(state, smbd_event_context(), + fsp->fake_file_handle, data, state->numtowrite); + if (subreq == NULL) { + TALLOC_FREE(state); + reply_nterror(req, NT_STATUS_NO_MEMORY); return; } + subreq->async.fn = pipe_write_done; + subreq->async.priv = talloc_move(req->conn, &req); +} + +static void pipe_write_done(struct async_req *subreq) +{ + struct smb_request *req = talloc_get_type_abort( + subreq->async.priv, struct smb_request); + struct pipe_write_state *state = talloc_get_type_abort( + req->async_priv, struct pipe_write_state); + NTSTATUS status; + ssize_t nwritten = -1; - if ((nwritten == 0 && numtowrite != 0) || (nwritten < 0)) { + status = np_write_recv(subreq, &nwritten); + TALLOC_FREE(subreq); + if ((nwritten == 0 && state->numtowrite != 0) || (nwritten < 0)) { reply_unixerror(req, ERRDOS, ERRnoaccess); - return; + goto send; } reply_outbuf(req, 1, 0); SSVAL(req->outbuf,smb_vwv0,nwritten); - - DEBUG(3,("write-IPC pnum=%04x nwritten=%d\n", fsp->fnum, - (int)nwritten)); - return; + DEBUG(3,("write-IPC nwritten=%d\n", (int)nwritten)); + + send: + if (!srv_send_smb(smbd_server_fd(), (char *)req->outbuf, + IS_CONN_ENCRYPTED(req->conn)||req->encrypted)) { + exit_server_cleanly("construct_reply: srv_send_smb failed."); + } + TALLOC_FREE(req); } /**************************************************************************** -- cgit From 8b480b52cef385f555ca90c804132472e2173129 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 31 Jan 2009 14:44:04 +0100 Subject: Remove unused np_write sync wrapper --- source3/include/proto.h | 2 -- source3/rpc_server/srv_pipe_hnd.c | 30 ------------------------------ 2 files changed, 32 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index ca10b7097f..081225614f 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6318,8 +6318,6 @@ struct async_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 async_req *req, ssize_t *nwritten); -NTSTATUS np_write(struct fake_file_handle *handle, const uint8_t *data, - size_t len, 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); diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index c844f6486e..813561bac4 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1200,36 +1200,6 @@ NTSTATUS np_write_recv(struct async_req *req, ssize_t *pnwritten) return NT_STATUS_OK; } -NTSTATUS np_write(struct fake_file_handle *handle, const uint8_t *data, - size_t len, ssize_t *nwritten) -{ - TALLOC_CTX *frame = talloc_stackframe(); - struct event_context *ev; - struct async_req *req; - NTSTATUS status; - - ev = event_context_init(frame); - if (ev == NULL) { - status = NT_STATUS_NO_MEMORY; - goto fail; - } - - req = np_write_send(frame, ev, handle, data, len); - if (req == NULL) { - status = NT_STATUS_NO_MEMORY; - goto fail; - } - - while (req->state < ASYNC_REQ_DONE) { - event_loop_once(ev); - } - - status = np_write_recv(req, nwritten); - fail: - TALLOC_FREE(frame); - return status; -} - struct np_read_state { ssize_t nread; bool is_data_outstanding; -- cgit From 72729bfaee6057c383e1b2b261893d2bd8ae9714 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 31 Jan 2009 14:57:52 +0100 Subject: Make reply_pipe_read_andx async --- source3/smbd/pipes.c | 70 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 13 deletions(-) diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c index abbcf67d55..f287adc92d 100644 --- a/source3/smbd/pipes.c +++ b/source3/smbd/pipes.c @@ -333,15 +333,20 @@ static void pipe_write_andx_done(struct async_req *subreq) wrinkles to handle pipes. ****************************************************************************/ +struct pipe_read_andx_state { + uint8_t *outbuf; + int smb_mincnt; + int smb_maxcnt; +}; + +static void pipe_read_andx_done(struct async_req *subreq); + void reply_pipe_read_and_X(struct smb_request *req) { files_struct *fsp = file_fsp(req, SVAL(req->vwv+0, 0)); - int smb_maxcnt = SVAL(req->vwv+5, 0); - int smb_mincnt = SVAL(req->vwv+6, 0); - ssize_t nread; uint8_t *data; - bool unused; - NTSTATUS status; + struct pipe_read_andx_state *state; + struct async_req *subreq; /* we don't use the offset given to use for pipe reads. This is deliberate, instead we always return the next lump of @@ -360,17 +365,55 @@ void reply_pipe_read_and_X(struct smb_request *req) return; } - reply_outbuf(req, 12, smb_maxcnt); + state = talloc(req, struct pipe_read_andx_state); + if (state == NULL) { + reply_nterror(req, NT_STATUS_NO_MEMORY); + return; + } + req->async_priv = state; + state->smb_maxcnt = SVAL(req->vwv+5, 0); + state->smb_mincnt = SVAL(req->vwv+6, 0); + + reply_outbuf(req, 12, state->smb_maxcnt); data = (uint8_t *)smb_buf(req->outbuf); - status = np_read(fsp->fake_file_handle, data, smb_maxcnt, &nread, - &unused); + /* + * We have to tell the upper layers that we're async. + */ + state->outbuf = req->outbuf; + req->outbuf = NULL; - if (!NT_STATUS_IS_OK(status)) { - reply_doserror(req, ERRDOS, ERRnoaccess); + subreq = np_read_send(state, smbd_event_context(), + fsp->fake_file_handle, data, + state->smb_maxcnt); + if (subreq == NULL) { + reply_nterror(req, NT_STATUS_NO_MEMORY); return; } + subreq->async.fn = pipe_read_andx_done; + subreq->async.priv = talloc_move(req->conn, &req); +} + +static void pipe_read_andx_done(struct async_req *subreq) +{ + struct smb_request *req = talloc_get_type_abort( + subreq->async.priv, struct smb_request); + struct pipe_read_andx_state *state = talloc_get_type_abort( + req->async_priv, struct pipe_read_andx_state); + NTSTATUS status; + ssize_t nread; + bool is_data_outstanding; + + status = np_read_recv(subreq, &nread, &is_data_outstanding); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status)) { + reply_nterror(req, status); + goto done; + } + + req->outbuf = state->outbuf; + state->outbuf = NULL; srv_set_message((char *)req->outbuf, 12, nread, False); @@ -380,10 +423,11 @@ void reply_pipe_read_and_X(struct smb_request *req) + 1 /* the wct field */ + 12 * sizeof(uint16_t) /* vwv */ + 2); /* the buflen field */ - SSVAL(req->outbuf,smb_vwv11,smb_maxcnt); + SSVAL(req->outbuf,smb_vwv11,state->smb_maxcnt); - DEBUG(3,("readX-IPC pnum=%04x min=%d max=%d nread=%d\n", - fsp->fnum, smb_mincnt, smb_maxcnt, (int)nread)); + DEBUG(3,("readX-IPC min=%d max=%d nread=%d\n", + state->smb_mincnt, state->smb_maxcnt, (int)nread)); + done: chain_reply(req); } -- cgit From fa7ddc78b8da8265096b1cc45471e1c7c96ac994 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 31 Jan 2009 16:17:25 +0100 Subject: Remove unused np_read sync wrapper --- source3/include/proto.h | 2 -- source3/rpc_server/srv_pipe_hnd.c | 30 ------------------------------ 2 files changed, 32 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 081225614f..fd556690aa 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6323,8 +6323,6 @@ struct async_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev, uint8_t *data, size_t len); NTSTATUS np_read_recv(struct async_req *req, ssize_t *nread, bool *is_data_outstanding); -NTSTATUS np_read(struct fake_file_handle *handle, uint8_t *data, size_t len, - ssize_t *nread, bool *is_data_outstanding); /* The following definitions come from rpc_server/srv_samr_util.c */ diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 813561bac4..0a4d94fedc 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1285,33 +1285,3 @@ NTSTATUS np_read_recv(struct async_req *req, ssize_t *nread, *is_data_outstanding = state->is_data_outstanding; return NT_STATUS_OK; } - -NTSTATUS np_read(struct fake_file_handle *handle, uint8_t *data, size_t len, - ssize_t *nread, bool *is_data_outstanding) -{ - TALLOC_CTX *frame = talloc_stackframe(); - struct event_context *ev; - struct async_req *req; - NTSTATUS status; - - ev = event_context_init(frame); - if (ev == NULL) { - status = NT_STATUS_NO_MEMORY; - goto fail; - } - - req = np_read_send(frame, ev, handle, data, len); - if (req == NULL) { - status = NT_STATUS_NO_MEMORY; - goto fail; - } - - while (req->state < ASYNC_REQ_DONE) { - event_loop_once(ev); - } - - status = np_read_recv(req, nread, is_data_outstanding); - fail: - TALLOC_FREE(frame); - return status; -} -- cgit From 99f021d0ef5f1e8e7793c28f1c5ed03912218142 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 1 Feb 2009 00:07:16 +0100 Subject: Fix the build on Solaris CC --- source3/rpc_server/srv_pipe_hnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 0a4d94fedc..90fa49f451 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1184,7 +1184,7 @@ static void np_write_done(struct async_req *subreq) async_req_error(req, status); return; } - return async_req_done(req); + async_req_done(req); } NTSTATUS np_write_recv(struct async_req *req, ssize_t *pnwritten) -- cgit From 06a24497dc167853bbd2171e50945595a62c5623 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 31 Jan 2009 23:32:01 +0100 Subject: s4:nbt_server/wins/: fix compiler warnings in winsdb.c metze --- source4/nbt_server/wins/winsdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c index bf9b8c442a..5c3efe2b83 100644 --- a/source4/nbt_server/wins/winsdb.c +++ b/source4/nbt_server/wins/winsdb.c @@ -168,7 +168,7 @@ static struct ldb_dn *winsdb_dn(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, return dn; } -static NTSTATUS winsdb_nbt_name(TALLOC_CTX *mem_ctx, const struct ldb_dn *dn, struct nbt_name **_name) +static NTSTATUS winsdb_nbt_name(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, struct nbt_name **_name) { NTSTATUS status; struct nbt_name *name; -- cgit From 15239f742cfcebe0bce4dbf4cb74eb2e8dcab364 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 31 Jan 2009 23:43:43 +0100 Subject: s4:kdc: avoid c++ reserved word 'private' metze --- source4/kdc/hdb-samba4.c | 52 ++++++++++++++++++++++++------------------------ source4/kdc/kdc.c | 13 ++++++------ source4/kdc/pac-glue.c | 34 +++++++++++++++---------------- 3 files changed, 50 insertions(+), 49 deletions(-) diff --git a/source4/kdc/hdb-samba4.c b/source4/kdc/hdb-samba4.c index 937839d67d..daeed77975 100644 --- a/source4/kdc/hdb-samba4.c +++ b/source4/kdc/hdb-samba4.c @@ -186,9 +186,9 @@ static HDBFlags uf2HDBFlags(krb5_context context, int userAccountControl, enum h return flags; } -static int hdb_ldb_destructor(struct hdb_ldb_private *private) +static int hdb_ldb_destructor(struct hdb_ldb_private *p) { - hdb_entry_ex *entry_ex = private->entry_ex; + hdb_entry_ex *entry_ex = p->entry_ex; free_hdb_entry(&entry_ex->entry); return 0; } @@ -509,7 +509,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, "nCName", ldb_dn_new(mem_ctx, (struct ldb_context *)db->hdb_db, NULL)); - struct hdb_ldb_private *private; + struct hdb_ldb_private *p; NTTIME acct_expiry; struct ldb_message_element *objectclasses; @@ -531,19 +531,19 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, goto out; } - private = talloc(mem_ctx, struct hdb_ldb_private); - if (!private) { + p = talloc(mem_ctx, struct hdb_ldb_private); + if (!p) { ret = ENOMEM; goto out; } - private->entry_ex = entry_ex; - private->iconv_convenience = lp_iconv_convenience(lp_ctx); - private->netbios_name = lp_netbios_name(lp_ctx); + p->entry_ex = entry_ex; + p->iconv_convenience = lp_iconv_convenience(lp_ctx); + p->netbios_name = lp_netbios_name(lp_ctx); - talloc_set_destructor(private, hdb_ldb_destructor); + talloc_set_destructor(p, hdb_ldb_destructor); - entry_ex->ctx = private; + entry_ex->ctx = p; entry_ex->free_entry = hdb_ldb_free_entry; userAccountControl = ldb_msg_find_attr_as_uint(msg, "userAccountControl", 0); @@ -655,7 +655,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, entry_ex->entry.generation = NULL; /* Get keys from the db */ - ret = LDB_message2entry_keys(context, private->iconv_convenience, private, msg, userAccountControl, entry_ex); + ret = LDB_message2entry_keys(context, p->iconv_convenience, p, msg, userAccountControl, entry_ex); if (ret) { /* Could be bougus data in the entry, or out of memory */ goto out; @@ -679,9 +679,9 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, } - private->msg = talloc_steal(private, msg); - private->realm_ref_msg = talloc_steal(private, realm_ref_msg); - private->samdb = (struct ldb_context *)db->hdb_db; + p->msg = talloc_steal(p, msg); + p->realm_ref_msg = talloc_steal(p, realm_ref_msg); + p->samdb = (struct ldb_context *)db->hdb_db; out: if (ret != 0) { @@ -712,24 +712,24 @@ static krb5_error_code LDB_trust_message2entry(krb5_context context, HDB *db, struct samr_Password password_hash; const struct ldb_val *password_val; struct trustAuthInOutBlob password_blob; - struct hdb_ldb_private *private; + struct hdb_ldb_private *p; enum ndr_err_code ndr_err; int i, ret, trust_direction_flags; - private = talloc(mem_ctx, struct hdb_ldb_private); - if (!private) { + p = talloc(mem_ctx, struct hdb_ldb_private); + if (!p) { ret = ENOMEM; goto out; } - private->entry_ex = entry_ex; - private->iconv_convenience = lp_iconv_convenience(lp_ctx); - private->netbios_name = lp_netbios_name(lp_ctx); + p->entry_ex = entry_ex; + p->iconv_convenience = lp_iconv_convenience(lp_ctx); + p->netbios_name = lp_netbios_name(lp_ctx); - talloc_set_destructor(private, hdb_ldb_destructor); + talloc_set_destructor(p, hdb_ldb_destructor); - entry_ex->ctx = private; + entry_ex->ctx = p; entry_ex->free_entry = hdb_ldb_free_entry; /* use 'whenCreated' */ @@ -756,7 +756,7 @@ static krb5_error_code LDB_trust_message2entry(krb5_context context, HDB *db, goto out; } - ndr_err = ndr_pull_struct_blob(password_val, mem_ctx, private->iconv_convenience, &password_blob, + ndr_err = ndr_pull_struct_blob(password_val, mem_ctx, p->iconv_convenience, &password_blob, (ndr_pull_flags_fn_t)ndr_pull_trustAuthInOutBlob); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { ret = EINVAL; @@ -868,9 +868,9 @@ static krb5_error_code LDB_trust_message2entry(krb5_context context, HDB *db, } - private->msg = talloc_steal(private, msg); - private->realm_ref_msg = NULL; - private->samdb = (struct ldb_context *)db->hdb_db; + p->msg = talloc_steal(p, msg); + p->realm_ref_msg = NULL; + p->samdb = (struct ldb_context *)db->hdb_db; out: if (ret != 0) { diff --git a/source4/kdc/kdc.c b/source4/kdc/kdc.c index c11c4a6eee..db824db86c 100644 --- a/source4/kdc/kdc.c +++ b/source4/kdc/kdc.c @@ -200,9 +200,9 @@ static void kdc_recv_handler(struct kdc_socket *kdc_socket) handle fd events on a KDC socket */ static void kdc_socket_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct kdc_socket *kdc_socket = talloc_get_type(private, struct kdc_socket); + struct kdc_socket *kdc_socket = talloc_get_type(private_data, struct kdc_socket); if (flags & EVENT_FD_WRITE) { kdc_send_handler(kdc_socket); } @@ -219,9 +219,9 @@ static void kdc_tcp_terminate_connection(struct kdc_tcp_connection *kdcconn, con /* receive a full packet on a KDC connection */ -static NTSTATUS kdc_tcp_recv(void *private, DATA_BLOB blob) +static NTSTATUS kdc_tcp_recv(void *private_data, DATA_BLOB blob) { - struct kdc_tcp_connection *kdcconn = talloc_get_type(private, + struct kdc_tcp_connection *kdcconn = talloc_get_type(private_data, struct kdc_tcp_connection); NTSTATUS status = NT_STATUS_UNSUCCESSFUL; TALLOC_CTX *tmp_ctx = talloc_new(kdcconn); @@ -293,9 +293,10 @@ static void kdc_tcp_recv_handler(struct stream_connection *conn, uint16_t flags) /* called on a tcp recv error */ -static void kdc_tcp_recv_error(void *private, NTSTATUS status) +static void kdc_tcp_recv_error(void *private_data, NTSTATUS status) { - struct kdc_tcp_connection *kdcconn = talloc_get_type(private, struct kdc_tcp_connection); + struct kdc_tcp_connection *kdcconn = talloc_get_type(private_data, + struct kdc_tcp_connection); kdc_tcp_terminate_connection(kdcconn, nt_errstr(status)); } diff --git a/source4/kdc/pac-glue.c b/source4/kdc/pac-glue.c index 74bec85d02..1a0df8e4a1 100644 --- a/source4/kdc/pac-glue.c +++ b/source4/kdc/pac-glue.c @@ -111,8 +111,8 @@ krb5_error_code samba_kdc_get_pac(void *priv, krb5_error_code ret; NTSTATUS nt_status; struct auth_serversupplied_info *server_info; - struct hdb_ldb_private *private = talloc_get_type(client->ctx, struct hdb_ldb_private); - TALLOC_CTX *mem_ctx = talloc_named(private, 0, "samba_get_pac context"); + struct hdb_ldb_private *p = talloc_get_type(client->ctx, struct hdb_ldb_private); + TALLOC_CTX *mem_ctx = talloc_named(p, 0, "samba_get_pac context"); unsigned int userAccountControl; if (!mem_ctx) { @@ -120,16 +120,16 @@ krb5_error_code samba_kdc_get_pac(void *priv, } /* The user account may be set not to want the PAC */ - userAccountControl = ldb_msg_find_attr_as_uint(private->msg, "userAccountControl", 0); + userAccountControl = ldb_msg_find_attr_as_uint(p->msg, "userAccountControl", 0); if (userAccountControl & UF_NO_AUTH_DATA_REQUIRED) { *pac = NULL; return 0; } - nt_status = authsam_make_server_info(mem_ctx, private->samdb, - private->netbios_name, - private->msg, - private->realm_ref_msg, + nt_status = authsam_make_server_info(mem_ctx, p->samdb, + p->netbios_name, + p->msg, + p->realm_ref_msg, data_blob(NULL, 0), data_blob(NULL, 0), &server_info); @@ -139,7 +139,7 @@ krb5_error_code samba_kdc_get_pac(void *priv, return ENOMEM; } - ret = make_pac(context, mem_ctx, private->iconv_convenience, server_info, pac); + ret = make_pac(context, mem_ctx, p->iconv_convenience, server_info, pac); talloc_free(mem_ctx); return ret; @@ -156,25 +156,25 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context, unsigned int userAccountControl; - struct hdb_ldb_private *private = talloc_get_type(server->ctx, struct hdb_ldb_private); + struct hdb_ldb_private *p = talloc_get_type(server->ctx, struct hdb_ldb_private); struct auth_serversupplied_info *server_info_out; - TALLOC_CTX *mem_ctx = talloc_named(private, 0, "samba_get_pac context"); + TALLOC_CTX *mem_ctx = talloc_named(p, 0, "samba_get_pac context"); if (!mem_ctx) { return ENOMEM; } /* The service account may be set not to want the PAC */ - userAccountControl = ldb_msg_find_attr_as_uint(private->msg, "userAccountControl", 0); + userAccountControl = ldb_msg_find_attr_as_uint(p->msg, "userAccountControl", 0); if (userAccountControl & UF_NO_AUTH_DATA_REQUIRED) { talloc_free(mem_ctx); *pac = NULL; return 0; } - ret = kerberos_pac_to_server_info(mem_ctx, private->iconv_convenience, + ret = kerberos_pac_to_server_info(mem_ctx, p->iconv_convenience, *pac, context, &server_info_out); /* We will compleatly regenerate this pac */ @@ -185,7 +185,7 @@ krb5_error_code samba_kdc_reget_pac(void *priv, krb5_context context, return ret; } - ret = make_pac(context, mem_ctx, private->iconv_convenience, server_info_out, pac); + ret = make_pac(context, mem_ctx, p->iconv_convenience, server_info_out, pac); talloc_free(mem_ctx); return ret; @@ -236,7 +236,7 @@ krb5_error_code samba_kdc_check_client_access(void *priv, krb5_error_code ret; NTSTATUS nt_status; TALLOC_CTX *tmp_ctx = talloc_new(entry_ex->ctx); - struct hdb_ldb_private *private = talloc_get_type(entry_ex->ctx, struct hdb_ldb_private); + struct hdb_ldb_private *p = talloc_get_type(entry_ex->ctx, struct hdb_ldb_private); char *name, *workstation = NULL; HostAddresses *addresses = req->req_body.addresses; int i; @@ -272,10 +272,10 @@ krb5_error_code samba_kdc_check_client_access(void *priv, /* we allow all kinds of trusts here */ nt_status = authsam_account_ok(tmp_ctx, - private->samdb, + p->samdb, MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT | MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT, - private->msg, - private->realm_ref_msg, + p->msg, + p->realm_ref_msg, workstation, name, true); free(name); -- cgit From f3f2dfc51a25080290e13ed1d1f8c85932e0be31 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 31 Jan 2009 23:57:02 +0100 Subject: s4:lib/messaging: avoid c++ reserved word 'private' metze --- source4/lib/messaging/irpc.h | 14 ++++++------- source4/lib/messaging/messaging.c | 40 +++++++++++++++++++------------------- source4/lib/messaging/tests/irpc.c | 4 ++-- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/source4/lib/messaging/irpc.h b/source4/lib/messaging/irpc.h index fa91a147c6..9be8461f6a 100644 --- a/source4/lib/messaging/irpc.h +++ b/source4/lib/messaging/irpc.h @@ -48,10 +48,10 @@ struct irpc_message { typedef NTSTATUS (*irpc_function_t)(struct irpc_message *, void *r); /* register a server function with the irpc messaging system */ -#define IRPC_REGISTER(msg_ctx, pipename, funcname, function, private) \ +#define IRPC_REGISTER(msg_ctx, pipename, funcname, function, private_data) \ irpc_register(msg_ctx, &ndr_table_ ## pipename, \ NDR_ ## funcname, \ - (irpc_function_t)function, private) + (irpc_function_t)function, private_data) /* make a irpc call */ #define IRPC_CALL(msg_ctx, server_id, pipename, funcname, ptr, ctx) \ @@ -82,16 +82,16 @@ struct irpc_request { struct loadparm_context; -typedef void (*msg_callback_t)(struct messaging_context *msg, void *private, +typedef void (*msg_callback_t)(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data); NTSTATUS messaging_send(struct messaging_context *msg, struct server_id server, uint32_t msg_type, DATA_BLOB *data); -NTSTATUS messaging_register(struct messaging_context *msg, void *private, +NTSTATUS messaging_register(struct messaging_context *msg, void *private_data, uint32_t msg_type, msg_callback_t fn); -NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private, +NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private_data, msg_callback_t fn, uint32_t *msg_type); struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, const char *dir, @@ -104,14 +104,14 @@ struct messaging_context *messaging_client_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev); NTSTATUS messaging_send_ptr(struct messaging_context *msg, struct server_id server, uint32_t msg_type, void *ptr); -void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private); +void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private_data); NTSTATUS irpc_register(struct messaging_context *msg_ctx, const struct ndr_interface_table *table, - int call, irpc_function_t fn, void *private); + int call, irpc_function_t fn, void *private_data); struct irpc_request *irpc_call_send(struct messaging_context *msg_ctx, struct server_id server_id, const struct ndr_interface_table *table, diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index decad7b5a8..c27f977cce 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -64,7 +64,7 @@ struct messaging_context { struct dispatch_fn { struct dispatch_fn *next, *prev; uint32_t msg_type; - void *private; + void *private_data; msg_callback_t fn; }; @@ -94,7 +94,7 @@ static void irpc_handler(struct messaging_context *, void *, /* A useful function for testing the message system. */ -static void ping_message(struct messaging_context *msg, void *private, +static void ping_message(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data) { DEBUG(1,("INFO: Received PING message from server %u.%u [%.*s]\n", @@ -149,7 +149,7 @@ static void messaging_dispatch(struct messaging_context *msg, struct messaging_r next = d->next; data.data = rec->packet.data + sizeof(*rec->header); data.length = rec->header->length; - d->fn(msg, d->private, d->msg_type, rec->header->from, &data); + d->fn(msg, d->private_data, d->msg_type, rec->header->from, &data); } rec->header->length = 0; } @@ -217,9 +217,9 @@ static NTSTATUS try_send(struct messaging_rec *rec) retry backed off messages */ static void msg_retry_timer(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct messaging_context *msg = talloc_get_type(private, + struct messaging_context *msg = talloc_get_type(private_data, struct messaging_context); msg->retry_te = NULL; @@ -339,9 +339,9 @@ static void messaging_recv_handler(struct messaging_context *msg) handle a socket event */ static void messaging_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct messaging_context *msg = talloc_get_type(private, + struct messaging_context *msg = talloc_get_type(private_data, struct messaging_context); if (flags & EVENT_FD_WRITE) { messaging_send_handler(msg); @@ -355,7 +355,7 @@ static void messaging_handler(struct tevent_context *ev, struct tevent_fd *fde, /* Register a dispatch function for a particular message type. */ -NTSTATUS messaging_register(struct messaging_context *msg, void *private, +NTSTATUS messaging_register(struct messaging_context *msg, void *private_data, uint32_t msg_type, msg_callback_t fn) { struct dispatch_fn *d; @@ -376,7 +376,7 @@ NTSTATUS messaging_register(struct messaging_context *msg, void *private, d = talloc_zero(msg->dispatch, struct dispatch_fn); NT_STATUS_HAVE_NO_MEMORY(d); d->msg_type = msg_type; - d->private = private; + d->private_data = private_data; d->fn = fn; DLIST_ADD(msg->dispatch[msg_type], d); @@ -388,7 +388,7 @@ NTSTATUS messaging_register(struct messaging_context *msg, void *private, register a temporary message handler. The msg_type is allocated above MSG_TMP_BASE */ -NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private, +NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private_data, msg_callback_t fn, uint32_t *msg_type) { struct dispatch_fn *d; @@ -396,7 +396,7 @@ NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private, d = talloc_zero(msg->dispatch, struct dispatch_fn); NT_STATUS_HAVE_NO_MEMORY(d); - d->private = private; + d->private_data = private_data; d->fn = fn; id = idr_get_new_above(msg->dispatch_tree, d, MSG_TMP_BASE, UINT16_MAX); @@ -414,7 +414,7 @@ NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private, /* De-register the function for a particular message type. */ -void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private) +void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private_data) { struct dispatch_fn *d, *next; @@ -429,7 +429,7 @@ void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void for (d = msg->dispatch[msg_type]; d; d = next) { next = d->next; - if (d->private == private) { + if (d->private_data == private_data) { DLIST_REMOVE(msg->dispatch[msg_type], d); talloc_free(d); } @@ -631,7 +631,7 @@ struct irpc_list { const struct ndr_interface_table *table; int callnum; irpc_function_t fn; - void *private; + void *private_data; }; @@ -640,7 +640,7 @@ struct irpc_list { */ NTSTATUS irpc_register(struct messaging_context *msg_ctx, const struct ndr_interface_table *table, - int callnum, irpc_function_t fn, void *private) + int callnum, irpc_function_t fn, void *private_data) { struct irpc_list *irpc; @@ -659,7 +659,7 @@ NTSTATUS irpc_register(struct messaging_context *msg_ctx, irpc->table = table; irpc->callnum = callnum; irpc->fn = fn; - irpc->private = private; + irpc->private_data = private_data; irpc->uuid = irpc->table->syntax_id.uuid; return NT_STATUS_OK; @@ -768,7 +768,7 @@ static void irpc_handler_request(struct messaging_context *msg_ctx, if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) goto failed; /* make the call */ - m->private = i->private; + m->private = i->private_data; m->defer_reply = false; m->msg_ctx = msg_ctx; m->irpc = i; @@ -793,7 +793,7 @@ failed: /* handle an incoming irpc message */ -static void irpc_handler(struct messaging_context *msg_ctx, void *private, +static void irpc_handler(struct messaging_context *msg_ctx, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *packet) { struct irpc_message *m; @@ -844,9 +844,9 @@ static int irpc_destructor(struct irpc_request *irpc) timeout a irpc request */ static void irpc_timeout(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct irpc_request *irpc = talloc_get_type(private, struct irpc_request); + struct irpc_request *irpc = talloc_get_type(private_data, struct irpc_request); irpc->status = NT_STATUS_IO_TIMEOUT; irpc->done = true; if (irpc->async.fn) { diff --git a/source4/lib/messaging/tests/irpc.c b/source4/lib/messaging/tests/irpc.c index d45bcb6bf7..5d49438c5c 100644 --- a/source4/lib/messaging/tests/irpc.c +++ b/source4/lib/messaging/tests/irpc.c @@ -54,9 +54,9 @@ static NTSTATUS irpc_AddOne(struct irpc_message *irpc, struct echo_AddOne *r) a deferred reply to echodata */ static void deferred_echodata(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct irpc_message *irpc = talloc_get_type(private, struct irpc_message); + struct irpc_message *irpc = talloc_get_type(private_data, struct irpc_message); struct echo_EchoData *r = irpc->data; r->out.out_data = talloc_memdup(r, r->in.in_data, r->in.len); if (r->out.out_data == NULL) { -- cgit From 96f176dbd84090fd18b8c796f869ddaa2da39e59 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 1 Feb 2009 00:02:17 +0100 Subject: s4:lib/messaging: fix warnings in testsuite metze --- source4/lib/messaging/tests/irpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source4/lib/messaging/tests/irpc.c b/source4/lib/messaging/tests/irpc.c index 5d49438c5c..42a811d116 100644 --- a/source4/lib/messaging/tests/irpc.c +++ b/source4/lib/messaging/tests/irpc.c @@ -87,7 +87,7 @@ static bool test_addone(struct torture_context *test, const void *_data, struct echo_AddOne r; NTSTATUS status; const struct irpc_test_data *data = (const struct irpc_test_data *)_data; - uint32_t value = (uint32_t)_value; + uint32_t value = *(const uint32_t *)_value; /* make the call */ r.in.in_data = value; @@ -261,7 +261,7 @@ struct torture_suite *torture_local_irpc(TALLOC_CTX *mem_ctx) for (i = 0; i < 5; i++) { torture_tcase_add_test_const(tcase, "addone", test_addone, - (void *)values[i]); + (void *)&values[i]); } torture_tcase_add_test_const(tcase, "echodata", test_echodata, NULL); -- cgit From 5f13710ced2565355c3cdcef04067cacdf74a9ad Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 1 Feb 2009 00:03:47 +0100 Subject: s4:irpc: avoid c++ reserved word 'private' metze --- source4/kdc/kdc.c | 2 +- source4/lib/messaging/irpc.h | 4 ++-- source4/lib/messaging/messaging.c | 4 ++-- source4/lib/messaging/tests/irpc.c | 4 ++-- source4/libcli/composite/composite.c | 2 +- source4/libcli/finddcs.c | 2 +- source4/libcli/wbclient/wbclient.c | 4 ++-- source4/nbt_server/irpc.c | 5 +++-- source4/nbt_server/wins/winswack.c | 4 ++-- source4/smb_server/management.c | 6 ++++-- source4/winbind/wb_irpc.c | 4 ++-- source4/wrepl_server/wrepl_apply_records.c | 12 ++++++------ source4/wrepl_server/wrepl_scavenging.c | 4 ++-- 13 files changed, 30 insertions(+), 27 deletions(-) diff --git a/source4/kdc/kdc.c b/source4/kdc/kdc.c index db824db86c..48ef5c50d2 100644 --- a/source4/kdc/kdc.c +++ b/source4/kdc/kdc.c @@ -566,7 +566,7 @@ static NTSTATUS kdc_check_generic_kerberos(struct irpc_message *msg, struct PAC_Validate pac_validate; DATA_BLOB srv_sig; struct PAC_SIGNATURE_DATA kdc_sig; - struct kdc_server *kdc = talloc_get_type(msg->private, struct kdc_server); + struct kdc_server *kdc = talloc_get_type(msg->private_data, struct kdc_server); enum ndr_err_code ndr_err; krb5_enctype etype; int ret; diff --git a/source4/lib/messaging/irpc.h b/source4/lib/messaging/irpc.h index 9be8461f6a..3c518828ab 100644 --- a/source4/lib/messaging/irpc.h +++ b/source4/lib/messaging/irpc.h @@ -30,7 +30,7 @@ */ struct irpc_message { struct server_id from; - void *private; + void *private_data; struct irpc_header header; struct ndr_pull *ndr; bool defer_reply; @@ -76,7 +76,7 @@ struct irpc_request { TALLOC_CTX *mem_ctx; struct { void (*fn)(struct irpc_request *); - void *private; + void *private_data; } async; }; diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index c27f977cce..cfceeffac7 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -109,7 +109,7 @@ static void ping_message(struct messaging_context *msg, void *private_data, static NTSTATUS irpc_uptime(struct irpc_message *msg, struct irpc_uptime *r) { - struct messaging_context *ctx = talloc_get_type(msg->private, struct messaging_context); + struct messaging_context *ctx = talloc_get_type(msg->private_data, struct messaging_context); *r->out.start_time = timeval_to_nttime(&ctx->start_time); return NT_STATUS_OK; } @@ -768,7 +768,7 @@ static void irpc_handler_request(struct messaging_context *msg_ctx, if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) goto failed; /* make the call */ - m->private = i->private_data; + m->private_data= i->private_data; m->defer_reply = false; m->msg_ctx = msg_ctx; m->irpc = i; diff --git a/source4/lib/messaging/tests/irpc.c b/source4/lib/messaging/tests/irpc.c index 42a811d116..3eb23e0f7d 100644 --- a/source4/lib/messaging/tests/irpc.c +++ b/source4/lib/messaging/tests/irpc.c @@ -145,7 +145,7 @@ static bool test_echodata(struct torture_context *tctx, static void irpc_callback(struct irpc_request *irpc) { struct echo_AddOne *r = (struct echo_AddOne *)irpc->r; - int *pong_count = (int *)irpc->async.private; + int *pong_count = (int *)irpc->async.private_data; NTSTATUS status = irpc_call_recv(irpc); if (!NT_STATUS_IS_OK(status)) { printf("irpc call failed - %s\n", nt_errstr(status)); @@ -186,7 +186,7 @@ static bool test_speed(struct torture_context *tctx, torture_assert(tctx, irpc != NULL, "AddOne send failed"); irpc->async.fn = irpc_callback; - irpc->async.private = &pong_count; + irpc->async.private_data = &pong_count; ping_count++; diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index aff8f79481..a6b1c68d1c 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -184,7 +184,7 @@ _PUBLIC_ void composite_continue_irpc(struct composite_context *ctx, { if (composite_nomem(new_req, ctx)) return; new_req->async.fn = continuation; - new_req->async.private = private_data; + new_req->async.private_data = private_data; } _PUBLIC_ void composite_continue_smb(struct composite_context *ctx, diff --git a/source4/libcli/finddcs.c b/source4/libcli/finddcs.c index 6e531391a6..2e4fad9332 100644 --- a/source4/libcli/finddcs.c +++ b/source4/libcli/finddcs.c @@ -174,7 +174,7 @@ static void finddcs_name_resolved(struct composite_context *ctx) static void finddcs_getdc_replied(struct irpc_request *ireq) { struct finddcs_state *state = - talloc_get_type(ireq->async.private, struct finddcs_state); + talloc_get_type(ireq->async.private_data, struct finddcs_state); state->ctx->status = irpc_call_recv(ireq); if (!composite_is_ok(state->ctx)) return; diff --git a/source4/libcli/wbclient/wbclient.c b/source4/libcli/wbclient/wbclient.c index b881e32f7b..da7d678da9 100644 --- a/source4/libcli/wbclient/wbclient.c +++ b/source4/libcli/wbclient/wbclient.c @@ -117,7 +117,7 @@ struct composite_context *wbc_sids_to_xids_send(struct wbc_context *wbc_ctx, static void sids_to_xids_recv_ids(struct irpc_request *req) { struct wbc_idmap_state *state = talloc_get_type_abort( - req->async.private, + req->async.private_data, struct wbc_idmap_state); state->ctx->status = irpc_call_recv(state->irpc_req); @@ -183,7 +183,7 @@ struct composite_context *wbc_xids_to_sids_send(struct wbc_context *wbc_ctx, static void xids_to_sids_recv_ids(struct irpc_request *req) { struct wbc_idmap_state *state = talloc_get_type_abort( - req->async.private, + req->async.private_data, struct wbc_idmap_state); state->ctx->status = irpc_call_recv(state->irpc_req); diff --git a/source4/nbt_server/irpc.c b/source4/nbt_server/irpc.c index fc61372ead..748f18dcfd 100644 --- a/source4/nbt_server/irpc.c +++ b/source4/nbt_server/irpc.c @@ -36,7 +36,8 @@ static NTSTATUS nbtd_information(struct irpc_message *msg, struct nbtd_information *r) { - struct nbtd_server *server = talloc_get_type(msg->private, struct nbtd_server); + struct nbtd_server *server = talloc_get_type(msg->private_data, + struct nbtd_server); switch (r->in.level) { case NBTD_INFO_STATISTICS: @@ -111,7 +112,7 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg, struct nbtd_getdcname *req) { struct nbtd_server *server = - talloc_get_type(msg->private, struct nbtd_server); + talloc_get_type(msg->private_data, struct nbtd_server); struct nbtd_interface *iface = nbtd_find_request_iface(server, req->in.ip_address, true); struct getdc_state *s; struct nbt_netlogon_packet p; diff --git a/source4/nbt_server/wins/winswack.c b/source4/nbt_server/wins/winswack.c index c499889f9e..c53fa1d069 100644 --- a/source4/nbt_server/wins/winswack.c +++ b/source4/nbt_server/wins/winswack.c @@ -295,7 +295,7 @@ NTSTATUS nbtd_proxy_wins_challenge(struct irpc_message *msg, struct nbtd_proxy_wins_challenge *req) { struct nbtd_server *nbtd_server = - talloc_get_type(msg->private, struct nbtd_server); + talloc_get_type(msg->private_data, struct nbtd_server); struct proxy_wins_challenge_state *s; uint32_t i; @@ -355,7 +355,7 @@ NTSTATUS nbtd_proxy_wins_release_demand(struct irpc_message *msg, struct nbtd_proxy_wins_release_demand *req) { struct nbtd_server *nbtd_server = - talloc_get_type(msg->private, struct nbtd_server); + talloc_get_type(msg->private_data, struct nbtd_server); struct proxy_wins_release_demand_state *s; uint32_t i; diff --git a/source4/smb_server/management.c b/source4/smb_server/management.c index 4306b22c30..e58c278613 100644 --- a/source4/smb_server/management.c +++ b/source4/smb_server/management.c @@ -32,7 +32,8 @@ static NTSTATUS smbsrv_session_information(struct irpc_message *msg, struct smbsrv_information *r) { - struct smbsrv_connection *smb_conn = talloc_get_type(msg->private, struct smbsrv_connection); + struct smbsrv_connection *smb_conn = talloc_get_type(msg->private_data, + struct smbsrv_connection); int i=0, count=0; struct smbsrv_session *sess; @@ -75,7 +76,8 @@ static NTSTATUS smbsrv_session_information(struct irpc_message *msg, static NTSTATUS smbsrv_tcon_information(struct irpc_message *msg, struct smbsrv_information *r) { - struct smbsrv_connection *smb_conn = talloc_get_type(msg->private, struct smbsrv_connection); + struct smbsrv_connection *smb_conn = talloc_get_type(msg->private_data, + struct smbsrv_connection); int i=0, count=0; struct smbsrv_tcon *tcon; diff --git a/source4/winbind/wb_irpc.c b/source4/winbind/wb_irpc.c index 0535045adb..42f4e7c94b 100644 --- a/source4/winbind/wb_irpc.c +++ b/source4/winbind/wb_irpc.c @@ -36,7 +36,7 @@ static void wb_irpc_SamLogon_callback(struct composite_context *ctx); static NTSTATUS wb_irpc_SamLogon(struct irpc_message *msg, struct winbind_SamLogon *req) { - struct wbsrv_service *service = talloc_get_type(msg->private, + struct wbsrv_service *service = talloc_get_type(msg->private_data, struct wbsrv_service); struct wb_irpc_SamLogon_state *s; struct composite_context *ctx; @@ -83,7 +83,7 @@ static void wb_irpc_get_idmap_callback(struct composite_context *ctx); static NTSTATUS wb_irpc_get_idmap(struct irpc_message *msg, struct winbind_get_idmap *req) { - struct wbsrv_service *service = talloc_get_type(msg->private, + struct wbsrv_service *service = talloc_get_type(msg->private_data, struct wbsrv_service); struct wb_irpc_get_idmap_state *s; struct composite_context *ctx; diff --git a/source4/wrepl_server/wrepl_apply_records.c b/source4/wrepl_server/wrepl_apply_records.c index 96a6033b1e..e6ff9a03bf 100644 --- a/source4/wrepl_server/wrepl_apply_records.c +++ b/source4/wrepl_server/wrepl_apply_records.c @@ -893,7 +893,7 @@ struct r_do_challenge_state { static void r_do_late_release_demand_handler(struct irpc_request *ireq) { NTSTATUS status; - struct r_do_challenge_state *state = talloc_get_type(ireq->async.private, + struct r_do_challenge_state *state = talloc_get_type(ireq->async.private_data, struct r_do_challenge_state); status = irpc_call_recv(ireq); @@ -931,7 +931,7 @@ static NTSTATUS r_do_late_release_demand(struct r_do_challenge_state *state) NT_STATUS_HAVE_NO_MEMORY(ireq); ireq->async.fn = r_do_late_release_demand_handler; - ireq->async.private = state; + ireq->async.private_data= state; return NT_STATUS_OK; } @@ -954,7 +954,7 @@ _UA_MA_DI_A<00>: C:BEST vs. B:BEST2 (C:ALL) => B:MHOMED => MHOMED_MERGE static void r_do_challenge_handler(struct irpc_request *ireq) { NTSTATUS status; - struct r_do_challenge_state *state = talloc_get_type(ireq->async.private, + struct r_do_challenge_state *state = talloc_get_type(ireq->async.private_data, struct r_do_challenge_state); bool old_is_subset = false; bool new_is_subset = false; @@ -1076,7 +1076,7 @@ static NTSTATUS r_do_challenge(struct wreplsrv_partner *partner, NT_STATUS_HAVE_NO_MEMORY(ireq); ireq->async.fn = r_do_challenge_handler; - ireq->async.private = state; + ireq->async.private_data= state; talloc_steal(partner, state); return NT_STATUS_OK; @@ -1090,7 +1090,7 @@ struct r_do_release_demand_state { static void r_do_release_demand_handler(struct irpc_request *ireq) { NTSTATUS status; - struct r_do_release_demand_state *state = talloc_get_type(ireq->async.private, + struct r_do_release_demand_state *state = talloc_get_type(ireq->async.private_data, struct r_do_release_demand_state); status = irpc_call_recv(ireq); @@ -1152,7 +1152,7 @@ static NTSTATUS r_do_release_demand(struct wreplsrv_partner *partner, NT_STATUS_HAVE_NO_MEMORY(ireq); ireq->async.fn = r_do_release_demand_handler; - ireq->async.private = state; + ireq->async.private_data= state; talloc_steal(partner, state); return NT_STATUS_OK; diff --git a/source4/wrepl_server/wrepl_scavenging.c b/source4/wrepl_server/wrepl_scavenging.c index 9f6a49ef09..8fc7d0a6f0 100644 --- a/source4/wrepl_server/wrepl_scavenging.c +++ b/source4/wrepl_server/wrepl_scavenging.c @@ -314,7 +314,7 @@ struct verify_state { static void verify_handler(struct irpc_request *ireq) { - struct verify_state *s = talloc_get_type(ireq->async.private, + struct verify_state *s = talloc_get_type(ireq->async.private_data, struct verify_state); struct winsdb_record *rec = s->rec; const char *action; @@ -495,7 +495,7 @@ static NTSTATUS wreplsrv_scavenging_replica_active_records(struct wreplsrv_servi NT_STATUS_HAVE_NO_MEMORY(ireq); ireq->async.fn = verify_handler; - ireq->async.private = s; + ireq->async.private_data= s; talloc_steal(service, s); } -- cgit From a5e570b56205f64fd330f0ac1fda9884a5ea8311 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 31 Jan 2009 20:00:15 -0500 Subject: Start restoring the sqlite3 backend Passes many tests but not all yet. --- source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c | 677 ++++++++++++++++-------------- 1 file changed, 357 insertions(+), 320 deletions(-) diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c index 39a77a5505..8acbac4cc3 100644 --- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c +++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c @@ -1,23 +1,23 @@ -/* +/* ldb database library - + Copyright (C) Derrell Lipman 2005 - Copyright (C) Simo Sorce 2005-2006 - + Copyright (C) Simo Sorce 2005-2009 + ** NOTE! The following LGPL license applies to the ldb ** 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 . */ @@ -50,6 +50,9 @@ struct lsql_context { long long current_eid; const char * const * attrs; struct ldb_reply *ares; + + bool callback_failed; + struct tevent_timer *timeout_event; }; /* @@ -63,7 +66,8 @@ struct lsql_context { #define RESULT_ATTR_TABLE "temp_result_attrs" -//#define TEMPTAB /* for testing, create non-temporary table */ + +/* for testing, define to nothing, (create non-temporary table) */ #define TEMPTAB "TEMPORARY" /* @@ -144,7 +148,7 @@ base160_sql(sqlite3_context * hContext, val = sqlite3_value_int64(argv[0]); for (i = 3; i >= 0; i--) { - + result[i] = base160tab[val % 160]; val /= 160; } @@ -244,6 +248,7 @@ static char *parsetree_to_sql(struct ldb_module *module, void *mem_ctx, const struct ldb_parse_tree *t) { + struct ldb_context *ldb; const struct ldb_schema_attribute *a; struct ldb_val value, subval; char *wild_card_string; @@ -252,6 +257,7 @@ static char *parsetree_to_sql(struct ldb_module *module, char *attr; int i; + ldb = ldb_module_get_ctx(module); switch(t->operation) { case LDB_OP_AND: @@ -271,7 +277,7 @@ static char *parsetree_to_sql(struct ldb_module *module, ret = talloc_asprintf(mem_ctx, "SELECT * FROM ( %s )\n", tmp); return ret; - + case LDB_OP_OR: tmp = parsetree_to_sql(module, mem_ctx, t->u.list.elements[0]); @@ -304,10 +310,10 @@ static char *parsetree_to_sql(struct ldb_module *module, */ attr = ldb_attr_casefold(mem_ctx, t->u.equality.attr); if (attr == NULL) return NULL; - a = ldb_schema_attribute_by_name(module->ldb, attr); + a = ldb_schema_attribute_by_name(ldb, attr); /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, mem_ctx, &(t->u.equality.value), &value); + a->syntax->canonicalise_fn(ldb, mem_ctx, &(t->u.equality.value), &value); if (value.data == NULL) { return NULL; } @@ -315,7 +321,7 @@ static char *parsetree_to_sql(struct ldb_module *module, if (strcasecmp(t->u.equality.attr, "dn") == 0) { /* DN query is a special ldb case */ const char *cdn = ldb_dn_get_casefold( - ldb_dn_new(mem_ctx, module->ldb, + ldb_dn_new(mem_ctx, ldb, (const char *)value.data)); return lsqlite3_tprintf(mem_ctx, @@ -352,13 +358,13 @@ static char *parsetree_to_sql(struct ldb_module *module, attr = ldb_attr_casefold(mem_ctx, t->u.substring.attr); if (attr == NULL) return NULL; - a = ldb_schema_attribute_by_name(module->ldb, attr); + a = ldb_schema_attribute_by_name(ldb, attr); subval.data = (void *)wild_card_string; subval.length = strlen(wild_card_string) + 1; /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, mem_ctx, &(subval), &value); + a->syntax->canonicalise_fn(ldb, mem_ctx, &(subval), &value); if (value.data == NULL) { return NULL; } @@ -373,10 +379,10 @@ static char *parsetree_to_sql(struct ldb_module *module, case LDB_OP_GREATER: attr = ldb_attr_casefold(mem_ctx, t->u.equality.attr); if (attr == NULL) return NULL; - a = ldb_schema_attribute_by_name(module->ldb, attr); + a = ldb_schema_attribute_by_name(ldb, attr); /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, mem_ctx, &(t->u.equality.value), &value); + a->syntax->canonicalise_fn(ldb, mem_ctx, &(t->u.equality.value), &value); if (value.data == NULL) { return NULL; } @@ -392,10 +398,10 @@ static char *parsetree_to_sql(struct ldb_module *module, case LDB_OP_LESS: attr = ldb_attr_casefold(mem_ctx, t->u.equality.attr); if (attr == NULL) return NULL; - a = ldb_schema_attribute_by_name(module->ldb, attr); + a = ldb_schema_attribute_by_name(ldb, attr); /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, mem_ctx, &(t->u.equality.value), &value); + a->syntax->canonicalise_fn(ldb, mem_ctx, &(t->u.equality.value), &value); if (value.data == NULL) { return NULL; } @@ -424,10 +430,10 @@ static char *parsetree_to_sql(struct ldb_module *module, case LDB_OP_APPROX: attr = ldb_attr_casefold(mem_ctx, t->u.equality.attr); if (attr == NULL) return NULL; - a = ldb_schema_attribute_by_name(module->ldb, attr); + a = ldb_schema_attribute_by_name(ldb, attr); /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, mem_ctx, &(t->u.equality.value), &value); + a->syntax->canonicalise_fn(ldb, mem_ctx, &(t->u.equality.value), &value); if (value.data == NULL) { return NULL; } @@ -439,7 +445,7 @@ static char *parsetree_to_sql(struct ldb_module *module, attr, value.data, attr); - + case LDB_OP_EXTENDED: #warning "work out how to handle bitops" return NULL; @@ -473,22 +479,22 @@ query_int(const struct lsqlite3_private * lsqlite3, char * p; sqlite3_stmt * pStmt; va_list args; - + /* Begin access to variable argument list */ va_start(args, pSql); - + /* Format the query */ if ((p = sqlite3_vmprintf(pSql, args)) == NULL) { return SQLITE_NOMEM; } - + /* * Prepare and execute the SQL statement. Loop allows retrying on * certain errors, e.g. SQLITE_SCHEMA occurs if the schema changes, * requiring retrying the operation. */ for (bLoop = TRUE; bLoop; ) { - + /* Compile the SQL statement into sqlite virtual machine */ if ((ret = sqlite3_prepare(lsqlite3->sqlite, p, @@ -503,7 +509,7 @@ query_int(const struct lsqlite3_private * lsqlite3, } else if (ret != SQLITE_OK) { break; } - + /* One row expected */ if ((ret = sqlite3_step(pStmt)) == SQLITE_SCHEMA) { if (stmtGetEID != NULL) { @@ -516,10 +522,10 @@ query_int(const struct lsqlite3_private * lsqlite3, (void) sqlite3_finalize(pStmt); break; } - + /* Get the value to be returned */ *pRet = sqlite3_column_int64(pStmt, 0); - + /* Free the virtual machine */ if ((ret = sqlite3_finalize(pStmt)) == SQLITE_SCHEMA) { if (stmtGetEID != NULL) { @@ -531,21 +537,21 @@ query_int(const struct lsqlite3_private * lsqlite3, (void) sqlite3_finalize(pStmt); break; } - + /* * Normal condition is only one time through loop. Loop is * rerun in error conditions, via "continue", above. */ bLoop = FALSE; } - + /* All done with variable argument list */ va_end(args); - + /* Free the memory we allocated for our query string */ sqlite3_free(p); - + return ret; } @@ -574,9 +580,9 @@ static void lsqlite3_compare(sqlite3_context *ctx, int argc, /* greater */ case '>': /* >= */ a = ldb_schema_attribute_by_name(ldb, attr); - valX.data = (void *)cmp; + valX.data = (uint8_t *)cmp; valX.length = strlen(cmp); - valY.data = (void *)val; + valY.data = (uint8_t *)val; valY.length = strlen(val); ret = a->syntax->comparison_fn(ldb, ldb, &valY, &valX); if (ret >= 0) @@ -588,9 +594,9 @@ static void lsqlite3_compare(sqlite3_context *ctx, int argc, /* lesser */ case '<': /* <= */ a = ldb_schema_attribute_by_name(ldb, attr); - valX.data = (void *)cmp; + valX.data = (uint8_t *)cmp; valX.length = strlen(cmp); - valY.data = (void *)val; + valY.data = (uint8_t *)val; valY.length = strlen(val); ret = a->syntax->comparison_fn(ldb, ldb, &valY, &valX); if (ret <= 0) @@ -656,49 +662,52 @@ static int lsqlite3_eid_callback(void *result, int col_num, char **cols, char ** */ static int lsqlite3_search_callback(void *result, int col_num, char **cols, char **names) { - struct ldb_handle *handle = talloc_get_type(result, struct ldb_handle); - struct lsql_context *ac = talloc_get_type(handle->private_data, struct lsql_context); + struct ldb_context *ldb; + struct lsql_context *ac; struct ldb_message *msg; long long eid; - int i; + int i, ret; + + ac = talloc_get_type(result, struct lsql_context); + ldb = ldb_module_get_ctx(ac->module); /* eid, dn, attr_name, attr_value */ - if (col_num != 4) - return SQLITE_ABORT; + if (col_num != 4) return SQLITE_ABORT; eid = atoll(cols[0]); + if (ac->ares) { + msg = ac->ares->message; + } + if (eid != ac->current_eid) { /* here begin a new entry */ /* call the async callback for the last entry * except the first time */ if (ac->current_eid != 0) { - ac->ares->message = ldb_msg_canonicalize(ac->module->ldb, ac->ares->message); - if (ac->ares->message == NULL) - return SQLITE_ABORT; - - handle->status = ac->callback(ac->module->ldb, ac->context, ac->ares); - if (handle->status != LDB_SUCCESS) + msg = ldb_msg_canonicalize(ldb, msg); + if (!msg) return SQLITE_ABORT; + + ret = ldb_module_send_entry(ac->req, msg, NULL); + if (ret != LDB_SUCCESS) { + ac->callback_failed = true; return SQLITE_ABORT; + } } /* start over */ ac->ares = talloc_zero(ac, struct ldb_reply); - if (!ac->ares) - return SQLITE_ABORT; + if (!ac->ares) return SQLITE_ABORT; - ac->ares->message = ldb_msg_new(ac->ares); - if (!ac->ares->message) - return SQLITE_ABORT; + msg = ldb_msg_new(ac->ares); + if (!msg) return SQLITE_ABORT; ac->ares->type = LDB_REPLY_ENTRY; ac->current_eid = eid; } - msg = ac->ares->message; - if (msg->dn == NULL) { - msg->dn = ldb_dn_new(msg, ac->module->ldb, cols[1]); + msg->dn = ldb_dn_new(msg, ldb, cols[1]); if (msg->dn == NULL) return SQLITE_ABORT; } @@ -711,13 +720,15 @@ static int lsqlite3_search_callback(void *result, int col_num, char **cols, char break; } } - if (!found) return SQLITE_OK; + if (!found) goto done; } if (ldb_msg_add_string(msg, cols[2], cols[3]) != 0) { return SQLITE_ABORT; } +done: + ac->ares->message = msg; return SQLITE_OK; } @@ -755,10 +766,10 @@ static long long lsqlite3_get_eid_ndn(sqlite3 *sqlite, void *mem_ctx, const char return eid; } -static long long lsqlite3_get_eid(struct ldb_module *module, struct ldb_dn *dn) +static long long lsqlite3_get_eid(struct lsqlite3_private *lsqlite3, + struct ldb_dn *dn) { TALLOC_CTX *local_ctx; - struct lsqlite3_private *lsqlite3 = module->private_data; long long eid = -1; char *cdn; @@ -788,38 +799,44 @@ done: */ /* search for matching records, by tree */ -int lsql_search(struct ldb_module *module, struct ldb_request *req) +int lsql_search(struct lsql_context *ctx) { - struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_context *lsql_ac; + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; + struct lsqlite3_private *lsqlite3; + struct ldb_context *ldb; char *norm_basedn; char *sqlfilter; char *errmsg; char *query = NULL; int ret; - lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); + ldb = ldb_module_get_ctx(module); + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); - if ((( ! ldb_dn_is_valid(req->op.search.base)) || ldb_dn_is_null(req->op.search.base)) && - (req->op.search.scope == LDB_SCOPE_BASE || req->op.search.scope == LDB_SCOPE_ONELEVEL)) + if ((( ! ldb_dn_is_valid(req->op.search.base)) || + ldb_dn_is_null(req->op.search.base)) && + (req->op.search.scope == LDB_SCOPE_BASE || + req->op.search.scope == LDB_SCOPE_ONELEVEL)) { return LDB_ERR_OPERATIONS_ERROR; + } if (req->op.search.base) { - norm_basedn = ldb_dn_alloc_casefold(lsql_ac, req->op.search.base); + norm_basedn = ldb_dn_alloc_casefold(ctx, req->op.search.base); if (norm_basedn == NULL) { - ret = LDB_ERR_INVALID_DN_SYNTAX; - goto failed; + return LDB_ERR_OPERATIONS_ERROR; } - } else norm_basedn = talloc_strdup(lsql_ac, ""); + } else norm_basedn = talloc_strdup(ctx, ""); /* Convert filter into a series of SQL conditions (constraints) */ - sqlfilter = parsetree_to_sql(module, lsql_ac, req->op.search.tree); - + sqlfilter = parsetree_to_sql(module, ctx, req->op.search.tree); + switch(req->op.search.scope) { case LDB_SCOPE_DEFAULT: case LDB_SCOPE_SUBTREE: if (*norm_basedn != '\0') { - query = lsqlite3_tprintf(lsql_ac, + query = lsqlite3_tprintf(ctx, "SELECT entry.eid,\n" " entry.dn,\n" " av.attr_name,\n" @@ -843,7 +860,7 @@ int lsql_search(struct ldb_module *module, struct ldb_request *req) norm_basedn, sqlfilter); } else { - query = lsqlite3_tprintf(lsql_ac, + query = lsqlite3_tprintf(ctx, "SELECT entry.eid,\n" " entry.dn,\n" " av.attr_name,\n" @@ -865,9 +882,9 @@ int lsql_search(struct ldb_module *module, struct ldb_request *req) } break; - + case LDB_SCOPE_BASE: - query = lsqlite3_tprintf(lsql_ac, + query = lsqlite3_tprintf(ctx, "SELECT entry.eid,\n" " entry.dn,\n" " av.attr_name,\n" @@ -889,9 +906,9 @@ int lsql_search(struct ldb_module *module, struct ldb_request *req) norm_basedn, sqlfilter); break; - + case LDB_SCOPE_ONELEVEL: - query = lsqlite3_tprintf(lsql_ac, + query = lsqlite3_tprintf(ctx, "SELECT entry.eid,\n" " entry.dn,\n" " av.attr_name,\n" @@ -917,113 +934,108 @@ int lsql_search(struct ldb_module *module, struct ldb_request *req) } if (query == NULL) { - goto failed; + return LDB_ERR_OPERATIONS_ERROR; } /* * / printf ("%s\n", query); / * */ - lsql_ac->current_eid = 0; - lsql_ac->attrs = req->op.search.attrs; - lsql_ac->ares = NULL; + ctx->current_eid = 0; + ctx->attrs = req->op.search.attrs; + ctx->ares = NULL; - req->handle->state = LDB_ASYNC_PENDING; + ldb_request_set_state(req, LDB_ASYNC_PENDING); - ret = sqlite3_exec(lsqlite3->sqlite, query, lsqlite3_search_callback, req->handle, &errmsg); + ret = sqlite3_exec(lsqlite3->sqlite, query, lsqlite3_search_callback, ctx, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - goto failed; + return LDB_ERR_OPERATIONS_ERROR; } /* complete the last message if any */ - if (lsql_ac->ares) { - lsql_ac->ares->message = ldb_msg_canonicalize(module->ldb, lsql_ac->ares->message); - if (lsql_ac->ares->message == NULL) - goto failed; - - req->handle->status = lsql_ac->callback(module->ldb, lsql_ac->context, lsql_ac->ares); - if (req->handle->status != LDB_SUCCESS) - goto failed; + if (ctx->ares) { + ctx->ares->message = ldb_msg_canonicalize(ldb, ctx->ares->message); + if (ctx->ares->message == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ret = ldb_module_send_entry(req, ctx->ares->message, NULL); + if (ret != LDB_SUCCESS) { + return ret; + } } - req->handle->state = LDB_ASYNC_DONE; return LDB_SUCCESS; - -failed: - return LDB_ERR_OPERATIONS_ERROR; } /* add a record */ -static int lsql_add(struct ldb_module *module, struct ldb_request *req) +static int lsql_add(struct lsql_context *ctx) { - struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_context *lsql_ac; + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; + struct lsqlite3_private *lsqlite3; + struct ldb_context *ldb; struct ldb_message *msg = req->op.add.message; long long eid; char *dn, *ndn; char *errmsg; char *query; int i; - int ret = LDB_SUCCESS; + int ret; - lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); - req->handle->state = LDB_ASYNC_DONE; - req->handle->status = LDB_SUCCESS; + ldb = ldb_module_get_ctx(module); + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); /* See if this is an ltdb special */ if (ldb_dn_is_special(msg->dn)) { /* struct ldb_dn *c; - c = ldb_dn_new(local_ctx, module->ldb, "@INDEXLIST"); - if (ldb_dn_compare(module->ldb, msg->dn, c) == 0) { + c = ldb_dn_new(local_ctx, ldb, "@INDEXLIST"); + if (ldb_dn_compare(ldb, msg->dn, c) == 0) { #warning "should we handle indexes somehow ?" ret = LDB_ERR_UNWILLING_TO_PERFORM; goto done; } */ /* Others return an error */ - ret = LDB_ERR_UNWILLING_TO_PERFORM; - goto done; + return LDB_ERR_UNWILLING_TO_PERFORM; } /* create linearized and normalized dns */ - dn = ldb_dn_alloc_linearized(lsql_ac, msg->dn); - ndn = ldb_dn_alloc_casefold(lsql_ac, msg->dn); + dn = ldb_dn_alloc_linearized(ctx, msg->dn); + ndn = ldb_dn_alloc_casefold(ctx, msg->dn); if (dn == NULL || ndn == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - query = lsqlite3_tprintf(lsql_ac, + query = lsqlite3_tprintf(ctx, /* Add new entry */ "INSERT OR ABORT INTO ldb_entry " "('dn', 'norm_dn') " "VALUES ('%q', '%q');", dn, ndn); if (query == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - eid = lsqlite3_get_eid_ndn(lsqlite3->sqlite, lsql_ac, ndn); + eid = lsqlite3_get_eid_ndn(lsqlite3->sqlite, ctx, ndn); if (eid == -1) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } for (i = 0; i < msg->num_elements; i++) { @@ -1033,13 +1045,12 @@ static int lsql_add(struct ldb_module *module, struct ldb_request *req) int j; /* Get a case-folded copy of the attribute name */ - attr = ldb_attr_casefold(lsql_ac, el->name); + attr = ldb_attr_casefold(ctx, el->name); if (attr == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - a = ldb_schema_attribute_by_name(module->ldb, el->name); + a = ldb_schema_attribute_by_name(ldb, el->name); /* For each value of the specified attribute name... */ for (j = 0; j < el->num_values; j++) { @@ -1047,13 +1058,12 @@ static int lsql_add(struct ldb_module *module, struct ldb_request *req) char *insert; /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, lsql_ac, &(el->values[j]), &value); + a->syntax->canonicalise_fn(ldb, ctx, &(el->values[j]), &value); if (value.data == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - insert = lsqlite3_tprintf(lsql_ac, + insert = lsqlite3_tprintf(ctx, "INSERT OR ROLLBACK INTO ldb_attribute_values " "('eid', 'attr_name', 'norm_attr_name'," " 'attr_value', 'norm_attr_value') " @@ -1061,57 +1071,49 @@ static int lsql_add(struct ldb_module *module, struct ldb_request *req) eid, el->name, attr, el->values[j].data, value.data); if (insert == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } ret = sqlite3_exec(lsqlite3->sqlite, insert, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } } } - if (lsql_ac->callback) { - req->handle->status = lsql_ac->callback(module->ldb, lsql_ac->context, NULL); - } - -done: - req->handle->state = LDB_ASYNC_DONE; - return ret; + return LDB_SUCCESS; } /* modify a record */ -static int lsql_modify(struct ldb_module *module, struct ldb_request *req) +static int lsql_modify(struct lsql_context *ctx) { - struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_context *lsql_ac; + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; + struct lsqlite3_private *lsqlite3; + struct ldb_context *ldb; struct ldb_message *msg = req->op.mod.message; long long eid; char *errmsg; int i; - int ret = LDB_SUCCESS; + int ret; - lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); - req->handle->state = LDB_ASYNC_DONE; - req->handle->status = LDB_SUCCESS; + ldb = ldb_module_get_ctx(module); + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); /* See if this is an ltdb special */ if (ldb_dn_is_special(msg->dn)) { /* Others return an error */ - ret = LDB_ERR_UNWILLING_TO_PERFORM; - goto done; + return LDB_ERR_UNWILLING_TO_PERFORM; } - eid = lsqlite3_get_eid(module, msg->dn); + eid = lsqlite3_get_eid(lsqlite3, msg->dn); if (eid == -1) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } for (i = 0; i < msg->num_elements; i++) { @@ -1123,37 +1125,34 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) int j; /* Get a case-folded copy of the attribute name */ - attr = ldb_attr_casefold(lsql_ac, el->name); + attr = ldb_attr_casefold(ctx, el->name); if (attr == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - a = ldb_schema_attribute_by_name(module->ldb, el->name); + a = ldb_schema_attribute_by_name(ldb, el->name); switch (flags) { case LDB_FLAG_MOD_REPLACE: - + /* remove all attributes before adding the replacements */ - mod = lsqlite3_tprintf(lsql_ac, + mod = lsqlite3_tprintf(ctx, "DELETE FROM ldb_attribute_values " "WHERE eid = '%lld' " "AND norm_attr_name = '%q';", eid, attr); if (mod == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } /* MISSING break is INTENTIONAL */ @@ -1165,13 +1164,12 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) struct ldb_val value; /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, lsql_ac, &(el->values[j]), &value); + a->syntax->canonicalise_fn(ldb, ctx, &(el->values[j]), &value); if (value.data == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - mod = lsqlite3_tprintf(lsql_ac, + mod = lsqlite3_tprintf(ctx, "INSERT OR ROLLBACK INTO ldb_attribute_values " "('eid', 'attr_name', 'norm_attr_name'," " 'attr_value', 'norm_attr_value') " @@ -1180,18 +1178,16 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) el->values[j].data, value.data); if (mod == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } } @@ -1200,24 +1196,22 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) case LDB_FLAG_MOD_DELETE: #warning "We should throw an error if the attribute we are trying to delete does not exist!" if (el->num_values == 0) { - mod = lsqlite3_tprintf(lsql_ac, + mod = lsqlite3_tprintf(ctx, "DELETE FROM ldb_attribute_values " "WHERE eid = '%lld' " "AND norm_attr_name = '%q';", eid, attr); if (mod == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } } @@ -1226,13 +1220,12 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) struct ldb_val value; /* Get a canonicalised copy of the data */ - a->syntax->canonicalise_fn(module->ldb, lsql_ac, &(el->values[j]), &value); + a->syntax->canonicalise_fn(ldb, ctx, &(el->values[j]), &value); if (value.data == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - mod = lsqlite3_tprintf(lsql_ac, + mod = lsqlite3_tprintf(ctx, "DELETE FROM ldb_attribute_values " "WHERE eid = '%lld' " "AND norm_attr_name = '%q' " @@ -1240,18 +1233,16 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) eid, attr, value.data); if (mod == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } } @@ -1259,121 +1250,106 @@ static int lsql_modify(struct ldb_module *module, struct ldb_request *req) } } - if (lsql_ac->callback) { - req->handle->status = lsql_ac->callback(module->ldb, lsql_ac->context, NULL); - } - -done: - req->handle->state = LDB_ASYNC_DONE; - return ret; + return LDB_SUCCESS; } /* delete a record */ -static int lsql_delete(struct ldb_module *module, struct ldb_request *req) +static int lsql_delete(struct lsql_context *ctx) { - struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_context *lsql_ac; + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; + struct lsqlite3_private *lsqlite3; + struct ldb_context *ldb; long long eid; char *errmsg; char *query; - int ret = LDB_SUCCESS; - + int ret; - lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); - req->handle->state = LDB_ASYNC_DONE; - req->handle->status = LDB_SUCCESS; + ldb = ldb_module_get_ctx(module); + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); - eid = lsqlite3_get_eid(module, req->op.del.dn); + eid = lsqlite3_get_eid(lsqlite3, req->op.del.dn); if (eid == -1) { - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - query = lsqlite3_tprintf(lsql_ac, + query = lsqlite3_tprintf(ctx, /* Delete entry */ "DELETE FROM ldb_entry WHERE eid = %lld; " /* Delete attributes */ "DELETE FROM ldb_attribute_values WHERE eid = %lld; ", eid, eid); if (query == NULL) { - ret = LDB_ERR_OTHER; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - req->handle->status = LDB_ERR_OPERATIONS_ERROR; - goto done; + return LDB_ERR_OPERATIONS_ERROR; } - if (lsql_ac->callback) { - ret = lsql_ac->callback(module->ldb, lsql_ac->context, NULL); - } - -done: - req->handle->state = LDB_ASYNC_DONE; - return ret; + return LDB_SUCCESS; } /* rename a record */ -static int lsql_rename(struct ldb_module *module, struct ldb_request *req) +static int lsql_rename(struct lsql_context *ctx) { - struct lsqlite3_private *lsqlite3 = talloc_get_type(module->private_data, struct lsqlite3_private); - struct lsql_context *lsql_ac; + struct ldb_module *module = ctx->module; + struct ldb_request *req = ctx->req; + struct lsqlite3_private *lsqlite3; + struct ldb_context *ldb; char *new_dn, *new_cdn, *old_cdn; char *errmsg; char *query; - int ret = LDB_SUCCESS; + int ret; - lsql_ac = talloc_get_type(req->handle->private_data, struct lsql_context); - req->handle->state = LDB_ASYNC_DONE; - req->handle->status = LDB_SUCCESS; + ldb = ldb_module_get_ctx(module); + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); /* create linearized and normalized dns */ - old_cdn = ldb_dn_alloc_casefold(lsql_ac, req->op.rename.olddn); - new_cdn = ldb_dn_alloc_casefold(lsql_ac, req->op.rename.newdn); - new_dn = ldb_dn_alloc_linearized(lsql_ac, req->op.rename.newdn); + old_cdn = ldb_dn_alloc_casefold(ctx, req->op.rename.olddn); + new_cdn = ldb_dn_alloc_casefold(ctx, req->op.rename.newdn); + new_dn = ldb_dn_alloc_linearized(ctx, req->op.rename.newdn); if (old_cdn == NULL || new_cdn == NULL || new_dn == NULL) { - goto done; + return LDB_ERR_OPERATIONS_ERROR; } /* build the SQL query */ - query = lsqlite3_tprintf(lsql_ac, + query = lsqlite3_tprintf(ctx, "UPDATE ldb_entry SET dn = '%q', norm_dn = '%q' " "WHERE norm_dn = '%q';", new_dn, new_cdn, old_cdn); if (query == NULL) { - goto done; + return LDB_ERR_OPERATIONS_ERROR; } /* execute */ ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { - ldb_set_errstring(module->ldb, errmsg); + ldb_set_errstring(ldb, errmsg); free(errmsg); } - ret = LDB_ERR_OPERATIONS_ERROR; - goto done; - } - - if (lsql_ac->callback) { - ret = lsql_ac->callback(module->ldb, lsql_ac->context, NULL); + return LDB_ERR_OPERATIONS_ERROR; } -done: - req->handle->state = LDB_ASYNC_DONE; - return ret; + return LDB_SUCCESS; } static int lsql_start_trans(struct ldb_module * module) { int ret; char *errmsg; - struct lsqlite3_private * lsqlite3 = module->private_data; + struct lsqlite3_private *lsqlite3; + + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); if (lsqlite3->trans_count == 0) { ret = sqlite3_exec(lsqlite3->sqlite, "BEGIN IMMEDIATE;", NULL, NULL, &errmsg); @@ -1395,7 +1371,10 @@ static int lsql_end_trans(struct ldb_module *module) { int ret; char *errmsg; - struct lsqlite3_private *lsqlite3 = module->private_data; + struct lsqlite3_private *lsqlite3; + + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); if (lsqlite3->trans_count > 0) { lsqlite3->trans_count--; @@ -1417,7 +1396,10 @@ static int lsql_end_trans(struct ldb_module *module) static int lsql_del_trans(struct ldb_module *module) { - struct lsqlite3_private *lsqlite3 = module->private_data; + struct lsqlite3_private *lsqlite3; + + lsqlite3 = talloc_get_type(ldb_module_get_private(module), + struct lsqlite3_private); if (lsqlite3->trans_count > 0) { lsqlite3->trans_count--; @@ -1431,69 +1413,132 @@ static int lsql_del_trans(struct ldb_module *module) } static int destructor(struct lsqlite3_private *lsqlite3) -{ +{ if (lsqlite3->sqlite) { sqlite3_close(lsqlite3->sqlite); } return 0; } -static int lsql_request(struct ldb_module *module, struct ldb_request *req) +static void lsql_request_done(struct lsql_context *ctx, int error) { - return LDB_ERR_OPERATIONS_ERROR; + struct ldb_context *ldb; + struct ldb_request *req; + struct ldb_reply *ares; + + ldb = ldb_module_get_ctx(ctx->module); + req = ctx->req; + + /* if we already returned an error just return */ + if (ldb_request_get_status(req) != LDB_SUCCESS) { + return; + } + + ares = talloc_zero(req, struct ldb_reply); + if (!ares) { + ldb_oom(ldb); + req->callback(req, NULL); + return; + } + ares->type = LDB_REPLY_DONE; + ares->error = error; + + req->callback(req, ares); +} + +static void lsql_timeout(struct tevent_context *ev, + struct tevent_timer *te, + struct timeval t, + void *private_data) +{ + struct lsql_context *ctx; + ctx = talloc_get_type(private_data, struct lsql_context); + + lsql_request_done(ctx, LDB_ERR_TIME_LIMIT_EXCEEDED); } -static int lsql_run_request(struct ldb_module *module, struct ldb_request *req) +static void lsql_callback(struct tevent_context *ev, + struct tevent_timer *te, + struct timeval t, + void *private_data) { - switch (req->operation) { + struct lsql_context *ctx; + int ret; + + ctx = talloc_get_type(private_data, struct lsql_context); + + switch (ctx->req->operation) { case LDB_SEARCH: - return lsql_search(module, req); + ret = lsql_search(ctx); break; case LDB_ADD: - return lsql_add(module, req); + ret = lsql_add(ctx); break; case LDB_MODIFY: - return lsql_modify(module, req); + ret = lsql_modify(ctx); break; case LDB_DELETE: - return lsql_delete(module, req); + ret = lsql_delete(ctx); break; case LDB_RENAME: - return lsql_rename(module, req); + ret = lsql_rename(ctx); break; /* TODO: - case LDB_SEQUENCE_NUMBER: - return lsql_sequence_number(module, req); + case LDB_EXTENDED: + ret = lsql_extended(ctx); break; */ default: - return lsql_request(module, req); - break; + /* no other op supported */ + ret = LDB_ERR_UNWILLING_TO_PERFORM; } - return LDB_ERR_OPERATIONS_ERROR; + if (!ctx->callback_failed) { + /* Once we are done, we do not need timeout events */ + talloc_free(ctx->timeout_event); + lsql_request_done(ctx, ret); + } } static int lsql_handle_request(struct ldb_module *module, struct ldb_request *req) { + struct ldb_context *ldb; + struct tevent_context *ev; struct lsql_context *ac; + struct tevent_timer *te; + struct timeval tv; if (check_critical_controls(req->controls)) { return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION; } + if (req->starttime == 0 || req->timeout == 0) { + ldb_set_errstring(ldb, "Invalid timeout settings"); + return LDB_ERR_TIME_LIMIT_EXCEEDED; + } + + ldb = ldb_module_get_ctx(module); + ev = ldb_get_event_context(ldb); + ac = talloc_zero(req, struct lsql_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, "Out of Memory"); + ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } ac->module = module; ac->req = req; - req->handle = ldb_handle_new(req, lsql_run_request, ac); - if (req->handle == NULL) { - talloc_free(ac); + tv.tv_sec = 0; + tv.tv_usec = 0; + te = tevent_add_timer(ev, ac, tv, lsql_callback, ac); + if (NULL == te) { + return LDB_ERR_OPERATIONS_ERROR; + } + + tv.tv_sec = req->starttime + req->timeout; + ac->timeout_event = tevent_add_timer(ev, ac, tv, lsql_timeout, ac); + if (NULL == ac->timeout_event) { return LDB_ERR_OPERATIONS_ERROR; } @@ -1510,11 +1555,10 @@ static const struct ldb_module_ops lsqlite3_ops = { .modify = lsql_handle_request, .del = lsql_handle_request, .rename = lsql_handle_request, - .request = lsql_handle_request, + .extended = lsql_handle_request, .start_transaction = lsql_start_trans, .end_transaction = lsql_end_trans, .del_transaction = lsql_del_trans, - /* TODO: .sequence_number = lsql_handle_request */ }; /* @@ -1538,15 +1582,15 @@ static int initialize(struct lsqlite3_private *lsqlite3, } schema = lsqlite3_tprintf(local_ctx, - - + + "CREATE TABLE ldb_info AS " " SELECT 'LDB' AS database_type," " '1.0' AS version;" - + /* - * The entry table holds the information about an entry. - * This table is used to obtain the EID of the entry and to + * The entry table holds the information about an entry. + * This table is used to obtain the EID of the entry and to * support scope=one and scope=base. The parent and child * table is included in the entry table since all the other * attributes are dependent on EID. @@ -1557,7 +1601,7 @@ static int initialize(struct lsqlite3_private *lsqlite3, " dn TEXT UNIQUE NOT NULL," " norm_dn TEXT UNIQUE NOT NULL" ");" - + "CREATE TABLE ldb_object_classes" "(" @@ -1566,7 +1610,7 @@ static int initialize(struct lsqlite3_private *lsqlite3, " tree_key TEXT UNIQUE," " max_child_num INTEGER DEFAULT 0" ");" - + /* * We keep a full listing of attribute/value pairs here */ @@ -1578,23 +1622,23 @@ static int initialize(struct lsqlite3_private *lsqlite3, " attr_value TEXT," " norm_attr_value TEXT " ");" - - + + /* * Indexes */ "CREATE INDEX ldb_attribute_values_eid_idx " " ON ldb_attribute_values (eid);" - + "CREATE INDEX ldb_attribute_values_name_value_idx " " ON ldb_attribute_values (attr_name, norm_attr_value);" - - + + /* * Triggers */ - + "CREATE TRIGGER ldb_object_classes_insert_tr" " AFTER INSERT" " ON ldb_object_classes" @@ -1624,20 +1668,20 @@ static int initialize(struct lsqlite3_private *lsqlite3, " (class_name, tree_key) " " VALUES " " ('TOP', '0001');"); - + /* Skip protocol indicator of url */ if (strncmp(url, "sqlite3://", 10) != 0) { return SQLITE_MISUSE; } - + /* Update pointer to just after the protocol indicator */ url += 10; - + /* Try to open the (possibly empty/non-existent) database */ if ((ret = sqlite3_open(url, &lsqlite3->sqlite)) != SQLITE_OK) { return ret; } - + /* In case this is a new database, enable auto_vacuum */ ret = sqlite3_exec(lsqlite3->sqlite, "PRAGMA auto_vacuum = 1;", NULL, NULL, &errmsg); if (ret != SQLITE_OK) { @@ -1647,7 +1691,7 @@ static int initialize(struct lsqlite3_private *lsqlite3, } goto failed; } - + if (flags & LDB_FLG_NOSYNC) { /* DANGEROUS */ ret = sqlite3_exec(lsqlite3->sqlite, "PRAGMA synchronous = OFF;", NULL, NULL, &errmsg); @@ -1659,9 +1703,9 @@ static int initialize(struct lsqlite3_private *lsqlite3, goto failed; } } - + /* */ - + /* Establish a busy timeout of 30 seconds */ if ((ret = sqlite3_busy_timeout(lsqlite3->sqlite, 30000)) != SQLITE_OK) { @@ -1720,7 +1764,7 @@ static int initialize(struct lsqlite3_private *lsqlite3, goto failed; } rollback = 1; - + /* Determine if this is a new database. No tables means it is. */ if (query_int(lsqlite3, &queryInt, @@ -1729,7 +1773,7 @@ static int initialize(struct lsqlite3_private *lsqlite3, " WHERE type = 'table';") != 0) { goto failed; } - + if (queryInt == 0) { /* * Create the database schema @@ -1765,12 +1809,12 @@ static int initialize(struct lsqlite3_private *lsqlite3, " AND version = '1.0'" " );") != 0 || queryInt != 1) { - + /* It's not one that we created. See ya! */ goto failed; } } - + /* Commit the transaction */ ret = sqlite3_exec(lsqlite3->sqlite, "COMMIT;", NULL, NULL, &errmsg); if (ret != SQLITE_OK) { @@ -1780,11 +1824,11 @@ static int initialize(struct lsqlite3_private *lsqlite3, } goto failed; } - + return SQLITE_OK; failed: - if (rollback) lsqlite3_safe_rollback(lsqlite3->sqlite); + if (rollback) lsqlite3_safe_rollback(lsqlite3->sqlite); sqlite3_close(lsqlite3->sqlite); return -1; } @@ -1793,43 +1837,35 @@ failed: * connect to the database */ static int lsqlite3_connect(struct ldb_context *ldb, - const char *url, - unsigned int flags, + const char *url, + unsigned int flags, const char *options[], - struct ldb_module **module) + struct ldb_module **_module) { - int i; - int ret; - struct lsqlite3_private * lsqlite3 = NULL; - - lsqlite3 = talloc(ldb, struct lsqlite3_private); + struct ldb_module *module; + struct lsqlite3_private *lsqlite3; + int i, ret; + + module = ldb_module_new(ldb, ldb, "ldb_sqlite3 backend", &lsqlite3_ops); + if (!module) return -1; + + lsqlite3 = talloc(module, struct lsqlite3_private); if (!lsqlite3) { goto failed; } - + lsqlite3->sqlite = NULL; lsqlite3->options = NULL; lsqlite3->trans_count = 0; - + ret = initialize(lsqlite3, ldb, url, flags); if (ret != SQLITE_OK) { goto failed; } - - talloc_set_destructor(lsqlite3, destructor); - + talloc_set_destructor(lsqlite3, destructor); - *module = talloc(ldb, struct ldb_module); - if (!module) { - ldb_oom(ldb); - goto failed; - } - talloc_set_name_const(*module, "ldb_sqlite3 backend"); - (*module)->ldb = ldb; - (*module)->prev = (*module)->next = NULL; - (*module)->private_data = lsqlite3; - (*module)->ops = &lsqlite3_ops; + ldb_module_set_private(module, lsqlite3); if (options) { /* @@ -1837,14 +1873,14 @@ static int lsqlite3_connect(struct ldb_context *ldb, * on the caller keeping it around (it might be dynamic) */ for (i=0;options[i];i++) ; - + lsqlite3->options = talloc_array(lsqlite3, char *, i+1); if (!lsqlite3->options) { goto failed; } - + for (i=0;options[i];i++) { - + lsqlite3->options[i+1] = NULL; lsqlite3->options[i] = talloc_strdup(lsqlite3->options, options[i]); @@ -1853,11 +1889,12 @@ static int lsqlite3_connect(struct ldb_context *ldb, } } } - + + *_module = module; return 0; - + failed: - if (lsqlite3->sqlite != NULL) { + if (lsqlite3 && lsqlite3->sqlite != NULL) { (void) sqlite3_close(lsqlite3->sqlite); } talloc_free(lsqlite3); -- cgit From 16f072809cf0e8542b776988d3fe1a0db055a74b Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Sun, 1 Feb 2009 03:22:41 +0100 Subject: fix build with external dns_sd libraries --- source3/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/Makefile.in b/source3/Makefile.in index 9bc6329f82..babdd51248 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1533,7 +1533,7 @@ bin/pdbtest@EXEEXT@: $(BINARY_PREREQS) $(PDBTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SH bin/vfstest@EXEEXT@: $(BINARY_PREREQS) $(VFSTEST_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@ @echo Linking $@ @$(CC) -o $@ $(VFSTEST_OBJ) $(LDFLAGS) $(TERMLDFLAGS) \ - $(TERMLIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) \ + $(TERMLIBS) $(DYNEXP) $(PRINT_LIBS) $(AUTH_LIBS) $(DNSSD_LIBS) \ $(ACL_LIBS) $(LIBS) $(POPT_LIBS) $(KRB5LIBS) $(LDAP_LIBS) \ @SMBD_LIBS@ $(NSCD_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) \ $(WINBIND_LIBS) $(ZLIB_LIBS) -- cgit From 19ce90b90e0024aa1d2453fcdc52828f6bee2f33 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 31 Jan 2009 16:47:15 +0100 Subject: Just for fun: Move some bytes from bss to text --- source3/smbd/mangle_hash.c | 2 +- source3/smbd/mangle_hash2.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/smbd/mangle_hash.c b/source3/smbd/mangle_hash.c index ebd93ff5d0..96fe4d2cab 100644 --- a/source3/smbd/mangle_hash.c +++ b/source3/smbd/mangle_hash.c @@ -53,7 +53,7 @@ * */ -static const char basechars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%"; +static const char basechars[43]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%"; #define MANGLE_BASE (sizeof(basechars)/sizeof(char)-1) #define mangle(V) ((char)(basechars[(V) % MANGLE_BASE])) diff --git a/source3/smbd/mangle_hash2.c b/source3/smbd/mangle_hash2.c index 859e5e7227..3a3939c511 100644 --- a/source3/smbd/mangle_hash2.c +++ b/source3/smbd/mangle_hash2.c @@ -85,7 +85,7 @@ #define FLAG_CHECK(c, flag) (char_flags[(unsigned char)(c)] & (flag)) /* these are the characters we use in the 8.3 hash. Must be 36 chars long */ -static const char * const basechars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +static const char basechars[36] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; #define base_forward(v) basechars[v] /* the list of reserved dos names - all of these are illegal */ -- cgit From dba6624dca024d144b0adb1016d17d176d38b735 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 31 Jan 2009 16:57:46 +0100 Subject: Fix nonempty blank lines --- source3/passdb/passdb.c | 121 ++++++++++++++++++++++++------------------------ source3/smbd/lanman.c | 115 +++++++++++++++++++++++---------------------- 2 files changed, 117 insertions(+), 119 deletions(-) diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index e677d429af..d26a667f44 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -7,17 +7,17 @@ Copyright (C) Andrew Bartlett 2001-2002 Copyright (C) Simo Sorce 2003 Copyright (C) Volker Lendecke 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 . */ @@ -67,16 +67,16 @@ static int samu_destroy(struct samu *user) struct samu *samu_new( TALLOC_CTX *ctx ) { struct samu *user; - + if ( !(user = TALLOC_ZERO_P( ctx, struct samu )) ) { DEBUG(0,("samuser_new: Talloc failed!\n")); return NULL; } - + talloc_set_destructor( user, samu_destroy ); - + /* no initial methods */ - + user->methods = NULL; /* Don't change these timestamp settings without a good reason. @@ -98,7 +98,7 @@ struct samu *samu_new( TALLOC_CTX *ctx ) /* Some parts of samba strlen their pdb_get...() returns, so this keeps the interface unchanged for now. */ - + user->username = ""; user->domain = ""; user->nt_username = ""; @@ -118,8 +118,7 @@ struct samu *samu_new( TALLOC_CTX *ctx ) asks for a filtered list of users. */ user->acct_ctrl = ACB_NORMAL; - - + return user; } @@ -140,7 +139,7 @@ static NTSTATUS samu_set_unix_internal(struct samu *user, const struct passwd *p } /* Basic properties based upon the Unix account information */ - + pdb_set_username(user, pwd->pw_name, PDB_SET); pdb_set_fullname(user, pwd->pw_gecos, PDB_SET); pdb_set_domain (user, get_global_sam_name(), PDB_DEFAULT); @@ -149,29 +148,29 @@ static NTSTATUS samu_set_unix_internal(struct samu *user, const struct passwd *p will be rejected by other parts of the Samba code. Rely on pdb_get_group_sid() to "Do The Right Thing" (TM) --jerry */ - + gid_to_sid(&group_sid, pwd->pw_gid); pdb_set_group_sid(user, &group_sid, PDB_SET); #endif - + /* save the password structure for later use */ - + user->unix_pw = tcopy_passwd( user, pwd ); /* Special case for the guest account which must have a RID of 501 */ - + if ( strequal( pwd->pw_name, guest_account ) ) { if ( !pdb_set_user_sid_from_rid(user, DOMAIN_USER_RID_GUEST, PDB_DEFAULT)) { return NT_STATUS_NO_SUCH_USER; } return NT_STATUS_OK; } - + /* Non-guest accounts...Check for a workstation or user account */ if (pwd->pw_name[strlen(pwd->pw_name)-1] == '$') { /* workstation */ - + if (!pdb_set_acct_ctrl(user, ACB_WSTRUST, PDB_DEFAULT)) { DEBUG(1, ("Failed to set 'workstation account' flags for user %s.\n", pwd->pw_name)); @@ -180,15 +179,15 @@ static NTSTATUS samu_set_unix_internal(struct samu *user, const struct passwd *p } else { /* user */ - + if (!pdb_set_acct_ctrl(user, ACB_NORMAL, PDB_DEFAULT)) { DEBUG(1, ("Failed to set 'normal account' flags for user %s.\n", pwd->pw_name)); return NT_STATUS_INVALID_ACCOUNT_NAME; } - + /* set some basic attributes */ - + pdb_set_profile_path(user, talloc_sub_specified(user, lp_logon_path(), pwd->pw_name, domain, pwd->pw_uid, pwd->pw_gid), PDB_DEFAULT); @@ -202,7 +201,7 @@ static NTSTATUS samu_set_unix_internal(struct samu *user, const struct passwd *p lp_logon_script(), pwd->pw_name, domain, pwd->pw_uid, pwd->pw_gid), PDB_DEFAULT); } - + /* Now deal with the user SID. If we have a backend that can generate RIDs, then do so. But sometimes the caller just wanted a structure initialized and will fill in these fields later (such as from a @@ -211,7 +210,7 @@ static NTSTATUS samu_set_unix_internal(struct samu *user, const struct passwd *p if ( create && !pdb_rid_algorithm() ) { uint32 user_rid; DOM_SID user_sid; - + if ( !pdb_new_rid( &user_rid ) ) { DEBUG(3, ("Could not allocate a new RID\n")); return NT_STATUS_ACCESS_DENIED; @@ -224,18 +223,18 @@ static NTSTATUS samu_set_unix_internal(struct samu *user, const struct passwd *p DEBUG(3, ("pdb_set_user_sid failed\n")); return NT_STATUS_INTERNAL_ERROR; } - + return NT_STATUS_OK; } /* generate a SID for the user with the RID algorithm */ - + urid = algorithmic_pdb_uid_to_user_rid( user->unix_pw->pw_uid ); - + if ( !pdb_set_user_sid_from_rid( user, urid, PDB_SET) ) { return NT_STATUS_INTERNAL_ERROR; } - + return NT_STATUS_OK; } @@ -365,10 +364,10 @@ bool pdb_gethexpwd(const char *p, unsigned char *pwd) unsigned char lonybble, hinybble; const char *hexchars = "0123456789ABCDEF"; char *p1, *p2; - + if (!p) return false; - + for (i = 0; i < 32; i += 2) { hinybble = toupper_ascii(p[i]); lonybble = toupper_ascii(p[i + 1]); @@ -554,16 +553,16 @@ bool lookup_global_sam_name(const char *name, int flags, uint32_t *rid, { GROUP_MAP map; bool ret; - + /* Windows treats "MACHINE\None" as a special name for rid 513 on non-DCs. You cannot create a user or group name "None" on Windows. You will get an error that the group already exists. */ - + if ( strequal( name, "None" ) ) { *rid = DOMAIN_GROUP_RID_USERS; *type = SID_NAME_DOM_GRP; - + return True; } @@ -578,7 +577,7 @@ bool lookup_global_sam_name(const char *name, int flags, uint32_t *rid, if ( !(sam_account = samu_new( NULL )) ) { return False; } - + become_root(); ret = pdb_getsampwnam(sam_account, name); unbecome_root(); @@ -586,7 +585,7 @@ bool lookup_global_sam_name(const char *name, int flags, uint32_t *rid, if (ret) { sid_copy(&user_sid, pdb_get_user_sid(sam_account)); } - + TALLOC_FREE(sam_account); if (ret) { @@ -654,7 +653,7 @@ NTSTATUS local_password_change(const char *user_name, if(!pdb_getsampwnam(sam_pass, user_name)) { unbecome_root(); TALLOC_FREE(sam_pass); - + if ((local_flags & LOCAL_ADD_USER) || (local_flags & LOCAL_DELETE_USER)) { int tmp_debug = DEBUGLEVEL; struct passwd *pwd; @@ -754,7 +753,7 @@ NTSTATUS local_password_change(const char *user_name, return NT_STATUS_UNSUCCESSFUL; } } - + if (local_flags & LOCAL_SET_NO_PASSWORD) { if (!pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)|ACB_PWNOTREQ, PDB_CHANGED)) { if (asprintf(pp_err_str, "Failed to set 'no password required' flag for user %s.\n", user_name) < 0) { @@ -789,7 +788,7 @@ NTSTATUS local_password_change(const char *user_name, TALLOC_FREE(sam_pass); return NT_STATUS_UNSUCCESSFUL; } - + if (!pdb_set_plaintext_passwd (sam_pass, new_passwd)) { if (asprintf(pp_err_str, "Failed to set password for user %s.\n", user_name) < 0) { *pp_err_str = NULL; @@ -893,7 +892,7 @@ static bool init_samu_from_buffer_v0(struct samu *sampass, uint8 *buf, uint32 bu dir_drive_len, unknown_str_len, munged_dial_len, fullname_len, homedir_len, logon_script_len, profile_path_len, acct_desc_len, workstations_len; - + uint32 user_rid, group_rid, remove_me, hours_len, unknown_6; uint16 acct_ctrl, logon_divs; uint16 bad_password_count, logon_count; @@ -902,7 +901,7 @@ static bool init_samu_from_buffer_v0(struct samu *sampass, uint8 *buf, uint32 bu uint32 len = 0; uint32 lm_pw_len, nt_pw_len, hourslen; bool ret = True; - + if(sampass == NULL || buf == NULL) { DEBUG(0, ("init_samu_from_buffer_v0: NULL parameters found!\n")); return False; @@ -942,7 +941,7 @@ static bool init_samu_from_buffer_v0(struct samu *sampass, uint8 *buf, uint32 bu &bad_password_count, /* w */ &logon_count, /* w */ &unknown_6); /* d */ - + if (len == (uint32) -1) { ret = False; goto done; @@ -987,7 +986,7 @@ static bool init_samu_from_buffer_v0(struct samu *sampass, uint8 *buf, uint32 bu lp_logon_script()), PDB_DEFAULT); } - + if (profile_path) { pdb_set_profile_path(sampass, profile_path, PDB_SET); } else { @@ -1079,7 +1078,7 @@ static bool init_samu_from_buffer_v1(struct samu *sampass, uint8 *buf, uint32 bu dir_drive_len, unknown_str_len, munged_dial_len, fullname_len, homedir_len, logon_script_len, profile_path_len, acct_desc_len, workstations_len; - + uint32 user_rid, group_rid, remove_me, hours_len, unknown_6; uint16 acct_ctrl, logon_divs; uint16 bad_password_count, logon_count; @@ -1088,7 +1087,7 @@ static bool init_samu_from_buffer_v1(struct samu *sampass, uint8 *buf, uint32 bu uint32 len = 0; uint32 lm_pw_len, nt_pw_len, hourslen; bool ret = True; - + if(sampass == NULL || buf == NULL) { DEBUG(0, ("init_samu_from_buffer_v1: NULL parameters found!\n")); return False; @@ -1130,7 +1129,7 @@ static bool init_samu_from_buffer_v1(struct samu *sampass, uint8 *buf, uint32 bu &bad_password_count, /* w */ &logon_count, /* w */ &unknown_6); /* d */ - + if (len == (uint32) -1) { ret = False; goto done; @@ -1178,7 +1177,7 @@ static bool init_samu_from_buffer_v1(struct samu *sampass, uint8 *buf, uint32 bu lp_logon_script()), PDB_DEFAULT); } - + if (profile_path) { pdb_set_profile_path(sampass, profile_path, PDB_SET); } else { @@ -1268,7 +1267,7 @@ static bool init_samu_from_buffer_v2(struct samu *sampass, uint8 *buf, uint32 bu dir_drive_len, unknown_str_len, munged_dial_len, fullname_len, homedir_len, logon_script_len, profile_path_len, acct_desc_len, workstations_len; - + uint32 user_rid, group_rid, hours_len, unknown_6; uint16 acct_ctrl, logon_divs; uint16 bad_password_count, logon_count; @@ -1280,12 +1279,12 @@ static bool init_samu_from_buffer_v2(struct samu *sampass, uint8 *buf, uint32 bu bool ret = True; fstring tmp_string; bool expand_explicit = lp_passdb_expand_explicit(); - + if(sampass == NULL || buf == NULL) { DEBUG(0, ("init_samu_from_buffer_v2: NULL parameters found!\n")); return False; } - + /* SAMU_BUFFER_FORMAT_V2 "dddddddBBBBBBBBBBBBddBBBwwdBwwd" */ /* unpack the buffer into variables */ @@ -1323,7 +1322,7 @@ static bool init_samu_from_buffer_v2(struct samu *sampass, uint8 *buf, uint32 bu &bad_password_count, /* w */ &logon_count, /* w */ &unknown_6); /* d */ - + if (len == (uint32) -1) { ret = False; goto done; @@ -1376,7 +1375,7 @@ static bool init_samu_from_buffer_v2(struct samu *sampass, uint8 *buf, uint32 bu lp_logon_script()), PDB_DEFAULT); } - + if (profile_path) { fstrcpy( tmp_string, profile_path ); if (expand_explicit) { @@ -1503,7 +1502,7 @@ static bool init_samu_from_buffer_v3(struct samu *sampass, uint8 *buf, uint32 bu dir_drive_len, unknown_str_len, munged_dial_len, fullname_len, homedir_len, logon_script_len, profile_path_len, acct_desc_len, workstations_len; - + uint32 user_rid, group_rid, hours_len, unknown_6, acct_ctrl; uint16 logon_divs; uint16 bad_password_count, logon_count; @@ -1515,12 +1514,12 @@ static bool init_samu_from_buffer_v3(struct samu *sampass, uint8 *buf, uint32 bu bool ret = True; fstring tmp_string; bool expand_explicit = lp_passdb_expand_explicit(); - + if(sampass == NULL || buf == NULL) { DEBUG(0, ("init_samu_from_buffer_v3: NULL parameters found!\n")); return False; } - + /* SAMU_BUFFER_FORMAT_V3 "dddddddBBBBBBBBBBBBddBBBdwdBwwd" */ /* unpack the buffer into variables */ @@ -1559,7 +1558,7 @@ static bool init_samu_from_buffer_v3(struct samu *sampass, uint8 *buf, uint32 bu &bad_password_count, /* w */ &logon_count, /* w */ &unknown_6); /* d */ - + if (len == (uint32) -1) { ret = False; goto done; @@ -1612,7 +1611,7 @@ static bool init_samu_from_buffer_v3(struct samu *sampass, uint8 *buf, uint32 bu lp_logon_script()), PDB_DEFAULT); } - + if (profile_path) { fstrcpy( tmp_string, profile_path ); if (expand_explicit) { @@ -1839,12 +1838,12 @@ static uint32 init_buffer_from_samu_v3 (uint8 **buf, struct samu *sampass, bool } else { profile_path_len = 0; } - + lm_pw = pdb_get_lanman_passwd(sampass); if (!lm_pw) { lm_pw_len = 0; } - + nt_pw = pdb_get_nt_passwd(sampass); if (!nt_pw) { nt_pw_len = 0; @@ -1927,7 +1926,7 @@ static uint32 init_buffer_from_samu_v3 (uint8 **buf, struct samu *sampass, bool DEBUG(0,("init_buffer_from_samu_v3: Unable to malloc() memory for buffer!\n")); return (-1); } - + /* now for the real call to tdb_pack() */ buflen = tdb_pack(*buf, len, SAMU_BUFFER_FORMAT_V3, logon_time, /* d */ @@ -1961,7 +1960,7 @@ static uint32 init_buffer_from_samu_v3 (uint8 **buf, struct samu *sampass, bool pdb_get_bad_password_count(sampass), /* w */ pdb_get_logon_count(sampass), /* w */ pdb_get_unknown_6(sampass)); /* d */ - + /* check to make sure we got it correct */ if (buflen != len) { DEBUG(0, ("init_buffer_from_samu_v3: somthing odd is going on here: bufflen (%lu) != len (%lu) in tdb_pack operations!\n", @@ -2038,7 +2037,7 @@ bool pdb_copy_sam_account(struct samu *dst, struct samu *src ) } dst->methods = src->methods; - + if ( src->unix_pw ) { dst->unix_pw = tcopy_passwd( dst, src->unix_pw ); if (!dst->unix_pw) { @@ -2127,7 +2126,7 @@ bool pdb_update_autolock_flag(struct samu *sampass, bool *updated) DEBUG(9, ("pdb_update_autolock_flag: No reset duration, can't reset autolock\n")); return True; } - + LastBadPassword = pdb_get_bad_password_time(sampass); DEBUG(7, ("pdb_update_autolock_flag: Account %s, LastBadPassword=%d, duration=%d, current time =%d.\n", pdb_get_username(sampass), (uint32)LastBadPassword, duration*60, (uint32)time(NULL))); @@ -2150,7 +2149,7 @@ bool pdb_update_autolock_flag(struct samu *sampass, bool *updated) *updated = True; } } - + return True; } diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index c8e35783c0..3ae4b1d61a 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -6,17 +6,17 @@ SMB Version handling Copyright (C) John H Terpstra 1995-1998 - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -876,9 +876,9 @@ static bool api_DosPrintQGetInfo(connection_struct *conn, uint16 vuid, /* remove any trailing username */ if ((p = strchr_m(QueueName,'%'))) *p = 0; - + DEBUG(3,("api_DosPrintQGetInfo uLevel=%d name=%s\n",uLevel,QueueName)); - + /* check it's a supported varient */ if (!prefix_ok(str1,"zWrLh")) return False; @@ -899,11 +899,11 @@ static bool api_DosPrintQGetInfo(connection_struct *conn, uint16 vuid, SSVAL(*rparam,4,0); return(True); } - + snum = find_service(QueueName); if ( !(lp_snum_ok(snum) && lp_print_ok(snum)) ) return False; - + if (uLevel==52) { count = get_printerdrivernumber(snum); DEBUG(3,("api_DosPrintQGetInfo: Driver files count: %d\n",count)); @@ -934,7 +934,7 @@ static bool api_DosPrintQGetInfo(connection_struct *conn, uint16 vuid, } *rdata_len = desc.usedlen; - + /* * We must set the return code to ERRbuftoosmall * in order to support lanman style printing with Win NT/2k @@ -942,7 +942,7 @@ static bool api_DosPrintQGetInfo(connection_struct *conn, uint16 vuid, */ if (!mdrcnt && lp_disable_spoolss()) desc.errcode = ERRbuftoosmall; - + *rdata_len = desc.usedlen; *rparam_len = 6; *rparam = smb_realloc_limit(*rparam,*rparam_len); @@ -954,7 +954,7 @@ static bool api_DosPrintQGetInfo(connection_struct *conn, uint16 vuid, SSVALS(*rparam,0,desc.errcode); SSVAL(*rparam,2,0); SSVAL(*rparam,4,desc.neededlen); - + DEBUG(4,("printqgetinfo: errorcode %d\n",desc.errcode)); SAFE_FREE(queue); @@ -986,7 +986,7 @@ static bool api_DosPrintQEnum(connection_struct *conn, uint16 vuid, print_status_struct *status = NULL; int *subcntarr = NULL; int queuecnt = 0, subcnt = 0, succnt = 0; - + if (!param_format || !output_format1 || !p) { return False; } @@ -994,7 +994,7 @@ static bool api_DosPrintQEnum(connection_struct *conn, uint16 vuid, memset((char *)&desc,'\0',sizeof(desc)); DEBUG(3,("DosPrintQEnum uLevel=%d\n",uLevel)); - + if (!prefix_ok(param_format,"WrLeh")) { return False; } @@ -1071,7 +1071,7 @@ static bool api_DosPrintQEnum(connection_struct *conn, uint16 vuid, } SAFE_FREE(subcntarr); - + *rdata_len = desc.usedlen; *rparam_len = 8; *rparam = smb_realloc_limit(*rparam,*rparam_len); @@ -1082,7 +1082,7 @@ static bool api_DosPrintQEnum(connection_struct *conn, uint16 vuid, SSVAL(*rparam,2,0); SSVAL(*rparam,4,succnt); SSVAL(*rparam,6,queuecnt); - + for (i = 0; i < queuecnt; i++) { if (queue) { SAFE_FREE(queue[i]); @@ -1091,7 +1091,7 @@ static bool api_DosPrintQEnum(connection_struct *conn, uint16 vuid, SAFE_FREE(queue); SAFE_FREE(status); - + return True; err: @@ -1248,11 +1248,11 @@ static int get_server_info(uint32 servertype, DEBUG(4,("s: dom mismatch ")); ok = False; } - + if (!strequal(domain, s->domain) && !(servertype & SV_TYPE_DOMAIN_ENUM)) { ok = False; } - + /* We should never return a server type with a SV_TYPE_LOCAL_LIST_ONLY set. */ s->type &= ~SV_TYPE_LOCAL_LIST_ONLY; @@ -1266,7 +1266,7 @@ static int get_server_info(uint32 servertype, s->name, s->type, s->comment, s->domain)); } } - + TALLOC_FREE(lines); return count; } @@ -1284,7 +1284,7 @@ static int fill_srv_info(struct srv_info_struct *service, char* p2; int l2; int len; - + switch (uLevel) { case 0: struct_len = 16; @@ -1295,7 +1295,7 @@ static int fill_srv_info(struct srv_info_struct *service, default: return -1; } - + if (!buf) { len = 0; switch (uLevel) { @@ -1308,7 +1308,7 @@ static int fill_srv_info(struct srv_info_struct *service, *stringspace = len; return struct_len + len; } - + len = struct_len; p = *buf; if (*buflen < struct_len) { @@ -1324,7 +1324,7 @@ static int fill_srv_info(struct srv_info_struct *service, if (!baseaddr) { baseaddr = p; } - + switch (uLevel) { case 0: push_ascii(p,service->name, MAX_NETBIOSNAME_LEN, STR_TERMINATE); @@ -1416,7 +1416,7 @@ static bool api_RNetServerEnum(connection_struct *conn, uint16 vuid, if (!check_server_info(uLevel,str2)) { return False; } - + DEBUG(4, ("server request level: %s %8x ", str2, servertype)); DEBUG(4, ("domains_req:%s ", BOOLSTR(domain_request))); DEBUG(4, ("local_only:%s\n", BOOLSTR(local_request))); @@ -1454,7 +1454,7 @@ static bool api_RNetServerEnum(connection_struct *conn, uint16 vuid, data_len += fill_srv_info(s,uLevel,0,&f_len,0,&s_len,0); DEBUG(4,("fill_srv_info %20s %8x %25s %15s\n", s->name, s->type, s->comment, s->domain)); - + if (data_len <= buf_len) { counted++; fixed_len += f_len; @@ -1470,7 +1470,7 @@ static bool api_RNetServerEnum(connection_struct *conn, uint16 vuid, if (!*rdata) { return False; } - + p2 = (*rdata) + fixed_len; /* auxilliary data (strings) will go here */ p = *rdata; f_len = fixed_len; @@ -1493,7 +1493,7 @@ static bool api_RNetServerEnum(connection_struct *conn, uint16 vuid, count2--; } } - + *rparam_len = 8; *rparam = smb_realloc_limit(*rparam,*rparam_len); if (!*rparam) { @@ -1540,9 +1540,9 @@ static bool api_RNetGroupGetUsers(connection_struct *conn, uint16 vuid, if (!prefix_ok(str1,"zWrLeh")) { return False; } - + *rdata_len = 0; - + *rparam_len = 8; *rparam = smb_realloc_limit(*rparam,*rparam_len); if (!*rparam) { @@ -1599,7 +1599,7 @@ static int fill_share_info(connection_struct *conn, int snum, int uLevel, char* p2; int l2; int len; - + switch( uLevel ) { case 0: struct_len = 13; @@ -1616,8 +1616,7 @@ static int fill_share_info(connection_struct *conn, int snum, int uLevel, default: return -1; } - - + if (!buf) { len = 0; @@ -1635,7 +1634,7 @@ static int fill_share_info(connection_struct *conn, int snum, int uLevel, } return struct_len + len; } - + len = struct_len; p = *buf; if ((*buflen) < struct_len) { @@ -1653,9 +1652,9 @@ static int fill_share_info(connection_struct *conn, int snum, int uLevel, if (!baseaddr) { baseaddr = p; } - + push_ascii(p,lp_servicename(snum),13, STR_TERMINATE); - + if (uLevel > 0) { int type; @@ -1671,7 +1670,7 @@ static int fill_share_info(connection_struct *conn, int snum, int uLevel, SIVAL(p,16,PTR_DIFF(p2,baseaddr)); len += CopyExpanded(conn,snum,&p2,lp_comment(snum),&l2); } - + if (uLevel > 1) { SSVAL(p,20,ACCESS_READ|ACCESS_WRITE|ACCESS_CREATE); /* permissions */ SSVALS(p,22,-1); /* max uses */ @@ -1680,7 +1679,7 @@ static int fill_share_info(connection_struct *conn, int snum, int uLevel, len += CopyAndAdvance(&p2,lp_pathname(snum),&l2); memset(p+30,0,SHPWLEN+2); /* passwd (reserved), pad field */ } - + if (uLevel > 2) { memset(p+40,0,SHPWLEN+2); SSVAL(p,50,0); @@ -1691,7 +1690,7 @@ static int fill_share_info(connection_struct *conn, int snum, int uLevel, SSVAL(p,64,0); SSVAL(p,66,0); } - + if (stringbuf) { (*buf) = p + struct_len; (*buflen) -= struct_len; @@ -1718,7 +1717,7 @@ static bool api_RNetShareGetInfo(connection_struct *conn,uint16 vuid, char *p = skip_string(param,tpscnt,netname); int uLevel = get_safe_SVAL(param,tpscnt,p,0,-1); int snum; - + if (!str1 || !str2 || !netname || !p) { return False; } @@ -1727,7 +1726,7 @@ static bool api_RNetShareGetInfo(connection_struct *conn,uint16 vuid, if (snum < 0) { return False; } - + /* check it's a supported varient */ if (!prefix_ok(str1,"zWrLh")) { return False; @@ -1735,7 +1734,7 @@ static bool api_RNetShareGetInfo(connection_struct *conn,uint16 vuid, if (!check_share_info(uLevel,str2)) { return False; } - + *rdata = smb_realloc_limit(*rdata,mdrcnt); if (!*rdata) { return False; @@ -1745,7 +1744,7 @@ static bool api_RNetShareGetInfo(connection_struct *conn,uint16 vuid, if (*rdata_len < 0) { return False; } - + *rparam_len = 6; *rparam = smb_realloc_limit(*rparam,*rparam_len); if (!*rparam) { @@ -1754,7 +1753,7 @@ static bool api_RNetShareGetInfo(connection_struct *conn,uint16 vuid, SSVAL(*rparam,0,NERR_Success); SSVAL(*rparam,2,0); /* converter word */ SSVAL(*rparam,4,*rdata_len); - + return True; } @@ -1790,7 +1789,7 @@ static bool api_RNetShareEnum( connection_struct *conn, uint16 vuid, int i; int data_len, fixed_len, string_len; int f_len = 0, s_len = 0; - + if (!str1 || !str2 || !p) { return False; } @@ -1801,7 +1800,7 @@ static bool api_RNetShareEnum( connection_struct *conn, uint16 vuid, if (!check_share_info(uLevel,str2)) { return False; } - + /* Ensure all the usershares are loaded. */ become_root(); load_registry_shares(); @@ -1834,7 +1833,7 @@ static bool api_RNetShareEnum( connection_struct *conn, uint16 vuid, if (!*rdata) { return False; } - + p2 = (*rdata) + fixed_len; /* auxiliary data (strings) will go here */ p = *rdata; f_len = fixed_len; @@ -1853,7 +1852,7 @@ static bool api_RNetShareEnum( connection_struct *conn, uint16 vuid, } } } - + *rparam_len = 8; *rparam = smb_realloc_limit(*rparam,*rparam_len); if (!*rparam) { @@ -1863,7 +1862,7 @@ static bool api_RNetShareEnum( connection_struct *conn, uint16 vuid, SSVAL(*rparam,2,0); SSVAL(*rparam,4,counted); SSVAL(*rparam,6,total); - + DEBUG(3,("RNetShareEnum gave %d entries of %d (%d %d %d %d)\n", counted,total,uLevel, buf_len,*rdata_len,mdrcnt)); @@ -2004,7 +2003,7 @@ static bool api_RNetShareAdd(connection_struct *conn,uint16 vuid, SSVAL(*rparam,2,0); /* converter word */ SSVAL(*rparam,4,*rdata_len); *rdata_len = 0; - + return True; error_exit: @@ -2042,7 +2041,7 @@ static bool api_RNetGroupEnum(connection_struct *conn,uint16 vuid, struct samr_displayentry *entries; int num_entries; - + if (!str1 || !str2 || !p) { return False; } @@ -2538,7 +2537,7 @@ static bool api_SetUserPassword(connection_struct *conn,uint16 vuid, memset((char *)pass1,'\0',sizeof(fstring)); memset((char *)pass2,'\0',sizeof(fstring)); - + return(True); } @@ -2677,7 +2676,7 @@ static bool api_RDosPrintJobDel(connection_struct *conn,uint16 vuid, } errcode = NERR_notsupported; - + switch (function) { case 81: /* delete */ if (print_job_delete(conn->server_info, snum, jobid, &werr)) @@ -2695,7 +2694,7 @@ static bool api_RDosPrintJobDel(connection_struct *conn,uint16 vuid, if (!W_ERROR_IS_OK(werr)) errcode = W_ERROR_V(werr); - + out: SSVAL(*rparam,0,errcode); SSVAL(*rparam,2,0); /* converter word */ @@ -2845,9 +2844,9 @@ static bool api_PrintJobInfo(connection_struct *conn, uint16 vuid, sharename)); return False; } - + *rdata_len = 0; - + /* check it's a supported varient */ if ((strcmp(str1,"WWsTP")) || (!check_printjob_info(&desc,uLevel,str2))) @@ -2884,7 +2883,7 @@ static bool api_PrintJobInfo(connection_struct *conn, uint16 vuid, out: SSVALS(*rparam,0,errcode); SSVAL(*rparam,2,0); /* converter word */ - + return(True); } @@ -3638,7 +3637,7 @@ static bool api_WWkstaUserLogon(connection_struct *conn,uint16 vuid, desc.buflen = mdrcnt; desc.subformat = NULL; desc.format = str2; - + if (init_package(&desc,1,0)) { PACKI(&desc,"W",0); /* code */ PACKS(&desc,"B21",name); /* eff. name */ @@ -3870,11 +3869,11 @@ static bool api_WPrintJobEnumerate(connection_struct *conn, uint16 vuid, if (strcmp(str1,"zWrLeh") != 0) { return False; } - + if (uLevel > 2) { return False; /* defined only for uLevel 0,1,2 */ } - + if (!check_printjob_info(&desc,uLevel,str2)) { return False; } -- cgit From 57de60a83f3f88566d356547eb20a6f0569f76ec Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 1 Feb 2009 00:30:04 +0100 Subject: cli_get_pipe_name_from_interface does not really need a talloc_ctx --- source3/include/proto.h | 3 +-- source3/lib/netapi/cm.c | 2 +- source3/rpc_client/cli_pipe.c | 30 ++++++++++++++++++++---------- source3/rpc_client/rpc_transport_np.c | 13 ++----------- source3/rpcclient/rpcclient.c | 9 +++------ source3/utils/net_rpc.c | 3 +-- 6 files changed, 28 insertions(+), 32 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index fd556690aa..6a97d81a61 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5852,8 +5852,7 @@ bool prs_data_blob(prs_struct *prs, DATA_BLOB *blob, TALLOC_CTX *mem_ctx); /* The following definitions come from rpc_parse/parse_rpc.c */ -const char *cli_get_pipe_name_from_iface(TALLOC_CTX *mem_ctx, - const struct ndr_syntax_id *interface); +const char *get_pipe_name_from_iface(const struct ndr_syntax_id *interface); void init_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 flags, uint32 call_id, int data_len, int auth_len); bool smb_io_rpc_hdr(const char *desc, RPC_HDR *rpc, prs_struct *ps, int depth); diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c index d5ef09d831..233255fed4 100644 --- a/source3/lib/netapi/cm.c +++ b/source3/lib/netapi/cm.c @@ -184,7 +184,7 @@ WERROR libnetapi_open_pipe(struct libnetapi_ctx *ctx, status = pipe_cm_open(ctx, cli, interface, &result); if (!NT_STATUS_IS_OK(status)) { libnetapi_set_error_string(ctx, "failed to open PIPE %s: %s", - cli_get_pipe_name_from_iface(debug_ctx(), interface), + get_pipe_name_from_iface(interface), get_friendly_nt_error_msg(status)); return WERR_DEST_NOT_FOUND; } diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index a741dec706..cee5d1cfc8 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -81,9 +81,10 @@ static const struct pipe_id_info { Return the pipe name from the interface. ****************************************************************************/ -const char *cli_get_pipe_name_from_iface(TALLOC_CTX *mem_ctx, - const struct ndr_syntax_id *interface) +const char *get_pipe_name_from_iface(const struct ndr_syntax_id *interface) { + char *guid_str; + const char *result; int i; for (i = 0; pipe_names[i].client_pipe; i++) { if (ndr_syntax_id_equal(pipe_names[i].abstr_syntax, @@ -97,7 +98,18 @@ const char *cli_get_pipe_name_from_iface(TALLOC_CTX *mem_ctx, * interested in the known pipes mentioned in pipe_names[] */ - return NULL; + guid_str = GUID_string(talloc_tos(), &interface->uuid); + if (guid_str == NULL) { + return NULL; + } + result = talloc_asprintf(talloc_tos(), "Interface %s.%d", guid_str, + (int)interface->if_version); + TALLOC_FREE(guid_str); + + if (result == NULL) { + return "PIPE"; + } + return result; } /******************************************************************** @@ -3649,8 +3661,7 @@ NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli, } DEBUG(lvl, ("cli_rpc_pipe_open_noauth: rpc_pipe_bind for pipe " "%s failed with error %s\n", - cli_get_pipe_name_from_iface(debug_ctx(), - interface), + get_pipe_name_from_iface(interface), nt_errstr(status) )); TALLOC_FREE(result); return status; @@ -3658,8 +3669,7 @@ NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli, DEBUG(10,("cli_rpc_pipe_open_noauth: opened pipe %s to machine " "%s and bound anonymously.\n", - cli_get_pipe_name_from_iface(debug_ctx(), interface), - cli->desthost )); + get_pipe_name_from_iface(interface), cli->desthost)); *presult = result; return NT_STATUS_OK; @@ -3705,8 +3715,8 @@ static NTSTATUS cli_rpc_pipe_open_ntlmssp_internal(struct cli_state *cli, DEBUG(10,("cli_rpc_pipe_open_ntlmssp_internal: opened pipe %s to " "machine %s and bound NTLMSSP as user %s\\%s.\n", - cli_get_pipe_name_from_iface(debug_ctx(), interface), - cli->desthost, domain, username )); + get_pipe_name_from_iface(interface), cli->desthost, domain, + username )); *presult = result; return NT_STATUS_OK; @@ -3897,7 +3907,7 @@ NTSTATUS cli_rpc_pipe_open_schannel_with_key(struct cli_state *cli, DEBUG(10,("cli_rpc_pipe_open_schannel_with_key: opened pipe %s to machine %s " "for domain %s and bound using schannel.\n", - cli_get_pipe_name_from_iface(debug_ctx(), interface), + get_pipe_name_from_iface(interface), cli->desthost, domain )); *presult = result; diff --git a/source3/rpc_client/rpc_transport_np.c b/source3/rpc_client/rpc_transport_np.c index 68aae6a0cc..a11e0e0f22 100644 --- a/source3/rpc_client/rpc_transport_np.c +++ b/source3/rpc_client/rpc_transport_np.c @@ -286,7 +286,6 @@ struct async_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx, { struct async_req *result, *subreq; struct rpc_transport_np_init_state *state; - NTSTATUS status; if (!async_req_setup(mem_ctx, &result, &state, struct rpc_transport_np_init_state)) { @@ -304,12 +303,8 @@ struct async_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx, } state->transport->priv = state->transport_np; - state->transport_np->pipe_name = cli_get_pipe_name_from_iface( - state, abstract_syntax); - if (state->transport_np->pipe_name == NULL) { - status = NT_STATUS_PIPE_NOT_AVAILABLE; - goto post_status; - } + state->transport_np->pipe_name = get_pipe_name_from_iface( + abstract_syntax); state->transport_np->cli = cli; subreq = cli_ntcreate_send( @@ -323,10 +318,6 @@ struct async_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx, subreq->async.priv = result; return result; - post_status: - if (async_post_status(result, ev, status)) { - return result; - } fail: TALLOC_FREE(result); return NULL; diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 050e78d274..9a02c129b5 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -619,16 +619,14 @@ static NTSTATUS do_cmd(struct cli_state *cli, default: DEBUG(0, ("Could not initialise %s. Invalid " "auth type %u\n", - cli_get_pipe_name_from_iface( - debug_ctx(), + get_pipe_name_from_iface( cmd_entry->interface), pipe_default_auth_type )); return NT_STATUS_UNSUCCESSFUL; } if (!NT_STATUS_IS_OK(ntresult)) { DEBUG(0, ("Could not initialise %s. Error was %s\n", - cli_get_pipe_name_from_iface( - debug_ctx(), + get_pipe_name_from_iface( cmd_entry->interface), nt_errstr(ntresult) )); return ntresult; @@ -657,8 +655,7 @@ static NTSTATUS do_cmd(struct cli_state *cli, if (!NT_STATUS_IS_OK(ntresult)) { DEBUG(0, ("Could not initialise credentials for %s.\n", - cli_get_pipe_name_from_iface( - debug_ctx(), + get_pipe_name_from_iface( cmd_entry->interface))); return ntresult; } diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index a37bbbd566..bdf92a4e4b 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -181,8 +181,7 @@ int run_rpc_command(struct net_context *c, } if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(0, ("Could not initialise pipe %s. Error was %s\n", - cli_get_pipe_name_from_iface( - debug_ctx(), interface), + get_pipe_name_from_iface(interface), nt_errstr(nt_status) )); cli_shutdown(cli); return -1; -- cgit From 3cd8c121dc27739a9a70bf47e32dcd19e35ddf14 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 1 Feb 2009 00:31:16 +0100 Subject: Fix some type-punned warnings --- source3/utils/net_rpc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index bdf92a4e4b..714d79402c 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -796,7 +796,7 @@ static int rpc_user_info(struct net_context *c, int argc, const char **argv) status = NetUserGetGroups(c->opt_host, argv[0], 0, - (uint8_t **)&u0, + (uint8_t **)(void *)&u0, (uint32_t)-1, &entries_read, &total_entries); @@ -2996,7 +2996,7 @@ static int rpc_share_list(struct net_context *c, int argc, const char **argv) status = NetShareEnum(c->opt_host, level, - (uint8_t **)&i1, + (uint8_t **)(void *)&i1, (uint32_t)-1, &entries_read, &total_entries, @@ -4775,7 +4775,7 @@ static int rpc_file_user(struct net_context *c, int argc, const char **argv) NULL, username, 3, - (uint8_t **)&i3, + (uint8_t **)(void *)&i3, preferred_len, &entries_read, &total_entries, -- cgit From 53394980ad7dc09af4412a6c4ee75241798b0e7c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 1 Feb 2009 12:03:31 +0100 Subject: Replace pipe names in pipes_struct by ndr_syntax_id This was mainly used for debugging output --- source3/include/ntdomain.h | 3 +- source3/include/proto.h | 5 ++- source3/rpc_server/srv_lsa_hnd.c | 22 ++++++----- source3/rpc_server/srv_pipe.c | 81 +++++++++++++++++++++++++-------------- source3/rpc_server/srv_pipe_hnd.c | 78 ++++++++++++++++++++++--------------- 5 files changed, 117 insertions(+), 72 deletions(-) diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h index 3f501550da..2d6a358391 100644 --- a/source3/include/ntdomain.h +++ b/source3/include/ntdomain.h @@ -214,8 +214,7 @@ typedef struct pipes_struct { struct auth_serversupplied_info *server_info; - fstring name; - fstring pipe_srv_name; + struct ndr_syntax_id syntax; /* linked list of rpc dispatch tables associated with the open rpc contexts */ diff --git a/source3/include/proto.h b/source3/include/proto.h index 6a97d81a61..c97adaa1c0 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6271,7 +6271,8 @@ NTSTATUS _eventlog_read_eventlog( pipes_struct * p, /* The following definitions come from rpc_server/srv_lsa_hnd.c */ -bool init_pipe_handle_list(pipes_struct *p, const char *pipe_name); +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); @@ -6294,7 +6295,7 @@ NTSTATUS rpc_srv_register(int version, const char *clnt, const char *srv, const struct ndr_interface_table *iface, const struct api_struct *cmds, int size); -bool is_known_pipename(const char *cli_filename); +bool is_known_pipename(const char *cli_filename, struct ndr_syntax_id *syntax); bool api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p); bool api_pipe_alter_context(pipes_struct *p, prs_struct *rpc_in_p); bool api_pipe_ntlmssp_auth_process(pipes_struct *p, prs_struct *rpc_in, diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 5f7c8d9f1a..2779b8aa18 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -34,9 +34,10 @@ pipe is open. JRA. ****************************************************************************/ -static bool is_samr_lsa_pipe(const char *pipe_name) +static bool is_samr_lsa_pipe(const struct ndr_syntax_id *syntax) { - return (strstr(pipe_name, "samr") || strstr(pipe_name, "lsa")); + return (ndr_syntax_id_equal(syntax, &ndr_table_samr.syntax_id) + || ndr_syntax_id_equal(syntax, &ndr_table_lsarpc.syntax_id)); } /**************************************************************************** @@ -44,7 +45,7 @@ static bool is_samr_lsa_pipe(const char *pipe_name) pipes of the same name. ****************************************************************************/ -bool init_pipe_handle_list(pipes_struct *p, const char *pipe_name) +bool init_pipe_handle_list(pipes_struct *p, const struct ndr_syntax_id *syntax) { pipes_struct *plist; struct handle_list *hl; @@ -52,11 +53,11 @@ bool init_pipe_handle_list(pipes_struct *p, const char *pipe_name) for (plist = get_first_internal_pipe(); plist; plist = get_next_internal_pipe(plist)) { - if (strequal(plist->name, pipe_name)) { + if (ndr_syntax_id_equal(syntax, &plist->syntax)) { break; } - if (is_samr_lsa_pipe(plist->name) - && is_samr_lsa_pipe(pipe_name)) { + if (is_samr_lsa_pipe(&plist->syntax) + && is_samr_lsa_pipe(syntax)) { /* * samr and lsa share a handle space (same process * under Windows?) @@ -80,7 +81,8 @@ bool init_pipe_handle_list(pipes_struct *p, const char *pipe_name) } ZERO_STRUCTP(hl); - DEBUG(10,("init_pipe_handles: created handle list for pipe %s\n", pipe_name )); + DEBUG(10,("init_pipe_handles: created handle list for " + "pipe %s\n", get_pipe_name_from_iface(syntax))); } /* @@ -96,7 +98,8 @@ bool init_pipe_handle_list(pipes_struct *p, const char *pipe_name) p->pipe_handles = hl; DEBUG(10,("init_pipe_handles: pipe_handles ref count = %lu for pipe %s\n", - (unsigned long)p->pipe_handles->pipe_ref_count, pipe_name )); + (unsigned long)p->pipe_handles->pipe_ref_count, + get_pipe_name_from_iface(syntax))); return True; } @@ -242,7 +245,8 @@ void close_policy_by_pipe(pipes_struct *p) p->pipe_handles->count = 0; SAFE_FREE(p->pipe_handles); - DEBUG(10,("close_policy_by_pipe: deleted handle list for pipe %s\n", p->name )); + DEBUG(10,("close_policy_by_pipe: deleted handle list for " + "pipe %s\n", get_pipe_name_from_iface(&p->syntax))); } } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 343342a06c..cbe697817a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -610,7 +610,8 @@ static bool pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) AUTH_NTLMSSP_STATE *a = p->auth.a_u.auth_ntlmssp_state; bool ret; - DEBUG(5,("pipe_ntlmssp_verify_final: pipe %s checking user details\n", p->name)); + DEBUG(5,("pipe_ntlmssp_verify_final: pipe %s checking user details\n", + get_pipe_name_from_iface(&p->syntax))); ZERO_STRUCT(reply); @@ -634,7 +635,7 @@ static bool pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) if (!(a->ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SIGN)) { DEBUG(0,("pipe_ntlmssp_verify_final: pipe %s : packet integrity requested " "but client declined signing.\n", - p->name )); + get_pipe_name_from_iface(&p->syntax))); return False; } } @@ -642,7 +643,7 @@ static bool pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) if (!(a->ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SEAL)) { DEBUG(0,("pipe_ntlmssp_verify_final: pipe %s : packet privacy requested " "but client declined sealing.\n", - p->name )); + get_pipe_name_from_iface(&p->syntax))); return False; } } @@ -962,14 +963,14 @@ bool check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, int i=0; struct pipe_rpc_fns *context_fns; - DEBUG(3,("check_bind_req for %s\n", p->name)); + DEBUG(3,("check_bind_req for %s\n", + get_pipe_name_from_iface(&p->syntax))); /* we have to check all now since win2k introduced a new UUID on the lsaprpc pipe */ for (i=0; iname) - && ndr_syntax_id_equal( + if (ndr_syntax_id_equal( abstract, &rpc_lookup[i].rpc_interface) && ndr_syntax_id_equal( transfer, &ndr_transfer_syntax)) { @@ -1056,7 +1057,7 @@ NTSTATUS rpc_srv_register(int version, const char *clnt, const char *srv, * @param[in] cli_filename The pipe name requested by the client * @result Do we want to serve this? */ -bool is_known_pipename(const char *cli_filename) +bool is_known_pipename(const char *cli_filename, struct ndr_syntax_id *syntax) { const char *pipename = cli_filename; int i; @@ -1076,6 +1077,7 @@ bool is_known_pipename(const char *cli_filename) for (i=0; ipipe_bound) { - DEBUG(2,("api_pipe_bind_req: rejecting bind request on bound pipe %s.\n", p->pipe_srv_name)); + DEBUG(2,("api_pipe_bind_req: rejecting bind request on bound " + "pipe %s.\n", get_pipe_name_from_iface(&p->syntax))); return setup_bind_nak(p); } @@ -1589,16 +1592,20 @@ bool api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) &hdr_rb.rpc_context[0].abstract)) { DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", rpc_lookup[i].pipe.clnt, rpc_lookup[i].pipe.srv)); - fstrcpy(p->name, rpc_lookup[i].pipe.clnt); - fstrcpy(p->pipe_srv_name, rpc_lookup[i].pipe.srv); break; } } if (i == rpc_lookup_size) { - if (NT_STATUS_IS_ERR(smb_probe_module("rpc", p->name))) { + NTSTATUS status; + + status = smb_probe_module( + "rpc", get_pipe_name_from_iface( + &hdr_rb.rpc_context[0].abstract)); + + if (NT_STATUS_IS_ERR(status)) { DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", - p->name )); + get_pipe_name_from_iface(&hdr_rb.rpc_context[0].abstract))); prs_mem_free(&outgoing_rpc); prs_mem_free(&out_hdr_ba); prs_mem_free(&out_auth); @@ -1607,23 +1614,26 @@ bool api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) } for (i = 0; i < rpc_lookup_size; i++) { - if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { + if (strequal(rpc_lookup[i].pipe.clnt, + get_pipe_name_from_iface(&p->syntax))) { DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", rpc_lookup[i].pipe.clnt, rpc_lookup[i].pipe.srv)); - fstrcpy(p->pipe_srv_name, rpc_lookup[i].pipe.srv); break; } } if (i == rpc_lookup_size) { - DEBUG(0, ("module %s doesn't provide functions for pipe %s!\n", p->name, p->name)); + DEBUG(0, ("module %s doesn't provide functions for " + "pipe %s!\n", + get_pipe_name_from_iface(&p->syntax), + get_pipe_name_from_iface(&p->syntax))); goto err_exit; } } /* name has to be \PIPE\xxxxx */ fstrcpy(ack_pipe_name, "\\PIPE\\"); - fstrcat(ack_pipe_name, p->pipe_srv_name); + fstrcat(ack_pipe_name, rpc_lookup[i].pipe.srv); DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); @@ -2233,7 +2243,7 @@ void free_pipe_rpc_context( PIPE_RPC_FNS *list ) return; } -static bool api_rpcTNP(pipes_struct *p, const char *rpc_name, +static bool api_rpcTNP(pipes_struct *p, const struct api_struct *api_rpc_cmds, int n_cmds); /**************************************************************************** @@ -2258,7 +2268,8 @@ bool api_pipe_request(pipes_struct *p) changed_user = True; } - DEBUG(5, ("Requested \\PIPE\\%s\n", p->name)); + DEBUG(5, ("Requested \\PIPE\\%s\n", + get_pipe_name_from_iface(&p->syntax))); /* get the set of RPC functions for this context */ @@ -2266,12 +2277,13 @@ bool api_pipe_request(pipes_struct *p) if ( pipe_fns ) { TALLOC_CTX *frame = talloc_stackframe(); - ret = api_rpcTNP(p, p->name, pipe_fns->cmds, pipe_fns->n_cmds); + ret = api_rpcTNP(p, pipe_fns->cmds, pipe_fns->n_cmds); TALLOC_FREE(frame); } else { DEBUG(0,("api_pipe_request: No rpc function table associated with context [%d] on pipe [%s]\n", - p->hdr_req.context_id, p->name)); + p->hdr_req.context_id, + get_pipe_name_from_iface(&p->syntax))); } if (changed_user) { @@ -2285,18 +2297,22 @@ bool api_pipe_request(pipes_struct *p) Calls the underlying RPC function for a named pipe. ********************************************************************/ -static bool api_rpcTNP(pipes_struct *p, const char *rpc_name, +static bool api_rpcTNP(pipes_struct *p, const struct api_struct *api_rpc_cmds, int n_cmds) { int fn_num; - fstring name; uint32 offset1, offset2; /* interpret the command */ - DEBUG(4,("api_rpcTNP: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); + DEBUG(4,("api_rpcTNP: %s op 0x%x - ", + get_pipe_name_from_iface(&p->syntax), p->hdr_req.opnum)); - slprintf(name, sizeof(name)-1, "in_%s", rpc_name); - prs_dump(name, p->hdr_req.opnum, &p->in_data.data); + if (DEBUGLEVEL >= 50) { + fstring name; + slprintf(name, sizeof(name)-1, "in_%s", + get_pipe_name_from_iface(&p->syntax)); + prs_dump(name, p->hdr_req.opnum, &p->in_data.data); + } for (fn_num = 0; fn_num < n_cmds; fn_num++) { if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) { @@ -2322,7 +2338,9 @@ static bool api_rpcTNP(pipes_struct *p, const char *rpc_name, fn_num, api_rpc_cmds[fn_num].fn)); /* do the actual command */ if(!api_rpc_cmds[fn_num].fn(p)) { - DEBUG(0,("api_rpcTNP: %s: %s failed.\n", rpc_name, api_rpc_cmds[fn_num].name)); + DEBUG(0,("api_rpcTNP: %s: %s failed.\n", + get_pipe_name_from_iface(&p->syntax), + api_rpc_cmds[fn_num].name)); prs_mem_free(&p->out_data.rdata); return False; } @@ -2341,13 +2359,18 @@ static bool api_rpcTNP(pipes_struct *p, const char *rpc_name, return True; } - slprintf(name, sizeof(name)-1, "out_%s", rpc_name); offset2 = prs_offset(&p->out_data.rdata); prs_set_offset(&p->out_data.rdata, offset1); - prs_dump(name, p->hdr_req.opnum, &p->out_data.rdata); + if (DEBUGLEVEL >= 50) { + fstring name; + slprintf(name, sizeof(name)-1, "out_%s", + get_pipe_name_from_iface(&p->syntax)); + prs_dump(name, p->hdr_req.opnum, &p->out_data.rdata); + } prs_set_offset(&p->out_data.rdata, offset2); - DEBUG(5,("api_rpcTNP: called %s successfully\n", rpc_name)); + DEBUG(5,("api_rpcTNP: called %s successfully\n", + get_pipe_name_from_iface(&p->syntax))); /* Check for buffer underflow in rpc parsing */ diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 90fa49f451..a20a98564b 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -90,13 +90,14 @@ static bool pipe_init_outgoing_data(pipes_struct *p) ****************************************************************************/ static struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, - const char *pipe_name, + const struct ndr_syntax_id *syntax, const char *client_address, struct auth_serversupplied_info *server_info) { pipes_struct *p; - DEBUG(4,("Create pipe requested %s\n", pipe_name)); + DEBUG(4,("Create pipe requested %s\n", + get_pipe_name_from_iface(syntax))); p = TALLOC_ZERO_P(mem_ctx, struct pipes_struct); @@ -105,13 +106,15 @@ static struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, return NULL; } - if ((p->mem_ctx = talloc_init("pipe %s %p", pipe_name, p)) == NULL) { + if ((p->mem_ctx = talloc_init("pipe %s %p", + get_pipe_name_from_iface(syntax), + p)) == NULL) { DEBUG(0,("open_rpc_pipe_p: talloc_init failed.\n")); TALLOC_FREE(p); return NULL; } - if (!init_pipe_handle_list(p, pipe_name)) { + if (!init_pipe_handle_list(p, syntax)) { DEBUG(0,("open_rpc_pipe_p: init_pipe_handles failed.\n")); talloc_destroy(p->mem_ctx); TALLOC_FREE(p); @@ -152,11 +155,11 @@ static struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, * Initialize the outgoing RPC data buffer with no memory. */ prs_init_empty(&p->out_data.rdata, p->mem_ctx, MARSHALL); - - fstrcpy(p->name, pipe_name); - + + p->syntax = *syntax; + DEBUG(4,("Created internal pipe %s (pipes_open=%d)\n", - pipe_name, pipes_open)); + get_pipe_name_from_iface(syntax), pipes_open)); talloc_set_destructor(p, close_internal_rpc_pipe_hnd); @@ -174,7 +177,7 @@ static void set_incoming_fault(pipes_struct *p) p->in_data.pdu_received_len = 0; p->fault_state = True; DEBUG(10, ("set_incoming_fault: Setting fault state on pipe %s\n", - p->name)); + get_pipe_name_from_iface(&p->syntax))); } /**************************************************************************** @@ -324,7 +327,8 @@ static void free_pipe_context(pipes_struct *p) "%lu\n", (unsigned long)talloc_total_size(p->mem_ctx) )); talloc_free_children(p->mem_ctx); } else { - p->mem_ctx = talloc_init("pipe %s %p", p->name, p); + p->mem_ctx = talloc_init( + "pipe %s %p", get_pipe_name_from_iface(&p->syntax), p); if (p->mem_ctx == NULL) { p->fault_state = True; } @@ -492,7 +496,7 @@ static void process_complete_pdu(pipes_struct *p) if(p->fault_state) { DEBUG(10,("process_complete_pdu: pipe %s in fault state.\n", - p->name )); + get_pipe_name_from_iface(&p->syntax))); set_incoming_fault(p); setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR)); return; @@ -520,12 +524,13 @@ static void process_complete_pdu(pipes_struct *p) case RPC_PING: /* CL request - ignore... */ DEBUG(0,("process_complete_pdu: Error. Connectionless packet type %u received on pipe %s.\n", - (unsigned int)p->hdr.pkt_type, p->name)); + (unsigned int)p->hdr.pkt_type, + get_pipe_name_from_iface(&p->syntax))); break; case RPC_RESPONSE: /* No responses here. */ DEBUG(0,("process_complete_pdu: Error. RPC_RESPONSE received from client on pipe %s.\n", - p->name )); + get_pipe_name_from_iface(&p->syntax))); break; case RPC_FAULT: @@ -537,7 +542,8 @@ static void process_complete_pdu(pipes_struct *p) case RPC_FACK: case RPC_CANCEL_ACK: DEBUG(0,("process_complete_pdu: Error. Connectionless packet type %u received on pipe %s.\n", - (unsigned int)p->hdr.pkt_type, p->name)); + (unsigned int)p->hdr.pkt_type, + get_pipe_name_from_iface(&p->syntax))); break; case RPC_BIND: @@ -552,7 +558,8 @@ static void process_complete_pdu(pipes_struct *p) case RPC_BINDACK: case RPC_BINDNACK: DEBUG(0,("process_complete_pdu: Error. RPC_BINDACK/RPC_BINDNACK packet type %u received on pipe %s.\n", - (unsigned int)p->hdr.pkt_type, p->name)); + (unsigned int)p->hdr.pkt_type, + get_pipe_name_from_iface(&p->syntax))); break; @@ -567,7 +574,7 @@ static void process_complete_pdu(pipes_struct *p) case RPC_ALTCONTRESP: DEBUG(0,("process_complete_pdu: Error. RPC_ALTCONTRESP on pipe %s: Should only be server -> client.\n", - p->name)); + get_pipe_name_from_iface(&p->syntax))); break; case RPC_AUTH3: @@ -581,7 +588,7 @@ static void process_complete_pdu(pipes_struct *p) case RPC_SHUTDOWN: DEBUG(0,("process_complete_pdu: Error. RPC_SHUTDOWN on pipe %s: Should only be server -> client.\n", - p->name)); + get_pipe_name_from_iface(&p->syntax))); break; case RPC_CO_CANCEL: @@ -619,7 +626,8 @@ static void process_complete_pdu(pipes_struct *p) prs_set_endian_data( &p->in_data.data, RPC_LITTLE_ENDIAN); if (!reply) { - DEBUG(3,("process_complete_pdu: DCE/RPC fault sent on pipe %s\n", p->pipe_srv_name)); + DEBUG(3,("process_complete_pdu: DCE/RPC fault sent on " + "pipe %s\n", get_pipe_name_from_iface(&p->syntax))); set_incoming_fault(p); setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR)); prs_mem_free(&rpc_in); @@ -773,7 +781,8 @@ static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data, size_ return -1; } - DEBUG(6,(" name: %s len: %u\n", p->name, (unsigned int)n)); + DEBUG(6,(" name: %s len: %u\n", get_pipe_name_from_iface(&p->syntax), + (unsigned int)n)); /* * We cannot return more than one PDU length per @@ -787,8 +796,10 @@ static ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data, size_ */ if(n > RPC_MAX_PDU_FRAG_LEN) { - DEBUG(5,("read_from_pipe: too large read (%u) requested on \ -pipe %s. We can only service %d sized reads.\n", (unsigned int)n, p->name, RPC_MAX_PDU_FRAG_LEN )); + DEBUG(5,("read_from_pipe: too large read (%u) requested on " + "pipe %s. We can only service %d sized reads.\n", + (unsigned int)n, get_pipe_name_from_iface(&p->syntax), + RPC_MAX_PDU_FRAG_LEN )); n = RPC_MAX_PDU_FRAG_LEN; } @@ -803,9 +814,12 @@ pipe %s. We can only service %d sized reads.\n", (unsigned int)n, p->name, RPC_M if((pdu_remaining = p->out_data.current_pdu_len - p->out_data.current_pdu_sent) > 0) { data_returned = (ssize_t)MIN(n, pdu_remaining); - DEBUG(10,("read_from_pipe: %s: current_pdu_len = %u, current_pdu_sent = %u \ -returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, - (unsigned int)p->out_data.current_pdu_sent, (int)data_returned)); + DEBUG(10,("read_from_pipe: %s: current_pdu_len = %u, " + "current_pdu_sent = %u returning %d bytes.\n", + get_pipe_name_from_iface(&p->syntax), + (unsigned int)p->out_data.current_pdu_len, + (unsigned int)p->out_data.current_pdu_sent, + (int)data_returned)); memcpy( data, &p->out_data.current_pdu[p->out_data.current_pdu_sent], (size_t)data_returned); p->out_data.current_pdu_sent += (uint32)data_returned; @@ -817,9 +831,11 @@ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, * may of course be zero if this is the first return fragment. */ - DEBUG(10,("read_from_pipe: %s: fault_state = %d : data_sent_length \ -= %u, prs_offset(&p->out_data.rdata) = %u.\n", - p->name, (int)p->fault_state, (unsigned int)p->out_data.data_sent_length, (unsigned int)prs_offset(&p->out_data.rdata) )); + DEBUG(10,("read_from_pipe: %s: fault_state = %d : data_sent_length " + "= %u, prs_offset(&p->out_data.rdata) = %u.\n", + get_pipe_name_from_iface(&p->syntax), (int)p->fault_state, + (unsigned int)p->out_data.data_sent_length, + (unsigned int)prs_offset(&p->out_data.rdata) )); if(p->out_data.data_sent_length >= prs_offset(&p->out_data.rdata)) { /* @@ -837,7 +853,8 @@ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, */ if(!create_next_pdu(p)) { - DEBUG(0,("read_from_pipe: %s: create_next_pdu failed.\n", p->name)); + DEBUG(0,("read_from_pipe: %s: create_next_pdu failed.\n", + get_pipe_name_from_iface(&p->syntax))); return -1; } @@ -1086,13 +1103,14 @@ NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name, handle->private_data = p; } else { struct pipes_struct *p; + struct ndr_syntax_id syntax; - if (!is_known_pipename(name)) { + if (!is_known_pipename(name, &syntax)) { TALLOC_FREE(handle); return NT_STATUS_OBJECT_NAME_NOT_FOUND; } - p = make_internal_rpc_pipe_p(handle, name, client_address, + p = make_internal_rpc_pipe_p(handle, &syntax, client_address, server_info); handle->type = FAKE_FILE_TYPE_NAMED_PIPE; -- cgit From 7967d8c779935df17363dd1cd3bea25d6e1b8479 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 1 Feb 2009 13:01:54 +0100 Subject: Move rpc_pipe_open_internal to srv_pipe_hnd.c This is a smbd-only function --- source3/rpc_client/cli_pipe.c | 37 ------------------------------------- source3/rpc_server/srv_pipe_hnd.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index cee5d1cfc8..0aaec05f67 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -4117,40 +4117,3 @@ NTSTATUS cli_get_session_key(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } - -/** - * Create a new RPC client context which uses a local dispatch function. - */ -NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *abstract_syntax, - NTSTATUS (*dispatch) (struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *r), - struct auth_serversupplied_info *serversupplied_info, - struct rpc_pipe_client **presult) -{ - struct rpc_pipe_client *result; - - result = TALLOC_ZERO_P(mem_ctx, struct rpc_pipe_client); - if (result == NULL) { - return NT_STATUS_NO_MEMORY; - } - - result->abstract_syntax = *abstract_syntax; - result->transfer_syntax = ndr_transfer_syntax; - result->dispatch = dispatch; - - result->pipes_struct = TALLOC_ZERO_P(mem_ctx, pipes_struct); - if (result->pipes_struct == NULL) { - TALLOC_FREE(result); - return NT_STATUS_NO_MEMORY; - } - result->pipes_struct->mem_ctx = mem_ctx; - result->pipes_struct->server_info = serversupplied_info; - result->pipes_struct->pipe_bound = true; - - result->max_xmit_frag = -1; - result->max_recv_frag = -1; - - *presult = result; - return NT_STATUS_OK; -} - - diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index a20a98564b..49049f8d55 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1303,3 +1303,40 @@ NTSTATUS np_read_recv(struct async_req *req, ssize_t *nread, *is_data_outstanding = state->is_data_outstanding; return NT_STATUS_OK; } + +/** + * Create a new RPC client context which uses a local dispatch function. + */ +NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx, + const struct ndr_syntax_id *abstract_syntax, + NTSTATUS (*dispatch) (struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const struct ndr_interface_table *table, + uint32_t opnum, void *r), + struct auth_serversupplied_info *serversupplied_info, + struct rpc_pipe_client **presult) +{ + struct rpc_pipe_client *result; + + result = TALLOC_ZERO_P(mem_ctx, struct rpc_pipe_client); + if (result == NULL) { + return NT_STATUS_NO_MEMORY; + } + + result->abstract_syntax = *abstract_syntax; + result->transfer_syntax = ndr_transfer_syntax; + result->dispatch = dispatch; + + result->pipes_struct = make_internal_rpc_pipe_p( + result, abstract_syntax, "", serversupplied_info); + if (result->pipes_struct == NULL) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + result->max_xmit_frag = -1; + result->max_recv_frag = -1; + + *presult = result; + return NT_STATUS_OK; +} -- cgit From 50ca5af9f38b46fb3c7dea5b50997d3bd1c7e46f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 31 Jan 2009 17:58:30 +0100 Subject: Convert api_RNetUserEnum to use the srv_samr_nt.c directly This is a sample for other accesses to pdb to go via samr. The goal is to access passdb only via srv_samr_nt.c. If that is done, then we can easily swap in another samr implementation like for example samba4's via a unix domain socket. --- source3/smbd/lanman.c | 103 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 77 insertions(+), 26 deletions(-) diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index 3ae4b1d61a..4807e62436 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -2281,8 +2281,11 @@ static bool api_RNetUserEnum(connection_struct *conn, uint16 vuid, int num_users=0; int errflags=0; int i, resume_context, cli_buf_size; - struct pdb_search *search; - struct samr_displayentry *users; + uint32_t resume_handle; + + struct rpc_pipe_client *samr_pipe; + struct policy_handle samr_handle, domain_handle; + NTSTATUS status; char *str1 = get_safe_str_ptr(param,tpscnt,param,2); char *str2 = skip_string(param,tpscnt,str1); @@ -2327,40 +2330,88 @@ static bool api_RNetUserEnum(connection_struct *conn, uint16 vuid, p = *rdata; endp = *rdata + *rdata_len; - become_root(); - search = pdb_search_users(ACB_NORMAL); - unbecome_root(); - if (search == NULL) { - DEBUG(0, ("api_RNetUserEnum:unable to open sam database.\n")); - return False; + status = rpc_pipe_open_internal( + talloc_tos(), &ndr_table_samr.syntax_id, rpc_samr_dispatch, + conn->server_info, &samr_pipe); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("api_RNetUserEnum: Could not connect to samr: %s\n", + nt_errstr(status))); + return false; } - become_root(); - num_users = pdb_search_entries(search, resume_context, 0xffffffff, - &users); - unbecome_root(); + status = rpccli_samr_Connect2(samr_pipe, talloc_tos(), global_myname(), + SAMR_ACCESS_OPEN_DOMAIN, &samr_handle); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("api_RNetUserEnum: samr_Connect2 failed: %s\n", + nt_errstr(status))); + return false; + } + + status = rpccli_samr_OpenDomain(samr_pipe, talloc_tos(), &samr_handle, + SAMR_DOMAIN_ACCESS_ENUM_ACCOUNTS, + get_global_sam_sid(), &domain_handle); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("api_RNetUserEnum: samr_OpenDomain failed: %s\n", + nt_errstr(status))); + return false; + } errflags=NERR_Success; - for (i=0; ientries[i].name.string; + + if(((PTR_DIFF(p,*rdata)+21)<=*rdata_len) + &&(strlen(name)<=21)) { + strlcpy(p,name,PTR_DIFF(endp,p)); + DEBUG(10,("api_RNetUserEnum:adding entry %d " + "username %s\n",count_sent,p)); + p += 21; + count_sent++; + } else { + /* set overflow error */ + DEBUG(10,("api_RNetUserEnum:overflow on entry %d " + "username %s\n",count_sent,name)); + errflags=234; + break; + } + } + + if (errflags != NERR_Success) { + break; + } + + TALLOC_FREE(sam_entries); } - pdb_search_destroy(search); + rpccli_samr_Close(samr_pipe, talloc_tos(), &domain_handle); + rpccli_samr_Close(samr_pipe, talloc_tos(), &samr_handle); *rdata_len = PTR_DIFF(p,*rdata); -- cgit From 0931bb8937eaec55844dee0cdeefafa162053c53 Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Sun, 1 Feb 2009 13:28:06 +0100 Subject: "test" expects only one = Signed-off-by: Stefan Metzmacher --- source4/build/m4/check_path.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/build/m4/check_path.m4 b/source4/build/m4/check_path.m4 index f7266e6e44..1751a89e5f 100644 --- a/source4/build/m4/check_path.m4 +++ b/source4/build/m4/check_path.m4 @@ -43,7 +43,7 @@ if test x$fhs = xyes; then winbindd_privileged_socket_dir="${localstatedir}/lib/samba/winbindd_privileged" else # Check to prevent installing directly under /usr without the FHS - AS_IF([test $prefix == /usr || test $prefix == /usr/local],[ + AS_IF([test $prefix = /usr || test $prefix = /usr/local],[ AC_MSG_ERROR([Don't install directly under "/usr" or "/usr/local" without using the FHS option (--enable-fhs). This could lead to file loss!]) ]) fi -- cgit From c14b7e648bcfc4865da4b290e46977fff81d4500 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 1 Feb 2009 16:32:02 +0100 Subject: Split up async_req into a generic and a NTSTATUS specific part --- lib/async_req/async_req.c | 67 +++++--------------- lib/async_req/async_req.h | 20 +++--- lib/async_req/async_req_ntstatus.c | 82 ++++++++++++++++++++++++ lib/async_req/async_req_ntstatus.h | 37 +++++++++++ lib/async_req/async_sock.c | 30 ++++----- lib/async_req/config.mk | 2 +- source3/Makefile.in | 2 +- source3/include/includes.h | 2 +- source3/lib/util_sock.c | 26 ++++---- source3/lib/wb_reqtrans.c | 50 +++++++-------- source3/lib/wbclient.c | 54 ++++++++-------- source3/libsmb/async_smb.c | 4 +- source3/libsmb/cliconnect.c | 8 +-- source3/libsmb/clientgen.c | 6 +- source3/libsmb/clifile.c | 6 +- source3/libsmb/clireadwrite.c | 32 +++++----- source3/libsmb/clitrans.c | 14 ++--- source3/rpc_client/cli_pipe.c | 106 ++++++++++++++++---------------- source3/rpc_client/rpc_transport_np.c | 18 +++--- source3/rpc_client/rpc_transport_smbd.c | 30 ++++----- source3/rpc_server/srv_pipe_hnd.c | 12 ++-- 21 files changed, 343 insertions(+), 265 deletions(-) create mode 100644 lib/async_req/async_req_ntstatus.c create mode 100644 lib/async_req/async_req_ntstatus.h diff --git a/lib/async_req/async_req.c b/lib/async_req/async_req.c index be70a56380..1b9fc5517b 100644 --- a/lib/async_req/async_req.c +++ b/lib/async_req/async_req.c @@ -43,8 +43,8 @@ char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req) { - return talloc_asprintf(mem_ctx, "async_req: state=%d, status=%s, " - "priv=%s", req->state, nt_errstr(req->status), + return talloc_asprintf(mem_ctx, "async_req: state=%d, error=%d, " + "priv=%s", req->state, (int)req->error, talloc_get_name(req->private_data)); } @@ -81,7 +81,7 @@ struct async_req *async_req_new(TALLOC_CTX *mem_ctx) void async_req_done(struct async_req *req) { - req->status = NT_STATUS_OK; + req->error = 0; req->state = ASYNC_REQ_DONE; if (req->async.fn != NULL) { req->async.fn(req); @@ -98,9 +98,9 @@ void async_req_done(struct async_req *req) * function with the appropriate status code. */ -void async_req_error(struct async_req *req, NTSTATUS status) +void async_req_error(struct async_req *req, uint32_t error) { - req->status = status; + req->error = error; req->state = ASYNC_REQ_ERROR; if (req->async.fn != NULL) { req->async.fn(req); @@ -121,11 +121,11 @@ static void async_trigger(struct tevent_context *ev, struct tevent_timer *te, struct async_req *req = talloc_get_type_abort(priv, struct async_req); TALLOC_FREE(te); - if (NT_STATUS_IS_OK(req->status)) { + if (req->error == 0) { async_req_done(req); } else { - async_req_error(req, req->status); + async_req_error(req, req->error); } } @@ -142,10 +142,10 @@ static void async_trigger(struct tevent_context *ev, struct tevent_timer *te, * conventions, independent of whether the request was actually deferred. */ -bool async_post_status(struct async_req *req, struct tevent_context *ev, - NTSTATUS status) +bool async_post_error(struct async_req *req, struct tevent_context *ev, + uint32_t error) { - req->status = status; + req->error = error; if (tevent_add_timer(ev, req, timeval_zero(), async_trigger, req) == NULL) { @@ -154,55 +154,18 @@ bool async_post_status(struct async_req *req, struct tevent_context *ev, return true; } -/** - * @brief Helper function for nomem check - * @param[in] p The pointer to be checked - * @param[in] req The request being processed - * - * Convenience helper to easily check alloc failure within a callback - * implementing the next step of an async request. - * - * Call pattern would be - * \code - * p = talloc(mem_ctx, bla); - * if (async_req_nomem(p, req)) { - * return; - * } - * \endcode - */ - -bool async_req_nomem(const void *p, struct async_req *req) -{ - if (p != NULL) { - return false; - } - async_req_error(req, NT_STATUS_NO_MEMORY); - return true; -} - -bool async_req_is_error(struct async_req *req, NTSTATUS *status) +bool async_req_is_error(struct async_req *req, uint32_t *error) { if (req->state < ASYNC_REQ_DONE) { - *status = NT_STATUS_INTERNAL_ERROR; return true; } if (req->state == ASYNC_REQ_ERROR) { - *status = req->status; + *error = req->error; return true; } return false; } -NTSTATUS async_req_simple_recv(struct async_req *req) -{ - NTSTATUS status; - - if (async_req_is_error(req, &status)) { - return status; - } - return NT_STATUS_OK; -} - static void async_req_timedout(struct tevent_context *ev, struct tevent_timer *te, struct timeval now, @@ -211,7 +174,7 @@ static void async_req_timedout(struct tevent_context *ev, struct async_req *req = talloc_get_type_abort( priv, struct async_req); TALLOC_FREE(te); - async_req_error(req, NT_STATUS_IO_TIMEOUT); + async_req_nterror(req, NT_STATUS_IO_TIMEOUT); } bool async_req_set_timeout(struct async_req *req, struct tevent_context *ev, @@ -240,9 +203,9 @@ struct async_req *async_wait_send(TALLOC_CTX *mem_ctx, return result; } -NTSTATUS async_wait_recv(struct async_req *req) +bool async_wait_recv(struct async_req *req) { - return NT_STATUS_OK; + return true; } struct async_queue_entry { diff --git a/lib/async_req/async_req.h b/lib/async_req/async_req.h index 59f5bd19b2..19b052a788 100644 --- a/lib/async_req/async_req.h +++ b/lib/async_req/async_req.h @@ -20,7 +20,7 @@ #ifndef __ASYNC_REQ_H__ #define __ASYNC_REQ_H__ -#include "includes.h" +#include "lib/talloc/talloc.h" /** * An async request moves between the following 4 states: @@ -92,9 +92,9 @@ struct async_req { * @brief status code when finished * * This status can be queried in the async completion function. It - * will be set to NT_STATUS_OK when everything went fine. + * will be set to 0 when everything went fine. **/ - NTSTATUS status; + uint32_t error; /** * @brief What to do on completion @@ -121,16 +121,12 @@ char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req); void async_req_done(struct async_req *req); -void async_req_error(struct async_req *req, NTSTATUS status); +void async_req_error(struct async_req *req, uint32_t error); -bool async_post_status(struct async_req *req, struct tevent_context *ev, - NTSTATUS status); +bool async_post_error(struct async_req *req, struct tevent_context *ev, + uint32_t error); -bool async_req_nomem(const void *p, struct async_req *req); - -bool async_req_is_error(struct async_req *req, NTSTATUS *status); - -NTSTATUS async_req_simple_recv(struct async_req *req); +bool async_req_is_error(struct async_req *req, uint32_t *error); bool async_req_set_timeout(struct async_req *req, struct tevent_context *ev, struct timeval to); @@ -139,7 +135,7 @@ struct async_req *async_wait_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct timeval to); -NTSTATUS async_wait_recv(struct async_req *req); +bool async_wait_recv(struct async_req *req); struct async_req_queue; diff --git a/lib/async_req/async_req_ntstatus.c b/lib/async_req/async_req_ntstatus.c new file mode 100644 index 0000000000..dd81026074 --- /dev/null +++ b/lib/async_req/async_req_ntstatus.c @@ -0,0 +1,82 @@ +/* + Unix SMB/CIFS implementation. + NTSTATUS wrappers for async_req.h + Copyright (C) Volker Lendecke 2008, 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 . +*/ + +#include "includes.h" +#include "lib/tevent/tevent.h" +#include "lib/talloc/talloc.h" +#include "lib/util/dlinklist.h" +#include "lib/async_req/async_req_ntstatus.h" + +/** + * @brief Helper function for nomem check + * @param[in] p The pointer to be checked + * @param[in] req The request being processed + * + * Convenience helper to easily check alloc failure within a callback + * implementing the next step of an async request. + * + * Call pattern would be + * \code + * p = talloc(mem_ctx, bla); + * if (async_req_ntnomem(p, req)) { + * return; + * } + * \endcode + */ + +bool async_req_ntnomem(const void *p, struct async_req *req) +{ + if (p != NULL) { + return false; + } + async_req_nterror(req, NT_STATUS_NO_MEMORY); + return true; +} + +void async_req_nterror(struct async_req *req, NTSTATUS status) +{ + async_req_error(req, NT_STATUS_V(status)); +} + +bool async_post_ntstatus(struct async_req *req, struct tevent_context *ev, + NTSTATUS status) +{ + return async_post_error(req, ev, NT_STATUS_V(status)); +} + +bool async_req_is_nterror(struct async_req *req, NTSTATUS *status) +{ + uint32_t error = NT_STATUS_V(NT_STATUS_INTERNAL_ERROR); + + if (async_req_is_error(req, &error)) { + *status = NT_STATUS(error); + return true; + } + return false; +} + +NTSTATUS async_req_simple_recv_ntstatus(struct async_req *req) +{ + NTSTATUS status; + + if (async_req_is_nterror(req, &status)) { + return status; + } + return NT_STATUS_OK; +} diff --git a/lib/async_req/async_req_ntstatus.h b/lib/async_req/async_req_ntstatus.h new file mode 100644 index 0000000000..7cc8caa14c --- /dev/null +++ b/lib/async_req/async_req_ntstatus.h @@ -0,0 +1,37 @@ +/* + Unix SMB/CIFS implementation. + NTSTATUS wrappers for async_req.h + Copyright (C) Volker Lendecke 2008, 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 . +*/ + +#ifndef __ASYNC_REQ_NTSTATUS_H__ +#define __ASYNC_REQ_NTSTATUS_H__ + +#include "lib/async_req/async_req.h" +#include "includes.h" + +void async_req_nterror(struct async_req *req, NTSTATUS status); + +bool async_post_ntstatus(struct async_req *req, struct tevent_context *ev, + NTSTATUS status); + +bool async_req_is_nterror(struct async_req *req, NTSTATUS *status); + +NTSTATUS async_req_simple_recv_ntstatus(struct async_req *req); + +bool async_req_ntnomem(const void *p, struct async_req *req); + +#endif diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c index 7febc54fd4..b992320669 100644 --- a/lib/async_req/async_sock.c +++ b/lib/async_req/async_sock.c @@ -239,7 +239,7 @@ static void async_send_callback(struct tevent_context *ev, struct param_send *p = &state->param.param_send; if (state->syscall_type != ASYNC_SYSCALL_SEND) { - async_req_error(req, NT_STATUS_INTERNAL_ERROR); + async_req_nterror(req, NT_STATUS_INTERNAL_ERROR); return; } @@ -306,7 +306,7 @@ static void async_sendall_callback(struct tevent_context *ev, struct param_sendall *p = &state->param.param_sendall; if (state->syscall_type != ASYNC_SYSCALL_SENDALL) { - async_req_error(req, NT_STATUS_INTERNAL_ERROR); + async_req_nterror(req, NT_STATUS_INTERNAL_ERROR); return; } @@ -316,18 +316,18 @@ static void async_sendall_callback(struct tevent_context *ev, state->sys_errno = errno; if (state->result.result_ssize_t == -1) { - async_req_error(req, map_nt_error_from_unix(state->sys_errno)); + async_req_nterror(req, map_nt_error_from_unix(state->sys_errno)); return; } if (state->result.result_ssize_t == 0) { - async_req_error(req, NT_STATUS_END_OF_FILE); + async_req_nterror(req, NT_STATUS_END_OF_FILE); return; } p->sent += state->result.result_ssize_t; if (p->sent > p->length) { - async_req_error(req, NT_STATUS_INTERNAL_ERROR); + async_req_nterror(req, NT_STATUS_INTERNAL_ERROR); return; } @@ -376,7 +376,7 @@ struct async_req *sendall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, NTSTATUS sendall_recv(struct async_req *req) { - return async_req_simple_recv(req); + return async_req_simple_recv_ntstatus(req); } /** @@ -398,7 +398,7 @@ static void async_recv_callback(struct tevent_context *ev, struct param_recv *p = &state->param.param_recv; if (state->syscall_type != ASYNC_SYSCALL_RECV) { - async_req_error(req, NT_STATUS_INTERNAL_ERROR); + async_req_nterror(req, NT_STATUS_INTERNAL_ERROR); return; } @@ -466,7 +466,7 @@ static void async_recvall_callback(struct tevent_context *ev, struct param_recvall *p = &state->param.param_recvall; if (state->syscall_type != ASYNC_SYSCALL_RECVALL) { - async_req_error(req, NT_STATUS_INTERNAL_ERROR); + async_req_nterror(req, NT_STATUS_INTERNAL_ERROR); return; } @@ -476,18 +476,18 @@ static void async_recvall_callback(struct tevent_context *ev, state->sys_errno = errno; if (state->result.result_ssize_t == -1) { - async_req_error(req, map_nt_error_from_unix(state->sys_errno)); + async_req_nterror(req, map_nt_error_from_unix(state->sys_errno)); return; } if (state->result.result_ssize_t == 0) { - async_req_error(req, NT_STATUS_END_OF_FILE); + async_req_nterror(req, NT_STATUS_END_OF_FILE); return; } p->received += state->result.result_ssize_t; if (p->received > p->length) { - async_req_error(req, NT_STATUS_INTERNAL_ERROR); + async_req_nterror(req, NT_STATUS_INTERNAL_ERROR); return; } @@ -535,7 +535,7 @@ struct async_req *recvall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, NTSTATUS recvall_recv(struct async_req *req) { - return async_req_simple_recv(req); + return async_req_simple_recv_ntstatus(req); } struct async_connect_state { @@ -627,7 +627,7 @@ struct async_req *async_connect_send(TALLOC_CTX *mem_ctx, status = map_nt_error_from_unix(state->sys_errno); post_status: fcntl(fd, F_SETFL, state->old_sockflags); - if (!async_post_status(result, ev, status)) { + if (!async_post_ntstatus(result, ev, status)) { goto fail; } return result; @@ -675,7 +675,7 @@ static void async_connect_connected(struct tevent_context *ev, DEBUG(10, ("connect returned %s\n", strerror(errno))); fcntl(state->fd, F_SETFL, state->old_sockflags); - async_req_error(req, map_nt_error_from_unix(state->sys_errno)); + async_req_nterror(req, map_nt_error_from_unix(state->sys_errno)); return; } @@ -693,7 +693,7 @@ NTSTATUS async_connect_recv(struct async_req *req, int *perrno) *perrno = state->sys_errno; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } if (state->sys_errno == 0) { diff --git a/lib/async_req/config.mk b/lib/async_req/config.mk index 8cc594082c..820f890fd0 100644 --- a/lib/async_req/config.mk +++ b/lib/async_req/config.mk @@ -1,3 +1,3 @@ [SUBSYSTEM::LIBASYNC_REQ] -LIBASYNC_REQ_OBJ_FILES = $(addprefix ../lib/async_req/, async_req.o async_sock.o) +LIBASYNC_REQ_OBJ_FILES = $(addprefix ../lib/async_req/, async_req.o async_sock.o async_req_ntstatus.o) diff --git a/source3/Makefile.in b/source3/Makefile.in index babdd51248..fa57db7f3f 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -343,7 +343,7 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \ lib/messages_ctdbd.o lib/packet.o lib/ctdbd_conn.o \ lib/interfaces.o lib/memcache.o \ lib/util_transfer_file.o ../lib/async_req/async_req.o \ - ../lib/async_req/async_sock.o \ + ../lib/async_req/async_sock.o ../lib/async_req/async_req_ntstatus.o \ $(TDB_LIB_OBJ) \ $(VERSION_OBJ) lib/charcnv.o lib/debug.o lib/fault.o \ lib/interface.o lib/pidfile.o \ diff --git a/source3/include/includes.h b/source3/include/includes.h index 7b0b270f60..c58ebcdbfe 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -647,7 +647,7 @@ struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx); #include "ctdbd_conn.h" #include "../lib/util/talloc_stack.h" #include "memcache.h" -#include "../lib/async_req/async_req.h" +#include "../lib/async_req/async_req_ntstatus.h" #include "async_smb.h" #include "../lib/async_req/async_sock.h" #include "services.h" diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 3ddc4342a7..bafcdc5c5c 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1036,7 +1036,7 @@ struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx, return result; post_status: - if (!async_post_status(result, ev, status)) { + if (!async_post_ntstatus(result, ev, status)) { goto fail; } return result; @@ -1077,12 +1077,12 @@ static void open_socket_out_connected(struct async_req *subreq) subreq = async_connect_send(state, state->ev, state->fd, (struct sockaddr *)&state->ss, state->salen); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } if (!async_req_set_timeout(subreq, state->ev, timeval_set(0, state->wait_nsec))) { - async_req_error(req, NT_STATUS_NO_MEMORY); + async_req_nterror(req, NT_STATUS_NO_MEMORY); return; } subreq->async.fn = open_socket_out_connected; @@ -1098,7 +1098,7 @@ static void open_socket_out_connected(struct async_req *subreq) #endif /* real error */ - async_req_error(req, map_nt_error_from_unix(sys_errno)); + async_req_nterror(req, map_nt_error_from_unix(sys_errno)); } NTSTATUS open_socket_out_recv(struct async_req *req, int *pfd) @@ -1107,7 +1107,7 @@ NTSTATUS open_socket_out_recv(struct async_req *req, int *pfd) req->private_data, struct open_socket_out_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } *pfd = state->fd; @@ -1183,7 +1183,7 @@ struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx, return result; post_status: - if (!async_post_status(result, ev, status)) { + if (!async_post_ntstatus(result, ev, status)) { goto fail; } return result; @@ -1198,18 +1198,18 @@ static void open_socket_out_defer_waited(struct async_req *subreq) 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); - NTSTATUS status; + bool ret; - status = async_wait_recv(subreq); + ret = async_wait_recv(subreq); TALLOC_FREE(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + if (!ret) { + async_req_nterror(req, NT_STATUS_INTERNAL_ERROR); return; } subreq = open_socket_out_send(state, state->ev, &state->ss, state->port, state->timeout); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } subreq->async.fn = open_socket_out_defer_connected; @@ -1227,7 +1227,7 @@ static void open_socket_out_defer_connected(struct async_req *subreq) status = open_socket_out_recv(subreq, &state->fd); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -1239,7 +1239,7 @@ NTSTATUS open_socket_out_defer_recv(struct async_req *req, int *pfd) req->private_data, struct open_socket_out_defer_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } *pfd = state->fd; diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index 0e6e5d15c4..7bca627690 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -81,7 +81,7 @@ static void wb_req_read_len(struct async_req *subreq) status = recvall_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -89,14 +89,14 @@ static void wb_req_read_len(struct async_req *subreq) DEBUG(0, ("wb_req_read_len: Invalid request size received: " "%d (expected %d)\n", (int)state->wb_req->length, (int)sizeof(struct winbindd_request))); - async_req_error(req, NT_STATUS_INVALID_BUFFER_SIZE); + async_req_nterror(req, NT_STATUS_INVALID_BUFFER_SIZE); return; } subreq = recvall_send( req, state->ev, state->fd, (uint32 *)(state->wb_req)+1, sizeof(struct winbindd_request) - sizeof(uint32), 0); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } @@ -115,7 +115,7 @@ static void wb_req_read_main(struct async_req *subreq) status = recvall_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -124,7 +124,7 @@ static void wb_req_read_main(struct async_req *subreq) DEBUG(3, ("Got request with %d bytes extra data on " "unprivileged socket\n", (int)state->wb_req->extra_len)); - async_req_error(req, NT_STATUS_INVALID_BUFFER_SIZE); + async_req_nterror(req, NT_STATUS_INVALID_BUFFER_SIZE); return; } @@ -135,7 +135,7 @@ static void wb_req_read_main(struct async_req *subreq) state->wb_req->extra_data.data = TALLOC_ARRAY( state->wb_req, char, state->wb_req->extra_len + 1); - if (async_req_nomem(state->wb_req->extra_data.data, req)) { + if (async_req_ntnomem(state->wb_req->extra_data.data, req)) { return; } @@ -144,7 +144,7 @@ static void wb_req_read_main(struct async_req *subreq) subreq = recvall_send( req, state->ev, state->fd, state->wb_req->extra_data.data, state->wb_req->extra_len, 0); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } @@ -161,7 +161,7 @@ static void wb_req_read_extra(struct async_req *subreq) status = recvall_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -175,7 +175,7 @@ NTSTATUS wb_req_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx, req->private_data, struct req_read_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } *preq = talloc_move(mem_ctx, &state->wb_req); @@ -232,7 +232,7 @@ static void wb_req_write_main(struct async_req *subreq) status = sendall_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -244,7 +244,7 @@ static void wb_req_write_main(struct async_req *subreq) subreq = sendall_send(state, state->ev, state->fd, state->wb_req->extra_data.data, state->wb_req->extra_len, 0); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } @@ -261,7 +261,7 @@ static void wb_req_write_extra(struct async_req *subreq) status = sendall_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -270,7 +270,7 @@ static void wb_req_write_extra(struct async_req *subreq) NTSTATUS wb_req_write_recv(struct async_req *req) { - return async_req_simple_recv(req); + return async_req_simple_recv_ntstatus(req); } struct resp_read_state { @@ -327,7 +327,7 @@ static void wb_resp_read_len(struct async_req *subreq) status = recvall_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -336,14 +336,14 @@ static void wb_resp_read_len(struct async_req *subreq) "%d (expected at least%d)\n", (int)state->wb_resp->length, (int)sizeof(struct winbindd_response))); - async_req_error(req, NT_STATUS_INVALID_BUFFER_SIZE); + async_req_nterror(req, NT_STATUS_INVALID_BUFFER_SIZE); return; } subreq = recvall_send( req, state->ev, state->fd, (uint32 *)(state->wb_resp)+1, sizeof(struct winbindd_response) - sizeof(uint32), 0); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } @@ -363,7 +363,7 @@ static void wb_resp_read_main(struct async_req *subreq) status = recvall_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -375,7 +375,7 @@ static void wb_resp_read_main(struct async_req *subreq) state->wb_resp->extra_data.data = TALLOC_ARRAY( state->wb_resp, char, extra_len+1); - if (async_req_nomem(state->wb_resp->extra_data.data, req)) { + if (async_req_ntnomem(state->wb_resp->extra_data.data, req)) { return; } ((char *)state->wb_resp->extra_data.data)[extra_len] = 0; @@ -383,7 +383,7 @@ static void wb_resp_read_main(struct async_req *subreq) subreq = recvall_send( req, state->ev, state->fd, state->wb_resp->extra_data.data, extra_len, 0); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } @@ -400,7 +400,7 @@ static void wb_resp_read_extra(struct async_req *subreq) status = recvall_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -414,7 +414,7 @@ NTSTATUS wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx, req->private_data, struct resp_read_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } *presp = talloc_move(mem_ctx, &state->wb_resp); @@ -471,7 +471,7 @@ static void wb_resp_write_main(struct async_req *subreq) status = sendall_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -484,7 +484,7 @@ static void wb_resp_write_main(struct async_req *subreq) state, state->ev, state->fd, state->wb_resp->extra_data.data, state->wb_resp->length - sizeof(struct winbindd_response), 0); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } @@ -501,7 +501,7 @@ static void wb_resp_write_extra(struct async_req *subreq) status = sendall_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -510,5 +510,5 @@ static void wb_resp_write_extra(struct async_req *subreq) NTSTATUS wb_resp_write_recv(struct async_req *req) { - return async_req_simple_recv(req); + return async_req_simple_recv_ntstatus(req); } diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index ea0bcb512e..cf5ce7e734 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -232,7 +232,7 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx, if (req == NULL) { return NULL; } - if (async_post_status(req, ev, status)) { + if (async_post_ntstatus(req, ev, status)) { return req; } TALLOC_FREE(req); @@ -295,8 +295,8 @@ static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, } if (winbind_closed_fd(fd)) { - if (!async_post_status(result, ev, - NT_STATUS_PIPE_DISCONNECTED)) { + if (!async_post_ntstatus(result, ev, + NT_STATUS_PIPE_DISCONNECTED)) { goto fail; } return result; @@ -334,13 +334,13 @@ static void wb_int_trans_write_done(struct async_req *subreq) status = wb_req_write_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } subreq = wb_resp_read_send(state, state->ev, state->fd); if (subreq == NULL) { - async_req_error(req, NT_STATUS_NO_MEMORY); + async_req_nterror(req, NT_STATUS_NO_MEMORY); } subreq->async.fn = wb_int_trans_read_done; subreq->async.priv = req; @@ -357,7 +357,7 @@ static void wb_int_trans_read_done(struct async_req *subreq) status = wb_resp_read_recv(subreq, state, &state->wb_resp); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -372,7 +372,7 @@ static NTSTATUS wb_int_trans_recv(struct async_req *req, req->private_data, struct wb_int_trans_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } @@ -454,7 +454,7 @@ static void wb_open_pipe_connect_nonpriv_done(struct async_req *subreq) TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { state->wb_ctx->is_priv = true; - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -463,7 +463,7 @@ static void wb_open_pipe_connect_nonpriv_done(struct async_req *subreq) subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, &state->wb_req); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } @@ -483,7 +483,7 @@ static void wb_open_pipe_ping_done(struct async_req *subreq) status = wb_int_trans_recv(subreq, state, &wb_resp); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -496,7 +496,7 @@ static void wb_open_pipe_ping_done(struct async_req *subreq) subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, &state->wb_req); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } @@ -516,7 +516,7 @@ static void wb_open_pipe_getpriv_done(struct async_req *subreq) status = wb_int_trans_recv(subreq, state, &wb_resp); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -526,7 +526,7 @@ static void wb_open_pipe_getpriv_done(struct async_req *subreq) subreq = wb_connect_send(state, state->ev, state->wb_ctx, (char *)wb_resp->extra_data.data); TALLOC_FREE(wb_resp); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } @@ -545,7 +545,7 @@ static void wb_open_pipe_connect_priv_done(struct async_req *subreq) status = wb_connect_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } state->wb_ctx->is_priv = true; @@ -554,7 +554,7 @@ static void wb_open_pipe_connect_priv_done(struct async_req *subreq) static NTSTATUS wb_open_pipe_recv(struct async_req *req) { - return async_req_simple_recv(req); + return async_req_simple_recv_ntstatus(req); } struct wb_trans_state { @@ -582,7 +582,7 @@ static void wb_trigger_trans(struct async_req *req) subreq = wb_open_pipe_send(state, state->ev, state->wb_ctx, state->need_priv); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } subreq->async.fn = wb_trans_connect_done; @@ -592,7 +592,7 @@ static void wb_trigger_trans(struct async_req *req) subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, state->wb_req); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } subreq->async.fn = wb_trans_done; @@ -645,13 +645,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, status); + async_req_nterror(req, status); return true; } state->num_retries -= 1; if (state->num_retries == 0) { - async_req_error(req, status); + async_req_nterror(req, status); return true; } @@ -665,7 +665,7 @@ static bool wb_trans_retry(struct async_req *req, } subreq = async_wait_send(state, state->ev, timeval_set(1, 0)); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return true; } @@ -680,18 +680,18 @@ static void wb_trans_retry_wait_done(struct async_req *subreq) subreq->async.priv, struct async_req); struct wb_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_trans_state); - NTSTATUS status; + bool ret; - status = async_wait_recv(subreq); + ret = async_wait_recv(subreq); TALLOC_FREE(subreq); - if (!NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - async_req_error(req, status); + if (ret) { + async_req_nterror(req, NT_STATUS_INTERNAL_ERROR); return; } subreq = wb_open_pipe_send(state, state->ev, state->wb_ctx, state->need_priv); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } subreq->async.fn = wb_trans_connect_done; @@ -715,7 +715,7 @@ static void wb_trans_connect_done(struct async_req *subreq) subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, state->wb_req); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } @@ -748,7 +748,7 @@ NTSTATUS wb_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx, req->private_data, struct wb_trans_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c index 18e5a71ee2..e579d1c9f0 100644 --- a/source3/libsmb/async_smb.c +++ b/source3/libsmb/async_smb.c @@ -979,7 +979,7 @@ static void handle_incoming_pdu(struct cli_state *cli) nt_errstr(status))); for (req = cli->outstanding_requests; req; req = req->next) { - async_req_error(req->async[0], status); + async_req_nterror(req->async[0], status); } return; } @@ -1110,7 +1110,7 @@ static void cli_state_handler(struct event_context *event_ctx, num_async = req->num_async; for (i=0; iasync[i], status); + async_req_nterror(req->async[i], status); } } TALLOC_FREE(cli->fd_event); diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index ed5adc5694..60b1a6027c 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -215,7 +215,7 @@ NTSTATUS cli_session_setup_guest_recv(struct async_req *req) uint8_t *p; NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } @@ -1283,7 +1283,7 @@ struct async_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx, access_denied: result = async_req_new(mem_ctx); - if (async_post_status(result, ev, NT_STATUS_ACCESS_DENIED)) { + if (async_post_ntstatus(result, ev, NT_STATUS_ACCESS_DENIED)) { return result; } TALLOC_FREE(result); @@ -1301,7 +1301,7 @@ NTSTATUS cli_tcon_andx_recv(struct async_req *req) uint8_t *bytes; NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } @@ -1483,7 +1483,7 @@ NTSTATUS cli_negprot_recv(struct async_req *req) NTSTATUS status; uint16_t protnum; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index a41aa11f7a..0382ef5fae 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -650,7 +650,7 @@ static void cli_echo_recv_helper(struct async_req *req) status = cli_pull_reply(req, &wct, &vwv, &num_bytes, &bytes); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -659,7 +659,7 @@ static void cli_echo_recv_helper(struct async_req *req) if ((num_bytes != cli_req->data.echo.data.length) || (memcmp(cli_req->data.echo.data.data, bytes, num_bytes) != 0)) { - async_req_error(req, NT_STATUS_INVALID_NETWORK_RESPONSE); + async_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE); return; } @@ -727,7 +727,7 @@ struct async_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev, NTSTATUS cli_echo_recv(struct async_req *req) { - return async_req_simple_recv(req); + return async_req_simple_recv_ntstatus(req); } /** diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 91f13a79ac..0703f04c5f 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -836,7 +836,7 @@ NTSTATUS cli_ntcreate_recv(struct async_req *req, uint16_t *pfnum) uint8_t *bytes; NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } @@ -1049,7 +1049,7 @@ NTSTATUS cli_open_recv(struct async_req *req, int *fnum) uint8_t *bytes; NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } @@ -1127,7 +1127,7 @@ NTSTATUS cli_close_recv(struct async_req *req) uint8_t *bytes; NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c index 1ba93d827d..26fa614f69 100644 --- a/source3/libsmb/clireadwrite.c +++ b/source3/libsmb/clireadwrite.c @@ -148,7 +148,7 @@ NTSTATUS cli_read_andx_recv(struct async_req *req, ssize_t *received, NTSTATUS status; size_t size; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } @@ -297,7 +297,7 @@ struct async_req *cli_pull_send(TALLOC_CTX *mem_ctx, state->top_req = 0; if (size == 0) { - if (!async_post_status(result, ev, NT_STATUS_OK)) { + if (!async_post_ntstatus(result, ev, NT_STATUS_OK)) { goto failed; } return result; @@ -367,7 +367,7 @@ static void cli_pull_read_done(struct async_req *read_req) status = cli_read_andx_recv(read_req, &read_state->data.read.received, &read_state->data.read.rcvbuf); if (!NT_STATUS_IS_OK(status)) { - async_req_error(state->req, status); + async_req_nterror(state->req, status); return; } @@ -404,7 +404,7 @@ static void cli_pull_read_done(struct async_req *read_req) top_read->data.read.received, state->priv); if (!NT_STATUS_IS_OK(status)) { - async_req_error(state->req, status); + async_req_nterror(state->req, status); return; } state->pushed += top_read->data.read.received; @@ -432,7 +432,7 @@ static void cli_pull_read_done(struct async_req *read_req) state->start_offset + state->requested, request_thistime); - if (async_req_nomem(new_req, state->req)) { + if (async_req_ntnomem(new_req, state->req)) { return; } @@ -455,7 +455,7 @@ NTSTATUS cli_pull_recv(struct async_req *req, SMB_OFF_T *received) req->private_data, struct cli_pull_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } *received = state->pushed; @@ -792,7 +792,7 @@ NTSTATUS cli_write_andx_recv(struct async_req *req, size_t *pwritten) NTSTATUS status; size_t written; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } @@ -879,14 +879,14 @@ static void cli_writeall_written(struct async_req *subreq) status = cli_write_andx_recv(subreq, &written); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } state->written += written; if (state->written > state->size) { - async_req_error(req, NT_STATUS_INVALID_NETWORK_RESPONSE); + async_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE); return; } @@ -902,7 +902,7 @@ static void cli_writeall_written(struct async_req *subreq) state->buf + state->written, state->offset + state->written, to_write); if (subreq == NULL) { - async_req_error(req, NT_STATUS_NO_MEMORY); + async_req_nterror(req, NT_STATUS_NO_MEMORY); return; } @@ -912,7 +912,7 @@ static void cli_writeall_written(struct async_req *subreq) static NTSTATUS cli_writeall_recv(struct async_req *req) { - return async_req_simple_recv(req); + return async_req_simple_recv_ntstatus(req); } struct cli_push_state { @@ -1018,7 +1018,7 @@ struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev, } if (i == 0) { - if (!async_post_status(result, ev, NT_STATUS_OK)) { + if (!async_post_ntstatus(result, ev, NT_STATUS_OK)) { goto failed; } return result; @@ -1047,7 +1047,7 @@ static void cli_push_written(struct async_req *req) } if (i == state->num_reqs) { - async_req_error(state->req, NT_STATUS_INTERNAL_ERROR); + async_req_nterror(state->req, NT_STATUS_INTERNAL_ERROR); return; } @@ -1055,7 +1055,7 @@ static void cli_push_written(struct async_req *req) TALLOC_FREE(state->reqs[i]); req = NULL; if (!NT_STATUS_IS_OK(status)) { - async_req_error(state->req, status); + async_req_nterror(state->req, status); return; } @@ -1081,7 +1081,7 @@ static void cli_push_written(struct async_req *req) state->reqs, state->ev, state->cli, state->fnum, state->mode, buf, state->start_offset + state->sent, to_write); if (state->reqs[i] == NULL) { - async_req_error(state->req, NT_STATUS_NO_MEMORY); + async_req_nterror(state->req, NT_STATUS_NO_MEMORY); return; } @@ -1094,7 +1094,7 @@ static void cli_push_written(struct async_req *req) NTSTATUS cli_push_recv(struct async_req *req) { - return async_req_simple_recv(req); + return async_req_simple_recv_ntstatus(req); } NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode, diff --git a/source3/libsmb/clitrans.c b/source3/libsmb/clitrans.c index 4a0fc5f6e9..69e2be3af7 100644 --- a/source3/libsmb/clitrans.c +++ b/source3/libsmb/clitrans.c @@ -962,7 +962,7 @@ static void cli_trans_ship_rest(struct async_req *req, { state->secondary_request_ctx = talloc_new(state); if (state->secondary_request_ctx == NULL) { - async_req_error(req, NT_STATUS_NO_MEMORY); + async_req_nterror(req, NT_STATUS_NO_MEMORY); return; } @@ -972,7 +972,7 @@ static void cli_trans_ship_rest(struct async_req *req, cli_req = cli_ship_trans(state->secondary_request_ctx, state); if (cli_req == NULL) { - async_req_error(req, NT_STATUS_NO_MEMORY); + async_req_nterror(req, NT_STATUS_NO_MEMORY); return; } } @@ -1133,7 +1133,7 @@ static void cli_trans_recv_helper(struct async_req *req) */ if (NT_STATUS_IS_ERR(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -1154,7 +1154,7 @@ static void cli_trans_recv_helper(struct async_req *req) state->rsetup = (uint16_t *)TALLOC_MEMDUP( state, setup, sizeof(uint16_t) * num_setup); if (state->rsetup == NULL) { - async_req_error(req, NT_STATUS_NO_MEMORY); + async_req_nterror(req, NT_STATUS_NO_MEMORY); return; } } @@ -1165,7 +1165,7 @@ static void cli_trans_recv_helper(struct async_req *req) if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("Pulling params failed: %s\n", nt_errstr(status))); - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -1175,7 +1175,7 @@ static void cli_trans_recv_helper(struct async_req *req) if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("Pulling data failed: %s\n", nt_errstr(status))); - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -1318,7 +1318,7 @@ NTSTATUS cli_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx, cli_req->recv_helper.priv, struct cli_trans_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index 0aaec05f67..b9fd322485 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -255,7 +255,7 @@ static void rpc_read_done(struct async_req *subreq) status = state->transport->read_recv(subreq, &received); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -269,7 +269,7 @@ static void rpc_read_done(struct async_req *subreq) state->data + state->num_read, state->size - state->num_read, state->transport->priv); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } subreq->async.fn = rpc_read_done; @@ -278,7 +278,7 @@ static void rpc_read_done(struct async_req *subreq) static NTSTATUS rpc_read_recv(struct async_req *req) { - return async_req_simple_recv(req); + return async_req_simple_recv_ntstatus(req); } struct rpc_write_state { @@ -335,7 +335,7 @@ static void rpc_write_done(struct async_req *subreq) status = state->transport->write_recv(subreq, &written); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -350,7 +350,7 @@ static void rpc_write_done(struct async_req *subreq) state->data + state->num_written, state->size - state->num_written, state->transport->priv); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } subreq->async.fn = rpc_write_done; @@ -359,7 +359,7 @@ static void rpc_write_done(struct async_req *subreq) static NTSTATUS rpc_write_recv(struct async_req *req) { - return async_req_simple_recv(req); + return async_req_simple_recv_ntstatus(req); } @@ -470,7 +470,7 @@ static struct async_req *get_complete_frag_send(TALLOC_CTX *mem_ctx, status = NT_STATUS_OK; post_status: - if (async_post_status(result, ev, status)) { + if (async_post_ntstatus(result, ev, status)) { return result; } TALLOC_FREE(result); @@ -488,18 +488,18 @@ static void get_complete_frag_got_header(struct async_req *subreq) status = rpc_read_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } status = parse_rpc_header(state->cli, state->prhdr, state->pdu); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } if (!rpc_grow_buffer(state->pdu, state->prhdr->frag_len)) { - async_req_error(req, NT_STATUS_NO_MEMORY); + async_req_nterror(req, NT_STATUS_NO_MEMORY); return; } @@ -512,7 +512,7 @@ static void get_complete_frag_got_header(struct async_req *subreq) state, state->ev, state->cli->transport, (uint8_t *)(prs_data_p(state->pdu) + RPC_HEADER_LEN), state->prhdr->frag_len - RPC_HEADER_LEN); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } subreq->async.fn = get_complete_frag_got_rest; @@ -528,7 +528,7 @@ static void get_complete_frag_got_rest(struct async_req *subreq) status = rpc_read_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -536,7 +536,7 @@ static void get_complete_frag_got_rest(struct async_req *subreq) static NTSTATUS get_complete_frag_recv(struct async_req *req) { - return async_req_simple_recv(req); + return async_req_simple_recv_ntstatus(req); } /**************************************************************************** @@ -1096,7 +1096,7 @@ static struct async_req *cli_api_pipe_send(TALLOC_CTX *mem_ctx, status = NT_STATUS_INVALID_PARAMETER; post_status: - if (async_post_status(result, ev, status)) { + if (async_post_ntstatus(result, ev, status)) { return result; } fail: @@ -1116,7 +1116,7 @@ static void cli_api_pipe_trans_done(struct async_req *subreq) &state->rdata_len); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -1133,12 +1133,12 @@ static void cli_api_pipe_write_done(struct async_req *subreq) status = rpc_write_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } state->rdata = TALLOC_ARRAY(state, uint8_t, RPC_HEADER_LEN); - if (async_req_nomem(state->rdata, req)) { + if (async_req_ntnomem(state->rdata, req)) { return; } @@ -1150,7 +1150,7 @@ static void cli_api_pipe_write_done(struct async_req *subreq) subreq = state->transport->read_send(state, state->ev, state->rdata, RPC_HEADER_LEN, state->transport->priv); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } subreq->async.fn = cli_api_pipe_read_done; @@ -1169,7 +1169,7 @@ static void cli_api_pipe_read_done(struct async_req *subreq) status = state->transport->read_recv(subreq, &received); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } state->rdata_len = received; @@ -1183,7 +1183,7 @@ static NTSTATUS cli_api_pipe_recv(struct async_req *req, TALLOC_CTX *mem_ctx, req->private_data, struct cli_api_pipe_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } @@ -1296,7 +1296,7 @@ static struct async_req *rpc_api_pipe_send(TALLOC_CTX *mem_ctx, return result; post_status: - if (async_post_status(result, ev, status)) { + if (async_post_ntstatus(result, ev, status)) { return result; } TALLOC_FREE(result); @@ -1318,7 +1318,7 @@ static void rpc_api_pipe_trans_done(struct async_req *subreq) TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { DEBUG(5, ("cli_api_pipe failed: %s\n", nt_errstr(status))); - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -1336,7 +1336,7 @@ static void rpc_api_pipe_trans_done(struct async_req *subreq) */ rdata_copy = (char *)memdup(rdata, rdata_len); TALLOC_FREE(rdata); - if (async_req_nomem(rdata_copy, req)) { + if (async_req_ntnomem(rdata_copy, req)) { return; } prs_give_memory(&state->incoming_frag, rdata_copy, rdata_len, true); @@ -1344,7 +1344,7 @@ static void rpc_api_pipe_trans_done(struct async_req *subreq) /* Ensure we have enough data for a pdu. */ subreq = get_complete_frag_send(state, state->ev, state->cli, &state->rhdr, &state->incoming_frag); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } subreq->async.fn = rpc_api_pipe_got_pdu; @@ -1366,7 +1366,7 @@ static void rpc_api_pipe_got_pdu(struct async_req *subreq) if (!NT_STATUS_IS_OK(status)) { DEBUG(5, ("get_complete_frag failed: %s\n", nt_errstr(status))); - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -1381,7 +1381,7 @@ static void rpc_api_pipe_got_pdu(struct async_req *subreq) nt_errstr(status))); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -1405,13 +1405,13 @@ static void rpc_api_pipe_got_pdu(struct async_req *subreq) "%s\n", state->incoming_pdu.bigendian_data?"big":"little", state->incoming_frag.bigendian_data?"big":"little")); - async_req_error(req, NT_STATUS_INVALID_PARAMETER); + async_req_nterror(req, NT_STATUS_INVALID_PARAMETER); return; } /* Now copy the data portion out of the pdu into rbuf. */ if (!prs_force_grow(&state->incoming_pdu, rdata_len)) { - async_req_error(req, NT_STATUS_NO_MEMORY); + async_req_nterror(req, NT_STATUS_NO_MEMORY); return; } @@ -1422,7 +1422,7 @@ static void rpc_api_pipe_got_pdu(struct async_req *subreq) status = cli_pipe_reset_current_pdu(state->cli, &state->rhdr, &state->incoming_frag); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -1436,7 +1436,7 @@ static void rpc_api_pipe_got_pdu(struct async_req *subreq) subreq = get_complete_frag_send(state, state->ev, state->cli, &state->rhdr, &state->incoming_frag); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } subreq->async.fn = rpc_api_pipe_got_pdu; @@ -1450,7 +1450,7 @@ static NTSTATUS rpc_api_pipe_recv(struct async_req *req, TALLOC_CTX *mem_ctx, req->private_data, struct rpc_api_pipe_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } @@ -2117,7 +2117,7 @@ struct async_req *rpc_api_pipe_req_send(TALLOC_CTX *mem_ctx, return result; post_status: - if (async_post_status(result, ev, status)) { + if (async_post_ntstatus(result, ev, status)) { return result; } TALLOC_FREE(result); @@ -2221,13 +2221,13 @@ static void rpc_api_pipe_req_write_done(struct async_req *subreq) status = rpc_write_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } status = prepare_next_frag(state, &is_last_frag); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -2235,7 +2235,7 @@ static void rpc_api_pipe_req_write_done(struct async_req *subreq) subreq = rpc_api_pipe_send(state, state->ev, state->cli, &state->outgoing_frag, RPC_RESPONSE); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } subreq->async.fn = rpc_api_pipe_req_done; @@ -2246,7 +2246,7 @@ static void rpc_api_pipe_req_write_done(struct async_req *subreq) state->cli->transport, (uint8_t *)prs_data_p(&state->outgoing_frag), prs_offset(&state->outgoing_frag)); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } subreq->async.fn = rpc_api_pipe_req_write_done; @@ -2265,7 +2265,7 @@ static void rpc_api_pipe_req_done(struct async_req *subreq) status = rpc_api_pipe_recv(subreq, state, &state->reply_pdu); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -2278,7 +2278,7 @@ NTSTATUS rpc_api_pipe_req_recv(struct async_req *req, TALLOC_CTX *mem_ctx, req->private_data, struct rpc_api_pipe_req_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { /* * We always have to initialize to reply pdu, even if there is * none. The rpccli_* caller routines expect this. @@ -2585,7 +2585,7 @@ struct async_req *rpc_pipe_bind_send(TALLOC_CTX *mem_ctx, return result; post_status: - if (async_post_status(result, ev, status)) { + if (async_post_ntstatus(result, ev, status)) { return result; } TALLOC_FREE(result); @@ -2609,7 +2609,7 @@ static void rpc_pipe_bind_step_one_done(struct async_req *subreq) DEBUG(3, ("rpc_pipe_bind: %s bind request returned %s\n", rpccli_pipe_txt(debug_ctx(), state->cli), nt_errstr(status))); - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -2617,7 +2617,7 @@ static void rpc_pipe_bind_step_one_done(struct async_req *subreq) if (!smb_io_rpc_hdr("hdr", &hdr, &reply_pdu, 0)) { DEBUG(0, ("rpc_pipe_bind: failed to unmarshall RPC_HDR.\n")); prs_mem_free(&reply_pdu); - async_req_error(req, NT_STATUS_BUFFER_TOO_SMALL); + async_req_nterror(req, NT_STATUS_BUFFER_TOO_SMALL); return; } @@ -2625,14 +2625,14 @@ static void rpc_pipe_bind_step_one_done(struct async_req *subreq) DEBUG(0, ("rpc_pipe_bind: Failed to unmarshall " "RPC_HDR_BA.\n")); prs_mem_free(&reply_pdu); - async_req_error(req, NT_STATUS_BUFFER_TOO_SMALL); + async_req_nterror(req, NT_STATUS_BUFFER_TOO_SMALL); return; } if (!check_bind_response(&hdr_ba, &state->cli->transfer_syntax)) { DEBUG(2, ("rpc_pipe_bind: check_bind_response failed.\n")); prs_mem_free(&reply_pdu); - async_req_error(req, NT_STATUS_BUFFER_TOO_SMALL); + async_req_nterror(req, NT_STATUS_BUFFER_TOO_SMALL); return; } @@ -2658,7 +2658,7 @@ static void rpc_pipe_bind_step_one_done(struct async_req *subreq) &reply_pdu); prs_mem_free(&reply_pdu); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); } break; @@ -2668,7 +2668,7 @@ static void rpc_pipe_bind_step_one_done(struct async_req *subreq) &reply_pdu); prs_mem_free(&reply_pdu); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); } break; @@ -2679,7 +2679,7 @@ static void rpc_pipe_bind_step_one_done(struct async_req *subreq) DEBUG(0,("cli_finish_bind_auth: unknown auth type %u\n", (unsigned int)state->cli->auth->auth_type)); prs_mem_free(&reply_pdu); - async_req_error(req, NT_STATUS_INTERNAL_ERROR); + async_req_nterror(req, NT_STATUS_INTERNAL_ERROR); } } @@ -2756,7 +2756,7 @@ static void rpc_bind_auth3_write_done(struct async_req *subreq) status = rpc_write_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -2871,7 +2871,7 @@ static void rpc_bind_ntlmssp_api_done(struct async_req *subreq) status = rpc_api_pipe_recv(subreq, talloc_tos(), &reply_pdu); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -2879,19 +2879,19 @@ static void rpc_bind_ntlmssp_api_done(struct async_req *subreq) if (!smb_io_rpc_hdr("rpc_hdr ", &hdr, &reply_pdu, 0)) { DEBUG(0, ("rpc_finish_spnego_ntlmssp_bind: Failed to " "unmarshall RPC_HDR.\n")); - async_req_error(req, NT_STATUS_BUFFER_TOO_SMALL); + async_req_nterror(req, NT_STATUS_BUFFER_TOO_SMALL); return; } if (!prs_set_offset( &reply_pdu, hdr.frag_len - hdr.auth_len - RPC_HDR_AUTH_LEN)) { - async_req_error(req, NT_STATUS_INVALID_PARAMETER); + async_req_nterror(req, NT_STATUS_INVALID_PARAMETER); return; } if (!smb_io_rpc_hdr_auth("hdr_auth", &hdr_auth, &reply_pdu, 0)) { - async_req_error(req, NT_STATUS_INVALID_PARAMETER); + async_req_nterror(req, NT_STATUS_INVALID_PARAMETER); return; } @@ -2904,7 +2904,7 @@ static void rpc_bind_ntlmssp_api_done(struct async_req *subreq) OID_NTLMSSP, &tmp_blob)) { data_blob_free(&server_spnego_response); data_blob_free(&tmp_blob); - async_req_error(req, NT_STATUS_INVALID_PARAMETER); + async_req_nterror(req, NT_STATUS_INVALID_PARAMETER); return; } @@ -2918,7 +2918,7 @@ static void rpc_bind_ntlmssp_api_done(struct async_req *subreq) NTSTATUS rpc_pipe_bind_recv(struct async_req *req) { - return async_req_simple_recv(req); + return async_req_simple_recv_ntstatus(req); } NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli, diff --git a/source3/rpc_client/rpc_transport_np.c b/source3/rpc_client/rpc_transport_np.c index a11e0e0f22..80ff384046 100644 --- a/source3/rpc_client/rpc_transport_np.c +++ b/source3/rpc_client/rpc_transport_np.c @@ -93,7 +93,7 @@ static void rpc_np_write_done(struct async_req *subreq) status = cli_write_andx_recv(subreq, &state->written); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -105,7 +105,7 @@ static NTSTATUS rpc_np_write_recv(struct async_req *req, ssize_t *pwritten) req->private_data, struct rpc_np_write_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } *pwritten = state->written; @@ -169,13 +169,13 @@ static void rpc_np_read_done(struct async_req *subreq) } if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(subreq); - async_req_error(req, status); + async_req_nterror(req, status); return; } if (state->received > state->size) { TALLOC_FREE(subreq); - async_req_error(req, NT_STATUS_INVALID_NETWORK_RESPONSE); + async_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE); return; } @@ -189,7 +189,7 @@ static NTSTATUS rpc_np_read_recv(struct async_req *req, ssize_t *preceived) req->private_data, struct rpc_np_read_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } *preceived = state->received; @@ -251,7 +251,7 @@ static void rpc_np_trans_done(struct async_req *subreq) &state->rdata, &state->rdata_len); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -264,7 +264,7 @@ static NTSTATUS rpc_np_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx, req->private_data, struct rpc_np_trans_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } *prdata = talloc_move(mem_ctx, &state->rdata); @@ -334,7 +334,7 @@ static void rpc_transport_np_init_pipe_open(struct async_req *subreq) status = cli_ntcreate_recv(subreq, &state->transport_np->fnum); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } @@ -351,7 +351,7 @@ NTSTATUS rpc_transport_np_init_recv(struct async_req *req, req->private_data, struct rpc_transport_np_init_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } diff --git a/source3/rpc_client/rpc_transport_smbd.c b/source3/rpc_client/rpc_transport_smbd.c index 0ff4ebd468..b93e4cf602 100644 --- a/source3/rpc_client/rpc_transport_smbd.c +++ b/source3/rpc_client/rpc_transport_smbd.c @@ -169,12 +169,12 @@ static void get_anon_ipc_negprot_done(struct async_req *subreq) status = cli_negprot_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } subreq = cli_session_setup_guest_send(state, state->ev, state->cli); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } subreq->async.fn = get_anon_ipc_sesssetup_done; @@ -192,13 +192,13 @@ static void get_anon_ipc_sesssetup_done(struct async_req *subreq) status = cli_session_setup_guest_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } subreq = cli_tcon_andx_send(state, state->ev, state->cli, "IPC$", "IPC", NULL, 0); - if (async_req_nomem(subreq, req)) { + if (async_req_ntnomem(subreq, req)) { return; } subreq->async.fn = get_anon_ipc_tcon_done; @@ -214,7 +214,7 @@ static void get_anon_ipc_tcon_done(struct async_req *subreq) status = cli_tcon_andx_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -222,7 +222,7 @@ static void get_anon_ipc_tcon_done(struct async_req *subreq) static NTSTATUS get_anon_ipc_recv(struct async_req *req) { - return async_req_simple_recv(req); + return async_req_simple_recv_ntstatus(req); } struct rpc_cli_smbd_conn_init_state { @@ -356,7 +356,7 @@ struct async_req *rpc_cli_smbd_conn_init_send(TALLOC_CTX *mem_ctx, if (stdout_pipe[1] != -1) { close(stdout_pipe[1]); } - if (async_post_status(result, ev, status)) { + if (async_post_ntstatus(result, ev, status)) { return result; } TALLOC_FREE(result); @@ -372,7 +372,7 @@ static void rpc_cli_smbd_conn_init_done(struct async_req *subreq) status = get_anon_ipc_recv(subreq); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -386,7 +386,7 @@ NTSTATUS rpc_cli_smbd_conn_init_recv(struct async_req *req, req->private_data, struct rpc_cli_smbd_conn_init_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } *pconn = talloc_move(mem_ctx, &state->conn); @@ -481,7 +481,7 @@ static void rpc_smbd_write_done(struct async_req *subreq) status = state->sub_transp->write_recv(subreq, &state->written); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -493,7 +493,7 @@ static NTSTATUS rpc_smbd_write_recv(struct async_req *req, ssize_t *pwritten) req->private_data, struct rpc_smbd_write_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } *pwritten = state->written; @@ -554,7 +554,7 @@ static void rpc_smbd_read_done(struct async_req *subreq) status = state->sub_transp->read_recv(subreq, &state->received); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -566,7 +566,7 @@ static NTSTATUS rpc_smbd_read_recv(struct async_req *req, ssize_t *preceived) req->private_data, struct rpc_smbd_read_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } *preceived = state->received; @@ -632,7 +632,7 @@ static void rpc_transport_smbd_init_done(struct async_req *subreq) &state->transport_smbd->sub_transp); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -646,7 +646,7 @@ NTSTATUS rpc_transport_smbd_init_recv(struct async_req *req, req->private_data, struct rpc_transport_smbd_init_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 49049f8d55..fa38176749 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1183,7 +1183,7 @@ struct async_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev, status = NT_STATUS_INVALID_HANDLE; post_status: - if (async_post_status(result, ev, status)) { + if (async_post_ntstatus(result, ev, status)) { return result; } fail: @@ -1199,7 +1199,7 @@ static void np_write_done(struct async_req *subreq) status = sendall_recv(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -1211,7 +1211,7 @@ NTSTATUS np_write_recv(struct async_req *req, ssize_t *pnwritten) req->private_data, struct np_write_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } *pnwritten = state->nwritten; @@ -1267,7 +1267,7 @@ struct async_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev, status = NT_STATUS_INVALID_HANDLE; post_status: - if (async_post_status(result, ev, status)) { + if (async_post_ntstatus(result, ev, status)) { return result; } fail: @@ -1283,7 +1283,7 @@ static void np_read_done(struct async_req *subreq) status = recvall_recv(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_error(req, status); + async_req_nterror(req, status); return; } async_req_done(req); @@ -1296,7 +1296,7 @@ NTSTATUS np_read_recv(struct async_req *req, ssize_t *nread, req->private_data, struct np_read_state); NTSTATUS status; - if (async_req_is_error(req, &status)) { + if (async_req_is_nterror(req, &status)) { return status; } *nread = state->nread; -- cgit From 10c907bcdb5856feb15bd6b096254ea5d112a8c9 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 1 Feb 2009 13:06:13 -0500 Subject: Fix headers, only ldb.h is required --- lib/util/util_ldb.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/util/util_ldb.c b/lib/util/util_ldb.c index 70b18478c6..c11b6879d2 100644 --- a/lib/util/util_ldb.c +++ b/lib/util/util_ldb.c @@ -21,9 +21,7 @@ */ #include "includes.h" -#include "lib/events/events.h" #include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" #include "../lib/util/util_ldb.h" /* search the sam for the specified attributes - va_list variant -- cgit From 1dc745ec895181af84998c1451ebffc7d3ba2081 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 1 Feb 2009 13:06:38 -0500 Subject: Make schannel not depend on samdb anymore. --- source4/auth/gensec/config.mk | 2 +- source4/auth/gensec/schannel_state.c | 65 +++++++++++++++++++++++++++++++++--- 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/source4/auth/gensec/config.mk b/source4/auth/gensec/config.mk index 3c2fa51f78..3d13ce7f6d 100644 --- a/source4/auth/gensec/config.mk +++ b/source4/auth/gensec/config.mk @@ -78,7 +78,7 @@ $(eval $(call proto_header_template,$(gensecsrcdir)/schannel_proto.h,$(gensec_sc ################################################ # Start SUBSYSTEM SCHANNELDB [SUBSYSTEM::SCHANNELDB] -PRIVATE_DEPENDENCIES = LDB_WRAP SAMDB +PRIVATE_DEPENDENCIES = LDB_WRAP # End SUBSYSTEM SCHANNELDB ################################################ diff --git a/source4/auth/gensec/schannel_state.c b/source4/auth/gensec/schannel_state.c index d86b1f2b9c..ca8537cac9 100644 --- a/source4/auth/gensec/schannel_state.c +++ b/source4/auth/gensec/schannel_state.c @@ -20,10 +20,8 @@ */ #include "includes.h" -#include "lib/events/events.h" #include "lib/ldb/include/ldb.h" -#include "lib/ldb/include/ldb_errors.h" -#include "dsdb/samdb/samdb.h" +#include "librpc/gen_ndr/ndr_security.h" #include "ldb_wrap.h" #include "../lib/util/util_ldb.h" #include "libcli/auth/libcli_auth.h" @@ -31,6 +29,45 @@ #include "param/param.h" #include "auth/gensec/schannel_state.h" +static struct ldb_val *schannel_dom_sid_ldb_val(TALLOC_CTX *mem_ctx, + struct smb_iconv_convenience *smbiconv, + struct dom_sid *sid) +{ + enum ndr_err_code ndr_err; + struct ldb_val *v; + + v = talloc(mem_ctx, struct ldb_val); + if (!v) return NULL; + + ndr_err = ndr_push_struct_blob(v, mem_ctx, smbiconv, sid, + (ndr_push_flags_fn_t)ndr_push_dom_sid); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(v); + return NULL; + } + + return v; +} + +static struct dom_sid *schannel_ldb_val_dom_sid(TALLOC_CTX *mem_ctx, + const struct ldb_val *v) +{ + enum ndr_err_code ndr_err; + struct dom_sid *sid; + + sid = talloc(mem_ctx, struct dom_sid); + if (!sid) return NULL; + + ndr_err = ndr_pull_struct_blob(v, sid, NULL, sid, + (ndr_pull_flags_fn_t)ndr_pull_dom_sid); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(sid); + return NULL; + } + return sid; +} + + /** connect to the schannel ldb */ @@ -77,6 +114,8 @@ NTSTATUS schannel_store_session_key_ldb(TALLOC_CTX *mem_ctx, { struct ldb_message *msg; struct ldb_val val, seed, client_state, server_state; + struct smb_iconv_convenience *smbiconv; + struct ldb_val *sid_val; char *f; char *sct; int ret; @@ -103,6 +142,12 @@ NTSTATUS schannel_store_session_key_ldb(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } + smbiconv = lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")); + sid_val = schannel_dom_sid_ldb_val(msg, smbiconv, creds->sid); + if (sid_val == NULL) { + return NT_STATUS_NO_MEMORY; + } + val.data = creds->session_key; val.length = sizeof(creds->session_key); @@ -124,7 +169,7 @@ NTSTATUS schannel_store_session_key_ldb(TALLOC_CTX *mem_ctx, ldb_msg_add_string(msg, "accountName", creds->account_name); ldb_msg_add_string(msg, "computerName", creds->computer_name); ldb_msg_add_string(msg, "flatname", creds->domain); - samdb_msg_add_dom_sid(ldb, mem_ctx, msg, "objectSid", creds->sid); + ldb_msg_add_value(msg, "objectSid", sid_val, NULL); ldb_delete(ldb, msg->dn); @@ -265,7 +310,17 @@ NTSTATUS schannel_fetch_session_key_ldb(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } - (*creds)->sid = samdb_result_dom_sid(*creds, res->msgs[0], "objectSid"); + val = ldb_msg_find_ldb_val(res->msgs[0], "objectSid"); + if (val == NULL) { + DEBUG(1,("schannel: missing ObjectSid for client: %s\n", computer_name)); + talloc_free(res); + return NT_STATUS_INTERNAL_ERROR; + } + (*creds)->sid = schannel_ldb_val_dom_sid(*creds, val); + if ((*creds)->sid == NULL) { + talloc_free(res); + return NT_STATUS_INTERNAL_ERROR; + } talloc_free(res); return NT_STATUS_OK; -- cgit From 07aa05f678defb69d0d4c6fc9c65750ecaa85bf6 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Sun, 1 Feb 2009 16:08:45 +0100 Subject: shared: Move dom_sid_* utility functions to top level --- libcli/security/config.mk | 5 + libcli/security/dom_sid.c | 312 +++++++++++++++++++++++++++++++++++++ libcli/security/dom_sid.h | 42 +++++ source3/Makefile.in | 4 +- source3/samba4.mk | 1 + source4/Makefile | 1 + source4/libcli/security/config.mk | 4 +- source4/libcli/security/dom_sid.c | 306 ------------------------------------ source4/libcli/security/security.h | 3 + source4/main.mk | 1 + source4/torture/rpc/samba3rpc.c | 2 +- source4/winbind/idmap.c | 2 +- source4/winbind/wb_cmd_getpwnam.c | 2 +- source4/winbind/wb_sid2gid.c | 2 +- source4/winbind/wb_sid2uid.c | 2 +- 15 files changed, 374 insertions(+), 315 deletions(-) create mode 100644 libcli/security/config.mk create mode 100644 libcli/security/dom_sid.c create mode 100644 libcli/security/dom_sid.h delete mode 100644 source4/libcli/security/dom_sid.c diff --git a/libcli/security/config.mk b/libcli/security/config.mk new file mode 100644 index 0000000000..56d8e138ff --- /dev/null +++ b/libcli/security/config.mk @@ -0,0 +1,5 @@ +[SUBSYSTEM::LIBSECURITY_COMMON] +PRIVATE_DEPENDENCIES = TALLOC + +LIBSECURITY_COMMON_OBJ_FILES = $(addprefix $(libclicommonsrcdir)/security/, \ + dom_sid.o) diff --git a/libcli/security/dom_sid.c b/libcli/security/dom_sid.c new file mode 100644 index 0000000000..f41ea677fc --- /dev/null +++ b/libcli/security/dom_sid.c @@ -0,0 +1,312 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + + Copyright (C) Stefan (metze) Metzmacher 2002-2004 + Copyright (C) Andrew Tridgell 1992-2004 + Copyright (C) Jeremy Allison 1999 + + 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 . +*/ + +#include "includes.h" +#include "librpc/gen_ndr/security.h" +#include "libcli/security/security.h" + +/***************************************************************** + Compare the auth portion of two sids. +*****************************************************************/ + +static int dom_sid_compare_auth(const struct dom_sid *sid1, + const struct dom_sid *sid2) +{ + int i; + + if (sid1 == sid2) + return 0; + if (!sid1) + return -1; + if (!sid2) + return 1; + + if (sid1->sid_rev_num != sid2->sid_rev_num) + return sid1->sid_rev_num - sid2->sid_rev_num; + + for (i = 0; i < 6; i++) + if (sid1->id_auth[i] != sid2->id_auth[i]) + return sid1->id_auth[i] - sid2->id_auth[i]; + + return 0; +} + +/***************************************************************** + Compare two sids. +*****************************************************************/ + +int dom_sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid2) +{ + int i; + + if (sid1 == sid2) + return 0; + if (!sid1) + return -1; + if (!sid2) + return 1; + + /* Compare most likely different rids, first: i.e start at end */ + if (sid1->num_auths != sid2->num_auths) + return sid1->num_auths - sid2->num_auths; + + for (i = sid1->num_auths-1; i >= 0; --i) + if (sid1->sub_auths[i] != sid2->sub_auths[i]) + return sid1->sub_auths[i] - sid2->sub_auths[i]; + + return dom_sid_compare_auth(sid1, sid2); +} + +/***************************************************************** + Compare two sids. +*****************************************************************/ + +bool dom_sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2) +{ + return dom_sid_compare(sid1, sid2) == 0; +} + +/* Yes, I did think about multibyte issues here, and for all I can see there's + * none of those for parsing a SID. */ +#undef strncasecmp + +bool dom_sid_parse(const char *sidstr, struct dom_sid *ret) +{ + uint_t rev, ia, num_sub_auths, i; + char *p; + + if (strncasecmp(sidstr, "S-", 2)) { + return false; + } + + sidstr += 2; + + rev = strtol(sidstr, &p, 10); + if (*p != '-') { + return false; + } + sidstr = p+1; + + ia = strtol(sidstr, &p, 10); + if (p == sidstr) { + return false; + } + sidstr = p; + + num_sub_auths = 0; + for (i=0;sidstr[i];i++) { + if (sidstr[i] == '-') num_sub_auths++; + } + + ret->sid_rev_num = rev; + ret->id_auth[0] = 0; + ret->id_auth[1] = 0; + ret->id_auth[2] = ia >> 24; + ret->id_auth[3] = ia >> 16; + ret->id_auth[4] = ia >> 8; + ret->id_auth[5] = ia; + ret->num_auths = num_sub_auths; + + for (i=0;isub_auths[i] = strtoul(sidstr, &p, 10); + if (p == sidstr) { + return false; + } + sidstr = p; + } + + return true; +} + +/* + convert a string to a dom_sid, returning a talloc'd dom_sid +*/ +struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) +{ + struct dom_sid *ret; + ret = talloc(mem_ctx, struct dom_sid); + if (!ret) { + return NULL; + } + if (!dom_sid_parse(sidstr, ret)) { + talloc_free(ret); + return NULL; + } + + return ret; +} + +/* + convert a string to a dom_sid, returning a talloc'd dom_sid +*/ +struct dom_sid *dom_sid_parse_length(TALLOC_CTX *mem_ctx, const DATA_BLOB *sid) +{ + struct dom_sid *ret; + char *p = talloc_strndup(mem_ctx, (char *)sid->data, sid->length); + if (!p) { + return NULL; + } + ret = dom_sid_parse_talloc(mem_ctx, p); + talloc_free(p); + return ret; +} + +/* + copy a dom_sid structure +*/ +struct dom_sid *dom_sid_dup(TALLOC_CTX *mem_ctx, const struct dom_sid *dom_sid) +{ + struct dom_sid *ret; + int i; + + if (!dom_sid) { + return NULL; + } + + ret = talloc(mem_ctx, struct dom_sid); + if (!ret) { + return NULL; + } + + ret->sid_rev_num = dom_sid->sid_rev_num; + ret->id_auth[0] = dom_sid->id_auth[0]; + ret->id_auth[1] = dom_sid->id_auth[1]; + ret->id_auth[2] = dom_sid->id_auth[2]; + ret->id_auth[3] = dom_sid->id_auth[3]; + ret->id_auth[4] = dom_sid->id_auth[4]; + ret->id_auth[5] = dom_sid->id_auth[5]; + ret->num_auths = dom_sid->num_auths; + + for (i=0;inum_auths;i++) { + ret->sub_auths[i] = dom_sid->sub_auths[i]; + } + + return ret; +} + +/* + add a rid to a domain dom_sid to make a full dom_sid. This function + returns a new sid in the supplied memory context +*/ +struct dom_sid *dom_sid_add_rid(TALLOC_CTX *mem_ctx, + const struct dom_sid *domain_sid, + uint32_t rid) +{ + struct dom_sid *sid; + + sid = talloc(mem_ctx, struct dom_sid); + if (!sid) return NULL; + + *sid = *domain_sid; + + sid->sub_auths[sid->num_auths] = rid; + sid->num_auths++; + + return sid; +} + +/* + Split up a SID into its domain and RID part +*/ +NTSTATUS dom_sid_split_rid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid, + struct dom_sid **domain, uint32_t *rid) +{ + if (sid->num_auths == 0) { + return NT_STATUS_INVALID_PARAMETER; + } + + if (domain) { + if (!(*domain = dom_sid_dup(mem_ctx, sid))) { + return NT_STATUS_NO_MEMORY; + } + + (*domain)->num_auths -= 1; + } + + if (rid) { + *rid = sid->sub_auths[sid->num_auths - 1]; + } + + return NT_STATUS_OK; +} + +/* + return true if the 2nd sid is in the domain given by the first sid +*/ +bool dom_sid_in_domain(const struct dom_sid *domain_sid, + const struct dom_sid *sid) +{ + int i; + + if (!domain_sid || !sid) { + return false; + } + + if (domain_sid->num_auths > sid->num_auths) { + return false; + } + + for (i = domain_sid->num_auths-1; i >= 0; --i) { + if (domain_sid->sub_auths[i] != sid->sub_auths[i]) { + return false; + } + } + + return dom_sid_compare_auth(domain_sid, sid) == 0; +} + +/* + convert a dom_sid to a string +*/ +char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid) +{ + int i, ofs, maxlen; + uint32_t ia; + char *ret; + + if (!sid) { + return talloc_strdup(mem_ctx, "(NULL SID)"); + } + + maxlen = sid->num_auths * 11 + 25; + ret = talloc_array(mem_ctx, char, maxlen); + if (!ret) return talloc_strdup(mem_ctx, "(SID ERR)"); + + ia = (sid->id_auth[5]) + + (sid->id_auth[4] << 8 ) + + (sid->id_auth[3] << 16) + + (sid->id_auth[2] << 24); + + ofs = snprintf(ret, maxlen, "S-%u-%lu", + (unsigned int)sid->sid_rev_num, (unsigned long)ia); + + for (i = 0; i < sid->num_auths; i++) { + ofs += snprintf(ret + ofs, maxlen - ofs, "-%lu", + (unsigned long)sid->sub_auths[i]); + } + + return ret; +} diff --git a/libcli/security/dom_sid.h b/libcli/security/dom_sid.h new file mode 100644 index 0000000000..9d96392777 --- /dev/null +++ b/libcli/security/dom_sid.h @@ -0,0 +1,42 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + + Copyright (C) Stefan (metze) Metzmacher 2002-2004 + Copyright (C) Andrew Tridgell 1992-2004 + Copyright (C) Jeremy Allison 1999 + + 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 . +*/ + +#ifndef _DOM_SID_H_ +#define _DOM_SID_H_ + +int dom_sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid2); +bool dom_sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2); +bool dom_sid_parse(const char *sidstr, struct dom_sid *ret); +struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr); +struct dom_sid *dom_sid_parse_length(TALLOC_CTX *mem_ctx, const DATA_BLOB *sid); +struct dom_sid *dom_sid_dup(TALLOC_CTX *mem_ctx, const struct dom_sid *dom_sid); +struct dom_sid *dom_sid_add_rid(TALLOC_CTX *mem_ctx, + const struct dom_sid *domain_sid, + uint32_t rid); +NTSTATUS dom_sid_split_rid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid, + struct dom_sid **domain, uint32_t *rid); +bool dom_sid_in_domain(const struct dom_sid *domain_sid, + const struct dom_sid *sid); +char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid); + +#endif /*_DOM_SID_H_*/ + diff --git a/source3/Makefile.in b/source3/Makefile.in index fa57db7f3f..bc306229c8 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -279,7 +279,6 @@ LIBNDR_OBJ = ../librpc/ndr/ndr_basic.o \ ../librpc/gen_ndr/ndr_security.o \ ../librpc/ndr/ndr_sec_helper.o \ librpc/ndr/ndr_string.o \ - librpc/ndr/sid.o \ ../librpc/ndr/uuid.o \ librpc/ndr/util.o @@ -364,7 +363,8 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \ lib/ldap_escape.o @CHARSET_STATIC@ \ lib/secdesc.o lib/util_seaccess.o lib/secace.o lib/secacl.o \ libads/krb5_errs.o lib/system_smbd.o lib/audit.o $(LIBNDR_OBJ) \ - lib/file_id.o lib/idmap_cache.o + lib/file_id.o lib/idmap_cache.o \ + ../libcli/security/dom_sid.o LIB_DUMMY_OBJ = lib/dummysmbd.o lib/dummyroot.o LIB_NONSMBD_OBJ = $(LIB_OBJ) $(LIB_DUMMY_OBJ) diff --git a/source3/samba4.mk b/source3/samba4.mk index 715961e4de..b7df7a58da 100644 --- a/source3/samba4.mk +++ b/source3/samba4.mk @@ -111,6 +111,7 @@ ntptrsrcdir := $(samba4srcdir)/ntptr clientsrcdir := $(samba4srcdir)/client libclisrcdir := $(samba4srcdir)/libcli libclinbtsrcdir := $(samba4srcdir)/../libcli/nbt +libclicommonsrcdir := $(samba4srcdir)/../libcli pyscriptsrcdir := $(samba4srcdir)/scripting/python kdcsrcdir := $(samba4srcdir)/kdc smbreadlinesrcdir := $(samba4srcdir)/lib/smbreadline diff --git a/source4/Makefile b/source4/Makefile index b342d671f6..267e302c9f 100644 --- a/source4/Makefile +++ b/source4/Makefile @@ -98,6 +98,7 @@ ntvfssrcdir := ntvfs ntptrsrcdir := ntptr librpcsrcdir := librpc libclisrcdir := libcli +libclicommonsrcdir := ../libcli libclinbtsrcdir := ../libcli/nbt pyscriptsrcdir := $(srcdir)/scripting/python kdcsrcdir := kdc diff --git a/source4/libcli/security/config.mk b/source4/libcli/security/config.mk index 4b35841507..cd5b75bb81 100644 --- a/source4/libcli/security/config.mk +++ b/source4/libcli/security/config.mk @@ -1,8 +1,8 @@ [SUBSYSTEM::LIBSECURITY] -PUBLIC_DEPENDENCIES = LIBNDR +PUBLIC_DEPENDENCIES = LIBNDR LIBSECURITY_COMMON LIBSECURITY_OBJ_FILES = $(addprefix $(libclisrcdir)/security/, \ security_token.o security_descriptor.o \ - dom_sid.o access_check.o privilege.o sddl.o) + access_check.o privilege.o sddl.o) $(eval $(call proto_header_template,$(libclisrcdir)/security/proto.h,$(LIBSECURITY_OBJ_FILES:.o=.c))) diff --git a/source4/libcli/security/dom_sid.c b/source4/libcli/security/dom_sid.c deleted file mode 100644 index e1a6b8e8ee..0000000000 --- a/source4/libcli/security/dom_sid.c +++ /dev/null @@ -1,306 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Samba utility functions - - Copyright (C) Stefan (metze) Metzmacher 2002-2004 - Copyright (C) Andrew Tridgell 1992-2004 - Copyright (C) Jeremy Allison 1999 - - 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 . -*/ - -#include "includes.h" -#include "librpc/gen_ndr/security.h" -#include "libcli/security/security.h" - -/***************************************************************** - Compare the auth portion of two sids. -*****************************************************************/ - -static int dom_sid_compare_auth(const struct dom_sid *sid1, const struct dom_sid *sid2) -{ - int i; - - if (sid1 == sid2) - return 0; - if (!sid1) - return -1; - if (!sid2) - return 1; - - if (sid1->sid_rev_num != sid2->sid_rev_num) - return sid1->sid_rev_num - sid2->sid_rev_num; - - for (i = 0; i < 6; i++) - if (sid1->id_auth[i] != sid2->id_auth[i]) - return sid1->id_auth[i] - sid2->id_auth[i]; - - return 0; -} - -/***************************************************************** - Compare two sids. -*****************************************************************/ - -int dom_sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid2) -{ - int i; - - if (sid1 == sid2) - return 0; - if (!sid1) - return -1; - if (!sid2) - return 1; - - /* Compare most likely different rids, first: i.e start at end */ - if (sid1->num_auths != sid2->num_auths) - return sid1->num_auths - sid2->num_auths; - - for (i = sid1->num_auths-1; i >= 0; --i) - if (sid1->sub_auths[i] != sid2->sub_auths[i]) - return sid1->sub_auths[i] - sid2->sub_auths[i]; - - return dom_sid_compare_auth(sid1, sid2); -} - -/***************************************************************** - Compare two sids. -*****************************************************************/ - -bool dom_sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2) -{ - return dom_sid_compare(sid1, sid2) == 0; -} - -bool dom_sid_parse(const char *sidstr, struct dom_sid *ret) -{ - uint_t rev, ia, num_sub_auths, i; - char *p; - - if (strncasecmp(sidstr, "S-", 2)) { - return false; - } - - sidstr += 2; - - rev = strtol(sidstr, &p, 10); - if (*p != '-') { - return false; - } - sidstr = p+1; - - ia = strtol(sidstr, &p, 10); - if (p == sidstr) { - return false; - } - sidstr = p; - - num_sub_auths = 0; - for (i=0;sidstr[i];i++) { - if (sidstr[i] == '-') num_sub_auths++; - } - - ret->sid_rev_num = rev; - ret->id_auth[0] = 0; - ret->id_auth[1] = 0; - ret->id_auth[2] = ia >> 24; - ret->id_auth[3] = ia >> 16; - ret->id_auth[4] = ia >> 8; - ret->id_auth[5] = ia; - ret->num_auths = num_sub_auths; - - for (i=0;isub_auths[i] = strtoul(sidstr, &p, 10); - if (p == sidstr) { - return false; - } - sidstr = p; - } - - return true; -} - -/* - convert a string to a dom_sid, returning a talloc'd dom_sid -*/ -struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) -{ - struct dom_sid *ret; - ret = talloc(mem_ctx, struct dom_sid); - if (!ret) { - return NULL; - } - if (!dom_sid_parse(sidstr, ret)) { - talloc_free(ret); - return NULL; - } - - return ret; -} - -/* - convert a string to a dom_sid, returning a talloc'd dom_sid -*/ -struct dom_sid *dom_sid_parse_length(TALLOC_CTX *mem_ctx, const DATA_BLOB *sid) -{ - struct dom_sid *ret; - char *p = talloc_strndup(mem_ctx, (char *)sid->data, sid->length); - if (!p) { - return NULL; - } - ret = dom_sid_parse_talloc(mem_ctx, p); - talloc_free(p); - return ret; -} - -/* - copy a dom_sid structure -*/ -struct dom_sid *dom_sid_dup(TALLOC_CTX *mem_ctx, const struct dom_sid *dom_sid) -{ - struct dom_sid *ret; - int i; - - if (!dom_sid) { - return NULL; - } - - ret = talloc(mem_ctx, struct dom_sid); - if (!ret) { - return NULL; - } - - ret->sid_rev_num = dom_sid->sid_rev_num; - ret->id_auth[0] = dom_sid->id_auth[0]; - ret->id_auth[1] = dom_sid->id_auth[1]; - ret->id_auth[2] = dom_sid->id_auth[2]; - ret->id_auth[3] = dom_sid->id_auth[3]; - ret->id_auth[4] = dom_sid->id_auth[4]; - ret->id_auth[5] = dom_sid->id_auth[5]; - ret->num_auths = dom_sid->num_auths; - - for (i=0;inum_auths;i++) { - ret->sub_auths[i] = dom_sid->sub_auths[i]; - } - - return ret; -} - -/* - add a rid to a domain dom_sid to make a full dom_sid. This function - returns a new sid in the supplied memory context -*/ -struct dom_sid *dom_sid_add_rid(TALLOC_CTX *mem_ctx, - const struct dom_sid *domain_sid, - uint32_t rid) -{ - struct dom_sid *sid; - - sid = talloc(mem_ctx, struct dom_sid); - if (!sid) return NULL; - - *sid = *domain_sid; - - sid->sub_auths[sid->num_auths] = rid; - sid->num_auths++; - - return sid; -} - -/* - Split up a SID into its domain and RID part -*/ -NTSTATUS dom_sid_split_rid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid, - struct dom_sid **domain, uint32_t *rid) -{ - if (sid->num_auths == 0) { - return NT_STATUS_INVALID_PARAMETER; - } - - if (domain) { - if (!(*domain = dom_sid_dup(mem_ctx, sid))) { - return NT_STATUS_NO_MEMORY; - } - - (*domain)->num_auths -= 1; - } - - if (rid) { - *rid = sid->sub_auths[sid->num_auths - 1]; - } - - return NT_STATUS_OK; -} - -/* - return true if the 2nd sid is in the domain given by the first sid -*/ -bool dom_sid_in_domain(const struct dom_sid *domain_sid, - const struct dom_sid *sid) -{ - int i; - - if (!domain_sid || !sid) { - return false; - } - - if (domain_sid->num_auths > sid->num_auths) { - return false; - } - - for (i = domain_sid->num_auths-1; i >= 0; --i) { - if (domain_sid->sub_auths[i] != sid->sub_auths[i]) { - return false; - } - } - - return dom_sid_compare_auth(domain_sid, sid) == 0; -} - -/* - convert a dom_sid to a string -*/ -char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid) -{ - int i, ofs, maxlen; - uint32_t ia; - char *ret; - - if (!sid) { - return talloc_strdup(mem_ctx, "(NULL SID)"); - } - - maxlen = sid->num_auths * 11 + 25; - ret = talloc_array(mem_ctx, char, maxlen); - if (!ret) return talloc_strdup(mem_ctx, "(SID ERR)"); - - ia = (sid->id_auth[5]) + - (sid->id_auth[4] << 8 ) + - (sid->id_auth[3] << 16) + - (sid->id_auth[2] << 24); - - ofs = snprintf(ret, maxlen, "S-%u-%lu", - (unsigned int)sid->sid_rev_num, (unsigned long)ia); - - for (i = 0; i < sid->num_auths; i++) { - ofs += snprintf(ret + ofs, maxlen - ofs, "-%lu", (unsigned long)sid->sub_auths[i]); - } - - return ret; -} diff --git a/source4/libcli/security/security.h b/source4/libcli/security/security.h index 46ef6186b8..517f3e8ebe 100644 --- a/source4/libcli/security/security.h +++ b/source4/libcli/security/security.h @@ -28,4 +28,7 @@ enum security_user_level { struct auth_session_info; +/* Moved the dom_sid functions to the top level dir with manual proto header */ +#include "libcli/security/dom_sid.h" + #include "libcli/security/proto.h" diff --git a/source4/main.mk b/source4/main.mk index bfff04d13c..04f7a36a5f 100644 --- a/source4/main.mk +++ b/source4/main.mk @@ -49,3 +49,4 @@ mkinclude scripting/python/config.mk mkinclude kdc/config.mk mkinclude ../lib/smbconf/config.mk mkinclude ../lib/async_req/config.mk +mkinclude ../libcli/security/config.mk diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index 2207786f17..a1e52ba80e 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -49,7 +49,7 @@ #include "libcli/auth/libcli_auth.h" #include "../lib/crypto/crypto.h" #include "auth/ntlmssp/ntlmssp.h" -#include "libcli/security/proto.h" +#include "libcli/security/security.h" #include "param/param.h" #include "lib/registry/registry.h" #include "libcli/resolve/resolve.h" diff --git a/source4/winbind/idmap.c b/source4/winbind/idmap.c index f7be59136c..d0efbb159b 100644 --- a/source4/winbind/idmap.c +++ b/source4/winbind/idmap.c @@ -29,7 +29,7 @@ #include "lib/ldb_wrap.h" #include "param/param.h" #include "winbind/idmap.h" -#include "libcli/security/proto.h" +#include "libcli/security/security.h" #include "libcli/ldap/ldap_ndr.h" /** diff --git a/source4/winbind/wb_cmd_getpwnam.c b/source4/winbind/wb_cmd_getpwnam.c index 7d821537f0..be43684f82 100644 --- a/source4/winbind/wb_cmd_getpwnam.c +++ b/source4/winbind/wb_cmd_getpwnam.c @@ -27,7 +27,7 @@ #include "winbind/wb_helper.h" #include "smbd/service_task.h" #include "libnet/libnet_proto.h" -#include "libcli/security/proto.h" +#include "libcli/security/security.h" struct cmd_getpwnam_state { struct composite_context *ctx; diff --git a/source4/winbind/wb_sid2gid.c b/source4/winbind/wb_sid2gid.c index d68956ce85..282d10c9c9 100644 --- a/source4/winbind/wb_sid2gid.c +++ b/source4/winbind/wb_sid2gid.c @@ -24,7 +24,7 @@ #include "winbind/wb_server.h" #include "smbd/service_task.h" #include "winbind/wb_helper.h" -#include "libcli/security/proto.h" +#include "libcli/security/security.h" #include "winbind/idmap.h" struct sid2gid_state { diff --git a/source4/winbind/wb_sid2uid.c b/source4/winbind/wb_sid2uid.c index b65e41978c..151f39906b 100644 --- a/source4/winbind/wb_sid2uid.c +++ b/source4/winbind/wb_sid2uid.c @@ -24,7 +24,7 @@ #include "winbind/wb_server.h" #include "smbd/service_task.h" #include "winbind/wb_helper.h" -#include "libcli/security/proto.h" +#include "libcli/security/security.h" #include "winbind/idmap.h" struct sid2uid_state { -- cgit From d936be23cd9d04adc2dca27cfc7772b53383f298 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Sun, 1 Feb 2009 20:43:47 +0100 Subject: s3: Fix the non-merged build. --- libcli/security/dom_sid.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libcli/security/dom_sid.c b/libcli/security/dom_sid.c index f41ea677fc..db82020990 100644 --- a/libcli/security/dom_sid.c +++ b/libcli/security/dom_sid.c @@ -22,7 +22,6 @@ #include "includes.h" #include "librpc/gen_ndr/security.h" -#include "libcli/security/security.h" /***************************************************************** Compare the auth portion of two sids. -- cgit From 8c57f34b99b9bd587e1c2be0905a8c41eebbd568 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 2 Feb 2009 00:35:43 +0100 Subject: s3:winbind_user: move initialization of domain up in winbindd_fill_pwent() and streamline logic some Michael --- source3/winbindd/winbindd_user.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/source3/winbindd/winbindd_user.c b/source3/winbindd/winbindd_user.c index 5356e16a74..2e326430fc 100644 --- a/source3/winbindd/winbindd_user.c +++ b/source3/winbindd/winbindd_user.c @@ -80,6 +80,13 @@ static bool winbindd_fill_pwent(TALLOC_CTX *ctx, char *dom_name, char *user_name if (!pw || !dom_name || !user_name) return False; + domain = find_domain_from_name_noinit(dom_name); + if (domain == NULL) { + DEBUG(5,("winbindd_fill_pwent: Failed to find domain for %s. " + "Disabling name alias support\n", dom_name)); + nt_status = NT_STATUS_NO_SUCH_DOMAIN; + } + /* Resolve the uid number */ if (!NT_STATUS_IS_OK(idmap_sid_to_uid(dom_name, user_sid, @@ -98,19 +105,10 @@ static bool winbindd_fill_pwent(TALLOC_CTX *ctx, char *dom_name, char *user_name return False; } - strlower_m(user_name); - /* Username */ - domain = find_domain_from_name_noinit(dom_name); - if (domain) { - nt_status = normalize_name_map(ctx, domain, user_name, - &mapped_name); - } else { - DEBUG(5,("winbindd_fill_pwent: Failed to find domain for %s. " - "Disabling name alias support\n", dom_name)); - nt_status = NT_STATUS_NO_SUCH_DOMAIN; - } + strlower_m(user_name); + nt_status = normalize_name_map(ctx, domain, user_name, &mapped_name); /* Basic removal of whitespace */ if (NT_STATUS_IS_OK(nt_status)) { -- cgit From a0d05192006c4bade760bd945ab91b5268ca47a6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 2 Feb 2009 00:36:59 +0100 Subject: s3:winbind_user: fix "getent passwd" to allocate new uids. "getent passwd" used to fill the idmap cache with negative cache entries for unmapped user sids. Don't pass domain name unconditionally to idmap_sid_to_[ug]id(). idmap_sid_to_[ug]id() only creates new mappings (allocating idmap backends tdb, tdb2, ldap...) when the domain name passed in is "". Note that it is _wrong_ to directly call the idmap_sid_to_[ug]id() functions here, in the main winbindd. The correct fix would be to send a sid_to_[ug]id request to winbindd itself, but this needs more work to prepare the async mechanisms, and we nee a quick fix for getent passwd now. Michael --- source3/winbindd/winbindd_user.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source3/winbindd/winbindd_user.c b/source3/winbindd/winbindd_user.c index 2e326430fc..b01e1847f2 100644 --- a/source3/winbindd/winbindd_user.c +++ b/source3/winbindd/winbindd_user.c @@ -76,6 +76,7 @@ static bool winbindd_fill_pwent(TALLOC_CTX *ctx, char *dom_name, char *user_name char *mapped_name = NULL; struct winbindd_domain *domain = NULL; NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + char *dom_name_idmap = ""; if (!pw || !dom_name || !user_name) return False; @@ -87,9 +88,13 @@ static bool winbindd_fill_pwent(TALLOC_CTX *ctx, char *dom_name, char *user_name nt_status = NT_STATUS_NO_SUCH_DOMAIN; } + if (domain->have_idmap_config) { + dom_name_idmap = dom_name; + } + /* Resolve the uid number */ - if (!NT_STATUS_IS_OK(idmap_sid_to_uid(dom_name, user_sid, + if (!NT_STATUS_IS_OK(idmap_sid_to_uid(dom_name_idmap, user_sid, &pw->pw_uid))) { DEBUG(1, ("error getting user id for sid %s\n", sid_string_dbg(user_sid))); @@ -98,7 +103,7 @@ static bool winbindd_fill_pwent(TALLOC_CTX *ctx, char *dom_name, char *user_name /* Resolve the gid number */ - if (!NT_STATUS_IS_OK(idmap_sid_to_gid(dom_name, group_sid, + if (!NT_STATUS_IS_OK(idmap_sid_to_gid(dom_name_idmap, group_sid, &pw->pw_gid))) { DEBUG(1, ("error getting group id for sid %s\n", sid_string_dbg(group_sid))); -- cgit From d75b3913c9e03ff97336aa7a6e1cbac2eb03f230 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 2 Feb 2009 00:46:57 +0100 Subject: s3:winbind_group: fix "getent group" to allocate new gids. "getent group" used to fill the idmap cache with negative cache entries for unmapped group sids. Don't pass domain name unconditionally to idmap_sid_to_gid(). idmap_sid_to_gid() only creates new mappings (allocating idmap backends tdb, tdb2, ldap...) when the domain name passed in is "". Note that it is _wrong_ to directly call the idmap_sid_to_gid() functions here, in the main winbindd. The correct fix would be to send a sid_to_gid request to winbindd itself, but this needs more work to prepare the async mechanisms, and we nee a quick fix for getent passwd now. Michael --- source3/winbindd/winbindd_group.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source3/winbindd/winbindd_group.c b/source3/winbindd/winbindd_group.c index bc532bbce7..48e6577902 100644 --- a/source3/winbindd/winbindd_group.c +++ b/source3/winbindd/winbindd_group.c @@ -1306,6 +1306,7 @@ void winbindd_getgrent(struct winbindd_cli_state *state) char *gr_mem; DOM_SID group_sid; struct winbindd_domain *domain; + char *domain_name_idmap; /* Do we need to fetch another chunk of groups? */ @@ -1353,8 +1354,13 @@ void winbindd_getgrent(struct winbindd_cli_state *state) sid_copy(&group_sid, &domain->sid); sid_append_rid(&group_sid, name_list[ent->sam_entry_index].rid); - if (!NT_STATUS_IS_OK(idmap_sid_to_gid(domain->name, &group_sid, - &group_gid))) { + domain_name_idmap = domain->have_idmap_config + ? domain->name + : ""; + + if (!NT_STATUS_IS_OK(idmap_sid_to_gid(domain_name_idmap, + &group_sid, &group_gid))) + { union unid_t id; enum lsa_SidType type; -- cgit From d96248a9b46559552f53b0ecd3861387ea7ff050 Mon Sep 17 00:00:00 2001 From: Dan Sledz Date: Thu, 15 Jan 2009 17:02:41 -0800 Subject: Add two new parameters to control how we verify kerberos tickets. Removes lp_use_kerberos_keytab parameter. The first is "kerberos method" and replaces the "use kerberos keytab" with an enum. Valid options are: secrets only - use only the secrets for ticket verification (default) system keytab - use only the system keytab for ticket verification dedicated keytab - use a dedicated keytab for ticket verification. secrets and keytab - use the secrets.tdb first, then the system keytab For existing installs: "use kerberos keytab = yes" corresponds to secrets and keytab "use kerberos keytab = no" corresponds to secrets only The major difference between "system keytab" and "dedicated keytab" is that the latter method relies on kerberos to find the correct keytab entry instead of filtering based on expected principals. The second parameter is "dedicated keytab file", which is the keytab to use when in "dedicated keytab" mode. This keytab is only used in ads_verify_ticket. --- source3/include/includes.h | 19 +++++- source3/include/proto.h | 3 +- source3/libads/kerberos_verify.c | 129 +++++++++++++++++++++++++++++++++------ source3/libnet/libnet_join.c | 2 +- source3/param/loadparm.c | 33 ++++++++-- source3/rpc_server/srv_pipe.c | 2 +- source3/smbd/negprot.c | 2 +- source3/smbd/sesssetup.c | 4 +- source3/utils/net_ads.c | 8 +-- source3/winbindd/winbindd_dual.c | 2 +- 10 files changed, 170 insertions(+), 34 deletions(-) diff --git a/source3/include/includes.h b/source3/include/includes.h index c58ebcdbfe..ebd8923769 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -879,8 +879,25 @@ char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...) PRINTF_ATT #define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */ #endif -#if defined(HAVE_KRB5) +/* + * This should be under the HAVE_KRB5 flag but since they're used + * in lp_kerberos_method(), they ned to be always available + */ +#define KERBEROS_VERIFY_SECRETS 0 +#define KERBEROS_VERIFY_SYSTEM_KEYTAB 1 +#define KERBEROS_VERIFY_DEDICATED_KEYTAB 2 +#define KERBEROS_VERIFY_SECRETS_AND_KEYTAB 3 +/* + * If you add any entries to the above, please modify the below expressions + * so they remain accurate. + */ +#define USE_KERBEROS_KEYTAB (KERBEROS_VERIFY_SECRETS != lp_kerberos_method()) +#define USE_SYSTEM_KEYTAB \ + ((KERBEROS_VERIFY_SECRETS_AND_KEYTAB == lp_kerberos_method()) || \ + (KERBEROS_VERIFY_SYSTEM_KEYTAB == lp_kerberos_method())) + +#if defined(HAVE_KRB5) krb5_error_code smb_krb5_parse_name(krb5_context context, const char *name, /* in unix charset */ krb5_principal *principal); diff --git a/source3/include/proto.h b/source3/include/proto.h index c97adaa1c0..285b44dcde 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -4060,7 +4060,8 @@ bool lp_client_use_spnego(void); bool lp_hostname_lookups(void); bool lp_change_notify(const struct share_params *p ); bool lp_kernel_change_notify(const struct share_params *p ); -bool lp_use_kerberos_keytab(void); +char * lp_dedicated_keytab_file(void); +int lp_kerberos_method(void); bool lp_defer_sharing_violations(void); bool lp_enable_privileges(void); bool lp_enable_asu_support(void); diff --git a/source3/libads/kerberos_verify.c b/source3/libads/kerberos_verify.c index de3fdeb9de..4483d2be58 100644 --- a/source3/libads/kerberos_verify.c +++ b/source3/libads/kerberos_verify.c @@ -31,6 +31,86 @@ const krb5_data *krb5_princ_component(krb5_context, krb5_principal, int ); #endif +static bool ads_dedicated_keytab_verify_ticket(krb5_context context, + krb5_auth_context auth_context, + const DATA_BLOB *ticket, + krb5_ticket **pp_tkt, + krb5_keyblock **keyblock, + krb5_error_code *perr) +{ + krb5_error_code ret = 0; + bool auth_ok = false; + krb5_keytab keytab = NULL; + krb5_keytab_entry kt_entry; + krb5_ticket *dec_ticket = NULL; + + krb5_data packet; + + *pp_tkt = NULL; + *keyblock = NULL; + *perr = 0; + + ZERO_STRUCT(kt_entry); + + ret = smb_krb5_open_keytab(context, lp_dedicated_keytab_file(), true, + &keytab); + if (ret) { + DEBUG(1, ("smb_krb5_open_keytab failed (%s)\n", + error_message(ret))); + goto out; + } + + packet.length = ticket->length; + packet.data = (char *)ticket->data; + *pp_tkt = NULL; + + ret = krb5_rd_req(context, &auth_context, &packet, NULL, keytab, + NULL, &dec_ticket); + if (ret) { + DEBUG(0, ("krb5_rd_req failed (%s)\n", error_message(ret))); + goto out; + } + + /* Get the key for checking the pac signature */ + ret = krb5_kt_get_entry(context, keytab, dec_ticket->server, + dec_ticket->enc_part.kvno, dec_ticket->enc_part.enctype, + &kt_entry); + if (ret) { + DEBUG(0, ("krb5_kt_get_entry failed (%s)\n", + error_message(ret))); + goto out; + } + +#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK /* Heimdal */ + ret = krb5_copy_keyblock(context, &kt_entry.keyblock, keyblock); +#elif defined(HAVE_KRB5_KEYTAB_ENTRY_KEY) /* MIT */ + ret = krb5_copy_keyblock(context, &kt_entry.key, keyblock); +#else +#error UNKNOWN_KRB5_KEYTAB_ENTRY_FORMAT +#endif + smb_krb5_kt_free_entry(context, &kt_entry); + + if (ret) { + DEBUG(0, ("failed to copy key: %s\n", + error_message(ret))); + goto out; + } + + auth_ok = true; + *pp_tkt = dec_ticket; + dec_ticket = NULL; + + out: + if (dec_ticket) + krb5_free_ticket(context, dec_ticket); + + if (keytab) + krb5_kt_close(context, keytab); + + *perr = ret; + return auth_ok; +} + /********************************************************************************** Try to verify a ticket using the system keytab... the system keytab has kvno -1 entries, so it's more like what microsoft does... see comment in utils/net_ads.c in the @@ -437,22 +517,38 @@ NTSTATUS ads_verify_ticket(TALLOC_CTX *mem_ctx, } } - /* Try secrets.tdb first and fallback to the krb5.keytab if - necessary */ - - auth_ok = ads_secrets_verify_ticket(context, auth_context, host_princ, - ticket, &tkt, &keyblock, &ret); - - if (!auth_ok && - (ret == KRB5KRB_AP_ERR_TKT_NYV || - ret == KRB5KRB_AP_ERR_TKT_EXPIRED || - ret == KRB5KRB_AP_ERR_SKEW)) { - goto auth_failed; - } - - if (!auth_ok && lp_use_kerberos_keytab()) { - auth_ok = ads_keytab_verify_ticket(context, auth_context, - ticket, &tkt, &keyblock, &ret); + switch (lp_kerberos_method()) { + default: + case KERBEROS_VERIFY_SECRETS: + auth_ok = ads_secrets_verify_ticket(context, auth_context, + host_princ, ticket, &tkt, &keyblock, &ret); + break; + case KERBEROS_VERIFY_SYSTEM_KEYTAB: + auth_ok = ads_keytab_verify_ticket(context, auth_context, + ticket, &tkt, &keyblock, &ret); + break; + case KERBEROS_VERIFY_DEDICATED_KEYTAB: + auth_ok = ads_dedicated_keytab_verify_ticket(context, + auth_context, ticket, &tkt, &keyblock, &ret); + break; + case KERBEROS_VERIFY_SECRETS_AND_KEYTAB: + /* First try secrets.tdb and fallback to the krb5.keytab if + necessary. This is the pre 3.4 behavior when + "use kerberos keytab" was true.*/ + auth_ok = ads_secrets_verify_ticket(context, auth_context, + host_princ, ticket, &tkt, &keyblock, &ret); + + if (!auth_ok) { + /* Only fallback if we failed to decrypt the ticket */ + if (ret != KRB5KRB_AP_ERR_TKT_NYV && + ret != KRB5KRB_AP_ERR_TKT_EXPIRED && + ret != KRB5KRB_AP_ERR_SKEW) { + auth_ok = ads_keytab_verify_ticket(context, + auth_context, ticket, &tkt, &keyblock, + &ret); + } + } + break; } if ( use_replay_cache ) { @@ -465,7 +561,6 @@ NTSTATUS ads_verify_ticket(TALLOC_CTX *mem_ctx, #endif } - auth_failed: if (!auth_ok) { DEBUG(3,("ads_verify_ticket: krb5_rd_req with auth failed (%s)\n", error_message(ret))); diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index be6943bad9..b33800f20d 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -504,7 +504,7 @@ static ADS_STATUS libnet_join_set_os_attributes(TALLOC_CTX *mem_ctx, static bool libnet_join_create_keytab(TALLOC_CTX *mem_ctx, struct libnet_JoinCtx *r) { - if (!lp_use_kerberos_keytab()) { + if (!USE_SYSTEM_KEYTAB) { return true; } diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 6438888942..d672b372cf 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -322,7 +322,8 @@ struct global { bool bHostnameLookups; bool bUnixExtensions; bool bDisableNetbios; - bool bUseKerberosKeytab; + char * szDedicatedKeytabFile; + int iKerberosMethod; bool bDeferSharingViolations; bool bEnablePrivileges; bool bASUSupport; @@ -861,6 +862,17 @@ static const struct enum_list enum_config_backend[] = { {-1, NULL} }; +/* ADS kerberos ticket verification options */ + +static const struct enum_list enum_kerberos_method[] = { + {KERBEROS_VERIFY_SECRETS, "default"}, + {KERBEROS_VERIFY_SECRETS, "secrets only"}, + {KERBEROS_VERIFY_SYSTEM_KEYTAB, "system keytab"}, + {KERBEROS_VERIFY_DEDICATED_KEYTAB, "dedicated keytab"}, + {KERBEROS_VERIFY_SECRETS_AND_KEYTAB, "secrets and keytab"}, + {-1, NULL} +}; + /* Note: We do not initialise the defaults union - it is not allowed in ANSI C * * The FLAG_HIDE is explicit. Paramters set this way do NOT appear in any edit @@ -1745,14 +1757,24 @@ static struct parm_struct parm_table[] = { .flags = FLAG_ADVANCED | FLAG_GLOBAL, }, { - .label = "use kerberos keytab", - .type = P_BOOL, + .label = "dedicated keytab file", + .type = P_STRING, .p_class = P_GLOBAL, - .ptr = &Globals.bUseKerberosKeytab, + .ptr = &Globals.szDedicatedKeytabFile, .special = NULL, .enum_list = NULL, .flags = FLAG_ADVANCED, }, + { + .label = "kerberos method", + .type = P_ENUM, + .p_class = P_GLOBAL, + .ptr = &Globals.iKerberosMethod, + .special = NULL, + .enum_list = enum_kerberos_method, + .flags = FLAG_ADVANCED, + }, + {N_("Logging Options"), P_SEP, P_SEPARATOR}, @@ -5322,7 +5344,8 @@ FN_GLOBAL_BOOL(lp_client_use_spnego, &Globals.bClientUseSpnego) FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups) FN_LOCAL_PARM_BOOL(lp_change_notify, bChangeNotify) FN_LOCAL_PARM_BOOL(lp_kernel_change_notify, bKernelChangeNotify) -FN_GLOBAL_BOOL(lp_use_kerberos_keytab, &Globals.bUseKerberosKeytab) +FN_GLOBAL_STRING(lp_dedicated_keytab_file, &Globals.szDedicatedKeytabFile) +FN_GLOBAL_INTEGER(lp_kerberos_method, &Globals.iKerberosMethod) FN_GLOBAL_BOOL(lp_defer_sharing_violations, &Globals.bDeferSharingViolations) FN_GLOBAL_BOOL(lp_enable_privileges, &Globals.bEnablePrivileges) FN_GLOBAL_BOOL(lp_enable_asu_support, &Globals.bASUSupport) diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index cbe697817a..924226bc4f 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1147,7 +1147,7 @@ static bool pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_ } DEBUG(3,("pipe_spnego_auth_bind_negotiate: Got secblob of size %lu\n", (unsigned long)secblob.length)); - if ( got_kerberos_mechanism && ((lp_security()==SEC_ADS) || lp_use_kerberos_keytab()) ) { + if ( got_kerberos_mechanism && ((lp_security()==SEC_ADS) || USE_KERBEROS_KEYTAB) ) { bool ret = pipe_spnego_auth_bind_kerberos(p, rpc_in_p, pauth_info, &secblob, pout_auth); data_blob_free(&secblob); data_blob_free(&blob); diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index 729d144ea1..57608a9b40 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -212,7 +212,7 @@ static DATA_BLOB negprot_spnego(void) */ - if (lp_security() != SEC_ADS && !lp_use_kerberos_keytab()) { + if (lp_security() != SEC_ADS && !USE_KERBEROS_KEYTAB) { #if 0 /* Code for PocketPC client */ blob = data_blob(guid, 16); diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c index a2ad56bea1..7a03ef7f3c 100644 --- a/source3/smbd/sesssetup.c +++ b/source3/smbd/sesssetup.c @@ -795,7 +795,7 @@ static void reply_spnego_negotiate(struct smb_request *req, #ifdef HAVE_KRB5 if (kerb_mech && ((lp_security()==SEC_ADS) || - lp_use_kerberos_keytab()) ) { + USE_KERBEROS_KEYTAB) ) { bool destroy_vuid = True; reply_spnego_kerberos(req, &secblob, kerb_mech, vuid, &destroy_vuid); @@ -887,7 +887,7 @@ static void reply_spnego_auth(struct smb_request *req, (unsigned long)secblob.length)); #ifdef HAVE_KRB5 if (kerb_mech && ((lp_security()==SEC_ADS) || - lp_use_kerberos_keytab()) ) { + USE_KERBEROS_KEYTAB)) { bool destroy_vuid = True; reply_spnego_kerberos(req, &secblob, kerb_mech, vuid, &destroy_vuid); diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 766f3216f0..03786e2e17 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -1920,7 +1920,7 @@ int net_ads_changetrustpw(struct net_context *c, int argc, const char **argv) d_printf("Password change for principal %s succeeded.\n", host_principal); - if (lp_use_kerberos_keytab()) { + if (USE_SYSTEM_KEYTAB) { d_printf("Attempting to update system keytab with new password.\n"); if (ads_keytab_create_default(ads)) { d_printf("Failed to update system keytab.\n"); @@ -2241,9 +2241,9 @@ int net_ads_keytab(struct net_context *c, int argc, const char **argv) {NULL, NULL, 0, NULL, NULL} }; - if (!lp_use_kerberos_keytab()) { - d_printf("\nWarning: \"use kerberos keytab\" must be set to \"true\" in order to \ -use keytab functions.\n"); + if (!USE_KERBEROS_KEYTAB) { + d_printf("\nWarning: \"kerberos method\" must be set to a \ + keytab method to use keytab functions.\n"); } return net_run_function(c, argc, argv, "net ads keytab", func); diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index 1385c76bae..d40bab94ef 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -1360,7 +1360,7 @@ static bool fork_domain_child(struct winbindd_child *child) } if (child->domain && child->domain->primary && - !lp_use_kerberos_keytab() && + !USE_KERBEROS_KEYTAB && lp_server_role() == ROLE_DOMAIN_MEMBER) { struct timeval next_change; -- cgit From 10e9e95ce8bb94c6a2547dd1148cd20a171b3583 Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Sun, 1 Feb 2009 23:59:53 -0800 Subject: s3 build: Fix "assignment discards qualifiers from pointer target type" warnings --- source3/winbindd/winbindd_group.c | 8 ++------ source3/winbindd/winbindd_user.c | 11 ++++------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/source3/winbindd/winbindd_group.c b/source3/winbindd/winbindd_group.c index 48e6577902..9d9b264124 100644 --- a/source3/winbindd/winbindd_group.c +++ b/source3/winbindd/winbindd_group.c @@ -1306,7 +1306,6 @@ void winbindd_getgrent(struct winbindd_cli_state *state) char *gr_mem; DOM_SID group_sid; struct winbindd_domain *domain; - char *domain_name_idmap; /* Do we need to fetch another chunk of groups? */ @@ -1354,11 +1353,8 @@ void winbindd_getgrent(struct winbindd_cli_state *state) sid_copy(&group_sid, &domain->sid); sid_append_rid(&group_sid, name_list[ent->sam_entry_index].rid); - domain_name_idmap = domain->have_idmap_config - ? domain->name - : ""; - - if (!NT_STATUS_IS_OK(idmap_sid_to_gid(domain_name_idmap, + if (!NT_STATUS_IS_OK(idmap_sid_to_gid(domain->have_idmap_config + ? domain->name : "", &group_sid, &group_gid))) { union unid_t id; diff --git a/source3/winbindd/winbindd_user.c b/source3/winbindd/winbindd_user.c index b01e1847f2..62fd4d7f07 100644 --- a/source3/winbindd/winbindd_user.c +++ b/source3/winbindd/winbindd_user.c @@ -76,7 +76,6 @@ static bool winbindd_fill_pwent(TALLOC_CTX *ctx, char *dom_name, char *user_name char *mapped_name = NULL; struct winbindd_domain *domain = NULL; NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; - char *dom_name_idmap = ""; if (!pw || !dom_name || !user_name) return False; @@ -88,13 +87,10 @@ static bool winbindd_fill_pwent(TALLOC_CTX *ctx, char *dom_name, char *user_name nt_status = NT_STATUS_NO_SUCH_DOMAIN; } - if (domain->have_idmap_config) { - dom_name_idmap = dom_name; - } - /* Resolve the uid number */ - if (!NT_STATUS_IS_OK(idmap_sid_to_uid(dom_name_idmap, user_sid, + if (!NT_STATUS_IS_OK(idmap_sid_to_uid(domain->have_idmap_config ? + dom_name : "", user_sid, &pw->pw_uid))) { DEBUG(1, ("error getting user id for sid %s\n", sid_string_dbg(user_sid))); @@ -103,7 +99,8 @@ static bool winbindd_fill_pwent(TALLOC_CTX *ctx, char *dom_name, char *user_name /* Resolve the gid number */ - if (!NT_STATUS_IS_OK(idmap_sid_to_gid(dom_name_idmap, group_sid, + if (!NT_STATUS_IS_OK(idmap_sid_to_gid(domain->have_idmap_config ? + dom_name : "", group_sid, &pw->pw_gid))) { DEBUG(1, ("error getting group id for sid %s\n", sid_string_dbg(group_sid))); -- cgit From 73f4fc1f802f31459b70dba4777d142d00fcdd92 Mon Sep 17 00:00:00 2001 From: Karolin Seeger Date: Mon, 2 Feb 2009 11:46:39 +0100 Subject: docs: Describe "service" in man mount.cifs. This fixes bug #5346. Thanks to the Debian Samba package maintainers for reporting and providing a patch! Karolin --- docs-xml/manpages-3/mount.cifs.8.xml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs-xml/manpages-3/mount.cifs.8.xml b/docs-xml/manpages-3/mount.cifs.8.xml index 54fbc139b4..00711e0de0 100644 --- a/docs-xml/manpages-3/mount.cifs.8.xml +++ b/docs-xml/manpages-3/mount.cifs.8.xml @@ -43,10 +43,13 @@ by the popular Open Source server Samba. - The mount.cifs utility attaches the UNC name (exported network resource) to - the local directory mount-point. It is possible to set the mode for mount.cifs to -setuid root to allow non-root users to mount shares to directories for which they -have write permission. + The mount.cifs utility attaches the UNC name (exported network resource) + specified as service (using //server/share syntax, + where "server" is the server name or IP address and "share" is the name + of the share) to the local directory mount-point. + It is possible to set the mode for mount.cifs to setuid root to allow + non-root users to mount shares to directories for which they + have write permission. -- cgit From e7454d46d4cf6125e14ed7c9a36132eea929f19c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:15:46 +0100 Subject: s4:auth/gensec: s/private/private_data metze --- source4/auth/gensec/socket.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source4/auth/gensec/socket.c b/source4/auth/gensec/socket.c index a338797ecf..6a03f0bcec 100644 --- a/source4/auth/gensec/socket.c +++ b/source4/auth/gensec/socket.c @@ -158,9 +158,9 @@ NTSTATUS gensec_packet_full_request(struct gensec_security *gensec_security, return packet_full_request_u32(NULL, blob, size); } -static NTSTATUS gensec_socket_full_request(void *private, DATA_BLOB blob, size_t *size) +static NTSTATUS gensec_socket_full_request(void *private_data, DATA_BLOB blob, size_t *size) { - struct gensec_socket *gensec_socket = talloc_get_type(private, struct gensec_socket); + struct gensec_socket *gensec_socket = talloc_get_type(private_data, struct gensec_socket); struct gensec_security *gensec_security = gensec_socket->gensec_security; return gensec_packet_full_request(gensec_security, blob, size); } @@ -187,9 +187,9 @@ static NTSTATUS gensec_socket_pending(struct socket_context *sock, size_t *npend } /* Note if an error occours, so we can return it up the stack */ -static void gensec_socket_error_handler(void *private, NTSTATUS status) +static void gensec_socket_error_handler(void *private_data, NTSTATUS status) { - struct gensec_socket *gensec_socket = talloc_get_type(private, struct gensec_socket); + struct gensec_socket *gensec_socket = talloc_get_type(private_data, struct gensec_socket); if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) { gensec_socket->eof = true; } else { @@ -199,9 +199,9 @@ static void gensec_socket_error_handler(void *private, NTSTATUS status) static void gensec_socket_trigger_read(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct gensec_socket *gensec_socket = talloc_get_type(private, struct gensec_socket); + struct gensec_socket *gensec_socket = talloc_get_type(private_data, struct gensec_socket); gensec_socket->in_extra_read++; gensec_socket->recv_handler(gensec_socket->recv_private, EVENT_FD_READ); @@ -287,9 +287,9 @@ static NTSTATUS gensec_socket_recv(struct socket_context *sock, void *buf, * * This function (and anything under it) MUST NOT call the event system */ -static NTSTATUS gensec_socket_unwrap(void *private, DATA_BLOB blob) +static NTSTATUS gensec_socket_unwrap(void *private_data, DATA_BLOB blob) { - struct gensec_socket *gensec_socket = talloc_get_type(private, struct gensec_socket); + struct gensec_socket *gensec_socket = talloc_get_type(private_data, struct gensec_socket); DATA_BLOB unwrapped; NTSTATUS nt_status; TALLOC_CTX *mem_ctx; @@ -329,9 +329,9 @@ static NTSTATUS gensec_socket_unwrap(void *private, DATA_BLOB blob) } /* when the data is sent, we know we have not been interrupted */ -static void send_callback(void *private) +static void send_callback(void *private_data) { - struct gensec_socket *gensec_socket = talloc_get_type(private, struct gensec_socket); + struct gensec_socket *gensec_socket = talloc_get_type(private_data, struct gensec_socket); gensec_socket->interrupted = false; } -- cgit From 2e82a4ced2282eec55983b443e9e54f57e8b443d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:17:20 +0100 Subject: s4:auth/kerberos: s/private/private_data metze --- source4/auth/kerberos/krb5_init_context.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source4/auth/kerberos/krb5_init_context.c b/source4/auth/kerberos/krb5_init_context.c index 6e885842f3..04f0718a62 100644 --- a/source4/auth/kerberos/krb5_init_context.c +++ b/source4/auth/kerberos/krb5_init_context.c @@ -65,11 +65,11 @@ static krb5_error_code smb_krb5_context_destroy_2(struct smb_krb5_context *ctx) } /* We never close down the DEBUG system, and no need to unreference the use */ -static void smb_krb5_debug_close(void *private) { +static void smb_krb5_debug_close(void *private_data) { return; } -static void smb_krb5_debug_wrapper(const char *timestr, const char *msg, void *private) +static void smb_krb5_debug_wrapper(const char *timestr, const char *msg, void *private_data) { DEBUG(2, ("Kerberos: %s\n", msg)); } @@ -117,9 +117,9 @@ static void smb_krb5_socket_recv(struct smb_krb5_socket *smb_krb5) talloc_free(tmp_ctx); } -static NTSTATUS smb_krb5_full_packet(void *private, DATA_BLOB data) +static NTSTATUS smb_krb5_full_packet(void *private_data, DATA_BLOB data) { - struct smb_krb5_socket *smb_krb5 = talloc_get_type(private, struct smb_krb5_socket); + struct smb_krb5_socket *smb_krb5 = talloc_get_type(private_data, struct smb_krb5_socket); talloc_steal(smb_krb5, data.data); smb_krb5->reply = data; smb_krb5->reply.length -= 4; @@ -132,16 +132,16 @@ static NTSTATUS smb_krb5_full_packet(void *private, DATA_BLOB data) */ static void smb_krb5_request_timeout(struct tevent_context *event_ctx, struct tevent_timer *te, struct timeval t, - void *private) + void *private_data) { - struct smb_krb5_socket *smb_krb5 = talloc_get_type(private, struct smb_krb5_socket); + struct smb_krb5_socket *smb_krb5 = talloc_get_type(private_data, struct smb_krb5_socket); DEBUG(5,("Timed out smb_krb5 packet\n")); smb_krb5->status = NT_STATUS_IO_TIMEOUT; } -static void smb_krb5_error_handler(void *private, NTSTATUS status) +static void smb_krb5_error_handler(void *private_data, NTSTATUS status) { - struct smb_krb5_socket *smb_krb5 = talloc_get_type(private, struct smb_krb5_socket); + struct smb_krb5_socket *smb_krb5 = talloc_get_type(private_data, struct smb_krb5_socket); smb_krb5->status = status; } @@ -170,9 +170,9 @@ static void smb_krb5_socket_send(struct smb_krb5_socket *smb_krb5) handle fd events on a smb_krb5_socket */ static void smb_krb5_socket_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct smb_krb5_socket *smb_krb5 = talloc_get_type(private, struct smb_krb5_socket); + struct smb_krb5_socket *smb_krb5 = talloc_get_type(private_data, struct smb_krb5_socket); switch (smb_krb5->hi->proto) { case KRB5_KRBHST_UDP: if (flags & TEVENT_FD_READ) { -- cgit From b7f298348934e86b1f8026bd445ec167439581f6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:19:11 +0100 Subject: s4:extended_dn_out: s/private/p s/new/nattrs metze --- source4/dsdb/samdb/ldb_modules/extended_dn_out.c | 80 ++++++++++++------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn_out.c b/source4/dsdb/samdb/ldb_modules/extended_dn_out.c index 058c51bdb8..f8526faf3b 100644 --- a/source4/dsdb/samdb/ldb_modules/extended_dn_out.c +++ b/source4/dsdb/samdb/ldb_modules/extended_dn_out.c @@ -59,42 +59,42 @@ static bool is_attr_in_list(const char * const * attrs, const char *attr) static char **copy_attrs(void *mem_ctx, const char * const * attrs) { - char **new; + char **nattrs; int i, num; for (num = 0; attrs[num]; num++); - new = talloc_array(mem_ctx, char *, num + 1); - if (!new) return NULL; + nattrs = talloc_array(mem_ctx, char *, num + 1); + if (!nattrs) return NULL; for(i = 0; i < num; i++) { - new[i] = talloc_strdup(new, attrs[i]); - if (!new[i]) { - talloc_free(new); + nattrs[i] = talloc_strdup(nattrs, attrs[i]); + if (!nattrs[i]) { + talloc_free(nattrs); return NULL; } } - new[i] = NULL; + nattrs[i] = NULL; - return new; + return nattrs; } static bool add_attrs(void *mem_ctx, char ***attrs, const char *attr) { - char **new; + char **nattrs; int num; for (num = 0; (*attrs)[num]; num++); - new = talloc_realloc(mem_ctx, *attrs, char *, num + 2); - if (!new) return false; + nattrs = talloc_realloc(mem_ctx, *attrs, char *, num + 2); + if (!nattrs) return false; - *attrs = new; + *attrs = nattrs; - new[num] = talloc_strdup(new, attr); - if (!new[num]) return false; + nattrs[num] = talloc_strdup(nattrs, attr); + if (!nattrs[num]) return false; - new[num + 1] = NULL; + nattrs[num + 1] = NULL; return true; } @@ -246,10 +246,10 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares) struct dsdb_openldap_dereference_result_control *dereference_control = NULL; int ret, i, j; struct ldb_message *msg = ares->message; - struct extended_dn_out_private *private; + struct extended_dn_out_private *p; ac = talloc_get_type(req->context, struct extended_search_context); - private = talloc_get_type(ac->module->private_data, struct extended_dn_out_private); + p = talloc_get_type(ac->module->private_data, struct extended_dn_out_private); if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -271,7 +271,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares) break; } - if (private && private->normalise) { + if (p && p->normalise) { ret = fix_dn(ares->message->dn); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, NULL, NULL, ret); @@ -289,7 +289,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares) } } - if ((private && private->normalise) || ac->inject) { + if ((p && p->normalise) || ac->inject) { const struct ldb_val *val = ldb_msg_find_ldb_val(ares->message, "distinguishedName"); if (val) { ldb_msg_remove_attr(ares->message, "distinguishedName"); @@ -307,7 +307,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares) } } - if (private && private->dereference) { + if (p && p->dereference) { control = ldb_reply_get_control(ares, DSDB_OPENLDAP_DEREFERENCE_CONTROL); if (control && control->data) { @@ -323,7 +323,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares) continue; } - if (private->normalise) { + if (p->normalise) { /* If we are also in 'normalise' mode, then * fix the attribute names to be in the * correct case */ @@ -351,7 +351,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares) return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_INVALID_DN_SYNTAX); } - if (private->normalise) { + if (p->normalise) { ret = fix_dn(dn); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, NULL, NULL, ret); @@ -408,7 +408,7 @@ static int extended_dn_out_search(struct ldb_module *module, struct ldb_request const char * const *const_attrs; int ret; - struct extended_dn_out_private *private = talloc_get_type(module->private_data, struct extended_dn_out_private); + struct extended_dn_out_private *p = talloc_get_type(module->private_data, struct extended_dn_out_private); /* check if there's an extended dn control */ control = ldb_request_get_control(req, LDB_CONTROL_EXTENDED_DN_OID); @@ -450,7 +450,7 @@ static int extended_dn_out_search(struct ldb_module *module, struct ldb_request * the extended DN, or we are 'store DN+GUID+SID' * (!dereference) mode. (This is the normal mode for LDB on * tdb). */ - if (control || (storage_format_control && private && !private->dereference)) { + if (control || (storage_format_control && p && !p->dereference)) { ac->inject = true; if (extended_ctrl) { ac->extended_type = extended_ctrl->type; @@ -522,10 +522,10 @@ static int extended_dn_out_search(struct ldb_module *module, struct ldb_request /* Add in dereference control, if we were asked to, we are * using the 'dereference' mode (such as with an OpenLDAP * backend) and have the control prepared */ - if (control && private && private->dereference && private->dereference_control) { + if (control && p && p->dereference && p->dereference_control) { ret = ldb_request_add_control(down_req, DSDB_OPENLDAP_DEREFERENCE_CONTROL, - false, private->dereference_control); + false, p->dereference_control); if (ret != LDB_SUCCESS) { return ret; } @@ -539,17 +539,17 @@ static int extended_dn_out_ldb_init(struct ldb_module *module) { int ret; - struct extended_dn_out_private *private = talloc(module, struct extended_dn_out_private); + struct extended_dn_out_private *p = talloc(module, struct extended_dn_out_private); - module->private_data = private; + module->private_data = p; - if (!private) { + if (!p) { ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - private->dereference = false; - private->normalise = false; + p->dereference = false; + p->normalise = false; ret = ldb_mod_register_control(module, LDB_CONTROL_EXTENDED_DN_OID); if (ret != LDB_SUCCESS) { @@ -564,24 +564,24 @@ static int extended_dn_out_ldb_init(struct ldb_module *module) static int extended_dn_out_dereference_init(struct ldb_module *module) { int ret, i = 0; - struct extended_dn_out_private *private; + struct extended_dn_out_private *p; struct dsdb_openldap_dereference_control *dereference_control; struct dsdb_attribute *cur; struct dsdb_schema *schema; - module->private_data = private = talloc_zero(module, struct extended_dn_out_private); + module->private_data = p = talloc_zero(module, struct extended_dn_out_private); - if (!private) { + if (!p) { ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } - private->dereference = true; + p->dereference = true; /* At the moment, servers that need dereference also need the * DN and attribute names to be normalised */ - private->normalise = true; + p->normalise = true; ret = ldb_mod_register_control(module, LDB_CONTROL_EXTENDED_DN_OID); if (ret != LDB_SUCCESS) { @@ -602,10 +602,10 @@ static int extended_dn_out_dereference_init(struct ldb_module *module) return LDB_SUCCESS; } - private->dereference_control = dereference_control - = talloc_zero(private, struct dsdb_openldap_dereference_control); + p->dereference_control = dereference_control + = talloc_zero(p, struct dsdb_openldap_dereference_control); - if (!private->dereference_control) { + if (!p->dereference_control) { ldb_oom(module->ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -621,7 +621,7 @@ static int extended_dn_out_dereference_init(struct ldb_module *module) continue; } dereference_control->dereference - = talloc_realloc(private, dereference_control->dereference, + = talloc_realloc(p, dereference_control->dereference, struct dsdb_openldap_dereference *, i + 2); if (!dereference_control) { ldb_oom(module->ldb); -- cgit From 735af62105c563f9ee2ffd8bc21e914499d5ee76 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:20:52 +0100 Subject: s4:lib/messaging: s/private/private_data metze --- source4/lib/messaging/pymessaging.c | 4 ++-- source4/lib/messaging/tests/messaging.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source4/lib/messaging/pymessaging.c b/source4/lib/messaging/pymessaging.c index 535da4526c..96981895b6 100644 --- a/source4/lib/messaging/pymessaging.c +++ b/source4/lib/messaging/pymessaging.c @@ -159,11 +159,11 @@ static PyObject *py_messaging_send(PyObject *self, PyObject *args, PyObject *kwa Py_RETURN_NONE; } -static void py_msg_callback_wrapper(struct messaging_context *msg, void *private, +static void py_msg_callback_wrapper(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data) { - PyObject *callback = (PyObject *)private; + PyObject *callback = (PyObject *)private_data; PyObject_CallFunction(callback, discard_const_p(char, "i(iii)s#"), msg_type, server_id.id, server_id.id2, server_id.node, diff --git a/source4/lib/messaging/tests/messaging.c b/source4/lib/messaging/tests/messaging.c index 838de55d83..f61132caac 100644 --- a/source4/lib/messaging/tests/messaging.c +++ b/source4/lib/messaging/tests/messaging.c @@ -29,7 +29,7 @@ static uint32_t msg_pong; -static void ping_message(struct messaging_context *msg, void *private, +static void ping_message(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data) { NTSTATUS status; @@ -39,17 +39,17 @@ static void ping_message(struct messaging_context *msg, void *private, } } -static void pong_message(struct messaging_context *msg, void *private, +static void pong_message(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data) { - int *count = private; + int *count = (int *)private_data; (*count)++; } -static void exit_message(struct messaging_context *msg, void *private, +static void exit_message(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data) { - talloc_free(private); + talloc_free(private_data); exit(0); } -- cgit From 7db458a56c9296c96c65f903a75453ac635a42c8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:21:17 +0100 Subject: s4:lib/socket: s/private/private_data metze --- source4/lib/socket/connect.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source4/lib/socket/connect.c b/source4/lib/socket/connect.c index be15aa987b..b943de8c14 100644 --- a/source4/lib/socket/connect.c +++ b/source4/lib/socket/connect.c @@ -36,7 +36,7 @@ struct connect_state { static void socket_connect_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private); + uint16_t flags, void *private_data); /* call the real socket_connect() call, and setup event handler @@ -118,10 +118,10 @@ struct composite_context *socket_connect_send(struct socket_context *sock, */ static void socket_connect_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { struct composite_context *result = - talloc_get_type(private, struct composite_context); + talloc_get_type(private_data, struct composite_context); struct connect_state *state = talloc_get_type(result->private_data, struct connect_state); -- cgit From 79ae2de00135b3047dcb835c14a3afac6eb168eb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:22:01 +0100 Subject: s4:lib/stream: s/private/private_data metze --- source4/lib/stream/packet.c | 32 ++++++++++++++++---------------- source4/lib/stream/packet.h | 16 ++++++++-------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/source4/lib/stream/packet.c b/source4/lib/stream/packet.c index 7882059faf..f614e9490a 100644 --- a/source4/lib/stream/packet.c +++ b/source4/lib/stream/packet.c @@ -37,7 +37,7 @@ struct packet_context { struct socket_context *sock; struct tevent_context *ev; size_t packet_size; - void *private; + void *private_data; struct tevent_fd *fde; bool serialise; int processing; @@ -105,9 +105,9 @@ _PUBLIC_ void packet_set_error_handler(struct packet_context *pc, packet_error_h /* set the private pointer passed to the callback functions */ -_PUBLIC_ void packet_set_private(struct packet_context *pc, void *private) +_PUBLIC_ void packet_set_private(struct packet_context *pc, void *private_data) { - pc->private = private; + pc->private_data = private_data; } /* @@ -184,15 +184,15 @@ static void packet_error(struct packet_context *pc, NTSTATUS status) { pc->sock = NULL; if (pc->error_handler) { - pc->error_handler(pc->private, status); + pc->error_handler(pc->private_data, status); return; } /* default error handler is to free the callers private pointer */ if (!NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) { DEBUG(0,("packet_error on %s - %s\n", - talloc_get_name(pc->private), nt_errstr(status))); + talloc_get_name(pc->private_data), nt_errstr(status))); } - talloc_free(pc->private); + talloc_free(pc->private_data); return; } @@ -210,9 +210,9 @@ static void packet_eof(struct packet_context *pc) used to put packets on event boundaries */ static void packet_next_event(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct packet_context *pc = talloc_get_type(private, struct packet_context); + struct packet_context *pc = talloc_get_type(private_data, struct packet_context); if (pc->num_read != 0 && pc->packet_size != 0 && pc->packet_size <= pc->num_read) { packet_recv(pc); @@ -330,7 +330,7 @@ next_partial: /* see if its a full request */ blob = pc->partial; blob.length = pc->num_read; - status = pc->full_request(pc->private, blob, &pc->packet_size); + status = pc->full_request(pc->private_data, blob, &pc->packet_size); if (NT_STATUS_IS_ERR(status)) { packet_error(pc, status); return; @@ -375,7 +375,7 @@ next_partial: pc->busy = true; - status = pc->callback(pc->private, blob); + status = pc->callback(pc->private_data, blob); pc->busy = false; @@ -409,7 +409,7 @@ next_partial: blob = pc->partial; blob.length = pc->num_read; - status = pc->full_request(pc->private, blob, &pc->packet_size); + status = pc->full_request(pc->private_data, blob, &pc->packet_size); if (NT_STATUS_IS_ERR(status)) { packet_error(pc, status); return; @@ -495,7 +495,7 @@ _PUBLIC_ void packet_queue_run(struct packet_context *pc) */ _PUBLIC_ NTSTATUS packet_send_callback(struct packet_context *pc, DATA_BLOB blob, packet_send_callback_fn_t send_callback, - void *private) + void *private_data) { struct send_element *el; el = talloc(pc, struct send_element); @@ -505,7 +505,7 @@ _PUBLIC_ NTSTATUS packet_send_callback(struct packet_context *pc, DATA_BLOB blob el->blob = blob; el->nsent = 0; el->send_callback = send_callback; - el->send_callback_private = private; + el->send_callback_private = private_data; /* if we aren't going to free the packet then we must reference it to ensure it doesn't disappear before going out */ @@ -517,7 +517,7 @@ _PUBLIC_ NTSTATUS packet_send_callback(struct packet_context *pc, DATA_BLOB blob talloc_steal(el, blob.data); } - if (private && !talloc_reference(el, private)) { + if (private_data && !talloc_reference(el, private_data)) { return NT_STATUS_NO_MEMORY; } @@ -538,7 +538,7 @@ _PUBLIC_ NTSTATUS packet_send(struct packet_context *pc, DATA_BLOB blob) /* a full request checker for NBT formatted packets (first 3 bytes are length) */ -_PUBLIC_ NTSTATUS packet_full_request_nbt(void *private, DATA_BLOB blob, size_t *size) +_PUBLIC_ NTSTATUS packet_full_request_nbt(void *private_data, DATA_BLOB blob, size_t *size) { if (blob.length < 4) { return STATUS_MORE_ENTRIES; @@ -555,7 +555,7 @@ _PUBLIC_ NTSTATUS packet_full_request_nbt(void *private, DATA_BLOB blob, size_t work out if a packet is complete for protocols that use a 32 bit network byte order length */ -_PUBLIC_ NTSTATUS packet_full_request_u32(void *private, DATA_BLOB blob, size_t *size) +_PUBLIC_ NTSTATUS packet_full_request_u32(void *private_data, DATA_BLOB blob, size_t *size) { if (blob.length < 4) { return STATUS_MORE_ENTRIES; diff --git a/source4/lib/stream/packet.h b/source4/lib/stream/packet.h index c9bd9d4767..3c2fb0a683 100644 --- a/source4/lib/stream/packet.h +++ b/source4/lib/stream/packet.h @@ -24,20 +24,20 @@ struct packet_context; struct tevent_context; struct tevent_fd; -typedef NTSTATUS (*packet_full_request_fn_t)(void *private, +typedef NTSTATUS (*packet_full_request_fn_t)(void *private_data, DATA_BLOB blob, size_t *packet_size); -typedef NTSTATUS (*packet_callback_fn_t)(void *private, DATA_BLOB blob); +typedef NTSTATUS (*packet_callback_fn_t)(void *private_data, DATA_BLOB blob); /* Used to notify that a packet has been sent, and is on the wire */ -typedef void (*packet_send_callback_fn_t)(void *private); -typedef void (*packet_error_handler_fn_t)(void *private, NTSTATUS status); +typedef void (*packet_send_callback_fn_t)(void *private_data); +typedef void (*packet_error_handler_fn_t)(void *private_data, NTSTATUS status); struct packet_context *packet_init(TALLOC_CTX *mem_ctx); void packet_set_callback(struct packet_context *pc, packet_callback_fn_t callback); void packet_set_error_handler(struct packet_context *pc, packet_error_handler_fn_t handler); -void packet_set_private(struct packet_context *pc, void *private); +void packet_set_private(struct packet_context *pc, void *private_data); void packet_set_full_request(struct packet_context *pc, packet_full_request_fn_t callback); void packet_set_socket(struct packet_context *pc, struct socket_context *sock); void packet_set_event_context(struct packet_context *pc, struct tevent_context *ev); @@ -51,13 +51,13 @@ void packet_recv_enable(struct packet_context *pc); NTSTATUS packet_send(struct packet_context *pc, DATA_BLOB blob); NTSTATUS packet_send_callback(struct packet_context *pc, DATA_BLOB blob, packet_send_callback_fn_t send_callback, - void *private); + void *private_data); void packet_queue_run(struct packet_context *pc); /* pre-canned handlers */ -NTSTATUS packet_full_request_nbt(void *private, DATA_BLOB blob, size_t *size); -NTSTATUS packet_full_request_u32(void *private, DATA_BLOB blob, size_t *size); +NTSTATUS packet_full_request_nbt(void *private_data, DATA_BLOB blob, size_t *size); +NTSTATUS packet_full_request_u32(void *private_data, DATA_BLOB blob, size_t *size); -- cgit From ea7ea27f2f5d729629cf326424ea8b1123b9fc6e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:22:40 +0100 Subject: s4:libcli/cldap: s/private/private_data metze --- source4/libcli/cldap/cldap.c | 12 ++++++------ source4/libcli/cldap/cldap.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source4/libcli/cldap/cldap.c b/source4/libcli/cldap/cldap.c index 556f9bcec3..d9a6c970b9 100644 --- a/source4/libcli/cldap/cldap.c +++ b/source4/libcli/cldap/cldap.c @@ -146,9 +146,9 @@ static void cldap_socket_recv(struct cldap_socket *cldap) */ static void cldap_request_timeout(struct tevent_context *event_ctx, struct tevent_timer *te, struct timeval t, - void *private) + void *private_data) { - struct cldap_request *req = talloc_get_type(private, struct cldap_request); + struct cldap_request *req = talloc_get_type(private_data, struct cldap_request); /* possibly try again */ if (req->num_retries != 0) { @@ -224,9 +224,9 @@ static void cldap_socket_send(struct cldap_socket *cldap) handle fd events on a cldap_socket */ static void cldap_socket_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct cldap_socket *cldap = talloc_get_type(private, struct cldap_socket); + struct cldap_socket *cldap = talloc_get_type(private_data, struct cldap_socket); if (flags & EVENT_FD_WRITE) { cldap_socket_send(cldap); } @@ -282,10 +282,10 @@ failed: NTSTATUS cldap_set_incoming_handler(struct cldap_socket *cldap, void (*handler)(struct cldap_socket *, struct ldap_message *, struct socket_address *), - void *private) + void *private_data) { cldap->incoming.handler = handler; - cldap->incoming.private = private; + cldap->incoming.private = private_data; EVENT_FD_READABLE(cldap->fde); return NT_STATUS_OK; } diff --git a/source4/libcli/cldap/cldap.h b/source4/libcli/cldap/cldap.h index 17e88716c5..1841e82540 100644 --- a/source4/libcli/cldap/cldap.h +++ b/source4/libcli/cldap/cldap.h @@ -117,7 +117,7 @@ struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx, NTSTATUS cldap_set_incoming_handler(struct cldap_socket *cldap, void (*handler)(struct cldap_socket *, struct ldap_message *, struct socket_address *), - void *private); + void *private_data); struct cldap_request *cldap_search_send(struct cldap_socket *cldap, struct cldap_search *io); NTSTATUS cldap_search_recv(struct cldap_request *req, TALLOC_CTX *mem_ctx, -- cgit From 8d379008283415a9895ea9b0f9acc262f5859a8d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:23:24 +0100 Subject: s4:libcli/clilist.c: s/private/private_data metze --- source4/libcli/clilist.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source4/libcli/clilist.c b/source4/libcli/clilist.c index 5d43606c61..65ee0a8303 100644 --- a/source4/libcli/clilist.c +++ b/source4/libcli/clilist.c @@ -73,9 +73,9 @@ static bool interpret_long_filename(enum smb_search_data_level level, } /* callback function used for trans2 search */ -static bool smbcli_list_new_callback(void *private, const union smb_search_data *file) +static bool smbcli_list_new_callback(void *private_data, const union smb_search_data *file) { - struct search_private *state = (struct search_private*) private; + struct search_private *state = (struct search_private*) private_data; struct clilist_file_info *tdl; /* add file info to the dirlist pool */ @@ -231,9 +231,9 @@ static bool interpret_short_filename(enum smb_search_data_level level, } /* callback function used for smb_search */ -static bool smbcli_list_old_callback(void *private, const union smb_search_data *file) +static bool smbcli_list_old_callback(void *private_data, const union smb_search_data *file) { - struct search_private *state = (struct search_private*) private; + struct search_private *state = (struct search_private*) private_data; struct clilist_file_info *tdl; /* add file info to the dirlist pool */ -- cgit From 0db079b9eb9446f63a3b1c08cd6de34faa0f6088 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:24:00 +0100 Subject: s4:libcli/dgram: s/private/private_data metze --- source4/libcli/dgram/dgramsocket.c | 8 ++++---- source4/libcli/dgram/libdgram.h | 6 +++--- source4/libcli/dgram/mailslot.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source4/libcli/dgram/dgramsocket.c b/source4/libcli/dgram/dgramsocket.c index 5c878f19fa..1a5cc6dce8 100644 --- a/source4/libcli/dgram/dgramsocket.c +++ b/source4/libcli/dgram/dgramsocket.c @@ -140,9 +140,9 @@ static void dgm_socket_send(struct nbt_dgram_socket *dgmsock) handle fd events on a nbt_dgram_socket */ static void dgm_socket_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct nbt_dgram_socket *dgmsock = talloc_get_type(private, + struct nbt_dgram_socket *dgmsock = talloc_get_type(private_data, struct nbt_dgram_socket); if (flags & EVENT_FD_WRITE) { dgm_socket_send(dgmsock); @@ -200,10 +200,10 @@ NTSTATUS dgram_set_incoming_handler(struct nbt_dgram_socket *dgmsock, void (*handler)(struct nbt_dgram_socket *, struct nbt_dgram_packet *, struct socket_address *), - void *private) + void *private_data) { dgmsock->incoming.handler = handler; - dgmsock->incoming.private = private; + dgmsock->incoming.private = private_data; EVENT_FD_READABLE(dgmsock->fde); return NT_STATUS_OK; } diff --git a/source4/libcli/dgram/libdgram.h b/source4/libcli/dgram/libdgram.h index 8060d8cf53..b303afa6dc 100644 --- a/source4/libcli/dgram/libdgram.h +++ b/source4/libcli/dgram/libdgram.h @@ -91,7 +91,7 @@ NTSTATUS dgram_set_incoming_handler(struct nbt_dgram_socket *dgmsock, void (*handler)(struct nbt_dgram_socket *, struct nbt_dgram_packet *, struct socket_address *), - void *private); + void *private_data); struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx, struct tevent_context *event_ctx, struct smb_iconv_convenience *); @@ -102,11 +102,11 @@ struct dgram_mailslot_handler *dgram_mailslot_find(struct nbt_dgram_socket *dgms struct dgram_mailslot_handler *dgram_mailslot_listen(struct nbt_dgram_socket *dgmsock, const char *mailslot_name, dgram_mailslot_handler_t handler, - void *private); + void *private_data); struct dgram_mailslot_handler *dgram_mailslot_temp(struct nbt_dgram_socket *dgmsock, const char *mailslot_name, dgram_mailslot_handler_t handler, - void *private); + void *private_data); DATA_BLOB dgram_mailslot_data(struct nbt_dgram_packet *dgram); diff --git a/source4/libcli/dgram/mailslot.c b/source4/libcli/dgram/mailslot.c index 3bd587aa54..bc607e3b24 100644 --- a/source4/libcli/dgram/mailslot.c +++ b/source4/libcli/dgram/mailslot.c @@ -52,7 +52,7 @@ static int dgram_mailslot_destructor(struct dgram_mailslot_handler *dgmslot) struct dgram_mailslot_handler *dgram_mailslot_listen(struct nbt_dgram_socket *dgmsock, const char *mailslot_name, dgram_mailslot_handler_t handler, - void *private) + void *private_data) { struct dgram_mailslot_handler *dgmslot; @@ -66,7 +66,7 @@ struct dgram_mailslot_handler *dgram_mailslot_listen(struct nbt_dgram_socket *dg return NULL; } dgmslot->handler = handler; - dgmslot->private = private; + dgmslot->private = private_data; DLIST_ADD(dgmsock->mailslot_handlers, dgmslot); talloc_set_destructor(dgmslot, dgram_mailslot_destructor); @@ -115,7 +115,7 @@ const char *dgram_mailslot_name(struct nbt_dgram_packet *packet) struct dgram_mailslot_handler *dgram_mailslot_temp(struct nbt_dgram_socket *dgmsock, const char *mailslot_name, dgram_mailslot_handler_t handler, - void *private) + void *private_data) { char *name; int i; @@ -131,7 +131,7 @@ struct dgram_mailslot_handler *dgram_mailslot_temp(struct nbt_dgram_socket *dgms talloc_free(name); return NULL; } - dgmslot = dgram_mailslot_listen(dgmsock, name, handler, private); + dgmslot = dgram_mailslot_listen(dgmsock, name, handler, private_data); talloc_free(name); if (dgmslot != NULL) { return dgmslot; -- cgit From 1ee4bbec1a573be26360568275bd3882837dca9b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:24:59 +0100 Subject: s4:libcli/raw: s/private/private_data metze --- source4/libcli/raw/clioplock.c | 4 ++-- source4/libcli/raw/clitransport.c | 26 +++++++++++++------------- source4/libcli/raw/interfaces.h | 2 +- source4/libcli/raw/libcliraw.h | 8 ++++---- source4/libcli/raw/rawsearch.c | 28 ++++++++++++++-------------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/source4/libcli/raw/clioplock.c b/source4/libcli/raw/clioplock.c index 47ffb6dd31..5005f878af 100644 --- a/source4/libcli/raw/clioplock.c +++ b/source4/libcli/raw/clioplock.c @@ -55,8 +55,8 @@ set the oplock handler for a connection ****************************************************************************/ _PUBLIC_ void smbcli_oplock_handler(struct smbcli_transport *transport, bool (*handler)(struct smbcli_transport *, uint16_t, uint16_t, uint8_t, void *), - void *private) + void *private_data) { transport->oplock.handler = handler; - transport->oplock.private = private; + transport->oplock.private = private_data; } diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c index 22e2552edc..e6f27b1159 100644 --- a/source4/libcli/raw/clitransport.c +++ b/source4/libcli/raw/clitransport.c @@ -35,9 +35,9 @@ */ static void smbcli_transport_event_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct smbcli_transport *transport = talloc_get_type(private, + struct smbcli_transport *transport = talloc_get_type(private_data, struct smbcli_transport); if (flags & EVENT_FD_READ) { packet_recv(transport->packet); @@ -61,13 +61,13 @@ static int transport_destructor(struct smbcli_transport *transport) /* handle receive errors */ -static void smbcli_transport_error(void *private, NTSTATUS status) +static void smbcli_transport_error(void *private_data, NTSTATUS status) { - struct smbcli_transport *transport = talloc_get_type(private, struct smbcli_transport); + struct smbcli_transport *transport = talloc_get_type(private_data, struct smbcli_transport); smbcli_transport_dead(transport, status); } -static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob); +static NTSTATUS smbcli_transport_finish_recv(void *private_data, DATA_BLOB blob); /* create a transport structure based on an established socket @@ -308,9 +308,9 @@ again: } static void idle_handler(struct tevent_context *ev, - struct tevent_timer *te, struct timeval t, void *private) + struct tevent_timer *te, struct timeval t, void *private_data) { - struct smbcli_transport *transport = talloc_get_type(private, + struct smbcli_transport *transport = talloc_get_type(private_data, struct smbcli_transport); struct timeval next = timeval_add(&t, 0, transport->idle.period); transport->socket->event.te = event_add_timed(transport->socket->event.ctx, @@ -327,10 +327,10 @@ static void idle_handler(struct tevent_context *ev, _PUBLIC_ void smbcli_transport_idle_handler(struct smbcli_transport *transport, void (*idle_func)(struct smbcli_transport *, void *), uint64_t period, - void *private) + void *private_data) { transport->idle.func = idle_func; - transport->idle.private = private; + transport->idle.private = private_data; transport->idle.period = period; if (transport->socket->event.te != NULL) { @@ -347,9 +347,9 @@ _PUBLIC_ void smbcli_transport_idle_handler(struct smbcli_transport *transport, we have a full request in our receive buffer - match it to a pending request and process */ -static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob) +static NTSTATUS smbcli_transport_finish_recv(void *private_data, DATA_BLOB blob) { - struct smbcli_transport *transport = talloc_get_type(private, + struct smbcli_transport *transport = talloc_get_type(private_data, struct smbcli_transport); uint8_t *buffer, *hdr, *vwv; int len; @@ -542,9 +542,9 @@ _PUBLIC_ bool smbcli_transport_process(struct smbcli_transport *transport) handle timeouts of individual smb requests */ static void smbcli_timeout_handler(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct smbcli_request *req = talloc_get_type(private, struct smbcli_request); + struct smbcli_request *req = talloc_get_type(private_data, struct smbcli_request); if (req->state == SMBCLI_REQUEST_RECV) { DLIST_REMOVE(req->transport->pending_recv, req); diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h index c2269cbbc2..a0584c0aa4 100644 --- a/source4/libcli/raw/interfaces.h +++ b/source4/libcli/raw/interfaces.h @@ -2698,7 +2698,7 @@ union smb_search_data { }; /* Callback function passed to the raw search interface. */ -typedef bool (*smbcli_search_callback)(void *private, const union smb_search_data *file); +typedef bool (*smbcli_search_callback)(void *private_data, const union smb_search_data *file); enum smb_search_close_level {RAW_FINDCLOSE_GENERIC, RAW_FINDCLOSE_FCLOSE, RAW_FINDCLOSE_FINDCLOSE}; diff --git a/source4/libcli/raw/libcliraw.h b/source4/libcli/raw/libcliraw.h index 0ab6f5650c..1b9cba8e38 100644 --- a/source4/libcli/raw/libcliraw.h +++ b/source4/libcli/raw/libcliraw.h @@ -149,7 +149,7 @@ struct smbcli_transport { struct { /* a oplock break request handler */ bool (*handler)(struct smbcli_transport *transport, - uint16_t tid, uint16_t fnum, uint8_t level, void *private); + uint16_t tid, uint16_t fnum, uint8_t level, void *private_data); /* private data passed to the oplock handler */ void *private; } oplock; @@ -328,11 +328,11 @@ struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session, TALLOC_CTX NTSTATUS smb_raw_tcon(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_tcon *parms); void smbcli_oplock_handler(struct smbcli_transport *transport, bool (*handler)(struct smbcli_transport *, uint16_t, uint16_t, uint8_t, void *), - void *private); + void *private_data); void smbcli_transport_idle_handler(struct smbcli_transport *transport, void (*idle_func)(struct smbcli_transport *, void *), uint64_t period, - void *private); + void *private_data); NTSTATUS smbcli_request_simple_recv(struct smbcli_request *req); bool smbcli_oplock_ack(struct smbcli_tree *tree, uint16_t fnum, uint16_t ack_level); NTSTATUS smb_raw_open(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_open *parms); @@ -366,7 +366,7 @@ struct smbcli_request *smb_raw_echo_send(struct smbcli_transport *transport, struct smb_echo *p); NTSTATUS smb_raw_search_first(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, - union smb_search_first *io, void *private, + union smb_search_first *io, void *private_data, smbcli_search_callback callback); NTSTATUS smb_raw_flush(struct smbcli_tree *tree, union smb_flush *parms); diff --git a/source4/libcli/raw/rawsearch.c b/source4/libcli/raw/rawsearch.c index 99141574e2..9c90d45492 100644 --- a/source4/libcli/raw/rawsearch.c +++ b/source4/libcli/raw/rawsearch.c @@ -28,7 +28,7 @@ static void smb_raw_search_backend(struct smbcli_request *req, TALLOC_CTX *mem_ctx, uint16_t count, - void *private, + void *private_data, smbcli_search_callback callback) { @@ -57,7 +57,7 @@ static void smb_raw_search_backend(struct smbcli_request *req, search_data.search.size = IVAL(p, 26); smbcli_req_pull_ascii(&req->in.bufinfo, mem_ctx, &name, p+30, 13, STR_ASCII); search_data.search.name = name; - if (!callback(private, &search_data)) { + if (!callback(private_data, &search_data)) { break; } p += 43; @@ -69,7 +69,7 @@ static void smb_raw_search_backend(struct smbcli_request *req, ****************************************************************************/ static NTSTATUS smb_raw_search_first_old(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, - union smb_search_first *io, void *private, + union smb_search_first *io, void *private_data, smbcli_search_callback callback) { @@ -99,7 +99,7 @@ static NTSTATUS smb_raw_search_first_old(struct smbcli_tree *tree, if (NT_STATUS_IS_OK(req->status)) { io->search_first.out.count = SVAL(req->in.vwv, VWV(0)); - smb_raw_search_backend(req, mem_ctx, io->search_first.out.count, private, callback); + smb_raw_search_backend(req, mem_ctx, io->search_first.out.count, private_data, callback); } return smbcli_request_destroy(req); @@ -110,7 +110,7 @@ static NTSTATUS smb_raw_search_first_old(struct smbcli_tree *tree, ****************************************************************************/ static NTSTATUS smb_raw_search_next_old(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, - union smb_search_next *io, void *private, + union smb_search_next *io, void *private_data, smbcli_search_callback callback) { @@ -146,7 +146,7 @@ static NTSTATUS smb_raw_search_next_old(struct smbcli_tree *tree, if (NT_STATUS_IS_OK(req->status)) { io->search_next.out.count = SVAL(req->in.vwv, VWV(0)); - smb_raw_search_backend(req, mem_ctx, io->search_next.out.count, private, callback); + smb_raw_search_backend(req, mem_ctx, io->search_next.out.count, private_data, callback); } return smbcli_request_destroy(req); @@ -682,7 +682,7 @@ static NTSTATUS smb_raw_t2search_backend(struct smbcli_tree *tree, uint16_t flags, int16_t count, DATA_BLOB *blob, - void *private, + void *private_data, smbcli_search_callback callback) { @@ -703,7 +703,7 @@ static NTSTATUS smb_raw_t2search_backend(struct smbcli_tree *tree, /* the callback function can tell us that no more will fit - in that case we stop, but it isn't an error */ - if (!callback(private, &search_data)) { + if (!callback(private_data, &search_data)) { break; } @@ -721,7 +721,7 @@ static NTSTATUS smb_raw_t2search_backend(struct smbcli_tree *tree, */ _PUBLIC_ NTSTATUS smb_raw_search_first(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, - union smb_search_first *io, void *private, + union smb_search_first *io, void *private_data, smbcli_search_callback callback) { DATA_BLOB p_blob, d_blob; @@ -731,7 +731,7 @@ _PUBLIC_ NTSTATUS smb_raw_search_first(struct smbcli_tree *tree, case RAW_SEARCH_SEARCH: case RAW_SEARCH_FFIRST: case RAW_SEARCH_FUNIQUE: - return smb_raw_search_first_old(tree, mem_ctx, io, private, callback); + return smb_raw_search_first_old(tree, mem_ctx, io, private_data, callback); case RAW_SEARCH_TRANS2: break; @@ -760,7 +760,7 @@ _PUBLIC_ NTSTATUS smb_raw_search_first(struct smbcli_tree *tree, status = smb_raw_t2search_backend(tree, mem_ctx, io->generic.data_level, io->t2ffirst.in.flags, io->t2ffirst.out.count, - &d_blob, private, callback); + &d_blob, private_data, callback); return status; } @@ -769,7 +769,7 @@ _PUBLIC_ NTSTATUS smb_raw_search_first(struct smbcli_tree *tree, */ NTSTATUS smb_raw_search_next(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, - union smb_search_next *io, void *private, + union smb_search_next *io, void *private_data, smbcli_search_callback callback) { DATA_BLOB p_blob, d_blob; @@ -778,7 +778,7 @@ NTSTATUS smb_raw_search_next(struct smbcli_tree *tree, switch (io->generic.level) { case RAW_SEARCH_SEARCH: case RAW_SEARCH_FFIRST: - return smb_raw_search_next_old(tree, mem_ctx, io, private, callback); + return smb_raw_search_next_old(tree, mem_ctx, io, private_data, callback); case RAW_SEARCH_FUNIQUE: return NT_STATUS_INVALID_LEVEL; @@ -809,7 +809,7 @@ NTSTATUS smb_raw_search_next(struct smbcli_tree *tree, status = smb_raw_t2search_backend(tree, mem_ctx, io->generic.data_level, io->t2fnext.in.flags, io->t2fnext.out.count, - &d_blob, private, callback); + &d_blob, private_data, callback); return status; } -- cgit From 71e318cf319606828657338ad49d0ad73ba2cc19 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:26:08 +0100 Subject: s4:libcli/smb2: s/private/private_data metze --- source4/libcli/smb2/transport.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/source4/libcli/smb2/transport.c b/source4/libcli/smb2/transport.c index 94ea2586ef..679b085889 100644 --- a/source4/libcli/smb2/transport.c +++ b/source4/libcli/smb2/transport.c @@ -35,9 +35,9 @@ */ static void smb2_transport_event_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct smb2_transport *transport = talloc_get_type(private, + struct smb2_transport *transport = talloc_get_type(private_data, struct smb2_transport); if (flags & EVENT_FD_READ) { packet_recv(transport->packet); @@ -61,14 +61,14 @@ static int transport_destructor(struct smb2_transport *transport) /* handle receive errors */ -static void smb2_transport_error(void *private, NTSTATUS status) +static void smb2_transport_error(void *private_data, NTSTATUS status) { - struct smb2_transport *transport = talloc_get_type(private, + struct smb2_transport *transport = talloc_get_type(private_data, struct smb2_transport); smb2_transport_dead(transport, status); } -static NTSTATUS smb2_transport_finish_recv(void *private, DATA_BLOB blob); +static NTSTATUS smb2_transport_finish_recv(void *private_data, DATA_BLOB blob); /* create a transport structure based on an established socket @@ -181,9 +181,9 @@ static NTSTATUS smb2_handle_oplock_break(struct smb2_transport *transport, we have a full request in our receive buffer - match it to a pending request and process */ -static NTSTATUS smb2_transport_finish_recv(void *private, DATA_BLOB blob) +static NTSTATUS smb2_transport_finish_recv(void *private_data, DATA_BLOB blob) { - struct smb2_transport *transport = talloc_get_type(private, + struct smb2_transport *transport = talloc_get_type(private_data, struct smb2_transport); uint8_t *buffer, *hdr; int len; @@ -302,9 +302,9 @@ error: handle timeouts of individual smb requests */ static void smb2_timeout_handler(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct smb2_request *req = talloc_get_type(private, struct smb2_request); + struct smb2_request *req = talloc_get_type(private_data, struct smb2_request); if (req->state == SMB2_REQUEST_RECV) { DLIST_REMOVE(req->transport->pending_recv, req); @@ -381,9 +381,9 @@ void smb2_transport_send(struct smb2_request *req) } static void idle_handler(struct tevent_context *ev, - struct tevent_timer *te, struct timeval t, void *private) + struct tevent_timer *te, struct timeval t, void *private_data) { - struct smb2_transport *transport = talloc_get_type(private, + struct smb2_transport *transport = talloc_get_type(private_data, struct smb2_transport); struct timeval next = timeval_add(&t, 0, transport->idle.period); transport->socket->event.te = event_add_timed(transport->socket->event.ctx, @@ -400,10 +400,10 @@ static void idle_handler(struct tevent_context *ev, void smb2_transport_idle_handler(struct smb2_transport *transport, void (*idle_func)(struct smb2_transport *, void *), uint64_t period, - void *private) + void *private_data) { transport->idle.func = idle_func; - transport->idle.private = private; + transport->idle.private = private_data; transport->idle.period = period; if (transport->socket->event.te != NULL) { -- cgit From 58ca4d4e3184580fbd895cec80d01b01768ae378 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:26:33 +0100 Subject: s4:libcli/wrepl: s/private/private_data metze --- source4/libcli/wrepl/winsrepl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c index 61bb10bf6a..48a6abba9d 100644 --- a/source4/libcli/wrepl/winsrepl.c +++ b/source4/libcli/wrepl/winsrepl.c @@ -81,9 +81,9 @@ static void wrepl_request_timeout_handler(struct tevent_context *ev, struct teve /* handle recv events */ -static NTSTATUS wrepl_finish_recv(void *private, DATA_BLOB packet_blob_in) +static NTSTATUS wrepl_finish_recv(void *private_data, DATA_BLOB packet_blob_in) { - struct wrepl_socket *wrepl_socket = talloc_get_type(private, struct wrepl_socket); + struct wrepl_socket *wrepl_socket = talloc_get_type(private_data, struct wrepl_socket); struct wrepl_request *req = wrepl_socket->recv_queue; DATA_BLOB blob; enum ndr_err_code ndr_err; @@ -123,9 +123,9 @@ static NTSTATUS wrepl_finish_recv(void *private, DATA_BLOB packet_blob_in) handler for winrepl events */ static void wrepl_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct wrepl_socket *wrepl_socket = talloc_get_type(private, + struct wrepl_socket *wrepl_socket = talloc_get_type(private_data, struct wrepl_socket); if (flags & EVENT_FD_READ) { packet_recv(wrepl_socket->packet); @@ -136,9 +136,9 @@ static void wrepl_handler(struct tevent_context *ev, struct tevent_fd *fde, } } -static void wrepl_error(void *private, NTSTATUS status) +static void wrepl_error(void *private_data, NTSTATUS status) { - struct wrepl_socket *wrepl_socket = talloc_get_type(private, + struct wrepl_socket *wrepl_socket = talloc_get_type(private_data, struct wrepl_socket); wrepl_socket_dead(wrepl_socket, status); } -- cgit From c005bbddb713c25f3201d6007e6ef1114084d041 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:27:04 +0100 Subject: s4:libnet/: s/private/private_data metze --- source4/libnet/libnet_samdump.c | 6 +++--- source4/libnet/libnet_samdump_keytab.c | 6 +++--- source4/libnet/libnet_samsync.h | 4 ++-- source4/libnet/libnet_samsync_ldb.c | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source4/libnet/libnet_samdump.c b/source4/libnet/libnet_samdump.c index e259d4df40..21361f1eca 100644 --- a/source4/libnet/libnet_samdump.c +++ b/source4/libnet/libnet_samdump.c @@ -103,14 +103,14 @@ static NTSTATUS vampire_samdump_handle_trusted_domain(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } -static NTSTATUS libnet_samdump_fn(TALLOC_CTX *mem_ctx, - void *private, +static NTSTATUS libnet_samdump_fn(TALLOC_CTX *mem_ctx, + void *private_data, enum netr_SamDatabaseID database, struct netr_DELTA_ENUM *delta, char **error_string) { NTSTATUS nt_status = NT_STATUS_OK; - struct samdump_state *samdump_state = (struct samdump_state *)private; + struct samdump_state *samdump_state = (struct samdump_state *)private_data; *error_string = NULL; switch (delta->delta_type) { diff --git a/source4/libnet/libnet_samdump_keytab.c b/source4/libnet/libnet_samdump_keytab.c index 2218d20f6b..a1846b81da 100644 --- a/source4/libnet/libnet_samdump_keytab.c +++ b/source4/libnet/libnet_samdump_keytab.c @@ -74,14 +74,14 @@ struct libnet_samdump_keytab_data { struct loadparm_context *lp_ctx; }; -static NTSTATUS libnet_samdump_keytab_fn(TALLOC_CTX *mem_ctx, - void *private, +static NTSTATUS libnet_samdump_keytab_fn(TALLOC_CTX *mem_ctx, + void *private_data, enum netr_SamDatabaseID database, struct netr_DELTA_ENUM *delta, char **error_string) { NTSTATUS nt_status = NT_STATUS_OK; - struct libnet_samdump_keytab_data *data = private; + struct libnet_samdump_keytab_data *data = private_data; *error_string = NULL; switch (delta->delta_type) { case NETR_DELTA_USER: diff --git a/source4/libnet/libnet_samsync.h b/source4/libnet/libnet_samsync.h index d2ac30fe14..c2295f3957 100644 --- a/source4/libnet/libnet_samsync.h +++ b/source4/libnet/libnet_samsync.h @@ -34,11 +34,11 @@ struct libnet_SamSync { const char *binding_string; bool rid_crypt; NTSTATUS (*init_fn)(TALLOC_CTX *mem_ctx, - void *private, + void *private_data, struct libnet_SamSync_state *samsync_state, char **error_string); NTSTATUS (*delta_fn)(TALLOC_CTX *mem_ctx, - void *private, + void *private_data, enum netr_SamDatabaseID database, struct netr_DELTA_ENUM *delta, char **error_string); diff --git a/source4/libnet/libnet_samsync_ldb.c b/source4/libnet/libnet_samsync_ldb.c index 160b4b3e19..e24c54a8c2 100644 --- a/source4/libnet/libnet_samsync_ldb.c +++ b/source4/libnet/libnet_samsync_ldb.c @@ -1052,13 +1052,13 @@ static NTSTATUS samsync_ldb_delete_account(TALLOC_CTX *mem_ctx, } static NTSTATUS libnet_samsync_ldb_fn(TALLOC_CTX *mem_ctx, - void *private, + void *private_data, enum netr_SamDatabaseID database, struct netr_DELTA_ENUM *delta, char **error_string) { NTSTATUS nt_status = NT_STATUS_OK; - struct samsync_ldb_state *state = talloc_get_type(private, struct samsync_ldb_state); + struct samsync_ldb_state *state = talloc_get_type(private_data, struct samsync_ldb_state); *error_string = NULL; switch (delta->delta_type) { @@ -1172,11 +1172,11 @@ static NTSTATUS libnet_samsync_ldb_fn(TALLOC_CTX *mem_ctx, } static NTSTATUS libnet_samsync_ldb_init(TALLOC_CTX *mem_ctx, - void *private, + void *private_data, struct libnet_SamSync_state *samsync_state, char **error_string) { - struct samsync_ldb_state *state = talloc_get_type(private, struct samsync_ldb_state); + struct samsync_ldb_state *state = talloc_get_type(private_data, struct samsync_ldb_state); const char *server = dcerpc_server_name(samsync_state->netlogon_pipe); char *ldap_url; -- cgit From 74e783bf5850658124d60503d7b5d2fba8a9bb87 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:27:33 +0100 Subject: s4:librpc/rpc: s/private/private_data metze --- source4/librpc/rpc/dcerpc.c | 4 ++-- source4/librpc/rpc/dcerpc_connect.c | 4 ++-- source4/librpc/rpc/dcerpc_sock.c | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c index 45c4e78cf1..7a568d3c9e 100644 --- a/source4/librpc/rpc/dcerpc.c +++ b/source4/librpc/rpc/dcerpc.c @@ -653,9 +653,9 @@ static void dcerpc_bind_recv_handler(struct rpc_request *req, handle timeouts of individual dcerpc requests */ static void dcerpc_timeout_handler(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct rpc_request *req = talloc_get_type(private, struct rpc_request); + struct rpc_request *req = talloc_get_type(private_data, struct rpc_request); if (req->ignore_timeout) { dcerpc_req_dequeue(req); diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c index 9b8503c04b..0f9fbe0abc 100644 --- a/source4/librpc/rpc/dcerpc_connect.c +++ b/source4/librpc/rpc/dcerpc_connect.c @@ -709,9 +709,9 @@ static void continue_pipe_auth(struct composite_context *ctx) handle timeouts of a dcerpc connect */ static void dcerpc_connect_timeout_handler(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct composite_context *c = talloc_get_type(private, struct composite_context); + struct composite_context *c = talloc_get_type(private_data, struct composite_context); composite_error(c, NT_STATUS_IO_TIMEOUT); } diff --git a/source4/librpc/rpc/dcerpc_sock.c b/source4/librpc/rpc/dcerpc_sock.c index 689249288f..64a5b92e90 100644 --- a/source4/librpc/rpc/dcerpc_sock.c +++ b/source4/librpc/rpc/dcerpc_sock.c @@ -85,9 +85,9 @@ static void sock_dead(struct dcerpc_connection *p, NTSTATUS status) /* handle socket recv errors */ -static void sock_error_handler(void *private, NTSTATUS status) +static void sock_error_handler(void *private_data, NTSTATUS status) { - struct dcerpc_connection *p = talloc_get_type(private, + struct dcerpc_connection *p = talloc_get_type(private_data, struct dcerpc_connection); sock_dead(p, status); } @@ -95,7 +95,7 @@ static void sock_error_handler(void *private, NTSTATUS status) /* check if a blob is a complete packet */ -static NTSTATUS sock_complete_packet(void *private, DATA_BLOB blob, size_t *size) +static NTSTATUS sock_complete_packet(void *private_data, DATA_BLOB blob, size_t *size) { if (blob.length < DCERPC_FRAG_LEN_OFFSET+2) { return STATUS_MORE_ENTRIES; @@ -110,9 +110,9 @@ static NTSTATUS sock_complete_packet(void *private, DATA_BLOB blob, size_t *size /* process recv requests */ -static NTSTATUS sock_process_recv(void *private, DATA_BLOB blob) +static NTSTATUS sock_process_recv(void *private_data, DATA_BLOB blob) { - struct dcerpc_connection *p = talloc_get_type(private, + struct dcerpc_connection *p = talloc_get_type(private_data, struct dcerpc_connection); struct sock_private *sock = (struct sock_private *)p->transport.private_data; sock->pending_reads--; @@ -127,9 +127,9 @@ static NTSTATUS sock_process_recv(void *private, DATA_BLOB blob) called when a IO is triggered by the events system */ static void sock_io_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct dcerpc_connection *p = talloc_get_type(private, + struct dcerpc_connection *p = talloc_get_type(private_data, struct dcerpc_connection); struct sock_private *sock = (struct sock_private *)p->transport.private_data; -- cgit From c463bc127c911dcc3177e208931819ffc2f4fadb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:28:05 +0100 Subject: s4:ntp_signd: s/private/private_data metze --- source4/ntp_signd/ntp_signd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source4/ntp_signd/ntp_signd.c b/source4/ntp_signd/ntp_signd.c index 575be1e97e..3040716897 100644 --- a/source4/ntp_signd/ntp_signd.c +++ b/source4/ntp_signd/ntp_signd.c @@ -110,9 +110,9 @@ static NTSTATUS signing_failure(struct ntp_signd_connection *ntp_signdconn, /* receive a full packet on a NTP_SIGND connection */ -static NTSTATUS ntp_signd_recv(void *private, DATA_BLOB wrapped_input) +static NTSTATUS ntp_signd_recv(void *private_data, DATA_BLOB wrapped_input) { - struct ntp_signd_connection *ntp_signdconn = talloc_get_type(private, + struct ntp_signd_connection *ntp_signdconn = talloc_get_type(private_data, struct ntp_signd_connection); NTSTATUS status = NT_STATUS_UNSUCCESSFUL; TALLOC_CTX *tmp_ctx = talloc_new(ntp_signdconn); @@ -271,9 +271,9 @@ static void ntp_signd_recv_handler(struct stream_connection *conn, uint16_t flag /* called on a tcp recv error */ -static void ntp_signd_recv_error(void *private, NTSTATUS status) +static void ntp_signd_recv_error(void *private_data, NTSTATUS status) { - struct ntp_signd_connection *ntp_signdconn = talloc_get_type(private, struct ntp_signd_connection); + struct ntp_signd_connection *ntp_signdconn = talloc_get_type(private_data, struct ntp_signd_connection); ntp_signd_terminate_connection(ntp_signdconn, nt_errstr(status)); } -- cgit From 50ad5239fd13fcec2b18eaa2ced55fd0e1b00a65 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:29:13 +0100 Subject: s4:ntvfs: s/private/private_data metze --- source4/ntvfs/ntvfs.h | 10 +++++----- source4/ntvfs/ntvfs_interface.c | 32 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/source4/ntvfs/ntvfs.h b/source4/ntvfs/ntvfs.h index 5e86030efa..b62595967f 100644 --- a/source4/ntvfs/ntvfs.h +++ b/source4/ntvfs/ntvfs.h @@ -55,7 +55,7 @@ struct ntvfs_ops { /* async_setup - called when a backend is processing a async request */ NTSTATUS (*async_setup)(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private); + void *private_data); /* filesystem operations */ NTSTATUS (*fsinfo)(struct ntvfs_module_context *ntvfs, @@ -94,12 +94,12 @@ struct ntvfs_ops { /* directory search */ NTSTATUS (*search_first)(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - union smb_search_first *io, void *private, - bool (*callback)(void *private, const union smb_search_data *file)); + union smb_search_first *io, void *private_data, + bool (*callback)(void *private_data, const union smb_search_data *file)); NTSTATUS (*search_next)(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - union smb_search_next *io, void *private, - bool (*callback)(void *private, const union smb_search_data *file)); + union smb_search_next *io, void *private_data, + bool (*callback)(void *private_data, const union smb_search_data *file)); NTSTATUS (*search_close)(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_search_close *io); diff --git a/source4/ntvfs/ntvfs_interface.c b/source4/ntvfs/ntvfs_interface.c index c348558fca..6d3fe55c06 100644 --- a/source4/ntvfs/ntvfs_interface.c +++ b/source4/ntvfs/ntvfs_interface.c @@ -46,13 +46,13 @@ NTSTATUS ntvfs_disconnect(struct ntvfs_context *ntvfs_ctx) /* async setup - called by a backend that wants to setup any state for a async request */ -NTSTATUS ntvfs_async_setup(struct ntvfs_request *req, void *private) +NTSTATUS ntvfs_async_setup(struct ntvfs_request *req, void *private_data) { struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->async_setup) { return NT_STATUS_NOT_IMPLEMENTED; } - return ntvfs->ops->async_setup(ntvfs, req, private); + return ntvfs->ops->async_setup(ntvfs, req, private_data); } /* filesystem operations */ @@ -148,24 +148,24 @@ NTSTATUS ntvfs_copy(struct ntvfs_request *req, struct smb_copy *cp) } /* directory search */ -NTSTATUS ntvfs_search_first(struct ntvfs_request *req, union smb_search_first *io, void *private, - bool ntvfs_callback(void *private, const union smb_search_data *file)) +NTSTATUS ntvfs_search_first(struct ntvfs_request *req, union smb_search_first *io, void *private_data, + bool ntvfs_callback(void *private_data, const union smb_search_data *file)) { struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->search_first) { return NT_STATUS_NOT_IMPLEMENTED; } - return ntvfs->ops->search_first(ntvfs, req, io, private, ntvfs_callback); + return ntvfs->ops->search_first(ntvfs, req, io, private_data, ntvfs_callback); } -NTSTATUS ntvfs_search_next(struct ntvfs_request *req, union smb_search_next *io, void *private, - bool ntvfs_callback(void *private, const union smb_search_data *file)) +NTSTATUS ntvfs_search_next(struct ntvfs_request *req, union smb_search_next *io, void *private_data, + bool ntvfs_callback(void *private_data, const union smb_search_data *file)) { struct ntvfs_module_context *ntvfs = req->ctx->modules; if (!ntvfs->ops->search_next) { return NT_STATUS_NOT_IMPLEMENTED; } - return ntvfs->ops->search_next(ntvfs, req, io, private, ntvfs_callback); + return ntvfs->ops->search_next(ntvfs, req, io, private_data, ntvfs_callback); } NTSTATUS ntvfs_search_close(struct ntvfs_request *req, union smb_search_close *io) @@ -354,12 +354,12 @@ NTSTATUS ntvfs_next_disconnect(struct ntvfs_module_context *ntvfs) /* async_setup - called when setting up for a async request */ NTSTATUS ntvfs_next_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { if (!ntvfs->next || !ntvfs->next->ops->async_setup) { return NT_STATUS_NOT_IMPLEMENTED; } - return ntvfs->next->ops->async_setup(ntvfs->next, req, private); + return ntvfs->next->ops->async_setup(ntvfs->next, req, private_data); } /* filesystem operations */ @@ -468,24 +468,24 @@ NTSTATUS ntvfs_next_open(struct ntvfs_module_context *ntvfs, /* directory search */ NTSTATUS ntvfs_next_search_first(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - union smb_search_first *io, void *private, - bool (*callback)(void *private, const union smb_search_data *file)) + union smb_search_first *io, void *private_data, + bool (*callback)(void *private_data, const union smb_search_data *file)) { if (!ntvfs->next || !ntvfs->next->ops->search_first) { return NT_STATUS_NOT_IMPLEMENTED; } - return ntvfs->next->ops->search_first(ntvfs->next, req, io, private, callback); + return ntvfs->next->ops->search_first(ntvfs->next, req, io, private_data, callback); } NTSTATUS ntvfs_next_search_next(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - union smb_search_next *io, void *private, - bool (*callback)(void *private, const union smb_search_data *file)) + union smb_search_next *io, void *private_data, + bool (*callback)(void *private_data, const union smb_search_data *file)) { if (!ntvfs->next || !ntvfs->next->ops->search_next) { return NT_STATUS_NOT_IMPLEMENTED; } - return ntvfs->next->ops->search_next(ntvfs->next, req, io, private, callback); + return ntvfs->next->ops->search_next(ntvfs->next, req, io, private_data, callback); } NTSTATUS ntvfs_next_search_close(struct ntvfs_module_context *ntvfs, -- cgit From 24fb16f1f6d1e5ecbc1c6468bc1f35e7ecb3b0aa Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:30:38 +0100 Subject: s4:ntvfs/cifs/: s/private/p metze --- source4/ntvfs/cifs/vfs_cifs.c | 216 +++++++++++++++++++++--------------------- 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index e615401e51..2ac60ee71b 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -64,14 +64,14 @@ struct async_info { }; #define CHECK_UPSTREAM_OPEN do { \ - if (! private->transport->socket->sock) { \ + if (! p->transport->socket->sock) { \ req->async_states->state|=NTVFS_ASYNC_STATE_CLOSE; \ return NT_STATUS_CONNECTION_DISCONNECTED; \ } \ } while(0) #define SETUP_PID do { \ - private->tree->session->pid = req->smbpid; \ + p->tree->session->pid = req->smbpid; \ CHECK_UPSTREAM_OPEN; \ } while(0) @@ -110,12 +110,12 @@ struct async_info { */ static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private) { - struct cvfs_private *private = p_private; + struct cvfs_private *p = p_private; NTSTATUS status; struct ntvfs_handle *h = NULL; struct cvfs_file *f; - for (f=private->files; f; f=f->next) { + for (f=p->files; f; f=f->next) { if (f->fnum != fnum) continue; h = f->h; break; @@ -127,7 +127,7 @@ static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin } DEBUG(5,("vfs_cifs: sending oplock break level %d for fnum %d\n", level, fnum)); - status = ntvfs_send_oplock_break(private->ntvfs, h, level); + status = ntvfs_send_oplock_break(p->ntvfs, h, level); if (!NT_STATUS_IS_OK(status)) return false; return true; } @@ -139,7 +139,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { NTSTATUS status; - struct cvfs_private *private; + struct cvfs_private *p; const char *host, *user, *pass, *domain, *remote_share; struct smb_composite_connect io; struct composite_context *creq; @@ -163,12 +163,12 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, machine_account = share_bool_option(scfg, CIFS_USE_MACHINE_ACCT, CIFS_USE_MACHINE_ACCT_DEFAULT); - private = talloc_zero(ntvfs, struct cvfs_private); - if (!private) { + p = talloc_zero(ntvfs, struct cvfs_private); + if (!p) { return NT_STATUS_NO_MEMORY; } - ntvfs->private_data = private; + ntvfs->private_data = p; if (!host) { DEBUG(1,("CIFS backend: You must supply server\n")); @@ -177,7 +177,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, if (user && pass) { DEBUG(5, ("CIFS backend: Using specified password\n")); - credentials = cli_credentials_init(private); + credentials = cli_credentials_init(p); if (!credentials) { return NT_STATUS_NO_MEMORY; } @@ -189,7 +189,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, cli_credentials_set_password(credentials, pass, CRED_SPECIFIED); } else if (machine_account) { DEBUG(5, ("CIFS backend: Using machine account\n")); - credentials = cli_credentials_init(private); + credentials = cli_credentials_init(p); cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx); if (domain) { cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED); @@ -217,7 +217,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, io.in.service = remote_share; io.in.service_type = "?????"; io.in.iconv_convenience = lp_iconv_convenience(ntvfs->ctx->lp_ctx); - io.in.gensec_settings = lp_gensec_settings(private, ntvfs->ctx->lp_ctx); + io.in.gensec_settings = lp_gensec_settings(p, ntvfs->ctx->lp_ctx); lp_smbcli_options(ntvfs->ctx->lp_ctx, &io.in.options); lp_smbcli_session_options(ntvfs->ctx->lp_ctx, &io.in.session_options); @@ -225,17 +225,17 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, io.in.options.use_level2_oplocks = false; } - creq = smb_composite_connect_send(&io, private, + creq = smb_composite_connect_send(&io, p, lp_resolve_context(ntvfs->ctx->lp_ctx), ntvfs->ctx->event_ctx); - status = smb_composite_connect_recv(creq, private); + status = smb_composite_connect_recv(creq, p); NT_STATUS_NOT_OK_RETURN(status); - private->tree = io.out.tree; + p->tree = io.out.tree; - private->transport = private->tree->session->transport; + p->transport = p->tree->session->transport; SETUP_PID; - private->ntvfs = ntvfs; + p->ntvfs = ntvfs; ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); @@ -243,11 +243,11 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); /* we need to receive oplock break requests from the server */ - smbcli_oplock_handler(private->transport, oplock_handler, private); + smbcli_oplock_handler(p->transport, oplock_handler, p); - private->map_generic = share_bool_option(scfg, CIFS_MAP_GENERIC, CIFS_MAP_GENERIC_DEFAULT); + p->map_generic = share_bool_option(scfg, CIFS_MAP_GENERIC, CIFS_MAP_GENERIC_DEFAULT); - private->map_trans2 = share_bool_option(scfg, CIFS_MAP_TRANS2, CIFS_MAP_TRANS2_DEFAULT); + p->map_trans2 = share_bool_option(scfg, CIFS_MAP_TRANS2, CIFS_MAP_TRANS2_DEFAULT); return NT_STATUS_OK; } @@ -257,17 +257,17 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, */ static NTSTATUS cvfs_disconnect(struct ntvfs_module_context *ntvfs) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct async_info *a, *an; /* first cleanup pending requests */ - for (a=private->pending; a; a = an) { + for (a=p->pending; a; a = an) { an = a->next; smbcli_request_destroy(a->c_req); talloc_free(a); } - talloc_free(private); + talloc_free(p); ntvfs->private_data = NULL; return NT_STATUS_OK; @@ -307,9 +307,9 @@ static void async_simple(struct smbcli_request *c_req) async->parms = io; \ async->req = req; \ async->f = file; \ - async->cvfs = private; \ + async->cvfs = p; \ async->c_req = c_req; \ - DLIST_ADD(private->pending, async); \ + DLIST_ADD(p->pending, async); \ c_req->async.private = async; \ talloc_set_destructor(async, async_info_destructor); \ } \ @@ -329,7 +329,7 @@ static void async_simple(struct smbcli_request *c_req) static NTSTATUS cvfs_unlink(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_unlink *unl) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; @@ -337,10 +337,10 @@ static NTSTATUS cvfs_unlink(struct ntvfs_module_context *ntvfs, /* see if the front end will allow us to perform this function asynchronously. */ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_unlink(private->tree, unl); + return smb_raw_unlink(p->tree, unl); } - c_req = smb_raw_unlink_send(private->tree, unl); + c_req = smb_raw_unlink_send(p->tree, unl); SIMPLE_ASYNC_TAIL; } @@ -363,7 +363,7 @@ static void async_ioctl(struct smbcli_request *c_req) static NTSTATUS cvfs_ioctl(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_ioctl *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID_AND_FILE; @@ -371,10 +371,10 @@ static NTSTATUS cvfs_ioctl(struct ntvfs_module_context *ntvfs, /* see if the front end will allow us to perform this function asynchronously. */ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_ioctl(private->tree, req, io); + return smb_raw_ioctl(p->tree, req, io); } - c_req = smb_raw_ioctl_send(private->tree, io); + c_req = smb_raw_ioctl_send(p->tree, io); ASYNC_RECV_TAIL(io, async_ioctl); } @@ -385,16 +385,16 @@ static NTSTATUS cvfs_ioctl(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_chkpath *cp) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_chkpath(private->tree, cp); + return smb_raw_chkpath(p->tree, cp); } - c_req = smb_raw_chkpath_send(private->tree, cp); + c_req = smb_raw_chkpath_send(p->tree, cp); SIMPLE_ASYNC_TAIL; } @@ -417,16 +417,16 @@ static void async_qpathinfo(struct smbcli_request *c_req) static NTSTATUS cvfs_qpathinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_pathinfo(private->tree, req, info); + return smb_raw_pathinfo(p->tree, req, info); } - c_req = smb_raw_pathinfo_send(private->tree, info); + c_req = smb_raw_pathinfo_send(p->tree, info); ASYNC_RECV_TAIL(info, async_qpathinfo); } @@ -449,16 +449,16 @@ static void async_qfileinfo(struct smbcli_request *c_req) static NTSTATUS cvfs_qfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID_AND_FILE; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_fileinfo(private->tree, req, io); + return smb_raw_fileinfo(p->tree, req, io); } - c_req = smb_raw_fileinfo_send(private->tree, io); + c_req = smb_raw_fileinfo_send(p->tree, io); ASYNC_RECV_TAIL(io, async_qfileinfo); } @@ -470,16 +470,16 @@ static NTSTATUS cvfs_qfileinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_setpathinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_setfileinfo *st) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_setpathinfo(private->tree, st); + return smb_raw_setpathinfo(p->tree, st); } - c_req = smb_raw_setpathinfo_send(private->tree, st); + c_req = smb_raw_setpathinfo_send(p->tree, st); SIMPLE_ASYNC_TAIL; } @@ -516,7 +516,7 @@ failed: static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_open *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; struct ntvfs_handle *h; struct cvfs_file *f; @@ -525,7 +525,7 @@ static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs, SETUP_PID; if (io->generic.level != RAW_OPEN_GENERIC && - private->map_generic) { + p->map_generic) { return ntvfs_map_open(ntvfs, req, io); } @@ -539,21 +539,21 @@ static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs, if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { union smb_handle *file; - status = smb_raw_open(private->tree, req, io); + status = smb_raw_open(p->tree, req, io); NT_STATUS_NOT_OK_RETURN(status); SMB_OPEN_OUT_FILE(io, file); f->fnum = file->fnum; file->ntvfs = NULL; - status = ntvfs_handle_set_backend_data(f->h, private->ntvfs, f); + status = ntvfs_handle_set_backend_data(f->h, p->ntvfs, f); NT_STATUS_NOT_OK_RETURN(status); file->ntvfs = f->h; - DLIST_ADD(private->files, f); + DLIST_ADD(p->files, f); return NT_STATUS_OK; } - c_req = smb_raw_open_send(private->tree, io); + c_req = smb_raw_open_send(p->tree, io); ASYNC_RECV_TAIL_F(io, async_open, f); } @@ -564,16 +564,16 @@ static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_mkdir(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_mkdir *md) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_mkdir(private->tree, md); + return smb_raw_mkdir(p->tree, md); } - c_req = smb_raw_mkdir_send(private->tree, md); + c_req = smb_raw_mkdir_send(p->tree, md); SIMPLE_ASYNC_TAIL; } @@ -584,15 +584,15 @@ static NTSTATUS cvfs_mkdir(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_rmdir(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, struct smb_rmdir *rd) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_rmdir(private->tree, rd); + return smb_raw_rmdir(p->tree, rd); } - c_req = smb_raw_rmdir_send(private->tree, rd); + c_req = smb_raw_rmdir_send(p->tree, rd); SIMPLE_ASYNC_TAIL; } @@ -603,7 +603,7 @@ static NTSTATUS cvfs_rmdir(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_rename(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_rename *ren) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; @@ -616,10 +616,10 @@ static NTSTATUS cvfs_rename(struct ntvfs_module_context *ntvfs, } if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_rename(private->tree, ren); + return smb_raw_rename(p->tree, ren); } - c_req = smb_raw_rename_send(private->tree, ren); + c_req = smb_raw_rename_send(p->tree, ren); SIMPLE_ASYNC_TAIL; } @@ -651,23 +651,23 @@ static void async_read(struct smbcli_request *c_req) static NTSTATUS cvfs_read(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_read *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (io->generic.level != RAW_READ_GENERIC && - private->map_generic) { + p->map_generic) { return ntvfs_map_read(ntvfs, req, io); } SETUP_FILE; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_read(private->tree, io); + return smb_raw_read(p->tree, io); } - c_req = smb_raw_read_send(private->tree, io); + c_req = smb_raw_read_send(p->tree, io); ASYNC_RECV_TAIL(io, async_read); } @@ -690,22 +690,22 @@ static void async_write(struct smbcli_request *c_req) static NTSTATUS cvfs_write(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_write *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (io->generic.level != RAW_WRITE_GENERIC && - private->map_generic) { + p->map_generic) { return ntvfs_map_write(ntvfs, req, io); } SETUP_FILE; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_write(private->tree, io); + return smb_raw_write(p->tree, io); } - c_req = smb_raw_write_send(private->tree, io); + c_req = smb_raw_write_send(p->tree, io); ASYNC_RECV_TAIL(io, async_write); } @@ -729,16 +729,16 @@ static NTSTATUS cvfs_seek(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_seek *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID_AND_FILE; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_seek(private->tree, io); + return smb_raw_seek(p->tree, io); } - c_req = smb_raw_seek_send(private->tree, io); + c_req = smb_raw_seek_send(p->tree, io); ASYNC_RECV_TAIL(io, async_seek); } @@ -750,7 +750,7 @@ static NTSTATUS cvfs_flush(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_flush *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; @@ -766,10 +766,10 @@ static NTSTATUS cvfs_flush(struct ntvfs_module_context *ntvfs, } if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_flush(private->tree, io); + return smb_raw_flush(p->tree, io); } - c_req = smb_raw_flush_send(private->tree, io); + c_req = smb_raw_flush_send(p->tree, io); SIMPLE_ASYNC_TAIL; } @@ -780,7 +780,7 @@ static NTSTATUS cvfs_flush(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_close *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; struct cvfs_file *f; union smb_close io2; @@ -788,7 +788,7 @@ static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs, SETUP_PID; if (io->generic.level != RAW_CLOSE_GENERIC && - private->map_generic) { + p->map_generic) { return ntvfs_map_close(ntvfs, req, io); } @@ -805,13 +805,13 @@ static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs, even if file-close fails, we'll remove it from the list, what else would we do? Maybe we should not remove until after the proxied call completes? */ - DLIST_REMOVE(private->files, f); + DLIST_REMOVE(p->files, f); if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_close(private->tree, io); + return smb_raw_close(p->tree, io); } - c_req = smb_raw_close_send(private->tree, io); + c_req = smb_raw_close_send(p->tree, io); SIMPLE_ASYNC_TAIL; } @@ -822,16 +822,16 @@ static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_exit(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_exit(private->tree->session); + return smb_raw_exit(p->tree->session); } - c_req = smb_raw_exit_send(private->tree->session); + c_req = smb_raw_exit_send(p->tree->session); SIMPLE_ASYNC_TAIL; } @@ -851,7 +851,7 @@ static NTSTATUS cvfs_logoff(struct ntvfs_module_context *ntvfs, */ static NTSTATUS cvfs_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { return NT_STATUS_OK; } @@ -862,11 +862,11 @@ static NTSTATUS cvfs_async_setup(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_cancel(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct async_info *a; /* find the matching request */ - for (a=private->pending;a;a=a->next) { + for (a=p->pending;a;a=a->next) { if (a->req == req) { break; } @@ -885,22 +885,22 @@ static NTSTATUS cvfs_cancel(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_lock(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_lock *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (io->generic.level != RAW_LOCK_GENERIC && - private->map_generic) { + p->map_generic) { return ntvfs_map_lock(ntvfs, req, io); } SETUP_FILE; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_lock(private->tree, io); + return smb_raw_lock(p->tree, io); } - c_req = smb_raw_lock_send(private->tree, io); + c_req = smb_raw_lock_send(p->tree, io); SIMPLE_ASYNC_TAIL; } @@ -911,15 +911,15 @@ static NTSTATUS cvfs_setfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_setfileinfo *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID_AND_FILE; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_setfileinfo(private->tree, io); + return smb_raw_setfileinfo(p->tree, io); } - c_req = smb_raw_setfileinfo_send(private->tree, io); + c_req = smb_raw_setfileinfo_send(p->tree, io); SIMPLE_ASYNC_TAIL; } @@ -943,16 +943,16 @@ static void async_fsinfo(struct smbcli_request *c_req) static NTSTATUS cvfs_fsinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fsinfo *fs) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_fsinfo(private->tree, req, fs); + return smb_raw_fsinfo(p->tree, req, fs); } - c_req = smb_raw_fsinfo_send(private->tree, req, fs); + c_req = smb_raw_fsinfo_send(p->tree, req, fs); ASYNC_RECV_TAIL(fs, async_fsinfo); } @@ -974,11 +974,11 @@ static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs, void *search_private, bool (*callback)(void *, const union smb_search_data *)) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; SETUP_PID; - return smb_raw_search_first(private->tree, req, io, search_private, callback); + return smb_raw_search_first(p->tree, req, io, search_private, callback); } /* continue a search */ @@ -987,22 +987,22 @@ static NTSTATUS cvfs_search_next(struct ntvfs_module_context *ntvfs, void *search_private, bool (*callback)(void *, const union smb_search_data *)) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; SETUP_PID; - return smb_raw_search_next(private->tree, req, io, search_private, callback); + return smb_raw_search_next(p->tree, req, io, search_private, callback); } /* close a search */ static NTSTATUS cvfs_search_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_search_close *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; SETUP_PID; - return smb_raw_search_close(private->tree, io); + return smb_raw_search_close(p->tree, io); } /* @@ -1022,20 +1022,20 @@ static NTSTATUS cvfs_trans2(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, struct smb_trans2 *trans2) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; - if (private->map_trans2) { + if (p->map_trans2) { return NT_STATUS_NOT_IMPLEMENTED; } SETUP_PID; if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { - return smb_raw_trans2(private->tree, req, trans2); + return smb_raw_trans2(p->tree, req, trans2); } - c_req = smb_raw_trans2_send(private->tree, trans2); + c_req = smb_raw_trans2_send(p->tree, trans2); ASYNC_RECV_TAIL(trans2, async_trans2); } @@ -1066,9 +1066,9 @@ static NTSTATUS cvfs_notify(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_notify *io) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smbcli_request *c_req; - int saved_timeout = private->transport->options.request_timeout; + int saved_timeout = p->transport->options.request_timeout; struct cvfs_file *f; if (io->nttrans.level != RAW_NOTIFY_NTTRANS) { @@ -1088,11 +1088,11 @@ static NTSTATUS cvfs_notify(struct ntvfs_module_context *ntvfs, /* we must not timeout on notify requests - they wait forever */ - private->transport->options.request_timeout = 0; + p->transport->options.request_timeout = 0; - c_req = smb_raw_changenotify_send(private->tree, io); + c_req = smb_raw_changenotify_send(p->tree, io); - private->transport->options.request_timeout = saved_timeout; + p->transport->options.request_timeout = saved_timeout; ASYNC_RECV_TAIL(io, async_changenotify); } -- cgit From 0c64c213e84f644b39f1c654e0be9ca601173eca Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:32:04 +0100 Subject: s4:ntvfs/cifs_posix_cli: s/private/p metze --- source4/ntvfs/cifs_posix_cli/svfs_util.c | 12 ++-- source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c | 92 +++++++++++++-------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/source4/ntvfs/cifs_posix_cli/svfs_util.c b/source4/ntvfs/cifs_posix_cli/svfs_util.c index e502340229..03a46205a7 100644 --- a/source4/ntvfs/cifs_posix_cli/svfs_util.c +++ b/source4/ntvfs/cifs_posix_cli/svfs_util.c @@ -39,17 +39,17 @@ char *cifspsx_unix_path(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *name) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; char *ret; if (*name != '\\') { - ret = talloc_asprintf(req, "%s/%s", private->connectpath, name); + ret = talloc_asprintf(req, "%s/%s", p->connectpath, name); } else { - ret = talloc_asprintf(req, "%s%s", private->connectpath, name); + ret = talloc_asprintf(req, "%s%s", p->connectpath, name); } all_string_sub(ret, "\\", "/", 0); - strlower(ret + strlen(private->connectpath)); + strlower(ret + strlen(p->connectpath)); return ret; } @@ -145,13 +145,13 @@ struct cifspsx_dir *cifspsx_list_unix(TALLOC_CTX *mem_ctx, struct ntvfs_request */ struct cifspsx_dir *cifspsx_list(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *pattern) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; char *unix_path; unix_path = cifspsx_unix_path(ntvfs, req, pattern); if (!unix_path) { return NULL; } - return cifspsx_list_unix(private, req, unix_path); + return cifspsx_list_unix(p, req, unix_path); } diff --git a/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c b/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c index 34a26b06b4..02fe9f2264 100644 --- a/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c +++ b/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c @@ -51,21 +51,21 @@ static NTSTATUS cifspsx_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { struct stat st; - struct cifspsx_private *private; + struct cifspsx_private *p; struct share_config *scfg = ntvfs->ctx->config; - private = talloc(ntvfs, struct cifspsx_private); - NT_STATUS_HAVE_NO_MEMORY(private); - private->ntvfs = ntvfs; - private->next_search_handle = 0; - private->connectpath = talloc_strdup(private, share_string_option(scfg, SHARE_PATH, "")); - private->open_files = NULL; - private->search = NULL; + p = talloc(ntvfs, struct cifspsx_private); + NT_STATUS_HAVE_NO_MEMORY(p); + p->ntvfs = ntvfs; + p->next_search_handle = 0; + p->connectpath = talloc_strdup(p, share_string_option(scfg, SHARE_PATH, "")); + p->open_files = NULL; + p->search = NULL; /* the directory must exist */ - if (stat(private->connectpath, &st) != 0 || !S_ISDIR(st.st_mode)) { + if (stat(p->connectpath, &st) != 0 || !S_ISDIR(st.st_mode)) { DEBUG(0,("'%s' is not a directory, when connecting to [%s]\n", - private->connectpath, sharename)); + p->connectpath, sharename)); return NT_STATUS_BAD_NETWORK_NAME; } @@ -74,7 +74,7 @@ static NTSTATUS cifspsx_connect(struct ntvfs_module_context *ntvfs, ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:"); NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); - ntvfs->private_data = private; + ntvfs->private_data = p; DEBUG(0,("WARNING: ntvfs cifs posix: connect to share [%s] with ROOT privileges!!!\n",sharename)); @@ -92,12 +92,12 @@ static NTSTATUS cifspsx_disconnect(struct ntvfs_module_context *ntvfs) /* find open file handle given fd */ -static struct cifspsx_file *find_fd(struct cifspsx_private *private, struct ntvfs_handle *handle) +static struct cifspsx_file *find_fd(struct cifspsx_private *cp, struct ntvfs_handle *handle) { struct cifspsx_file *f; void *p; - p = ntvfs_handle_get_backend_data(handle, private->ntvfs); + p = ntvfs_handle_get_backend_data(handle, cp->ntvfs); if (!p) return NULL; f = talloc_get_type(p, struct cifspsx_file); @@ -278,7 +278,7 @@ static NTSTATUS cifspsx_qpathinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS cifspsx_qfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct cifspsx_file *f; struct stat st; @@ -286,7 +286,7 @@ static NTSTATUS cifspsx_qfileinfo(struct ntvfs_module_context *ntvfs, return ntvfs_map_qfileinfo(ntvfs, req, info); } - f = find_fd(private, info->generic.in.file.ntvfs); + f = find_fd(p, info->generic.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -305,7 +305,7 @@ static NTSTATUS cifspsx_qfileinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS cifspsx_open(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_open *io) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; char *unix_path; struct stat st; int fd, flags; @@ -394,7 +394,7 @@ do_open: f->name = talloc_strdup(f, unix_path); NT_STATUS_HAVE_NO_MEMORY(f->name); - DLIST_ADD(private->open_files, f); + DLIST_ADD(p->open_files, f); status = ntvfs_handle_set_backend_data(handle, ntvfs, f); NT_STATUS_NOT_OK_RETURN(status); @@ -495,7 +495,7 @@ static NTSTATUS cifspsx_copy(struct ntvfs_module_context *ntvfs, static NTSTATUS cifspsx_read(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_read *rd) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct cifspsx_file *f; ssize_t ret; @@ -503,7 +503,7 @@ static NTSTATUS cifspsx_read(struct ntvfs_module_context *ntvfs, return NT_STATUS_NOT_SUPPORTED; } - f = find_fd(private, rd->readx.in.file.ntvfs); + f = find_fd(p, rd->readx.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -529,7 +529,7 @@ static NTSTATUS cifspsx_read(struct ntvfs_module_context *ntvfs, static NTSTATUS cifspsx_write(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_write *wr) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct cifspsx_file *f; ssize_t ret; @@ -539,7 +539,7 @@ static NTSTATUS cifspsx_write(struct ntvfs_module_context *ntvfs, CHECK_READ_ONLY(req); - f = find_fd(private, wr->writex.in.file.ntvfs); + f = find_fd(p, wr->writex.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -575,14 +575,14 @@ static NTSTATUS cifspsx_flush(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_flush *io) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct cifspsx_file *f; switch (io->generic.level) { case RAW_FLUSH_FLUSH: case RAW_FLUSH_SMB2: /* ignore the additional unknown option in SMB2 */ - f = find_fd(private, io->generic.in.file.ntvfs); + f = find_fd(p, io->generic.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -590,7 +590,7 @@ static NTSTATUS cifspsx_flush(struct ntvfs_module_context *ntvfs, return NT_STATUS_OK; case RAW_FLUSH_ALL: - for (f=private->open_files;f;f=f->next) { + for (f=p->open_files;f;f=f->next) { fsync(f->fd); } return NT_STATUS_OK; @@ -606,7 +606,7 @@ static NTSTATUS cifspsx_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_close *io) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct cifspsx_file *f; if (io->generic.level != RAW_CLOSE_CLOSE) { @@ -614,7 +614,7 @@ static NTSTATUS cifspsx_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_LEVEL; } - f = find_fd(private, io->close.in.file.ntvfs); + f = find_fd(p, io->close.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -623,7 +623,7 @@ static NTSTATUS cifspsx_close(struct ntvfs_module_context *ntvfs, return map_nt_error_from_unix(errno); } - DLIST_REMOVE(private->open_files, f); + DLIST_REMOVE(p->open_files, f); talloc_free(f->name); talloc_free(f); @@ -653,7 +653,7 @@ static NTSTATUS cifspsx_logoff(struct ntvfs_module_context *ntvfs, */ static NTSTATUS cifspsx_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { return NT_STATUS_OK; } @@ -694,13 +694,13 @@ static NTSTATUS cifspsx_setfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_setfileinfo *info) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct cifspsx_file *f; struct utimbuf unix_times; CHECK_READ_ONLY(req); - f = find_fd(private, info->generic.in.file.ntvfs); + f = find_fd(p, info->generic.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -746,14 +746,14 @@ static NTSTATUS cifspsx_setfileinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS cifspsx_fsinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fsinfo *fs) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct stat st; if (fs->generic.level != RAW_QFS_GENERIC) { return ntvfs_map_fsinfo(ntvfs, req, fs); } - if (sys_fsusage(private->connectpath, + if (sys_fsusage(p->connectpath, &fs->generic.out.blocks_free, &fs->generic.out.blocks_total) == -1) { return map_nt_error_from_unix(errno); @@ -761,7 +761,7 @@ static NTSTATUS cifspsx_fsinfo(struct ntvfs_module_context *ntvfs, fs->generic.out.block_size = 512; - if (stat(private->connectpath, &st) != 0) { + if (stat(p->connectpath, &st) != 0) { return NT_STATUS_DISK_CORRUPT_ERROR; } @@ -789,13 +789,13 @@ static NTSTATUS cifspsx_fsattr(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fsattr *fs) { struct stat st; - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; if (fs->generic.level != RAW_FSATTR_GENERIC) { return ntvfs_map_fsattr(ntvfs, req, fs); } - if (stat(private->connectpath, &st) == -1) { + if (stat(p->connectpath, &st) == -1) { return map_nt_error_from_unix(errno); } @@ -833,7 +833,7 @@ static NTSTATUS cifspsx_search_first(struct ntvfs_module_context *ntvfs, { struct cifspsx_dir *dir; int i; - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct search_state *search; union smb_search_data file; uint_t max_count; @@ -846,7 +846,7 @@ static NTSTATUS cifspsx_search_first(struct ntvfs_module_context *ntvfs, return NT_STATUS_NOT_SUPPORTED; } - search = talloc_zero(private, struct search_state); + search = talloc_zero(p, struct search_state); if (!search) { return NT_STATUS_NO_MEMORY; } @@ -858,7 +858,7 @@ static NTSTATUS cifspsx_search_first(struct ntvfs_module_context *ntvfs, return NT_STATUS_FOOBAR; } - search->handle = private->next_search_handle; + search->handle = p->next_search_handle; search->dir = dir; if (dir->count < max_count) { @@ -892,8 +892,8 @@ static NTSTATUS cifspsx_search_first(struct ntvfs_module_context *ntvfs, ((io->t2ffirst.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) { talloc_free(search); } else { - private->next_search_handle++; - DLIST_ADD(private->search, search); + p->next_search_handle++; + DLIST_ADD(p->search, search); } return NT_STATUS_OK; @@ -907,7 +907,7 @@ static NTSTATUS cifspsx_search_next(struct ntvfs_module_context *ntvfs, { struct cifspsx_dir *dir; int i; - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct search_state *search; union smb_search_data file; uint_t max_count; @@ -920,7 +920,7 @@ static NTSTATUS cifspsx_search_next(struct ntvfs_module_context *ntvfs, return NT_STATUS_NOT_SUPPORTED; } - for (search=private->search; search; search = search->next) { + for (search=p->search; search; search = search->next) { if (search->handle == io->t2fnext.in.handle) break; } @@ -984,7 +984,7 @@ found: /* work out if we are going to keep the search state */ if ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE) || ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) { - DLIST_REMOVE(private->search, search); + DLIST_REMOVE(p->search, search); talloc_free(search); } @@ -995,10 +995,10 @@ found: static NTSTATUS cifspsx_search_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_search_close *io) { - struct cifspsx_private *private = ntvfs->private_data; + struct cifspsx_private *p = ntvfs->private_data; struct search_state *search; - for (search=private->search; search; search = search->next) { + for (search=p->search; search; search = search->next) { if (search->handle == io->findclose.in.handle) break; } @@ -1007,7 +1007,7 @@ static NTSTATUS cifspsx_search_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_FOOBAR; } - DLIST_REMOVE(private->search, search); + DLIST_REMOVE(p->search, search); talloc_free(search); return NT_STATUS_OK; -- cgit From 33e8f4772544a457bc2adc200235e065cba3c239 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:32:46 +0100 Subject: s4:ntvfs/common: s/private/private_data metze --- source4/ntvfs/common/opendb.c | 8 ++++---- source4/ntvfs/common/opendb.h | 4 ++-- source4/ntvfs/common/opendb_tdb.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source4/ntvfs/common/opendb.c b/source4/ntvfs/common/opendb.c index cfbb88f90e..12fe7015a7 100644 --- a/source4/ntvfs/common/opendb.c +++ b/source4/ntvfs/common/opendb.c @@ -107,9 +107,9 @@ NTSTATUS odb_open_file(struct odb_lock *lck, /* register a pending open file in the open files database */ -NTSTATUS odb_open_file_pending(struct odb_lock *lck, void *private) +NTSTATUS odb_open_file_pending(struct odb_lock *lck, void *private_data) { - return ops->odb_open_file_pending(lck, private); + return ops->odb_open_file_pending(lck, private_data); } @@ -126,9 +126,9 @@ NTSTATUS odb_close_file(struct odb_lock *lck, void *file_handle, /* remove a pending opendb entry */ -NTSTATUS odb_remove_pending(struct odb_lock *lck, void *private) +NTSTATUS odb_remove_pending(struct odb_lock *lck, void *private_data) { - return ops->odb_remove_pending(lck, private); + return ops->odb_remove_pending(lck, private_data); } diff --git a/source4/ntvfs/common/opendb.h b/source4/ntvfs/common/opendb.h index 179db111ca..446df1777f 100644 --- a/source4/ntvfs/common/opendb.h +++ b/source4/ntvfs/common/opendb.h @@ -30,10 +30,10 @@ struct opendb_ops { int *fd, NTTIME open_write_time, bool allow_level_II_oplock, uint32_t oplock_level, uint32_t *oplock_granted); - NTSTATUS (*odb_open_file_pending)(struct odb_lock *lck, void *private); + NTSTATUS (*odb_open_file_pending)(struct odb_lock *lck, void *private_data); NTSTATUS (*odb_close_file)(struct odb_lock *lck, void *file_handle, const char **delete_path); - NTSTATUS (*odb_remove_pending)(struct odb_lock *lck, void *private); + NTSTATUS (*odb_remove_pending)(struct odb_lock *lck, void *private_data); NTSTATUS (*odb_rename)(struct odb_lock *lck, const char *path); NTSTATUS (*odb_get_path)(struct odb_lock *lck, const char **path); NTSTATUS (*odb_set_delete_on_close)(struct odb_lock *lck, bool del_on_close); diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c index 83da122fe2..8f5d10f902 100644 --- a/source4/ntvfs/common/opendb_tdb.c +++ b/source4/ntvfs/common/opendb_tdb.c @@ -548,7 +548,7 @@ static NTSTATUS odb_tdb_open_file(struct odb_lock *lck, /* register a pending open file in the open files database */ -static NTSTATUS odb_tdb_open_file_pending(struct odb_lock *lck, void *private) +static NTSTATUS odb_tdb_open_file_pending(struct odb_lock *lck, void *private_data) { struct odb_context *odb = lck->odb; @@ -562,7 +562,7 @@ static NTSTATUS odb_tdb_open_file_pending(struct odb_lock *lck, void *private) NT_STATUS_HAVE_NO_MEMORY(lck->file.pending); lck->file.pending[lck->file.num_pending].server = odb->ntvfs_ctx->server_id; - lck->file.pending[lck->file.num_pending].notify_ptr = private; + lck->file.pending[lck->file.num_pending].notify_ptr = private_data; lck->file.num_pending++; @@ -710,7 +710,7 @@ static NTSTATUS odb_tdb_break_oplocks(struct odb_lock *lck) /* remove a pending opendb entry */ -static NTSTATUS odb_tdb_remove_pending(struct odb_lock *lck, void *private) +static NTSTATUS odb_tdb_remove_pending(struct odb_lock *lck, void *private_data) { struct odb_context *odb = lck->odb; int i; @@ -721,7 +721,7 @@ static NTSTATUS odb_tdb_remove_pending(struct odb_lock *lck, void *private) /* find the entry, and delete it */ for (i=0;ifile.num_pending;i++) { - if (private == lck->file.pending[i].notify_ptr && + if (private_data == lck->file.pending[i].notify_ptr && cluster_id_equal(&odb->ntvfs_ctx->server_id, &lck->file.pending[i].server)) { if (i < lck->file.num_pending-1) { memmove(lck->file.pending+i, lck->file.pending+i+1, -- cgit From 8a95f4d2d6dc4ad3e0434c6f5e53b87ff3fdecb1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:33:21 +0100 Subject: s4:ntvfs/ipc: s/private/ipriv metze --- source4/ntvfs/ipc/vfs_ipc.c | 88 ++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c index 5a63edcc3e..2f05a86dfa 100644 --- a/source4/ntvfs/ipc/vfs_ipc.c +++ b/source4/ntvfs/ipc/vfs_ipc.c @@ -44,7 +44,7 @@ struct ipc_private { /* a list of open pipes */ struct pipe_state { struct pipe_state *next, *prev; - struct ipc_private *private; + struct ipc_private *ipriv; const char *pipe_name; struct ntvfs_handle *handle; struct dcesrv_connection *dce_conn; @@ -56,12 +56,12 @@ struct ipc_private { /* find a open pipe give a file handle */ -static struct pipe_state *pipe_state_find(struct ipc_private *private, struct ntvfs_handle *handle) +static struct pipe_state *pipe_state_find(struct ipc_private *ipriv, struct ntvfs_handle *handle) { struct pipe_state *s; void *p; - p = ntvfs_handle_get_backend_data(handle, private->ntvfs); + p = ntvfs_handle_get_backend_data(handle, ipriv->ntvfs); if (!p) return NULL; s = talloc_get_type(p, struct pipe_state); @@ -73,14 +73,14 @@ static struct pipe_state *pipe_state_find(struct ipc_private *private, struct nt /* find a open pipe give a wire fnum */ -static struct pipe_state *pipe_state_find_key(struct ipc_private *private, struct ntvfs_request *req, const DATA_BLOB *key) +static struct pipe_state *pipe_state_find_key(struct ipc_private *ipriv, struct ntvfs_request *req, const DATA_BLOB *key) { struct ntvfs_handle *h; - h = ntvfs_handle_search_by_wire_key(private->ntvfs, req, key); + h = ntvfs_handle_search_by_wire_key(ipriv->ntvfs, req, key); if (!h) return NULL; - return pipe_state_find(private, h); + return pipe_state_find(ipriv, h); } @@ -91,7 +91,7 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { NTSTATUS status; - struct ipc_private *private; + struct ipc_private *ipriv; ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "IPC"); NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); @@ -100,16 +100,16 @@ static NTSTATUS ipc_connect(struct ntvfs_module_context *ntvfs, NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); /* prepare the private state for this connection */ - private = talloc(ntvfs, struct ipc_private); - NT_STATUS_HAVE_NO_MEMORY(private); + ipriv = talloc(ntvfs, struct ipc_private); + NT_STATUS_HAVE_NO_MEMORY(ipriv); - ntvfs->private_data = private; + ntvfs->private_data = ipriv; - private->ntvfs = ntvfs; - private->pipe_list = NULL; + ipriv->ntvfs = ntvfs; + ipriv->pipe_list = NULL; /* setup the DCERPC server subsystem */ - status = dcesrv_init_ipc_context(private, ntvfs->ctx->lp_ctx, &private->dcesrv); + status = dcesrv_init_ipc_context(ipriv, ntvfs->ctx->lp_ctx, &ipriv->dcesrv); NT_STATUS_NOT_OK_RETURN(status); return NT_STATUS_OK; @@ -174,23 +174,23 @@ static NTSTATUS ipc_setpathinfo(struct ntvfs_module_context *ntvfs, */ static int ipc_fd_destructor(struct pipe_state *p) { - DLIST_REMOVE(p->private->pipe_list, p); - ntvfs_handle_remove_backend_data(p->handle, p->private->ntvfs); + DLIST_REMOVE(p->ipriv->pipe_list, p); + ntvfs_handle_remove_backend_data(p->handle, p->ipriv->ntvfs); return 0; } static struct socket_address *ipc_get_my_addr(struct dcesrv_connection *dce_conn, TALLOC_CTX *mem_ctx) { - struct ipc_private *private = dce_conn->transport.private_data; + struct ipc_private *ipriv = dce_conn->transport.private_data; - return ntvfs_get_my_addr(private->ntvfs, mem_ctx); + return ntvfs_get_my_addr(ipriv->ntvfs, mem_ctx); } static struct socket_address *ipc_get_peer_addr(struct dcesrv_connection *dce_conn, TALLOC_CTX *mem_ctx) { - struct ipc_private *private = dce_conn->transport.private_data; + struct ipc_private *ipriv = dce_conn->transport.private_data; - return ntvfs_get_peer_addr(private->ntvfs, mem_ctx); + return ntvfs_get_peer_addr(ipriv->ntvfs, mem_ctx); } /* @@ -203,7 +203,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, struct pipe_state *p; NTSTATUS status; struct dcerpc_binding *ep_description; - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; struct ntvfs_handle *h; status = ntvfs_handle_new(ntvfs, req, &h); @@ -235,7 +235,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, /* The session info is refcount-increased in the * dcesrv_endpoint_search_connect() function */ - status = dcesrv_endpoint_search_connect(private->dcesrv, + status = dcesrv_endpoint_search_connect(ipriv->dcesrv, p, ep_description, h->session_info, @@ -246,18 +246,18 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs, &p->dce_conn); NT_STATUS_NOT_OK_RETURN(status); - p->dce_conn->transport.private_data = private; + p->dce_conn->transport.private_data = ipriv; p->dce_conn->transport.report_output_data = NULL; p->dce_conn->transport.get_my_addr = ipc_get_my_addr; p->dce_conn->transport.get_peer_addr = ipc_get_peer_addr; - DLIST_ADD(private->pipe_list, p); + DLIST_ADD(ipriv->pipe_list, p); - p->private = private; + p->ipriv = ipriv; talloc_set_destructor(p, ipc_fd_destructor); - status = ntvfs_handle_set_backend_data(h, private->ntvfs, p); + status = ntvfs_handle_set_backend_data(h, ipriv->ntvfs, p); NT_STATUS_NOT_OK_RETURN(status); *ps = p; @@ -417,7 +417,7 @@ static NTSTATUS ipc_readx_dcesrv_output(void *private_data, DATA_BLOB *out, size static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_read *rd) { - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; DATA_BLOB data; struct pipe_state *p; NTSTATUS status = NT_STATUS_OK; @@ -426,7 +426,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, return ntvfs_map_read(ntvfs, req, rd); } - p = pipe_state_find(private, rd->readx.in.file.ntvfs); + p = pipe_state_find(ipriv, rd->readx.in.file.ntvfs); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -457,7 +457,7 @@ static NTSTATUS ipc_read(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_write *wr) { - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; DATA_BLOB data; struct pipe_state *p; NTSTATUS status; @@ -469,7 +469,7 @@ static NTSTATUS ipc_write(struct ntvfs_module_context *ntvfs, data.data = discard_const_p(void, wr->writex.in.data); data.length = wr->writex.in.count; - p = pipe_state_find(private, wr->writex.in.file.ntvfs); + p = pipe_state_find(ipriv, wr->writex.in.file.ntvfs); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -511,14 +511,14 @@ static NTSTATUS ipc_flush(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_close *io) { - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; struct pipe_state *p; if (io->generic.level != RAW_CLOSE_CLOSE) { return ntvfs_map_close(ntvfs, req, io); } - p = pipe_state_find(private, io->close.in.file.ntvfs); + p = pipe_state_find(ipriv, io->close.in.file.ntvfs); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -534,10 +534,10 @@ static NTSTATUS ipc_close(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_exit(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req) { - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; struct pipe_state *p, *next; - for (p=private->pipe_list; p; p=next) { + for (p=ipriv->pipe_list; p; p=next) { next = p->next; if (p->handle->session_info == req->session_info && p->handle->smbpid == req->smbpid) { @@ -554,10 +554,10 @@ static NTSTATUS ipc_exit(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_logoff(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req) { - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; struct pipe_state *p, *next; - for (p=private->pipe_list; p; p=next) { + for (p=ipriv->pipe_list; p; p=next) { next = p->next; if (p->handle->session_info == req->session_info) { talloc_free(p); @@ -572,7 +572,7 @@ static NTSTATUS ipc_logoff(struct ntvfs_module_context *ntvfs, */ static NTSTATUS ipc_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { return NT_STATUS_OK; } @@ -610,8 +610,8 @@ static NTSTATUS ipc_setfileinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_qfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { - struct ipc_private *private = ntvfs->private_data; - struct pipe_state *p = pipe_state_find(private, info->generic.in.file.ntvfs); + struct ipc_private *ipriv = ntvfs->private_data; + struct pipe_state *p = pipe_state_find(ipriv, info->generic.in.file.ntvfs); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -717,7 +717,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, struct smb_trans2 *trans) { struct pipe_state *p; - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; NTSTATUS status; DATA_BLOB fnum_key; uint16_t fnum; @@ -731,7 +731,7 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, SSVAL(&fnum, 0, trans->in.setup[1]); fnum_key = data_blob_const(&fnum, 2); - p = pipe_state_find_key(private, req, &fnum_key); + p = pipe_state_find_key(ipriv, req, &fnum_key); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -772,14 +772,14 @@ static NTSTATUS ipc_dcerpc_cmd(struct ntvfs_module_context *ntvfs, static NTSTATUS ipc_set_nm_pipe_state(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, struct smb_trans2 *trans) { - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; struct pipe_state *p; DATA_BLOB fnum_key; /* the fnum is in setup[1] */ fnum_key = data_blob_const(&trans->in.setup[1], sizeof(trans->in.setup[1])); - p = pipe_state_find_key(private, req, &fnum_key); + p = pipe_state_find_key(ipriv, req, &fnum_key); if (!p) { return NT_STATUS_INVALID_HANDLE; } @@ -830,7 +830,7 @@ static NTSTATUS ipc_ioctl_smb2(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_ioctl *io) { struct pipe_state *p; - struct ipc_private *private = ntvfs->private_data; + struct ipc_private *ipriv = ntvfs->private_data; NTSTATUS status; switch (io->smb2.in.function) { @@ -841,7 +841,7 @@ static NTSTATUS ipc_ioctl_smb2(struct ntvfs_module_context *ntvfs, return NT_STATUS_FS_DRIVER_REQUIRED; } - p = pipe_state_find(private, io->smb2.in.file.ntvfs); + p = pipe_state_find(ipriv, io->smb2.in.file.ntvfs); if (!p) { return NT_STATUS_INVALID_HANDLE; } -- cgit From 7ee87c339bc328f89d08afc0e5c9e095ceb1f746 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:33:46 +0100 Subject: s4:ntvfs/nbench: s/private/nprivates metze --- source4/ntvfs/nbench/vfs_nbench.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source4/ntvfs/nbench/vfs_nbench.c b/source4/ntvfs/nbench/vfs_nbench.c index 987227a0b7..7ba2e7c649 100644 --- a/source4/ntvfs/nbench/vfs_nbench.c +++ b/source4/ntvfs/nbench/vfs_nbench.c @@ -41,7 +41,7 @@ static void nbench_log(struct ntvfs_request *req, static void nbench_log(struct ntvfs_request *req, const char *format, ...) { - struct nbench_private *private = req->async_states->ntvfs->private_data; + struct nbench_private *nprivates = req->async_states->ntvfs->private_data; va_list ap; char *s = NULL; @@ -49,7 +49,7 @@ static void nbench_log(struct ntvfs_request *req, vasprintf(&s, format, ap); va_end(ap); - write(private->log_fd, s, strlen(s)); + write(nprivates->log_fd, s, strlen(s)); free(s); } @@ -671,11 +671,11 @@ static void nbench_async_setup_send(struct ntvfs_request *req) */ static NTSTATUS nbench_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, async_setup, NULL, (ntvfs, req, private)); + PASS_THRU_REQ(ntvfs, req, async_setup, NULL, (ntvfs, req, private_data)); return status; } -- cgit From 2110ef3c5d4b2085310f706c62e6bf11299dc2eb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:34:16 +0100 Subject: s4:ntvfs/posix: s/private/private_data metze --- source4/ntvfs/posix/pvfs_aio.c | 8 ++++---- source4/ntvfs/posix/pvfs_lock.c | 4 ++-- source4/ntvfs/posix/pvfs_notify.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source4/ntvfs/posix/pvfs_aio.c b/source4/ntvfs/posix/pvfs_aio.c index 7a090e214a..56566e3592 100644 --- a/source4/ntvfs/posix/pvfs_aio.c +++ b/source4/ntvfs/posix/pvfs_aio.c @@ -42,9 +42,9 @@ struct pvfs_aio_write_state { called when an aio read has finished */ static void pvfs_aio_read_handler(struct tevent_context *ev, struct tevent_aio *ae, - int ret, void *private) + int ret, void *private_data) { - struct pvfs_aio_read_state *state = talloc_get_type(private, + struct pvfs_aio_read_state *state = talloc_get_type(private_data, struct pvfs_aio_read_state); struct pvfs_file *f = state->f; union smb_read *rd = state->rd; @@ -107,9 +107,9 @@ NTSTATUS pvfs_aio_pread(struct ntvfs_request *req, union smb_read *rd, called when an aio write has finished */ static void pvfs_aio_write_handler(struct tevent_context *ev, struct tevent_aio *ae, - int ret, void *private) + int ret, void *private_data) { - struct pvfs_aio_write_state *state = talloc_get_type(private, + struct pvfs_aio_write_state *state = talloc_get_type(private_data, struct pvfs_aio_write_state); struct pvfs_file *f = state->f; union smb_write *wr = state->wr; diff --git a/source4/ntvfs/posix/pvfs_lock.c b/source4/ntvfs/posix/pvfs_lock.c index 173b2fe187..2353baeff4 100644 --- a/source4/ntvfs/posix/pvfs_lock.c +++ b/source4/ntvfs/posix/pvfs_lock.c @@ -88,9 +88,9 @@ static void pvfs_lock_async_failed(struct pvfs_state *pvfs, range, so we should try the lock again. Note that on timeout we do retry the lock, giving it a last chance. */ -static void pvfs_pending_lock_continue(void *private, enum pvfs_wait_notice reason) +static void pvfs_pending_lock_continue(void *private_data, enum pvfs_wait_notice reason) { - struct pvfs_pending_lock *pending = private; + struct pvfs_pending_lock *pending = private_data; struct pvfs_state *pvfs = pending->pvfs; struct pvfs_file *f = pending->f; struct ntvfs_request *req = pending->req; diff --git a/source4/ntvfs/posix/pvfs_notify.c b/source4/ntvfs/posix/pvfs_notify.c index 8224d36b7d..09aa0f64e6 100644 --- a/source4/ntvfs/posix/pvfs_notify.c +++ b/source4/ntvfs/posix/pvfs_notify.c @@ -126,9 +126,9 @@ static int pvfs_notify_destructor(struct pvfs_notify_buffer *n) /* called when a async notify event comes in */ -static void pvfs_notify_callback(void *private, const struct notify_event *ev) +static void pvfs_notify_callback(void *private_data, const struct notify_event *ev) { - struct pvfs_notify_buffer *n = talloc_get_type(private, struct pvfs_notify_buffer); + struct pvfs_notify_buffer *n = talloc_get_type(private_data, struct pvfs_notify_buffer); size_t len; struct notify_changes *n2; char *new_path; @@ -201,9 +201,9 @@ static NTSTATUS pvfs_notify_setup(struct pvfs_state *pvfs, struct pvfs_file *f, called from the pvfs_wait code when either an event has come in, or the notify request has been cancelled */ -static void pvfs_notify_end(void *private, enum pvfs_wait_notice reason) +static void pvfs_notify_end(void *private_data, enum pvfs_wait_notice reason) { - struct pvfs_notify_buffer *notify_buffer = talloc_get_type(private, + struct pvfs_notify_buffer *notify_buffer = talloc_get_type(private_data, struct pvfs_notify_buffer); if (reason == PVFS_WAIT_CANCEL) { pvfs_notify_send(notify_buffer, NT_STATUS_CANCELLED, false); -- cgit From 42f92109d2cd5c1ecb58b246de00bd9ede14703f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:35:29 +0100 Subject: s4:ntvfs/simple: s/private/p metze --- source4/ntvfs/simple/svfs_util.c | 12 ++--- source4/ntvfs/simple/vfs_simple.c | 92 +++++++++++++++++++-------------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/source4/ntvfs/simple/svfs_util.c b/source4/ntvfs/simple/svfs_util.c index a0cdbe9c39..f7f011572a 100644 --- a/source4/ntvfs/simple/svfs_util.c +++ b/source4/ntvfs/simple/svfs_util.c @@ -36,17 +36,17 @@ char *svfs_unix_path(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *name) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; char *ret; if (*name != '\\') { - ret = talloc_asprintf(req, "%s/%s", private->connectpath, name); + ret = talloc_asprintf(req, "%s/%s", p->connectpath, name); } else { - ret = talloc_asprintf(req, "%s%s", private->connectpath, name); + ret = talloc_asprintf(req, "%s%s", p->connectpath, name); } all_string_sub(ret, "\\", "/", 0); - strlower(ret + strlen(private->connectpath)); + strlower(ret + strlen(p->connectpath)); return ret; } @@ -142,13 +142,13 @@ struct svfs_dir *svfs_list_unix(TALLOC_CTX *mem_ctx, struct ntvfs_request *req, */ struct svfs_dir *svfs_list(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *pattern) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; char *unix_path; unix_path = svfs_unix_path(ntvfs, req, pattern); if (!unix_path) { return NULL; } - return svfs_list_unix(private, req, unix_path); + return svfs_list_unix(p, req, unix_path); } diff --git a/source4/ntvfs/simple/vfs_simple.c b/source4/ntvfs/simple/vfs_simple.c index 5d904b4fcb..bf0afcec0a 100644 --- a/source4/ntvfs/simple/vfs_simple.c +++ b/source4/ntvfs/simple/vfs_simple.c @@ -50,21 +50,21 @@ static NTSTATUS svfs_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { struct stat st; - struct svfs_private *private; + struct svfs_private *p; struct share_config *scfg = ntvfs->ctx->config; - private = talloc(ntvfs, struct svfs_private); - NT_STATUS_HAVE_NO_MEMORY(private); - private->ntvfs = ntvfs; - private->next_search_handle = 0; - private->connectpath = talloc_strdup(private, share_string_option(scfg, SHARE_PATH, "")); - private->open_files = NULL; - private->search = NULL; + p = talloc(ntvfs, struct svfs_private); + NT_STATUS_HAVE_NO_MEMORY(p); + p->ntvfs = ntvfs; + p->next_search_handle = 0; + p->connectpath = talloc_strdup(p, share_string_option(scfg, SHARE_PATH, "")); + p->open_files = NULL; + p->search = NULL; /* the directory must exist */ - if (stat(private->connectpath, &st) != 0 || !S_ISDIR(st.st_mode)) { + if (stat(p->connectpath, &st) != 0 || !S_ISDIR(st.st_mode)) { DEBUG(0,("'%s' is not a directory, when connecting to [%s]\n", - private->connectpath, sharename)); + p->connectpath, sharename)); return NT_STATUS_BAD_NETWORK_NAME; } @@ -73,7 +73,7 @@ static NTSTATUS svfs_connect(struct ntvfs_module_context *ntvfs, ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:"); NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); - ntvfs->private_data = private; + ntvfs->private_data = p; return NT_STATUS_OK; } @@ -89,12 +89,12 @@ static NTSTATUS svfs_disconnect(struct ntvfs_module_context *ntvfs) /* find open file handle given fd */ -static struct svfs_file *find_fd(struct svfs_private *private, struct ntvfs_handle *handle) +static struct svfs_file *find_fd(struct svfs_private *sp, struct ntvfs_handle *handle) { struct svfs_file *f; void *p; - p = ntvfs_handle_get_backend_data(handle, private->ntvfs); + p = ntvfs_handle_get_backend_data(handle, sp->ntvfs); if (!p) return NULL; f = talloc_get_type(p, struct svfs_file); @@ -275,7 +275,7 @@ static NTSTATUS svfs_qpathinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS svfs_qfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fileinfo *info) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct svfs_file *f; struct stat st; @@ -283,7 +283,7 @@ static NTSTATUS svfs_qfileinfo(struct ntvfs_module_context *ntvfs, return ntvfs_map_qfileinfo(ntvfs, req, info); } - f = find_fd(private, info->generic.in.file.ntvfs); + f = find_fd(p, info->generic.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -302,7 +302,7 @@ static NTSTATUS svfs_qfileinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS svfs_open(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_open *io) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; char *unix_path; struct stat st; int fd, flags; @@ -391,7 +391,7 @@ do_open: f->name = talloc_strdup(f, unix_path); NT_STATUS_HAVE_NO_MEMORY(f->name); - DLIST_ADD(private->open_files, f); + DLIST_ADD(p->open_files, f); status = ntvfs_handle_set_backend_data(handle, ntvfs, f); NT_STATUS_NOT_OK_RETURN(status); @@ -492,7 +492,7 @@ static NTSTATUS svfs_copy(struct ntvfs_module_context *ntvfs, static NTSTATUS svfs_read(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_read *rd) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct svfs_file *f; ssize_t ret; @@ -500,7 +500,7 @@ static NTSTATUS svfs_read(struct ntvfs_module_context *ntvfs, return NT_STATUS_NOT_SUPPORTED; } - f = find_fd(private, rd->readx.in.file.ntvfs); + f = find_fd(p, rd->readx.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -526,7 +526,7 @@ static NTSTATUS svfs_read(struct ntvfs_module_context *ntvfs, static NTSTATUS svfs_write(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_write *wr) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct svfs_file *f; ssize_t ret; @@ -536,7 +536,7 @@ static NTSTATUS svfs_write(struct ntvfs_module_context *ntvfs, CHECK_READ_ONLY(req); - f = find_fd(private, wr->writex.in.file.ntvfs); + f = find_fd(p, wr->writex.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -572,14 +572,14 @@ static NTSTATUS svfs_flush(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_flush *io) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct svfs_file *f; switch (io->generic.level) { case RAW_FLUSH_FLUSH: case RAW_FLUSH_SMB2: /* ignore the additional unknown option in SMB2 */ - f = find_fd(private, io->generic.in.file.ntvfs); + f = find_fd(p, io->generic.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -587,7 +587,7 @@ static NTSTATUS svfs_flush(struct ntvfs_module_context *ntvfs, return NT_STATUS_OK; case RAW_FLUSH_ALL: - for (f=private->open_files;f;f=f->next) { + for (f=p->open_files;f;f=f->next) { fsync(f->fd); } return NT_STATUS_OK; @@ -603,7 +603,7 @@ static NTSTATUS svfs_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_close *io) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct svfs_file *f; if (io->generic.level != RAW_CLOSE_CLOSE) { @@ -611,7 +611,7 @@ static NTSTATUS svfs_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_INVALID_LEVEL; } - f = find_fd(private, io->close.in.file.ntvfs); + f = find_fd(p, io->close.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -620,7 +620,7 @@ static NTSTATUS svfs_close(struct ntvfs_module_context *ntvfs, return map_nt_error_from_unix(errno); } - DLIST_REMOVE(private->open_files, f); + DLIST_REMOVE(p->open_files, f); talloc_free(f->name); talloc_free(f); @@ -650,7 +650,7 @@ static NTSTATUS svfs_logoff(struct ntvfs_module_context *ntvfs, */ static NTSTATUS svfs_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { return NT_STATUS_OK; } @@ -691,13 +691,13 @@ static NTSTATUS svfs_setfileinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_setfileinfo *info) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct svfs_file *f; struct utimbuf unix_times; CHECK_READ_ONLY(req); - f = find_fd(private, info->generic.in.file.ntvfs); + f = find_fd(p, info->generic.in.file.ntvfs); if (!f) { return NT_STATUS_INVALID_HANDLE; } @@ -743,14 +743,14 @@ static NTSTATUS svfs_setfileinfo(struct ntvfs_module_context *ntvfs, static NTSTATUS svfs_fsinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fsinfo *fs) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct stat st; if (fs->generic.level != RAW_QFS_GENERIC) { return ntvfs_map_fsinfo(ntvfs, req, fs); } - if (sys_fsusage(private->connectpath, + if (sys_fsusage(p->connectpath, &fs->generic.out.blocks_free, &fs->generic.out.blocks_total) == -1) { return map_nt_error_from_unix(errno); @@ -758,7 +758,7 @@ static NTSTATUS svfs_fsinfo(struct ntvfs_module_context *ntvfs, fs->generic.out.block_size = 512; - if (stat(private->connectpath, &st) != 0) { + if (stat(p->connectpath, &st) != 0) { return NT_STATUS_DISK_CORRUPT_ERROR; } @@ -786,13 +786,13 @@ static NTSTATUS svfs_fsattr(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fsattr *fs) { struct stat st; - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; if (fs->generic.level != RAW_FSATTR_GENERIC) { return ntvfs_map_fsattr(ntvfs, req, fs); } - if (stat(private->connectpath, &st) == -1) { + if (stat(p->connectpath, &st) == -1) { return map_nt_error_from_unix(errno); } @@ -830,7 +830,7 @@ static NTSTATUS svfs_search_first(struct ntvfs_module_context *ntvfs, { struct svfs_dir *dir; int i; - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct search_state *search; union smb_search_data file; uint_t max_count; @@ -843,7 +843,7 @@ static NTSTATUS svfs_search_first(struct ntvfs_module_context *ntvfs, return NT_STATUS_NOT_SUPPORTED; } - search = talloc_zero(private, struct search_state); + search = talloc_zero(p, struct search_state); if (!search) { return NT_STATUS_NO_MEMORY; } @@ -855,7 +855,7 @@ static NTSTATUS svfs_search_first(struct ntvfs_module_context *ntvfs, return NT_STATUS_FOOBAR; } - search->handle = private->next_search_handle; + search->handle = p->next_search_handle; search->dir = dir; if (dir->count < max_count) { @@ -889,8 +889,8 @@ static NTSTATUS svfs_search_first(struct ntvfs_module_context *ntvfs, ((io->t2ffirst.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) { talloc_free(search); } else { - private->next_search_handle++; - DLIST_ADD(private->search, search); + p->next_search_handle++; + DLIST_ADD(p->search, search); } return NT_STATUS_OK; @@ -904,7 +904,7 @@ static NTSTATUS svfs_search_next(struct ntvfs_module_context *ntvfs, { struct svfs_dir *dir; int i; - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct search_state *search; union smb_search_data file; uint_t max_count; @@ -917,7 +917,7 @@ static NTSTATUS svfs_search_next(struct ntvfs_module_context *ntvfs, return NT_STATUS_NOT_SUPPORTED; } - for (search=private->search; search; search = search->next) { + for (search=p->search; search; search = search->next) { if (search->handle == io->t2fnext.in.handle) break; } @@ -981,7 +981,7 @@ found: /* work out if we are going to keep the search state */ if ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE) || ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) { - DLIST_REMOVE(private->search, search); + DLIST_REMOVE(p->search, search); talloc_free(search); } @@ -992,10 +992,10 @@ found: static NTSTATUS svfs_search_close(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_search_close *io) { - struct svfs_private *private = ntvfs->private_data; + struct svfs_private *p = ntvfs->private_data; struct search_state *search; - for (search=private->search; search; search = search->next) { + for (search=p->search; search; search = search->next) { if (search->handle == io->findclose.in.handle) break; } @@ -1004,7 +1004,7 @@ static NTSTATUS svfs_search_close(struct ntvfs_module_context *ntvfs, return NT_STATUS_FOOBAR; } - DLIST_REMOVE(private->search, search); + DLIST_REMOVE(p->search, search); talloc_free(search); return NT_STATUS_OK; -- cgit From 7bb44616443babf9fa1f755dc5eb245576b3f8c2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:36:39 +0100 Subject: s4:ntvfs/smb2: s/private/p metze --- source4/ntvfs/smb2/vfs_smb2.c | 78 +++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/source4/ntvfs/smb2/vfs_smb2.c b/source4/ntvfs/smb2/vfs_smb2.c index ebb17e2806..d1e194f638 100644 --- a/source4/ntvfs/smb2/vfs_smb2.c +++ b/source4/ntvfs/smb2/vfs_smb2.c @@ -100,12 +100,12 @@ struct async_info { */ static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private) { - struct cvfs_private *private = p_private; + struct cvfs_private *p = p_private; NTSTATUS status; struct ntvfs_handle *h = NULL; struct cvfs_file *f; - for (f=private->files; f; f=f->next) { + for (f=p->files; f; f=f->next) { if (f->fnum != fnum) continue; h = f->h; break; @@ -117,7 +117,7 @@ static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin } DEBUG(5,("vfs_smb2: sending oplock break level %d for fnum %d\n", level, fnum)); - status = ntvfs_send_oplock_break(private->ntvfs, h, level); + status = ntvfs_send_oplock_break(p->ntvfs, h, level); if (!NT_STATUS_IS_OK(status)) return false; return true; } @@ -157,7 +157,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { NTSTATUS status; - struct cvfs_private *private; + struct cvfs_private *p; const char *host, *user, *pass, *domain, *remote_share; struct composite_context *creq; struct share_config *scfg = ntvfs->ctx->config; @@ -181,12 +181,12 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, machine_account = share_bool_option(scfg, SMB2_USE_MACHINE_ACCT, SMB2_USE_MACHINE_ACCT_DEFAULT); - private = talloc_zero(ntvfs, struct cvfs_private); - if (!private) { + p = talloc_zero(ntvfs, struct cvfs_private); + if (!p) { return NT_STATUS_NO_MEMORY; } - ntvfs->private_data = private; + ntvfs->private_data = p; if (!host) { DEBUG(1,("CIFS backend: You must supply server\n")); @@ -195,7 +195,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, if (user && pass) { DEBUG(5, ("CIFS backend: Using specified password\n")); - credentials = cli_credentials_init(private); + credentials = cli_credentials_init(p); if (!credentials) { return NT_STATUS_NO_MEMORY; } @@ -207,7 +207,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, cli_credentials_set_password(credentials, pass, CRED_SPECIFIED); } else if (machine_account) { DEBUG(5, ("CIFS backend: Using machine account\n")); - credentials = cli_credentials_init(private); + credentials = cli_credentials_init(p); cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx); if (domain) { cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED); @@ -226,25 +226,25 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, lp_smbcli_options(ntvfs->ctx->lp_ctx, &options); - creq = smb2_connect_send(private, host, - lp_parm_string_list(private, ntvfs->ctx->lp_ctx, NULL, "smb2", "ports", NULL), + creq = smb2_connect_send(p, host, + lp_parm_string_list(p, ntvfs->ctx->lp_ctx, NULL, "smb2", "ports", NULL), remote_share, lp_resolve_context(ntvfs->ctx->lp_ctx), credentials, ntvfs->ctx->event_ctx, &options, lp_socket_options(ntvfs->ctx->lp_ctx), - lp_gensec_settings(private, ntvfs->ctx->lp_ctx) + lp_gensec_settings(p, ntvfs->ctx->lp_ctx) ); - status = smb2_connect_recv(creq, private, &tree); + status = smb2_connect_recv(creq, p, &tree); NT_STATUS_NOT_OK_RETURN(status); - status = smb2_get_roothandle(tree, &private->roothandle); + status = smb2_get_roothandle(tree, &p->roothandle); NT_STATUS_NOT_OK_RETURN(status); - private->tree = tree; - private->transport = private->tree->session->transport; - private->ntvfs = ntvfs; + p->tree = tree; + p->transport = p->tree->session->transport; + p->ntvfs = ntvfs; ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); @@ -253,7 +253,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, /* we need to receive oplock break requests from the server */ /* TODO: enable oplocks - smbcli_oplock_handler(private->transport, oplock_handler, private); + smbcli_oplock_handler(p->transport, oplock_handler, p); */ return NT_STATUS_OK; } @@ -263,17 +263,17 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, */ static NTSTATUS cvfs_disconnect(struct ntvfs_module_context *ntvfs) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct async_info *a, *an; /* first cleanup pending requests */ - for (a=private->pending; a; a = an) { + for (a=p->pending; a; a = an) { an = a->next; talloc_free(a->c_req); talloc_free(a); } - talloc_free(private); + talloc_free(p); ntvfs->private_data = NULL; return NT_STATUS_OK; @@ -330,9 +330,9 @@ static void async_simple_composite(struct composite_context *c_req) async->parms = io; \ async->req = req; \ async->f = file; \ - async->cvfs = private; \ + async->cvfs = p; \ async->c_req = c_req; \ - DLIST_ADD(private->pending, async); \ + DLIST_ADD(p->pending, async); \ c_req->async.private_data = async; \ talloc_set_destructor(async, async_info_destructor); \ } \ @@ -364,12 +364,12 @@ static void async_simple_composite(struct composite_context *c_req) static NTSTATUS cvfs_unlink(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_unlink *unl) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct composite_context *c_req; CHECK_ASYNC(req); - c_req = smb2_composite_unlink_send(private->tree, unl); + c_req = smb2_composite_unlink_send(p->tree, unl); SIMPLE_COMPOSITE_TAIL; } @@ -389,7 +389,7 @@ static NTSTATUS cvfs_ioctl(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_chkpath *cp) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smb2_request *c_req; struct smb2_find f; @@ -400,7 +400,7 @@ static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs, find call, using the roothandle we established at connect time */ ZERO_STRUCT(f); - f.in.file.handle = private->roothandle; + f.in.file.handle = p->roothandle; f.in.level = SMB2_FIND_DIRECTORY_INFO; f.in.pattern = cp->chkpath.in.path; /* SMB2 find doesn't accept \ or the empty string - this is the best @@ -412,7 +412,7 @@ static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs, f.in.continue_flags = SMB2_CONTINUE_FLAG_SINGLE | SMB2_CONTINUE_FLAG_RESTART; f.in.max_response_size = 0x1000; - c_req = smb2_find_send(private->tree, &f); + c_req = smb2_find_send(p->tree, &f); SIMPLE_ASYNC_TAIL; } @@ -461,12 +461,12 @@ static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_mkdir(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_mkdir *md) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct composite_context *c_req; CHECK_ASYNC(req); - c_req = smb2_composite_mkdir_send(private->tree, md); + c_req = smb2_composite_mkdir_send(p->tree, md); SIMPLE_COMPOSITE_TAIL; } @@ -477,12 +477,12 @@ static NTSTATUS cvfs_mkdir(struct ntvfs_module_context *ntvfs, static NTSTATUS cvfs_rmdir(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, struct smb_rmdir *rd) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct composite_context *c_req; CHECK_ASYNC(req); - c_req = smb2_composite_rmdir_send(private->tree, rd); + c_req = smb2_composite_rmdir_send(p->tree, rd); SIMPLE_COMPOSITE_TAIL; } @@ -576,7 +576,7 @@ static NTSTATUS cvfs_logoff(struct ntvfs_module_context *ntvfs, */ static NTSTATUS cvfs_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { return NT_STATUS_OK; } @@ -628,7 +628,7 @@ static void async_fsinfo(struct smb2_request *c_req) static NTSTATUS cvfs_fsinfo(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, union smb_fsinfo *fs) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smb2_request *c_req; enum smb_fsinfo_level level = fs->generic.level; @@ -667,9 +667,9 @@ static NTSTATUS cvfs_fsinfo(struct ntvfs_module_context *ntvfs, } fs->generic.level = level; - fs->generic.handle = private->roothandle; + fs->generic.handle = p->roothandle; - c_req = smb2_getinfo_fs_send(private->tree, fs); + c_req = smb2_getinfo_fs_send(p->tree, fs); ASYNC_RECV_TAIL(fs, async_fsinfo); } @@ -691,7 +691,7 @@ static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs, void *search_private, bool (*callback)(void *, const union smb_search_data *)) { - struct cvfs_private *private = ntvfs->private_data; + struct cvfs_private *p = ntvfs->private_data; struct smb2_find f; enum smb_search_data_level smb2_level; uint_t count, i; @@ -733,7 +733,7 @@ static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs, distinguish multiple searches happening at once */ ZERO_STRUCT(f); - f.in.file.handle = private->roothandle; + f.in.file.handle = p->roothandle; f.in.level = smb2_level; f.in.pattern = io->t2ffirst.in.pattern; while (f.in.pattern[0] == '\\') { @@ -742,7 +742,7 @@ static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs, f.in.continue_flags = 0; f.in.max_response_size = 0x10000; - status = smb2_find_level(private->tree, req, &f, &count, &data); + status = smb2_find_level(p->tree, req, &f, &count, &data); NT_STATUS_NOT_OK_RETURN(status); for (i=0;i Date: Mon, 2 Feb 2009 08:37:18 +0100 Subject: s4:ntvfs/unixuid: s/private/priv metze --- source4/ntvfs/unixuid/vfs_unixuid.c | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/source4/ntvfs/unixuid/vfs_unixuid.c b/source4/ntvfs/unixuid/vfs_unixuid.c index 448d610819..db22a85492 100644 --- a/source4/ntvfs/unixuid/vfs_unixuid.c +++ b/source4/ntvfs/unixuid/vfs_unixuid.c @@ -170,7 +170,7 @@ static NTSTATUS nt_token_to_unix_security(struct ntvfs_module_context *ntvfs, static NTSTATUS unixuid_setup_security(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, struct unix_sec_ctx **sec) { - struct unixuid_private *private = ntvfs->private_data; + struct unixuid_private *priv = ntvfs->private_data; struct security_token *token; struct unix_sec_ctx *newsec; NTSTATUS status; @@ -186,20 +186,20 @@ static NTSTATUS unixuid_setup_security(struct ntvfs_module_context *ntvfs, return NT_STATUS_NO_MEMORY; } - if (token == private->last_token) { - newsec = private->last_sec_ctx; + if (token == priv->last_token) { + newsec = priv->last_sec_ctx; } else { status = nt_token_to_unix_security(ntvfs, req, token, &newsec); if (!NT_STATUS_IS_OK(status)) { talloc_free(*sec); return status; } - if (private->last_sec_ctx) { - talloc_free(private->last_sec_ctx); + if (priv->last_sec_ctx) { + talloc_free(priv->last_sec_ctx); } - private->last_sec_ctx = newsec; - private->last_token = token; - talloc_steal(private, newsec); + priv->last_sec_ctx = newsec; + priv->last_token = token; + talloc_steal(priv, newsec); } status = set_unix_security(newsec); @@ -233,24 +233,24 @@ static NTSTATUS unixuid_setup_security(struct ntvfs_module_context *ntvfs, static NTSTATUS unixuid_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { - struct unixuid_private *private; + struct unixuid_private *priv; NTSTATUS status; - private = talloc(ntvfs, struct unixuid_private); - if (!private) { + priv = talloc(ntvfs, struct unixuid_private); + if (!priv) { return NT_STATUS_NO_MEMORY; } - private->wbc_ctx = wbc_init(private, ntvfs->ctx->msg_ctx, + priv->wbc_ctx = wbc_init(priv, ntvfs->ctx->msg_ctx, ntvfs->ctx->event_ctx); - if (private->wbc_ctx == NULL) { - talloc_free(private); + if (priv->wbc_ctx == NULL) { + talloc_free(priv); return NT_STATUS_INTERNAL_ERROR; } - ntvfs->private_data = private; - private->last_sec_ctx = NULL; - private->last_token = NULL; + ntvfs->private_data = priv; + priv->last_sec_ctx = NULL; + priv->last_token = NULL; /* we don't use PASS_THRU_REQ here, as the connect operation runs with root privileges. This allows the backends to setup any database @@ -265,10 +265,10 @@ static NTSTATUS unixuid_connect(struct ntvfs_module_context *ntvfs, */ static NTSTATUS unixuid_disconnect(struct ntvfs_module_context *ntvfs) { - struct unixuid_private *private = ntvfs->private_data; + struct unixuid_private *priv = ntvfs->private_data; NTSTATUS status; - talloc_free(private); + talloc_free(priv); ntvfs->private_data = NULL; status = ntvfs_next_disconnect(ntvfs); @@ -509,12 +509,12 @@ static NTSTATUS unixuid_exit(struct ntvfs_module_context *ntvfs, static NTSTATUS unixuid_logoff(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req) { - struct unixuid_private *private = ntvfs->private_data; + struct unixuid_private *priv = ntvfs->private_data; NTSTATUS status; PASS_THRU_REQ(ntvfs, req, logoff, (ntvfs, req)); - private->last_token = NULL; + priv->last_token = NULL; return status; } @@ -524,11 +524,11 @@ static NTSTATUS unixuid_logoff(struct ntvfs_module_context *ntvfs, */ static NTSTATUS unixuid_async_setup(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, - void *private) + void *private_data) { NTSTATUS status; - PASS_THRU_REQ(ntvfs, req, async_setup, (ntvfs, req, private)); + PASS_THRU_REQ(ntvfs, req, async_setup, (ntvfs, req, private_data)); return status; } -- cgit From 0854950b34dedbbd03120fa359403e3451161a38 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:38:07 +0100 Subject: s4:rpc_server/echo: s/private/private_data metze --- source4/rpc_server/echo/rpc_echo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source4/rpc_server/echo/rpc_echo.c b/source4/rpc_server/echo/rpc_echo.c index 7bb117477c..8bcee7d925 100644 --- a/source4/rpc_server/echo/rpc_echo.c +++ b/source4/rpc_server/echo/rpc_echo.c @@ -157,9 +157,9 @@ struct echo_TestSleep_private { }; static void echo_TestSleep_handler(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct echo_TestSleep_private *p = talloc_get_type(private, + struct echo_TestSleep_private *p = talloc_get_type(private_data, struct echo_TestSleep_private); struct echo_TestSleep *r = p->r; NTSTATUS status; -- cgit From 4523a634cb1702f96cc41099d9761a073c7a6d49 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:39:09 +0100 Subject: s4:rpc_server/remote: s/private/priv metze --- source4/rpc_server/remote/dcesrv_remote.c | 34 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/source4/rpc_server/remote/dcesrv_remote.c b/source4/rpc_server/remote/dcesrv_remote.c index 1310ecee90..7354854e9c 100644 --- a/source4/rpc_server/remote/dcesrv_remote.c +++ b/source4/rpc_server/remote/dcesrv_remote.c @@ -39,7 +39,7 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct { NTSTATUS status; const struct ndr_interface_table *table; - struct dcesrv_remote_private *private; + struct dcesrv_remote_private *priv; const char *binding = lp_parm_string(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "binding"); const char *user, *pass, *domain; struct cli_credentials *credentials; @@ -47,13 +47,13 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct machine_account = lp_parm_bool(dce_call->conn->dce_ctx->lp_ctx, NULL, "dcerpc_remote", "use_machine_account", false); - private = talloc(dce_call->conn, struct dcesrv_remote_private); - if (!private) { + priv = talloc(dce_call->conn, struct dcesrv_remote_private); + if (!priv) { return NT_STATUS_NO_MEMORY; } - private->c_pipe = NULL; - dce_call->context->private = private; + priv->c_pipe = NULL; + dce_call->context->private = priv; if (!binding) { DEBUG(0,("You must specify a DCE/RPC binding string\n")); @@ -72,7 +72,7 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct if (user && pass) { DEBUG(5, ("dcerpc_remote: RPC Proxy: Using specified account\n")); - credentials = cli_credentials_init(private); + credentials = cli_credentials_init(priv); if (!credentials) { return NT_STATUS_NO_MEMORY; } @@ -84,7 +84,7 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct cli_credentials_set_password(credentials, pass, CRED_SPECIFIED); } else if (machine_account) { DEBUG(5, ("dcerpc_remote: RPC Proxy: Using machine account\n")); - credentials = cli_credentials_init(private); + credentials = cli_credentials_init(priv); cli_credentials_set_conf(credentials, dce_call->conn->dce_ctx->lp_ctx); if (domain) { cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED); @@ -101,8 +101,8 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct return NT_STATUS_INVALID_PARAMETER; } - status = dcerpc_pipe_connect(private, - &(private->c_pipe), binding, table, + status = dcerpc_pipe_connect(priv, + &(priv->c_pipe), binding, table, credentials, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx); @@ -116,9 +116,9 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct static void remote_op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface) { - struct dcesrv_remote_private *private = (struct dcesrv_remote_private *)context->private; + struct dcesrv_remote_private *priv = (struct dcesrv_remote_private *)context->private; - talloc_free(private->c_pipe); + talloc_free(priv->c_pipe); return; } @@ -156,7 +156,7 @@ static NTSTATUS remote_op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CT static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r) { - struct dcesrv_remote_private *private = dce_call->context->private; + struct dcesrv_remote_private *priv = dce_call->context->private; uint16_t opnum = dce_call->pkt.u.request.opnum; const struct ndr_interface_table *table = dce_call->context->iface->private; const struct ndr_interface_call *call; @@ -165,23 +165,23 @@ static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CT name = table->calls[opnum].name; call = &table->calls[opnum]; - if (private->c_pipe->conn->flags & DCERPC_DEBUG_PRINT_IN) { + if (priv->c_pipe->conn->flags & DCERPC_DEBUG_PRINT_IN) { ndr_print_function_debug(call->ndr_print, name, NDR_IN | NDR_SET_VALUES, r); } - private->c_pipe->conn->flags |= DCERPC_NDR_REF_ALLOC; + priv->c_pipe->conn->flags |= DCERPC_NDR_REF_ALLOC; /* we didn't use the return code of this function as we only check the last_fault_code */ - dcerpc_ndr_request(private->c_pipe, NULL, table, opnum, mem_ctx,r); + dcerpc_ndr_request(priv->c_pipe, NULL, table, opnum, mem_ctx,r); - dce_call->fault_code = private->c_pipe->last_fault_code; + dce_call->fault_code = priv->c_pipe->last_fault_code; if (dce_call->fault_code != 0) { DEBUG(0,("dcesrv_remote: call[%s] failed with: %s!\n",name, dcerpc_errstr(mem_ctx, dce_call->fault_code))); return NT_STATUS_NET_WRITE_FAULT; } if ((dce_call->fault_code == 0) && - (private->c_pipe->conn->flags & DCERPC_DEBUG_PRINT_OUT)) { + (priv->c_pipe->conn->flags & DCERPC_DEBUG_PRINT_OUT)) { ndr_print_function_debug(call->ndr_print, name, NDR_OUT, r); } -- cgit From 5bf95a71ddfeb6d2a77d7b4f488a4f5cf57f00f0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:39:45 +0100 Subject: s4:smb_server: s/private/private_data metze --- source4/smb_server/smb/receive.c | 4 ++-- source4/smb_server/smb/search.c | 4 ++-- source4/smb_server/smb/trans2.c | 4 ++-- source4/smb_server/smb2/find.c | 4 ++-- source4/smb_server/smb2/receive.c | 4 ++-- source4/smb_server/smb_server.c | 8 ++++---- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/source4/smb_server/smb/receive.c b/source4/smb_server/smb/receive.c index 0afa3a652d..03631f8f0b 100644 --- a/source4/smb_server/smb/receive.c +++ b/source4/smb_server/smb/receive.c @@ -351,9 +351,9 @@ static const struct smb_message_struct receive a SMB request header from the wire, forming a request_context from the result ****************************************************************************/ -NTSTATUS smbsrv_recv_smb_request(void *private, DATA_BLOB blob) +NTSTATUS smbsrv_recv_smb_request(void *private_data, DATA_BLOB blob) { - struct smbsrv_connection *smb_conn = talloc_get_type(private, struct smbsrv_connection); + struct smbsrv_connection *smb_conn = talloc_get_type(private_data, struct smbsrv_connection); struct smbsrv_request *req; struct timeval cur_time = timeval_current(); uint8_t command; diff --git a/source4/smb_server/smb/search.c b/source4/smb_server/smb/search.c index 90b2331271..bf4721757b 100644 --- a/source4/smb_server/smb/search.c +++ b/source4/smb_server/smb/search.c @@ -65,9 +65,9 @@ static bool find_fill_info(struct smbsrv_request *req, } /* callback function for search first/next */ -static bool find_callback(void *private, const union smb_search_data *file) +static bool find_callback(void *private_data, const union smb_search_data *file) { - struct search_state *state = (struct search_state *)private; + struct search_state *state = (struct search_state *)private_data; return find_fill_info(state->req, file); } diff --git a/source4/smb_server/smb/trans2.c b/source4/smb_server/smb/trans2.c index 40ffeeef48..e0f6438dc6 100644 --- a/source4/smb_server/smb/trans2.c +++ b/source4/smb_server/smb/trans2.c @@ -800,9 +800,9 @@ static NTSTATUS find_fill_info(struct find_state *state, } /* callback function for trans2 findfirst/findnext */ -static bool find_callback(void *private, const union smb_search_data *file) +static bool find_callback(void *private_data, const union smb_search_data *file) { - struct find_state *state = talloc_get_type(private, struct find_state); + struct find_state *state = talloc_get_type(private_data, struct find_state); struct smb_trans2 *trans = state->op->trans; uint_t old_length; diff --git a/source4/smb_server/smb2/find.c b/source4/smb_server/smb2/find.c index 32b280c5c2..10fcda9434 100644 --- a/source4/smb_server/smb2/find.c +++ b/source4/smb_server/smb2/find.c @@ -40,9 +40,9 @@ struct smb2srv_find_state { }; /* callback function for SMB2 Find */ -static bool smb2srv_find_callback(void *private, const union smb_search_data *file) +static bool smb2srv_find_callback(void *private_data, const union smb_search_data *file) { - struct smb2srv_find_state *state = talloc_get_type(private, struct smb2srv_find_state); + struct smb2srv_find_state *state = talloc_get_type(private_data, struct smb2srv_find_state); struct smb2_find *info = state->info; uint32_t old_length; NTSTATUS status; diff --git a/source4/smb_server/smb2/receive.c b/source4/smb_server/smb2/receive.c index c3607f0a33..5a857e133f 100644 --- a/source4/smb_server/smb2/receive.c +++ b/source4/smb_server/smb2/receive.c @@ -449,9 +449,9 @@ notcon: return NT_STATUS_OK; } -NTSTATUS smbsrv_recv_smb2_request(void *private, DATA_BLOB blob) +NTSTATUS smbsrv_recv_smb2_request(void *private_data, DATA_BLOB blob) { - struct smbsrv_connection *smb_conn = talloc_get_type(private, struct smbsrv_connection); + struct smbsrv_connection *smb_conn = talloc_get_type(private_data, struct smbsrv_connection); struct smb2srv_request *req; struct timeval cur_time = timeval_current(); uint32_t protocol_version; diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c index e9531d8b39..a18440bfa8 100644 --- a/source4/smb_server/smb_server.c +++ b/source4/smb_server/smb_server.c @@ -34,10 +34,10 @@ #include "dsdb/samdb/samdb.h" #include "param/param.h" -static NTSTATUS smbsrv_recv_generic_request(void *private, DATA_BLOB blob) +static NTSTATUS smbsrv_recv_generic_request(void *private_data, DATA_BLOB blob) { NTSTATUS status; - struct smbsrv_connection *smb_conn = talloc_get_type(private, struct smbsrv_connection); + struct smbsrv_connection *smb_conn = talloc_get_type(private_data, struct smbsrv_connection); uint32_t protocol_version; /* see if its a special NBT packet */ @@ -109,9 +109,9 @@ static void smbsrv_send(struct stream_connection *conn, uint16_t flags) /* handle socket recv errors */ -static void smbsrv_recv_error(void *private, NTSTATUS status) +static void smbsrv_recv_error(void *private_data, NTSTATUS status) { - struct smbsrv_connection *smb_conn = talloc_get_type(private, struct smbsrv_connection); + struct smbsrv_connection *smb_conn = talloc_get_type(private_data, struct smbsrv_connection); smbsrv_terminate_connection(smb_conn, nt_errstr(status)); } -- cgit From 29cc638c2cfe4ab785d52c3cc61e81dfaf387b29 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:41:28 +0100 Subject: s4:smbd: s/private/private_data metze --- source4/smbd/process_prefork.c | 12 ++++++------ source4/smbd/process_single.c | 10 +++++----- source4/smbd/process_standard.c | 14 +++++++------- source4/smbd/process_thread.c | 16 ++++++++-------- source4/smbd/server.c | 8 ++++---- source4/smbd/service_named_pipe.c | 2 +- source4/smbd/service_stream.c | 24 ++++++++++++------------ source4/smbd/service_task.c | 4 ++-- 8 files changed, 45 insertions(+), 45 deletions(-) diff --git a/source4/smbd/process_prefork.c b/source4/smbd/process_prefork.c index ad8172d3a7..979a65482e 100644 --- a/source4/smbd/process_prefork.c +++ b/source4/smbd/process_prefork.c @@ -74,7 +74,7 @@ static void prefork_accept_connection(struct tevent_context *ev, void (*new_conn)(struct tevent_context *, struct loadparm_context *, struct socket_context *, struct server_id , void *), - void *private) + void *private_data) { NTSTATUS status; struct socket_context *connected_socket; @@ -86,9 +86,9 @@ static void prefork_accept_connection(struct tevent_context *ev, return; } - talloc_steal(private, connected_socket); + talloc_steal(private_data, connected_socket); - new_conn(ev, lp_ctx, connected_socket, cluster_id(pid, socket_get_fd(connected_socket)), private); + new_conn(ev, lp_ctx, connected_socket, cluster_id(pid, socket_get_fd(connected_socket)), private_data); } /* @@ -98,7 +98,7 @@ static void prefork_new_task(struct tevent_context *ev, struct loadparm_context *lp_ctx, const char *service_name, void (*new_task_fn)(struct tevent_context *, struct loadparm_context *lp_ctx, struct server_id , void *), - void *private) + void *private_data) { pid_t pid; int i, num_children; @@ -120,7 +120,7 @@ static void prefork_new_task(struct tevent_context *ev, /* the service has given us a private pointer that encapsulates the context it needs for this new connection - everything else will be freed */ - talloc_steal(ev2, private); + talloc_steal(ev2, private_data); /* this will free all the listening sockets and all state that is not associated with this new connection */ @@ -131,7 +131,7 @@ static void prefork_new_task(struct tevent_context *ev, prefork_reload_after_fork(); /* setup this new connection: process will bind to it's sockets etc */ - new_task_fn(ev2, lp_ctx, cluster_id(pid, 0), private); + new_task_fn(ev2, lp_ctx, cluster_id(pid, 0), private_data); num_children = lp_parm_int(lp_ctx, NULL, "prefork children", service_name, 0); if (num_children == 0) { diff --git a/source4/smbd/process_single.c b/source4/smbd/process_single.c index bb82c384d6..738ace95c7 100644 --- a/source4/smbd/process_single.c +++ b/source4/smbd/process_single.c @@ -43,7 +43,7 @@ static void single_accept_connection(struct tevent_context *ev, struct loadparm_context *, struct socket_context *, struct server_id , void *), - void *private) + void *private_data) { NTSTATUS status; struct socket_context *connected_socket; @@ -67,12 +67,12 @@ static void single_accept_connection(struct tevent_context *ev, return; } - talloc_steal(private, connected_socket); + talloc_steal(private_data, connected_socket); /* The cluster_id(0, fd) cannot collide with the incrementing * task below, as the first component is 0, not 1 */ new_conn(ev, lp_ctx, connected_socket, - cluster_id(0, socket_get_fd(connected_socket)), private); + cluster_id(0, socket_get_fd(connected_socket)), private_data); } /* @@ -82,7 +82,7 @@ static void single_new_task(struct tevent_context *ev, struct loadparm_context *lp_ctx, const char *service_name, void (*new_task)(struct tevent_context *, struct loadparm_context *, struct server_id, void *), - void *private) + void *private_data) { static uint32_t taskid = 0; @@ -90,7 +90,7 @@ static void single_new_task(struct tevent_context *ev, * in the accept connection above, and unlikly to collide with * PIDs from process modal standard (don't run samba as * init) */ - new_task(ev, lp_ctx, cluster_id(1, taskid++), private); + new_task(ev, lp_ctx, cluster_id(1, taskid++), private_data); } diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c index b20adbfd16..137e0a7ce0 100644 --- a/source4/smbd/process_standard.c +++ b/source4/smbd/process_standard.c @@ -61,7 +61,7 @@ static void standard_accept_connection(struct tevent_context *ev, void (*new_conn)(struct tevent_context *, struct loadparm_context *, struct socket_context *, struct server_id , void *), - void *private) + void *private_data) { NTSTATUS status; struct socket_context *sock2; @@ -97,8 +97,8 @@ static void standard_accept_connection(struct tevent_context *ev, /* the service has given us a private pointer that encapsulates the context it needs for this new connection - everything else will be freed */ - talloc_steal(ev2, private); - talloc_steal(private, sock2); + talloc_steal(ev2, private_data); + talloc_steal(private_data, sock2); /* this will free all the listening sockets and all state that is not associated with this new connection */ @@ -128,7 +128,7 @@ static void standard_accept_connection(struct tevent_context *ev, talloc_free(s); /* setup this new connection. Cluster ID is PID based for this process modal */ - new_conn(ev2, lp_ctx, sock2, cluster_id(pid, 0), private); + new_conn(ev2, lp_ctx, sock2, cluster_id(pid, 0), private_data); /* we can't return to the top level here, as that event context is gone, so we now process events in the new event context until there are no @@ -146,7 +146,7 @@ static void standard_new_task(struct tevent_context *ev, struct loadparm_context *lp_ctx, const char *service_name, void (*new_task)(struct tevent_context *, struct loadparm_context *lp_ctx, struct server_id , void *), - void *private) + void *private_data) { pid_t pid; struct tevent_context *ev2; @@ -166,7 +166,7 @@ static void standard_new_task(struct tevent_context *ev, /* the service has given us a private pointer that encapsulates the context it needs for this new connection - everything else will be freed */ - talloc_steal(ev2, private); + talloc_steal(ev2, private_data); /* this will free all the listening sockets and all state that is not associated with this new connection */ @@ -183,7 +183,7 @@ static void standard_new_task(struct tevent_context *ev, setproctitle("task %s server_id[%d]", service_name, pid); /* setup this new task. Cluster ID is PID based for this process modal */ - new_task(ev2, lp_ctx, cluster_id(pid, 0), private); + new_task(ev2, lp_ctx, cluster_id(pid, 0), private_data); /* we can't return to the top level here, as that event context is gone, so we now process events in the new event context until there are no diff --git a/source4/smbd/process_thread.c b/source4/smbd/process_thread.c index 3c3b6b287f..5be6374c14 100644 --- a/source4/smbd/process_thread.c +++ b/source4/smbd/process_thread.c @@ -41,14 +41,14 @@ struct new_conn_state { struct socket_context *sock; struct loadparm_context *lp_ctx; void (*new_conn)(struct tevent_context *, struct loadparm_context *lp_ctx, struct socket_context *, uint32_t , void *); - void *private; + void *private_data; }; static void *thread_connection_fn(void *thread_parm) { struct new_conn_state *new_conn = talloc_get_type(thread_parm, struct new_conn_state); - new_conn->new_conn(new_conn->ev, new_conn->lp_ctx, new_conn->sock, pthread_self(), new_conn->private); + new_conn->new_conn(new_conn->ev, new_conn->lp_ctx, new_conn->sock, pthread_self(), new_conn->private_data); /* run this connection from here */ event_loop_wait(new_conn->ev); @@ -68,7 +68,7 @@ static void thread_accept_connection(struct tevent_context *ev, struct loadparm_context *, struct socket_context *, uint32_t , void *), - void *private) + void *private_data) { NTSTATUS status; int rc; @@ -87,7 +87,7 @@ static void thread_accept_connection(struct tevent_context *ev, } state->new_conn = new_conn; - state->private = private; + state->private_data = private_data; state->lp_ctx = lp_ctx; state->ev = ev2; @@ -125,7 +125,7 @@ struct new_task_state { struct loadparm_context *lp_ctx; void (*new_task)(struct tevent_context *, struct loadparm_context *, uint32_t , void *); - void *private; + void *private_data; }; static void *thread_task_fn(void *thread_parm) @@ -133,7 +133,7 @@ static void *thread_task_fn(void *thread_parm) struct new_task_state *new_task = talloc_get_type(thread_parm, struct new_task_state); new_task->new_task(new_task->ev, new_task->lp_ctx, pthread_self(), - new_task->private); + new_task->private_data); /* run this connection from here */ event_loop_wait(new_task->ev); @@ -152,7 +152,7 @@ static void thread_new_task(struct tevent_context *ev, void (*new_task)(struct tevent_context *, struct loadparm_context *, uint32_t , void *), - void *private) + void *private_data) { int rc; pthread_t thread_id; @@ -171,7 +171,7 @@ static void thread_new_task(struct tevent_context *ev, state->new_task = new_task; state->lp_ctx = lp_ctx; - state->private = private; + state->private_data = private_data; state->ev = ev2; pthread_attr_init(&thread_attr); diff --git a/source4/smbd/server.c b/source4/smbd/server.c index df970661f1..247a10f60f 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -149,9 +149,9 @@ static void setup_signals(void) handle io on stdin */ static void server_stdin_handler(struct tevent_context *event_ctx, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - const char *binary_name = (const char *)private; + const char *binary_name = (const char *)private_data; uint8_t c; if (read(0, &c, 1) == 0) { DEBUG(0,("%s: EOF on stdin - terminating\n", binary_name)); @@ -169,9 +169,9 @@ static void server_stdin_handler(struct tevent_context *event_ctx, struct tevent */ _NORETURN_ static void max_runtime_handler(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - const char *binary_name = (const char *)private; + const char *binary_name = (const char *)private_data; DEBUG(0,("%s: maximum runtime exceeded - terminating\n", binary_name)); exit(0); } diff --git a/source4/smbd/service_named_pipe.c b/source4/smbd/service_named_pipe.c index e3c0908a15..ffa4072392 100644 --- a/source4/smbd/service_named_pipe.c +++ b/source4/smbd/service_named_pipe.c @@ -238,7 +238,7 @@ static void named_pipe_recv_error(void *private_data, NTSTATUS status) stream_terminate_connection(pipe_conn->connection, nt_errstr(status)); } -static NTSTATUS named_pipe_full_request(void *private, DATA_BLOB blob, size_t *size) +static NTSTATUS named_pipe_full_request(void *private_data, DATA_BLOB blob, size_t *size) { if (blob.length < 8) { return STATUS_MORE_ENTRIES; diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c index 6dff01f4f3..fe07dc5a38 100644 --- a/source4/smbd/service_stream.c +++ b/source4/smbd/service_stream.c @@ -47,7 +47,7 @@ struct stream_socket { struct tevent_context *event_ctx; const struct model_ops *model_ops; struct socket_context *sock; - void *private; + void *private_data; }; @@ -101,16 +101,16 @@ static void stream_io_handler(struct stream_connection *conn, uint16_t flags) } static void stream_io_handler_fde(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct stream_connection *conn = talloc_get_type(private, + struct stream_connection *conn = talloc_get_type(private_data, struct stream_connection); stream_io_handler(conn, flags); } -void stream_io_handler_callback(void *private, uint16_t flags) +void stream_io_handler_callback(void *private_data, uint16_t flags) { - struct stream_connection *conn = talloc_get_type(private, + struct stream_connection *conn = talloc_get_type(private_data, struct stream_connection); stream_io_handler(conn, flags); } @@ -163,9 +163,9 @@ NTSTATUS stream_new_connection_merge(struct tevent_context *ev, static void stream_new_connection(struct tevent_context *ev, struct loadparm_context *lp_ctx, struct socket_context *sock, - struct server_id server_id, void *private) + struct server_id server_id, void *private_data) { - struct stream_socket *stream_socket = talloc_get_type(private, struct stream_socket); + struct stream_socket *stream_socket = talloc_get_type(private_data, struct stream_socket); struct stream_connection *srv_conn; struct socket_address *c, *s; @@ -177,7 +177,7 @@ static void stream_new_connection(struct tevent_context *ev, talloc_steal(srv_conn, sock); - srv_conn->private = stream_socket->private; + srv_conn->private = stream_socket->private_data; srv_conn->model_ops = stream_socket->model_ops; srv_conn->socket = sock; srv_conn->server_id = server_id; @@ -235,9 +235,9 @@ static void stream_new_connection(struct tevent_context *ev, called when someone opens a connection to one of our listening ports */ static void stream_accept_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct stream_socket *stream_socket = talloc_get_type(private, struct stream_socket); + struct stream_socket *stream_socket = talloc_get_type(private_data, struct stream_socket); /* ask the process model to create us a process for this new connection. When done, it calls stream_new_connection() @@ -263,7 +263,7 @@ NTSTATUS stream_setup_socket(struct tevent_context *event_context, const char *sock_addr, uint16_t *port, const char *socket_options, - void *private) + void *private_data) { NTSTATUS status; struct stream_socket *stream_socket; @@ -352,7 +352,7 @@ NTSTATUS stream_setup_socket(struct tevent_context *event_context, tevent_fd_set_close_fn(fde, socket_tevent_fd_close_fn); socket_set_flags(stream_socket->sock, SOCKET_FLAG_NOCLOSE); - stream_socket->private = talloc_reference(stream_socket, private); + stream_socket->private_data = talloc_reference(stream_socket, private_data); stream_socket->ops = stream_ops; stream_socket->event_ctx = event_context; stream_socket->model_ops = model_ops; diff --git a/source4/smbd/service_task.c b/source4/smbd/service_task.c index d3951a4a9a..c4fd3d4e98 100644 --- a/source4/smbd/service_task.c +++ b/source4/smbd/service_task.c @@ -53,9 +53,9 @@ struct task_state { */ static void task_server_callback(struct tevent_context *event_ctx, struct loadparm_context *lp_ctx, - struct server_id server_id, void *private) + struct server_id server_id, void *private_data) { - struct task_state *state = talloc_get_type(private, struct task_state); + struct task_state *state = talloc_get_type(private_data, struct task_state); struct task_server *task; task = talloc(event_ctx, struct task_server); -- cgit From e3dfbc9b7684e969776d3f7dbc7c4dad4108791b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:42:16 +0100 Subject: s4:ntlm_auth: s/private/private1 metze --- source4/utils/ntlm_auth.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/source4/utils/ntlm_auth.c b/source4/utils/ntlm_auth.c index 074ab698cf..bd262683d5 100644 --- a/source4/utils/ntlm_auth.c +++ b/source4/utils/ntlm_auth.c @@ -59,22 +59,22 @@ enum stdio_helper_mode { typedef void (*stdio_helper_function)(enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **private2); static void manage_squid_basic_request (enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **private2); static void manage_gensec_request (enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **private2); static void manage_ntlm_server_1_request (enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **private2); static void manage_squid_request(struct loadparm_context *lp_ctx, @@ -248,7 +248,7 @@ static NTSTATUS local_pw_check_specified(struct loadparm_context *lp_ctx, static void manage_squid_basic_request(enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **private2) { char *user, *pass; @@ -280,7 +280,7 @@ static void manage_squid_basic_request(enum stdio_helper_mode stdio_helper_mode, static void manage_gensec_get_pw_request(enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **password) { DATA_BLOB in; @@ -298,7 +298,7 @@ static void manage_gensec_get_pw_request(enum stdio_helper_mode stdio_helper_mod if (strncmp(buf, "PW ", 3) == 0) { - *password = talloc_strndup(*private /* hopefully the right gensec context, useful to use for talloc */, + *password = talloc_strndup(*private1 /* hopefully the right gensec context, useful to use for talloc */, (const char *)in.data, in.length); if (*password == NULL) { @@ -380,7 +380,7 @@ static void gensec_want_feature_list(struct gensec_security *state, char* featur static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **private2) { DATA_BLOB in; @@ -405,15 +405,15 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, TALLOC_CTX *mem_ctx; - if (*private) { - state = (struct gensec_ntlm_state *)*private; + if (*private1) { + state = (struct gensec_ntlm_state *)*private1; } else { state = talloc_zero(NULL, struct gensec_ntlm_state); if (!state) { mux_printf(mux_id, "BH No Memory\n"); exit(1); } - *private = state; + *private1 = state; if (opt_password) { state->set_password = opt_password; } @@ -714,7 +714,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode, static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mode, struct loadparm_context *lp_ctx, - char *buf, int length, void **private, + char *buf, int length, void **private1, unsigned int mux_id, void **private2) { char *request, *parameter; @@ -922,7 +922,7 @@ static void manage_squid_request(struct loadparm_context *lp_ctx, enum stdio_hel static struct mux_private *mux_private; static void *normal_private; - void **private; + void **private1; buf = talloc_strdup(NULL, ""); @@ -1004,13 +1004,13 @@ static void manage_squid_request(struct loadparm_context *lp_ctx, enum stdio_hel (sizeof(*mux_private->private_pointers) * (mux_private->max_mux - prev_max))); }; - private = &mux_private->private_pointers[mux_id]; + private1 = &mux_private->private_pointers[mux_id]; } else { c = buf; - private = &normal_private; + private1 = &normal_private; } - fn(helper_mode, lp_ctx, c, length, private, mux_id, private2); + fn(helper_mode, lp_ctx, c, length, private1, mux_id, private2); talloc_free(buf); } -- cgit From 100f4e318e2cf61413a70bb269efadc2c73228c8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:42:38 +0100 Subject: s4:web_server: s/private/private_data metze --- source4/web_server/web_server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source4/web_server/web_server.c b/source4/web_server/web_server.c index c79fa8c753..9d1d160ae7 100644 --- a/source4/web_server/web_server.c +++ b/source4/web_server/web_server.c @@ -50,9 +50,9 @@ static int websrv_destructor(struct websrv_context *web) */ static void websrv_timeout(struct tevent_context *event_context, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct websrv_context *web = talloc_get_type(private, struct websrv_context); + struct websrv_context *web = talloc_get_type(private_data, struct websrv_context); struct stream_connection *conn = web->conn; web->conn = NULL; /* TODO: send a message to any running esp context on this connection -- cgit From 7237d777d5fb208a7ae305090d07c11bb6e6ba34 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:43:37 +0100 Subject: s4:winbind: s/private/private_data metze --- source4/winbind/wb_samba3_protocol.c | 6 +++--- source4/winbind/wb_server.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source4/winbind/wb_samba3_protocol.c b/source4/winbind/wb_samba3_protocol.c index d40e0e6bc6..77c5bf3a1e 100644 --- a/source4/winbind/wb_samba3_protocol.c +++ b/source4/winbind/wb_samba3_protocol.c @@ -28,7 +28,7 @@ work out if a packet is complete for protocols that use a 32 bit host byte order length */ -NTSTATUS wbsrv_samba3_packet_full_request(void *private, DATA_BLOB blob, size_t *size) +NTSTATUS wbsrv_samba3_packet_full_request(void *private_data, DATA_BLOB blob, size_t *size) { uint32_t *len; if (blob.length < 4) { @@ -270,10 +270,10 @@ NTSTATUS wbsrv_samba3_send_reply(struct wbsrv_samba3_call *call) return status; } -NTSTATUS wbsrv_samba3_process(void *private, DATA_BLOB blob) +NTSTATUS wbsrv_samba3_process(void *private_data, DATA_BLOB blob) { NTSTATUS status; - struct wbsrv_connection *wbconn = talloc_get_type(private, + struct wbsrv_connection *wbconn = talloc_get_type(private_data, struct wbsrv_connection); struct wbsrv_samba3_call *call; status = wbsrv_samba3_pull_request(blob, wbconn, &call); diff --git a/source4/winbind/wb_server.c b/source4/winbind/wb_server.c index 9ffcd467ee..bf1f3f29ac 100644 --- a/source4/winbind/wb_server.c +++ b/source4/winbind/wb_server.c @@ -41,9 +41,9 @@ void wbsrv_terminate_connection(struct wbsrv_connection *wbconn, const char *rea /* called on a tcp recv error */ -static void wbsrv_recv_error(void *private, NTSTATUS status) +static void wbsrv_recv_error(void *private_data, NTSTATUS status) { - struct wbsrv_connection *wbconn = talloc_get_type(private, struct wbsrv_connection); + struct wbsrv_connection *wbconn = talloc_get_type(private_data, struct wbsrv_connection); wbsrv_terminate_connection(wbconn, nt_errstr(status)); } -- cgit From 35f7cee25db3f4a3db9bfa6d7a12f1d9d6698ca0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:44:06 +0100 Subject: s4:wrepl_server: s/private/private_data metze --- source4/wrepl_server/wrepl_in_connection.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source4/wrepl_server/wrepl_in_connection.c b/source4/wrepl_server/wrepl_in_connection.c index ecc265e590..711ae866dd 100644 --- a/source4/wrepl_server/wrepl_in_connection.c +++ b/source4/wrepl_server/wrepl_in_connection.c @@ -47,9 +47,9 @@ static int terminate_after_send_destructor(struct wreplsrv_in_connection **tas) /* receive some data on a WREPL connection */ -static NTSTATUS wreplsrv_recv_request(void *private, DATA_BLOB blob) +static NTSTATUS wreplsrv_recv_request(void *private_data, DATA_BLOB blob) { - struct wreplsrv_in_connection *wreplconn = talloc_get_type(private, struct wreplsrv_in_connection); + struct wreplsrv_in_connection *wreplconn = talloc_get_type(private_data, struct wreplsrv_in_connection); struct wreplsrv_in_call *call; DATA_BLOB packet_in_blob; DATA_BLOB packet_out_blob; @@ -142,9 +142,9 @@ static void wreplsrv_send(struct stream_connection *conn, uint16_t flags) /* handle socket recv errors */ -static void wreplsrv_recv_error(void *private, NTSTATUS status) +static void wreplsrv_recv_error(void *private_data, NTSTATUS status) { - struct wreplsrv_in_connection *wreplconn = talloc_get_type(private, + struct wreplsrv_in_connection *wreplconn = talloc_get_type(private_data, struct wreplsrv_in_connection); wreplsrv_terminate_in_connection(wreplconn, nt_errstr(status)); } -- cgit From ab7f003aad6d16103c72ec3330836340e83a230a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:44:44 +0100 Subject: s4:torture: s/private/private_data metze --- source4/torture/gentest.c | 12 ++++++------ source4/torture/nbench/nbio.c | 6 +++--- source4/torture/raw/oplock.c | 20 ++++++++++---------- source4/torture/raw/search.c | 8 ++++---- source4/torture/unix/unix_info2.c | 4 ++-- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c index 0677d9ac8e..428be25503 100644 --- a/source4/torture/gentest.c +++ b/source4/torture/gentest.c @@ -125,9 +125,9 @@ static struct smb2_handle bad_smb2_handle; static bool oplock_handler_smb2(struct smb2_transport *transport, const struct smb2_handle *handle, uint8_t level, void *private_data); -static void idle_func_smb2(struct smb2_transport *transport, void *private); -static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private); -static void idle_func_smb(struct smbcli_transport *transport, void *private); +static void idle_func_smb2(struct smb2_transport *transport, void *private_data); +static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private_data); +static void idle_func_smb(struct smbcli_transport *transport, void *private_data); /* check if a string should be ignored. This is used as the basis @@ -976,7 +976,7 @@ static void oplock_handler_close_recv_smb(struct smbcli_request *req) /* the oplock handler will either ack the break or close the file */ -static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private) +static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private_data) { union smb_close io; int i, j; @@ -1035,7 +1035,7 @@ static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, an operation on another connection blocking until that break is acked we check for operations on all transports in the idle function */ -static void idle_func_smb(struct smbcli_transport *transport, void *private) +static void idle_func_smb(struct smbcli_transport *transport, void *private_data) { int i, j; for (i=0;iclose_on_break) { printf("oplock break on %s - closing\n", info->fname); - oplock_handler_close(transport, tid, fnum, level, private); + oplock_handler_close(transport, tid, fnum, level, private_data); return true; } diff --git a/source4/torture/raw/search.c b/source4/torture/raw/search.c index 2a6aef20b5..8a3168dcc4 100644 --- a/source4/torture/raw/search.c +++ b/source4/torture/raw/search.c @@ -31,9 +31,9 @@ /* callback function for single_search */ -static bool single_search_callback(void *private, const union smb_search_data *file) +static bool single_search_callback(void *private_data, const union smb_search_data *file) { - union smb_search_data *data = (union smb_search_data *)private; + union smb_search_data *data = (union smb_search_data *)private_data; *data = *file; @@ -510,9 +510,9 @@ struct multiple_result { /* callback function for multiple_search */ -static bool multiple_search_callback(void *private, const union smb_search_data *file) +static bool multiple_search_callback(void *private_data, const union smb_search_data *file) { - struct multiple_result *data = (struct multiple_result *)private; + struct multiple_result *data = (struct multiple_result *)private_data; data->count++; diff --git a/source4/torture/unix/unix_info2.c b/source4/torture/unix/unix_info2.c index d0a2c3d041..30fe912234 100644 --- a/source4/torture/unix/unix_info2.c +++ b/source4/torture/unix/unix_info2.c @@ -201,9 +201,9 @@ static bool query_path_info2(void *mem_ctx, -1, fname, info2); } -static bool search_callback(void *private, const union smb_search_data *fdata) +static bool search_callback(void *private_data, const union smb_search_data *fdata) { - struct unix_info2 *info2 = (struct unix_info2 *)private; + struct unix_info2 *info2 = (struct unix_info2 *)private_data; info2->end_of_file = fdata->unix_info2.end_of_file; info2->num_bytes = fdata->unix_info2.num_bytes; -- cgit From 23bec6c670073fc419908c65918d885e6d9553e2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:50:04 +0100 Subject: s4:includes.h: stdlib.h and stdbool.h are already included by replace.h metze --- source4/include/includes.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/source4/include/includes.h b/source4/include/includes.h index f925e836c5..c1c565118d 100644 --- a/source4/include/includes.h +++ b/source4/include/includes.h @@ -34,8 +34,6 @@ #include "system/wait.h" /* Lists, trees, caching, database... */ -#include -#include #include #ifndef _PRINTF_ATTRIBUTE #define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2) -- cgit From 096b4a9bd054650f3f01be41e23b4168686ed9f2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 09:12:52 +0100 Subject: s4:libcli/smb2: s/class/info_class metze --- source4/libcli/smb2/getinfo.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c index b462bab1de..14d911683e 100644 --- a/source4/libcli/smb2/getinfo.c +++ b/source4/libcli/smb2/getinfo.c @@ -95,18 +95,19 @@ NTSTATUS smb2_getinfo(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, /* map a generic info level to a SMB2 info level */ -uint16_t smb2_getinfo_map_level(uint16_t level, uint8_t class) +uint16_t smb2_getinfo_map_level(uint16_t level, uint8_t info_class) { - if (class == SMB2_GETINFO_FILE && + if (info_class == SMB2_GETINFO_FILE && level == RAW_FILEINFO_SEC_DESC) { return SMB2_GETINFO_SECURITY; } - if ((level & 0xFF) == class) { + if ((level & 0xFF) == info_class) { return level; } else if (level > 1000) { - return ((level-1000)<<8) | class; + return ((level-1000)<<8) | info_class; } - DEBUG(0,("Unable to map SMB2 info level 0x%04x of class %d\n", level, class)); + DEBUG(0,("Unable to map SMB2 info level 0x%04x of class %d\n", + level, info_class)); return 0; } -- cgit From 2dc838341dd9f44437e3782cf49bf8163ec72fd2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 09:20:36 +0100 Subject: s4:dsdb/schema: s/class/sclass metze --- source4/dsdb/schema/schema_description.c | 27 ++++++++++++------------ source4/dsdb/schema/schema_query.c | 36 ++++++++++++++++---------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/source4/dsdb/schema/schema_description.c b/source4/dsdb/schema/schema_description.c index d616f3bb9b..0ff8a72bcd 100644 --- a/source4/dsdb/schema/schema_description.c +++ b/source4/dsdb/schema/schema_description.c @@ -313,7 +313,7 @@ char *schema_class_description(TALLOC_CTX *mem_ctx, return schema_entry; } -char *schema_class_to_description(TALLOC_CTX *mem_ctx, const struct dsdb_class *class) +char *schema_class_to_description(TALLOC_CTX *mem_ctx, const struct dsdb_class *sclass) { char *schema_description; TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); @@ -325,21 +325,22 @@ char *schema_class_to_description(TALLOC_CTX *mem_ctx, const struct dsdb_class * = schema_class_description(mem_ctx, TARGET_AD_SCHEMA_SUBENTRY, " ", - class->governsID_oid, - class->lDAPDisplayName, + sclass->governsID_oid, + sclass->lDAPDisplayName, NULL, - class->subClassOf, - class->objectClassCategory, + sclass->subClassOf, + sclass->objectClassCategory, dsdb_attribute_list(tmp_ctx, - class, DSDB_SCHEMA_ALL_MUST), + sclass, DSDB_SCHEMA_ALL_MUST), dsdb_attribute_list(tmp_ctx, - class, DSDB_SCHEMA_ALL_MAY), + sclass, DSDB_SCHEMA_ALL_MAY), NULL); talloc_free(tmp_ctx); return schema_description; } -char *schema_class_to_dITContentRule(TALLOC_CTX *mem_ctx, const struct dsdb_class *class, - const struct dsdb_schema *schema) + +char *schema_class_to_dITContentRule(TALLOC_CTX *mem_ctx, const struct dsdb_class *sclass, + const struct dsdb_schema *schema) { int i; char *schema_description; @@ -353,8 +354,8 @@ char *schema_class_to_dITContentRule(TALLOC_CTX *mem_ctx, const struct dsdb_clas return NULL; } - aux_class_list = merge_attr_list(tmp_ctx, aux_class_list, class->systemAuxiliaryClass); - aux_class_list = merge_attr_list(tmp_ctx, aux_class_list, class->auxiliaryClass); + aux_class_list = merge_attr_list(tmp_ctx, aux_class_list, sclass->systemAuxiliaryClass); + aux_class_list = merge_attr_list(tmp_ctx, aux_class_list, sclass->auxiliaryClass); for (i=0; aux_class_list && aux_class_list[i]; i++) { aux_class = dsdb_class_by_lDAPDisplayName(schema, aux_class_list[i]); @@ -370,8 +371,8 @@ char *schema_class_to_dITContentRule(TALLOC_CTX *mem_ctx, const struct dsdb_clas = schema_class_description(mem_ctx, TARGET_AD_SCHEMA_SUBENTRY, " ", - class->governsID_oid, - class->lDAPDisplayName, + sclass->governsID_oid, + sclass->lDAPDisplayName, (const char **)aux_class_list, NULL, /* Must not specify a * SUP (subclass) in diff --git a/source4/dsdb/schema/schema_query.c b/source4/dsdb/schema/schema_query.c index f848fee365..00de0f8983 100644 --- a/source4/dsdb/schema/schema_query.c +++ b/source4/dsdb/schema/schema_query.c @@ -241,41 +241,41 @@ const char **merge_attr_list(TALLOC_CTX *mem_ctx, considering subclasses, auxillary classes etc) */ -const char **dsdb_attribute_list(TALLOC_CTX *mem_ctx, const struct dsdb_class *class, enum dsdb_attr_list_query query) +const char **dsdb_attribute_list(TALLOC_CTX *mem_ctx, const struct dsdb_class *sclass, enum dsdb_attr_list_query query) { const char **attr_list = NULL; switch (query) { case DSDB_SCHEMA_ALL_MAY: - attr_list = merge_attr_list(mem_ctx, attr_list, class->mayContain); - attr_list = merge_attr_list(mem_ctx, attr_list, class->systemMayContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->mayContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->systemMayContain); break; case DSDB_SCHEMA_ALL_MUST: - attr_list = merge_attr_list(mem_ctx, attr_list, class->mustContain); - attr_list = merge_attr_list(mem_ctx, attr_list, class->systemMustContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->mustContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->systemMustContain); break; case DSDB_SCHEMA_SYS_MAY: - attr_list = merge_attr_list(mem_ctx, attr_list, class->systemMayContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->systemMayContain); break; case DSDB_SCHEMA_SYS_MUST: - attr_list = merge_attr_list(mem_ctx, attr_list, class->systemMustContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->systemMustContain); break; case DSDB_SCHEMA_MAY: - attr_list = merge_attr_list(mem_ctx, attr_list, class->mayContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->mayContain); break; case DSDB_SCHEMA_MUST: - attr_list = merge_attr_list(mem_ctx, attr_list, class->mustContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->mustContain); break; case DSDB_SCHEMA_ALL: - attr_list = merge_attr_list(mem_ctx, attr_list, class->mayContain); - attr_list = merge_attr_list(mem_ctx, attr_list, class->systemMayContain); - attr_list = merge_attr_list(mem_ctx, attr_list, class->mustContain); - attr_list = merge_attr_list(mem_ctx, attr_list, class->systemMustContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->mayContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->systemMayContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->mustContain); + attr_list = merge_attr_list(mem_ctx, attr_list, sclass->systemMustContain); break; } return attr_list; @@ -287,26 +287,26 @@ static const char **dsdb_full_attribute_list_internal(TALLOC_CTX *mem_ctx, enum dsdb_attr_list_query query) { int i; - const struct dsdb_class *class; + const struct dsdb_class *sclass; const char **attr_list = NULL; const char **this_class_list; const char **recursive_list; for (i=0; class_list && class_list[i]; i++) { - class = dsdb_class_by_lDAPDisplayName(schema, class_list[i]); + sclass = dsdb_class_by_lDAPDisplayName(schema, class_list[i]); - this_class_list = dsdb_attribute_list(mem_ctx, class, query); + this_class_list = dsdb_attribute_list(mem_ctx, sclass, query); attr_list = merge_attr_list(mem_ctx, attr_list, this_class_list); recursive_list = dsdb_full_attribute_list_internal(mem_ctx, schema, - class->systemAuxiliaryClass, + sclass->systemAuxiliaryClass, query); attr_list = merge_attr_list(mem_ctx, attr_list, recursive_list); recursive_list = dsdb_full_attribute_list_internal(mem_ctx, schema, - class->auxiliaryClass, + sclass->auxiliaryClass, query); attr_list = merge_attr_list(mem_ctx, attr_list, recursive_list); -- cgit From 0fadddf8d417f34dbe964ffd20483d24bf308325 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 09:31:38 +0100 Subject: s4:ldap_server: s/private/private_data metze --- source4/ldap_server/ldap_bind.c | 4 ++-- source4/ldap_server/ldap_extended.c | 4 ++-- source4/ldap_server/ldap_server.c | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source4/ldap_server/ldap_bind.c b/source4/ldap_server/ldap_bind.c index 0fe6fcce90..f3f843b920 100644 --- a/source4/ldap_server/ldap_bind.c +++ b/source4/ldap_server/ldap_bind.c @@ -100,9 +100,9 @@ struct ldapsrv_sasl_context { struct socket_context *sasl_socket; }; -static void ldapsrv_set_sasl(void *private) +static void ldapsrv_set_sasl(void *private_data) { - struct ldapsrv_sasl_context *ctx = talloc_get_type(private, struct ldapsrv_sasl_context); + struct ldapsrv_sasl_context *ctx = talloc_get_type(private_data, struct ldapsrv_sasl_context); talloc_steal(ctx->conn->connection, ctx->sasl_socket); talloc_unlink(ctx->conn->connection, ctx->conn->connection->socket); diff --git a/source4/ldap_server/ldap_extended.c b/source4/ldap_server/ldap_extended.c index 334e427d79..4479eab560 100644 --- a/source4/ldap_server/ldap_extended.c +++ b/source4/ldap_server/ldap_extended.c @@ -29,9 +29,9 @@ struct ldapsrv_starttls_context { struct socket_context *tls_socket; }; -static void ldapsrv_start_tls(void *private) +static void ldapsrv_start_tls(void *private_data) { - struct ldapsrv_starttls_context *ctx = talloc_get_type(private, struct ldapsrv_starttls_context); + struct ldapsrv_starttls_context *ctx = talloc_get_type(private_data, struct ldapsrv_starttls_context); talloc_steal(ctx->conn->connection, ctx->tls_socket); talloc_unlink(ctx->conn->connection, ctx->conn->connection->socket); diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c index ed8e6d3a2c..8d7e629848 100644 --- a/source4/ldap_server/ldap_server.c +++ b/source4/ldap_server/ldap_server.c @@ -55,9 +55,9 @@ void ldapsrv_terminate_connection(struct ldapsrv_connection *conn, /* handle packet errors */ -static void ldapsrv_error_handler(void *private, NTSTATUS status) +static void ldapsrv_error_handler(void *private_data, NTSTATUS status) { - struct ldapsrv_connection *conn = talloc_get_type(private, + struct ldapsrv_connection *conn = talloc_get_type(private_data, struct ldapsrv_connection); ldapsrv_terminate_connection(conn, nt_errstr(status)); } @@ -132,10 +132,10 @@ static void ldapsrv_process_message(struct ldapsrv_connection *conn, /* decode/process data */ -static NTSTATUS ldapsrv_decode(void *private, DATA_BLOB blob) +static NTSTATUS ldapsrv_decode(void *private_data, DATA_BLOB blob) { NTSTATUS status; - struct ldapsrv_connection *conn = talloc_get_type(private, + struct ldapsrv_connection *conn = talloc_get_type(private_data, struct ldapsrv_connection); struct asn1_data *asn1 = asn1_init(conn); struct ldap_message *msg = talloc(conn, struct ldap_message); @@ -170,9 +170,9 @@ static NTSTATUS ldapsrv_decode(void *private, DATA_BLOB blob) static void ldapsrv_conn_idle_timeout(struct tevent_context *ev, struct tevent_timer *te, struct timeval t, - void *private) + void *private_data) { - struct ldapsrv_connection *conn = talloc_get_type(private, struct ldapsrv_connection); + struct ldapsrv_connection *conn = talloc_get_type(private_data, struct ldapsrv_connection); ldapsrv_terminate_connection(conn, "Timeout. No requests after bind"); } @@ -217,9 +217,9 @@ static void ldapsrv_send(struct stream_connection *c, uint16_t flags) static void ldapsrv_conn_init_timeout(struct tevent_context *ev, struct tevent_timer *te, struct timeval t, - void *private) + void *private_data) { - struct ldapsrv_connection *conn = talloc_get_type(private, struct ldapsrv_connection); + struct ldapsrv_connection *conn = talloc_get_type(private_data, struct ldapsrv_connection); ldapsrv_terminate_connection(conn, "Timeout. No requests after initial connection"); } -- cgit From d0ad2ecdeadcfdc99ead63000d484dfba5745ac2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 09:36:58 +0100 Subject: s4:cluster: s/private/private_data metze --- source4/cluster/cluster_private.h | 2 +- source4/cluster/local.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source4/cluster/cluster_private.h b/source4/cluster/cluster_private.h index 79394b46db..e57c983ed0 100644 --- a/source4/cluster/cluster_private.h +++ b/source4/cluster/cluster_private.h @@ -36,7 +36,7 @@ struct cluster_ops { cluster_message_fn_t handler); NTSTATUS (*message_send)(struct cluster_ops *ops, struct server_id server, DATA_BLOB *data); - void *private; /* backend state */ + void *private_data; /* backend state */ }; void cluster_set_ops(struct cluster_ops *new_ops); diff --git a/source4/cluster/local.c b/source4/cluster/local.c index f36a06c9b6..96d1d53d4a 100644 --- a/source4/cluster/local.c +++ b/source4/cluster/local.c @@ -103,7 +103,7 @@ static struct cluster_ops cluster_local_ops = { .backend_handle = local_backend_handle, .message_init = local_message_init, .message_send = local_message_send, - .private = NULL + .private_data = NULL }; void cluster_local_init(void) -- cgit From 24d31c0e81c2332a610bb94acb1227fb9690443a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 09:38:43 +0100 Subject: s4:kludge_acl: s/class/sclass metze --- source4/dsdb/samdb/ldb_modules/kludge_acl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/kludge_acl.c b/source4/dsdb/samdb/ldb_modules/kludge_acl.c index 1597f687a4..0b5994bb88 100644 --- a/source4/dsdb/samdb/ldb_modules/kludge_acl.c +++ b/source4/dsdb/samdb/ldb_modules/kludge_acl.c @@ -152,7 +152,7 @@ static int kludge_acl_childClasses(struct ldb_context *ldb, struct ldb_message * struct ldb_message_element *oc_el; struct ldb_message_element *allowedClasses; const struct dsdb_schema *schema = dsdb_get_schema(ldb); - const struct dsdb_class *class; + const struct dsdb_class *sclass; int i, j, ret; /* If we don't have a schema yet, we can't do anything... */ @@ -172,14 +172,14 @@ static int kludge_acl_childClasses(struct ldb_context *ldb, struct ldb_message * oc_el = ldb_msg_find_element(msg, "objectClass"); for (i=0; oc_el && i < oc_el->num_values; i++) { - class = dsdb_class_by_lDAPDisplayName(schema, (const char *)oc_el->values[i].data); - if (!class) { + sclass = dsdb_class_by_lDAPDisplayName(schema, (const char *)oc_el->values[i].data); + if (!sclass) { /* We don't know this class? what is going on? */ continue; } - for (j=0; class->possibleInferiors && class->possibleInferiors[j]; j++) { - ldb_msg_add_string(msg, attrName, class->possibleInferiors[j]); + for (j=0; sclass->possibleInferiors && sclass->possibleInferiors[j]; j++) { + ldb_msg_add_string(msg, attrName, sclass->possibleInferiors[j]); } } -- cgit From 1bb0104070eb1188ed0256535907f2bed006a939 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 09:46:59 +0100 Subject: s4:cldap: s/private/private_data metze --- source4/cldap_server/netlogon.c | 2 +- source4/cldap_server/rootdse.c | 2 +- source4/libcli/cldap/cldap.c | 2 +- source4/libcli/cldap/cldap.h | 4 ++-- source4/libnet/libnet_become_dc.c | 4 ++-- source4/libnet/libnet_unbecome_dc.c | 4 ++-- source4/torture/ldap/cldapbench.c | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source4/cldap_server/netlogon.c b/source4/cldap_server/netlogon.c index 3c12954c31..0df35be6fd 100644 --- a/source4/cldap_server/netlogon.c +++ b/source4/cldap_server/netlogon.c @@ -407,7 +407,7 @@ void cldapd_netlogon_request(struct cldap_socket *cldap, struct ldb_parse_tree *tree, struct socket_address *src) { - struct cldapd_server *cldapd = talloc_get_type(cldap->incoming.private, struct cldapd_server); + struct cldapd_server *cldapd = talloc_get_type(cldap->incoming.private_data, struct cldapd_server); int i; const char *domain = NULL; const char *host = NULL; diff --git a/source4/cldap_server/rootdse.c b/source4/cldap_server/rootdse.c index 65786e6708..daa5060d07 100644 --- a/source4/cldap_server/rootdse.c +++ b/source4/cldap_server/rootdse.c @@ -155,7 +155,7 @@ void cldapd_rootdse_request(struct cldap_socket *cldap, struct ldap_SearchRequest *search, struct socket_address *src) { - struct cldapd_server *cldapd = talloc_get_type(cldap->incoming.private, struct cldapd_server); + struct cldapd_server *cldapd = talloc_get_type(cldap->incoming.private_data, struct cldapd_server); NTSTATUS status; struct cldap_reply reply; struct ldap_Result result; diff --git a/source4/libcli/cldap/cldap.c b/source4/libcli/cldap/cldap.c index d9a6c970b9..8d2e2e374c 100644 --- a/source4/libcli/cldap/cldap.c +++ b/source4/libcli/cldap/cldap.c @@ -285,7 +285,7 @@ NTSTATUS cldap_set_incoming_handler(struct cldap_socket *cldap, void *private_data) { cldap->incoming.handler = handler; - cldap->incoming.private = private_data; + cldap->incoming.private_data = private_data; EVENT_FD_READABLE(cldap->fde); return NT_STATUS_OK; } diff --git a/source4/libcli/cldap/cldap.h b/source4/libcli/cldap/cldap.h index 1841e82540..8951daa775 100644 --- a/source4/libcli/cldap/cldap.h +++ b/source4/libcli/cldap/cldap.h @@ -63,7 +63,7 @@ struct cldap_request { /* information on what to do on completion */ struct { void (*fn)(struct cldap_request *); - void *private; + void *private_data; } async; }; @@ -88,7 +88,7 @@ struct cldap_socket { struct { void (*handler)(struct cldap_socket *, struct ldap_message *, struct socket_address *); - void *private; + void *private_data; } incoming; }; diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c index 294ea4b79c..bf046745e6 100644 --- a/source4/libnet/libnet_become_dc.c +++ b/source4/libnet/libnet_become_dc.c @@ -756,14 +756,14 @@ static void becomeDC_send_cldap(struct libnet_BecomeDC_state *s) req = cldap_netlogon_send(s->cldap.sock, &s->cldap.io); if (composite_nomem(req, c)) return; req->async.fn = becomeDC_recv_cldap; - req->async.private = s; + req->async.private_data = s; } static void becomeDC_connect_ldap1(struct libnet_BecomeDC_state *s); static void becomeDC_recv_cldap(struct cldap_request *req) { - struct libnet_BecomeDC_state *s = talloc_get_type(req->async.private, + struct libnet_BecomeDC_state *s = talloc_get_type(req->async.private_data, struct libnet_BecomeDC_state); struct composite_context *c = s->creq; diff --git a/source4/libnet/libnet_unbecome_dc.c b/source4/libnet/libnet_unbecome_dc.c index 79c6dc0fc1..3f92daab28 100644 --- a/source4/libnet/libnet_unbecome_dc.c +++ b/source4/libnet/libnet_unbecome_dc.c @@ -275,14 +275,14 @@ static void unbecomeDC_send_cldap(struct libnet_UnbecomeDC_state *s) req = cldap_netlogon_send(s->cldap.sock, &s->cldap.io); if (composite_nomem(req, c)) return; req->async.fn = unbecomeDC_recv_cldap; - req->async.private = s; + req->async.private_data = s; } static void unbecomeDC_connect_ldap(struct libnet_UnbecomeDC_state *s); static void unbecomeDC_recv_cldap(struct cldap_request *req) { - struct libnet_UnbecomeDC_state *s = talloc_get_type(req->async.private, + struct libnet_UnbecomeDC_state *s = talloc_get_type(req->async.private_data, struct libnet_UnbecomeDC_state); struct composite_context *c = s->creq; diff --git a/source4/torture/ldap/cldapbench.c b/source4/torture/ldap/cldapbench.c index df2a5b0551..1fcfe5a050 100644 --- a/source4/torture/ldap/cldapbench.c +++ b/source4/torture/ldap/cldapbench.c @@ -33,7 +33,7 @@ struct bench_state { static void request_handler(struct cldap_request *req) { struct cldap_netlogon io; - struct bench_state *state = talloc_get_type(req->async.private, struct bench_state); + struct bench_state *state = talloc_get_type(req->async.private_data, struct bench_state); NTSTATUS status; TALLOC_CTX *tmp_ctx = talloc_new(NULL); io.in.version = 6; @@ -75,7 +75,7 @@ static bool bench_cldap(struct torture_context *tctx, const char *address) struct cldap_request *req; req = cldap_netlogon_send(cldap, &search); - req->async.private = state; + req->async.private_data = state; req->async.fn = request_handler; num_sent++; if (num_sent % 50 == 0) { -- cgit From e08dfe008e63789347cf7dc360b70ba1a1cb5b20 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 09:55:58 +0100 Subject: s4:dgram: s/private/private_data metze --- source4/libcli/dgram/dgramsocket.c | 2 +- source4/libcli/dgram/libdgram.h | 4 ++-- source4/libcli/dgram/mailslot.c | 2 +- source4/nbt_server/dgram/netlogon.c | 2 +- source4/nbt_server/dgram/ntlogon.c | 2 +- source4/nbt_server/irpc.c | 2 +- source4/torture/nbt/dgram.c | 48 ++++++++++++++++++------------------- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/source4/libcli/dgram/dgramsocket.c b/source4/libcli/dgram/dgramsocket.c index 1a5cc6dce8..751706d2c5 100644 --- a/source4/libcli/dgram/dgramsocket.c +++ b/source4/libcli/dgram/dgramsocket.c @@ -203,7 +203,7 @@ NTSTATUS dgram_set_incoming_handler(struct nbt_dgram_socket *dgmsock, void *private_data) { dgmsock->incoming.handler = handler; - dgmsock->incoming.private = private_data; + dgmsock->incoming.private_data = private_data; EVENT_FD_READABLE(dgmsock->fde); return NT_STATUS_OK; } diff --git a/source4/libcli/dgram/libdgram.h b/source4/libcli/dgram/libdgram.h index b303afa6dc..a17a6042d9 100644 --- a/source4/libcli/dgram/libdgram.h +++ b/source4/libcli/dgram/libdgram.h @@ -55,7 +55,7 @@ struct nbt_dgram_socket { struct { void (*handler)(struct nbt_dgram_socket *, struct nbt_dgram_packet *, struct socket_address *src); - void *private; + void *private_data; } incoming; }; @@ -79,7 +79,7 @@ struct dgram_mailslot_handler { const char *mailslot_name; dgram_mailslot_handler_t handler; - void *private; + void *private_data; }; diff --git a/source4/libcli/dgram/mailslot.c b/source4/libcli/dgram/mailslot.c index bc607e3b24..261946e458 100644 --- a/source4/libcli/dgram/mailslot.c +++ b/source4/libcli/dgram/mailslot.c @@ -66,7 +66,7 @@ struct dgram_mailslot_handler *dgram_mailslot_listen(struct nbt_dgram_socket *dg return NULL; } dgmslot->handler = handler; - dgmslot->private = private_data; + dgmslot->private_data = private_data; DLIST_ADD(dgmsock->mailslot_handlers, dgmslot); talloc_set_destructor(dgmslot, dgram_mailslot_destructor); diff --git a/source4/nbt_server/dgram/netlogon.c b/source4/nbt_server/dgram/netlogon.c index a3a7552f6a..e5c82280e3 100644 --- a/source4/nbt_server/dgram/netlogon.c +++ b/source4/nbt_server/dgram/netlogon.c @@ -161,7 +161,7 @@ void nbtd_mailslot_netlogon_handler(struct dgram_mailslot_handler *dgmslot, { NTSTATUS status = NT_STATUS_NO_MEMORY; struct nbtd_interface *iface = - talloc_get_type(dgmslot->private, struct nbtd_interface); + talloc_get_type(dgmslot->private_data, struct nbtd_interface); struct nbt_netlogon_packet *netlogon = talloc(dgmslot, struct nbt_netlogon_packet); struct nbtd_iface_name *iname; diff --git a/source4/nbt_server/dgram/ntlogon.c b/source4/nbt_server/dgram/ntlogon.c index 352be34489..87e76e08ee 100644 --- a/source4/nbt_server/dgram/ntlogon.c +++ b/source4/nbt_server/dgram/ntlogon.c @@ -76,7 +76,7 @@ void nbtd_mailslot_ntlogon_handler(struct dgram_mailslot_handler *dgmslot, { NTSTATUS status = NT_STATUS_NO_MEMORY; struct nbtd_interface *iface = - talloc_get_type(dgmslot->private, struct nbtd_interface); + talloc_get_type(dgmslot->private_data, struct nbtd_interface); struct nbt_ntlogon_packet *ntlogon = talloc(dgmslot, struct nbt_ntlogon_packet); struct nbtd_iface_name *iname; diff --git a/source4/nbt_server/irpc.c b/source4/nbt_server/irpc.c index 748f18dcfd..951f1d296a 100644 --- a/source4/nbt_server/irpc.c +++ b/source4/nbt_server/irpc.c @@ -65,7 +65,7 @@ static void getdc_recv_netlogon_reply(struct dgram_mailslot_handler *dgmslot, struct socket_address *src) { struct getdc_state *s = - talloc_get_type(dgmslot->private, struct getdc_state); + talloc_get_type(dgmslot->private_data, struct getdc_state); const char *p; struct nbt_netlogon_response netlogon; NTSTATUS status; diff --git a/source4/torture/nbt/dgram.c b/source4/torture/nbt/dgram.c index 5d26d65e0c..8eb315127a 100644 --- a/source4/torture/nbt/dgram.c +++ b/source4/torture/nbt/dgram.c @@ -42,11 +42,11 @@ static void netlogon_handler(struct dgram_mailslot_handler *dgmslot, struct socket_address *src) { NTSTATUS status; - struct nbt_netlogon_response *netlogon = dgmslot->private; + struct nbt_netlogon_response *netlogon = dgmslot->private_data; - dgmslot->private = netlogon = talloc(dgmslot, struct nbt_netlogon_response); + dgmslot->private_data = netlogon = talloc(dgmslot, struct nbt_netlogon_response); - if (!dgmslot->private) { + if (!dgmslot->private_data) { return; } @@ -139,11 +139,11 @@ static bool nbt_test_netlogon(struct torture_context *tctx) &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); - while (timeval_elapsed(&tv) < 5 && !dgmslot->private) { + while (timeval_elapsed(&tv) < 5 && !dgmslot->private_data) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -234,11 +234,11 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); - while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private_data == NULL) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -273,11 +273,11 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); - while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private_data == NULL) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -324,11 +324,11 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); - while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private_data == NULL) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -365,11 +365,11 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); - while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private_data == NULL) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -378,7 +378,7 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) torture_assert_int_equal(tctx, response->data.samlogon.data.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE, "Got incorrect netlogon response command"); - dgmslot->private = NULL; + dgmslot->private_data = NULL; ZERO_STRUCT(logon); logon.command = LOGON_SAM_LOGON_REQUEST; @@ -404,11 +404,11 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); - while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private_data == NULL) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -513,11 +513,11 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request"); - while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private_data == NULL) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -557,11 +557,11 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request"); - while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) { + while (timeval_elapsed(&tv) < 5 && dgmslot->private_data == NULL) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -597,11 +597,11 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request"); - while (timeval_elapsed(&tv) < 5 && !dgmslot->private) { + while (timeval_elapsed(&tv) < 5 && !dgmslot->private_data) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); @@ -634,11 +634,11 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) &myname, &logon); torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request"); - while (timeval_elapsed(&tv) < 5 && !dgmslot->private) { + while (timeval_elapsed(&tv) < 5 && !dgmslot->private_data) { event_loop_once(dgmsock->event_ctx); } - response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response); + response = talloc_get_type(dgmslot->private_data, struct nbt_netlogon_response); torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet"); -- cgit From 476aa1f00d298bdbefd92ba9505109167e3dfa1e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 09:56:47 +0100 Subject: s4:smb2: s/private/private_data metze --- source4/libcli/smb2/smb2.h | 2 +- source4/libcli/smb2/transport.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 9d63a4a95f..d1d5b842c3 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -59,7 +59,7 @@ struct smb2_transport { for a packet */ struct { void (*func)(struct smb2_transport *, void *); - void *private; + void *private_data; uint_t period; } idle; diff --git a/source4/libcli/smb2/transport.c b/source4/libcli/smb2/transport.c index 679b085889..e112544c62 100644 --- a/source4/libcli/smb2/transport.c +++ b/source4/libcli/smb2/transport.c @@ -390,7 +390,7 @@ static void idle_handler(struct tevent_context *ev, transport, next, idle_handler, transport); - transport->idle.func(transport, transport->idle.private); + transport->idle.func(transport, transport->idle.private_data); } /* @@ -403,7 +403,7 @@ void smb2_transport_idle_handler(struct smb2_transport *transport, void *private_data) { transport->idle.func = idle_func; - transport->idle.private = private_data; + transport->idle.private_data = private_data; transport->idle.period = period; if (transport->socket->event.te != NULL) { -- cgit From 5bca70a0c275f545433afad624b1e54adc27986d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 10:01:36 +0100 Subject: s4:rpc_server: s/private/private_data metze --- source4/rpc_server/dcerpc_server.c | 4 ++-- source4/rpc_server/dcerpc_server.h | 4 ++-- source4/rpc_server/netlogon/dcerpc_netlogon.c | 8 ++++---- source4/rpc_server/remote/dcesrv_remote.c | 16 ++++++++-------- source4/rpc_server/spoolss/dcesrv_spoolss.c | 14 +++++++------- source4/rpc_server/unixinfo/dcesrv_unixinfo.c | 10 +++++----- source4/rpc_server/winreg/rpc_winreg.c | 4 ++-- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c index e4be2e3123..d7bd7601f7 100644 --- a/source4/rpc_server/dcerpc_server.c +++ b/source4/rpc_server/dcerpc_server.c @@ -603,7 +603,7 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call) * it also matches samba3 */ context->assoc_group_id = SAMBA_ASSOC_GROUP; - context->private = NULL; + context->private_data = NULL; context->handles = NULL; DLIST_ADD(call->conn->contexts, context); call->context = context; @@ -767,7 +767,7 @@ static NTSTATUS dcesrv_alter_new_context(struct dcesrv_call_state *call, uint32_ context->iface = iface; context->context_id = context_id; context->assoc_group_id = SAMBA_ASSOC_GROUP; - context->private = NULL; + context->private_data = NULL; context->handles = NULL; DLIST_ADD(call->conn->contexts, context); call->context = context; diff --git a/source4/rpc_server/dcerpc_server.h b/source4/rpc_server/dcerpc_server.h index 51ad546ab4..7e12a3840b 100644 --- a/source4/rpc_server/dcerpc_server.h +++ b/source4/rpc_server/dcerpc_server.h @@ -66,7 +66,7 @@ struct dcesrv_interface { NTSTATUS (*ndr_push)(struct dcesrv_call_state *, TALLOC_CTX *, struct ndr_push *, const void *); /* for any private use by the interface code */ - const void *private; + const void *private_data; }; enum dcesrv_call_list { @@ -162,7 +162,7 @@ struct dcesrv_connection_context { const struct dcesrv_interface *iface; /* private data for the interface implementation */ - void *private; + void *private_data; /* current rpc handles - this is really the wrong scope for them, but it will do for now */ diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c index fc7fded63b..a9150d1a9a 100644 --- a/source4/rpc_server/netlogon/dcerpc_netlogon.c +++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c @@ -47,7 +47,7 @@ struct server_pipe_state { static NTSTATUS dcesrv_netr_ServerReqChallenge(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_ServerReqChallenge *r) { - struct server_pipe_state *pipe_state = dce_call->context->private; + struct server_pipe_state *pipe_state = dce_call->context->private_data; ZERO_STRUCTP(r->out.return_credentials); @@ -55,7 +55,7 @@ static NTSTATUS dcesrv_netr_ServerReqChallenge(struct dcesrv_call_state *dce_cal if (pipe_state) { talloc_free(pipe_state); - dce_call->context->private = NULL; + dce_call->context->private_data = NULL; } pipe_state = talloc(dce_call->context, struct server_pipe_state); @@ -68,7 +68,7 @@ static NTSTATUS dcesrv_netr_ServerReqChallenge(struct dcesrv_call_state *dce_cal *r->out.return_credentials = pipe_state->server_challenge; - dce_call->context->private = pipe_state; + dce_call->context->private_data = pipe_state; return NT_STATUS_OK; } @@ -76,7 +76,7 @@ static NTSTATUS dcesrv_netr_ServerReqChallenge(struct dcesrv_call_state *dce_cal static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct netr_ServerAuthenticate3 *r) { - struct server_pipe_state *pipe_state = dce_call->context->private; + struct server_pipe_state *pipe_state = dce_call->context->private_data; struct creds_CredentialState *creds; void *sam_ctx; struct samr_Password *mach_pwd; diff --git a/source4/rpc_server/remote/dcesrv_remote.c b/source4/rpc_server/remote/dcesrv_remote.c index 7354854e9c..e20e87b326 100644 --- a/source4/rpc_server/remote/dcesrv_remote.c +++ b/source4/rpc_server/remote/dcesrv_remote.c @@ -53,7 +53,7 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct } priv->c_pipe = NULL; - dce_call->context->private = priv; + dce_call->context->private_data = priv; if (!binding) { DEBUG(0,("You must specify a DCE/RPC binding string\n")); @@ -116,7 +116,7 @@ static NTSTATUS remote_op_bind(struct dcesrv_call_state *dce_call, const struct static void remote_op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface) { - struct dcesrv_remote_private *priv = (struct dcesrv_remote_private *)context->private; + struct dcesrv_remote_private *priv = (struct dcesrv_remote_private *)context->private_data; talloc_free(priv->c_pipe); @@ -126,7 +126,7 @@ static void remote_op_unbind(struct dcesrv_connection_context *context, const st static NTSTATUS remote_op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r) { enum ndr_err_code ndr_err; - const struct ndr_interface_table *table = (const struct ndr_interface_table *)dce_call->context->iface->private; + const struct ndr_interface_table *table = (const struct ndr_interface_table *)dce_call->context->iface->private_data; uint16_t opnum = dce_call->pkt.u.request.opnum; dce_call->fault_code = 0; @@ -156,9 +156,9 @@ static NTSTATUS remote_op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CT static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r) { - struct dcesrv_remote_private *priv = dce_call->context->private; + struct dcesrv_remote_private *priv = dce_call->context->private_data; uint16_t opnum = dce_call->pkt.u.request.opnum; - const struct ndr_interface_table *table = dce_call->context->iface->private; + const struct ndr_interface_table *table = dce_call->context->iface->private_data; const struct ndr_interface_call *call; const char *name; @@ -191,7 +191,7 @@ static NTSTATUS remote_op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CT static NTSTATUS remote_op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r) { enum ndr_err_code ndr_err; - const struct ndr_interface_table *table = dce_call->context->iface->private; + const struct ndr_interface_table *table = dce_call->context->iface->private_data; uint16_t opnum = dce_call->pkt.u.request.opnum; /* unravel the NDR for the packet */ @@ -207,7 +207,7 @@ static NTSTATUS remote_op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CT static NTSTATUS remote_register_one_iface(struct dcesrv_context *dce_ctx, const struct dcesrv_interface *iface) { int i; - const struct ndr_interface_table *table = iface->private; + const struct ndr_interface_table *table = iface->private_data; for (i=0;iendpoints->count;i++) { NTSTATUS ret; @@ -268,7 +268,7 @@ static bool remote_fill_interface(struct dcesrv_interface *iface, const struct n iface->reply = remote_op_reply; iface->ndr_push = remote_op_ndr_push; - iface->private = if_tabl; + iface->private_data = if_tabl; return true; } diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c index d041d79b3e..1317dba1a4 100644 --- a/source4/rpc_server/spoolss/dcesrv_spoolss.c +++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c @@ -220,7 +220,7 @@ static NTSTATUS dcerpc_spoolss_bind(struct dcesrv_call_state *dce_call, const st lp_ntptr_providor(dce_call->conn->dce_ctx->lp_ctx), &ntptr); NT_STATUS_NOT_OK_RETURN(status); - dce_call->context->private = ntptr; + dce_call->context->private_data = ntptr; return NT_STATUS_OK; } @@ -233,7 +233,7 @@ static NTSTATUS dcerpc_spoolss_bind(struct dcesrv_call_state *dce_call, const st static WERROR dcesrv_spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinters *r) { - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context); + struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); WERROR status; struct smb_iconv_convenience *ic = lp_iconv_convenience(ntptr->lp_ctx); @@ -369,7 +369,7 @@ static WERROR dcesrv_spoolss_AddPrinterDriver(struct dcesrv_call_state *dce_call static WERROR dcesrv_spoolss_EnumPrinterDrivers(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinterDrivers *r) { - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context); + struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); WERROR status; struct smb_iconv_convenience *ic = lp_iconv_convenience(ntptr->lp_ctx); @@ -402,7 +402,7 @@ static WERROR dcesrv_spoolss_GetPrinterDriver(struct dcesrv_call_state *dce_call static WERROR dcesrv_spoolss_GetPrinterDriverDirectory(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_GetPrinterDriverDirectory *r) { - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context); + struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); WERROR status; struct smb_iconv_convenience *ic = lp_iconv_convenience(ntptr->lp_ctx); @@ -796,7 +796,7 @@ static WERROR dcesrv_spoolss_EnumForms(struct dcesrv_call_state *dce_call, TALLO static WERROR dcesrv_spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_EnumPorts *r) { - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context); + struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); WERROR status; struct smb_iconv_convenience *ic = lp_iconv_convenience(ntptr->lp_ctx); @@ -819,7 +819,7 @@ static WERROR dcesrv_spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLO static WERROR dcesrv_spoolss_EnumMonitors(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_EnumMonitors *r) { - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context); + struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); WERROR status; struct smb_iconv_convenience *ic = lp_iconv_convenience(ntptr->lp_ctx); @@ -1228,7 +1228,7 @@ static WERROR dcesrv_spoolss_44(struct dcesrv_call_state *dce_call, TALLOC_CTX * static WERROR dcesrv_spoolss_OpenPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_OpenPrinterEx *r) { - struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context); + struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context); struct ntptr_GenericHandle *handle; struct dcesrv_handle *h; const char *server; diff --git a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c index af758afc6f..a1d76ef811 100644 --- a/source4/rpc_server/unixinfo/dcesrv_unixinfo.c +++ b/source4/rpc_server/unixinfo/dcesrv_unixinfo.c @@ -36,7 +36,7 @@ static NTSTATUS dcerpc_unixinfo_bind(struct dcesrv_call_state *dce_call, dce_call->event_ctx); NT_STATUS_HAVE_NO_MEMORY(wbc_ctx); - dce_call->context->private = wbc_ctx; + dce_call->context->private_data = wbc_ctx; return NT_STATUS_OK; } @@ -49,7 +49,7 @@ static NTSTATUS dcesrv_unixinfo_SidToUid(struct dcesrv_call_state *dce_call, { NTSTATUS status; struct wbc_context *wbc_ctx = talloc_get_type_abort( - dce_call->context->private, + dce_call->context->private_data, struct wbc_context); struct id_mapping *ids; struct composite_context *ctx; @@ -82,7 +82,7 @@ static NTSTATUS dcesrv_unixinfo_UidToSid(struct dcesrv_call_state *dce_call, struct unixinfo_UidToSid *r) { struct wbc_context *wbc_ctx = talloc_get_type_abort( - dce_call->context->private, + dce_call->context->private_data, struct wbc_context); struct id_mapping *ids; struct composite_context *ctx; @@ -124,7 +124,7 @@ static NTSTATUS dcesrv_unixinfo_SidToGid(struct dcesrv_call_state *dce_call, { NTSTATUS status; struct wbc_context *wbc_ctx = talloc_get_type_abort( - dce_call->context->private, + dce_call->context->private_data, struct wbc_context); struct id_mapping *ids; struct composite_context *ctx; @@ -157,7 +157,7 @@ static NTSTATUS dcesrv_unixinfo_GidToSid(struct dcesrv_call_state *dce_call, struct unixinfo_GidToSid *r) { struct wbc_context *wbc_ctx = talloc_get_type_abort( - dce_call->context->private, + dce_call->context->private_data, struct wbc_context); struct id_mapping *ids; struct composite_context *ctx; diff --git a/source4/rpc_server/winreg/rpc_winreg.c b/source4/rpc_server/winreg/rpc_winreg.c index aa94505041..6158730759 100644 --- a/source4/rpc_server/winreg/rpc_winreg.c +++ b/source4/rpc_server/winreg/rpc_winreg.c @@ -46,7 +46,7 @@ static NTSTATUS dcerpc_winreg_bind(struct dcesrv_call_state *dce_call, return NT_STATUS_UNSUCCESSFUL; } - dce_call->context->private = ctx; + dce_call->context->private_data = ctx; return NT_STATUS_OK; } @@ -57,7 +57,7 @@ static WERROR dcesrv_winreg_openhive(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, uint32_t hkey, struct policy_handle **outh) { - struct registry_context *ctx = dce_call->context->private; + struct registry_context *ctx = dce_call->context->private_data; struct dcesrv_handle *h; WERROR result; -- cgit From 62c8f6b1a57e3f03965358e5b6c3e55eeb7aaa8b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 10:13:43 +0100 Subject: s4:web_server: s/private/private_data metze --- source4/web_server/web_server.h | 2 +- source4/web_server/wsgi.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source4/web_server/web_server.h b/source4/web_server/web_server.h index f91c766494..3b02feaf7d 100644 --- a/source4/web_server/web_server.h +++ b/source4/web_server/web_server.h @@ -25,7 +25,7 @@ struct web_server_data { struct tls_params *tls_params; void (*http_process_input)(struct web_server_data *wdata, struct websrv_context *web); - void *private; + void *private_data; }; struct http_header { diff --git a/source4/web_server/wsgi.c b/source4/web_server/wsgi.c index 53ba2a2d9b..4d6b441f17 100644 --- a/source4/web_server/wsgi.c +++ b/source4/web_server/wsgi.c @@ -323,7 +323,7 @@ static void wsgi_process_http_input(struct web_server_data *wdata, struct websrv_context *web) { PyObject *py_environ, *result, *item, *iter; - PyObject *request_handler = wdata->private; + PyObject *request_handler = (PyObject *)wdata->private_data; struct socket_address *socket_address; web_request_Object *py_web = PyObject_New(web_request_Object, &web_request_Type); @@ -386,6 +386,6 @@ bool wsgi_initialize(struct web_server_data *wdata) DEBUG(0, ("Unable to find SWAT\n")); return false; } - wdata->private = py_swat; + wdata->private_data = py_swat; return true; } -- cgit From e5e0a064853ff5cd7f9bea0d9a6db8a0ae497635 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 10:14:32 +0100 Subject: s4:wrepl_request: s/private/private_data metze --- source4/libcli/wrepl/winsrepl.h | 2 +- source4/wrepl_server/wrepl_out_helpers.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source4/libcli/wrepl/winsrepl.h b/source4/libcli/wrepl/winsrepl.h index 738ba391eb..ec1fb6bb59 100644 --- a/source4/libcli/wrepl/winsrepl.h +++ b/source4/libcli/wrepl/winsrepl.h @@ -82,7 +82,7 @@ struct wrepl_request { struct { void (*fn)(struct wrepl_request *); - void *private; + void *private_data; } async; }; diff --git a/source4/wrepl_server/wrepl_out_helpers.c b/source4/wrepl_server/wrepl_out_helpers.c index d9a9684c79..6aff134072 100644 --- a/source4/wrepl_server/wrepl_out_helpers.c +++ b/source4/wrepl_server/wrepl_out_helpers.c @@ -62,7 +62,7 @@ static NTSTATUS wreplsrv_out_connect_wait_socket(struct wreplsrv_out_connect_sta NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = wreplsrv_out_connect_handler_req; - state->req->async.private = state; + state->req->async.private_data = state; state->stage = WREPLSRV_OUT_CONNECT_STAGE_WAIT_ASSOC_CTX; @@ -131,7 +131,7 @@ static void wreplsrv_out_connect_handler_creq(struct composite_context *creq) static void wreplsrv_out_connect_handler_req(struct wrepl_request *req) { - struct wreplsrv_out_connect_state *state = talloc_get_type(req->async.private, + struct wreplsrv_out_connect_state *state = talloc_get_type(req->async.private_data, struct wreplsrv_out_connect_state); wreplsrv_out_connect_handler(state); return; @@ -276,7 +276,7 @@ static NTSTATUS wreplsrv_pull_table_wait_connection(struct wreplsrv_pull_table_s NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = wreplsrv_pull_table_handler_req; - state->req->async.private = state; + state->req->async.private_data = state; state->stage = WREPLSRV_PULL_TABLE_STAGE_WAIT_TABLE_REPLY; @@ -330,7 +330,7 @@ static void wreplsrv_pull_table_handler_creq(struct composite_context *creq) static void wreplsrv_pull_table_handler_req(struct wrepl_request *req) { - struct wreplsrv_pull_table_state *state = talloc_get_type(req->async.private, + struct wreplsrv_pull_table_state *state = talloc_get_type(req->async.private_data, struct wreplsrv_pull_table_state); wreplsrv_pull_table_handler(state); return; @@ -436,7 +436,7 @@ static NTSTATUS wreplsrv_pull_names_wait_connection(struct wreplsrv_pull_names_s NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = wreplsrv_pull_names_handler_req; - state->req->async.private = state; + state->req->async.private_data = state; state->stage = WREPLSRV_PULL_NAMES_STAGE_WAIT_SEND_REPLY; @@ -490,7 +490,7 @@ static void wreplsrv_pull_names_handler_creq(struct composite_context *creq) static void wreplsrv_pull_names_handler_req(struct wrepl_request *req) { - struct wreplsrv_pull_names_state *state = talloc_get_type(req->async.private, + struct wreplsrv_pull_names_state *state = talloc_get_type(req->async.private_data, struct wreplsrv_pull_names_state); wreplsrv_pull_names_handler(state); return; @@ -651,7 +651,7 @@ static NTSTATUS wreplsrv_pull_cycle_next_owner_wrapper(struct wreplsrv_pull_cycl NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = wreplsrv_pull_cycle_handler_req; - state->req->async.private = state; + state->req->async.private_data = state; state->stage = WREPLSRV_PULL_CYCLE_STAGE_WAIT_STOP_ASSOC; } @@ -773,7 +773,7 @@ static void wreplsrv_pull_cycle_handler_creq(struct composite_context *creq) static void wreplsrv_pull_cycle_handler_req(struct wrepl_request *req) { - struct wreplsrv_pull_cycle_state *state = talloc_get_type(req->async.private, + struct wreplsrv_pull_cycle_state *state = talloc_get_type(req->async.private_data, struct wreplsrv_pull_cycle_state); wreplsrv_pull_cycle_handler(state); return; @@ -957,7 +957,7 @@ static NTSTATUS wreplsrv_push_notify_inform(struct wreplsrv_push_notify_state *s NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = wreplsrv_push_notify_handler_req; - state->req->async.private = state; + state->req->async.private_data = state; state->stage = WREPLSRV_PUSH_NOTIFY_STAGE_WAIT_INFORM; @@ -1056,7 +1056,7 @@ static void wreplsrv_push_notify_handler_creq(struct composite_context *creq) static void wreplsrv_push_notify_handler_req(struct wrepl_request *req) { - struct wreplsrv_push_notify_state *state = talloc_get_type(req->async.private, + struct wreplsrv_push_notify_state *state = talloc_get_type(req->async.private_data, struct wreplsrv_push_notify_state); wreplsrv_push_notify_handler(state); return; -- cgit From 0ac7792e022107c352f5464f52563c4e885272dd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 10:17:00 +0100 Subject: s4:libcliraw: s/private/private_data metze --- source4/libcli/composite/composite.c | 4 ++-- source4/libcli/raw/clioplock.c | 2 +- source4/libcli/raw/clitransport.c | 4 ++-- source4/libcli/raw/libcliraw.h | 6 +++--- source4/libcli/raw/rawrequest.c | 2 +- source4/libcli/smb_composite/appendacl.c | 12 ++++++------ source4/libcli/smb_composite/connect.c | 10 +++++----- source4/libcli/smb_composite/fsinfo.c | 4 ++-- source4/libcli/smb_composite/loadfile.c | 10 +++++----- source4/libcli/smb_composite/savefile.c | 10 +++++----- source4/libcli/smb_composite/sesssetup.c | 2 +- source4/librpc/rpc/dcerpc_smb.c | 16 ++++++++-------- source4/ntvfs/cifs/vfs_cifs.c | 24 ++++++++++++------------ source4/torture/basic/misc.c | 14 +++++++------- source4/torture/gentest.c | 2 +- source4/torture/raw/lockbench.c | 8 ++++---- source4/torture/raw/offline.c | 12 ++++++------ source4/torture/raw/openbench.c | 14 +++++++------- source4/torture/raw/oplock.c | 2 +- 19 files changed, 79 insertions(+), 79 deletions(-) diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index a6b1c68d1c..ab32175d00 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -86,7 +86,7 @@ _PUBLIC_ NTSTATUS composite_wait_free(struct composite_context *c) this is used to allow for a composite function to complete without going through any state transitions. When that happens the caller has had no opportunity to fill in the async callback fields - (ctx->async.fn and ctx->async.private) which means the usual way of + (ctx->async.fn and ctx->async.private_data) which means the usual way of dealing with composite functions doesn't work. To cope with this, we trigger a timer event that will happen then the event loop is re-entered. This gives the caller a chance to setup the callback, @@ -194,7 +194,7 @@ _PUBLIC_ void composite_continue_smb(struct composite_context *ctx, { if (composite_nomem(new_req, ctx)) return; new_req->async.fn = continuation; - new_req->async.private = private_data; + new_req->async.private_data = private_data; } _PUBLIC_ void composite_continue_smb2(struct composite_context *ctx, diff --git a/source4/libcli/raw/clioplock.c b/source4/libcli/raw/clioplock.c index 5005f878af..42ac6b517b 100644 --- a/source4/libcli/raw/clioplock.c +++ b/source4/libcli/raw/clioplock.c @@ -58,5 +58,5 @@ _PUBLIC_ void smbcli_oplock_handler(struct smbcli_transport *transport, void *private_data) { transport->oplock.handler = handler; - transport->oplock.private = private_data; + transport->oplock.private_data = private_data; } diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c index e6f27b1159..1fa27e37ea 100644 --- a/source4/libcli/raw/clitransport.c +++ b/source4/libcli/raw/clitransport.c @@ -317,7 +317,7 @@ static void idle_handler(struct tevent_context *ev, transport, next, idle_handler, transport); - transport->idle.func(transport, transport->idle.private); + transport->idle.func(transport, transport->idle.private_data); } /* @@ -330,7 +330,7 @@ _PUBLIC_ void smbcli_transport_idle_handler(struct smbcli_transport *transport, void *private_data) { transport->idle.func = idle_func; - transport->idle.private = private_data; + transport->idle.private_data = private_data; transport->idle.period = period; if (transport->socket->event.te != NULL) { diff --git a/source4/libcli/raw/libcliraw.h b/source4/libcli/raw/libcliraw.h index 1b9cba8e38..a9fcdab9cc 100644 --- a/source4/libcli/raw/libcliraw.h +++ b/source4/libcli/raw/libcliraw.h @@ -128,7 +128,7 @@ struct smbcli_transport { for a packet */ struct { void (*func)(struct smbcli_transport *, void *); - void *private; + void *private_data; uint_t period; } idle; @@ -151,7 +151,7 @@ struct smbcli_transport { bool (*handler)(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private_data); /* private data passed to the oplock handler */ - void *private; + void *private_data; } oplock; /* a list of async requests that are pending for receive on this connection */ @@ -286,7 +286,7 @@ struct smbcli_request { */ struct { void (*fn)(struct smbcli_request *); - void *private; + void *private_data; } async; }; diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c index a257e3d0f1..029d56428d 100644 --- a/source4/libcli/raw/rawrequest.c +++ b/source4/libcli/raw/rawrequest.c @@ -388,7 +388,7 @@ bool smbcli_handle_oplock_break(struct smbcli_transport *transport, uint_t len, uint16_t tid = SVAL(hdr, HDR_TID); uint16_t fnum = SVAL(vwv,VWV(2)); uint8_t level = CVAL(vwv,VWV(3)+1); - transport->oplock.handler(transport, tid, fnum, level, transport->oplock.private); + transport->oplock.handler(transport, tid, fnum, level, transport->oplock.private_data); } return true; diff --git a/source4/libcli/smb_composite/appendacl.c b/source4/libcli/smb_composite/appendacl.c index 1f06b96e75..69ed62a106 100644 --- a/source4/libcli/smb_composite/appendacl.c +++ b/source4/libcli/smb_composite/appendacl.c @@ -46,7 +46,7 @@ static NTSTATUS appendacl_open(struct composite_context *c, /* set the handler */ state->req->async.fn = appendacl_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = APPENDACL_GET; talloc_free (state->io_open); @@ -92,7 +92,7 @@ static NTSTATUS appendacl_get(struct composite_context *c, /* call handler when done setting new security descriptor on file */ state->req->async.fn = appendacl_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = APPENDACL_SET; talloc_free (state->io_fileinfo); @@ -124,7 +124,7 @@ static NTSTATUS appendacl_set(struct composite_context *c, /* set the handler */ state->req->async.fn = appendacl_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = APPENDACL_GETAGAIN; talloc_free (state->io_setfileinfo); @@ -159,7 +159,7 @@ static NTSTATUS appendacl_getagain(struct composite_context *c, /* call the handler */ state->req->async.fn = appendacl_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = APPENDACL_CLOSEPATH; talloc_free (state->io_fileinfo); @@ -188,7 +188,7 @@ static NTSTATUS appendacl_close(struct composite_context *c, */ static void appendacl_handler(struct smbcli_request *req) { - struct composite_context *c = (struct composite_context *)req->async.private; + struct composite_context *c = (struct composite_context *)req->async.private_data; struct appendacl_state *state = talloc_get_type(c->private_data, struct appendacl_state); /* when this handler is called, the stage indicates what @@ -270,7 +270,7 @@ struct composite_context *smb_composite_appendacl_send(struct smbcli_tree *tree, /* setup the callback handler */ state->req->async.fn = appendacl_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = APPENDACL_OPENPATH; return c; diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c index e0f4919f0b..3db777ddc8 100644 --- a/source4/libcli/smb_composite/connect.c +++ b/source4/libcli/smb_composite/connect.c @@ -129,7 +129,7 @@ static NTSTATUS connect_session_setup_anon(struct composite_context *c, } state->req->async.fn = request_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = CONNECT_TCON; return NT_STATUS_OK; @@ -215,7 +215,7 @@ static NTSTATUS connect_session_setup(struct composite_context *c, } state->req->async.fn = request_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = CONNECT_TCON; return NT_STATUS_OK; @@ -285,7 +285,7 @@ static NTSTATUS connect_send_negprot(struct composite_context *c, NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = request_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = CONNECT_NEGPROT; return NT_STATUS_OK; @@ -354,7 +354,7 @@ static NTSTATUS connect_socket(struct composite_context *c, NT_STATUS_HAVE_NO_MEMORY(state->req); state->req->async.fn = request_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = CONNECT_SESSION_REQUEST; return NT_STATUS_OK; @@ -434,7 +434,7 @@ static void state_handler(struct composite_context *c) */ static void request_handler(struct smbcli_request *req) { - struct composite_context *c = talloc_get_type(req->async.private, + struct composite_context *c = talloc_get_type(req->async.private_data, struct composite_context); state_handler(c); } diff --git a/source4/libcli/smb_composite/fsinfo.c b/source4/libcli/smb_composite/fsinfo.c index 7c9c7963f4..3bc93b62ab 100644 --- a/source4/libcli/smb_composite/fsinfo.c +++ b/source4/libcli/smb_composite/fsinfo.c @@ -47,7 +47,7 @@ static NTSTATUS fsinfo_connect(struct composite_context *c, state->fsinfo); NT_STATUS_HAVE_NO_MEMORY(state->req); - state->req->async.private = c; + state->req->async.private_data = c; state->req->async.fn = fsinfo_raw_handler; state->stage = FSINFO_QUERY; @@ -110,7 +110,7 @@ static void fsinfo_state_handler(struct composite_context *creq) */ static void fsinfo_raw_handler(struct smbcli_request *req) { - struct composite_context *c = talloc_get_type(req->async.private, + struct composite_context *c = talloc_get_type(req->async.private_data, struct composite_context); fsinfo_state_handler(c); } diff --git a/source4/libcli/smb_composite/loadfile.c b/source4/libcli/smb_composite/loadfile.c index 952f24b811..994c29c77d 100644 --- a/source4/libcli/smb_composite/loadfile.c +++ b/source4/libcli/smb_composite/loadfile.c @@ -61,7 +61,7 @@ static NTSTATUS setup_close(struct composite_context *c, /* call the handler again when the close is done */ state->req->async.fn = loadfile_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = LOADFILE_CLOSE; return NT_STATUS_OK; @@ -113,7 +113,7 @@ static NTSTATUS loadfile_open(struct composite_context *c, /* call the handler again when the first read is done */ state->req->async.fn = loadfile_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = LOADFILE_READ; talloc_free(state->io_open); @@ -152,7 +152,7 @@ static NTSTATUS loadfile_read(struct composite_context *c, /* call the handler again when the read is done */ state->req->async.fn = loadfile_handler; - state->req->async.private = c; + state->req->async.private_data = c; return NT_STATUS_OK; } @@ -180,7 +180,7 @@ static NTSTATUS loadfile_close(struct composite_context *c, */ static void loadfile_handler(struct smbcli_request *req) { - struct composite_context *c = (struct composite_context *)req->async.private; + struct composite_context *c = (struct composite_context *)req->async.private_data; struct loadfile_state *state = talloc_get_type(c->private_data, struct loadfile_state); /* when this handler is called, the stage indicates what @@ -250,7 +250,7 @@ struct composite_context *smb_composite_loadfile_send(struct smbcli_tree *tree, /* setup the callback handler */ state->req->async.fn = loadfile_handler; - state->req->async.private = c; + state->req->async.private_data = c; state->stage = LOADFILE_OPEN; return c; diff --git a/source4/libcli/smb_composite/savefile.c b/source4/libcli/smb_composite/savefile.c index f02ca46f06..25a35c01a9 100644 --- a/source4/libcli/smb_composite/savefile.c +++ b/source4/libcli/smb_composite/savefile.c @@ -64,7 +64,7 @@ static NTSTATUS setup_close(struct composite_context *c, /* call the handler again when the close is done */ state->stage = SAVEFILE_CLOSE; state->req->async.fn = savefile_handler; - state->req->async.private = c; + state->req->async.private_data = c; return NT_STATUS_OK; } @@ -108,7 +108,7 @@ static NTSTATUS savefile_open(struct composite_context *c, /* call the handler again when the first write is done */ state->stage = SAVEFILE_WRITE; state->req->async.fn = savefile_handler; - state->req->async.private = c; + state->req->async.private_data = c; talloc_free(state->io_open); return NT_STATUS_OK; @@ -149,7 +149,7 @@ static NTSTATUS savefile_write(struct composite_context *c, /* call the handler again when the write is done */ state->req->async.fn = savefile_handler; - state->req->async.private = c; + state->req->async.private_data = c; return NT_STATUS_OK; } @@ -181,7 +181,7 @@ static NTSTATUS savefile_close(struct composite_context *c, */ static void savefile_handler(struct smbcli_request *req) { - struct composite_context *c = (struct composite_context *)req->async.private; + struct composite_context *c = (struct composite_context *)req->async.private_data; struct savefile_state *state = talloc_get_type(c->private_data, struct savefile_state); /* when this handler is called, the stage indicates what @@ -254,7 +254,7 @@ struct composite_context *smb_composite_savefile_send(struct smbcli_tree *tree, /* setup the callback handler */ state->req->async.fn = savefile_handler; - state->req->async.private = c; + state->req->async.private_data = c; c->private_data = state; return c; diff --git a/source4/libcli/smb_composite/sesssetup.c b/source4/libcli/smb_composite/sesssetup.c index 7c9d1fb731..83d15e98eb 100644 --- a/source4/libcli/smb_composite/sesssetup.c +++ b/source4/libcli/smb_composite/sesssetup.c @@ -80,7 +80,7 @@ static void set_user_session_key(struct smbcli_session *session, */ static void request_handler(struct smbcli_request *req) { - struct composite_context *c = (struct composite_context *)req->async.private; + struct composite_context *c = (struct composite_context *)req->async.private_data; struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state); struct smbcli_session *session = req->session; DATA_BLOB session_key = data_blob(NULL, 0); diff --git a/source4/librpc/rpc/dcerpc_smb.c b/source4/librpc/rpc/dcerpc_smb.c index 312a44a5f0..013a8578e6 100644 --- a/source4/librpc/rpc/dcerpc_smb.c +++ b/source4/librpc/rpc/dcerpc_smb.c @@ -84,7 +84,7 @@ static void smb_read_callback(struct smbcli_request *req) uint16_t frag_length; NTSTATUS status; - state = talloc_get_type(req->async.private, struct smb_read_state); + state = talloc_get_type(req->async.private_data, struct smb_read_state); smb = talloc_get_type(state->c->transport.private_data, struct smb_private); io = state->io; @@ -133,7 +133,7 @@ static void smb_read_callback(struct smbcli_request *req) } state->req->async.fn = smb_read_callback; - state->req->async.private = state; + state->req->async.private_data = state; } /* @@ -185,7 +185,7 @@ static NTSTATUS send_read_request_continue(struct dcerpc_connection *c, DATA_BLO } req->async.fn = smb_read_callback; - req->async.private = state; + req->async.private_data = state; state->req = req; @@ -221,7 +221,7 @@ struct smb_trans_state { */ static void smb_trans_callback(struct smbcli_request *req) { - struct smb_trans_state *state = (struct smb_trans_state *)req->async.private; + struct smb_trans_state *state = (struct smb_trans_state *)req->async.private_data; struct dcerpc_connection *c = state->c; NTSTATUS status; @@ -293,7 +293,7 @@ static NTSTATUS smb_send_trans_request(struct dcerpc_connection *c, DATA_BLOB *b } state->req->async.fn = smb_trans_callback; - state->req->async.private = state; + state->req->async.private_data = state; talloc_steal(state, state->req); @@ -305,7 +305,7 @@ static NTSTATUS smb_send_trans_request(struct dcerpc_connection *c, DATA_BLOB *b */ static void smb_write_callback(struct smbcli_request *req) { - struct dcerpc_connection *c = (struct dcerpc_connection *)req->async.private; + struct dcerpc_connection *c = (struct dcerpc_connection *)req->async.private_data; if (!NT_STATUS_IS_OK(req->status)) { DEBUG(0,("dcerpc_smb: write callback error\n")); @@ -351,7 +351,7 @@ static NTSTATUS smb_send_request(struct dcerpc_connection *c, DATA_BLOB *blob, } req->async.fn = smb_write_callback; - req->async.private = c; + req->async.private_data = c; if (trigger_read) { send_read_request(c); @@ -501,7 +501,7 @@ struct composite_context *dcerpc_pipe_open_smb_send(struct dcerpc_pipe *p, static void pipe_open_recv(struct smbcli_request *req) { - struct pipe_open_smb_state *state = talloc_get_type(req->async.private, + struct pipe_open_smb_state *state = talloc_get_type(req->async.private_data, struct pipe_open_smb_state); struct composite_context *ctx = state->ctx; struct dcerpc_connection *c = state->c; diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index 2ac60ee71b..be9096b01f 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -289,7 +289,7 @@ static int async_info_destructor(struct async_info *async) */ static void async_simple(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smbcli_request_simple_recv(c_req); talloc_free(async); @@ -310,7 +310,7 @@ static void async_simple(struct smbcli_request *c_req) async->cvfs = p; \ async->c_req = c_req; \ DLIST_ADD(p->pending, async); \ - c_req->async.private = async; \ + c_req->async.private_data = async; \ talloc_set_destructor(async, async_info_destructor); \ } \ c_req->async.fn = async_fn; \ @@ -350,7 +350,7 @@ static NTSTATUS cvfs_unlink(struct ntvfs_module_context *ntvfs, */ static void async_ioctl(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_ioctl_recv(c_req, req, async->parms); talloc_free(async); @@ -404,7 +404,7 @@ static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs, */ static void async_qpathinfo(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_pathinfo_recv(c_req, req, async->parms); talloc_free(async); @@ -436,7 +436,7 @@ static NTSTATUS cvfs_qpathinfo(struct ntvfs_module_context *ntvfs, */ static void async_qfileinfo(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_fileinfo_recv(c_req, req, async->parms); talloc_free(async); @@ -490,7 +490,7 @@ static NTSTATUS cvfs_setpathinfo(struct ntvfs_module_context *ntvfs, */ static void async_open(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct cvfs_private *cvfs = async->cvfs; struct ntvfs_request *req = async->req; struct cvfs_file *f = async->f; @@ -638,7 +638,7 @@ static NTSTATUS cvfs_copy(struct ntvfs_module_context *ntvfs, */ static void async_read(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_read_recv(c_req, async->parms); talloc_free(async); @@ -677,7 +677,7 @@ static NTSTATUS cvfs_read(struct ntvfs_module_context *ntvfs, */ static void async_write(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_write_recv(c_req, async->parms); talloc_free(async); @@ -715,7 +715,7 @@ static NTSTATUS cvfs_write(struct ntvfs_module_context *ntvfs, */ static void async_seek(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_seek_recv(c_req, async->parms); talloc_free(async); @@ -930,7 +930,7 @@ static NTSTATUS cvfs_setfileinfo(struct ntvfs_module_context *ntvfs, */ static void async_fsinfo(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_fsinfo_recv(c_req, req, async->parms); talloc_free(async); @@ -1010,7 +1010,7 @@ static NTSTATUS cvfs_search_close(struct ntvfs_module_context *ntvfs, */ static void async_trans2(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_trans2_recv(c_req, req, async->parms); talloc_free(async); @@ -1054,7 +1054,7 @@ static NTSTATUS cvfs_trans(struct ntvfs_module_context *ntvfs, */ static void async_changenotify(struct smbcli_request *c_req) { - struct async_info *async = c_req->async.private; + struct async_info *async = c_req->async.private_data; struct ntvfs_request *req = async->req; req->async_states->status = smb_raw_changenotify_recv(c_req, req, async->parms); talloc_free(async); diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index 23844a2c85..f4f91c8ba3 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -510,7 +510,7 @@ static NTSTATUS benchrw_close(struct torture_context *tctx, NT_STATUS_HAVE_NO_MEMORY(req); /*register the callback function!*/ req->async.fn = benchrw_callback; - req->async.private = state; + req->async.private_data = state; return NT_STATUS_OK; } @@ -521,7 +521,7 @@ static void benchrw_callback(struct smbcli_request *req); static void benchrw_rw_callback(struct smbcli_request *req) { - struct benchrw_state *state = req->async.private; + struct benchrw_state *state = req->async.private_data; struct torture_context *tctx = state->tctx; if (!NT_STATUS_IS_OK(req->status)) { @@ -596,7 +596,7 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx, NT_STATUS_HAVE_NO_MEMORY(req); /*register the callback function!*/ req->async.fn = benchrw_rw_callback; - req->async.private = state; + req->async.private_data = state; return NT_STATUS_OK; } @@ -644,7 +644,7 @@ static NTSTATUS benchrw_open(struct torture_context *tctx, /*register the callback function!*/ req->async.fn = benchrw_callback; - req->async.private = state; + req->async.private_data = state; return NT_STATUS_OK; } @@ -691,7 +691,7 @@ static NTSTATUS benchrw_mkdir(struct torture_context *tctx, /*register the callback function!*/ req->async.fn = benchrw_callback; - req->async.private = state; + req->async.private_data = state; return NT_STATUS_OK; } @@ -701,7 +701,7 @@ static NTSTATUS benchrw_mkdir(struct torture_context *tctx, */ static void benchrw_callback(struct smbcli_request *req) { - struct benchrw_state *state = req->async.private; + struct benchrw_state *state = req->async.private_data; struct torture_context *tctx = state->tctx; /*dont send new requests when torture_numops is reached*/ @@ -913,7 +913,7 @@ bool run_benchrw(struct torture_context *tctx) req = smb_raw_mkdir_send(state[i]->cli,&parms); /* register callback fn + private data */ req->async.fn = benchrw_callback; - req->async.private=state[i]; + req->async.private_data=state[i]; break; /* error occured , finish */ case ERROR: diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c index 428be25503..be02f33378 100644 --- a/source4/torture/gentest.c +++ b/source4/torture/gentest.c @@ -1024,7 +1024,7 @@ static bool oplock_handler_smb(struct smbcli_transport *transport, uint16_t tid, } req->async.fn = oplock_handler_close_recv_smb; - req->async.private = NULL; + req->async.private_data = NULL; return true; } diff --git a/source4/torture/raw/lockbench.c b/source4/torture/raw/lockbench.c index 4077ae97e6..d20175a018 100644 --- a/source4/torture/raw/lockbench.c +++ b/source4/torture/raw/lockbench.c @@ -112,7 +112,7 @@ static void lock_send(struct benchlock_state *state) DEBUG(0,("Failed to setup lock\n")); lock_failed++; } - state->req->async.private = state; + state->req->async.private_data = state; state->req->async.fn = lock_completion; } @@ -222,7 +222,7 @@ static void reopen_connection(struct tevent_context *ev, struct tevent_timer *te */ static void lock_completion(struct smbcli_request *req) { - struct benchlock_state *state = (struct benchlock_state *)req->async.private; + struct benchlock_state *state = (struct benchlock_state *)req->async.private_data; NTSTATUS status = smbcli_request_simple_recv(req); state->req = NULL; if (!NT_STATUS_IS_OK(status)) { @@ -262,7 +262,7 @@ static void lock_completion(struct smbcli_request *req) static void echo_completion(struct smbcli_request *req) { - struct benchlock_state *state = (struct benchlock_state *)req->async.private; + struct benchlock_state *state = (struct benchlock_state *)req->async.private_data; NTSTATUS status = smbcli_request_simple_recv(req); if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) || NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT)) { @@ -305,7 +305,7 @@ static void report_rate(struct tevent_context *ev, struct tevent_timer *te, p.in.size = 0; p.in.data = NULL; req = smb_raw_echo_send(state[i].tree->session->transport, &p); - req->async.private = &state[i]; + req->async.private_data = &state[i]; req->async.fn = echo_completion; } } diff --git a/source4/torture/raw/offline.c b/source4/torture/raw/offline.c index 2d97efa049..5322f471a2 100644 --- a/source4/torture/raw/offline.c +++ b/source4/torture/raw/offline.c @@ -159,7 +159,7 @@ static void savefile_callback(struct composite_context *ctx) */ static void setoffline_callback(struct smbcli_request *req) { - struct offline_state *state = req->async.private; + struct offline_state *state = req->async.private_data; NTSTATUS status; status = smbcli_request_simple_recv(req); @@ -183,7 +183,7 @@ static void setoffline_callback(struct smbcli_request *req) */ static void getoffline_callback(struct smbcli_request *req) { - struct offline_state *state = req->async.private; + struct offline_state *state = req->async.private_data; NTSTATUS status; union smb_fileinfo io; @@ -286,7 +286,7 @@ static void test_offline(struct offline_state *state) } state->req->async.fn = setoffline_callback; - state->req->async.private = state; + state->req->async.private_data = state; break; } @@ -303,7 +303,7 @@ static void test_offline(struct offline_state *state) } state->req->async.fn = getoffline_callback; - state->req->async.private = state; + state->req->async.private_data = state; break; } @@ -318,7 +318,7 @@ static void test_offline(struct offline_state *state) static void echo_completion(struct smbcli_request *req) { - struct offline_state *state = (struct offline_state *)req->async.private; + struct offline_state *state = (struct offline_state *)req->async.private_data; NTSTATUS status = smbcli_request_simple_recv(req); if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) || NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT)) { @@ -380,7 +380,7 @@ static void report_rate(struct tevent_context *ev, struct tevent_timer *te, p.in.size = 0; p.in.data = NULL; req = smb_raw_echo_send(state[i].tree->session->transport, &p); - req->async.private = &state[i]; + req->async.private_data = &state[i]; req->async.fn = echo_completion; } } diff --git a/source4/torture/raw/openbench.c b/source4/torture/raw/openbench.c index a9ce4aec0d..bdad2b16a5 100644 --- a/source4/torture/raw/openbench.c +++ b/source4/torture/raw/openbench.c @@ -186,7 +186,7 @@ static void next_open(struct benchopen_state *state) state->req_open = smb_raw_open_send(state->tree, &state->open_parms); state->req_open->async.fn = open_completed; - state->req_open->async.private = state; + state->req_open->async.private_data = state; } @@ -203,7 +203,7 @@ static void next_close(struct benchopen_state *state) state->req_close = smb_raw_close_send(state->tree, &state->close_parms); state->req_close->async.fn = close_completed; - state->req_close->async.private = state; + state->req_close->async.private_data = state; } /* @@ -211,7 +211,7 @@ static void next_close(struct benchopen_state *state) */ static void open_completed(struct smbcli_request *req) { - struct benchopen_state *state = (struct benchopen_state *)req->async.private; + struct benchopen_state *state = (struct benchopen_state *)req->async.private_data; TALLOC_CTX *tmp_ctx = talloc_new(state->mem_ctx); NTSTATUS status; @@ -243,7 +243,7 @@ static void open_completed(struct smbcli_request *req) state->open_retries++; state->req_open = smb_raw_open_send(state->tree, &state->open_parms); state->req_open->async.fn = open_completed; - state->req_open->async.private = state; + state->req_open->async.private_data = state; return; } @@ -275,7 +275,7 @@ static void open_completed(struct smbcli_request *req) */ static void close_completed(struct smbcli_request *req) { - struct benchopen_state *state = (struct benchopen_state *)req->async.private; + struct benchopen_state *state = (struct benchopen_state *)req->async.private_data; NTSTATUS status = smbcli_request_simple_recv(req); state->req_close = NULL; @@ -312,7 +312,7 @@ static void close_completed(struct smbcli_request *req) static void echo_completion(struct smbcli_request *req) { - struct benchopen_state *state = (struct benchopen_state *)req->async.private; + struct benchopen_state *state = (struct benchopen_state *)req->async.private_data; NTSTATUS status = smbcli_request_simple_recv(req); if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) || NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT)) { @@ -357,7 +357,7 @@ static void report_rate(struct tevent_context *ev, struct tevent_timer *te, p.in.size = 0; p.in.data = NULL; req = smb_raw_echo_send(state[i].tree->session->transport, &p); - req->async.private = &state[i]; + req->async.private_data = &state[i]; req->async.fn = echo_completion; } } diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index 1f85725d9e..c10c49ecf3 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -166,7 +166,7 @@ static bool oplock_handler_close(struct smbcli_transport *transport, uint16_t ti } req->async.fn = oplock_handler_close_recv; - req->async.private = NULL; + req->async.private_data = NULL; return true; } -- cgit From 1441e87e249190bd9fea72773b8fd014a05f9861 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 10:21:51 +0100 Subject: s4:service_task: s/private/private_data metze --- source4/dsdb/repl/drepl_service.c | 2 +- source4/smbd/service_task.h | 2 +- source4/web_server/web_server.c | 6 +++--- source4/wrepl_server/wrepl_server.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source4/dsdb/repl/drepl_service.c b/source4/dsdb/repl/drepl_service.c index 98d1c1b06c..152bbec4d5 100644 --- a/source4/dsdb/repl/drepl_service.c +++ b/source4/dsdb/repl/drepl_service.c @@ -140,7 +140,7 @@ static void dreplsrv_task_init(struct task_server *task) } service->task = task; service->startup_time = timeval_current(); - task->private = service; + task->private_data = service; status = dreplsrv_init_creds(service); if (!W_ERROR_IS_OK(status)) { diff --git a/source4/smbd/service_task.h b/source4/smbd/service_task.h index f5788da021..69ecb1b970 100644 --- a/source4/smbd/service_task.h +++ b/source4/smbd/service_task.h @@ -30,7 +30,7 @@ struct task_server { struct messaging_context *msg_ctx; struct loadparm_context *lp_ctx; struct server_id server_id; - void *private; + void *private_data; }; diff --git a/source4/web_server/web_server.c b/source4/web_server/web_server.c index 9d1d160ae7..1c7449fb47 100644 --- a/source4/web_server/web_server.c +++ b/source4/web_server/web_server.c @@ -202,7 +202,7 @@ static void websrv_recv(struct stream_connection *conn, uint16_t flags) destroy the stack variables being used by that rendering process when we handle the timeout. */ if (!talloc_reference(web->task, web)) goto failed; - wdata = talloc_get_type(web->task->private, struct web_server_data); + wdata = talloc_get_type(web->task->private_data, struct web_server_data); if (wdata == NULL) goto failed; wdata->http_process_input(wdata, web); talloc_unlink(web->task, web); @@ -252,7 +252,7 @@ static void websrv_send(struct stream_connection *conn, uint16_t flags) static void websrv_accept(struct stream_connection *conn) { struct task_server *task = talloc_get_type(conn->private, struct task_server); - struct web_server_data *wdata = talloc_get_type(task->private, struct web_server_data); + struct web_server_data *wdata = talloc_get_type(task->private_data, struct web_server_data); struct websrv_context *web; struct socket_context *tls_socket; @@ -343,7 +343,7 @@ static void websrv_task_init(struct task_server *task) wdata = talloc_zero(task, struct web_server_data); if (wdata == NULL)goto failed; - task->private = wdata; + task->private_data = wdata; wdata->tls_params = tls_initialise(wdata, task->lp_ctx); if (wdata->tls_params == NULL) goto failed; diff --git a/source4/wrepl_server/wrepl_server.c b/source4/wrepl_server/wrepl_server.c index 5e100f46cc..c8316a5f4c 100644 --- a/source4/wrepl_server/wrepl_server.c +++ b/source4/wrepl_server/wrepl_server.c @@ -464,7 +464,7 @@ static void wreplsrv_task_init(struct task_server *task) } service->task = task; service->startup_time = timeval_current(); - task->private = service; + task->private_data = service; /* * setup up all partners, and open the winsdb -- cgit From d9c30894a1cb3d0814ba281dd6e9f5ca63c987d5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 10:30:03 +0100 Subject: s4:service_stream: s/private/private_data metze --- source4/kdc/kdc.c | 8 ++++---- source4/ldap_server/ldap_server.c | 8 ++++---- source4/ntp_signd/ntp_signd.c | 8 ++++---- source4/rpc_server/service_rpc.c | 8 ++++---- source4/smb_server/smb_server.c | 6 +++--- source4/smbd/service_named_pipe.c | 12 ++++++------ source4/smbd/service_stream.c | 4 ++-- source4/smbd/service_stream.h | 2 +- source4/web_server/web_server.c | 8 ++++---- source4/winbind/wb_server.c | 8 ++++---- source4/wrepl_server/wrepl_in_connection.c | 8 ++++---- 11 files changed, 40 insertions(+), 40 deletions(-) diff --git a/source4/kdc/kdc.c b/source4/kdc/kdc.c index 48ef5c50d2..1cfe9852f0 100644 --- a/source4/kdc/kdc.c +++ b/source4/kdc/kdc.c @@ -285,7 +285,7 @@ static NTSTATUS kdc_tcp_recv(void *private_data, DATA_BLOB blob) */ static void kdc_tcp_recv_handler(struct stream_connection *conn, uint16_t flags) { - struct kdc_tcp_connection *kdcconn = talloc_get_type(conn->private, + struct kdc_tcp_connection *kdcconn = talloc_get_type(conn->private_data, struct kdc_tcp_connection); packet_recv(kdcconn->packet); } @@ -305,7 +305,7 @@ static void kdc_tcp_recv_error(void *private_data, NTSTATUS status) */ static void kdc_tcp_send(struct stream_connection *conn, uint16_t flags) { - struct kdc_tcp_connection *kdcconn = talloc_get_type(conn->private, + struct kdc_tcp_connection *kdcconn = talloc_get_type(conn->private_data, struct kdc_tcp_connection); packet_queue_run(kdcconn->packet); } @@ -357,7 +357,7 @@ static bool kdc_process(struct kdc_server *kdc, */ static void kdc_tcp_generic_accept(struct stream_connection *conn, kdc_process_fn_t process_fn) { - struct kdc_server *kdc = talloc_get_type(conn->private, struct kdc_server); + struct kdc_server *kdc = talloc_get_type(conn->private_data, struct kdc_server); struct kdc_tcp_connection *kdcconn; kdcconn = talloc_zero(conn, struct kdc_tcp_connection); @@ -368,7 +368,7 @@ static void kdc_tcp_generic_accept(struct stream_connection *conn, kdc_process_f kdcconn->conn = conn; kdcconn->kdc = kdc; kdcconn->process = process_fn; - conn->private = kdcconn; + conn->private_data = kdcconn; kdcconn->packet = packet_init(kdcconn); if (kdcconn->packet == NULL) { diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c index 8d7e629848..61ff387152 100644 --- a/source4/ldap_server/ldap_server.c +++ b/source4/ldap_server/ldap_server.c @@ -183,7 +183,7 @@ static void ldapsrv_conn_idle_timeout(struct tevent_context *ev, void ldapsrv_recv(struct stream_connection *c, uint16_t flags) { struct ldapsrv_connection *conn = - talloc_get_type(c->private, struct ldapsrv_connection); + talloc_get_type(c->private_data, struct ldapsrv_connection); if (conn->limits.ite) { /* clean initial timeout if any */ talloc_free(conn->limits.ite); @@ -209,7 +209,7 @@ void ldapsrv_recv(struct stream_connection *c, uint16_t flags) static void ldapsrv_send(struct stream_connection *c, uint16_t flags) { struct ldapsrv_connection *conn = - talloc_get_type(c->private, struct ldapsrv_connection); + talloc_get_type(c->private_data, struct ldapsrv_connection); packet_queue_run(conn->packet); } @@ -328,7 +328,7 @@ failed: static void ldapsrv_accept(struct stream_connection *c) { struct ldapsrv_service *ldapsrv_service = - talloc_get_type(c->private, struct ldapsrv_service); + talloc_get_type(c->private_data, struct ldapsrv_service); struct ldapsrv_connection *conn; struct cli_credentials *server_credentials; struct socket_address *socket_address; @@ -347,7 +347,7 @@ static void ldapsrv_accept(struct stream_connection *c) conn->sockets.raw = c->socket; conn->lp_ctx = ldapsrv_service->task->lp_ctx; - c->private = conn; + c->private_data = conn; socket_address = socket_get_my_addr(c->socket, conn); if (!socket_address) { diff --git a/source4/ntp_signd/ntp_signd.c b/source4/ntp_signd/ntp_signd.c index 3040716897..4306e5a938 100644 --- a/source4/ntp_signd/ntp_signd.c +++ b/source4/ntp_signd/ntp_signd.c @@ -263,7 +263,7 @@ static NTSTATUS ntp_signd_recv(void *private_data, DATA_BLOB wrapped_input) */ static void ntp_signd_recv_handler(struct stream_connection *conn, uint16_t flags) { - struct ntp_signd_connection *ntp_signdconn = talloc_get_type(conn->private, + struct ntp_signd_connection *ntp_signdconn = talloc_get_type(conn->private_data, struct ntp_signd_connection); packet_recv(ntp_signdconn->packet); } @@ -282,7 +282,7 @@ static void ntp_signd_recv_error(void *private_data, NTSTATUS status) */ static void ntp_signd_send(struct stream_connection *conn, uint16_t flags) { - struct ntp_signd_connection *ntp_signdconn = talloc_get_type(conn->private, + struct ntp_signd_connection *ntp_signdconn = talloc_get_type(conn->private_data, struct ntp_signd_connection); packet_queue_run(ntp_signdconn->packet); } @@ -292,7 +292,7 @@ static void ntp_signd_send(struct stream_connection *conn, uint16_t flags) */ static void ntp_signd_accept(struct stream_connection *conn) { - struct ntp_signd_server *ntp_signd = talloc_get_type(conn->private, struct ntp_signd_server); + struct ntp_signd_server *ntp_signd = talloc_get_type(conn->private_data, struct ntp_signd_server); struct ntp_signd_connection *ntp_signdconn; ntp_signdconn = talloc_zero(conn, struct ntp_signd_connection); @@ -302,7 +302,7 @@ static void ntp_signd_accept(struct stream_connection *conn) } ntp_signdconn->conn = conn; ntp_signdconn->ntp_signd = ntp_signd; - conn->private = ntp_signdconn; + conn->private_data = ntp_signdconn; ntp_signdconn->packet = packet_init(ntp_signdconn); if (ntp_signdconn->packet == NULL) { diff --git a/source4/rpc_server/service_rpc.c b/source4/rpc_server/service_rpc.c index ec10c748f0..5596944bd8 100644 --- a/source4/rpc_server/service_rpc.c +++ b/source4/rpc_server/service_rpc.c @@ -103,7 +103,7 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn) { NTSTATUS status; struct dcesrv_socket_context *dcesrv_sock = - talloc_get_type(srv_conn->private, struct dcesrv_socket_context); + talloc_get_type(srv_conn->private_data, struct dcesrv_socket_context); struct dcesrv_connection *dcesrv_conn = NULL; if (!srv_conn->session_info) { @@ -144,7 +144,7 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn) dcesrv_conn->auth_state.session_key = dcesrv_inherited_session_key; } - srv_conn->private = dcesrv_conn; + srv_conn->private_data = dcesrv_conn; irpc_add_name(srv_conn->msg_ctx, "rpc_server"); @@ -154,7 +154,7 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn) static void dcesrv_sock_recv(struct stream_connection *conn, uint16_t flags) { NTSTATUS status; - struct dcesrv_connection *dce_conn = talloc_get_type(conn->private, struct dcesrv_connection); + struct dcesrv_connection *dce_conn = talloc_get_type(conn->private_data, struct dcesrv_connection); DATA_BLOB tmp_blob; size_t nread; @@ -200,7 +200,7 @@ static void dcesrv_sock_recv(struct stream_connection *conn, uint16_t flags) static void dcesrv_sock_send(struct stream_connection *conn, uint16_t flags) { - struct dcesrv_connection *dce_conn = talloc_get_type(conn->private, struct dcesrv_connection); + struct dcesrv_connection *dce_conn = talloc_get_type(conn->private_data, struct dcesrv_connection); NTSTATUS status; status = dcesrv_output(dce_conn, conn->socket, dcerpc_write_fn); diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c index a18440bfa8..6206a03b21 100644 --- a/source4/smb_server/smb_server.c +++ b/source4/smb_server/smb_server.c @@ -88,7 +88,7 @@ void smbsrv_terminate_connection(struct smbsrv_connection *smb_conn, const char */ static void smbsrv_recv(struct stream_connection *conn, uint16_t flags) { - struct smbsrv_connection *smb_conn = talloc_get_type(conn->private, + struct smbsrv_connection *smb_conn = talloc_get_type(conn->private_data, struct smbsrv_connection); DEBUG(10,("smbsrv_recv\n")); @@ -101,7 +101,7 @@ static void smbsrv_recv(struct stream_connection *conn, uint16_t flags) */ static void smbsrv_send(struct stream_connection *conn, uint16_t flags) { - struct smbsrv_connection *smb_conn = talloc_get_type(conn->private, + struct smbsrv_connection *smb_conn = talloc_get_type(conn->private_data, struct smbsrv_connection); packet_queue_run(smb_conn->packet); } @@ -148,7 +148,7 @@ static void smbsrv_accept(struct stream_connection *conn) smb_conn->lp_ctx = conn->lp_ctx; smb_conn->connection = conn; - conn->private = smb_conn; + conn->private_data = smb_conn; smb_conn->statistics.connect_time = timeval_current(); diff --git a/source4/smbd/service_named_pipe.c b/source4/smbd/service_named_pipe.c index ffa4072392..de4726e4d5 100644 --- a/source4/smbd/service_named_pipe.c +++ b/source4/smbd/service_named_pipe.c @@ -60,8 +60,8 @@ static void named_pipe_handover_connection(void *private_data) /* * remove the named_pipe layer together with its packet layer */ - conn->ops = pipe_conn->pipe_sock->ops; - conn->private = pipe_conn->pipe_sock->private_data; + conn->ops = pipe_conn->pipe_sock->ops; + conn->private_data = pipe_conn->pipe_sock->private_data; talloc_free(pipe_conn); /* we're now ready to start receiving events on this stream */ @@ -209,7 +209,7 @@ reply: static void named_pipe_recv(struct stream_connection *conn, uint16_t flags) { struct named_pipe_connection *pipe_conn = talloc_get_type( - conn->private, struct named_pipe_connection); + conn->private_data, struct named_pipe_connection); DEBUG(10,("named_pipe_recv\n")); @@ -222,7 +222,7 @@ static void named_pipe_recv(struct stream_connection *conn, uint16_t flags) static void named_pipe_send(struct stream_connection *conn, uint16_t flags) { struct named_pipe_connection *pipe_conn = talloc_get_type( - conn->private, struct named_pipe_connection); + conn->private_data, struct named_pipe_connection); packet_queue_run(pipe_conn->packet); } @@ -262,7 +262,7 @@ static NTSTATUS named_pipe_full_request(void *private_data, DATA_BLOB blob, size static void named_pipe_accept(struct stream_connection *conn) { struct named_pipe_socket *pipe_sock = talloc_get_type( - conn->private, struct named_pipe_socket); + conn->private_data, struct named_pipe_socket); struct named_pipe_connection *pipe_conn; DEBUG(5,("named_pipe_accept\n")); @@ -291,7 +291,7 @@ static void named_pipe_accept(struct stream_connection *conn) pipe_conn->pipe_sock = pipe_sock; pipe_conn->connection = conn; - conn->private = pipe_conn; + conn->private_data = pipe_conn; } static const struct stream_server_ops named_pipe_stream_ops = { diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c index fe07dc5a38..e09ac1d9e6 100644 --- a/source4/smbd/service_stream.c +++ b/source4/smbd/service_stream.c @@ -136,7 +136,7 @@ NTSTATUS stream_new_connection_merge(struct tevent_context *ev, talloc_steal(srv_conn, sock); - srv_conn->private = private_data; + srv_conn->private_data = private_data; srv_conn->model_ops = model_ops; srv_conn->socket = sock; srv_conn->server_id = cluster_id(0, 0); @@ -177,7 +177,7 @@ static void stream_new_connection(struct tevent_context *ev, talloc_steal(srv_conn, sock); - srv_conn->private = stream_socket->private_data; + srv_conn->private_data = stream_socket->private_data; srv_conn->model_ops = stream_socket->model_ops; srv_conn->socket = sock; srv_conn->server_id = server_id; diff --git a/source4/smbd/service_stream.h b/source4/smbd/service_stream.h index 078887bf14..5d577d4dd8 100644 --- a/source4/smbd/service_stream.h +++ b/source4/smbd/service_stream.h @@ -39,7 +39,7 @@ struct stream_connection { const struct stream_server_ops *ops; const struct model_ops *model_ops; struct server_id server_id; - void *private; + void *private_data; struct { struct tevent_context *ctx; diff --git a/source4/web_server/web_server.c b/source4/web_server/web_server.c index 1c7449fb47..2a2bfbb13b 100644 --- a/source4/web_server/web_server.c +++ b/source4/web_server/web_server.c @@ -145,7 +145,7 @@ NTSTATUS http_parse_header(struct websrv_context *web, const char *line) static void websrv_recv(struct stream_connection *conn, uint16_t flags) { struct web_server_data *wdata; - struct websrv_context *web = talloc_get_type(conn->private, + struct websrv_context *web = talloc_get_type(conn->private_data, struct websrv_context); NTSTATUS status; uint8_t buf[1024]; @@ -220,7 +220,7 @@ failed: */ static void websrv_send(struct stream_connection *conn, uint16_t flags) { - struct websrv_context *web = talloc_get_type(conn->private, + struct websrv_context *web = talloc_get_type(conn->private_data, struct websrv_context); NTSTATUS status; size_t nsent; @@ -251,7 +251,7 @@ static void websrv_send(struct stream_connection *conn, uint16_t flags) */ static void websrv_accept(struct stream_connection *conn) { - struct task_server *task = talloc_get_type(conn->private, struct task_server); + struct task_server *task = talloc_get_type(conn->private_data, struct task_server); struct web_server_data *wdata = talloc_get_type(task->private_data, struct web_server_data); struct websrv_context *web; struct socket_context *tls_socket; @@ -261,7 +261,7 @@ static void websrv_accept(struct stream_connection *conn) web->task = task; web->conn = conn; - conn->private = web; + conn->private_data = web; talloc_set_destructor(web, websrv_destructor); event_add_timed(conn->event.ctx, web, diff --git a/source4/winbind/wb_server.c b/source4/winbind/wb_server.c index bf1f3f29ac..95be49d1e3 100644 --- a/source4/winbind/wb_server.c +++ b/source4/winbind/wb_server.c @@ -49,7 +49,7 @@ static void wbsrv_recv_error(void *private_data, NTSTATUS status) static void wbsrv_accept(struct stream_connection *conn) { - struct wbsrv_listen_socket *listen_socket = talloc_get_type(conn->private, + struct wbsrv_listen_socket *listen_socket = talloc_get_type(conn->private_data, struct wbsrv_listen_socket); struct wbsrv_connection *wbconn; @@ -61,7 +61,7 @@ static void wbsrv_accept(struct stream_connection *conn) wbconn->conn = conn; wbconn->listen_socket = listen_socket; wbconn->lp_ctx = listen_socket->service->task->lp_ctx; - conn->private = wbconn; + conn->private_data = wbconn; wbconn->packet = packet_init(wbconn); if (wbconn->packet == NULL) { @@ -83,7 +83,7 @@ static void wbsrv_accept(struct stream_connection *conn) */ static void wbsrv_recv(struct stream_connection *conn, uint16_t flags) { - struct wbsrv_connection *wbconn = talloc_get_type(conn->private, + struct wbsrv_connection *wbconn = talloc_get_type(conn->private_data, struct wbsrv_connection); packet_recv(wbconn->packet); @@ -94,7 +94,7 @@ static void wbsrv_recv(struct stream_connection *conn, uint16_t flags) */ static void wbsrv_send(struct stream_connection *conn, uint16_t flags) { - struct wbsrv_connection *wbconn = talloc_get_type(conn->private, + struct wbsrv_connection *wbconn = talloc_get_type(conn->private_data, struct wbsrv_connection); packet_queue_run(wbconn->packet); } diff --git a/source4/wrepl_server/wrepl_in_connection.c b/source4/wrepl_server/wrepl_in_connection.c index 711ae866dd..e6a69b829a 100644 --- a/source4/wrepl_server/wrepl_in_connection.c +++ b/source4/wrepl_server/wrepl_in_connection.c @@ -123,7 +123,7 @@ static NTSTATUS wreplsrv_recv_request(void *private_data, DATA_BLOB blob) */ static void wreplsrv_recv(struct stream_connection *conn, uint16_t flags) { - struct wreplsrv_in_connection *wreplconn = talloc_get_type(conn->private, + struct wreplsrv_in_connection *wreplconn = talloc_get_type(conn->private_data, struct wreplsrv_in_connection); packet_recv(wreplconn->packet); @@ -134,7 +134,7 @@ static void wreplsrv_recv(struct stream_connection *conn, uint16_t flags) */ static void wreplsrv_send(struct stream_connection *conn, uint16_t flags) { - struct wreplsrv_in_connection *wreplconn = talloc_get_type(conn->private, + struct wreplsrv_in_connection *wreplconn = talloc_get_type(conn->private_data, struct wreplsrv_in_connection); packet_queue_run(wreplconn->packet); } @@ -154,7 +154,7 @@ static void wreplsrv_recv_error(void *private_data, NTSTATUS status) */ static void wreplsrv_accept(struct stream_connection *conn) { - struct wreplsrv_service *service = talloc_get_type(conn->private, struct wreplsrv_service); + struct wreplsrv_service *service = talloc_get_type(conn->private_data, struct wreplsrv_service); struct wreplsrv_in_connection *wreplconn; struct socket_address *peer_ip; @@ -189,7 +189,7 @@ static void wreplsrv_accept(struct stream_connection *conn) wreplconn->partner = wreplsrv_find_partner(service, peer_ip->addr); - conn->private = wreplconn; + conn->private_data = wreplconn; irpc_add_name(conn->msg_ctx, "wreplsrv_connection"); } -- cgit From 87ce6b198ac394f6f683ef125d59c1b18becbc19 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 11:00:08 +0100 Subject: s4:libcli/raw: s/class/eclass metze --- source4/libcli/raw/clitransport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c index 1fa27e37ea..5cf0272e88 100644 --- a/source4/libcli/raw/clitransport.c +++ b/source4/libcli/raw/clitransport.c @@ -450,12 +450,12 @@ static NTSTATUS smbcli_transport_finish_recv(void *private_data, DATA_BLOB blob) smb_setup_bufinfo(req); if (!(req->flags2 & FLAGS2_32_BIT_ERROR_CODES)) { - int class = CVAL(req->in.hdr,HDR_RCLS); + int eclass = CVAL(req->in.hdr,HDR_RCLS); int code = SVAL(req->in.hdr,HDR_ERR); - if (class == 0 && code == 0) { + if (eclass == 0 && code == 0) { transport->error.e.nt_status = NT_STATUS_OK; } else { - transport->error.e.nt_status = NT_STATUS_DOS(class, code); + transport->error.e.nt_status = NT_STATUS_DOS(eclass, code); } } else { transport->error.e.nt_status = NT_STATUS(IVAL(req->in.hdr, HDR_RCLS)); -- cgit From 9c387c189ebb925b22a28f74620b8773c6bf8b32 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 11:06:32 +0100 Subject: s4:resolve/dns_ex: undefine class because it's used in heimdal/lib/roken/resolve.h metze --- source4/libcli/resolve/dns_ex.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source4/libcli/resolve/dns_ex.c b/source4/libcli/resolve/dns_ex.c index 2970681d59..ce41d0cea8 100644 --- a/source4/libcli/resolve/dns_ex.c +++ b/source4/libcli/resolve/dns_ex.c @@ -37,6 +37,11 @@ #include "libcli/composite/composite.h" #include "librpc/gen_ndr/ndr_nbt.h" #include "libcli/resolve/resolve.h" + +#ifdef class +#undef class +#endif + #include "heimdal/lib/roken/resolve.h" struct dns_ex_state { -- cgit From f956dddf57b35408966d58f85864c7274bce15e2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 11:07:48 +0100 Subject: libcli/nbt: s/private/private_data metze --- libcli/nbt/nbtsocket.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libcli/nbt/nbtsocket.c b/libcli/nbt/nbtsocket.c index dac61efc11..a3e295d3df 100644 --- a/libcli/nbt/nbtsocket.c +++ b/libcli/nbt/nbtsocket.c @@ -115,9 +115,9 @@ failed: handle a request timeout */ static void nbt_name_socket_timeout(struct tevent_context *ev, struct tevent_timer *te, - struct timeval t, void *private) + struct timeval t, void *private_data) { - struct nbt_name_request *req = talloc_get_type(private, + struct nbt_name_request *req = talloc_get_type(private_data, struct nbt_name_request); if (req->num_retries != 0) { @@ -314,9 +314,9 @@ done: handle fd events on a nbt_name_socket */ static void nbt_name_socket_handler(struct tevent_context *ev, struct tevent_fd *fde, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - struct nbt_name_socket *nbtsock = talloc_get_type(private, + struct nbt_name_socket *nbtsock = talloc_get_type(private_data, struct nbt_name_socket); if (flags & EVENT_FD_WRITE) { nbt_name_socket_send(nbtsock); @@ -508,10 +508,10 @@ NTSTATUS nbt_name_request_recv(struct nbt_name_request *req) _PUBLIC_ NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock, void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *, struct socket_address *), - void *private) + void *private_data) { nbtsock->incoming.handler = handler; - nbtsock->incoming.private_data = private; + nbtsock->incoming.private_data = private_data; EVENT_FD_READABLE(nbtsock->fde); return NT_STATUS_OK; } -- cgit From 45c26648c3545804aeeddb0ca9aa5e2b6a85182b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 11:10:15 +0100 Subject: s4:update_keytab: s/delete/do_delete metze --- source4/dsdb/samdb/ldb_modules/update_keytab.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/update_keytab.c b/source4/dsdb/samdb/ldb_modules/update_keytab.c index e178ebb9dc..8920afee71 100644 --- a/source4/dsdb/samdb/ldb_modules/update_keytab.c +++ b/source4/dsdb/samdb/ldb_modules/update_keytab.c @@ -47,7 +47,7 @@ struct update_kt_ctx { struct ldb_request *req; struct ldb_dn *dn; - bool delete; + bool do_delete; struct ldb_reply *op_reply; bool found; @@ -75,7 +75,7 @@ static struct update_kt_ctx *update_kt_ctx_init(struct ldb_module *module, * Just hope we are lucky and nothing breaks (using the tdb backend masks a lot * of async issues). -SSS */ -static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delete) { +static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool do_delete) { struct ldb_context *ldb = ldb_module_get_ctx(module); struct update_kt_private *data = talloc_get_type(ldb_module_get_private(module), struct update_kt_private); struct dn_list *item; @@ -126,7 +126,7 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet status = cli_credentials_set_secrets(item->creds, ldb_get_event_context(ldb), ldb_get_opaque(ldb, "loadparm"), ldb, NULL, filter); talloc_free(filter); if (NT_STATUS_IS_OK(status)) { - if (delete) { + if (do_delete) { /* Ensure we don't helpfully keep an old keytab entry */ cli_credentials_set_kvno(item->creds, cli_credentials_get_kvno(item->creds)+2); /* Wipe passwords */ @@ -165,7 +165,7 @@ static int update_kt_op_callback(struct ldb_request *req, LDB_ERR_OPERATIONS_ERROR); } - if (ac->delete) { + if (ac->do_delete) { return ldb_module_done(ac->req, ares->controls, ares->response, LDB_SUCCESS); } @@ -230,10 +230,10 @@ static int ukt_search_modified_callback(struct ldb_request *req, if (ac->found) { /* do the dirty sync job here :/ */ - ret = add_modified(ac->module, ac->dn, ac->delete); + ret = add_modified(ac->module, ac->dn, ac->do_delete); } - if (ac->delete) { + if (ac->do_delete) { ret = ukt_del_op(ac); if (ret != LDB_SUCCESS) { return ldb_module_done(ac->req, @@ -342,7 +342,7 @@ static int update_kt_delete(struct ldb_module *module, struct ldb_request *req) } ac->dn = req->op.del.dn; - ac->delete = true; + ac->do_delete = true; return ukt_search_modified(ac); } -- cgit From 44625f76c174e97e8a2c03a196358c604e78f694 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 11:24:08 +0100 Subject: s4:loadparm: s/class/pclass metze --- source4/param/loadparm.c | 18 +++++++++--------- source4/param/loadparm.h | 2 +- source4/param/pyparam.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index 7c0d268868..0cd92c16f1 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -1221,9 +1221,9 @@ void *lp_parm_ptr(struct loadparm_context *lp_ctx, struct loadparm_service *service, struct parm_struct *parm) { if (service == NULL) { - if (parm->class == P_LOCAL) + if (parm->pclass == P_LOCAL) return ((char *)lp_ctx->sDefault)+parm->offset; - else if (parm->class == P_GLOBAL) + else if (parm->pclass == P_GLOBAL) return ((char *)lp_ctx->globals)+parm->offset; else return NULL; } else { @@ -1264,7 +1264,7 @@ static void copy_service(struct loadparm_service *pserviceDest, bool not_added; for (i = 0; parm_table[i].label; i++) - if (parm_table[i].offset != -1 && parm_table[i].class == P_LOCAL && + if (parm_table[i].offset != -1 && parm_table[i].pclass == P_LOCAL && (bcopyall || pcopymapDest[i])) { void *src_ptr = ((char *)pserviceSource) + parm_table[i].offset; @@ -1743,7 +1743,7 @@ bool lp_do_service_parameter(struct loadparm_context *lp_ctx, return true; } - if (parm_table[parmnum].class == P_GLOBAL) { + if (parm_table[parmnum].pclass == P_GLOBAL) { DEBUG(0, ("Global parameter %s found in service section!\n", pszParmName)); @@ -1758,7 +1758,7 @@ bool lp_do_service_parameter(struct loadparm_context *lp_ctx, * entries with the same data pointer */ for (i = 0; parm_table[i].label; i++) if (parm_table[i].offset == parm_table[parmnum].offset && - parm_table[i].class == parm_table[parmnum].class) + parm_table[i].pclass == parm_table[parmnum].pclass) service->copymap[i] = false; return set_variable(service, parmnum, parm_ptr, pszParmName, @@ -2053,7 +2053,7 @@ static void dump_globals(struct loadparm_context *lp_ctx, FILE *f, fprintf(f, "# Global parameters\n[global]\n"); for (i = 0; parm_table[i].label; i++) - if (parm_table[i].class == P_GLOBAL && + if (parm_table[i].pclass == P_GLOBAL && parm_table[i].offset != -1 && (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) { if (!show_defaults && (lp_ctx->flags[i] & FLAG_DEFAULT)) @@ -2084,7 +2084,7 @@ static void dump_a_service(struct loadparm_service * pService, struct loadparm_s fprintf(f, "\n[%s]\n", pService->szService); for (i = 0; parm_table[i].label; i++) - if (parm_table[i].class == P_LOCAL && + if (parm_table[i].pclass == P_LOCAL && parm_table[i].offset != -1 && (*parm_table[i].label != '-') && (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) { @@ -2157,7 +2157,7 @@ struct parm_struct *lp_next_parameter(struct loadparm_context *lp_ctx, int snum, struct loadparm_service *pService = lp_ctx->services[snum]; for (; parm_table[*i].label; (*i)++) { - if (parm_table[*i].class == P_LOCAL && + if (parm_table[*i].pclass == P_LOCAL && parm_table[*i].offset != -1 && (*parm_table[*i].label != '-') && ((*i) == 0 || @@ -2267,7 +2267,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx) parm_table[i].offset != -1 && !(lp_ctx->flags[i] & FLAG_CMDLINE)) { char **r; - if (parm_table[i].class == P_LOCAL) { + if (parm_table[i].pclass == P_LOCAL) { r = (char **)(((char *)lp_ctx->sDefault) + parm_table[i].offset); } else { r = (char **)(((char *)lp_ctx->globals) + parm_table[i].offset); diff --git a/source4/param/loadparm.h b/source4/param/loadparm.h index 47bce75cfb..454d3f8853 100644 --- a/source4/param/loadparm.h +++ b/source4/param/loadparm.h @@ -46,7 +46,7 @@ struct loadparm_context; struct parm_struct { const char *label; parm_type type; - parm_class class; + parm_class pclass; int offset; bool (*special)(struct loadparm_context *, const char *, char **); const struct enum_list *enum_list; diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c index 42775908ea..07f45d7cf6 100644 --- a/source4/param/pyparam.c +++ b/source4/param/pyparam.c @@ -77,7 +77,7 @@ static PyObject *py_lp_ctx_get_helper(struct loadparm_context *lp_ctx, const cha } parm = lp_parm_struct(param_name); - if (parm == NULL || parm->class == P_GLOBAL) { + if (parm == NULL || parm->pclass == P_GLOBAL) { return NULL; } parm_ptr = lp_parm_ptr(lp_ctx, service, parm); -- cgit From 73aea83966851e11923d2f5fd69171be385e22f7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 11:25:11 +0100 Subject: s4:schema_fsmo: s/class/sclass metze --- source4/dsdb/samdb/ldb_modules/schema_fsmo.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c index a134a3d4d0..edd451255e 100644 --- a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c @@ -291,11 +291,11 @@ static int schema_fsmo_extended(struct ldb_module *module, struct ldb_request *r static int generate_objectClasses(struct ldb_context *ldb, struct ldb_message *msg, const struct dsdb_schema *schema) { - const struct dsdb_class *class; + const struct dsdb_class *sclass; int ret; - for (class = schema->classes; class; class = class->next) { - ret = ldb_msg_add_string(msg, "objectClasses", schema_class_to_description(msg, class)); + for (sclass = schema->classes; sclass; sclass = sclass->next) { + ret = ldb_msg_add_string(msg, "objectClasses", schema_class_to_description(msg, sclass)); if (ret != LDB_SUCCESS) { return ret; } @@ -320,12 +320,12 @@ static int generate_attributeTypes(struct ldb_context *ldb, struct ldb_message * static int generate_dITContentRules(struct ldb_context *ldb, struct ldb_message *msg, const struct dsdb_schema *schema) { - const struct dsdb_class *class; + const struct dsdb_class *sclass; int ret; - for (class = schema->classes; class; class = class->next) { - if (class->auxiliaryClass || class->systemAuxiliaryClass) { - char *ditcontentrule = schema_class_to_dITContentRule(msg, class, schema); + for (sclass = schema->classes; sclass; sclass = sclass->next) { + if (sclass->auxiliaryClass || sclass->systemAuxiliaryClass) { + char *ditcontentrule = schema_class_to_dITContentRule(msg, sclass, schema); if (!ditcontentrule) { ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; -- cgit From 82466db35dd21064f3f3754fb9ebdedaf13566bc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 11:25:39 +0100 Subject: s4:ldif_handlers: s/class/sclass metze --- source4/lib/ldb-samba/ldif_handlers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source4/lib/ldb-samba/ldif_handlers.c b/source4/lib/ldb-samba/ldif_handlers.c index 13bb320d6f..fc87e6ca7a 100644 --- a/source4/lib/ldb-samba/ldif_handlers.c +++ b/source4/lib/ldb-samba/ldif_handlers.c @@ -366,7 +366,7 @@ static int ldif_canonicalise_objectCategory(struct ldb_context *ldb, void *mem_c { struct ldb_dn *dn1 = NULL; const struct dsdb_schema *schema = dsdb_get_schema(ldb); - const struct dsdb_class *class; + const struct dsdb_class *sclass; TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); if (!tmp_ctx) { return LDB_ERR_OPERATIONS_ERROR; @@ -382,10 +382,10 @@ static int ldif_canonicalise_objectCategory(struct ldb_context *ldb, void *mem_c dn1 = ldb_dn_from_ldb_val(tmp_ctx, ldb, in); if ( ! ldb_dn_validate(dn1)) { const char *lDAPDisplayName = talloc_strndup(tmp_ctx, (char *)in->data, in->length); - class = dsdb_class_by_lDAPDisplayName(schema, lDAPDisplayName); - if (class) { + sclass = dsdb_class_by_lDAPDisplayName(schema, lDAPDisplayName); + if (sclass) { struct ldb_dn *dn = ldb_dn_new(mem_ctx, ldb, - class->defaultObjectCategory); + sclass->defaultObjectCategory); *out = data_blob_string_const(ldb_dn_alloc_casefold(mem_ctx, dn)); talloc_free(tmp_ctx); -- cgit From 62a3947d53aa38a2dab5ddf163d41a58a26bff14 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 11:26:20 +0100 Subject: s4:ldb_map: s/new/ntree metze --- source4/lib/ldb/ldb_map/ldb_map.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/lib/ldb/ldb_map/ldb_map.h b/source4/lib/ldb/ldb_map/ldb_map.h index 7f92c15b98..872208174e 100644 --- a/source4/lib/ldb/ldb_map/ldb_map.h +++ b/source4/lib/ldb/ldb_map/ldb_map.h @@ -67,7 +67,7 @@ struct ldb_map_attribute { } type; /* if set, will be called for search expressions that contain this attribute */ - int (*convert_operator)(struct ldb_module *, TALLOC_CTX *ctx, struct ldb_parse_tree **new, const struct ldb_parse_tree *); + int (*convert_operator)(struct ldb_module *, TALLOC_CTX *ctx, struct ldb_parse_tree **ntree, const struct ldb_parse_tree *otree); union { struct { -- cgit From 5e6e370c4ed44e2b13d0817f3c1c1c36efb74cba Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 11:28:19 +0100 Subject: lib/util: s/class/dclass metze --- lib/util/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/debug.c b/lib/util/debug.c index 98aabc554b..578822088f 100644 --- a/lib/util/debug.c +++ b/lib/util/debug.c @@ -102,7 +102,7 @@ _PUBLIC_ void dbghdr(int level, const char *location, const char *func) } -_PUBLIC_ void dbghdrclass(int level, int class, const char *location, const char *func) +_PUBLIC_ void dbghdrclass(int level, int dclass, const char *location, const char *func) { /* Simple wrapper, Samba 4 doesn't do debug classes */ dbghdr(level, location, func); -- cgit From 48a0721606b789a8b5086ae41b7208e753c415c9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 12:14:45 +0100 Subject: lib/util: s/new/pn in idtree.c metze --- lib/util/idtree.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/util/idtree.c b/lib/util/idtree.c index 193922973f..c8a8b6346a 100644 --- a/lib/util/idtree.c +++ b/lib/util/idtree.c @@ -92,10 +92,10 @@ static void free_layer(struct idr_context *idp, struct idr_layer *p) static int idr_pre_get(struct idr_context *idp) { while (idp->id_free_cnt < IDR_FREE_MAX) { - struct idr_layer *new = talloc_zero(idp, struct idr_layer); - if(new == NULL) + struct idr_layer *pn = talloc_zero(idp, struct idr_layer); + if(pn == NULL) return (0); - free_layer(idp, new); + free_layer(idp, pn); } return 1; } @@ -103,7 +103,7 @@ static int idr_pre_get(struct idr_context *idp) static int sub_alloc(struct idr_context *idp, void *ptr, int *starting_id) { int n, m, sh; - struct idr_layer *p, *new; + struct idr_layer *p, *pn; struct idr_layer *pa[MAX_LEVEL]; int l, id, oid; uint32_t bm; @@ -155,9 +155,9 @@ restart: * Create the layer below if it is missing. */ if (!p->ary[m]) { - if (!(new = alloc_layer(idp))) + if (!(pn = alloc_layer(idp))) return -1; - p->ary[m] = new; + p->ary[m] = pn; p->count++; } pa[l--] = p; @@ -188,7 +188,7 @@ restart: static int idr_get_new_above_int(struct idr_context *idp, void *ptr, int starting_id) { - struct idr_layer *p, *new; + struct idr_layer *p, *pn; int layers, v, id; idr_pre_get(idp); @@ -210,24 +210,24 @@ build_up: layers++; if (!p->count) continue; - if (!(new = alloc_layer(idp))) { + if (!(pn = alloc_layer(idp))) { /* * The allocation failed. If we built part of * the structure tear it down. */ - for (new = p; p && p != idp->top; new = p) { + for (pn = p; p && p != idp->top; pn = p) { p = p->ary[0]; - new->ary[0] = NULL; - new->bitmap = new->count = 0; - free_layer(idp, new); + pn->ary[0] = NULL; + pn->bitmap = pn->count = 0; + free_layer(idp, pn); } return -1; } - new->ary[0] = p; - new->count = 1; + pn->ary[0] = p; + pn->count = 1; if (p->bitmap == IDR_FULL) - set_bit(0, new->bitmap); - p = new; + set_bit(0, pn->bitmap); + p = pn; } idp->top = p; idp->layers = layers; -- cgit From aa9c6b58f52b79c644cb894cc25b41cecd79b226 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 12:15:17 +0100 Subject: s4:libnet: s/new/n metze --- source4/libnet/libnet_samdump.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source4/libnet/libnet_samdump.c b/source4/libnet/libnet_samdump.c index 21361f1eca..b35fef2c16 100644 --- a/source4/libnet/libnet_samdump.c +++ b/source4/libnet/libnet_samdump.c @@ -75,13 +75,13 @@ static NTSTATUS vampire_samdump_handle_secret(TALLOC_CTX *mem_ctx, { struct netr_DELTA_SECRET *secret = delta->delta_union.secret; const char *name = delta->delta_id_union.name; - struct samdump_secret *new = talloc(samdump_state, struct samdump_secret); + struct samdump_secret *n = talloc(samdump_state, struct samdump_secret); - new->name = talloc_strdup(new, name); - new->secret = data_blob_talloc(new, secret->current_cipher.cipher_data, secret->current_cipher.maxlen); - new->mtime = secret->current_cipher_set_time; + n->name = talloc_strdup(n, name); + n->secret = data_blob_talloc(n, secret->current_cipher.cipher_data, secret->current_cipher.maxlen); + n->mtime = secret->current_cipher_set_time; - DLIST_ADD(samdump_state->secrets, new); + DLIST_ADD(samdump_state->secrets, n); return NT_STATUS_OK; } @@ -93,12 +93,12 @@ static NTSTATUS vampire_samdump_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct netr_DELTA_TRUSTED_DOMAIN *trusted_domain = delta->delta_union.trusted_domain; struct dom_sid *dom_sid = delta->delta_id_union.sid; - struct samdump_trusted_domain *new = talloc(samdump_state, struct samdump_trusted_domain); + struct samdump_trusted_domain *n = talloc(samdump_state, struct samdump_trusted_domain); - new->name = talloc_strdup(new, trusted_domain->domain_name.string); - new->sid = talloc_steal(new, dom_sid); + n->name = talloc_strdup(n, trusted_domain->domain_name.string); + n->sid = talloc_steal(n, dom_sid); - DLIST_ADD(samdump_state->trusted_domains, new); + DLIST_ADD(samdump_state->trusted_domains, n); return NT_STATUS_OK; } -- cgit From 21571e64a9c338b8e0be092f01a99813674b9ed1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 12:25:14 +0100 Subject: s4:rpc_server/lsa: s/delete/del s/open/opn metze --- source4/rpc_server/lsa/dcesrv_lsa.c | 62 +++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c index 6507c75ae2..1f1f6afa6d 100644 --- a/source4/rpc_server/lsa/dcesrv_lsa.c +++ b/source4/rpc_server/lsa/dcesrv_lsa.c @@ -1260,28 +1260,28 @@ static NTSTATUS dcesrv_lsa_DeleteTrustedDomain(struct dcesrv_call_state *dce_cal struct lsa_DeleteTrustedDomain *r) { NTSTATUS status; - struct lsa_OpenTrustedDomain open; - struct lsa_DeleteObject delete; + struct lsa_OpenTrustedDomain opn; + struct lsa_DeleteObject del; struct dcesrv_handle *h; - open.in.handle = r->in.handle; - open.in.sid = r->in.dom_sid; - open.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - open.out.trustdom_handle = talloc(mem_ctx, struct policy_handle); - if (!open.out.trustdom_handle) { + opn.in.handle = r->in.handle; + opn.in.sid = r->in.dom_sid; + opn.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + opn.out.trustdom_handle = talloc(mem_ctx, struct policy_handle); + if (!opn.out.trustdom_handle) { return NT_STATUS_NO_MEMORY; } - status = dcesrv_lsa_OpenTrustedDomain(dce_call, mem_ctx, &open); + status = dcesrv_lsa_OpenTrustedDomain(dce_call, mem_ctx, &opn); if (!NT_STATUS_IS_OK(status)) { return status; } - DCESRV_PULL_HANDLE(h, open.out.trustdom_handle, DCESRV_HANDLE_ANY); + DCESRV_PULL_HANDLE(h, opn.out.trustdom_handle, DCESRV_HANDLE_ANY); talloc_steal(mem_ctx, h); - delete.in.handle = open.out.trustdom_handle; - delete.out.handle = open.out.trustdom_handle; - status = dcesrv_lsa_DeleteObject(dce_call, mem_ctx, &delete); + del.in.handle = opn.out.trustdom_handle; + del.out.handle = opn.out.trustdom_handle; + status = dcesrv_lsa_DeleteObject(dce_call, mem_ctx, &del); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -1407,26 +1407,27 @@ static NTSTATUS dcesrv_lsa_QueryTrustedDomainInfoBySid(struct dcesrv_call_state struct lsa_QueryTrustedDomainInfoBySid *r) { NTSTATUS status; - struct lsa_OpenTrustedDomain open; + struct lsa_OpenTrustedDomain opn; struct lsa_QueryTrustedDomainInfo query; struct dcesrv_handle *h; - open.in.handle = r->in.handle; - open.in.sid = r->in.dom_sid; - open.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - open.out.trustdom_handle = talloc(mem_ctx, struct policy_handle); - if (!open.out.trustdom_handle) { + + opn.in.handle = r->in.handle; + opn.in.sid = r->in.dom_sid; + opn.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + opn.out.trustdom_handle = talloc(mem_ctx, struct policy_handle); + if (!opn.out.trustdom_handle) { return NT_STATUS_NO_MEMORY; } - status = dcesrv_lsa_OpenTrustedDomain(dce_call, mem_ctx, &open); + status = dcesrv_lsa_OpenTrustedDomain(dce_call, mem_ctx, &opn); if (!NT_STATUS_IS_OK(status)) { return status; } /* Ensure this handle goes away at the end of this call */ - DCESRV_PULL_HANDLE(h, open.out.trustdom_handle, DCESRV_HANDLE_ANY); + DCESRV_PULL_HANDLE(h, opn.out.trustdom_handle, DCESRV_HANDLE_ANY); talloc_steal(mem_ctx, h); - query.in.trustdom_handle = open.out.trustdom_handle; + query.in.trustdom_handle = opn.out.trustdom_handle; query.in.level = r->in.level; query.out.info = r->out.info; status = dcesrv_lsa_QueryTrustedDomainInfo(dce_call, mem_ctx, &query); @@ -1455,26 +1456,27 @@ static NTSTATUS dcesrv_lsa_QueryTrustedDomainInfoByName(struct dcesrv_call_state struct lsa_QueryTrustedDomainInfoByName *r) { NTSTATUS status; - struct lsa_OpenTrustedDomainByName open; + struct lsa_OpenTrustedDomainByName opn; struct lsa_QueryTrustedDomainInfo query; struct dcesrv_handle *h; - open.in.handle = r->in.handle; - open.in.name = *r->in.trusted_domain; - open.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - open.out.trustdom_handle = talloc(mem_ctx, struct policy_handle); - if (!open.out.trustdom_handle) { + + opn.in.handle = r->in.handle; + opn.in.name = *r->in.trusted_domain; + opn.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + opn.out.trustdom_handle = talloc(mem_ctx, struct policy_handle); + if (!opn.out.trustdom_handle) { return NT_STATUS_NO_MEMORY; } - status = dcesrv_lsa_OpenTrustedDomainByName(dce_call, mem_ctx, &open); + status = dcesrv_lsa_OpenTrustedDomainByName(dce_call, mem_ctx, &opn); if (!NT_STATUS_IS_OK(status)) { return status; } /* Ensure this handle goes away at the end of this call */ - DCESRV_PULL_HANDLE(h, open.out.trustdom_handle, DCESRV_HANDLE_ANY); + DCESRV_PULL_HANDLE(h, opn.out.trustdom_handle, DCESRV_HANDLE_ANY); talloc_steal(mem_ctx, h); - query.in.trustdom_handle = open.out.trustdom_handle; + query.in.trustdom_handle = opn.out.trustdom_handle; query.in.level = r->in.level; query.out.info = r->out.info; status = dcesrv_lsa_QueryTrustedDomainInfo(dce_call, mem_ctx, &query); -- cgit From 8249a467e365d7dc5eb52fd4c1315870405debb4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 12:59:28 +0100 Subject: lib/tevent: s/private/private_data metze --- lib/tevent/testsuite.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/tevent/testsuite.c b/lib/tevent/testsuite.c index 1b811f5fa2..faa18577a7 100644 --- a/lib/tevent/testsuite.c +++ b/lib/tevent/testsuite.c @@ -27,9 +27,9 @@ static int fde_count; static void fde_handler(struct tevent_context *ev_ctx, struct tevent_fd *f, - uint16_t flags, void *private) + uint16_t flags, void *private_data) { - int *fd = (int *)private; + int *fd = (int *)private_data; char c; #ifdef SA_SIGINFO kill(getpid(), SIGUSR1); @@ -41,16 +41,16 @@ static void fde_handler(struct tevent_context *ev_ctx, struct tevent_fd *f, } static void finished_handler(struct tevent_context *ev_ctx, struct tevent_timer *te, - struct timeval tval, void *private) + struct timeval tval, void *private_data) { - int *finished = (int *)private; + int *finished = (int *)private_data; (*finished) = 1; } static void count_handler(struct tevent_context *ev_ctx, struct signal_event *te, - int signum, int count, void *info, void *private) + int signum, int count, void *info, void *private_data) { - int *countp = (int *)private; + int *countp = (int *)private_data; (*countp) += count; } -- cgit From 0c3bc60a01a3353557abe42f6a689c54b9369e7f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 13:00:02 +0100 Subject: s4:lib/registry: s/new/nkey metze --- source4/lib/registry/tools/regshell.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 8939f21269..0fc06d1219 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -159,12 +159,12 @@ static WERROR cmd_set(struct regshell_context *ctx, int argc, char **argv) static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv) { - struct registry_key *new = NULL; + struct registry_key *nkey = NULL; WERROR error; if(argc == 2) { error = reg_open_key(ctx->registry, ctx->current, argv[1], - &new); + &nkey); if(!W_ERROR_IS_OK(error)) { DEBUG(0, ("Error opening specified key: %s\n", win_errstr(error))); @@ -172,7 +172,7 @@ static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv) } ctx->path = talloc_asprintf(ctx, "%s\\%s", ctx->path, argv[1]); - ctx->current = new; + ctx->current = nkey; } printf("New path is: %s\n", ctx->path); -- cgit From b4af7074b789b434f083a89a70c7cf7f8e43f4d4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 13:00:47 +0100 Subject: s4:py_security: avoid 'this' and use 'py_self' and 'self' metze --- source4/librpc/ndr/py_security.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source4/librpc/ndr/py_security.c b/source4/librpc/ndr/py_security.c index 93e4a093f3..f89263bba3 100644 --- a/source4/librpc/ndr/py_security.c +++ b/source4/librpc/ndr/py_security.c @@ -41,29 +41,29 @@ static void PyType_AddMethods(PyTypeObject *type, PyMethodDef *methods) } } -static int py_dom_sid_cmp(PyObject *self, PyObject *py_other) +static int py_dom_sid_cmp(PyObject *py_self, PyObject *py_other) { - struct dom_sid *this = py_talloc_get_ptr(self), *other; + struct dom_sid *self = py_talloc_get_ptr(py_self), *other; other = py_talloc_get_ptr(py_other); if (other == NULL) return -1; - return dom_sid_compare(this, other); + return dom_sid_compare(self, other); } -static PyObject *py_dom_sid_str(PyObject *self) +static PyObject *py_dom_sid_str(PyObject *py_self) { - struct dom_sid *this = py_talloc_get_ptr(self); - char *str = dom_sid_string(NULL, this); + struct dom_sid *self = py_talloc_get_ptr(py_self); + char *str = dom_sid_string(NULL, self); PyObject *ret = PyString_FromString(str); talloc_free(str); return ret; } -static PyObject *py_dom_sid_repr(PyObject *self) +static PyObject *py_dom_sid_repr(PyObject *py_self) { - struct dom_sid *this = py_talloc_get_ptr(self); - char *str = dom_sid_string(NULL, this); + struct dom_sid *self = py_talloc_get_ptr(py_self); + char *str = dom_sid_string(NULL, self); PyObject *ret = PyString_FromFormat("dom_sid('%s')", str); talloc_free(str); return ret; -- cgit From 03ed70c9f3485e99b7a9574f076c98a631a358bf Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 13:01:45 +0100 Subject: s4:torture/nbench: don't use 'new' metze --- source4/torture/nbench/nbio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source4/torture/nbench/nbio.c b/source4/torture/nbench/nbio.c index fa5fe5d2d6..bf594088cd 100644 --- a/source4/torture/nbench/nbio.c +++ b/source4/torture/nbench/nbio.c @@ -802,15 +802,15 @@ bool nb_mkdir(const char *dname, NTSTATUS status, bool retry) return true; } -bool nb_rename(const char *old, const char *new, NTSTATUS status, bool retry) +bool nb_rename(const char *o, const char *n, NTSTATUS status, bool retry) { NTSTATUS ret; union smb_rename io; io.generic.level = RAW_RENAME_RENAME; io.rename.in.attrib = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY; - io.rename.in.pattern1 = old; - io.rename.in.pattern2 = new; + io.rename.in.pattern1 = o; + io.rename.in.pattern2 = n; ret = smb_raw_rename(c->tree, &io); -- cgit From 3131ca2340dcdb43257fe9a75c749c93f6931948 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 13:03:00 +0100 Subject: s4:torture/rpc: avoid 'new' in samsync.c metze --- source4/torture/rpc/samsync.c | 44 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/source4/torture/rpc/samsync.c b/source4/torture/rpc/samsync.c index a3fc6f740f..00798214f3 100644 --- a/source4/torture/rpc/samsync.c +++ b/source4/torture/rpc/samsync.c @@ -830,14 +830,14 @@ static bool samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam { struct netr_DELTA_SECRET *secret = delta->delta_union.secret; const char *name = delta->delta_id_union.name; - struct samsync_secret *new = talloc(samsync_state, struct samsync_secret); + struct samsync_secret *nsec = talloc(samsync_state, struct samsync_secret); struct samsync_secret *old = talloc(mem_ctx, struct samsync_secret); struct lsa_QuerySecret q; struct lsa_OpenSecret o; struct policy_handle sec_handle; struct lsa_DATA_BUF_PTR bufp1; struct lsa_DATA_BUF_PTR bufp2; - NTTIME new_mtime; + NTTIME nsec_mtime; NTTIME old_mtime; bool ret = true; DATA_BLOB lsa_blob1, lsa_blob_out, session_key; @@ -849,12 +849,12 @@ static bool samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam creds_arcfour_crypt(samsync_state->creds, secret->old_cipher.cipher_data, secret->old_cipher.maxlen); - new->name = talloc_reference(new, name); - new->secret = data_blob_talloc(new, secret->current_cipher.cipher_data, secret->current_cipher.maxlen); - new->mtime = secret->current_cipher_set_time; + nsec->name = talloc_reference(nsec, name); + nsec->secret = data_blob_talloc(nsec, secret->current_cipher.cipher_data, secret->current_cipher.maxlen); + nsec->mtime = secret->current_cipher_set_time; - new = talloc_reference(samsync_state, new); - DLIST_ADD(samsync_state->secrets, new); + nsec = talloc_reference(samsync_state, nsec); + DLIST_ADD(samsync_state->secrets, nsec); old->name = talloc_reference(old, name); old->secret = data_blob_const(secret->old_cipher.cipher_data, secret->old_cipher.maxlen); @@ -882,13 +882,13 @@ static bool samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam } - ZERO_STRUCT(new_mtime); + ZERO_STRUCT(nsec_mtime); ZERO_STRUCT(old_mtime); /* fetch the secret back again */ q.in.sec_handle = &sec_handle; q.in.new_val = &bufp1; - q.in.new_mtime = &new_mtime; + q.in.new_mtime = &nsec_mtime; q.in.old_val = &bufp2; q.in.old_mtime = &old_mtime; @@ -957,26 +957,26 @@ static bool samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam } if (!q.out.new_mtime) { - printf("NEW mtime not available on LSA for secret %s\n", new->name); + printf("NEW mtime not available on LSA for secret %s\n", nsec->name); ret = false; } - if (new->mtime != *q.out.new_mtime) { + if (nsec->mtime != *q.out.new_mtime) { printf("NEW mtime on secret %s does not match between SAMSYNC (%s) and LSA (%s)\n", - new->name, nt_time_string(mem_ctx, new->mtime), + nsec->name, nt_time_string(mem_ctx, nsec->mtime), nt_time_string(mem_ctx, *q.out.new_mtime)); ret = false; } - if (new->secret.length != lsa_blob_out.length) { + if (nsec->secret.length != lsa_blob_out.length) { printf("Returned secret %s doesn't match: %d != %d\n", - new->name, (int)new->secret.length, (int)lsa_blob_out.length); + nsec->name, (int)nsec->secret.length, (int)lsa_blob_out.length); ret = false; } else if (memcmp(lsa_blob_out.data, - new->secret.data, new->secret.length) != 0) { + nsec->secret.data, nsec->secret.length) != 0) { printf("Returned secret %s doesn't match: \n", - new->name); + nsec->name); DEBUG(1, ("SamSync Secret:\n")); - dump_data(1, new->secret.data, new->secret.length); + dump_data(1, nsec->secret.data, nsec->secret.length); DEBUG(1, ("LSA Secret:\n")); dump_data(1, lsa_blob_out.data, lsa_blob_out.length); ret = false; @@ -994,7 +994,7 @@ static bool samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_st struct netr_DELTA_TRUSTED_DOMAIN *trusted_domain = delta->delta_union.trusted_domain; struct dom_sid *dom_sid = delta->delta_id_union.sid; - struct samsync_trusted_domain *new = talloc(samsync_state, struct samsync_trusted_domain); + struct samsync_trusted_domain *ndom = talloc(samsync_state, struct samsync_trusted_domain); struct lsa_OpenTrustedDomain t; struct policy_handle trustdom_handle; struct lsa_QueryTrustedDomainInfo q; @@ -1003,8 +1003,8 @@ static bool samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_st int levels [] = {1, 3, 8}; int i; - new->name = talloc_reference(new, trusted_domain->domain_name.string); - new->sid = talloc_reference(new, dom_sid); + ndom->name = talloc_reference(ndom, trusted_domain->domain_name.string); + ndom->sid = talloc_reference(ndom, dom_sid); t.in.handle = samsync_state->lsa_handle; t.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -1044,8 +1044,8 @@ static bool samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_st We would like to do this, but it is NOT_SUPPORTED on win2k3 TEST_SEC_DESC_EQUAL(trusted_domain->sdbuf, lsa, &trustdom_handle); */ - new = talloc_reference(samsync_state, new); - DLIST_ADD(samsync_state->trusted_domains, new); + ndom = talloc_reference(samsync_state, ndom); + DLIST_ADD(samsync_state->trusted_domains, ndom); return ret; } -- cgit From fb5346f3bbbde389295bb56de3ab97df50ddc2ee Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 13:03:36 +0100 Subject: s4:torture/util_smb: s/class/classnum metze --- source4/torture/util_smb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c index 732b84af73..1c50694279 100644 --- a/source4/torture/util_smb.c +++ b/source4/torture/util_smb.c @@ -583,10 +583,10 @@ _PUBLIC_ bool check_error(const char *location, struct smbcli_state *c, status = smbcli_nt_error(c->tree); if (NT_STATUS_IS_DOS(status)) { - int class, num; - class = NT_STATUS_DOS_CLASS(status); + int classnum, num; + classnum = NT_STATUS_DOS_CLASS(status); num = NT_STATUS_DOS_CODE(status); - if (eclass != class || ecode != num) { + if (eclass != classnum || ecode != num) { printf("unexpected error code %s\n", nt_errstr(status)); printf(" expected %s or %s (at %s)\n", nt_errstr(NT_STATUS_DOS(eclass, ecode)), -- cgit From 900a5a6f87d37c1a8cd6bfdc7c24a8d87a83ea48 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 13:04:06 +0100 Subject: s4:torture/rpc: s/class/kclass in winreg.c metze --- source4/torture/rpc/winreg.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c index b544e74181..b85dac7bf1 100644 --- a/source4/torture/rpc/winreg.c +++ b/source4/torture/rpc/winreg.c @@ -104,7 +104,7 @@ static bool test_NotifyChangeKeyValue(struct dcerpc_pipe *p, static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx, struct policy_handle *handle, const char *name, - const char *class) + const char *kclass) { struct winreg_CreateKey r; struct policy_handle newhandle; @@ -114,7 +114,7 @@ static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx, r.in.handle = handle; r.out.new_handle = &newhandle; init_winreg_String(&r.in.name, name); - init_winreg_String(&r.in.keyclass, class); + init_winreg_String(&r.in.keyclass, kclass); r.in.options = 0x0; r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; r.in.action_taken = r.out.action_taken = &action_taken; @@ -135,7 +135,7 @@ static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx, static bool test_CreateKey_sd(struct dcerpc_pipe *p, struct torture_context *tctx, struct policy_handle *handle, const char *name, - const char *class, + const char *kclass, struct policy_handle *newhandle) { struct winreg_CreateKey r; @@ -169,7 +169,7 @@ static bool test_CreateKey_sd(struct dcerpc_pipe *p, r.in.handle = handle; r.out.new_handle = newhandle; init_winreg_String(&r.in.name, name); - init_winreg_String(&r.in.keyclass, class); + init_winreg_String(&r.in.keyclass, kclass); r.in.options = 0x0; r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; r.in.action_taken = r.out.action_taken = &action_taken; @@ -1393,7 +1393,7 @@ static bool test_DeleteKey(struct dcerpc_pipe *p, struct torture_context *tctx, static bool test_QueryInfoKey(struct dcerpc_pipe *p, struct torture_context *tctx, - struct policy_handle *handle, char *class) + struct policy_handle *handle, char *kclass) { struct winreg_QueryInfoKey r; uint32_t num_subkeys, max_subkeylen, max_classlen, @@ -1415,7 +1415,7 @@ static bool test_QueryInfoKey(struct dcerpc_pipe *p, r.out.classname = talloc(tctx, struct winreg_String); r.in.classname = talloc(tctx, struct winreg_String); - init_winreg_String(r.in.classname, class); + init_winreg_String(r.in.classname, kclass); torture_assert_ntstatus_ok(tctx, dcerpc_winreg_QueryInfoKey(p, tctx, &r), @@ -1435,18 +1435,18 @@ static bool test_EnumKey(struct dcerpc_pipe *p, struct torture_context *tctx, bool test_security) { struct winreg_EnumKey r; - struct winreg_StringBuf class, name; + struct winreg_StringBuf kclass, name; NTSTATUS status; NTTIME t = 0; - class.name = ""; - class.size = 1024; + kclass.name = ""; + kclass.size = 1024; ZERO_STRUCT(r); r.in.handle = handle; r.in.enum_index = 0; r.in.name = &name; - r.in.keyclass = &class; + r.in.keyclass = &kclass; r.out.name = &name; r.in.last_changed_time = &t; -- cgit From 4bbfdb2ded3b34fe001757c67d6ca617ea781d2e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 13:04:40 +0100 Subject: s4:torture/rpc: avoid 'delete' and 'class' in samba3rpc.c metze --- source4/torture/rpc/samba3rpc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index a1e52ba80e..5b493db813 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -1867,7 +1867,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) d_printf("(%s) whoami on user connection failed\n", __location__); ret = false; - goto delete; + goto del; } talloc_free(tree); @@ -1881,7 +1881,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture) ret = false; } - delete: + del: if (!delete_user(cli, torture->lp_ctx, cmdline_credentials, cli_credentials_get_username(user_creds))) { @@ -3050,7 +3050,7 @@ static NTSTATUS enumkeys(struct dcerpc_pipe *p, struct policy_handle *handle, TALLOC_CTX *mem_ctx, int depth) { struct winreg_EnumKey r; - struct winreg_StringBuf class, name; + struct winreg_StringBuf kclass, name; NTSTATUS status; NTTIME t = 0; @@ -3058,13 +3058,13 @@ static NTSTATUS enumkeys(struct dcerpc_pipe *p, struct policy_handle *handle, return NT_STATUS_OK; } - class.name = ""; - class.size = 1024; + kclass.name = ""; + kclass.size = 1024; r.in.handle = handle; r.in.enum_index = 0; r.in.name = &name; - r.in.keyclass = &class; + r.in.keyclass = &kclass; r.out.name = &name; r.in.last_changed_time = &t; -- cgit From bab629426958907e675765ce0620f321dcc5f780 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 08:52:44 +0100 Subject: s4:includes: copy #error DONT_USE_CPLUSPLUS_RESERVED_NAMES from source3 We should not use c++ reserved names in source4 too. metze --- source4/include/includes.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source4/include/includes.h b/source4/include/includes.h index c1c565118d..d9b7759e7e 100644 --- a/source4/include/includes.h +++ b/source4/include/includes.h @@ -33,6 +33,22 @@ #include "system/time.h" #include "system/wait.h" +/* only do the C++ reserved word check when we compile + to include --with-developer since too many systems + still have comflicts with their header files (e.g. IRIX 6.4) */ + +#if !defined(__cplusplus) && defined(DEVELOPER) +#define class #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define private #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define public #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define protected #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define template #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define this #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define new #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define delete #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#define friend #error DONT_USE_CPLUSPLUS_RESERVED_NAMES +#endif + /* Lists, trees, caching, database... */ #include #ifndef _PRINTF_ATTRIBUTE -- cgit From 016598717b60c9c8731739789a394ddaecdb90eb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 12:43:20 +0100 Subject: selftest: remove source4 specific stuff from selftest.pl metze --- selftest/selftest.pl | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/selftest/selftest.pl b/selftest/selftest.pl index d4fd57e494..f6561cc8c7 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -365,7 +365,8 @@ unless (defined($ENV{VALGRIND})) { $ENV{MALLOC_CHECK_} = 2; } -my $old_pwd = "$RealBin/.."; +my $bindir = ($opt_bindir or "$builddir/bin"); +my $bindir_abs = abs_path($bindir); # Backwards compatibility: if (defined($ENV{TEST_LDAP}) and $ENV{TEST_LDAP} eq "yes") { @@ -410,8 +411,8 @@ if (defined($ENV{RUN_FROM_BUILD_FARM}) and my $tls_enabled = not $opt_quick; $ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no"); -$ENV{LDB_MODULES_PATH} = "$old_pwd/source4/bin/modules/ldb"; -$ENV{LD_SAMBA_MODULE_PATH} = "$old_pwd/source4/bin/modules"; +$ENV{LDB_MODULES_PATH} = "$bindir_abs/modules/ldb"; +$ENV{LD_SAMBA_MODULE_PATH} = "$bindir_abs/modules"; sub prefix_pathvar($$) { my ($name, $newpath) = @_; @@ -421,8 +422,8 @@ sub prefix_pathvar($$) $ENV{$name} = $newpath; } } -prefix_pathvar("PKG_CONFIG_PATH", "$old_pwd/source4/bin/pkgconfig"); -prefix_pathvar("PYTHONPATH", "$old_pwd/source4/bin/python"); +prefix_pathvar("PKG_CONFIG_PATH", "$bindir_abs/pkgconfig"); +prefix_pathvar("PYTHONPATH", "$bindir_abs/python"); if ($opt_socket_wrapper_keep_pcap) { # Socket wrapper keep pcap implies socket wrapper pcap @@ -450,10 +451,8 @@ my $testenv_default = "none"; if ($opt_target eq "samba4") { $testenv_default = "member"; require target::Samba4; - $target = new Samba4($opt_bindir or "$builddir/bin", - $ldap, "$srcdir/setup", $exeext); + $target = new Samba4($bindir, $ldap, "$srcdir/setup", $exeext); } elsif ($opt_target eq "samba3") { - my $bindir = ($opt_bindir or "$builddir/bin"); if ($opt_socket_wrapper and `$bindir/smbd -b | grep SOCKET_WRAPPER` eq "") { die("You must include --enable-socket-wrapper when compiling Samba in order to execute 'make test'. Exiting...."); } -- cgit From 6f8c0349eb745b8ef6400145a30ade2f44597acb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 2 Feb 2009 14:01:52 +0100 Subject: s3:build: fix linking of bin/net when shared libs have been disabled Michael --- source3/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/Makefile.in b/source3/Makefile.in index bc306229c8..9147c5289f 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -913,7 +913,7 @@ NET_OBJ = $(NET_OBJ1) \ $(REG_SMBCONF_OBJ) @LIBNETAPI_STATIC@ $(LIBNET_OBJ) \ $(LIBSMBCONF_OBJ) \ @LIBWBCLIENT_STATIC@ \ - $(PRIVILEGES_BASIC_OBJ) + $(PRIVILEGES_BASIC_OBJ) @LIBLUA_LIBS@ CUPS_OBJ = client/smbspool.o $(PARAM_OBJ) $(LIBSMB_OBJ) \ $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) \ -- cgit From 4934744962cf74d67c568387b1cad3a5db6b2a77 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 2 Feb 2009 14:05:28 +0100 Subject: s3:build: fix typo introduced in "fix build without shared libs" Michael --- source3/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/Makefile.in b/source3/Makefile.in index 9147c5289f..5d15e0fcca 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -913,7 +913,7 @@ NET_OBJ = $(NET_OBJ1) \ $(REG_SMBCONF_OBJ) @LIBNETAPI_STATIC@ $(LIBNET_OBJ) \ $(LIBSMBCONF_OBJ) \ @LIBWBCLIENT_STATIC@ \ - $(PRIVILEGES_BASIC_OBJ) @LIBLUA_LIBS@ + $(PRIVILEGES_BASIC_OBJ) @LIBLUA_STATIC@ CUPS_OBJ = client/smbspool.o $(PARAM_OBJ) $(LIBSMB_OBJ) \ $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) \ -- cgit From 662e05f7a92310c3e7913af06ef2e03fa593ecc2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 14:38:05 +0100 Subject: lib/tdb: the python bindings don't use swig anymore metze --- lib/tdb/python.mk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/tdb/python.mk b/lib/tdb/python.mk index a4e6037993..1f2d4ca4a8 100644 --- a/lib/tdb/python.mk +++ b/lib/tdb/python.mk @@ -1,8 +1,6 @@ -[PYTHON::swig_tdb] +[PYTHON::pytdb] LIBRARY_REALNAME = tdb.$(SHLIBEXT) PUBLIC_DEPENDENCIES = LIBTDB DYNCONFIG -swig_tdb_OBJ_FILES = $(tdbsrcdir)/pytdb.o - -$(swig_tdb_OBJ_FILES): CFLAGS+=$(CFLAG_NO_CAST_QUAL) +pytdb_OBJ_FILES = $(tdbsrcdir)/pytdb.o -- cgit From 886df1ac86a025e6af06205872cf4b7d43c2b202 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 14:40:48 +0100 Subject: lib/tevent: the python bindings don't use swig anymore metze --- lib/tevent/python.mk | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/tevent/python.mk b/lib/tevent/python.mk index abc60fa2ce..0c1beca675 100644 --- a/lib/tevent/python.mk +++ b/lib/tevent/python.mk @@ -1,10 +1,5 @@ -# TODO: Change python stuff to tevent -[PYTHON::swig_events] +[PYTHON::pytevent] LIBRARY_REALNAME = tevent.$(SHLIBEXT) PRIVATE_DEPENDENCIES = LIBTEVENT PYTALLOC LIBSAMBA-UTIL LIBREPLACE -swig_events_OBJ_FILES = $(libteventsrcdir)/pytevent.o - -$(swig_events_OBJ_FILES): CFLAGS+=$(CFLAG_NO_CAST_QUAL) - -PC_FILES += $(libteventsrcdir)/tevent.pc +pytevent_OBJ_FILES = $(libteventsrcdir)/pytevent.o -- cgit From 426dc44c5cff7ee2b6ba02f3fc7967a71a51cdd9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 14:48:08 +0100 Subject: s4:auth: the python bindings don't use swig anymore metze --- source4/auth/config.mk | 5 ++--- source4/scripting/python/config.mk | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/source4/auth/config.mk b/source4/auth/config.mk index b238caa2e5..baf4346b4a 100644 --- a/source4/auth/config.mk +++ b/source4/auth/config.mk @@ -36,11 +36,10 @@ auth_sam_reply_OBJ_FILES = $(addprefix $(authsrcdir)/, auth_sam_reply.o) $(eval $(call proto_header_template,$(authsrcdir)/auth_sam_reply.h,$(auth_sam_reply_OBJ_FILES:.o=.c))) -[PYTHON::swig_auth] +[PYTHON::pyauth] LIBRARY_REALNAME = samba/auth.$(SHLIBEXT) PUBLIC_DEPENDENCIES = auth_system_session PRIVATE_DEPENDENCIES = SAMDB PYTALLOC param -swig_auth_OBJ_FILES = $(authsrcdir)/pyauth.o +pyauth_OBJ_FILES = $(authsrcdir)/pyauth.o -$(swig_auth_OBJ_FILES): CFLAGS+=$(CFLAG_NO_CAST_QUAL) diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index 4d33ed2219..a5d8e40b0d 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -17,7 +17,7 @@ python_uuid_OBJ_FILES = $(pyscriptsrcdir)/uuidmodule.o [PYTHON::python_glue] LIBRARY_REALNAME = samba/glue.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS pyldb python_dcerpc_misc python_dcerpc_security swig_auth +PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS pyldb python_dcerpc_misc python_dcerpc_security pyauth python_glue_OBJ_FILES = $(pyscriptsrcdir)/pyglue.o -- cgit From eb012dd212c85b9a4833b3b062cd6ba89cc0a441 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 14:54:35 +0100 Subject: s4:auth/credentials: the python bindings don't use swig anymore metze --- source4/auth/credentials/config.mk | 6 ++---- source4/lib/registry/config.mk | 2 +- source4/librpc/config.mk | 32 ++++++++++++++++---------------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/source4/auth/credentials/config.mk b/source4/auth/credentials/config.mk index e4d14dde58..2402c732b3 100644 --- a/source4/auth/credentials/config.mk +++ b/source4/auth/credentials/config.mk @@ -13,10 +13,8 @@ $(eval $(call proto_header_template,$(authsrcdir)/credentials/credentials_proto. PUBLIC_HEADERS += $(authsrcdir)/credentials/credentials.h -[PYTHON::swig_credentials] +[PYTHON::pycredentials] LIBRARY_REALNAME = samba/credentials.$(SHLIBEXT) PUBLIC_DEPENDENCIES = CREDENTIALS LIBCMDLINE_CREDENTIALS PYTALLOC param -swig_credentials_OBJ_FILES = $(authsrcdir)/credentials/pycredentials.o - -$(swig_credentials_OBJ_FILES): CFLAGS+=$(CFLAG_NO_CAST_QUAL) +pycredentials_OBJ_FILES = $(authsrcdir)/credentials/pycredentials.o diff --git a/source4/lib/registry/config.mk b/source4/lib/registry/config.mk index 6528127b0b..a566042cf2 100644 --- a/source4/lib/registry/config.mk +++ b/source4/lib/registry/config.mk @@ -105,6 +105,6 @@ $(eval $(call proto_header_template,$(libregistrysrcdir)/tests/proto.h,$(torture [PYTHON::py_registry] LIBRARY_REALNAME = samba/registry.$(SHLIBEXT) -PUBLIC_DEPENDENCIES = registry PYTALLOC swig_credentials param +PUBLIC_DEPENDENCIES = registry PYTALLOC pycredentials param py_registry_OBJ_FILES = $(libregistrysrcdir)/pyregistry.o diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk index 5bbdfaf4d8..2f276886e9 100644 --- a/source4/librpc/config.mk +++ b/source4/librpc/config.mk @@ -633,7 +633,7 @@ PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, rpc/dcerpc.h) \ [PYTHON::python_dcerpc] LIBRARY_REALNAME = samba/dcerpc/base.$(SHLIBEXT) -PUBLIC_DEPENDENCIES = LIBCLI_SMB LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG dcerpc_samr RPC_NDR_LSA DYNCONFIG swig_credentials param +PUBLIC_DEPENDENCIES = LIBCLI_SMB LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG dcerpc_samr RPC_NDR_LSA DYNCONFIG pycredentials param python_dcerpc_OBJ_FILES = $(dcerpcsrcdir)/pyrpc.o @@ -642,13 +642,13 @@ $(eval $(call python_py_module_template,samba/dcerpc/__init__.py,$(dcerpcsrcdir) [PYTHON::python_echo] LIBRARY_REALNAME = samba/dcerpc/echo.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_ECHO PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_ECHO PYTALLOC param pycredentials python_dcerpc python_echo_OBJ_FILES = ../librpc/gen_ndr/py_echo.o [PYTHON::python_winreg] LIBRARY_REALNAME = samba/dcerpc/winreg.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_WINREG PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_WINREG PYTALLOC param pycredentials python_dcerpc python_winreg_OBJ_FILES = ../librpc/gen_ndr/py_winreg.o @@ -660,79 +660,79 @@ python_dcerpc_misc_OBJ_FILES = ../librpc/gen_ndr/py_misc.o [PYTHON::python_initshutdown] LIBRARY_REALNAME = samba/dcerpc/initshutdown.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_INITSHUTDOWN PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_INITSHUTDOWN PYTALLOC param pycredentials python_dcerpc python_initshutdown_OBJ_FILES = ../librpc/gen_ndr/py_initshutdown.o [PYTHON::python_epmapper] LIBRARY_REALNAME = samba/dcerpc/epmapper.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = dcerpc PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = dcerpc PYTALLOC param pycredentials python_dcerpc python_epmapper_OBJ_FILES = ../librpc/gen_ndr/py_epmapper.o [PYTHON::python_mgmt] LIBRARY_REALNAME = samba/dcerpc/mgmt.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = PYTALLOC param swig_credentials dcerpc python_dcerpc +PRIVATE_DEPENDENCIES = PYTALLOC param pycredentials dcerpc python_dcerpc python_mgmt_OBJ_FILES = ../librpc/gen_ndr/py_mgmt.o [PYTHON::python_atsvc] LIBRARY_REALNAME = samba/dcerpc/atsvc.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = dcerpc_atsvc PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = dcerpc_atsvc PYTALLOC param pycredentials python_dcerpc python_atsvc_OBJ_FILES = ../librpc/gen_ndr/py_atsvc.o [PYTHON::python_dcerpc_nbt] LIBRARY_REALNAME = samba/dcerpc/nbt.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = NDR_NBT PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = NDR_NBT PYTALLOC param pycredentials python_dcerpc python_dcerpc_nbt_OBJ_FILES = ../librpc/gen_ndr/py_nbt.o [PYTHON::python_samr] LIBRARY_REALNAME = samba/dcerpc/samr.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = dcerpc_samr PYTALLOC swig_credentials param python_dcerpc +PRIVATE_DEPENDENCIES = dcerpc_samr PYTALLOC pycredentials param python_dcerpc python_samr_OBJ_FILES = ../librpc/gen_ndr/py_samr.o [PYTHON::python_svcctl] LIBRARY_REALNAME = samba/dcerpc/svcctl.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_SVCCTL PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_SVCCTL PYTALLOC param pycredentials python_dcerpc python_svcctl_OBJ_FILES = ../librpc/gen_ndr/py_svcctl.o [PYTHON::python_lsa] LIBRARY_REALNAME = samba/dcerpc/lsa.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_LSA PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_LSA PYTALLOC param pycredentials python_dcerpc python_lsa_OBJ_FILES = ../librpc/gen_ndr/py_lsa.o [PYTHON::python_wkssvc] LIBRARY_REALNAME = samba/dcerpc/wkssvc.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_WKSSVC PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_WKSSVC PYTALLOC param pycredentials python_dcerpc python_wkssvc_OBJ_FILES = ../librpc/gen_ndr/py_wkssvc.o [PYTHON::python_dfs] LIBRARY_REALNAME = samba/dcerpc/dfs.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_DFS PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_DFS PYTALLOC param pycredentials python_dcerpc python_dfs_OBJ_FILES = ../librpc/gen_ndr/py_dfs.o [PYTHON::python_unixinfo] LIBRARY_REALNAME = samba/dcerpc/unixinfo.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_UNIXINFO PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_UNIXINFO PYTALLOC param pycredentials python_dcerpc python_unixinfo_OBJ_FILES = ../librpc/gen_ndr/py_unixinfo.o [PYTHON::python_irpc] LIBRARY_REALNAME = samba/dcerpc/irpc.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_IRPC PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_IRPC PYTALLOC param pycredentials python_dcerpc python_irpc_OBJ_FILES = $(gen_ndrsrcdir)/py_irpc.o [PYTHON::python_drsuapi] LIBRARY_REALNAME = samba/dcerpc/drsuapi.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = RPC_NDR_DRSUAPI PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = RPC_NDR_DRSUAPI PYTALLOC param pycredentials python_dcerpc python_drsuapi_OBJ_FILES = ../librpc/gen_ndr/py_drsuapi.o -- cgit From 91c292249b6368a6212055692747ed818ce683cc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 14:55:47 +0100 Subject: s4:lib/ldb: we should not silence warnings on handwritten python bindings metze --- source4/lib/ldb/python.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/source4/lib/ldb/python.mk b/source4/lib/ldb/python.mk index 6e73b7e33d..6cc6d2e90e 100644 --- a/source4/lib/ldb/python.mk +++ b/source4/lib/ldb/python.mk @@ -4,5 +4,3 @@ PUBLIC_DEPENDENCIES = LIBLDB PYTALLOC pyldb_OBJ_FILES = $(ldbsrcdir)/pyldb.o $(pyldb_OBJ_FILES): CFLAGS+=-I$(ldbsrcdir)/include - -$(pyldb_OBJ_FILES): CFLAGS+=$(CFLAG_NO_CAST_QUAL) -- cgit From 0963028d1d6ed854c1d8946a8c7d923dd782c540 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 14:57:10 +0100 Subject: s4:libcli: remove unused line in config.mk metze --- source4/libcli/config.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/source4/libcli/config.mk b/source4/libcli/config.mk index 60baf83c8e..dc3431ab9f 100644 --- a/source4/libcli/config.mk +++ b/source4/libcli/config.mk @@ -87,8 +87,6 @@ PUBLIC_DEPENDENCIES = LIBCLI_NBT DYNCONFIG LIBSAMBA-HOSTCONFIG python_netbios_OBJ_FILES = $(libclinbtsrcdir)/pynbt.o -$(python_libcli_nbt_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL) - [SUBSYSTEM::LIBCLI_DGRAM] PUBLIC_DEPENDENCIES = LIBCLI_NBT LIBNDR LIBCLI_RESOLVE LIBCLI_NETLOGON -- cgit From cec5414f4680d93e1e385397eff2d4e27c1ae3b5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 14:59:58 +0100 Subject: s4:param: we should not silence warnings on handwritten python bindings metze --- source4/param/config.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/source4/param/config.mk b/source4/param/config.mk index b60d39299c..6a40b0c188 100644 --- a/source4/param/config.mk +++ b/source4/param/config.mk @@ -62,5 +62,3 @@ LIBRARY_REALNAME = samba/param.$(SHLIBEXT) PRIVATE_DEPENDENCIES = LIBSAMBA-HOSTCONFIG PYTALLOC param_OBJ_FILES = $(paramsrcdir)/pyparam.o - -$(param_OBJ_FILES): CFLAGS+=$(CFLAG_NO_CAST_QUAL) -- cgit From 9aa7698c0e88039465dfec8bf5a5511cd7933d30 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 15:00:20 +0100 Subject: s4:scripting/python: we should not silence warnings on handwritten python bindings metze --- source4/scripting/python/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk index a5d8e40b0d..ba624ee163 100644 --- a/source4/scripting/python/config.mk +++ b/source4/scripting/python/config.mk @@ -21,7 +21,7 @@ PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS pyldb python_dcerpc_misc python_glue_OBJ_FILES = $(pyscriptsrcdir)/pyglue.o -$(python_glue_OBJ_FILES): CFLAGS+=$(CFLAG_NO_CAST_QUAL) -I$(ldbsrcdir) +$(python_glue_OBJ_FILES): CFLAGS+=-I$(ldbsrcdir) _PY_FILES = $(shell find $(pyscriptsrcdir)/samba ../lib/subunit/python -name "*.py") -- cgit From cc5ad06abb380ec109f59c83ef935ce6ab713ef1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 15:05:33 +0100 Subject: s4:param: swig_ldb was renamed to pyldb in d965ff05c9923c8a0e440e905d0d9fe662cc5db0 metze --- source4/param/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/param/config.mk b/source4/param/config.mk index 6a40b0c188..d420a3883c 100644 --- a/source4/param/config.mk +++ b/source4/param/config.mk @@ -13,7 +13,7 @@ PUBLIC_HEADERS += param/param.h PC_FILES += $(paramsrcdir)/samba-hostconfig.pc [SUBSYSTEM::PROVISION] -PRIVATE_DEPENDENCIES = LIBPYTHON swig_ldb +PRIVATE_DEPENDENCIES = LIBPYTHON pyldb PROVISION_OBJ_FILES = $(paramsrcdir)/provision.o $(param_OBJ_FILES) -- cgit From 161961711a457fd362dbb356b4a8c8c27892c719 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 15:07:35 +0100 Subject: s4:build: add a comment why we need CFLAG_NO_CAST_QUAL and CFLAG_NO_UNUSED_MACROS metze --- source4/build/m4/check_cc.m4 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source4/build/m4/check_cc.m4 b/source4/build/m4/check_cc.m4 index 1683cb028a..55802850b0 100644 --- a/source4/build/m4/check_cc.m4 +++ b/source4/build/m4/check_cc.m4 @@ -112,10 +112,6 @@ if test x$developer = xyes; then AX_CFLAGS_GCC_OPTION(-Wformat=2, DEVELOPER_CFLAGS) AX_CFLAGS_GCC_OPTION(-Wdeclaration-after-statement, DEVELOPER_CFLAGS) AX_CFLAGS_GCC_OPTION(-Wunused-macros, DEVELOPER_CFLAGS) - AX_CFLAGS_GCC_OPTION(-Wno-unused-macros, CFLAG_NO_UNUSED_MACROS) - AC_SUBST(CFLAG_NO_CAST_QUAL) - AC_SUBST(CFLAG_NO_UNUSED_MACROS) - AX_CFLAGS_GCC_OPTION(-Wno-cast-qual, CFLAG_NO_CAST_QUAL) # AX_CFLAGS_GCC_OPTION(-Wextra, DEVELOPER_CFLAGS) # AX_CFLAGS_GCC_OPTION(-Wc++-compat, DEVELOPER_CFLAGS) # AX_CFLAGS_GCC_OPTION(-Wmissing-prototypes, DEVELOPER_CFLAGS) @@ -126,6 +122,13 @@ if test x$developer = xyes; then # AX_CFLAGS_GCC_OPTION(-Wno-format-y2k, DEVELOPER_CFLAGS) AX_CFLAGS_GCC_OPTION(-Wno-unused-parameter, DEVELOPER_CFLAGS) + # + # warnings we don't want just for some files e.g. swig bindings + # + AX_CFLAGS_GCC_OPTION(-Wno-cast-qual, CFLAG_NO_CAST_QUAL) + AC_SUBST(CFLAG_NO_CAST_QUAL) + AX_CFLAGS_GCC_OPTION(-Wno-unused-macros, CFLAG_NO_UNUSED_MACROS) + AC_SUBST(CFLAG_NO_UNUSED_MACROS) else AX_CFLAGS_IRIX_OPTION(-fullwarn, DEVELOPER_CFLAGS) fi -- cgit From 45940ef23a6560a100ba400249e92451eb6d5b84 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 Feb 2009 13:58:13 +0100 Subject: s3:selftest: pass correct arguments to $SCRIPTDIR/test_smbtorture_s3.sh metze --- source3/selftest/tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/selftest/tests.sh b/source3/selftest/tests.sh index c4907a159f..0ac194ef17 100755 --- a/source3/selftest/tests.sh +++ b/source3/selftest/tests.sh @@ -91,14 +91,14 @@ export PASSWORD shift $# testitprefix="smbtorture_s3.plain." testitenv="dc" - . $SCRIPTDIR/test_smbtorture_s3.sh //\$SERVER_IP/tmp \$USERNAME \$PASSWORD "" + . $SCRIPTDIR/test_smbtorture_s3.sh //\$SERVER_IP/tmp \$USERNAME \$PASSWORD "" "" ) ( shift $# testitprefix="smbtorture_s3.crypt." testitenv="dc" - . $SCRIPTDIR/test_smbtorture_s3.sh //\$SERVER_IP/tmp \$USERNAME \$PASSWORD "-e" + . $SCRIPTDIR/test_smbtorture_s3.sh //\$SERVER_IP/tmp \$USERNAME \$PASSWORD "" "-e" ) ( -- cgit From cfc27ece109fcc63016ad58c5f584b5459f57945 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 2 Feb 2009 15:43:32 +0100 Subject: Attempt to fix "make test" on host "tridge" --- lib/util/byteorder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/byteorder.h b/lib/util/byteorder.h index 894beccabf..b860dea791 100644 --- a/lib/util/byteorder.h +++ b/lib/util/byteorder.h @@ -151,7 +151,7 @@ static __inline__ void st_le32(uint32_t *addr, const uint32_t val) #if HAVE_ASM_BYTEORDER -#define _PTRPOS(buf,pos) (((const uint8_t *)buf)+(pos)) +#define _PTRPOS(buf,pos) (((const uint8_t *)(buf))+(pos)) #define SVAL(buf,pos) ld_le16((const uint16_t *)_PTRPOS(buf,pos)) #define IVAL(buf,pos) ld_le32((const uint32_t *)_PTRPOS(buf,pos)) #define SSVAL(buf,pos,val) st_le16((uint16_t *)_PTRPOS(buf,pos), val) -- cgit From af736923a541df1a37afeb72b8a5652932c4c69c Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Mon, 2 Feb 2009 13:06:36 +0100 Subject: fix for commit d96248a9b46 which broke Heimdal builds --- source3/libads/kerberos_verify.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source3/libads/kerberos_verify.c b/source3/libads/kerberos_verify.c index 4483d2be58..ec897ada2a 100644 --- a/source3/libads/kerberos_verify.c +++ b/source3/libads/kerberos_verify.c @@ -72,9 +72,15 @@ static bool ads_dedicated_keytab_verify_ticket(krb5_context context, } /* Get the key for checking the pac signature */ +#ifdef HAVE_ETYPE_IN_ENCRYPTEDDATA /* Heimdal */ + ret = krb5_kt_get_entry(context, keytab, dec_ticket->server, + dec_ticket.enc_part.kvno, dec_ticket.enc_part.etype, + &kt_entry); +#else /* MIT */ ret = krb5_kt_get_entry(context, keytab, dec_ticket->server, dec_ticket->enc_part.kvno, dec_ticket->enc_part.enctype, &kt_entry); +#endif if (ret) { DEBUG(0, ("krb5_kt_get_entry failed (%s)\n", error_message(ret))); -- cgit From d3f9b0fab67285d061719e69c1c6e9c4ce80fb36 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 2 Feb 2009 17:23:35 +0100 Subject: Next step disentangling async_req from NTSTATUS Now I need to document this :-) --- lib/async_req/async_req.c | 75 ++++++++++++++++++++++----------- lib/async_req/async_req.h | 23 +++++++--- lib/async_req/async_req_ntstatus.c | 48 ++++++++------------- lib/async_req/async_req_ntstatus.h | 2 - source3/lib/util_sock.c | 4 +- source3/lib/wb_reqtrans.c | 16 +++---- source3/lib/wbclient.c | 16 +++---- source3/libsmb/clireadwrite.c | 2 +- source3/rpc_client/cli_pipe.c | 20 ++++----- source3/rpc_client/rpc_transport_smbd.c | 4 +- 10 files changed, 117 insertions(+), 93 deletions(-) diff --git a/lib/async_req/async_req.c b/lib/async_req/async_req.c index 1b9fc5517b..db47bd93ed 100644 --- a/lib/async_req/async_req.c +++ b/lib/async_req/async_req.c @@ -70,6 +70,14 @@ struct async_req *async_req_new(TALLOC_CTX *mem_ctx) return result; } +static void async_req_finish(struct async_req *req, enum async_req_state state) +{ + req->state = state; + if (req->async.fn != NULL) { + req->async.fn(req); + } +} + /** * @brief An async request has successfully finished * @param[in] req The finished request @@ -81,30 +89,23 @@ struct async_req *async_req_new(TALLOC_CTX *mem_ctx) void async_req_done(struct async_req *req) { - req->error = 0; - req->state = ASYNC_REQ_DONE; - if (req->async.fn != NULL) { - req->async.fn(req); - } + async_req_finish(req, ASYNC_REQ_DONE); } /** * @brief An async request has seen an error * @param[in] req The request with an error - * @param[in] status The error code + * @param[in] error The error code * * async_req_done is to be used by implementors of async requests. When a * request can not successfully completed, the implementation should call this * function with the appropriate status code. */ -void async_req_error(struct async_req *req, uint32_t error) +void async_req_error(struct async_req *req, uint64_t error) { req->error = error; - req->state = ASYNC_REQ_ERROR; - if (req->async.fn != NULL) { - req->async.fn(req); - } + async_req_finish(req, ASYNC_REQ_USER_ERROR); } /** @@ -129,6 +130,32 @@ static void async_trigger(struct tevent_context *ev, struct tevent_timer *te, } } +/** + * @brief Helper function for nomem check + * @param[in] p The pointer to be checked + * @param[in] req The request being processed + * + * Convenience helper to easily check alloc failure within a callback + * implementing the next step of an async request. + * + * Call pattern would be + * \code + * p = talloc(mem_ctx, bla); + * if (async_req_ntnomem(p, req)) { + * return; + * } + * \endcode + */ + +bool async_req_nomem(const void *p, struct async_req *req) +{ + if (p != NULL) { + return false; + } + async_req_finish(req, ASYNC_REQ_NO_MEMORY); + return true; +} + /** * @brief Finish a request before it started processing * @param[in] req The finished request @@ -143,7 +170,7 @@ static void async_trigger(struct tevent_context *ev, struct tevent_timer *te, */ bool async_post_error(struct async_req *req, struct tevent_context *ev, - uint32_t error) + uint64_t error) { req->error = error; @@ -154,16 +181,17 @@ bool async_post_error(struct async_req *req, struct tevent_context *ev, return true; } -bool async_req_is_error(struct async_req *req, uint32_t *error) +bool async_req_is_error(struct async_req *req, enum async_req_state *state, + uint64_t *error) { - if (req->state < ASYNC_REQ_DONE) { - return true; + if (req->state == ASYNC_REQ_DONE) { + return false; } - if (req->state == ASYNC_REQ_ERROR) { + if (req->state == ASYNC_REQ_USER_ERROR) { *error = req->error; - return true; } - return false; + *state = req->state; + return true; } static void async_req_timedout(struct tevent_context *ev, @@ -171,18 +199,17 @@ static void async_req_timedout(struct tevent_context *ev, struct timeval now, void *priv) { - struct async_req *req = talloc_get_type_abort( - priv, struct async_req); + struct async_req *req = talloc_get_type_abort(priv, struct async_req); TALLOC_FREE(te); - async_req_nterror(req, NT_STATUS_IO_TIMEOUT); + 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, - timeval_current_ofs(to.tv_sec, to.tv_usec), - async_req_timedout, req) + return (tevent_add_timer( + ev, req, timeval_current_ofs(to.tv_sec, to.tv_usec), + async_req_timedout, req) != NULL); } diff --git a/lib/async_req/async_req.h b/lib/async_req/async_req.h index 19b052a788..fc849880cd 100644 --- a/lib/async_req/async_req.h +++ b/lib/async_req/async_req.h @@ -40,9 +40,17 @@ enum async_req_state { */ ASYNC_REQ_DONE, /** - * an error has occured + * A user error has occured */ - ASYNC_REQ_ERROR + ASYNC_REQ_USER_ERROR, + /** + * Request timed out + */ + ASYNC_REQ_TIMED_OUT, + /** + * No memory in between + */ + ASYNC_REQ_NO_MEMORY }; /** @@ -94,7 +102,7 @@ struct async_req { * This status can be queried in the async completion function. It * will be set to 0 when everything went fine. **/ - uint32_t error; + uint64_t error; /** * @brief What to do on completion @@ -121,12 +129,15 @@ char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req); void async_req_done(struct async_req *req); -void async_req_error(struct async_req *req, uint32_t error); +void async_req_error(struct async_req *req, uint64_t error); + +bool async_req_nomem(const void *p, struct async_req *req); bool async_post_error(struct async_req *req, struct tevent_context *ev, - uint32_t error); + uint64_t error); -bool async_req_is_error(struct async_req *req, uint32_t *error); +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); diff --git a/lib/async_req/async_req_ntstatus.c b/lib/async_req/async_req_ntstatus.c index dd81026074..65bc0f6510 100644 --- a/lib/async_req/async_req_ntstatus.c +++ b/lib/async_req/async_req_ntstatus.c @@ -23,32 +23,6 @@ #include "lib/util/dlinklist.h" #include "lib/async_req/async_req_ntstatus.h" -/** - * @brief Helper function for nomem check - * @param[in] p The pointer to be checked - * @param[in] req The request being processed - * - * Convenience helper to easily check alloc failure within a callback - * implementing the next step of an async request. - * - * Call pattern would be - * \code - * p = talloc(mem_ctx, bla); - * if (async_req_ntnomem(p, req)) { - * return; - * } - * \endcode - */ - -bool async_req_ntnomem(const void *p, struct async_req *req) -{ - if (p != NULL) { - return false; - } - async_req_nterror(req, NT_STATUS_NO_MEMORY); - return true; -} - void async_req_nterror(struct async_req *req, NTSTATUS status) { async_req_error(req, NT_STATUS_V(status)); @@ -62,13 +36,27 @@ bool async_post_ntstatus(struct async_req *req, struct tevent_context *ev, bool async_req_is_nterror(struct async_req *req, NTSTATUS *status) { - uint32_t error = NT_STATUS_V(NT_STATUS_INTERNAL_ERROR); + enum async_req_state state; + uint64_t error; - if (async_req_is_error(req, &error)) { + if (!async_req_is_error(req, &state, &error)) { + return false; + } + switch (state) { + case ASYNC_REQ_USER_ERROR: *status = NT_STATUS(error); - return true; + break; + case ASYNC_REQ_TIMED_OUT: + *status = NT_STATUS_IO_TIMEOUT; + break; + case ASYNC_REQ_NO_MEMORY: + *status = NT_STATUS_NO_MEMORY; + break; + default: + *status = NT_STATUS_INTERNAL_ERROR; + break; } - return false; + return true; } NTSTATUS async_req_simple_recv_ntstatus(struct async_req *req) diff --git a/lib/async_req/async_req_ntstatus.h b/lib/async_req/async_req_ntstatus.h index 7cc8caa14c..7555aac603 100644 --- a/lib/async_req/async_req_ntstatus.h +++ b/lib/async_req/async_req_ntstatus.h @@ -32,6 +32,4 @@ bool async_req_is_nterror(struct async_req *req, NTSTATUS *status); NTSTATUS async_req_simple_recv_ntstatus(struct async_req *req); -bool async_req_ntnomem(const void *p, struct async_req *req); - #endif diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index bafcdc5c5c..78431d93c8 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1077,7 +1077,7 @@ static void open_socket_out_connected(struct async_req *subreq) subreq = async_connect_send(state, state->ev, state->fd, (struct sockaddr *)&state->ss, state->salen); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } if (!async_req_set_timeout(subreq, state->ev, @@ -1209,7 +1209,7 @@ static void open_socket_out_defer_waited(struct async_req *subreq) subreq = open_socket_out_send(state, state->ev, &state->ss, state->port, state->timeout); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } subreq->async.fn = open_socket_out_defer_connected; diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index 7bca627690..e779e47d28 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -96,7 +96,7 @@ static void wb_req_read_len(struct async_req *subreq) subreq = recvall_send( req, state->ev, state->fd, (uint32 *)(state->wb_req)+1, sizeof(struct winbindd_request) - sizeof(uint32), 0); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } @@ -135,7 +135,7 @@ static void wb_req_read_main(struct async_req *subreq) state->wb_req->extra_data.data = TALLOC_ARRAY( state->wb_req, char, state->wb_req->extra_len + 1); - if (async_req_ntnomem(state->wb_req->extra_data.data, req)) { + if (async_req_nomem(state->wb_req->extra_data.data, req)) { return; } @@ -144,7 +144,7 @@ static void wb_req_read_main(struct async_req *subreq) subreq = recvall_send( req, state->ev, state->fd, state->wb_req->extra_data.data, state->wb_req->extra_len, 0); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } @@ -244,7 +244,7 @@ static void wb_req_write_main(struct async_req *subreq) subreq = sendall_send(state, state->ev, state->fd, state->wb_req->extra_data.data, state->wb_req->extra_len, 0); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } @@ -343,7 +343,7 @@ static void wb_resp_read_len(struct async_req *subreq) subreq = recvall_send( req, state->ev, state->fd, (uint32 *)(state->wb_resp)+1, sizeof(struct winbindd_response) - sizeof(uint32), 0); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } @@ -375,7 +375,7 @@ static void wb_resp_read_main(struct async_req *subreq) state->wb_resp->extra_data.data = TALLOC_ARRAY( state->wb_resp, char, extra_len+1); - if (async_req_ntnomem(state->wb_resp->extra_data.data, req)) { + if (async_req_nomem(state->wb_resp->extra_data.data, req)) { return; } ((char *)state->wb_resp->extra_data.data)[extra_len] = 0; @@ -383,7 +383,7 @@ static void wb_resp_read_main(struct async_req *subreq) subreq = recvall_send( req, state->ev, state->fd, state->wb_resp->extra_data.data, extra_len, 0); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } @@ -484,7 +484,7 @@ static void wb_resp_write_main(struct async_req *subreq) state, state->ev, state->fd, state->wb_resp->extra_data.data, state->wb_resp->length - sizeof(struct winbindd_response), 0); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index cf5ce7e734..f22b96a99a 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -463,7 +463,7 @@ static void wb_open_pipe_connect_nonpriv_done(struct async_req *subreq) subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, &state->wb_req); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } @@ -496,7 +496,7 @@ static void wb_open_pipe_ping_done(struct async_req *subreq) subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, &state->wb_req); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } @@ -526,7 +526,7 @@ static void wb_open_pipe_getpriv_done(struct async_req *subreq) subreq = wb_connect_send(state, state->ev, state->wb_ctx, (char *)wb_resp->extra_data.data); TALLOC_FREE(wb_resp); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } @@ -582,7 +582,7 @@ static void wb_trigger_trans(struct async_req *req) subreq = wb_open_pipe_send(state, state->ev, state->wb_ctx, state->need_priv); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } subreq->async.fn = wb_trans_connect_done; @@ -592,7 +592,7 @@ static void wb_trigger_trans(struct async_req *req) subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, state->wb_req); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } subreq->async.fn = wb_trans_done; @@ -665,7 +665,7 @@ static bool wb_trans_retry(struct async_req *req, } subreq = async_wait_send(state, state->ev, timeval_set(1, 0)); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return true; } @@ -691,7 +691,7 @@ static void wb_trans_retry_wait_done(struct async_req *subreq) subreq = wb_open_pipe_send(state, state->ev, state->wb_ctx, state->need_priv); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } subreq->async.fn = wb_trans_connect_done; @@ -715,7 +715,7 @@ static void wb_trans_connect_done(struct async_req *subreq) subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, state->wb_req); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c index 26fa614f69..9d17ff86a5 100644 --- a/source3/libsmb/clireadwrite.c +++ b/source3/libsmb/clireadwrite.c @@ -432,7 +432,7 @@ static void cli_pull_read_done(struct async_req *read_req) state->start_offset + state->requested, request_thistime); - if (async_req_ntnomem(new_req, state->req)) { + if (async_req_nomem(new_req, state->req)) { return; } diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index b9fd322485..2841ff08f6 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -269,7 +269,7 @@ static void rpc_read_done(struct async_req *subreq) state->data + state->num_read, state->size - state->num_read, state->transport->priv); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } subreq->async.fn = rpc_read_done; @@ -350,7 +350,7 @@ static void rpc_write_done(struct async_req *subreq) state->data + state->num_written, state->size - state->num_written, state->transport->priv); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } subreq->async.fn = rpc_write_done; @@ -512,7 +512,7 @@ static void get_complete_frag_got_header(struct async_req *subreq) state, state->ev, state->cli->transport, (uint8_t *)(prs_data_p(state->pdu) + RPC_HEADER_LEN), state->prhdr->frag_len - RPC_HEADER_LEN); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } subreq->async.fn = get_complete_frag_got_rest; @@ -1138,7 +1138,7 @@ static void cli_api_pipe_write_done(struct async_req *subreq) } state->rdata = TALLOC_ARRAY(state, uint8_t, RPC_HEADER_LEN); - if (async_req_ntnomem(state->rdata, req)) { + if (async_req_nomem(state->rdata, req)) { return; } @@ -1150,7 +1150,7 @@ static void cli_api_pipe_write_done(struct async_req *subreq) subreq = state->transport->read_send(state, state->ev, state->rdata, RPC_HEADER_LEN, state->transport->priv); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } subreq->async.fn = cli_api_pipe_read_done; @@ -1336,7 +1336,7 @@ static void rpc_api_pipe_trans_done(struct async_req *subreq) */ rdata_copy = (char *)memdup(rdata, rdata_len); TALLOC_FREE(rdata); - if (async_req_ntnomem(rdata_copy, req)) { + if (async_req_nomem(rdata_copy, req)) { return; } prs_give_memory(&state->incoming_frag, rdata_copy, rdata_len, true); @@ -1344,7 +1344,7 @@ static void rpc_api_pipe_trans_done(struct async_req *subreq) /* Ensure we have enough data for a pdu. */ subreq = get_complete_frag_send(state, state->ev, state->cli, &state->rhdr, &state->incoming_frag); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } subreq->async.fn = rpc_api_pipe_got_pdu; @@ -1436,7 +1436,7 @@ static void rpc_api_pipe_got_pdu(struct async_req *subreq) subreq = get_complete_frag_send(state, state->ev, state->cli, &state->rhdr, &state->incoming_frag); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } subreq->async.fn = rpc_api_pipe_got_pdu; @@ -2235,7 +2235,7 @@ static void rpc_api_pipe_req_write_done(struct async_req *subreq) subreq = rpc_api_pipe_send(state, state->ev, state->cli, &state->outgoing_frag, RPC_RESPONSE); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } subreq->async.fn = rpc_api_pipe_req_done; @@ -2246,7 +2246,7 @@ static void rpc_api_pipe_req_write_done(struct async_req *subreq) state->cli->transport, (uint8_t *)prs_data_p(&state->outgoing_frag), prs_offset(&state->outgoing_frag)); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } subreq->async.fn = rpc_api_pipe_req_write_done; diff --git a/source3/rpc_client/rpc_transport_smbd.c b/source3/rpc_client/rpc_transport_smbd.c index b93e4cf602..bf4aa65dae 100644 --- a/source3/rpc_client/rpc_transport_smbd.c +++ b/source3/rpc_client/rpc_transport_smbd.c @@ -174,7 +174,7 @@ static void get_anon_ipc_negprot_done(struct async_req *subreq) } subreq = cli_session_setup_guest_send(state, state->ev, state->cli); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } subreq->async.fn = get_anon_ipc_sesssetup_done; @@ -198,7 +198,7 @@ static void get_anon_ipc_sesssetup_done(struct async_req *subreq) subreq = cli_tcon_andx_send(state, state->ev, state->cli, "IPC$", "IPC", NULL, 0); - if (async_req_ntnomem(subreq, req)) { + if (async_req_nomem(subreq, req)) { return; } subreq->async.fn = get_anon_ipc_tcon_done; -- cgit From 6ed02233c3d873d4aa6ee4306d61cc2aad465a5d Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Mon, 2 Feb 2009 22:14:57 +0100 Subject: s3-wbclient: Use new tevent data types --- source3/include/proto.h | 2 +- source3/lib/wb_reqtrans.c | 16 ++++++++-------- source3/lib/wbclient.c | 14 +++++++------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 285b44dcde..dfe42db245 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -7671,7 +7671,7 @@ NTSTATUS nss_info_template_init( void ); /* Misc protos */ -struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct event_context *ev, +struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct wb_context *wb_ctx, bool need_priv, const struct winbindd_request *wb_req); NTSTATUS wb_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx, diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index e779e47d28..b56c0fd4d3 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -27,7 +27,7 @@ struct req_read_state { struct winbindd_request *wb_req; - struct event_context *ev; + struct tevent_context *ev; size_t max_extra_data; int fd; }; @@ -37,7 +37,7 @@ static void wb_req_read_main(struct async_req *subreq); static void wb_req_read_extra(struct async_req *subreq); struct async_req *wb_req_read_send(TALLOC_CTX *mem_ctx, - struct event_context *ev, + struct tevent_context *ev, int fd, size_t max_extra_data) { struct async_req *result, *subreq; @@ -184,7 +184,7 @@ NTSTATUS wb_req_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx, struct req_write_state { struct winbindd_request *wb_req; - struct event_context *ev; + struct tevent_context *ev; int fd; }; @@ -192,7 +192,7 @@ static void wb_req_write_main(struct async_req *subreq); static void wb_req_write_extra(struct async_req *subreq); struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx, - struct event_context *ev, int fd, + struct tevent_context *ev, int fd, struct winbindd_request *wb_req) { struct async_req *result, *subreq; @@ -275,7 +275,7 @@ NTSTATUS wb_req_write_recv(struct async_req *req) struct resp_read_state { struct winbindd_response *wb_resp; - struct event_context *ev; + struct tevent_context *ev; size_t max_extra_data; int fd; }; @@ -285,7 +285,7 @@ static void wb_resp_read_main(struct async_req *subreq); static void wb_resp_read_extra(struct async_req *subreq); struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx, - struct event_context *ev, int fd) + struct tevent_context *ev, int fd) { struct async_req *result, *subreq; struct resp_read_state *state; @@ -423,7 +423,7 @@ NTSTATUS wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx, struct resp_write_state { struct winbindd_response *wb_resp; - struct event_context *ev; + struct tevent_context *ev; int fd; }; @@ -431,7 +431,7 @@ static void wb_resp_write_main(struct async_req *subreq); static void wb_resp_write_extra(struct async_req *subreq); struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, - struct event_context *ev, int fd, + struct tevent_context *ev, int fd, struct winbindd_response *wb_resp) { struct async_req *result, *subreq; diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index f22b96a99a..ae9a034cc8 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -155,7 +155,7 @@ struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx) } static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx, - struct event_context *ev, + struct tevent_context *ev, struct wb_context *wb_ctx, const char *dir) { @@ -272,7 +272,7 @@ static struct winbindd_request *winbindd_request_copy( } struct wb_int_trans_state { - struct event_context *ev; + struct tevent_context *ev; int fd; struct winbindd_request *wb_req; struct winbindd_response *wb_resp; @@ -282,7 +282,7 @@ static void wb_int_trans_write_done(struct async_req *subreq); static void wb_int_trans_read_done(struct async_req *subreq); static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, - struct event_context *ev, int fd, + struct tevent_context *ev, int fd, struct winbindd_request *wb_req) { struct async_req *result; @@ -396,7 +396,7 @@ static const char *winbindd_socket_dir(void) struct wb_open_pipe_state { struct wb_context *wb_ctx; - struct event_context *ev; + struct tevent_context *ev; bool need_priv; struct winbindd_request wb_req; }; @@ -407,7 +407,7 @@ static void wb_open_pipe_getpriv_done(struct async_req *subreq); static void wb_open_pipe_connect_priv_done(struct async_req *subreq); static struct async_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx, - struct event_context *ev, + struct tevent_context *ev, struct wb_context *wb_ctx, bool need_priv) { @@ -560,7 +560,7 @@ static NTSTATUS wb_open_pipe_recv(struct async_req *req) struct wb_trans_state { struct wb_trans_state *prev, *next; struct wb_context *wb_ctx; - struct event_context *ev; + struct tevent_context *ev; struct winbindd_request *wb_req; struct winbindd_response *wb_resp; int num_retries; @@ -599,7 +599,7 @@ static void wb_trigger_trans(struct async_req *req) subreq->async.priv = req; } -struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct event_context *ev, +struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct wb_context *wb_ctx, bool need_priv, const struct winbindd_request *wb_req) { -- cgit From 7f283b29f14fc3c39fdb164f2c8e9ca18b4442ea Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 3 Feb 2009 00:08:24 +0100 Subject: s3:build: pass the path to smbtorture4 down to make with and without '-t' prefix metze --- source3/Makefile.in | 3 ++- source3/m4/check_path.m4 | 4 +++- source3/samba4.m4 | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/source3/Makefile.in b/source3/Makefile.in index 5d15e0fcca..9d08f7e9ca 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -19,6 +19,7 @@ datarootdir=@datarootdir@ selftest_prefix=@selftest_prefix@ selftest_shrdir=@selftest_shrdir@ smbtorture4_path=@smbtorture4_path@ +smbtorture4_option=@smbtorture4_option@ selftest_custom_conf=@selftest_custom_conf@ LIBS=@LIBS@ @@ -2932,7 +2933,7 @@ test_pam_modules:: pam_modules ## Targets for 'make test' ## -TEST_EXTRA_ARGS = ${smbtorture4_path} ${selftest_shrdir} ${selftest_custom_conf} +TEST_EXTRA_ARGS = ${smbtorture4_option} ${selftest_shrdir} ${selftest_custom_conf} test:: all torture timelimit @echo Running Test suite diff --git a/source3/m4/check_path.m4 b/source3/m4/check_path.m4 index 12b998747a..0a61733870 100644 --- a/source3/m4/check_path.m4 +++ b/source3/m4/check_path.m4 @@ -332,6 +332,8 @@ AC_ARG_WITH(selftest-shrdir, # set path of samba4's smbtorture smbtorture4_path="" AC_SUBST(smbtorture4_path) +smbtorture4_option="" +AC_SUBST(smbtorture4_option) AC_ARG_WITH(smbtorture4_path, [AS_HELP_STRING([--with-smbtorture4-path=PATH], [The path to a samba4 smbtorture for make test (none)])], [ case "$withval" in @@ -343,7 +345,7 @@ AC_ARG_WITH(smbtorture4_path, if test -z "$smbtorture4_path" -a ! -f $smbtorture4_path; then AC_MSG_ERROR(['$smbtorture_path' does not exist!]) fi - smbtorture4_path="-t $withval" + smbtorture4_option="-t $withval" ;; esac ]) diff --git a/source3/samba4.m4 b/source3/samba4.m4 index ee47fccfb2..e2c754b02b 100644 --- a/source3/samba4.m4 +++ b/source3/samba4.m4 @@ -1,5 +1,6 @@ AC_SUBST(BLDSHARED) -smbtorture4_path="-t bin/smbtorture4" +smbtorture4_path="bin/smbtorture4" +smbtorture4_option="-t bin/smbtorture4" m4_include(build/m4/public.m4) m4_include(../m4/check_python.m4) -- cgit From df4e38fcc3232da3ed63ebca6f7b9ff7665b1e40 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Jan 2009 14:00:54 +0100 Subject: s3:selftest: run test_posix_s3.sh tests metze --- source3/Makefile.in | 4 +++- source3/selftest/tests.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/source3/Makefile.in b/source3/Makefile.in index 9d08f7e9ca..531f64f92f 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -2954,7 +2954,9 @@ selftestdir = ../selftest S3_LD_LIBPATH_OVERRIDE = $(LIB_PATH_VAR)="$(builddir)/bin" selftest:: all torture timelimit - @$(S3_LD_LIBPATH_OVERRIDE) PERL="$(PERL)" \ + @LIB_PATH_VAR=$(LIB_PATH_VAR) $(S3_LD_LIBPATH_OVERRIDE) \ + SAMBA4SHAREDDIR="$(builddir)/bin/shared" SMBTORTURE4=$(smbtorture4_path) \ + PERL="$(PERL)" PYTHON="$(PYTHON)" \ $(PERL) $(selftestdir)/selftest.pl \ --prefix=${selftest_prefix} --target=samba3 \ --testlist="$(srcdir)/selftest/tests.sh|" \ diff --git a/source3/selftest/tests.sh b/source3/selftest/tests.sh index 0ac194ef17..812a3a7fe8 100755 --- a/source3/selftest/tests.sh +++ b/source3/selftest/tests.sh @@ -129,3 +129,42 @@ plantest "blackbox.smbclient_s3.crypt" dc BINDIR="$BINDIR" script/tests/test_smb plantest "blackbox.net_s3" dc BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" script/tests/test_net_s3.sh +( + shift $# + testitprefix="posix_s3." + testitenv="dc:local" + + SMBTORTURE4BINARY=$SMBTORTURE4 + TORTURE4_OPTIONS="" + TORTURE4_OPTIONS="$TORTURE4_OPTIONS --configfile=\$SMB_CONF_PATH" + TORTURE4_OPTIONS="$TORTURE4_OPTIONS --maximum-runtime=$SELFTEST_MAXTIME" + TORTURE4_OPTIONS="$TORTURE4_OPTIONS --target=$SELFTEST_TARGET" + TORTURE4_OPTIONS="$TORTURE4_OPTIONS --basedir=$SELFTEST_PREFIX" + if [ -n "$SELFTEST_VERBOSE" ]; then + TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:progress=no" + fi + TORTURE_OPTIONS="$TORTURE4_OPTIONS --format=subunit" + if [ -n "$SELFTEST_QUICK" ]; then + TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:quick=yes" + fi + + # This is an ugly hack... + TORTURE4_OPTIONS="$TORTURE4_OPTIONS --option=torture:localdir=$SELFTEST_PREFIX/dc/share" + + if [ -x "$SMBTORTURE4" ]; then + LIB_PATH_VAR_VAR="\$`echo $LIB_PATH_VAR`" + S4_LIB_PREFIX=`eval echo "$LIB_PATH_VAR=\"$SAMBA4SHAREDDIR:$LIB_PATH_VAR_VAR\""` + SMBTORTURE4="$S4_LIB_PREFIX $SMBTORTURE4" + SMBTORTURE4VERSION=`eval $SMBTORTURE4 --version` + fi + if [ -n "$SMBTORTURE4" -a -n "$SMBTORTURE4VERSION" ];then + echo "Using SMBTORTURE4: $SMBTORTURE4BINARY" + echo "Version: $SMBTORTURE4VERSION" + . $SCRIPTDIR/test_posix_s3.sh //\$SERVER_IP/tmp \$USERNAME \$PASSWORD "" "" + else + echo "Skip Tests with Samba4's smbtorture" + echo "Try to compile with --with-smbtorture4-path=PATH to enable" + fi + +) + -- cgit From 553818add80818909268557665e2760a16f2d8a0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 2 Feb 2009 17:10:27 -0800 Subject: Fix bug #6082 - smbd_gpfs_getacl failed: Windows client can´t rename or delete file This fixes the generic rename/delete problem for 3.3.0 and above. Fixed slightly differently to discussions, user viewable modified ACLs are not a good idea :-). Jeremy. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source3/include/smb.h | 2 +- source3/lib/util_seaccess.c | 5 +++- source3/smbd/file_access.c | 11 +++------ source3/smbd/open.c | 56 +++++++++++++++++++++++++++++++++++++-------- 4 files changed, 54 insertions(+), 20 deletions(-) diff --git a/source3/include/smb.h b/source3/include/smb.h index 491dd763ff..b441b3476a 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -1259,7 +1259,7 @@ struct bitmap { /* Mapping of access rights to UNIX perms. for a UNIX directory. */ #define UNIX_DIRECTORY_ACCESS_RWX FILE_GENERIC_ALL #define UNIX_DIRECTORY_ACCESS_R FILE_GENERIC_READ -#define UNIX_DIRECTORY_ACCESS_W FILE_GENERIC_WRITE +#define UNIX_DIRECTORY_ACCESS_W (FILE_GENERIC_WRITE|FILE_DELETE_CHILD) #define UNIX_DIRECTORY_ACCESS_X FILE_GENERIC_EXECUTE #if 0 diff --git a/source3/lib/util_seaccess.c b/source3/lib/util_seaccess.c index fdc10f20ab..0da7442d19 100644 --- a/source3/lib/util_seaccess.c +++ b/source3/lib/util_seaccess.c @@ -149,7 +149,9 @@ static uint32_t access_check_max_allowed(const struct security_descriptor *sd, } /* - the main entry point for access checking. + The main entry point for access checking. If returning ACCESS_DENIED + this function returns the denied bits in the uint32_t pointed + to by the access_granted pointer. */ NTSTATUS se_access_check(const struct security_descriptor *sd, const NT_USER_TOKEN *token, @@ -238,6 +240,7 @@ NTSTATUS se_access_check(const struct security_descriptor *sd, done: if (bits_remaining != 0) { + *access_granted = bits_remaining; return NT_STATUS_ACCESS_DENIED; } diff --git a/source3/smbd/file_access.c b/source3/smbd/file_access.c index d44e63a89a..fe7ba1cc46 100644 --- a/source3/smbd/file_access.c +++ b/source3/smbd/file_access.c @@ -113,16 +113,11 @@ bool can_delete_file_in_directory(connection_struct *conn, const char *fname) * having the DELETE bit on the file itself and second if that does * not help, by the DELETE_CHILD bit on the containing directory. * - * Here we check the other way round because with just posix - * permissions looking at the file itself will never grant DELETE, so - * by looking at the directory first we save one get_acl call. + * Here we only check the directory permissions, we will + * check the file DELETE permission separately. */ - if (can_access_file_acl(conn, dname, FILE_DELETE_CHILD)) { - return true; - } - - return can_access_file_acl(conn, fname, DELETE_ACCESS); + return can_access_file_acl(conn, dname, FILE_DELETE_CHILD); } /**************************************************************************** diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 7d23b92359..bc5107447f 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -67,13 +67,15 @@ NTSTATUS smb1_file_se_access_check(const struct security_descriptor *sd, static NTSTATUS check_open_rights(struct connection_struct *conn, const char *fname, - uint32_t access_mask) + uint32_t access_mask, + uint32_t *access_granted) { /* Check if we have rights to open. */ NTSTATUS status; - uint32_t access_granted = 0; struct security_descriptor *sd; + *access_granted = 0; + status = SMB_VFS_GET_NT_ACL(conn, fname, (OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | @@ -90,9 +92,17 @@ static NTSTATUS check_open_rights(struct connection_struct *conn, status = smb1_file_se_access_check(sd, conn->server_info->ptok, access_mask, - &access_granted); + access_granted); TALLOC_FREE(sd); + + DEBUG(10,("check_open_rights: file %s requesting " + "0x%x returning 0x%x (%s)\n", + fname, + (unsigned int)access_mask, + (unsigned int)*access_granted, + nt_errstr(status) )); + return status; } @@ -415,14 +425,35 @@ static NTSTATUS open_file(files_struct *fsp, } else { fsp->fh->fd = -1; /* What we used to call a stat open. */ if (file_existed) { + uint32_t access_granted = 0; + status = check_open_rights(conn, path, - access_mask); + access_mask, + &access_granted); if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("open_file: Access denied on " - "file %s\n", - path)); - return status; + + /* Were we trying to do a stat open + * for delete and didn't get DELETE + * access (only) ? Check if the + * directory allows DELETE_CHILD. + * See here: + * http://blogs.msdn.com/oldnewthing/archive/2004/06/04/148426.aspx + * for details. */ + + if (!(NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) && + (access_mask & DELETE_ACCESS) && + (access_granted == DELETE_ACCESS) && + can_delete_file_in_directory(conn, path))) { + DEBUG(10, ("open_file: Access denied on " + "file %s\n", + path)); + return status; + } + + DEBUG(10,("open_file: overrode ACCESS_DENIED " + "on file %s\n", + path )); } } } @@ -2395,9 +2426,11 @@ static NTSTATUS open_directory(connection_struct *conn, } if (info == FILE_WAS_OPENED) { + uint32_t access_granted = 0; status = check_open_rights(conn, fname, - access_mask); + access_mask, + &access_granted); if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("open_directory: check_open_rights on " "file %s failed with %s\n", @@ -2826,8 +2859,11 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, && (create_disposition != FILE_CREATE) && (share_access & FILE_SHARE_DELETE) && (access_mask & DELETE_ACCESS) - && (!can_delete_file_in_directory(conn, fname))) { + && (!(can_delete_file_in_directory(conn, fname) || + can_access_file_acl(conn, fname, DELETE_ACCESS)))) { status = NT_STATUS_ACCESS_DENIED; + DEBUG(10,("create_file_unixpath: open file %s " + "for delete ACCESS_DENIED\n", fname )); goto fail; } -- cgit From 810b670b754f1f1f547c94c1b9bcff40154e7bb2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 3 Feb 2009 10:21:51 +0100 Subject: Fix Coverity ID 870 --- source3/libsmb/cliconnect.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 60b1a6027c..a39e035d2a 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -1229,6 +1229,10 @@ struct async_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx, */ passlen = clistr_push(cli, pword, pass, sizeof(pword), STR_TERMINATE); + if (passlen == -1) { + DEBUG(1, ("clistr_push(pword) failed\n")); + goto access_denied; + } } else { if (passlen) { memcpy(pword, pass, passlen); -- cgit From e6bb55c3d5b491ab9e6d568e6ce7594695e53322 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 3 Feb 2009 02:31:47 +0100 Subject: lib/tdb: don't generate a static library for the samba4 build We also don't do this for talloc and ldb. metze --- lib/tdb/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tdb/config.mk b/lib/tdb/config.mk index 90c9ba2863..38b03b93b6 100644 --- a/lib/tdb/config.mk +++ b/lib/tdb/config.mk @@ -1,7 +1,7 @@ ################################################ # Start SUBSYSTEM LIBTDB [LIBRARY::LIBTDB] -OUTPUT_TYPE = STATIC_LIBRARY +OUTPUT_TYPE = MERGED_OBJ CFLAGS = -I$(tdbsrcdir)/include # # End SUBSYSTEM ldb -- cgit From fda8abac17892e51c2d5fcdc1f405477bef320ed Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 3 Feb 2009 14:41:49 +0100 Subject: s3: Fix 'net rpc join' for users with the SeMachineAccountPrivilege. --- source3/libnet/libnet_join.c | 7 +++++-- source3/utils/net_rpc_join.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index b33800f20d..20f7b97745 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -790,7 +790,8 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, status = rpccli_samr_Connect2(pipe_hnd, mem_ctx, pipe_hnd->desthost, - SEC_RIGHTS_MAXIMUM_ALLOWED, + SAMR_ACCESS_ENUM_DOMAINS + | SAMR_ACCESS_OPEN_DOMAIN, &sam_pol); if (!NT_STATUS_IS_OK(status)) { goto done; @@ -798,7 +799,9 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx, status = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx, &sam_pol, - SEC_RIGHTS_MAXIMUM_ALLOWED, + SAMR_DOMAIN_ACCESS_LOOKUP_INFO_1 + | SAMR_DOMAIN_ACCESS_CREATE_USER + | SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, r->out.domain_sid, &domain_pol); if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c index 5651676693..0c363d373e 100644 --- a/source3/utils/net_rpc_join.c +++ b/source3/utils/net_rpc_join.c @@ -243,14 +243,17 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv) CHECK_RPC_ERR(rpccli_samr_Connect2(pipe_hnd, mem_ctx, pipe_hnd->desthost, - SEC_RIGHTS_MAXIMUM_ALLOWED, + SAMR_ACCESS_ENUM_DOMAINS + | SAMR_ACCESS_OPEN_DOMAIN, &sam_pol), "could not connect to SAM database"); CHECK_RPC_ERR(rpccli_samr_OpenDomain(pipe_hnd, mem_ctx, &sam_pol, - SEC_RIGHTS_MAXIMUM_ALLOWED, + SAMR_DOMAIN_ACCESS_LOOKUP_INFO_1 + | SAMR_DOMAIN_ACCESS_CREATE_USER + | SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, domain_sid, &domain_pol), "could not open domain"); -- cgit From 20a1cb15699c781651593c68685ece91c03e6a18 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 3 Feb 2009 15:02:14 +0100 Subject: s3:test: try to find why creating BUILTIN\Administrators doesn't work in the build-farm metze --- source3/script/tests/selftest.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source3/script/tests/selftest.sh b/source3/script/tests/selftest.sh index c02e0ee183..af01d0f961 100755 --- a/source3/script/tests/selftest.sh +++ b/source3/script/tests/selftest.sh @@ -346,9 +346,11 @@ START=`date` MAKE_TEST_BINARY="" MAKE_TEST_BINARY="bin/net" - printf "%s" "creating BUILTIN\\Administrators..." - bin/net -s $SERVERCONFFILE sam createbuiltingroup \ - Administrators > /dev/null 2>&1 || exit 1 + printf "%s\n" "creating BUILTIN\\Administrators..." + bin/net -s $SERVERCONFFILE sam createbuiltingroup Administrators || { + echo "FAILED: $?" + exit 1 + } echo "DONE" MAKE_TEST_BINARY="" -- cgit From 1318fe8c60cf3e6a12dfaf5933d7750d73cb3878 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 3 Feb 2009 14:51:12 +0100 Subject: Revert "fix for commit d96248a9b46 which broke Heimdal builds" This does not build. This reverts commit af736923a541df1a37afeb72b8a5652932c4c69c. --- source3/libads/kerberos_verify.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/source3/libads/kerberos_verify.c b/source3/libads/kerberos_verify.c index ec897ada2a..4483d2be58 100644 --- a/source3/libads/kerberos_verify.c +++ b/source3/libads/kerberos_verify.c @@ -72,15 +72,9 @@ static bool ads_dedicated_keytab_verify_ticket(krb5_context context, } /* Get the key for checking the pac signature */ -#ifdef HAVE_ETYPE_IN_ENCRYPTEDDATA /* Heimdal */ - ret = krb5_kt_get_entry(context, keytab, dec_ticket->server, - dec_ticket.enc_part.kvno, dec_ticket.enc_part.etype, - &kt_entry); -#else /* MIT */ ret = krb5_kt_get_entry(context, keytab, dec_ticket->server, dec_ticket->enc_part.kvno, dec_ticket->enc_part.enctype, &kt_entry); -#endif if (ret) { DEBUG(0, ("krb5_kt_get_entry failed (%s)\n", error_message(ret))); -- cgit From 3367812df604bb1d01f59ee2750427426164c519 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 3 Feb 2009 14:53:58 +0100 Subject: s3-kerberos: fix ads_dedicated_keytab_verify_ticket with heimdal. Guenther --- source3/libads/kerberos_verify.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/source3/libads/kerberos_verify.c b/source3/libads/kerberos_verify.c index 4483d2be58..fe22898a26 100644 --- a/source3/libads/kerberos_verify.c +++ b/source3/libads/kerberos_verify.c @@ -45,6 +45,8 @@ static bool ads_dedicated_keytab_verify_ticket(krb5_context context, krb5_ticket *dec_ticket = NULL; krb5_data packet; + krb5_kvno kvno = 0; + krb5_enctype enctype; *pp_tkt = NULL; *keyblock = NULL; @@ -62,7 +64,6 @@ static bool ads_dedicated_keytab_verify_ticket(krb5_context context, packet.length = ticket->length; packet.data = (char *)ticket->data; - *pp_tkt = NULL; ret = krb5_rd_req(context, &auth_context, &packet, NULL, keytab, NULL, &dec_ticket); @@ -71,10 +72,16 @@ static bool ads_dedicated_keytab_verify_ticket(krb5_context context, goto out; } +#ifdef HAVE_ETYPE_IN_ENCRYPTEDDATA /* Heimdal */ + enctype = dec_ticket->ticket.key.keytype; +#else /* MIT */ + enctype = dec_ticket->enc_part.enctype; + kvno = dec_ticket->enc_part.kvno; +#endif + /* Get the key for checking the pac signature */ ret = krb5_kt_get_entry(context, keytab, dec_ticket->server, - dec_ticket->enc_part.kvno, dec_ticket->enc_part.enctype, - &kt_entry); + kvno, enctype, &kt_entry); if (ret) { DEBUG(0, ("krb5_kt_get_entry failed (%s)\n", error_message(ret))); -- cgit From b0ea17973400cd15c3fb23c8deb4f9c37b42035a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 3 Feb 2009 14:15:40 +0100 Subject: s3-kerberos: use KRB5_KT_KEY compat macro. Guenther --- source3/libads/kerberos_verify.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/source3/libads/kerberos_verify.c b/source3/libads/kerberos_verify.c index fe22898a26..b903b2a6eb 100644 --- a/source3/libads/kerberos_verify.c +++ b/source3/libads/kerberos_verify.c @@ -88,13 +88,7 @@ static bool ads_dedicated_keytab_verify_ticket(krb5_context context, goto out; } -#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK /* Heimdal */ - ret = krb5_copy_keyblock(context, &kt_entry.keyblock, keyblock); -#elif defined(HAVE_KRB5_KEYTAB_ENTRY_KEY) /* MIT */ - ret = krb5_copy_keyblock(context, &kt_entry.key, keyblock); -#else -#error UNKNOWN_KRB5_KEYTAB_ENTRY_FORMAT -#endif + ret = krb5_copy_keyblock(context, KRB5_KT_KEY(&kt_entry), keyblock); smb_krb5_kt_free_entry(context, &kt_entry); if (ret) { -- cgit From 329b8775f56c8a89f02646e11ba27a33080f48b1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 3 Feb 2009 15:31:28 +0100 Subject: s3-net: fix warning message for keytab usage. Guenther --- source3/utils/net_ads.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 03786e2e17..86fb9f6782 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -2242,8 +2242,8 @@ int net_ads_keytab(struct net_context *c, int argc, const char **argv) }; if (!USE_KERBEROS_KEYTAB) { - d_printf("\nWarning: \"kerberos method\" must be set to a \ - keytab method to use keytab functions.\n"); + d_printf("\nWarning: \"kerberos method\" must be set to a " + "keytab method to use keytab functions.\n"); } return net_run_function(c, argc, argv, "net ads keytab", func); -- cgit From 35f1e02ca4c31214e85b7c25d8f695eb035871d7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 2 Feb 2009 16:41:44 +0100 Subject: librpc: add ndr_size_string_array(). Guenther --- librpc/ndr/libndr.h | 1 + source3/librpc/ndr/ndr_string.c | 23 +++++++++++++++++++++++ source4/librpc/ndr/ndr_string.c | 23 +++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h index 4ab0bf5f0b..7109b73d2a 100644 --- a/librpc/ndr/libndr.h +++ b/librpc/ndr/libndr.h @@ -506,6 +506,7 @@ uint32_t ndr_size_string(int ret, const char * const* string, int flags); enum ndr_err_code ndr_pull_string_array(struct ndr_pull *ndr, int ndr_flags, const char ***_a); enum ndr_err_code ndr_push_string_array(struct ndr_push *ndr, int ndr_flags, const char **a); void ndr_print_string_array(struct ndr_print *ndr, const char *name, const char **a); +size_t ndr_size_string_array(const char **a, uint32_t count, int flags); uint32_t ndr_string_length(const void *_var, uint32_t element_size); enum ndr_err_code ndr_check_string_terminator(struct ndr_pull *ndr, uint32_t count, uint32_t element_size); enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, const char **var, uint32_t length, uint8_t byte_mul, charset_t chset); diff --git a/source3/librpc/ndr/ndr_string.c b/source3/librpc/ndr/ndr_string.c index 86d7b26586..985d0f4daa 100644 --- a/source3/librpc/ndr/ndr_string.c +++ b/source3/librpc/ndr/ndr_string.c @@ -595,6 +595,29 @@ _PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, co ndr->depth--; } +_PUBLIC_ size_t ndr_size_string_array(const char **a, uint32_t count, int flags) +{ + uint32_t i; + size_t size = 0; + + switch (flags & LIBNDR_STRING_FLAGS) { + case LIBNDR_FLAG_STR_NULLTERM: + for (i = 0; i < count; i++) { + size += strlen_m_term(a[i]); + } + break; + case LIBNDR_FLAG_STR_NOTERM: + for (i = 0; i < count; i++) { + size += strlen_m(a[i]); + } + break; + default: + return 0; + } + + return size; +} + /** * Return number of elements in a string including the last (zeroed) element */ diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c index 265fa68b48..a2fcdeae29 100644 --- a/source4/librpc/ndr/ndr_string.c +++ b/source4/librpc/ndr/ndr_string.c @@ -595,6 +595,29 @@ _PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, co ndr->depth--; } +_PUBLIC_ size_t ndr_size_string_array(const char **a, uint32_t count, int flags) +{ + uint32_t i; + size_t size = 0; + + switch (flags & LIBNDR_STRING_FLAGS) { + case LIBNDR_FLAG_STR_NULLTERM: + for (i = 0; i < count; i++) { + size += strlen_m_term(a[i]); + } + break; + case LIBNDR_FLAG_STR_NOTERM: + for (i = 0; i < count; i++) { + size += strlen_m(a[i]); + } + break; + default: + return 0; + } + + return size; +} + /** * Return number of elements in a string including the last (zeroed) element */ -- cgit From 8fb6b18bac436d4babdafc4d8b97de70881c1238 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 22 Jan 2009 19:46:14 +0100 Subject: s3-eventlog: allow to open eventlog tdbs readonly. Guenther --- source3/include/proto.h | 2 +- source3/rpc_server/srv_eventlog_lib.c | 11 +++++++++-- source3/rpc_server/srv_eventlog_nt.c | 6 +++--- source3/utils/eventlogadm.c | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index dfe42db245..f68c354642 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6258,7 +6258,7 @@ char *elog_tdbname(TALLOC_CTX *ctx, const char *name ); int elog_tdb_size( TDB_CONTEXT * tdb, int *MaxSize, int *Retention ); bool prune_eventlog( TDB_CONTEXT * tdb ); bool can_write_to_eventlog( TDB_CONTEXT * tdb, int32 needed ); -ELOG_TDB *elog_open_tdb( char *logname, bool force_clear ); +ELOG_TDB *elog_open_tdb( char *logname, bool force_clear, bool read_only ); int elog_close_tdb( ELOG_TDB *etdb, bool force_close ); int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ); void fixup_eventlog_entry( Eventlog_entry * ee ); diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 8cbb319e9b..88e246a94f 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -312,7 +312,7 @@ bool can_write_to_eventlog( TDB_CONTEXT * tdb, int32_t needed ) /******************************************************************* *******************************************************************/ -ELOG_TDB *elog_open_tdb( char *logname, bool force_clear ) +ELOG_TDB *elog_open_tdb( char *logname, bool force_clear, bool read_only ) { TDB_CONTEXT *tdb = NULL; uint32_t vers_id; @@ -322,6 +322,13 @@ ELOG_TDB *elog_open_tdb( char *logname, bool force_clear ) char *eventlogdir; TALLOC_CTX *ctx = talloc_tos(); + /* check for invalid options */ + + if (force_clear && read_only) { + DEBUG(1,("elog_open_tdb: Invalid flags\n")); + return NULL; + } + /* first see if we have an open context */ for ( ptr=open_elog_list; ptr; ptr=ptr->next ) { @@ -363,7 +370,7 @@ ELOG_TDB *elog_open_tdb( char *logname, bool force_clear ) if ( !force_clear ) { - tdb = tdb_open_log( tdbpath, 0, TDB_DEFAULT, O_RDWR , 0 ); + tdb = tdb_open_log( tdbpath, 0, TDB_DEFAULT, read_only ? O_RDONLY : O_RDWR , 0 ); if ( tdb ) { vers_id = tdb_fetch_int32( tdb, EVT_VERSION ); diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index a687025ba6..990b03a570 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -194,7 +194,7 @@ static NTSTATUS elog_open( pipes_struct * p, const char *logname, POLICY_HND *hn in a single process */ become_root(); - elog->etdb = elog_open_tdb( elog->logname, False ); + elog->etdb = elog_open_tdb( elog->logname, False, False ); unbecome_root(); if ( !elog->etdb ) { @@ -214,7 +214,7 @@ static NTSTATUS elog_open( pipes_struct * p, const char *logname, POLICY_HND *hn } become_root(); - elog->etdb = elog_open_tdb( elog->logname, False ); + elog->etdb = elog_open_tdb( elog->logname, False, False ); unbecome_root(); } @@ -677,7 +677,7 @@ NTSTATUS _eventlog_ClearEventLogW(pipes_struct *p, elog_close_tdb( info->etdb, True ); become_root(); - info->etdb = elog_open_tdb( info->logname, True ); + info->etdb = elog_open_tdb( info->logname, True, False ); unbecome_root(); if ( !info->etdb ) diff --git a/source3/utils/eventlogadm.c b/source3/utils/eventlogadm.c index 5fed4d1a39..7d40772423 100644 --- a/source3/utils/eventlogadm.c +++ b/source3/utils/eventlogadm.c @@ -103,7 +103,7 @@ static int DoWriteCommand( int argc, char **argv, bool debugflag, char *exename argfname = argv[0]; - if ( !( etdb = elog_open_tdb( argfname, False ) ) ) { + if ( !( etdb = elog_open_tdb( argfname, False, False ) ) ) { printf( "can't open the eventlog TDB (%s)\n", argfname ); return -1; } -- cgit From 4976777e3b0f3d8c18182a822937f62c082027c7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 2 Feb 2009 14:00:01 +0100 Subject: s3-eventlog: make logname in elog_open_tdb const. Guenther --- source3/include/proto.h | 2 +- source3/rpc_server/srv_eventlog_lib.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index f68c354642..6f9474e3fb 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6258,7 +6258,7 @@ char *elog_tdbname(TALLOC_CTX *ctx, const char *name ); int elog_tdb_size( TDB_CONTEXT * tdb, int *MaxSize, int *Retention ); bool prune_eventlog( TDB_CONTEXT * tdb ); bool can_write_to_eventlog( TDB_CONTEXT * tdb, int32 needed ); -ELOG_TDB *elog_open_tdb( char *logname, bool force_clear, bool read_only ); +ELOG_TDB *elog_open_tdb( const char *logname, bool force_clear, bool read_only ); int elog_close_tdb( ELOG_TDB *etdb, bool force_close ); int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ); void fixup_eventlog_entry( Eventlog_entry * ee ); diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 88e246a94f..70673f73e9 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -312,7 +312,7 @@ bool can_write_to_eventlog( TDB_CONTEXT * tdb, int32_t needed ) /******************************************************************* *******************************************************************/ -ELOG_TDB *elog_open_tdb( char *logname, bool force_clear, bool read_only ) +ELOG_TDB *elog_open_tdb( const char *logname, bool force_clear, bool read_only ) { TDB_CONTEXT *tdb = NULL; uint32_t vers_id; -- cgit From b94946697dc1d2915f6330f3a02cca7d69bc7cff Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 2 Feb 2009 13:38:38 +0100 Subject: s3-eventlog: pass down talloc context to parse_logentry(). Guenther --- source3/include/proto.h | 2 +- source3/rpc_server/srv_eventlog_lib.c | 15 +++++++-------- source3/utils/eventlogadm.c | 3 ++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 6f9474e3fb..19d131cb63 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6262,7 +6262,7 @@ ELOG_TDB *elog_open_tdb( const char *logname, bool force_clear, bool read_only ) int elog_close_tdb( ELOG_TDB *etdb, bool force_close ); int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ); void fixup_eventlog_entry( Eventlog_entry * ee ); -bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor ); +bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, bool * eor ); /* The following definitions come from rpc_server/srv_eventlog_nt.c */ diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 70673f73e9..2890dc9528 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -594,9 +594,8 @@ void fixup_eventlog_entry( Eventlog_entry * ee ) going in. ********************************************************************/ -bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor ) +bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, bool * eor ) { - TALLOC_CTX *ctx = talloc_tos(); char *start = NULL, *stop = NULL; start = line; @@ -667,7 +666,7 @@ bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor ) while ( isspace( stop[0] ) ) { stop++; } - entry->data_record.source_name_len = rpcstr_push_talloc(ctx, + entry->data_record.source_name_len = rpcstr_push_talloc(mem_ctx, &entry->data_record.source_name, stop); if (entry->data_record.source_name_len == (uint32_t)-1 || @@ -679,7 +678,7 @@ bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor ) while ( isspace( stop[0] ) ) { stop++; } - entry->data_record.computer_name_len = rpcstr_push_talloc(ctx, + entry->data_record.computer_name_len = rpcstr_push_talloc(mem_ctx, &entry->data_record.computer_name, stop); if (entry->data_record.computer_name_len == (uint32_t)-1 || @@ -691,7 +690,7 @@ bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor ) while ( isspace( stop[0] ) ) { stop++; } - entry->record.user_sid_length = rpcstr_push_talloc(ctx, + entry->record.user_sid_length = rpcstr_push_talloc(mem_ctx, &entry->data_record.sid, stop); if (entry->record.user_sid_length == (uint32_t)-1 || @@ -708,14 +707,14 @@ bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor ) while ( isspace(stop[0])) { stop++; } - tmp_len = rpcstr_push_talloc(ctx, + tmp_len = rpcstr_push_talloc(mem_ctx, &temp, stop); if (tmp_len == (size_t)-1 || !temp) { return false; } old_len = entry->data_record.strings_len; - entry->data_record.strings = (smb_ucs2_t *)TALLOC_REALLOC_ARRAY(ctx, + entry->data_record.strings = (smb_ucs2_t *)TALLOC_REALLOC_ARRAY(mem_ctx, entry->data_record.strings, char, old_len + tmp_len); @@ -735,7 +734,7 @@ bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor ) stop++; } entry->data_record.user_data_len = strlen(stop); - entry->data_record.user_data = talloc_strdup(ctx, + entry->data_record.user_data = talloc_strdup(mem_ctx, stop); if (!entry->data_record.user_data) { return false; diff --git a/source3/utils/eventlogadm.c b/source3/utils/eventlogadm.c index 7d40772423..fb0bc602cc 100644 --- a/source3/utils/eventlogadm.c +++ b/source3/utils/eventlogadm.c @@ -89,6 +89,7 @@ static int DoWriteCommand( int argc, char **argv, bool debugflag, char *exename bool is_eor; Eventlog_entry ee; int rcnum; + TALLOC_CTX *mem_ctx = talloc_tos(); f1 = stdin; if ( !f1 ) { @@ -122,7 +123,7 @@ static int DoWriteCommand( int argc, char **argv, bool debugflag, char *exename is_eor = False; - parse_logentry( ( char * ) &linein, &ee, &is_eor ); + parse_logentry( mem_ctx, ( char * ) &linein, &ee, &is_eor ); /* should we do something with the return code? */ if ( is_eor ) { -- cgit From 268f87df61dbf2625d33c149607db046f60dd5fd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 15 Jan 2009 15:32:18 +0100 Subject: eventlog: add eventlog_Record_tdb to support the traditional s3 on-disc format. Guenther --- librpc/idl/eventlog.idl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/librpc/idl/eventlog.idl b/librpc/idl/eventlog.idl index ccdca008c5..0826f59ed8 100644 --- a/librpc/idl/eventlog.idl +++ b/librpc/idl/eventlog.idl @@ -58,6 +58,38 @@ import "lsa.idl", "security.idl"; [value(size)] uint32 size2; } eventlog_Record; + /* compat structure for samba3 on-disc eventlog format, + this is *NOT* used on the wire. - gd */ + + typedef [flag(NDR_NOALIGN|NDR_PAHEX),public] struct { + uint32 size; + [charset(DOS),value("eLfL")] uint8 reserved[4]; + uint32 record_number; + time_t time_generated; + time_t time_written; + uint32 event_id; + eventlogEventTypes event_type; + [range(0,256)] uint16 num_of_strings; + uint16 event_category; + uint16 reserved_flags; + uint32 closing_record_number; + uint32 stringoffset; + [value(sid.length)] uint32 sid_length; + uint32 sid_offset; + [value(data.length)] uint32 data_length; + uint32 data_offset; + [value(2*strlen_m_term(source_name))] uint32 source_name_len; + nstring source_name; + [value(2*strlen_m_term(computer_name))] uint32 computer_name_len; + nstring computer_name; + uint32 sid_padding; + DATA_BLOB sid; + [value(2*ndr_size_string_array(strings, num_of_strings, STR_NULLTERM))] uint32 strings_len; + nstring strings[num_of_strings]; + DATA_BLOB data; + uint32 padding; + } eventlog_Record_tdb; + /******************/ /* Function: 0x00 */ NTSTATUS eventlog_ClearEventLogW( -- cgit From 1c627c22324fbb83de4c602cdbdd658ab53cde54 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 3 Feb 2009 15:55:46 +0100 Subject: s3: re-run make samba3-idl. Guenther --- librpc/gen_ndr/eventlog.h | 29 +++++++ librpc/gen_ndr/ndr_eventlog.c | 174 ++++++++++++++++++++++++++++++++++++++++++ librpc/gen_ndr/ndr_eventlog.h | 3 + 3 files changed, 206 insertions(+) diff --git a/librpc/gen_ndr/eventlog.h b/librpc/gen_ndr/eventlog.h index 8dc0d0d146..0c998a8a18 100644 --- a/librpc/gen_ndr/eventlog.h +++ b/librpc/gen_ndr/eventlog.h @@ -65,6 +65,35 @@ struct eventlog_Record { uint32_t size2;/* [value(size)] */ }/* [public,flag(LIBNDR_FLAG_NOALIGN)] */; +struct eventlog_Record_tdb { + uint32_t size; + const char *reserved;/* [value("eLfL"),charset(DOS)] */ + uint32_t record_number; + time_t time_generated; + time_t time_written; + uint32_t event_id; + enum eventlogEventTypes event_type; + uint16_t num_of_strings;/* [range(0,256)] */ + uint16_t event_category; + uint16_t reserved_flags; + uint32_t closing_record_number; + uint32_t stringoffset; + uint32_t sid_length;/* [value(sid.length)] */ + uint32_t sid_offset; + uint32_t data_length;/* [value(data.length)] */ + uint32_t data_offset; + uint32_t source_name_len;/* [value(2*strlen_m_term(source_name))] */ + const char * source_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ + uint32_t computer_name_len;/* [value(2*strlen_m_term(computer_name))] */ + const char * computer_name;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ + uint32_t sid_padding; + DATA_BLOB sid; + uint32_t strings_len;/* [value(2*ndr_size_string_array(strings,num_of_strings,LIBNDR_FLAG_STR_NULLTERM))] */ + const char * *strings;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ + DATA_BLOB data; + uint32_t padding; +}/* [public,flag(LIBNDR_FLAG_NOALIGN|LIBNDR_PRINT_ARRAY_HEX)] */; + struct EVENTLOG_FULL_INFORMATION { uint32_t full; }; diff --git a/librpc/gen_ndr/ndr_eventlog.c b/librpc/gen_ndr/ndr_eventlog.c index 938f0db8eb..a43b343aa7 100644 --- a/librpc/gen_ndr/ndr_eventlog.c +++ b/librpc/gen_ndr/ndr_eventlog.c @@ -287,6 +287,180 @@ _PUBLIC_ void ndr_print_eventlog_Record(struct ndr_print *ndr, const char *name, } } +_PUBLIC_ enum ndr_err_code ndr_push_eventlog_Record_tdb(struct ndr_push *ndr, int ndr_flags, const struct eventlog_Record_tdb *r) +{ + uint32_t cntr_strings_0; + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_PRINT_ARRAY_HEX); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size)); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, "eLfL", 4, sizeof(uint8_t), CH_DOS)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->record_number)); + NDR_CHECK(ndr_push_time_t(ndr, NDR_SCALARS, r->time_generated)); + NDR_CHECK(ndr_push_time_t(ndr, NDR_SCALARS, r->time_written)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->event_id)); + NDR_CHECK(ndr_push_eventlogEventTypes(ndr, NDR_SCALARS, r->event_type)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->num_of_strings)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->event_category)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->reserved_flags)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->closing_record_number)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->stringoffset)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->sid.length)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->sid_offset)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->data.length)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->data_offset)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 2 * strlen_m_term(r->source_name))); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->source_name)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 2 * strlen_m_term(r->computer_name))); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->computer_name)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->sid_padding)); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->sid)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 2 * ndr_size_string_array(r->strings, r->num_of_strings, LIBNDR_FLAG_STR_NULLTERM))); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + for (cntr_strings_0 = 0; cntr_strings_0 < r->num_of_strings; cntr_strings_0++) { + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->strings[cntr_strings_0])); + } + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->data)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->padding)); + } + if (ndr_flags & NDR_BUFFERS) { + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_eventlog_Record_tdb(struct ndr_pull *ndr, int ndr_flags, struct eventlog_Record_tdb *r) +{ + uint32_t cntr_strings_0; + TALLOC_CTX *_mem_save_strings_0; + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_PRINT_ARRAY_HEX); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->reserved, 4, sizeof(uint8_t), CH_DOS)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->record_number)); + NDR_CHECK(ndr_pull_time_t(ndr, NDR_SCALARS, &r->time_generated)); + NDR_CHECK(ndr_pull_time_t(ndr, NDR_SCALARS, &r->time_written)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->event_id)); + NDR_CHECK(ndr_pull_eventlogEventTypes(ndr, NDR_SCALARS, &r->event_type)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->num_of_strings)); + if (r->num_of_strings > 256) { + return ndr_pull_error(ndr, NDR_ERR_RANGE, "value out of range"); + } + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->event_category)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->reserved_flags)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->closing_record_number)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->stringoffset)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sid_length)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sid_offset)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->data_length)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->data_offset)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->source_name_len)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->source_name)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->computer_name_len)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->computer_name)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sid_padding)); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->sid)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->strings_len)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_PULL_ALLOC_N(ndr, r->strings, r->num_of_strings); + _mem_save_strings_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->strings, 0); + for (cntr_strings_0 = 0; cntr_strings_0 < r->num_of_strings; cntr_strings_0++) { + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->strings[cntr_strings_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_strings_0, 0); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->data)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->padding)); + } + if (ndr_flags & NDR_BUFFERS) { + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_eventlog_Record_tdb(struct ndr_print *ndr, const char *name, const struct eventlog_Record_tdb *r) +{ + uint32_t cntr_strings_0; + ndr_print_struct(ndr, name, "eventlog_Record_tdb"); + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN|LIBNDR_PRINT_ARRAY_HEX); + ndr->depth++; + ndr_print_uint32(ndr, "size", r->size); + ndr_print_string(ndr, "reserved", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?"eLfL":r->reserved); + ndr_print_uint32(ndr, "record_number", r->record_number); + ndr_print_time_t(ndr, "time_generated", r->time_generated); + ndr_print_time_t(ndr, "time_written", r->time_written); + ndr_print_uint32(ndr, "event_id", r->event_id); + ndr_print_eventlogEventTypes(ndr, "event_type", r->event_type); + ndr_print_uint16(ndr, "num_of_strings", r->num_of_strings); + ndr_print_uint16(ndr, "event_category", r->event_category); + ndr_print_uint16(ndr, "reserved_flags", r->reserved_flags); + ndr_print_uint32(ndr, "closing_record_number", r->closing_record_number); + ndr_print_uint32(ndr, "stringoffset", r->stringoffset); + ndr_print_uint32(ndr, "sid_length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?r->sid.length:r->sid_length); + ndr_print_uint32(ndr, "sid_offset", r->sid_offset); + ndr_print_uint32(ndr, "data_length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?r->data.length:r->data_length); + ndr_print_uint32(ndr, "data_offset", r->data_offset); + ndr_print_uint32(ndr, "source_name_len", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?2 * strlen_m_term(r->source_name):r->source_name_len); + ndr_print_string(ndr, "source_name", r->source_name); + ndr_print_uint32(ndr, "computer_name_len", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?2 * strlen_m_term(r->computer_name):r->computer_name_len); + ndr_print_string(ndr, "computer_name", r->computer_name); + ndr_print_uint32(ndr, "sid_padding", r->sid_padding); + ndr_print_DATA_BLOB(ndr, "sid", r->sid); + ndr_print_uint32(ndr, "strings_len", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?2 * ndr_size_string_array(r->strings, r->num_of_strings, LIBNDR_FLAG_STR_NULLTERM):r->strings_len); + ndr->print(ndr, "%s: ARRAY(%d)", "strings", (int)r->num_of_strings); + ndr->depth++; + for (cntr_strings_0=0;cntr_strings_0num_of_strings;cntr_strings_0++) { + char *idx_0=NULL; + if (asprintf(&idx_0, "[%d]", cntr_strings_0) != -1) { + ndr_print_string(ndr, "strings", r->strings[cntr_strings_0]); + free(idx_0); + } + } + ndr->depth--; + ndr_print_DATA_BLOB(ndr, "data", r->data); + ndr_print_uint32(ndr, "padding", r->padding); + ndr->depth--; + ndr->flags = _flags_save_STRUCT; + } +} + static enum ndr_err_code ndr_push_eventlog_ClearEventLogW(struct ndr_push *ndr, int flags, const struct eventlog_ClearEventLogW *r) { if (flags & NDR_IN) { diff --git a/librpc/gen_ndr/ndr_eventlog.h b/librpc/gen_ndr/ndr_eventlog.h index 3fa20e3a29..39bfd38665 100644 --- a/librpc/gen_ndr/ndr_eventlog.h +++ b/librpc/gen_ndr/ndr_eventlog.h @@ -70,6 +70,9 @@ void ndr_print_eventlog_OpenUnknown0(struct ndr_print *ndr, const char *name, co enum ndr_err_code ndr_push_eventlog_Record(struct ndr_push *ndr, int ndr_flags, const struct eventlog_Record *r); enum ndr_err_code ndr_pull_eventlog_Record(struct ndr_pull *ndr, int ndr_flags, struct eventlog_Record *r); void ndr_print_eventlog_Record(struct ndr_print *ndr, const char *name, const struct eventlog_Record *r); +enum ndr_err_code ndr_push_eventlog_Record_tdb(struct ndr_push *ndr, int ndr_flags, const struct eventlog_Record_tdb *r); +enum ndr_err_code ndr_pull_eventlog_Record_tdb(struct ndr_pull *ndr, int ndr_flags, struct eventlog_Record_tdb *r); +void ndr_print_eventlog_Record_tdb(struct ndr_print *ndr, const char *name, const struct eventlog_Record_tdb *r); void ndr_print_eventlog_ClearEventLogW(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_ClearEventLogW *r); void ndr_print_eventlog_BackupEventLogW(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_BackupEventLogW *r); void ndr_print_eventlog_CloseEventLog(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_CloseEventLog *r); -- cgit From cf3be5ce7a7f318cfb84baba4d1fc56ddd8f5497 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 15 Jan 2009 20:28:30 +0100 Subject: s3-eventlog: add evlog_pull_record_tdb function. Guenther --- source3/include/proto.h | 3 ++ source3/rpc_server/srv_eventlog_lib.c | 55 +++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/source3/include/proto.h b/source3/include/proto.h index 19d131cb63..bf4976ec49 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6263,6 +6263,9 @@ int elog_close_tdb( ELOG_TDB *etdb, bool force_close ); int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ); void fixup_eventlog_entry( Eventlog_entry * ee ); bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, bool * eor ); +struct eventlog_Record_tdb *evlog_pull_record_tdb(TALLOC_CTX *mem_ctx, + TDB_CONTEXT *tdb, + uint32_t record_number); /* The following definitions come from rpc_server/srv_eventlog_nt.c */ diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 2890dc9528..d6c4f1ab61 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -748,3 +748,58 @@ bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, bo } return true; } + +/******************************************************************** + ********************************************************************/ + +struct eventlog_Record_tdb *evlog_pull_record_tdb(TALLOC_CTX *mem_ctx, + TDB_CONTEXT *tdb, + uint32_t record_number) +{ + struct eventlog_Record_tdb *r; + TDB_DATA data, key; + + int32_t srecno; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + + srecno = record_number; + key.dptr = (unsigned char *)&srecno; + key.dsize = sizeof(int32_t); + + data = tdb_fetch(tdb, key); + if (data.dsize == 0) { + DEBUG(8,("evlog_pull_record_tdb: " + "Can't find a record for the key, record %d\n", + record_number)); + return NULL; + } + + r = talloc_zero(mem_ctx, struct eventlog_Record_tdb); + if (!r) { + goto done; + } + + blob = data_blob_const(data.dptr, data.dsize); + + ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL, r, + (ndr_pull_flags_fn_t)ndr_pull_eventlog_Record_tdb); + + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(10,("evlog_pull_record_tdb: failed to decode record %d\n", + record_number)); + TALLOC_FREE(r); + goto done; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_DEBUG(eventlog_Record_tdb, r); + } + + DEBUG(10,("evlog_pull_record_tdb: retrieved entry for record %d\n", + record_number)); + done: + SAFE_FREE(data.dptr); + + return r; +} -- cgit From c53e3bfa7d1854494cb144b099eded8860f92e2a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 22 Jan 2009 20:11:19 +0100 Subject: s3-eventlogadm: add command to dump stored tdb entries. Guenther --- source3/Makefile.in | 4 +++- source3/utils/eventlogadm.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/source3/Makefile.in b/source3/Makefile.in index 531f64f92f..992df5ecee 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -983,7 +983,9 @@ EVTLOGADM_OBJ0 = utils/eventlogadm.o EVTLOGADM_OBJ = $(EVTLOGADM_OBJ0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ $(LIBSAMBA_OBJ) \ - registry/reg_eventlog.o rpc_server/srv_eventlog_lib.o + registry/reg_eventlog.o rpc_server/srv_eventlog_lib.o \ + ../librpc/gen_ndr/ndr_eventlog.o \ + ../librpc/gen_ndr/ndr_lsa.o SHARESEC_OBJ0 = utils/sharesec.o SHARESEC_OBJ = $(SHARESEC_OBJ0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ diff --git a/source3/utils/eventlogadm.c b/source3/utils/eventlogadm.c index fb0bc602cc..b957ec2fab 100644 --- a/source3/utils/eventlogadm.c +++ b/source3/utils/eventlogadm.c @@ -37,6 +37,7 @@ static void usage( char *s ) printf( "\nUsage: %s [OPTION]\n\n", s ); printf( " -o write \t\t\t\t\tWrites records to eventlog from STDIN\n" ); printf( " -o addsource \tAdds the specified source & DLL eventlog registry entry\n" ); + printf( " -o dump \t\t\t\t\tDump stored eventlog entries on STDOUT\n" ); printf( "\nMiscellaneous options:\n" ); printf( " -d\t\t\t\t\t\t\t\tturn debug on\n" ); printf( " -h\t\t\t\t\t\t\t\tdisplay help\n\n" ); @@ -157,6 +158,54 @@ static int DoWriteCommand( int argc, char **argv, bool debugflag, char *exename return 0; } +static int DoDumpCommand(int argc, char **argv, bool debugflag, char *exename) +{ + ELOG_TDB *etdb; + TALLOC_CTX *mem_ctx = talloc_tos(); + const char *tdb_filename; + uint32_t count = 1; + + if (argc > 2) { + return -1; + } + + tdb_filename = argv[0]; + + if (argc > 1) { + count = atoi(argv[1]); + } + + etdb = elog_open_tdb(argv[0], false, true); + if (!etdb) { + printf("can't open the eventlog TDB (%s)\n", argv[0]); + return -1; + } + + while (1) { + + struct eventlog_Record_tdb *r; + char *s; + + r = evlog_pull_record_tdb(mem_ctx, etdb->tdb, count); + if (!r) { + break; + } + + printf("displaying record: %d\n", count); + + s = NDR_PRINT_STRUCT_STRING(mem_ctx, eventlog_Record_tdb, r); + if (s) { + printf("%s\n", s); + talloc_free(s); + } + count++; + } + + elog_close_tdb(etdb, false); + + return 0; +} + /* would be nice to use the popT stuff here, however doing so forces us to drag in a lot of other infrastructure */ int main( int argc, char *argv[] ) @@ -222,6 +271,10 @@ int main( int argc, char *argv[] ) rc = DoWriteCommand( argc, argv, opt_debug, exename ); break; } + if ( !StrCaseCmp( opname, "dump" ) ) { + rc = DoDumpCommand( argc, argv, opt_debug, exename ); + break; + } printf( "unknown command [%s]\n", opname ); usage( exename ); exit( 1 ); -- cgit From 63bb31e11812264aa377abdd4c256c46dde236b0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 22 Jan 2009 20:14:28 +0100 Subject: s3-docs: add documentation for dump option of eventlogadm. Guenther --- docs-xml/manpages-3/eventlogadm.8.xml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs-xml/manpages-3/eventlogadm.8.xml b/docs-xml/manpages-3/eventlogadm.8.xml index 51a066fc85..fa514de026 100644 --- a/docs-xml/manpages-3/eventlogadm.8.xml +++ b/docs-xml/manpages-3/eventlogadm.8.xml @@ -40,6 +40,18 @@ + + eventlogadm + + + + dump + EVENTLOG + RECORD_NUMBER + + + + @@ -96,6 +108,20 @@ + + + + write + EVENTLOG + RECORD_NUMBER + + + The -o dump reads event log + records from a EVENTLOG tdb and dumps them to standard + output on screen. + + + -- cgit From c3ab29265546a56377a22ddc67701871ea41262c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 3 Feb 2009 02:32:57 +0100 Subject: merged-build: force non-shared build for samba4 This should fix 'make test4'. metze --- source3/configure.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source3/configure.in b/source3/configure.in index 615ab9e19f..1a25de8992 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -6537,7 +6537,10 @@ fi if test x$enable_merged_build = xyes; then MERGED_BUILD=1 + saved_USESHARED="$USESHARED" + USESHARED="false" m4_include(samba4.m4) + USESHARED="$saved_USESHARED" fi AC_SUBST(ZLIB_LIBS) -- cgit From adc9d105cdce4500d16f86b39401ae3aa3b0cacd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 3 Feb 2009 16:10:52 +0100 Subject: merged-build: link in LIBREPLACE into samba4 code as in the native build metze --- source3/samba4-templates.mk | 8 ++++---- source3/samba4.m4 | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/source3/samba4-templates.mk b/source3/samba4-templates.mk index ecebce6d1d..0024a7531f 100644 --- a/source3/samba4-templates.mk +++ b/source3/samba4-templates.mk @@ -19,9 +19,9 @@ endef # Link a binary # Arguments: target file, depends, flags define binary_link_template -$(1)4: $(2) $(LIBREPLACE_OBJ) ; +$(1)4: $(2) ; @echo Linking $$@ - @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3) $$(LIBS) $$(LIBREPLACE_OBJ) + @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3) $$(LIBS) clean:: @rm -f $(1) @@ -32,9 +32,9 @@ endef # Link a host-machine binary # Arguments: target file, depends, flags define host_binary_link_template -$(1)4: $(2) $(LIBREPLACE_OBJ) ; +$(1)4: $(2) ; @echo Linking $$@ - @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3) $$(LIBREPLACE_OBJ) + @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3) clean:: rm -f $(1) diff --git a/source3/samba4.m4 b/source3/samba4.m4 index e2c754b02b..8107f816ad 100644 --- a/source3/samba4.m4 +++ b/source3/samba4.m4 @@ -19,6 +19,24 @@ AC_MSG_RESULT($pythondir) AC_SUBST(pythondir) +SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL} ${CRYPT_LIBS}]) +SMB_ENABLE(LIBREPLACE_EXT) + +SMB_EXT_LIB(LIBREPLACE_NETWORK, [${LIBREPLACE_NETWORK_LIBS}]) +SMB_ENABLE(LIBREPLACE_NETWORK) + +SMB_SUBSYSTEM(LIBREPLACE, + [${LIBREPLACE_OBJS}], + [LIBREPLACE_EXT LIBREPLACE_NETWORK], + [-I../lib/replace]) + +LIBREPLACE_HOSTCC_OBJS=`echo ${LIBREPLACE_OBJS} |sed -e 's/\.o/\.ho/g'` + +SMB_SUBSYSTEM(LIBREPLACE_HOSTCC, + [${LIBREPLACE_HOSTCC_OBJS}], + [], + [-I../lib/replace]) + m4_include(lib/smbreadline/readline.m4) m4_include(heimdal_build/internal.m4) m4_include(../lib/util/fault.m4) -- cgit From e2aab39e560dc395fe8aba53ffd6fc42b025aa36 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 3 Feb 2009 16:16:17 +0100 Subject: s4:lib/ldb: call ldb utils always via $VALGRIND ldbfoo$EXEEXT in the tests metze --- source4/lib/ldb/tests/test-extended.sh | 6 +-- source4/lib/ldb/tests/test-generic.sh | 68 +++++++++++++++--------------- source4/lib/ldb/tests/test-tdb-features.sh | 34 +++++++-------- source4/lib/ldb/tests/test-tdb.sh | 4 +- 4 files changed, 56 insertions(+), 56 deletions(-) diff --git a/source4/lib/ldb/tests/test-extended.sh b/source4/lib/ldb/tests/test-extended.sh index a84e3b78a3..14b988e3f9 100755 --- a/source4/lib/ldb/tests/test-extended.sh +++ b/source4/lib/ldb/tests/test-extended.sh @@ -4,7 +4,7 @@ echo "Running extended search tests" mv $LDB_URL $LDB_URL.1 -cat < /dev/null && { +$VALGRIND ldbadd$EXEEXT $LDBDIR/tests/test.ldif 2> /dev/null && { echo "Should have failed to add again - gave $?" exit 1 } echo "Modifying elements" -$VALGRIND ldbmodify $LDBDIR/tests/test-modify.ldif || exit 1 +$VALGRIND ldbmodify$EXEEXT $LDBDIR/tests/test-modify.ldif || exit 1 echo "Showing modified record" -$VALGRIND ldbsearch '(uid=uham)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(uid=uham)' || exit 1 echo "Rename entry" OLDDN="cn=Ursula Hampster,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST" NEWDN="cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST" -$VALGRIND ldbrename "$OLDDN" "$NEWDN" || exit 1 +$VALGRIND ldbrename$EXEEXT "$OLDDN" "$NEWDN" || exit 1 echo "Showing renamed record" -$VALGRIND ldbsearch '(uid=uham)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(uid=uham)' || exit 1 echo "Starting ldbtest" -$VALGRIND ldbtest --num-records 100 --num-searches 10 || exit 1 +$VALGRIND ldbtest$EXEEXT --num-records 100 --num-searches 10 || exit 1 if [ $LDB_SPECIALS = 1 ]; then echo "Adding index" - $VALGRIND ldbadd $LDBDIR/tests/test-index.ldif || exit 1 + $VALGRIND ldbadd$EXEEXT $LDBDIR/tests/test-index.ldif || exit 1 fi echo "Adding bad attributes - should fail" -$VALGRIND ldbadd $LDBDIR/tests/test-wrong_attributes.ldif && { +$VALGRIND ldbadd$EXEEXT $LDBDIR/tests/test-wrong_attributes.ldif && { echo "Should fhave failed - gave $?" exit 1 } echo "testing indexed search" -$VALGRIND ldbsearch '(uid=uham)' || exit 1 -$VALGRIND ldbsearch '(&(objectclass=person)(objectclass=person)(objectclass=top))' || exit 1 -$VALGRIND ldbsearch '(&(uid=uham)(uid=uham))' || exit 1 -$VALGRIND ldbsearch '(|(uid=uham)(uid=uham))' || exit 1 -$VALGRIND ldbsearch '(|(uid=uham)(uid=uham)(objectclass=OpenLDAPperson))' || exit 1 -$VALGRIND ldbsearch '(&(uid=uham)(uid=uham)(!(objectclass=xxx)))' || exit 1 -$VALGRIND ldbsearch '(&(objectclass=person)(uid=uham)(!(uid=uhamxx)))' uid \* \+ dn || exit 1 -$VALGRIND ldbsearch '(&(uid=uham)(uid=uha*)(title=*))' uid || exit 1 +$VALGRIND ldbsearch$EXEEXT '(uid=uham)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(&(objectclass=person)(objectclass=person)(objectclass=top))' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(&(uid=uham)(uid=uham))' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(|(uid=uham)(uid=uham))' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(|(uid=uham)(uid=uham)(objectclass=OpenLDAPperson))' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(&(uid=uham)(uid=uham)(!(objectclass=xxx)))' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(&(objectclass=person)(uid=uham)(!(uid=uhamxx)))' uid \* \+ dn || exit 1 +$VALGRIND ldbsearch$EXEEXT '(&(uid=uham)(uid=uha*)(title=*))' uid || exit 1 # note that the "((" is treated as an attribute not an expression # this matches the openldap ldapsearch behaviour of looking for a '=' # to see if the first argument is an expression or not -$VALGRIND ldbsearch '((' uid || exit 1 -$VALGRIND ldbsearch '(objectclass=)' uid || exit 1 -$VALGRIND ldbsearch -b 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' -s base "" sn || exit 1 +$VALGRIND ldbsearch$EXEEXT '((' uid || exit 1 +$VALGRIND ldbsearch$EXEEXT '(objectclass=)' uid || exit 1 +$VALGRIND ldbsearch$EXEEXT -b 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' -s base "" sn || exit 1 echo "Test wildcard match" -$VALGRIND ldbadd $LDBDIR/tests/test-wildcard.ldif || exit 1 -$VALGRIND ldbsearch '(cn=test*multi)' || exit 1 -$VALGRIND ldbsearch '(cn=*test*multi*)' || exit 1 -$VALGRIND ldbsearch '(cn=*test_multi)' || exit 1 -$VALGRIND ldbsearch '(cn=test_multi*)' || exit 1 -$VALGRIND ldbsearch '(cn=test*multi*test*multi)' || exit 1 -$VALGRIND ldbsearch '(cn=test*multi*test*multi*multi_*)' || exit 1 +$VALGRIND ldbadd$EXEEXT $LDBDIR/tests/test-wildcard.ldif || exit 1 +$VALGRIND ldbsearch$EXEEXT '(cn=test*multi)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(cn=*test*multi*)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(cn=*test_multi)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(cn=test_multi*)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(cn=test*multi*test*multi)' || exit 1 +$VALGRIND ldbsearch$EXEEXT '(cn=test*multi*test*multi*multi_*)' || exit 1 echo "Starting ldbtest indexed" -$VALGRIND ldbtest --num-records 100 --num-searches 500 || exit 1 +$VALGRIND ldbtest$EXEEXT --num-records 100 --num-searches 500 || exit 1 echo "Testing one level search" -count=`$VALGRIND ldbsearch -b 'ou=Groups,o=University of Michigan,c=TEST' -s one 'objectclass=*' none |grep '^dn' | wc -l` +count=`$VALGRIND ldbsearch$EXEEXT -b 'ou=Groups,o=University of Michigan,c=TEST' -s one 'objectclass=*' none |grep '^dn' | wc -l` if [ $count != 3 ]; then echo returned $count records - expected 3 exit 1 @@ -83,8 +83,8 @@ fi echo "Testing binary file attribute value" mkdir -p tests/tmp cp $LDBDIR/tests/samba4.png tests/tmp/samba4.png -$VALGRIND ldbmodify $LDBDIR/tests/photo.ldif || exit 1 -count=`$VALGRIND ldbsearch '(cn=Hampster Ursula)' jpegPhoto | grep '^dn' | wc -l` +$VALGRIND ldbmodify$EXEEXT $LDBDIR/tests/photo.ldif || exit 1 +count=`$VALGRIND ldbsearch$EXEEXT '(cn=Hampster Ursula)' jpegPhoto | grep '^dn' | wc -l` if [ $count != 1 ]; then echo returned $count records - expected 1 exit 1 @@ -94,13 +94,13 @@ rm -f tests/tmp/samba4.png echo "*TODO* Testing UTF8 upper lower case searches !!" echo "Testing compare" -count=`$VALGRIND ldbsearch '(cn>=t)' cn | grep '^dn' | wc -l` +count=`$VALGRIND ldbsearch$EXEEXT '(cn>=t)' cn | grep '^dn' | wc -l` if [ $count != 2 ]; then echo returned $count records - expected 2 echo "this fails on openLdap ..." fi -count=`$VALGRIND ldbsearch '(cn<=t)' cn | grep '^dn' | wc -l` +count=`$VALGRIND ldbsearch$EXEEXT '(cn<=t)' cn | grep '^dn' | wc -l` if [ $count != 13 ]; then echo returned $count records - expected 13 echo "this fails on openLdap ..." @@ -111,7 +111,7 @@ checkcount() { scope=$2 basedn=$3 expression="$4" - n=`bin/ldbsearch -s "$scope" -b "$basedn" "$expression" | grep '^dn' | wc -l` + n=`$VALGRIND ldbsearch$EXEEXT -s "$scope" -b "$basedn" "$expression" | grep '^dn' | wc -l` if [ $n != $count ]; then echo "Got $n but expected $count for $expression" bin/ldbsearch "$expression" diff --git a/source4/lib/ldb/tests/test-tdb-features.sh b/source4/lib/ldb/tests/test-tdb-features.sh index fc0959c54a..d4248366ca 100644 --- a/source4/lib/ldb/tests/test-tdb-features.sh +++ b/source4/lib/ldb/tests/test-tdb-features.sh @@ -7,17 +7,17 @@ mv $LDB_URL $LDB_URL.2 checkcount() { count=$1 expression="$2" - n=`bin/ldbsearch "$expression" | grep '^dn' | wc -l` + n=`$VALGRIND ldbsearch$EXEEXT "$expression" | grep '^dn' | wc -l` if [ $n != $count ]; then echo "Got $n but expected $count for $expression" - $VALGRIND bin/ldbsearch "$expression" + $VALGRIND ldbsearch$EXEEXT "$expression" exit 1 fi echo "OK: $count $expression" } echo "Testing case sensitive search" -cat < Date: Tue, 3 Feb 2009 16:19:46 +0100 Subject: selftest: export BUILDDIR, BUILDDIR_ABS and EXEEXT metze --- selftest/selftest.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/selftest/selftest.pl b/selftest/selftest.pl index f6561cc8c7..0be2e78de3 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -394,6 +394,7 @@ mkdir($prefix, 0777) unless -d $prefix; my $prefix_abs = abs_path($prefix); my $srcdir_abs = abs_path($srcdir); +my $builddir_abs = abs_path($builddir); die("using an empty absolute prefix isn't allowed") unless $prefix_abs ne ""; die("using '/' as absolute prefix isn't allowed") unless $prefix_abs ne "/"; @@ -403,6 +404,9 @@ $ENV{KRB5CCNAME} = "$prefix/krb5ticket"; $ENV{PREFIX_ABS} = $prefix_abs; $ENV{SRCDIR} = $srcdir; $ENV{SRCDIR_ABS} = $srcdir_abs; +$ENV{BUILDDIR} = $builddir; +$ENV{BUILDDIR_ABS} = $builddir_abs; +$ENV{EXEEXT} = $exeext; if (defined($ENV{RUN_FROM_BUILD_FARM}) and ($ENV{RUN_FROM_BUILD_FARM} eq "yes")) { -- cgit From a5f9816263b67d87a62bb7e18aa10a7b0ba44794 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 3 Feb 2009 16:20:24 +0100 Subject: selftest: don't use hardcoded path to nmblookup in Samba4.pm metze --- selftest/target/Samba4.pm | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index 5ca1a6a305..0f7d317ea1 100644 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -159,18 +159,19 @@ sub wait_for_start($$) # This will return quickly when things are up, but be slow if we # need to wait for (eg) SSL init - system("bin/nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSALIAS}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSALIAS}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSALIAS}"); - system("bin/nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSALIAS}"); + my $nmblookup = $self->bindir_path("nmblookup"); + system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}"); + system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}"); + system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}"); + system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}"); + system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSALIAS}"); + system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSALIAS}"); + system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}"); + system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}"); + system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}"); + system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSNAME}"); + system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSALIAS}"); + system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{NETBIOSALIAS}"); print $self->getlog_env($testenv_vars); } -- cgit From 7c72853b50b14653fe3c62fde3bf653b45c755f8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 3 Feb 2009 16:21:54 +0100 Subject: s4:selftest: don't use hardcoded pathes metze --- source4/selftest/tests.sh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/source4/selftest/tests.sh b/source4/selftest/tests.sh index 2acd376d01..36e3bbe364 100755 --- a/source4/selftest/tests.sh +++ b/source4/selftest/tests.sh @@ -54,11 +54,13 @@ plansmbtorturetest() { plantest "$modname" "$env" $cmdline } -samba4srcdir=. -samba4bindir=$samba4srcdir/bin +samba4srcdir="`dirname $0`/.." +samba4bindir="$BUILDDIR/bin" smb4torture="$samba4bindir/smbtorture${EXEEXT}" $smb4torture -V +bbdir=../testprogs/blackbox + prefix_abs="$SELFTEST_PREFIX/s4client" CONFIGURATION="--configfile=\$SMB_CONF_PATH" @@ -83,15 +85,15 @@ echo "OPTIONS $TORTURE_OPTIONS" # Simple tests for LDAP and CLDAP for options in "" "--option=socket:testnonblock=true" "-U\$USERNAME%\$PASSWORD --option=socket:testnonblock=true" "-U\$USERNAME%\$PASSWORD"; do - plantest "ldb.ldap with options $options" dc $samba4srcdir/../testprogs/blackbox/test_ldb.sh ldap \$SERVER_IP $options + plantest "ldb.ldap with options $options" dc $bbdir/test_ldb.sh ldap \$SERVER_IP $options done # see if we support ldaps if grep ENABLE_GNUTLS.1 include/config.h > /dev/null; then for options in "" "-U\$USERNAME%\$PASSWORD"; do - plantest "ldb.ldaps with options $options" dc $samba4srcdir/../testprogs/blackbox/test_ldb.sh ldaps \$SERVER_IP $options + plantest "ldb.ldaps with options $options" dc $bbdir/test_ldb.sh ldaps \$SERVER_IP $options done fi -plantest "ldb.ldapi with options $options" dc $samba4srcdir/../testprogs/blackbox/test_ldb.sh ldapi \$PREFIX_ABS/dc/private/ldapi $options +plantest "ldb.ldapi with options $options" dc $bbdir/test_ldb.sh ldapi \$PREFIX_ABS/dc/private/ldapi $options for t in LDAP-CLDAP LDAP-BASIC LDAP-SCHEMA LDAP-UPTODATEVECTOR do plansmbtorturetest "$t" dc "-U\$USERNAME%\$PASSWORD" //\$SERVER_IP/_none_ @@ -295,8 +297,6 @@ fi # the API. These mainly test that the various command-line options of commands # work correctly. -bbdir=../testprogs/blackbox - plantest "blackbox.ndrdump" none $samba4srcdir/librpc/tests/test_ndrdump.sh plantest "blackbox.net" dc $samba4srcdir/utils/tests/test_net.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" plantest "blackbox.kinit" dc $bbdir/test_kinit.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$REALM" "\$DOMAIN" "$PREFIX" $CONFIGURATION @@ -395,14 +395,14 @@ then fi PYTHON=/usr/bin/python -SUBUNITRUN="$PYTHON ./scripting/bin/subunitrun" -plantest "ldb.python" none PYTHONPATH="$PYTHONPATH:lib/ldb/tests/python/" $SUBUNITRUN api -plantest "credentials.python" none PYTHONPATH="$PYTHONPATH:auth/credentials/tests" $SUBUNITRUN bindings -plantest "registry.python" none PYTHONPATH="$PYTHONPATH:lib/registry/tests/" $SUBUNITRUN bindings +SUBUNITRUN="$VALGRIND $PYTHON $samba4srcdir/scripting/bin/subunitrun" +plantest "ldb.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/lib/ldb/tests/python/" $SUBUNITRUN api +plantest "credentials.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/auth/credentials/tests" $SUBUNITRUN bindings +plantest "registry.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/lib/registry/tests/" $SUBUNITRUN bindings plantest "tdb.python" none PYTHONPATH="$PYTHONPATH:../lib/tdb/python/tests" $SUBUNITRUN simple -plantest "auth.python" none PYTHONPATH="$PYTHONPATH:auth/tests/" $SUBUNITRUN bindings -plantest "security.python" none PYTHONPATH="$PYTHONPATH:libcli/security/tests" $SUBUNITRUN bindings -plantest "param.python" none PYTHONPATH="$PYTHONPATH:param/tests" $SUBUNITRUN bindings +plantest "auth.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/auth/tests/" $SUBUNITRUN bindings +plantest "security.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/libcli/security/tests" $SUBUNITRUN bindings +plantest "param.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/param/tests" $SUBUNITRUN bindings plantest "upgrade.python" none $SUBUNITRUN samba.tests.upgrade plantest "samba.python" none $SUBUNITRUN samba.tests plantest "provision.python" none $SUBUNITRUN samba.tests.provision @@ -412,15 +412,15 @@ plantest "dcerpc.bare.python" dc:local $SUBUNITRUN samba.tests.dcerpc.bare plantest "unixinfo.python" dc:local $SUBUNITRUN samba.tests.dcerpc.unix plantest "samdb.python" none $SUBUNITRUN samba.tests.samdb plantest "tevent.python" none PYTHONPATH="$PYTHONPATH:../lib/tevent" $SUBUNITRUN tests -plantest "messaging.python" none PYTHONPATH="$PYTHONPATH:lib/messaging/tests" $SUBUNITRUN bindings -plantest "samba3sam.python" none PYTHONPATH="$PYTHONPATH:dsdb/samdb/ldb_modules/tests" $SUBUNITRUN samba3sam +plantest "messaging.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/lib/messaging/tests" $SUBUNITRUN bindings +plantest "samba3sam.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/dsdb/samdb/ldb_modules/tests" $SUBUNITRUN samba3sam plantest "subunit.python" none $SUBUNITRUN subunit plantest "rpcecho.python" dc:local $SUBUNITRUN samba.tests.dcerpc.rpcecho plantest "winreg.python" dc:local $SUBUNITRUN -U\$USERNAME%\$PASSWORD samba.tests.dcerpc.registry plantest "ldap.python" dc $PYTHON $samba4srcdir/lib/ldb/tests/python/ldap.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN -plantest "blackbox.samba3dump" none $PYTHON scripting/bin/samba3dump $samba4srcdir/../testdata/samba3 +plantest "blackbox.samba3dump" none $PYTHON $samba4srcdir/scripting/bin/samba3dump $samba4srcdir/../testdata/samba3 rm -rf $PREFIX/upgrade -plantest "blackbox.upgrade" none $PYTHON setup/upgrade $CONFIGURATION --targetdir=$PREFIX/upgrade ../testdata/samba3 ../testdata/samba3/smb.conf +plantest "blackbox.upgrade" none $PYTHON $samba4srcdir/setup/upgrade $CONFIGURATION --targetdir=$PREFIX/upgrade $samba4srcdir/../testdata/samba3 ../testdata/samba3/smb.conf rm -rf $PREFIX/provision mkdir $PREFIX/provision plantest "blackbox.provision.py" none PYTHON="$PYTHON" $samba4srcdir/setup/tests/blackbox_provision.sh "$PREFIX/provision" -- cgit From 8b408f781970b3f2b310389f9ae73ad0c5e42881 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 3 Feb 2009 16:23:13 +0100 Subject: s4:selftest: avoid hardcoded pathes in blackbox tests metze --- nsswitch/tests/test_wbinfo.sh | 4 +-- source4/client/tests/test_cifsdd.sh | 4 +-- source4/client/tests/test_smbclient.sh | 4 +-- source4/librpc/tests/test_ndrdump.sh | 4 +-- source4/torture/tests/test_gentest.sh | 4 +-- source4/torture/tests/test_locktest.sh | 4 +-- source4/torture/tests/test_masktest.sh | 4 +-- source4/utils/tests/test_net.sh | 7 +++--- source4/utils/tests/test_nmblookup.sh | 15 +++++++----- testprogs/blackbox/test_kinit.sh | 22 +++++++++-------- testprogs/blackbox/test_ldb.sh | 45 ++++++++++++++++++---------------- 11 files changed, 63 insertions(+), 54 deletions(-) diff --git a/nsswitch/tests/test_wbinfo.sh b/nsswitch/tests/test_wbinfo.sh index 84876e35d1..2e94c24640 100755 --- a/nsswitch/tests/test_wbinfo.sh +++ b/nsswitch/tests/test_wbinfo.sh @@ -14,8 +14,8 @@ TARGET=$4 shift 4 failed=0 -samba4bindir=`dirname $0`/../../source4/bin -wbinfo=$samba4bindir/wbinfo +samba4bindir="$BUILDDIR/bin" +wbinfo="$samba4bindir/wbinfo$EXEEXT" . `dirname $0`/../../testprogs/blackbox/subunit.sh diff --git a/source4/client/tests/test_cifsdd.sh b/source4/client/tests/test_cifsdd.sh index 08bfb25e80..2268b6a091 100755 --- a/source4/client/tests/test_cifsdd.sh +++ b/source4/client/tests/test_cifsdd.sh @@ -16,8 +16,8 @@ DOMAIN=$4 . `dirname $0`/../../../testprogs/blackbox/subunit.sh -samba4bindir=`dirname $0`/../../bin -DD=$samba4bindir/cifsdd +samba4bindir="$BUILDDIR/bin" +DD="$samba4bindir/cifsdd$EXEEXT" SHARE=tmp DEBUGLEVEL=1 diff --git a/source4/client/tests/test_smbclient.sh b/source4/client/tests/test_smbclient.sh index 7ff03ba6e2..7775422e33 100755 --- a/source4/client/tests/test_smbclient.sh +++ b/source4/client/tests/test_smbclient.sh @@ -18,8 +18,8 @@ PREFIX=$5 shift 5 failed=0 -samba4bindir=`dirname $0`/../../bin -smbclient=$samba4bindir/smbclient +samba4bindir="$BUILDDIR/bin" +smbclient="$samba4bindir/smbclient$EXEEXT" . `dirname $0`/../../../testprogs/blackbox/subunit.sh diff --git a/source4/librpc/tests/test_ndrdump.sh b/source4/librpc/tests/test_ndrdump.sh index 511856061c..dccf86df88 100755 --- a/source4/librpc/tests/test_ndrdump.sh +++ b/source4/librpc/tests/test_ndrdump.sh @@ -8,8 +8,8 @@ failed=0 -samba4bindir=`dirname $0`/../../bin -ndrdump=$samba4bindir/ndrdump +samba4bindir="$BUILDDIR/bin" +ndrdump="$samba4bindir/ndrdump$EXEEXT" files=`dirname $0`/ testit "ndrdump with in" $VALGRIND $ndrdump samr samr_CreateUser in $files/samr-CreateUser-in.dat $@ || failed=`expr $failed + 1` diff --git a/source4/torture/tests/test_gentest.sh b/source4/torture/tests/test_gentest.sh index 2f4d00dc77..c7f66c8445 100755 --- a/source4/torture/tests/test_gentest.sh +++ b/source4/torture/tests/test_gentest.sh @@ -17,8 +17,8 @@ DOMAIN=$4 shift 4 failed=0 -samba4bindir=`dirname $0`/../../bin -gentest=$samba4bindir/gentest +samba4bindir="$BUILDDIR/bin" +gentest="$samba4bindir/gentest$EXEEXT" . `dirname $0`/../../../testprogs/blackbox/subunit.sh diff --git a/source4/torture/tests/test_locktest.sh b/source4/torture/tests/test_locktest.sh index 1fe39b4d1d..a8f11ee0ba 100755 --- a/source4/torture/tests/test_locktest.sh +++ b/source4/torture/tests/test_locktest.sh @@ -18,8 +18,8 @@ PREFIX=$5 shift 5 failed=0 -samba4bindir=`dirname $0`/../../bin -locktest=$samba4bindir/locktest +samba4bindir="$BUILDDIR/bin" +locktest="$samba4bindir/locktest$EXEEXT" . `dirname $0`/../../../testprogs/blackbox/subunit.sh diff --git a/source4/torture/tests/test_masktest.sh b/source4/torture/tests/test_masktest.sh index 59165e47df..e4fa65ccfb 100755 --- a/source4/torture/tests/test_masktest.sh +++ b/source4/torture/tests/test_masktest.sh @@ -18,8 +18,8 @@ PREFIX=$5 shift 5 failed=0 -samba4bindir=`dirname $0`/../../bin -masktest=$samba4bindir/masktest +samba4bindir="$BUILDDIR/bin" +masktest="$samba4bindir/masktest$EXEEXT" . `dirname $0`/../../../testprogs/blackbox/subunit.sh diff --git a/source4/utils/tests/test_net.sh b/source4/utils/tests/test_net.sh index 3406c87cda..eb598bf5e1 100755 --- a/source4/utils/tests/test_net.sh +++ b/source4/utils/tests/test_net.sh @@ -9,8 +9,9 @@ shift 4 failed=0 -samba4bindir=`dirname $0`/../../bin -smbclient=$samba4bindir/smbclient +samba4bindir="$BUILDDIR/bin" +smbclient="$samba4bindir/smbclient$EXEEXT" +net="$samba4bindir/net$EXEEXT" testit() { name="$1" @@ -28,7 +29,7 @@ testit() { return $status } -testit "domain join" $VALGRIND bin/net join $DOMAIN $CONFIGURATION -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1` +testit "domain join" $VALGRIND $net join $DOMAIN $CONFIGURATION -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1` testit "Test login with --machine-pass without kerberos" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER/tmp --machine-pass -k no || failed=`expr $failed + 1` diff --git a/source4/utils/tests/test_nmblookup.sh b/source4/utils/tests/test_nmblookup.sh index ad9b3ba799..e2230e162f 100755 --- a/source4/utils/tests/test_nmblookup.sh +++ b/source4/utils/tests/test_nmblookup.sh @@ -26,11 +26,14 @@ testit() { return $status } -testit "nmblookup -U \$SERVER_IP \$SERVER" bin/nmblookup $TORTURE_OPTIONS -U $SERVER_IP $SERVER -testit "nmblookup -U \$SERVER_IP \$NETBIOSNAME" bin/nmblookup $TORTURE_OPTIONS -U $SERVER_IP $NETBIOSNAME -testit "nmblookup -U \$SERVER_IP \$NETBIOSALIAS" bin/nmblookup $TORTURE_OPTIONS -U $SERVER_IP $NETBIOSALIAS -testit "nmblookup \$SERVER" bin/nmblookup $TORTURE_OPTIONS $SERVER -testit "nmblookup \$NETBIOSNAME" bin/nmblookup $TORTURE_OPTIONS $NETBIOSNAME -testit "nmblookup \$NETBIOSALIAS" bin/nmblookup $TORTURE_OPTIONS $NETBIOSALIAS +samba4bindir="$BUILDDIR/bin" +nmblookup="$samba4bindir/nmblookup$EXEEXT" + +testit "nmblookup -U \$SERVER_IP \$SERVER" $nmblookup $TORTURE_OPTIONS -U $SERVER_IP $SERVER +testit "nmblookup -U \$SERVER_IP \$NETBIOSNAME" $nmblookup $TORTURE_OPTIONS -U $SERVER_IP $NETBIOSNAME +testit "nmblookup -U \$SERVER_IP \$NETBIOSALIAS" $nmblookup $TORTURE_OPTIONS -U $SERVER_IP $NETBIOSALIAS +testit "nmblookup \$SERVER" $nmblookup $TORTURE_OPTIONS $SERVER +testit "nmblookup \$NETBIOSNAME" $nmblookup $TORTURE_OPTIONS $NETBIOSNAME +testit "nmblookup \$NETBIOSALIAS" $nmblookup $TORTURE_OPTIONS $NETBIOSALIAS exit $failed diff --git a/testprogs/blackbox/test_kinit.sh b/testprogs/blackbox/test_kinit.sh index 90e3d37453..b19edfbb38 100755 --- a/testprogs/blackbox/test_kinit.sh +++ b/testprogs/blackbox/test_kinit.sh @@ -19,10 +19,12 @@ PREFIX=$6 shift 6 failed=0 -samba4bindir=`dirname $0`/../../source4/bin -smbclient=$samba4bindir/smbclient -samba4kinit=$samba4bindir/samba4kinit -net=$samba4bindir/net +samba4bindir="$BUILDDIR/bin" +smbclient="$samba4bindir/smbclient$EXEEXT" +samba4kinit="$samba4bindir/samba4kinit$EXEEXT" +net="$samba4bindir/net$EXEEXT" +rkpty="$samba4bindir/rkpty$EXEEXT" +samba4kpasswd="$samba4bindir/samba4kpasswd$EXEEXT" enableaccount="$PYTHON `dirname $0`/../../source4/setup/enableaccount" . `dirname $0`/subunit.sh @@ -68,7 +70,7 @@ testit "enable user with kerberos cache" $VALGRIND $enableaccount nettestuser -H KRB5CCNAME="$PREFIX/tmpuserccache" export KRB5CCNAME -testit "kinit with user password" $samba4bindir/samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1` +testit "kinit with user password" $samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1` test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1` @@ -76,7 +78,7 @@ NEWUSERPASS=testPaSS@34% testit "change user password with 'net password change' (rpc)" $VALGRIND $net password change -W$DOMAIN -U$DOMAIN\\nettestuser%$USERPASS $CONFIGURATION -k no $NEWUSERPASS $@ || failed=`expr $failed + 1` echo $NEWUSERPASS > ./tmpuserpassfile -testit "kinit with user password" $samba4bindir/samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1` +testit "kinit with user password" $samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1` test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1` @@ -95,9 +97,9 @@ send ${NEWUSERPASS}\n expect Success EOF -testit "change user password with kpasswd" $samba4bindir/rkpty ./tmpkpasswdscript $samba4bindir/samba4kpasswd nettestuser@$REALM || failed=`expr $failed + 1` +testit "change user password with kpasswd" $rkpty ./tmpkpasswdscript $samba4kpasswd nettestuser@$REALM || failed=`expr $failed + 1` -testit "kinit with user password" $samba4bindir/samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1` +testit "kinit with user password" $samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1` NEWUSERPASS=testPaSS@78% echo $NEWUSERPASS > ./tmpuserpassfile @@ -112,9 +114,9 @@ send ${NEWUSERPASS}\n expect Success EOF -testit "set user password with kpasswd" $samba4bindir/rkpty ./tmpkpasswdscript $samba4bindir/samba4kpasswd --cache=$PREFIX/tmpccache nettestuser@$REALM || failed=`expr $failed + 1` +testit "set user password with kpasswd" $rkpty ./tmpkpasswdscript $samba4kpasswd --cache=$PREFIX/tmpccache nettestuser@$REALM || failed=`expr $failed + 1` -testit "kinit with user password" $samba4bindir/samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1` +testit "kinit with user password" $samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1` test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1` diff --git a/testprogs/blackbox/test_ldb.sh b/testprogs/blackbox/test_ldb.sh index 042457e9e3..e301b5485a 100755 --- a/testprogs/blackbox/test_ldb.sh +++ b/testprogs/blackbox/test_ldb.sh @@ -32,19 +32,22 @@ check() { return $status } -check "RootDSE" bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x dnsHostName highestCommittedUSN || failed=`expr $failed + 1` + +ldbsearch="$BUILDDIR/bin/ldbsearch$EXEEXT" + +check "RootDSE" $ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x dnsHostName highestCommittedUSN || failed=`expr $failed + 1` echo "Getting defaultNamingContext" -BASEDN=`bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x defaultNamingContext | grep defaultNamingContext | awk '{print $2}'` +BASEDN=`$ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x defaultNamingContext | grep defaultNamingContext | awk '{print $2}'` echo "BASEDN is $BASEDN" -check "Listing Users" bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed=`expr $failed + 1` +check "Listing Users" $ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed=`expr $failed + 1` -check "Listing Users (sorted)" bin/ldbsearch -S $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed=`expr $failed + 1` +check "Listing Users (sorted)" $ldbsearch -S $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed=`expr $failed + 1` -check "Listing Groups" bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=group)' sAMAccountName || failed=`expr $failed + 1` +check "Listing Groups" $ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=group)' sAMAccountName || failed=`expr $failed + 1` -nentries=`bin/ldbsearch $options -H $p://$SERVER $CONFIGURATION '(|(|(&(!(groupType:1.2.840.113556.1.4.803:=1))(groupType:1.2.840.113556.1.4.803:=2147483648)(groupType:1.2.840.113556.1.4.804:=10))(samAccountType=805306368))(samAccountType=805306369))' sAMAccountName | grep sAMAccountName | wc -l` +nentries=`$ldbsearch $options -H $p://$SERVER $CONFIGURATION '(|(|(&(!(groupType:1.2.840.113556.1.4.803:=1))(groupType:1.2.840.113556.1.4.803:=2147483648)(groupType:1.2.840.113556.1.4.804:=10))(samAccountType=805306368))(samAccountType=805306369))' sAMAccountName | grep sAMAccountName | wc -l` echo "Found $nentries entries" if [ $nentries -lt 10 ]; then echo "Should have found at least 10 entries" @@ -52,66 +55,66 @@ failed=`expr $failed + 1` fi echo "Check rootDSE for Controls" -nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER -s base -b "" '(objectclass=*)' | grep -i supportedControl | wc -l` +nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER -s base -b "" '(objectclass=*)' | grep -i supportedControl | wc -l` if [ $nentries -lt 4 ]; then echo "Should have found at least 4 entries" failed=`expr $failed + 1` fi echo "Test Paged Results Control" -nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=paged_results:1:5 '(objectclass=user)' | grep sAMAccountName | wc -l` +nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=paged_results:1:5 '(objectclass=user)' | grep sAMAccountName | wc -l` if [ $nentries -lt 1 ]; then echo "Paged Results Control test returned 0 items" failed=`expr $failed + 1` fi echo "Test Server Sort Control" -nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=server_sort:1:0:sAMAccountName '(objectclass=user)' | grep sAMAccountName | wc -l` +nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=server_sort:1:0:sAMAccountName '(objectclass=user)' | grep sAMAccountName | wc -l` if [ $nentries -lt 1 ]; then echo "Server Sort Control test returned 0 items" failed=`expr $failed + 1` fi echo "Test Extended DN Control" -nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1 '(objectclass=user)' | grep sAMAccountName | wc -l` +nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1 '(objectclass=user)' | grep sAMAccountName | wc -l` if [ $nentries -lt 1 ]; then echo "Extended DN Control test returned 0 items" failed=`expr $failed + 1` fi -nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:0 '(objectclass=user)' | grep sAMAccountName | wc -l` +nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:0 '(objectclass=user)' | grep sAMAccountName | wc -l` if [ $nentries -lt 1 ]; then echo "Extended DN Control test returned 0 items" failed=`expr $failed + 1` fi -nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:1 '(objectclass=user)' | grep sAMAccountName | wc -l` +nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:1 '(objectclass=user)' | grep sAMAccountName | wc -l` if [ $nentries -lt 1 ]; then echo "Extended DN Control test returned 0 items" failed=`expr $failed + 1` fi echo "Test Domain scope Control" -nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=domain_scope:1 '(objectclass=user)' | grep sAMAccountName | wc -l` +nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=domain_scope:1 '(objectclass=user)' | grep sAMAccountName | wc -l` if [ $nentries -lt 1 ]; then echo "Extended Domain scope Control test returned 0 items" failed=`expr $failed + 1` fi echo "Test Attribute Scope Query Control" -nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=asq:1:member -s base -b "CN=Administrators,CN=Builtin,$BASEDN" | grep sAMAccountName | wc -l` +nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=asq:1:member -s base -b "CN=Administrators,CN=Builtin,$BASEDN" | grep sAMAccountName | wc -l` if [ $nentries -lt 1 ]; then echo "Attribute Scope Query test returned 0 items" failed=`expr $failed + 1` fi echo "Test Search Options Control" -nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=search_options:1:2 '(objectclass=crossRef)' | grep crossRef | wc -l` +nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=search_options:1:2 '(objectclass=crossRef)' | grep crossRef | wc -l` if [ $nentries -lt 1 ]; then echo "Search Options Control Query test returned 0 items" failed=`expr $failed + 1` fi echo "Test Search Options Control with Domain Scope Control" -nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=search_options:1:2,domain_scope:1 '(objectclass=crossRef)' | grep crossRef | wc -l` +nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=search_options:1:2,domain_scope:1 '(objectclass=crossRef)' | grep crossRef | wc -l` if [ $nentries -lt 1 ]; then echo "Search Options Control Query test returned 0 items" failed=`expr $failed + 1` @@ -130,7 +133,7 @@ wellknown_object_test() { basedns=" " for dn in ${basedns}; do echo "Test ${dn} => ${object}" - r=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectClass=*)' -b "${dn}" | grep 'dn: '` + r=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectClass=*)' -b "${dn}" | grep 'dn: '` n=`echo "${r}" | grep 'dn: ' | wc -l` c=`echo "${r}" | grep "${object}" | wc -l` @@ -181,18 +184,18 @@ if [ x"$st" != x"0" ]; then fi echo "Getting HEX GUID/SID of $BASEDN" -HEXDN=`bin/ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER -s base "(objectClass=*)" --controls=extended_dn:1:0 distinguishedName | grep 'distinguishedName: ' | cut -d ' ' -f2-` +HEXDN=`$ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER -s base "(objectClass=*)" --controls=extended_dn:1:0 distinguishedName | grep 'distinguishedName: ' | cut -d ' ' -f2-` HEXGUID=`echo "$HEXDN" | cut -d ';' -f1` echo "HEXGUID[$HEXGUID]" echo "Getting STR GUID/SID of $BASEDN" -STRDN=`bin/ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER -s base "(objectClass=*)" --controls=extended_dn:1:1 distinguishedName | grep 'distinguishedName: ' | cut -d ' ' -f2-` +STRDN=`$ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER -s base "(objectClass=*)" --controls=extended_dn:1:1 distinguishedName | grep 'distinguishedName: ' | cut -d ' ' -f2-` echo "STRDN: $STRDN" STRGUID=`echo "$STRDN" | cut -d ';' -f1` echo "STRGUID[$STRGUID]" echo "Getting STR GUID/SID of $BASEDN" -STRDN=`bin/ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER -s base "(objectClass=*)" --controls=extended_dn:1:1 | grep 'dn: ' | cut -d ' ' -f2-` +STRDN=`$ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER -s base "(objectClass=*)" --controls=extended_dn:1:1 | grep 'dn: ' | cut -d ' ' -f2-` echo "STRDN: $STRDN" STRSID=`echo "$STRDN" | cut -d ';' -f2` echo "STRSID[$STRSID]" @@ -200,7 +203,7 @@ echo "STRSID[$STRSID]" SPECIALDNS="$HEXGUID $STRGUID $STRSID" for SPDN in $SPECIALDNS; do echo "Search for $SPDN" - nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER -s base -b "$SPDN" '(objectClass=*)' | grep "dn: $BASEDN" | wc -l` + nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER -s base -b "$SPDN" '(objectClass=*)' | grep "dn: $BASEDN" | wc -l` if [ $nentries -lt 1 ]; then echo "Special search returned 0 items" failed=`expr $failed + 1` -- cgit From aa9592991a1f406708fc08fd32cd630f0e9ed43d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 3 Feb 2009 17:04:42 +0100 Subject: Revert "s3:test: try to find why creating BUILTIN\Administrators doesn't work in the build-farm" This reverts commit 20a1cb15699c781651593c68685ece91c03e6a18. I will also revert a849183f9492d09ccd7e273f955d4d8f2668fdf3 metze --- source3/script/tests/selftest.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/source3/script/tests/selftest.sh b/source3/script/tests/selftest.sh index af01d0f961..c02e0ee183 100755 --- a/source3/script/tests/selftest.sh +++ b/source3/script/tests/selftest.sh @@ -346,11 +346,9 @@ START=`date` MAKE_TEST_BINARY="" MAKE_TEST_BINARY="bin/net" - printf "%s\n" "creating BUILTIN\\Administrators..." - bin/net -s $SERVERCONFFILE sam createbuiltingroup Administrators || { - echo "FAILED: $?" - exit 1 - } + printf "%s" "creating BUILTIN\\Administrators..." + bin/net -s $SERVERCONFFILE sam createbuiltingroup \ + Administrators > /dev/null 2>&1 || exit 1 echo "DONE" MAKE_TEST_BINARY="" -- cgit From 484c4a5955d0365beb9587bb15c73fe3ed3301ce Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 3 Feb 2009 17:05:24 +0100 Subject: Revert "s3:selftest: create BUILTIN\\Administrators at startup" This reverts commit a849183f9492d09ccd7e273f955d4d8f2668fdf3. This is to racy for most of the build-farm machines, because winbindd doesn't start fast enough. metze --- source3/script/tests/selftest.sh | 7 ------- source3/script/tests/test_net_registry.sh | 15 ++++++++++----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/source3/script/tests/selftest.sh b/source3/script/tests/selftest.sh index c02e0ee183..94621841f5 100755 --- a/source3/script/tests/selftest.sh +++ b/source3/script/tests/selftest.sh @@ -345,13 +345,6 @@ START=`date` bin/smbclient $CONFIGURATION -L $SERVER_IP -U% -p 139 | head -2 MAKE_TEST_BINARY="" - MAKE_TEST_BINARY="bin/net" - printf "%s" "creating BUILTIN\\Administrators..." - bin/net -s $SERVERCONFFILE sam createbuiltingroup \ - Administrators > /dev/null 2>&1 || exit 1 - echo "DONE" - MAKE_TEST_BINARY="" - failed=0 . $SCRIPTDIR/tests_$SUBTESTS.sh diff --git a/source3/script/tests/test_net_registry.sh b/source3/script/tests/test_net_registry.sh index a3d1a24fd8..52a78bc339 100755 --- a/source3/script/tests/test_net_registry.sh +++ b/source3/script/tests/test_net_registry.sh @@ -7,10 +7,8 @@ RPC="$1" NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION" -NETREMOTE="${NET} -U${USERNAME}%${PASSWORD} -S ${SERVER} -I ${SERVER_IP}" - if test "x${RPC}" = "xrpc" ; then - NETREG="${NETREMOTE} rpc registry" + NETREG="${NET} -U${USERNAME}%${PASSWORD} -I ${SERVER_IP} rpc registry" else NETREG="${NET} registry" fi @@ -336,7 +334,14 @@ test_setvalue_twice() give_administrative_rights() { - ${NETREMOTE} rpc group addmem BUILTIN\\Administrators $USERNAME + bin/net -s $SERVERCONFFILE sam createbuiltingroup Administrators + if test "x$?" != "x0" ; then + echo "ERROR: creating builtin group Administrators" + false + return + fi + + bin/net -s $SERVERCONFFILE sam addmem BUILTIN\\Administrators $USERNAME if test "x$?" != "x0" ; then echo "ERROR: adding user $USERNAME to BUILTIN\\Administrators" false @@ -347,7 +352,7 @@ give_administrative_rights() take_administrative_rights() { - ${NETREMOTE} rpc group delmem BUILTIN\\Administrators $USERNAME + bin/net -s $SERVERCONFFILE sam delmem BUILTIN\\Administrators $USERNAME if test "x$?" != "x0" ; then echo "ERROR: removing user $USERNAME from BUILTIN\\Administrators" false -- cgit From 98e2fe5e6d7634aa1ecf12b1b1fb23c82b3f16c5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 3 Feb 2009 17:43:23 +0100 Subject: s3:selftest: fix blackbox.net_s3 tests metze --- source3/selftest/tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/selftest/tests.sh b/source3/selftest/tests.sh index 812a3a7fe8..f88dab0337 100755 --- a/source3/selftest/tests.sh +++ b/source3/selftest/tests.sh @@ -127,7 +127,7 @@ plantest "blackbox.smbclient_s3.crypt" dc BINDIR="$BINDIR" script/tests/test_smb #plantest "blackbox.smbclient_s3.crypt member creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$SERVER\\\\\$USERNAME \$PASSWORD "-e" #plantest "blackbox.smbclient_s3.crypt domain creds" member BINDIR="$BINDIR" script/tests/test_smbclient_s3.sh \$SERVER \$SERVER_IP \$DOMAIN\\\\\$DC_USERNAME \$DC_PASSWORD "-e" -plantest "blackbox.net_s3" dc BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" script/tests/test_net_s3.sh +plantest "blackbox.net_s3" dc:local BINDIR="$BINDIR" SCRIPTDIR="$SCRIPTDIR" SERVERCONFFILE="\$SMB_CONF_PATH" script/tests/test_net_s3.sh ( shift $# -- cgit From 189a85dd68eb6c62272e51769d842afbf8389a4f Mon Sep 17 00:00:00 2001 From: Ted Percival Date: Tue, 3 Feb 2009 14:25:31 -0800 Subject: Probably fixes a crash during name resolution when log level >= 10 and libc segfaults if printf is passed NULL for a "%s" arg (eg. Solaris). --- source3/libsmb/namequery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 05679570d4..ac38d40271 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -1502,7 +1502,7 @@ NTSTATUS internal_resolve_name(const char *name, *return_count = 0; DEBUG(10, ("internal_resolve_name: looking up %s#%x (sitename %s)\n", - name, name_type, sitename ? sitename : NULL)); + name, name_type, sitename ? sitename : "(null)")); if (is_ipaddress(name)) { if ((*return_iplist = SMB_MALLOC_P(struct ip_service)) == -- cgit From a4c5054b5a92c08498f522b39472d64a32a3cebb Mon Sep 17 00:00:00 2001 From: Miguel Suarez Date: Tue, 3 Feb 2009 14:36:50 -0800 Subject: Fix bug #6085 - In vfs_default.c change utime( ) call. --- source3/modules/vfs_default.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index f8ac3e85d3..679be57558 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -735,7 +735,7 @@ static int vfswrap_ntimes(vfs_handle_struct *handle, const char *path, struct utimbuf times; times.actime = convert_timespec_to_time_t(ft->atime); times.modtime = convert_timespec_to_time_t(ft->mtime); - result = utime(path, times); + result = utime(path, ×); } else { result = utime(path, NULL); } -- cgit From 76db6f15dcc5338b1968f26287674cf0b3244e0f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 4 Feb 2009 08:33:15 +0100 Subject: selftest/Samba3: use the same logic for make test and make selftest See also commit 484c4a5955d0365beb9587bb15c73fe3ed3301ce metze --- selftest/target/Samba3.pm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index bb074b7b6e..49984f17c8 100644 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -551,11 +551,6 @@ sub wait_for_start($$) system($self->binpath("smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER_IP} -U% -p 139 | head -2"); system($self->binpath("smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER_IP} -U% -p 139 | head -2"); - print "creating BUILTIN\\Administrators\n"; - $ENV{WINBINDD_SOCKET_DIR} = $envvars->{WINBINDD_SOCKET_DIR}; - system($self->binpath("net") ." $envvars->{CONFIGURATION} sam createbuiltingroup Administrators"); - delete $ENV{WINBINDD_SOCKET_DIR}; - print $self->getlog_env($envvars); } -- cgit From a0c4fbdb3cf48f317ac5a3ca20ead31acb4c7611 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 4 Feb 2009 12:02:56 +0100 Subject: librpc: add header file for drsblobs helper functions. Guenther --- librpc/gen_ndr/ndr_drsblobs.h | 1 + librpc/idl/drsblobs.idl | 1 + librpc/ndr/ndr_drsblobs.h | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 librpc/ndr/ndr_drsblobs.h diff --git a/librpc/gen_ndr/ndr_drsblobs.h b/librpc/gen_ndr/ndr_drsblobs.h index 2f6cf991d6..27c13c8397 100644 --- a/librpc/gen_ndr/ndr_drsblobs.h +++ b/librpc/gen_ndr/ndr_drsblobs.h @@ -6,6 +6,7 @@ #ifndef _HEADER_NDR_drsblobs #define _HEADER_NDR_drsblobs +#include "../librpc/ndr/ndr_drsblobs.h" #define NDR_DRSBLOBS_UUID "12345778-1234-abcd-0001-00000001" #define NDR_DRSBLOBS_VERSION 0.0 #define NDR_DRSBLOBS_NAME "drsblobs" diff --git a/librpc/idl/drsblobs.idl b/librpc/idl/drsblobs.idl index 7e9c2fe9bb..fb37500fea 100644 --- a/librpc/idl/drsblobs.idl +++ b/librpc/idl/drsblobs.idl @@ -6,6 +6,7 @@ import "drsuapi.idl", "misc.idl", "samr.idl", "lsa.idl"; uuid("12345778-1234-abcd-0001-00000001"), version(0.0), pointer_default(unique), + helper("../librpc/ndr/ndr_drsblobs.h"), helpstring("Active Directory Replication LDAP Blobs") ] interface drsblobs { diff --git a/librpc/ndr/ndr_drsblobs.h b/librpc/ndr/ndr_drsblobs.h new file mode 100644 index 0000000000..27532257de --- /dev/null +++ b/librpc/ndr/ndr_drsblobs.h @@ -0,0 +1,27 @@ +/* + Unix SMB/CIFS implementation. + + Manually parsed structures found in the DRS protocol + + Copyright (C) Andrew Bartlett 2008 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 . +*/ + +_PUBLIC_ void ndr_print_AuthenticationInformationArray_with_count(struct ndr_print *ndr, const char *name, int count, const struct AuthenticationInformationArray *r); +_PUBLIC_ enum ndr_err_code ndr_push_trustAuthInOutBlob(struct ndr_push *ndr, int ndr_flags, const struct trustAuthInOutBlob *r); +_PUBLIC_ enum ndr_err_code ndr_pull_trustAuthInOutBlob(struct ndr_pull *ndr, int ndr_flags, struct trustAuthInOutBlob *r); +_PUBLIC_ void ndr_print_trustAuthInOutBlob(struct ndr_print *ndr, const char *name, const struct trustAuthInOutBlob *r); +_PUBLIC_ enum ndr_err_code ndr_pull_trustDomainPasswords(struct ndr_pull *ndr, int ndr_flags, struct trustDomainPasswords *r); + -- cgit From a5597d75d218bff810928d618f4ea41277e554a9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 23 Jan 2009 14:58:27 +0100 Subject: eventlog: add w32 on-disc EVENTLOG structures (*evt files). Guenther --- librpc/idl/eventlog.idl | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/librpc/idl/eventlog.idl b/librpc/idl/eventlog.idl index 0826f59ed8..c0230f3693 100644 --- a/librpc/idl/eventlog.idl +++ b/librpc/idl/eventlog.idl @@ -90,6 +90,76 @@ import "lsa.idl", "security.idl"; uint32 padding; } eventlog_Record_tdb; + typedef [v1_enum] enum { + ELF_LOGFILE_HEADER_DIRTY = 0x0001, + ELF_LOGFILE_HEADER_WRAP = 0x0002, + ELF_LOGFILE_LOGFULL_WRITTEN = 0x0004, + ELF_LOGFILE_ARCHIVE_SET = 0x0008 + } EVENTLOG_HEADER_FLAGS; + + typedef [public] struct { + [value(0x30)] uint32 HeaderSize; + [charset(DOS),value("LfLe")] uint8 Signature[4]; + [value(1)] uint32 MajorVersion; + [value(1)] uint32 MinorVersion; + uint32 StartOffset; + uint32 EndOffset; + uint32 CurrentRecordNumber; + uint32 OldestRecordNumber; + uint32 MaxSize; + EVENTLOG_HEADER_FLAGS Flags; + uint32 Retention; + [value(0x30)] uint32 EndHeaderSize; + } EVENTLOGHEADER; + + typedef [public,gensize] struct { + uint32 Length; + [charset(DOS),value("LfLe")] uint8 Reserved[4]; + uint32 RecordNumber; + time_t TimeGenerated; + time_t TimeWritten; + uint32 EventID; + eventlogEventTypes EventType; + uint16 NumStrings; + uint16 EventCategory; + uint16 ReservedFlags; + uint32 ClosingRecordNumber; + uint32 StringOffset; + [value(ndr_size_dom_sid0(&UserSid, ndr->flags))] uint32 UserSidLength; + uint32 UserSidOffset; + uint32 DataLength; + uint32 DataOffset; + nstring SourceName; + nstring Computername; + [flag(NDR_ALIGN4),subcontext(0),subcontext_size(UserSidLength)] dom_sid0 UserSid; + nstring Strings[NumStrings]; + [flag(NDR_PAHEX)] uint8 Data[DataLength]; + astring Pad; + [value(Length)] uint32 Length2; + } EVENTLOGRECORD; + + typedef [public] struct { + [value(0x28)] uint32 RecordSizeBeginning; + [value(0x11111111)] uint32 One; + [value(0x22222222)] uint32 Two; + [value(0x33333333)] uint32 Three; + [value(0x44444444)] uint32 Four; + uint32 BeginRecord; + uint32 EndRecord; + uint32 CurrentRecordNumber; + uint32 OldestRecordNumber; + [value(0x28)] uint32 RecordSizeEnd; + } EVENTLOGEOF; + + /* the following is true for a non-wrapped evt file (e.g. backups + * generated and viewed with eventvwr) */ + + typedef [public] struct { + EVENTLOGHEADER hdr; + EVENTLOGRECORD records[hdr.CurrentRecordNumber-hdr.OldestRecordNumber]; + EVENTLOGEOF eof; + } EVENTLOG_EVT_FILE; + /******************/ /* Function: 0x00 */ NTSTATUS eventlog_ClearEventLogW( -- cgit From 4974554de9c513973191d9a745009fe988ec0fcd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 4 Feb 2009 12:59:47 +0100 Subject: eventlog: calculate offsets in EVENTLOGRECORD struct. We cannot use [relative] pointer properties here for various reasons. Guenther --- librpc/idl/eventlog.idl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/librpc/idl/eventlog.idl b/librpc/idl/eventlog.idl index c0230f3693..c7524f3c38 100644 --- a/librpc/idl/eventlog.idl +++ b/librpc/idl/eventlog.idl @@ -124,11 +124,11 @@ import "lsa.idl", "security.idl"; uint16 EventCategory; uint16 ReservedFlags; uint32 ClosingRecordNumber; - uint32 StringOffset; + [value(56+2*(strlen_m_term(SourceName)+strlen_m_term(Computername))+UserSidLength)] uint32 StringOffset; [value(ndr_size_dom_sid0(&UserSid, ndr->flags))] uint32 UserSidLength; - uint32 UserSidOffset; + [value(56+2*(strlen_m_term(SourceName)+strlen_m_term(Computername)))] uint32 UserSidOffset; uint32 DataLength; - uint32 DataOffset; + [value(56+2*(strlen_m_term(SourceName)+strlen_m_term(Computername))+UserSidLength+(2*ndr_size_string_array(Strings, NumStrings, STR_NULLTERM)))] uint32 DataOffset; nstring SourceName; nstring Computername; [flag(NDR_ALIGN4),subcontext(0),subcontext_size(UserSidLength)] dom_sid0 UserSid; -- cgit From 5e637e0afa01e227f2aa9e042da2f15b4d807083 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 23 Jan 2009 17:39:47 +0100 Subject: s3: re-run make samba3-idl. Guenther --- librpc/gen_ndr/eventlog.h | 77 ++++++++ librpc/gen_ndr/ndr_eventlog.c | 416 ++++++++++++++++++++++++++++++++++++++++++ librpc/gen_ndr/ndr_eventlog.h | 14 ++ 3 files changed, 507 insertions(+) diff --git a/librpc/gen_ndr/eventlog.h b/librpc/gen_ndr/eventlog.h index 0c998a8a18..94da688f5c 100644 --- a/librpc/gen_ndr/eventlog.h +++ b/librpc/gen_ndr/eventlog.h @@ -94,6 +94,83 @@ struct eventlog_Record_tdb { uint32_t padding; }/* [public,flag(LIBNDR_FLAG_NOALIGN|LIBNDR_PRINT_ARRAY_HEX)] */; +enum EVENTLOG_HEADER_FLAGS +#ifndef USE_UINT_ENUMS + { + ELF_LOGFILE_HEADER_DIRTY=0x0001, + ELF_LOGFILE_HEADER_WRAP=0x0002, + ELF_LOGFILE_LOGFULL_WRITTEN=0x0004, + ELF_LOGFILE_ARCHIVE_SET=0x0008 +} +#else + { __donnot_use_enum_EVENTLOG_HEADER_FLAGS=0x7FFFFFFF} +#define ELF_LOGFILE_HEADER_DIRTY ( 0x0001 ) +#define ELF_LOGFILE_HEADER_WRAP ( 0x0002 ) +#define ELF_LOGFILE_LOGFULL_WRITTEN ( 0x0004 ) +#define ELF_LOGFILE_ARCHIVE_SET ( 0x0008 ) +#endif +; + +struct EVENTLOGHEADER { + uint32_t HeaderSize;/* [value(0x30)] */ + const char *Signature;/* [value("LfLe"),charset(DOS)] */ + uint32_t MajorVersion;/* [value] */ + uint32_t MinorVersion;/* [value] */ + uint32_t StartOffset; + uint32_t EndOffset; + uint32_t CurrentRecordNumber; + uint32_t OldestRecordNumber; + uint32_t MaxSize; + enum EVENTLOG_HEADER_FLAGS Flags; + uint32_t Retention; + uint32_t EndHeaderSize;/* [value(0x30)] */ +}/* [public] */; + +struct EVENTLOGRECORD { + uint32_t Length; + const char *Reserved;/* [value("LfLe"),charset(DOS)] */ + uint32_t RecordNumber; + time_t TimeGenerated; + time_t TimeWritten; + uint32_t EventID; + enum eventlogEventTypes EventType; + uint16_t NumStrings; + uint16_t EventCategory; + uint16_t ReservedFlags; + uint32_t ClosingRecordNumber; + uint32_t StringOffset;/* [value(56+2*(strlen_m_term(SourceName)+strlen_m_term(Computername))+UserSidLength)] */ + uint32_t UserSidLength;/* [value(ndr_size_dom_sid0(&UserSid,ndr->flags))] */ + uint32_t UserSidOffset;/* [value(56+2*(strlen_m_term(SourceName)+strlen_m_term(Computername)))] */ + uint32_t DataLength; + uint32_t DataOffset;/* [value(56+2*(strlen_m_term(SourceName)+strlen_m_term(Computername))+UserSidLength+(2*ndr_size_string_array(Strings,NumStrings,LIBNDR_FLAG_STR_NULLTERM)))] */ + const char * SourceName;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ + const char * Computername;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ + struct dom_sid0 UserSid;/* [subcontext_size(UserSidLength),subcontext(0),flag(LIBNDR_FLAG_ALIGN4)] */ + const char * *Strings;/* [flag(LIBNDR_FLAG_STR_NULLTERM)] */ + uint8_t *Data;/* [flag(LIBNDR_PRINT_ARRAY_HEX)] */ + const char * Pad;/* [flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */ + uint32_t Length2;/* [value(Length)] */ +}/* [gensize,public] */; + +struct EVENTLOGEOF { + uint32_t RecordSizeBeginning;/* [value(0x28)] */ + uint32_t One;/* [value(0x11111111)] */ + uint32_t Two;/* [value(0x22222222)] */ + uint32_t Three;/* [value(0x33333333)] */ + uint32_t Four;/* [value(0x44444444)] */ + uint32_t BeginRecord; + uint32_t EndRecord; + uint32_t CurrentRecordNumber; + uint32_t OldestRecordNumber; + uint32_t RecordSizeEnd;/* [value(0x28)] */ +}/* [public] */; + +struct EVENTLOG_EVT_FILE { + struct EVENTLOGHEADER hdr; + struct EVENTLOGRECORD *records; + struct EVENTLOGEOF eof; +}/* [public] */; + struct EVENTLOG_FULL_INFORMATION { uint32_t full; }; diff --git a/librpc/gen_ndr/ndr_eventlog.c b/librpc/gen_ndr/ndr_eventlog.c index a43b343aa7..b80f613efa 100644 --- a/librpc/gen_ndr/ndr_eventlog.c +++ b/librpc/gen_ndr/ndr_eventlog.c @@ -461,6 +461,422 @@ _PUBLIC_ void ndr_print_eventlog_Record_tdb(struct ndr_print *ndr, const char *n } } +static enum ndr_err_code ndr_push_EVENTLOG_HEADER_FLAGS(struct ndr_push *ndr, int ndr_flags, enum EVENTLOG_HEADER_FLAGS r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_EVENTLOG_HEADER_FLAGS(struct ndr_pull *ndr, int ndr_flags, enum EVENTLOG_HEADER_FLAGS *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_EVENTLOG_HEADER_FLAGS(struct ndr_print *ndr, const char *name, enum EVENTLOG_HEADER_FLAGS r) +{ + const char *val = NULL; + + switch (r) { + case ELF_LOGFILE_HEADER_DIRTY: val = "ELF_LOGFILE_HEADER_DIRTY"; break; + case ELF_LOGFILE_HEADER_WRAP: val = "ELF_LOGFILE_HEADER_WRAP"; break; + case ELF_LOGFILE_LOGFULL_WRITTEN: val = "ELF_LOGFILE_LOGFULL_WRITTEN"; break; + case ELF_LOGFILE_ARCHIVE_SET: val = "ELF_LOGFILE_ARCHIVE_SET"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + +_PUBLIC_ enum ndr_err_code ndr_push_EVENTLOGHEADER(struct ndr_push *ndr, int ndr_flags, const struct EVENTLOGHEADER *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x30)); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, "LfLe", 4, sizeof(uint8_t), CH_DOS)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 1)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 1)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->StartOffset)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->EndOffset)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->CurrentRecordNumber)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->OldestRecordNumber)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->MaxSize)); + NDR_CHECK(ndr_push_EVENTLOG_HEADER_FLAGS(ndr, NDR_SCALARS, r->Flags)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->Retention)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x30)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_EVENTLOGHEADER(struct ndr_pull *ndr, int ndr_flags, struct EVENTLOGHEADER *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->HeaderSize)); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->Signature, 4, sizeof(uint8_t), CH_DOS)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->MajorVersion)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->MinorVersion)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->StartOffset)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->EndOffset)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->CurrentRecordNumber)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->OldestRecordNumber)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->MaxSize)); + NDR_CHECK(ndr_pull_EVENTLOG_HEADER_FLAGS(ndr, NDR_SCALARS, &r->Flags)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Retention)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->EndHeaderSize)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_EVENTLOGHEADER(struct ndr_print *ndr, const char *name, const struct EVENTLOGHEADER *r) +{ + ndr_print_struct(ndr, name, "EVENTLOGHEADER"); + ndr->depth++; + ndr_print_uint32(ndr, "HeaderSize", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0x30:r->HeaderSize); + ndr_print_string(ndr, "Signature", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?"LfLe":r->Signature); + ndr_print_uint32(ndr, "MajorVersion", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?1:r->MajorVersion); + ndr_print_uint32(ndr, "MinorVersion", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?1:r->MinorVersion); + ndr_print_uint32(ndr, "StartOffset", r->StartOffset); + ndr_print_uint32(ndr, "EndOffset", r->EndOffset); + ndr_print_uint32(ndr, "CurrentRecordNumber", r->CurrentRecordNumber); + ndr_print_uint32(ndr, "OldestRecordNumber", r->OldestRecordNumber); + ndr_print_uint32(ndr, "MaxSize", r->MaxSize); + ndr_print_EVENTLOG_HEADER_FLAGS(ndr, "Flags", r->Flags); + ndr_print_uint32(ndr, "Retention", r->Retention); + ndr_print_uint32(ndr, "EndHeaderSize", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0x30:r->EndHeaderSize); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_EVENTLOGRECORD(struct ndr_push *ndr, int ndr_flags, const struct EVENTLOGRECORD *r) +{ + uint32_t cntr_Strings_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->Length)); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, "LfLe", 4, sizeof(uint8_t), CH_DOS)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->RecordNumber)); + NDR_CHECK(ndr_push_time_t(ndr, NDR_SCALARS, r->TimeGenerated)); + NDR_CHECK(ndr_push_time_t(ndr, NDR_SCALARS, r->TimeWritten)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->EventID)); + NDR_CHECK(ndr_push_eventlogEventTypes(ndr, NDR_SCALARS, r->EventType)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->NumStrings)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->EventCategory)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->ReservedFlags)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->ClosingRecordNumber)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 56 + 2 * (strlen_m_term(r->SourceName) + strlen_m_term(r->Computername)) + ndr_size_dom_sid0(&r->UserSid, ndr->flags))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_dom_sid0(&r->UserSid, ndr->flags))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 56 + 2 * (strlen_m_term(r->SourceName) + strlen_m_term(r->Computername)))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->DataLength)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 56 + 2 * (strlen_m_term(r->SourceName) + strlen_m_term(r->Computername)) + ndr_size_dom_sid0(&r->UserSid, ndr->flags) + (2 * ndr_size_string_array(r->Strings, r->NumStrings, LIBNDR_FLAG_STR_NULLTERM)))); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->SourceName)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->Computername)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_dom_sid0 = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4); + { + struct ndr_push *_ndr_UserSid; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_UserSid, 0, ndr_size_dom_sid0(&r->UserSid, ndr->flags))); + NDR_CHECK(ndr_push_dom_sid0(_ndr_UserSid, NDR_SCALARS|NDR_BUFFERS, &r->UserSid)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_UserSid, 0, ndr_size_dom_sid0(&r->UserSid, ndr->flags))); + } + ndr->flags = _flags_save_dom_sid0; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + for (cntr_Strings_0 = 0; cntr_Strings_0 < r->NumStrings; cntr_Strings_0++) { + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->Strings[cntr_Strings_0])); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_uint8 = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->Data, r->DataLength)); + ndr->flags = _flags_save_uint8; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->Pad)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->Length)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_dom_sid0 = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4); + ndr->flags = _flags_save_dom_sid0; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_EVENTLOGRECORD(struct ndr_pull *ndr, int ndr_flags, struct EVENTLOGRECORD *r) +{ + uint32_t cntr_Strings_0; + TALLOC_CTX *_mem_save_Strings_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Length)); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->Reserved, 4, sizeof(uint8_t), CH_DOS)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->RecordNumber)); + NDR_CHECK(ndr_pull_time_t(ndr, NDR_SCALARS, &r->TimeGenerated)); + NDR_CHECK(ndr_pull_time_t(ndr, NDR_SCALARS, &r->TimeWritten)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->EventID)); + NDR_CHECK(ndr_pull_eventlogEventTypes(ndr, NDR_SCALARS, &r->EventType)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->NumStrings)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->EventCategory)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->ReservedFlags)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ClosingRecordNumber)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->StringOffset)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->UserSidLength)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->UserSidOffset)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->DataLength)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->DataOffset)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->SourceName)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->Computername)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_dom_sid0 = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4); + { + struct ndr_pull *_ndr_UserSid; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_UserSid, 0, r->UserSidLength)); + NDR_CHECK(ndr_pull_dom_sid0(_ndr_UserSid, NDR_SCALARS|NDR_BUFFERS, &r->UserSid)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_UserSid, 0, r->UserSidLength)); + } + ndr->flags = _flags_save_dom_sid0; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_PULL_ALLOC_N(ndr, r->Strings, r->NumStrings); + _mem_save_Strings_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->Strings, 0); + for (cntr_Strings_0 = 0; cntr_Strings_0 < r->NumStrings; cntr_Strings_0++) { + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->Strings[cntr_Strings_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_Strings_0, 0); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_uint8 = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_PRINT_ARRAY_HEX); + NDR_PULL_ALLOC_N(ndr, r->Data, r->DataLength); + NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->Data, r->DataLength)); + ndr->flags = _flags_save_uint8; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->Pad)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Length2)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_dom_sid0 = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4); + ndr->flags = _flags_save_dom_sid0; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_EVENTLOGRECORD(struct ndr_print *ndr, const char *name, const struct EVENTLOGRECORD *r) +{ + uint32_t cntr_Strings_0; + ndr_print_struct(ndr, name, "EVENTLOGRECORD"); + ndr->depth++; + ndr_print_uint32(ndr, "Length", r->Length); + ndr_print_string(ndr, "Reserved", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?"LfLe":r->Reserved); + ndr_print_uint32(ndr, "RecordNumber", r->RecordNumber); + ndr_print_time_t(ndr, "TimeGenerated", r->TimeGenerated); + ndr_print_time_t(ndr, "TimeWritten", r->TimeWritten); + ndr_print_uint32(ndr, "EventID", r->EventID); + ndr_print_eventlogEventTypes(ndr, "EventType", r->EventType); + ndr_print_uint16(ndr, "NumStrings", r->NumStrings); + ndr_print_uint16(ndr, "EventCategory", r->EventCategory); + ndr_print_uint16(ndr, "ReservedFlags", r->ReservedFlags); + ndr_print_uint32(ndr, "ClosingRecordNumber", r->ClosingRecordNumber); + ndr_print_uint32(ndr, "StringOffset", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?56 + 2 * (strlen_m_term(r->SourceName) + strlen_m_term(r->Computername)) + r->UserSidLength:r->StringOffset); + ndr_print_uint32(ndr, "UserSidLength", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_dom_sid0(&r->UserSid, ndr->flags):r->UserSidLength); + ndr_print_uint32(ndr, "UserSidOffset", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?56 + 2 * (strlen_m_term(r->SourceName) + strlen_m_term(r->Computername)):r->UserSidOffset); + ndr_print_uint32(ndr, "DataLength", r->DataLength); + ndr_print_uint32(ndr, "DataOffset", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?56 + 2 * (strlen_m_term(r->SourceName) + strlen_m_term(r->Computername)) + r->UserSidLength + (2 * ndr_size_string_array(r->Strings, r->NumStrings, LIBNDR_FLAG_STR_NULLTERM)):r->DataOffset); + ndr_print_string(ndr, "SourceName", r->SourceName); + ndr_print_string(ndr, "Computername", r->Computername); + ndr_print_dom_sid0(ndr, "UserSid", &r->UserSid); + ndr->print(ndr, "%s: ARRAY(%d)", "Strings", (int)r->NumStrings); + ndr->depth++; + for (cntr_Strings_0=0;cntr_Strings_0NumStrings;cntr_Strings_0++) { + char *idx_0=NULL; + if (asprintf(&idx_0, "[%d]", cntr_Strings_0) != -1) { + ndr_print_string(ndr, "Strings", r->Strings[cntr_Strings_0]); + free(idx_0); + } + } + ndr->depth--; + ndr_print_array_uint8(ndr, "Data", r->Data, r->DataLength); + ndr_print_string(ndr, "Pad", r->Pad); + ndr_print_uint32(ndr, "Length2", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?r->Length:r->Length2); + ndr->depth--; +} + +_PUBLIC_ size_t ndr_size_EVENTLOGRECORD(const struct EVENTLOGRECORD *r, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_EVENTLOGRECORD, ic); +} + +_PUBLIC_ enum ndr_err_code ndr_push_EVENTLOGEOF(struct ndr_push *ndr, int ndr_flags, const struct EVENTLOGEOF *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x28)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x11111111)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x22222222)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x33333333)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x44444444)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->BeginRecord)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->EndRecord)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->CurrentRecordNumber)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->OldestRecordNumber)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x28)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_EVENTLOGEOF(struct ndr_pull *ndr, int ndr_flags, struct EVENTLOGEOF *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->RecordSizeBeginning)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->One)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Two)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Three)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->Four)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->BeginRecord)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->EndRecord)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->CurrentRecordNumber)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->OldestRecordNumber)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->RecordSizeEnd)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_EVENTLOGEOF(struct ndr_print *ndr, const char *name, const struct EVENTLOGEOF *r) +{ + ndr_print_struct(ndr, name, "EVENTLOGEOF"); + ndr->depth++; + ndr_print_uint32(ndr, "RecordSizeBeginning", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0x28:r->RecordSizeBeginning); + ndr_print_uint32(ndr, "One", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0x11111111:r->One); + ndr_print_uint32(ndr, "Two", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0x22222222:r->Two); + ndr_print_uint32(ndr, "Three", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0x33333333:r->Three); + ndr_print_uint32(ndr, "Four", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0x44444444:r->Four); + ndr_print_uint32(ndr, "BeginRecord", r->BeginRecord); + ndr_print_uint32(ndr, "EndRecord", r->EndRecord); + ndr_print_uint32(ndr, "CurrentRecordNumber", r->CurrentRecordNumber); + ndr_print_uint32(ndr, "OldestRecordNumber", r->OldestRecordNumber); + ndr_print_uint32(ndr, "RecordSizeEnd", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?0x28:r->RecordSizeEnd); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_EVENTLOG_EVT_FILE(struct ndr_push *ndr, int ndr_flags, const struct EVENTLOG_EVT_FILE *r) +{ + uint32_t cntr_records_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_EVENTLOGHEADER(ndr, NDR_SCALARS, &r->hdr)); + for (cntr_records_0 = 0; cntr_records_0 < r->hdr.CurrentRecordNumber - r->hdr.OldestRecordNumber; cntr_records_0++) { + NDR_CHECK(ndr_push_EVENTLOGRECORD(ndr, NDR_SCALARS, &r->records[cntr_records_0])); + } + NDR_CHECK(ndr_push_EVENTLOGEOF(ndr, NDR_SCALARS, &r->eof)); + } + if (ndr_flags & NDR_BUFFERS) { + for (cntr_records_0 = 0; cntr_records_0 < r->hdr.CurrentRecordNumber - r->hdr.OldestRecordNumber; cntr_records_0++) { + NDR_CHECK(ndr_push_EVENTLOGRECORD(ndr, NDR_BUFFERS, &r->records[cntr_records_0])); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_EVENTLOG_EVT_FILE(struct ndr_pull *ndr, int ndr_flags, struct EVENTLOG_EVT_FILE *r) +{ + uint32_t cntr_records_0; + TALLOC_CTX *_mem_save_records_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_EVENTLOGHEADER(ndr, NDR_SCALARS, &r->hdr)); + NDR_PULL_ALLOC_N(ndr, r->records, r->hdr.CurrentRecordNumber - r->hdr.OldestRecordNumber); + _mem_save_records_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->records, 0); + for (cntr_records_0 = 0; cntr_records_0 < r->hdr.CurrentRecordNumber - r->hdr.OldestRecordNumber; cntr_records_0++) { + NDR_CHECK(ndr_pull_EVENTLOGRECORD(ndr, NDR_SCALARS, &r->records[cntr_records_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_records_0, 0); + NDR_CHECK(ndr_pull_EVENTLOGEOF(ndr, NDR_SCALARS, &r->eof)); + } + if (ndr_flags & NDR_BUFFERS) { + _mem_save_records_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->records, 0); + for (cntr_records_0 = 0; cntr_records_0 < r->hdr.CurrentRecordNumber - r->hdr.OldestRecordNumber; cntr_records_0++) { + NDR_CHECK(ndr_pull_EVENTLOGRECORD(ndr, NDR_BUFFERS, &r->records[cntr_records_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_records_0, 0); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_EVENTLOG_EVT_FILE(struct ndr_print *ndr, const char *name, const struct EVENTLOG_EVT_FILE *r) +{ + uint32_t cntr_records_0; + ndr_print_struct(ndr, name, "EVENTLOG_EVT_FILE"); + ndr->depth++; + ndr_print_EVENTLOGHEADER(ndr, "hdr", &r->hdr); + ndr->print(ndr, "%s: ARRAY(%d)", "records", (int)r->hdr.CurrentRecordNumber - r->hdr.OldestRecordNumber); + ndr->depth++; + for (cntr_records_0=0;cntr_records_0hdr.CurrentRecordNumber - r->hdr.OldestRecordNumber;cntr_records_0++) { + char *idx_0=NULL; + if (asprintf(&idx_0, "[%d]", cntr_records_0) != -1) { + ndr_print_EVENTLOGRECORD(ndr, "records", &r->records[cntr_records_0]); + free(idx_0); + } + } + ndr->depth--; + ndr_print_EVENTLOGEOF(ndr, "eof", &r->eof); + ndr->depth--; +} + static enum ndr_err_code ndr_push_eventlog_ClearEventLogW(struct ndr_push *ndr, int flags, const struct eventlog_ClearEventLogW *r) { if (flags & NDR_IN) { diff --git a/librpc/gen_ndr/ndr_eventlog.h b/librpc/gen_ndr/ndr_eventlog.h index 39bfd38665..34e6e09637 100644 --- a/librpc/gen_ndr/ndr_eventlog.h +++ b/librpc/gen_ndr/ndr_eventlog.h @@ -73,6 +73,20 @@ void ndr_print_eventlog_Record(struct ndr_print *ndr, const char *name, const st enum ndr_err_code ndr_push_eventlog_Record_tdb(struct ndr_push *ndr, int ndr_flags, const struct eventlog_Record_tdb *r); enum ndr_err_code ndr_pull_eventlog_Record_tdb(struct ndr_pull *ndr, int ndr_flags, struct eventlog_Record_tdb *r); void ndr_print_eventlog_Record_tdb(struct ndr_print *ndr, const char *name, const struct eventlog_Record_tdb *r); +void ndr_print_EVENTLOG_HEADER_FLAGS(struct ndr_print *ndr, const char *name, enum EVENTLOG_HEADER_FLAGS r); +enum ndr_err_code ndr_push_EVENTLOGHEADER(struct ndr_push *ndr, int ndr_flags, const struct EVENTLOGHEADER *r); +enum ndr_err_code ndr_pull_EVENTLOGHEADER(struct ndr_pull *ndr, int ndr_flags, struct EVENTLOGHEADER *r); +void ndr_print_EVENTLOGHEADER(struct ndr_print *ndr, const char *name, const struct EVENTLOGHEADER *r); +enum ndr_err_code ndr_push_EVENTLOGRECORD(struct ndr_push *ndr, int ndr_flags, const struct EVENTLOGRECORD *r); +enum ndr_err_code ndr_pull_EVENTLOGRECORD(struct ndr_pull *ndr, int ndr_flags, struct EVENTLOGRECORD *r); +void ndr_print_EVENTLOGRECORD(struct ndr_print *ndr, const char *name, const struct EVENTLOGRECORD *r); +size_t ndr_size_EVENTLOGRECORD(const struct EVENTLOGRECORD *r, struct smb_iconv_convenience *ic, int flags); +enum ndr_err_code ndr_push_EVENTLOGEOF(struct ndr_push *ndr, int ndr_flags, const struct EVENTLOGEOF *r); +enum ndr_err_code ndr_pull_EVENTLOGEOF(struct ndr_pull *ndr, int ndr_flags, struct EVENTLOGEOF *r); +void ndr_print_EVENTLOGEOF(struct ndr_print *ndr, const char *name, const struct EVENTLOGEOF *r); +enum ndr_err_code ndr_push_EVENTLOG_EVT_FILE(struct ndr_push *ndr, int ndr_flags, const struct EVENTLOG_EVT_FILE *r); +enum ndr_err_code ndr_pull_EVENTLOG_EVT_FILE(struct ndr_pull *ndr, int ndr_flags, struct EVENTLOG_EVT_FILE *r); +void ndr_print_EVENTLOG_EVT_FILE(struct ndr_print *ndr, const char *name, const struct EVENTLOG_EVT_FILE *r); void ndr_print_eventlog_ClearEventLogW(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_ClearEventLogW *r); void ndr_print_eventlog_BackupEventLogW(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_BackupEventLogW *r); void ndr_print_eventlog_CloseEventLog(struct ndr_print *ndr, const char *name, int flags, const struct eventlog_CloseEventLog *r); -- cgit From dd306249f23cacc01d6e6ea375450714109ebaa7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 21 Jan 2009 19:36:19 +0100 Subject: s3-eventlog: add evlog_push_record_tdb function. This is almost a copy of write_eventlog_tdb() and still needs to be modified to use tdb transactions. Guenther --- source3/include/proto.h | 4 ++ source3/rpc_server/srv_eventlog_lib.c | 74 +++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/source3/include/proto.h b/source3/include/proto.h index bf4976ec49..5c68e12566 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6266,6 +6266,10 @@ bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, bo struct eventlog_Record_tdb *evlog_pull_record_tdb(TALLOC_CTX *mem_ctx, TDB_CONTEXT *tdb, uint32_t record_number); +NTSTATUS evlog_push_record_tdb(TALLOC_CTX *mem_ctx, + TDB_CONTEXT *tdb, + struct eventlog_Record_tdb *r, + uint32_t *record_number); /* The following definitions come from rpc_server/srv_eventlog_nt.c */ diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index d6c4f1ab61..9d61307aaa 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -803,3 +803,77 @@ struct eventlog_Record_tdb *evlog_pull_record_tdb(TALLOC_CTX *mem_ctx, return r; } + +/******************************************************************** + write an eventlog entry. Note that we have to lock, read next + eventlog, increment, write, write the record, unlock + + coming into this, ee has the eventlog record, and the auxilliary date + (computer name, etc.) filled into the other structure. Before packing + into a record, this routine will calc the appropriate padding, etc., + and then blast out the record in a form that can be read back in + ********************************************************************/ + +NTSTATUS evlog_push_record_tdb(TALLOC_CTX *mem_ctx, + TDB_CONTEXT *tdb, + struct eventlog_Record_tdb *r, + uint32_t *record_number) +{ + TDB_DATA kbuf, ebuf; + DATA_BLOB blob; + enum ndr_err_code ndr_err; + int ret; + + if (!r) { + return NT_STATUS_INVALID_PARAMETER; + } + + if (!can_write_to_eventlog(tdb, r->size)) { + return NT_STATUS_EVENTLOG_CANT_START; + } + + /* need to read the record number and insert it into the entry here */ + + /* lock */ + ret = tdb_lock_bystring_with_timeout(tdb, EVT_NEXT_RECORD, 1); + if (ret == -1) { + return NT_STATUS_LOCK_NOT_GRANTED; + } + + /* read */ + r->record_number = tdb_fetch_int32(tdb, EVT_NEXT_RECORD); + + ndr_err = ndr_push_struct_blob(&blob, mem_ctx, NULL, r, + (ndr_push_flags_fn_t)ndr_push_eventlog_Record_tdb); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + tdb_unlock_bystring(tdb, EVT_NEXT_RECORD); + return ndr_map_error2ntstatus(ndr_err); + } + + /* increment the record count */ + + kbuf.dsize = sizeof(int32_t); + kbuf.dptr = (uint8_t *)&r->record_number; + + ebuf.dsize = blob.length; + ebuf.dptr = blob.data; + + ret = tdb_store(tdb, kbuf, ebuf, 0); + if (ret == -1) { + tdb_unlock_bystring(tdb, EVT_NEXT_RECORD); + return NT_STATUS_EVENTLOG_FILE_CORRUPT; + } + + ret = tdb_store_int32(tdb, EVT_NEXT_RECORD, r->record_number + 1); + if (ret == -1) { + tdb_unlock_bystring(tdb, EVT_NEXT_RECORD); + return NT_STATUS_EVENTLOG_FILE_CORRUPT; + } + tdb_unlock_bystring(tdb, EVT_NEXT_RECORD); + + if (record_number) { + *record_number = r->record_number; + } + + return NT_STATUS_OK; +} -- cgit From 16f83ae75003107084c50b8e45d1922889158d80 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 4 Feb 2009 10:01:38 +0100 Subject: s3-eventlog: add fixup_eventlog_record_tdb. Guenther --- source3/include/proto.h | 1 + source3/rpc_server/srv_eventlog_lib.c | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/source3/include/proto.h b/source3/include/proto.h index 5c68e12566..0b58460beb 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6263,6 +6263,7 @@ int elog_close_tdb( ELOG_TDB *etdb, bool force_close ); int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ); void fixup_eventlog_entry( Eventlog_entry * ee ); bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, bool * eor ); +size_t fixup_eventlog_record_tdb(struct eventlog_Record_tdb *r); struct eventlog_Record_tdb *evlog_pull_record_tdb(TALLOC_CTX *mem_ctx, TDB_CONTEXT *tdb, uint32_t record_number); diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 9d61307aaa..73aa5f94aa 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -749,6 +749,46 @@ bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, bo return true; } +/******************************************************************* + calculate the correct fields etc for an eventlog entry +*******************************************************************/ + +size_t fixup_eventlog_record_tdb(struct eventlog_Record_tdb *r) +{ + size_t size = 56; /* static size of integers before buffers start */ + + r->source_name_len = strlen_m_term(r->source_name) * 2; + r->computer_name_len = strlen_m_term(r->computer_name) * 2; + r->strings_len = ndr_size_string_array(r->strings, + r->num_of_strings, LIBNDR_FLAG_STR_NULLTERM) * 2; + + /* fix up the eventlog entry structure as necessary */ + r->sid_padding = ( ( 4 - ( ( r->source_name_len + r->computer_name_len ) % 4 ) ) % 4 ); + r->padding = ( 4 - ( ( r->strings_len + r->data_length ) % 4 ) ) % 4; + + if (r->sid_length == 0) { + /* Should not pad to a DWORD boundary for writing out the sid if there is + no SID, so just propagate the padding to pad the data */ + r->padding += r->sid_padding; + r->sid_padding = 0; + } + + size += r->source_name_len; + size += r->computer_name_len; + size += r->sid_padding; + size += r->sid_length; + size += r->strings_len; + size += r->data_length; + size += r->padding; + /* need another copy of length at the end of the data */ + size += sizeof(r->size); + + r->size = size; + + return size; +} + + /******************************************************************** ********************************************************************/ -- cgit From de7f0a70c8293f1b87f9c821f16fd3c6f7b184b7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 2 Feb 2009 17:24:28 +0100 Subject: s3-eventlogadm: use struct eventlog_Record_tdb for storing entries in tdbs. Guenther --- source3/include/proto.h | 2 +- source3/rpc_server/srv_eventlog_lib.c | 93 +++++++++++++++-------------------- source3/utils/eventlogadm.c | 23 +++++---- 3 files changed, 55 insertions(+), 63 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 0b58460beb..9f0caa2fa8 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6262,7 +6262,7 @@ ELOG_TDB *elog_open_tdb( const char *logname, bool force_clear, bool read_only ) int elog_close_tdb( ELOG_TDB *etdb, bool force_close ); int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ); void fixup_eventlog_entry( Eventlog_entry * ee ); -bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, bool * eor ); +bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, struct eventlog_Record_tdb *entry, bool * eor ); size_t fixup_eventlog_record_tdb(struct eventlog_Record_tdb *r); struct eventlog_Record_tdb *evlog_pull_record_tdb(TALLOC_CTX *mem_ctx, TDB_CONTEXT *tdb, diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 73aa5f94aa..85200d56ba 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -594,7 +594,7 @@ void fixup_eventlog_entry( Eventlog_entry * ee ) going in. ********************************************************************/ -bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, bool * eor ) +bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, struct eventlog_Record_tdb *entry, bool * eor ) { char *start = NULL, *stop = NULL; @@ -615,32 +615,32 @@ bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, bo if ( 0 == strncmp( start, "LEN", stop - start ) ) { /* This will get recomputed later anyway -- probably not necessary */ - entry->record.length = atoi( stop + 1 ); + entry->size = atoi( stop + 1 ); } else if ( 0 == strncmp( start, "RS1", stop - start ) ) { /* For now all these reserved entries seem to have the same value, which can be hardcoded to int(1699505740) for now */ - entry->record.reserved1 = atoi( stop + 1 ); + entry->reserved = talloc_strdup(mem_ctx, "eLfL"); } else if ( 0 == strncmp( start, "RCN", stop - start ) ) { - entry->record.record_number = atoi( stop + 1 ); + entry->record_number = atoi( stop + 1 ); } else if ( 0 == strncmp( start, "TMG", stop - start ) ) { - entry->record.time_generated = atoi( stop + 1 ); + entry->time_generated = atoi( stop + 1 ); } else if ( 0 == strncmp( start, "TMW", stop - start ) ) { - entry->record.time_written = atoi( stop + 1 ); + entry->time_written = atoi( stop + 1 ); } else if ( 0 == strncmp( start, "EID", stop - start ) ) { - entry->record.event_id = atoi( stop + 1 ); + entry->event_id = atoi( stop + 1 ); } else if ( 0 == strncmp( start, "ETP", stop - start ) ) { if ( strstr( start, "ERROR" ) ) { - entry->record.event_type = EVENTLOG_ERROR_TYPE; + entry->event_type = EVENTLOG_ERROR_TYPE; } else if ( strstr( start, "WARNING" ) ) { - entry->record.event_type = EVENTLOG_WARNING_TYPE; + entry->event_type = EVENTLOG_WARNING_TYPE; } else if ( strstr( start, "INFO" ) ) { - entry->record.event_type = EVENTLOG_INFORMATION_TYPE; + entry->event_type = EVENTLOG_INFORMATION_TYPE; } else if ( strstr( start, "AUDIT_SUCCESS" ) ) { - entry->record.event_type = EVENTLOG_AUDIT_SUCCESS; + entry->event_type = EVENTLOG_AUDIT_SUCCESS; } else if ( strstr( start, "AUDIT_FAILURE" ) ) { - entry->record.event_type = EVENTLOG_AUDIT_FAILURE; + entry->event_type = EVENTLOG_AUDIT_FAILURE; } else if ( strstr( start, "SUCCESS" ) ) { - entry->record.event_type = EVENTLOG_SUCCESS; + entry->event_type = EVENTLOG_SUCCESS; } else { /* some other eventlog type -- currently not defined in MSDN docs, so error out */ return False; @@ -650,27 +650,26 @@ bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, bo /* else if(0 == strncmp(start, "NST", stop - start)) { - entry->record.num_strings = atoi(stop + 1); + entry->num_of_strings = atoi(stop + 1); } */ else if ( 0 == strncmp( start, "ECT", stop - start ) ) { - entry->record.event_category = atoi( stop + 1 ); + entry->event_category = atoi( stop + 1 ); } else if ( 0 == strncmp( start, "RS2", stop - start ) ) { - entry->record.reserved2 = atoi( stop + 1 ); + entry->reserved_flags = atoi( stop + 1 ); } else if ( 0 == strncmp( start, "CRN", stop - start ) ) { - entry->record.closing_record_number = atoi( stop + 1 ); + entry->closing_record_number = atoi( stop + 1 ); } else if ( 0 == strncmp( start, "USL", stop - start ) ) { - entry->record.user_sid_length = atoi( stop + 1 ); + entry->sid_length = atoi( stop + 1 ); } else if ( 0 == strncmp( start, "SRC", stop - start ) ) { stop++; while ( isspace( stop[0] ) ) { stop++; } - entry->data_record.source_name_len = rpcstr_push_talloc(mem_ctx, - &entry->data_record.source_name, - stop); - if (entry->data_record.source_name_len == (uint32_t)-1 || - entry->data_record.source_name == NULL) { + entry->source_name_len = strlen_m_term(stop); + entry->source_name = talloc_strdup(mem_ctx, stop); + if (entry->source_name_len == (uint32_t)-1 || + entry->source_name == NULL) { return false; } } else if ( 0 == strncmp( start, "SRN", stop - start ) ) { @@ -678,54 +677,43 @@ bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, bo while ( isspace( stop[0] ) ) { stop++; } - entry->data_record.computer_name_len = rpcstr_push_talloc(mem_ctx, - &entry->data_record.computer_name, - stop); - if (entry->data_record.computer_name_len == (uint32_t)-1 || - entry->data_record.computer_name == NULL) { + entry->computer_name_len = strlen_m_term(stop); + entry->computer_name = talloc_strdup(mem_ctx, stop); + if (entry->computer_name_len == (uint32_t)-1 || + entry->computer_name == NULL) { return false; } } else if ( 0 == strncmp( start, "SID", stop - start ) ) { + smb_ucs2_t *dummy = NULL; stop++; while ( isspace( stop[0] ) ) { stop++; } - entry->record.user_sid_length = rpcstr_push_talloc(mem_ctx, - &entry->data_record.sid, + entry->sid_length = rpcstr_push_talloc(mem_ctx, + &dummy, stop); - if (entry->record.user_sid_length == (uint32_t)-1 || - entry->data_record.sid == NULL) { + entry->sid = data_blob_talloc(mem_ctx, dummy, entry->sid_length); + if (entry->sid_length == (uint32_t)-1 || + entry->sid.data == NULL) { return false; } } else if ( 0 == strncmp( start, "STR", stop - start ) ) { - smb_ucs2_t *temp = NULL; size_t tmp_len; - uint32_t old_len; /* skip past initial ":" */ stop++; /* now skip any other leading whitespace */ while ( isspace(stop[0])) { stop++; } - tmp_len = rpcstr_push_talloc(mem_ctx, - &temp, - stop); - if (tmp_len == (size_t)-1 || !temp) { + tmp_len = strlen_m_term(stop); + if (tmp_len == (size_t)-1) { return false; } - old_len = entry->data_record.strings_len; - entry->data_record.strings = (smb_ucs2_t *)TALLOC_REALLOC_ARRAY(mem_ctx, - entry->data_record.strings, - char, - old_len + tmp_len); - if (!entry->data_record.strings) { + if (!add_string_to_array(mem_ctx, stop, &entry->strings, + (int *)&entry->num_of_strings)) { return false; } - memcpy(((char *)entry->data_record.strings) + old_len, - temp, - tmp_len); - entry->data_record.strings_len += tmp_len; - entry->record.num_strings++; + entry->strings_len += tmp_len; } else if ( 0 == strncmp( start, "DAT", stop - start ) ) { /* skip past initial ":" */ stop++; @@ -733,10 +721,9 @@ bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, Eventlog_entry * entry, bo while ( isspace( stop[0] ) ) { stop++; } - entry->data_record.user_data_len = strlen(stop); - entry->data_record.user_data = talloc_strdup(mem_ctx, - stop); - if (!entry->data_record.user_data) { + entry->data_length = strlen_m(stop); + entry->data = data_blob_talloc(mem_ctx, stop, entry->data_length); + if (!entry->data.data) { return false; } } else { diff --git a/source3/utils/eventlogadm.c b/source3/utils/eventlogadm.c index b957ec2fab..d134ea8fea 100644 --- a/source3/utils/eventlogadm.c +++ b/source3/utils/eventlogadm.c @@ -5,6 +5,7 @@ * * * Copyright (C) Brian Moran 2005. + * 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 @@ -84,12 +85,13 @@ static int DoWriteCommand( int argc, char **argv, bool debugflag, char *exename FILE *f1; char *argfname; ELOG_TDB *etdb; + NTSTATUS status; /* fixed constants are bad bad bad */ char linein[1024]; bool is_eor; - Eventlog_entry ee; - int rcnum; + struct eventlog_Record_tdb ee; + uint32_t record_number; TALLOC_CTX *mem_ctx = talloc_tos(); f1 = stdin; @@ -128,22 +130,25 @@ static int DoWriteCommand( int argc, char **argv, bool debugflag, char *exename /* should we do something with the return code? */ if ( is_eor ) { - fixup_eventlog_entry( &ee ); + fixup_eventlog_record_tdb( &ee ); if ( opt_debug ) - printf( "record number [%d], tg [%d] , tw [%d]\n", ee.record.record_number, ee.record.time_generated, ee.record.time_written ); + printf( "record number [%d], tg [%d] , tw [%d]\n", + ee.record_number, (int)ee.time_generated, (int)ee.time_written ); - if ( ee.record.time_generated != 0 ) { + if ( ee.time_generated != 0 ) { /* printf("Writing to the event log\n"); */ - rcnum = write_eventlog_tdb( ELOG_TDB_CTX(etdb), &ee ); - if ( !rcnum ) { - printf( "Can't write to the event log\n" ); + status = evlog_push_record_tdb( mem_ctx, ELOG_TDB_CTX(etdb), + &ee, &record_number ); + if ( !NT_STATUS_IS_OK(status) ) { + printf( "Can't write to the event log: %s\n", + nt_errstr(status) ); } else { if ( opt_debug ) printf( "Wrote record %d\n", - rcnum ); + record_number ); } } else { if ( opt_debug ) -- cgit From 8eb562a81db03bac3e4bb469eaa45e0969be924e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 4 Feb 2009 18:09:48 +0100 Subject: Ensure null termination of the password in mymachinepw, remove a debug --- source3/auth/auth_netlogond.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source3/auth/auth_netlogond.c b/source3/auth/auth_netlogond.c index a57f3b74a3..9191c751f3 100644 --- a/source3/auth/auth_netlogond.c +++ b/source3/auth/auth_netlogond.c @@ -134,8 +134,6 @@ static char *mymachinepw(TALLOC_CTX *mem_ctx) return NULL; } - pwd[sizeof(pwd)-1] = '\0'; - nread = read(fd, pwd, sizeof(pwd)-1); close(fd); @@ -144,7 +142,7 @@ static char *mymachinepw(TALLOC_CTX *mem_ctx) return NULL; } - DEBUG(0, ("pwd: %d [%s]\n", (int)nread, pwd)); + pwd[nread] = '\0'; if (pwd[nread-1] == '\n') { pwd[nread-1] = '\0'; -- cgit From 9b3cce096ceca8b7d72456cbc6f0a725ad55d46c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 4 Feb 2009 18:10:28 +0100 Subject: Fix a valgrind error: rpc_bind talloc_move()s the auth struct --- source3/auth/auth_netlogond.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/source3/auth/auth_netlogond.c b/source3/auth/auth_netlogond.c index 9191c751f3..c39dd8c752 100644 --- a/source3/auth/auth_netlogond.c +++ b/source3/auth/auth_netlogond.c @@ -236,8 +236,6 @@ static NTSTATUS check_netlogond_security(const struct auth_context *auth_context goto done; } - TALLOC_FREE(auth); - plaintext_machinepw = mymachinepw(talloc_tos()); if (plaintext_machinepw == NULL) { status = NT_STATUS_NO_MEMORY; -- cgit From df5e231a6fad8c913881432294432e8feef6ea9f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 29 Jan 2009 15:11:39 +0100 Subject: s3-eventlog: add evlog_evt_entry_to_tdb_entry. Guenther --- source3/include/proto.h | 3 ++ source3/rpc_server/srv_eventlog_lib.c | 63 +++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/source3/include/proto.h b/source3/include/proto.h index 9f0caa2fa8..bb9d87eb53 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6271,6 +6271,9 @@ NTSTATUS evlog_push_record_tdb(TALLOC_CTX *mem_ctx, TDB_CONTEXT *tdb, struct eventlog_Record_tdb *r, uint32_t *record_number); +NTSTATUS evlog_evt_entry_to_tdb_entry(TALLOC_CTX *mem_ctx, + const struct EVENTLOGRECORD *e, + struct eventlog_Record_tdb *t); /* The following definitions come from rpc_server/srv_eventlog_nt.c */ diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 85200d56ba..247c8ac04b 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -904,3 +904,66 @@ NTSTATUS evlog_push_record_tdb(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } + +/******************************************************************** + ********************************************************************/ + +NTSTATUS evlog_evt_entry_to_tdb_entry(TALLOC_CTX *mem_ctx, + const struct EVENTLOGRECORD *e, + struct eventlog_Record_tdb *t) +{ + uint32_t i; + + ZERO_STRUCTP(t); + + t->size = e->Length; + t->reserved = e->Reserved; + t->record_number = e->RecordNumber; + t->time_generated = e->TimeGenerated; + t->time_written = e->TimeWritten; + t->event_id = e->EventID; + t->event_type = e->EventType; + t->num_of_strings = e->NumStrings; + t->event_category = e->EventCategory; + t->reserved_flags = e->ReservedFlags; + t->closing_record_number = e->ClosingRecordNumber; + + t->stringoffset = e->StringOffset; + t->sid_length = e->UserSidLength; + t->sid_offset = e->UserSidOffset; + t->data_length = e->DataLength; + t->data_offset = e->DataOffset; + + t->source_name_len = 2 * strlen_m_term(e->SourceName); + t->source_name = talloc_strdup(mem_ctx, e->SourceName); + NT_STATUS_HAVE_NO_MEMORY(t->source_name); + + t->computer_name_len = 2 * strlen_m_term(e->Computername); + t->computer_name = talloc_strdup(mem_ctx, e->Computername); + NT_STATUS_HAVE_NO_MEMORY(t->computer_name); + + /* t->sid_padding; */ + if (e->UserSidLength > 0) { + const char *sid_str = NULL; + smb_ucs2_t *dummy = NULL; + sid_str = sid_string_talloc(mem_ctx, &e->UserSid); + t->sid_length = rpcstr_push_talloc(mem_ctx, &dummy, sid_str); + if (t->sid_length == -1) { + return NT_STATUS_NO_MEMORY; + } + t->sid = data_blob_talloc(mem_ctx, (uint8_t *)dummy, t->sid_length); + NT_STATUS_HAVE_NO_MEMORY(t->sid.data); + } + + t->strings = talloc_array(mem_ctx, const char *, e->NumStrings); + for (i=0; i < e->NumStrings; i++) { + t->strings[i] = talloc_strdup(t->strings, e->Strings[i]); + NT_STATUS_HAVE_NO_MEMORY(t->strings[i]); + } + + t->strings_len = 2 * ndr_size_string_array(t->strings, t->num_of_strings, LIBNDR_FLAG_STR_NULLTERM); + t->data = data_blob_talloc(mem_ctx, e->Data, e->DataLength); + /* t->padding = r->Pad; */ + + return NT_STATUS_OK; +} -- cgit From 65200328eea3ab2179796ecf88a7ef276f8e2c9c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 4 Feb 2009 18:31:04 +0100 Subject: s3-eventlog: add evlog_tdb_entry_to_evt_entry. Guenther --- source3/include/proto.h | 3 ++ source3/rpc_server/srv_eventlog_lib.c | 63 +++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/source3/include/proto.h b/source3/include/proto.h index bb9d87eb53..3ae2448e4b 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6274,6 +6274,9 @@ NTSTATUS evlog_push_record_tdb(TALLOC_CTX *mem_ctx, NTSTATUS evlog_evt_entry_to_tdb_entry(TALLOC_CTX *mem_ctx, const struct EVENTLOGRECORD *e, struct eventlog_Record_tdb *t); +NTSTATUS evlog_tdb_entry_to_evt_entry(TALLOC_CTX *mem_ctx, + const struct eventlog_Record_tdb *t, + struct EVENTLOGRECORD *e); /* The following definitions come from rpc_server/srv_eventlog_nt.c */ diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 247c8ac04b..fdd3db9191 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -967,3 +967,66 @@ NTSTATUS evlog_evt_entry_to_tdb_entry(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } + +/******************************************************************** + ********************************************************************/ + +NTSTATUS evlog_tdb_entry_to_evt_entry(TALLOC_CTX *mem_ctx, + const struct eventlog_Record_tdb *t, + struct EVENTLOGRECORD *e) +{ + uint32_t i; + + ZERO_STRUCTP(e); + + e->Length = t->size; + e->Reserved = t->reserved; + e->RecordNumber = t->record_number; + e->TimeGenerated = t->time_generated; + e->TimeWritten = t->time_written; + e->EventID = t->event_id; + e->EventType = t->event_type; + e->NumStrings = t->num_of_strings; + e->EventCategory = t->event_category; + e->ReservedFlags = t->reserved_flags; + e->ClosingRecordNumber = t->closing_record_number; + + e->StringOffset = t->stringoffset; + e->UserSidLength = t->sid_length; + e->UserSidOffset = t->sid_offset; + e->DataLength = t->data_length; + e->DataOffset = t->data_offset; + + e->SourceName = talloc_strdup(mem_ctx, t->source_name); + NT_STATUS_HAVE_NO_MEMORY(e->SourceName); + + e->Computername = talloc_strdup(mem_ctx, t->computer_name); + NT_STATUS_HAVE_NO_MEMORY(e->Computername); + + if (t->sid_length > 0) { + const char *sid_str = NULL; + size_t len; + if (!convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, + t->sid.data, t->sid.length, + &sid_str, &len, false)) { + return NT_STATUS_INVALID_SID; + } + if (len > 0) { + e->UserSid = *string_sid_talloc(mem_ctx, sid_str); + } + } + + e->Strings = talloc_array(mem_ctx, const char *, t->num_of_strings); + for (i=0; i < t->num_of_strings; i++) { + e->Strings[i] = talloc_strdup(e->Strings, t->strings[i]); + NT_STATUS_HAVE_NO_MEMORY(e->Strings[i]); + } + + e->Data = (uint8_t *)talloc_memdup(mem_ctx, t->data.data, t->data_length); + e->Pad = talloc_strdup(mem_ctx, ""); + NT_STATUS_HAVE_NO_MEMORY(e->Pad); + + e->Length2 = t->size; + + return NT_STATUS_OK; +} -- cgit From 21d23bf7e893aa8afc128af419135f4d37b080f9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 23 Jan 2009 15:00:17 +0100 Subject: s3-net: add "net eventlog dump". This allows to dump a native (non-wrapped) win32 *.evt eventlog file. Guenther --- source3/Makefile.in | 11 +++-- source3/utils/net.c | 8 ++++ source3/utils/net_eventlog.c | 100 +++++++++++++++++++++++++++++++++++++++++++ source3/utils/net_proto.h | 3 ++ 4 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 source3/utils/net_eventlog.c diff --git a/source3/Makefile.in b/source3/Makefile.in index 992df5ecee..c4a631721c 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -530,6 +530,7 @@ REG_FULL_OBJ = $(REG_SMBCONF_OBJ) \ registry/reg_perfcount.o \ registry/reg_util_legacy.o +LIB_EVENTLOG_OBJ = rpc_server/srv_eventlog_lib.o RPC_LSA_OBJ = rpc_server/srv_lsa_nt.o ../librpc/gen_ndr/srv_lsa.o @@ -566,7 +567,7 @@ 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_EVENTLOG_OBJ = rpc_server/srv_eventlog.o rpc_server/srv_eventlog_nt.o \ - rpc_server/srv_eventlog_lib.o ../librpc/gen_ndr/srv_eventlog.o + $(LIB_EVENTLOG_OBJ) ../librpc/gen_ndr/srv_eventlog.o RPC_PIPE_OBJ = rpc_server/srv_pipe_hnd.o \ rpc_server/srv_pipe.o rpc_server/srv_lsa_hnd.o @@ -896,7 +897,8 @@ NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_help.o \ $(PASSWD_UTIL_OBJ) utils/net_dns.o utils/net_ads_gpo.o \ utils/net_conf.o utils/net_join.o utils/net_user.o \ utils/net_group.o utils/net_file.o utils/net_registry.o \ - auth/token_util.o utils/net_dom.o utils/net_share.o utils/net_lua.o + auth/token_util.o utils/net_dom.o utils/net_share.o utils/net_lua.o \ + utils/net_eventlog.o # these are not processed by make proto NET_OBJ2 = utils/net_registry_util.o utils/net_help_common.o @@ -914,7 +916,8 @@ NET_OBJ = $(NET_OBJ1) \ $(REG_SMBCONF_OBJ) @LIBNETAPI_STATIC@ $(LIBNET_OBJ) \ $(LIBSMBCONF_OBJ) \ @LIBWBCLIENT_STATIC@ \ - $(PRIVILEGES_BASIC_OBJ) @LIBLUA_STATIC@ + $(PRIVILEGES_BASIC_OBJ) @LIBLUA_STATIC@ \ + $(LIB_EVENTLOG_OBJ) CUPS_OBJ = client/smbspool.o $(PARAM_OBJ) $(LIBSMB_OBJ) \ $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) \ @@ -983,7 +986,7 @@ EVTLOGADM_OBJ0 = utils/eventlogadm.o EVTLOGADM_OBJ = $(EVTLOGADM_OBJ0) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \ $(LIBSAMBA_OBJ) \ - registry/reg_eventlog.o rpc_server/srv_eventlog_lib.o \ + registry/reg_eventlog.o $(LIB_EVENTLOG_OBJ) \ ../librpc/gen_ndr/ndr_eventlog.o \ ../librpc/gen_ndr/ndr_lsa.o diff --git a/source3/utils/net.c b/source3/utils/net.c index c9525ab2eb..d483198a9e 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -589,6 +589,14 @@ static struct functable net_func[] = { " Use 'net help lua' to get more information about 'net " "lua' commands." }, + { "eventlog", + net_eventlog, + NET_TRANSPORT_LOCAL, + "Dump Win32 *.evt eventlog files", + " Use 'net help eventlog' to get more information about 'net " + "eventlog' commands." + }, + #ifdef WITH_FAKE_KASERVER { "afs", net_afs, diff --git a/source3/utils/net_eventlog.c b/source3/utils/net_eventlog.c new file mode 100644 index 0000000000..79f04c5a7e --- /dev/null +++ b/source3/utils/net_eventlog.c @@ -0,0 +1,100 @@ +/* + * Samba Unix/Linux SMB client library + * Distributed SMB/CIFS Server Management Utility + * Local win32 eventlog interface + * + * 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 + * 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 . + */ + +#include "includes.h" +#include "utils/net.h" + +/** + * Dump an *evt win32 eventlog file + * + * @param argc Standard main() style argc. + * @param argv Standard main() style argv. Initial components are already + * stripped. + * + * @return A shell status integer (0 for success). + **/ + +static int net_eventlog_dump(struct net_context *c, int argc, + const char **argv) +{ + int ret = -1; + TALLOC_CTX *ctx = talloc_stackframe(); + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct EVENTLOG_EVT_FILE evt; + char *s; + + if (argc < 1 || c->display_usage) { + d_fprintf(stderr, "usage: net eventlog dump \n"); + goto done; + } + + blob.data = (uint8_t *)file_load(argv[0], &blob.length, 0, ctx); + if (!blob.data) { + d_fprintf(stderr, "failed to load evt file: %s\n", argv[0]); + goto done; + } + + ndr_err = ndr_pull_struct_blob(&blob, ctx, NULL, &evt, + (ndr_pull_flags_fn_t)ndr_pull_EVENTLOG_EVT_FILE); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + d_fprintf(stderr, "evt pull failed: %s\n", ndr_errstr(ndr_err)); + goto done; + } + + s = NDR_PRINT_STRUCT_STRING(ctx, EVENTLOG_EVT_FILE, &evt); + if (s) { + printf("%s\n", s); + } + + ret = 0; + done: + TALLOC_FREE(ctx); + return ret; +} + +/** + * 'net rpc eventlog' entrypoint. + * @param argc Standard main() style argc. + * @param argv Standard main() style argv. Initial components are already + * stripped. + **/ + +int net_eventlog(struct net_context *c, int argc, const char **argv) +{ + int ret = -1; + + struct functable func[] = { + { + "dump", + net_eventlog_dump, + NET_TRANSPORT_LOCAL, + "Dump eventlog", + "net eventlog dump\n" + " Dump win32 *.evt eventlog file" + }, + { NULL, NULL, 0, NULL, NULL } + }; + + ret = net_run_function(c, argc, argv, "net eventlog", func); + + return ret; +} diff --git a/source3/utils/net_proto.h b/source3/utils/net_proto.h index a65fbbb6eb..75ac032db9 100644 --- a/source3/utils/net_proto.h +++ b/source3/utils/net_proto.h @@ -427,6 +427,9 @@ int net_usershare(struct net_context *c, int argc, const char **argv); int net_lua(struct net_context *c, int argc, const char **argv); +/* The following definitions come from utils/net_eventlog.c */ + +int net_eventlog(struct net_context *c, int argc, const char **argv); /* The following definitions come from utils/net_util.c */ -- cgit From c0cf20a49e34eec76422e79d463eb780c5c53e96 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 26 Jan 2009 16:41:46 +0100 Subject: s3-net: add "net eventlog import". This allows to import a native (non-wrapped) win32 *.evt eventlog file into our tdb eventlog representation. Guenther --- source3/utils/net_eventlog.c | 104 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/source3/utils/net_eventlog.c b/source3/utils/net_eventlog.c index 79f04c5a7e..034f0612cc 100644 --- a/source3/utils/net_eventlog.c +++ b/source3/utils/net_eventlog.c @@ -71,6 +71,101 @@ static int net_eventlog_dump(struct net_context *c, int argc, return ret; } +/** + * Import an *evt win32 eventlog file to internal tdb representation + * + * @param argc Standard main() style argc. + * @param argv Standard main() style argv. Initial components are already + * stripped. + * + * @return A shell status integer (0 for success). + **/ + +static int net_eventlog_import(struct net_context *c, int argc, + const char **argv) +{ + int ret = -1; + TALLOC_CTX *ctx = talloc_stackframe(); + NTSTATUS status; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + uint32_t num_records = 0; + uint32_t i; + ELOG_TDB *etdb = NULL; + + struct EVENTLOGHEADER evt_header; + struct EVENTLOG_EVT_FILE evt; + + if (argc < 2 || c->display_usage) { + d_fprintf(stderr, "usage: net eventlog import \n"); + goto done; + } + + blob.data = (uint8_t *)file_load(argv[0], &blob.length, 0, ctx); + if (!blob.data) { + d_fprintf(stderr, "failed to load evt file: %s\n", argv[0]); + goto done; + } + + /* dump_data(0, blob.data, blob.length); */ + ndr_err = ndr_pull_struct_blob(&blob, ctx, NULL, &evt_header, + (ndr_pull_flags_fn_t)ndr_pull_EVENTLOGHEADER); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + d_fprintf(stderr, "evt header pull failed: %s\n", ndr_errstr(ndr_err)); + goto done; + } + + if (evt_header.Flags & ELF_LOGFILE_HEADER_WRAP) { + d_fprintf(stderr, "input file is wrapped, cannot proceed\n"); + goto done; + } + + ndr_err = ndr_pull_struct_blob(&blob, ctx, NULL, &evt, + (ndr_pull_flags_fn_t)ndr_pull_EVENTLOG_EVT_FILE); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + d_fprintf(stderr, "evt pull failed: %s\n", ndr_errstr(ndr_err)); + goto done; + } + + /* NDR_PRINT_DEBUG(EVENTLOG_EVT_FILE, &evt); */ + + etdb = elog_open_tdb(argv[1], false, false); + if (!etdb) { + d_fprintf(stderr, "can't open the eventlog TDB (%s)\n", argv[1]); + goto done; + } + + num_records = evt.hdr.CurrentRecordNumber - evt.hdr.OldestRecordNumber; + + for (i=0; i Date: Thu, 29 Jan 2009 15:33:20 +0100 Subject: s3-net: add "net eventlog export". This allows to export our tdb eventlog representation into a native win32 *.evt eventlog file. Guenther --- source3/utils/net_eventlog.c | 109 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/source3/utils/net_eventlog.c b/source3/utils/net_eventlog.c index 034f0612cc..197a7cd330 100644 --- a/source3/utils/net_eventlog.c +++ b/source3/utils/net_eventlog.c @@ -166,6 +166,106 @@ static int net_eventlog_import(struct net_context *c, int argc, return ret; } +/** + * Export internal eventlog tdb representation to an *evt win32 eventlog file + * + * @param argc Standard main() style argc. + * @param argv Standard main() style argv. Initial components are already + * stripped. + * + * @return A shell status integer (0 for success). + **/ + +static int net_eventlog_export(struct net_context *c, int argc, + const char **argv) +{ + int ret = -1; + NTSTATUS status; + TALLOC_CTX *ctx = talloc_stackframe(); + enum ndr_err_code ndr_err; + DATA_BLOB blob; + uint32_t num_records = 0; + struct EVENTLOG_EVT_FILE evt; + ELOG_TDB *etdb = NULL; + uint32_t count = 1; + size_t endoffset = 0; + + if (argc < 2 || c->display_usage) { + d_fprintf(stderr, "usage: net eventlog export \n"); + goto done; + } + + etdb = elog_open_tdb(argv[1], false, true); + if (!etdb) { + d_fprintf(stderr, "can't open the eventlog TDB (%s)\n", argv[1]); + goto done; + } + + ZERO_STRUCT(evt); + + while (1) { + + struct eventlog_Record_tdb *r; + struct EVENTLOGRECORD e; + + r = evlog_pull_record_tdb(ctx, etdb->tdb, count); + if (!r) { + break; + } + + status = evlog_tdb_entry_to_evt_entry(ctx, r, &e); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + endoffset += ndr_size_EVENTLOGRECORD(&e, NULL, 0); + + ADD_TO_ARRAY(ctx, struct EVENTLOGRECORD, e, &evt.records, &num_records); + count++; + } + + evt.hdr.StartOffset = 0x30; + evt.hdr.EndOffset = evt.hdr.StartOffset + endoffset; + evt.hdr.CurrentRecordNumber = count; + evt.hdr.OldestRecordNumber = 1; + evt.hdr.MaxSize = tdb_fetch_int32(etdb->tdb, EVT_MAXSIZE); + evt.hdr.Flags = 0; + evt.hdr.Retention = tdb_fetch_int32(etdb->tdb, EVT_RETENTION); + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_DEBUG(EVENTLOGHEADER, &evt.hdr); + } + + evt.eof.BeginRecord = 0x30; + evt.eof.EndRecord = evt.hdr.StartOffset + endoffset; + evt.eof.CurrentRecordNumber = evt.hdr.CurrentRecordNumber; + evt.eof.OldestRecordNumber = evt.hdr.OldestRecordNumber; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_DEBUG(EVENTLOGEOF, &evt.eof); + } + + ndr_err = ndr_push_struct_blob(&blob, ctx, NULL, &evt, + (ndr_push_flags_fn_t)ndr_push_EVENTLOG_EVT_FILE); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + d_fprintf(stderr, "evt push failed: %s\n", ndr_errstr(ndr_err)); + goto done; + } + + if (!file_save(argv[0], blob.data, blob.length)) { + d_fprintf(stderr, "failed to save evt file: %s\n", argv[0]); + goto done; + } + + ret = 0; + done: + + elog_close_tdb(etdb, false); + + TALLOC_FREE(ctx); + return ret; +} + /** * 'net rpc eventlog' entrypoint. * @param argc Standard main() style argc. @@ -194,6 +294,15 @@ int net_eventlog(struct net_context *c, int argc, const char **argv) "net eventlog import\n" " Import win32 *.evt eventlog file" }, + { + "export", + net_eventlog_export, + NET_TRANSPORT_LOCAL, + "Export eventlog", + "net eventlog export\n" + " Export win32 *.evt eventlog file" + }, + { NULL, NULL, 0, NULL, NULL } }; -- cgit From 1b71fa5c59f3af4f096a640839c7d48b20b2266a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 3 Feb 2009 13:09:59 +0100 Subject: s3-eventlog: add evlog_pull_record function. Guenther --- source3/include/proto.h | 3 +++ source3/rpc_server/srv_eventlog_lib.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/source3/include/proto.h b/source3/include/proto.h index 3ae2448e4b..0f9779f2f8 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6271,6 +6271,9 @@ NTSTATUS evlog_push_record_tdb(TALLOC_CTX *mem_ctx, TDB_CONTEXT *tdb, struct eventlog_Record_tdb *r, uint32_t *record_number); +struct EVENTLOGRECORD *evlog_pull_record(TALLOC_CTX *mem_ctx, + TDB_CONTEXT *tdb, + uint32_t record_number); NTSTATUS evlog_evt_entry_to_tdb_entry(TALLOC_CTX *mem_ctx, const struct EVENTLOGRECORD *e, struct eventlog_Record_tdb *t); diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index fdd3db9191..1cd306c5f2 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -831,6 +831,39 @@ struct eventlog_Record_tdb *evlog_pull_record_tdb(TALLOC_CTX *mem_ctx, return r; } +/******************************************************************** + ********************************************************************/ + +struct EVENTLOGRECORD *evlog_pull_record(TALLOC_CTX *mem_ctx, + TDB_CONTEXT *tdb, + uint32_t record_number) +{ + struct eventlog_Record_tdb *t; + struct EVENTLOGRECORD *r; + NTSTATUS status; + + r = talloc_zero(mem_ctx, struct EVENTLOGRECORD); + if (!r) { + return NULL; + } + + t = evlog_pull_record_tdb(r, tdb, record_number); + if (!t) { + talloc_free(r); + return NULL; + } + + status = evlog_tdb_entry_to_evt_entry(r, t, r); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(r); + return NULL; + } + + r->Length = r->Length2 = ndr_size_EVENTLOGRECORD(r, NULL, 0); + + return r; +} + /******************************************************************** write an eventlog entry. Note that we have to lock, read next eventlog, increment, write, write the record, unlock -- cgit From 63a992168db48568c91fe622e81141ca00c9bc45 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 3 Feb 2009 13:08:44 +0100 Subject: s3-eventlog: add evlog_push_record function. Guenther --- source3/include/proto.h | 4 ++++ source3/rpc_server/srv_eventlog_lib.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/source3/include/proto.h b/source3/include/proto.h index 0f9779f2f8..68c4c8b8e3 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6271,6 +6271,10 @@ NTSTATUS evlog_push_record_tdb(TALLOC_CTX *mem_ctx, TDB_CONTEXT *tdb, struct eventlog_Record_tdb *r, uint32_t *record_number); +NTSTATUS evlog_push_record(TALLOC_CTX *mem_ctx, + TDB_CONTEXT *tdb, + struct EVENTLOGRECORD *r, + uint32_t *record_number); struct EVENTLOGRECORD *evlog_pull_record(TALLOC_CTX *mem_ctx, TDB_CONTEXT *tdb, uint32_t record_number); diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 1cd306c5f2..2c70141360 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -938,6 +938,34 @@ NTSTATUS evlog_push_record_tdb(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } +/******************************************************************** + ********************************************************************/ + +NTSTATUS evlog_push_record(TALLOC_CTX *mem_ctx, + TDB_CONTEXT *tdb, + struct EVENTLOGRECORD *r, + uint32_t *record_number) +{ + struct eventlog_Record_tdb *t; + NTSTATUS status; + + t = talloc_zero(mem_ctx, struct eventlog_Record_tdb); + if (!t) { + return NT_STATUS_NO_MEMORY; + } + + status = evlog_evt_entry_to_tdb_entry(t, r, t); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(t); + return status; + } + + status = evlog_push_record_tdb(mem_ctx, tdb, t, record_number); + talloc_free(t); + + return status; +} + /******************************************************************** ********************************************************************/ -- cgit From 456bd5ad08d754691706f955970cddba3846c3a7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 15 Jan 2009 20:10:09 +0100 Subject: s3-eventlog: use pidl for _eventlog_ReadEventLogW. Guenther --- source3/rpc_server/srv_eventlog.c | 22 +------ source3/rpc_server/srv_eventlog_nt.c | 123 +++++++++++++++++++---------------- 2 files changed, 69 insertions(+), 76 deletions(-) diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c index 39e3115561..dd00a247fd 100644 --- a/source3/rpc_server/srv_eventlog.c +++ b/source3/rpc_server/srv_eventlog.c @@ -63,27 +63,7 @@ static bool api_eventlog_get_oldest_entry(pipes_struct *p) static bool api_eventlog_read_eventlog(pipes_struct *p) { - EVENTLOG_Q_READ_EVENTLOG q_u; - EVENTLOG_R_READ_EVENTLOG r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!(eventlog_io_q_read_eventlog("", &q_u, data, 0))) { - DEBUG(0, ("eventlog_io_q_read_eventlog: unable to unmarshall EVENTLOG_Q_READ_EVENTLOG.\n")); - return False; - } - - r_u.status = _eventlog_read_eventlog(p, &q_u, &r_u); - - if (!(eventlog_io_r_read_eventlog("", &q_u, &r_u, rdata, 0))) { - DEBUG(0, ("eventlog_io_r_read_eventlog: unable to marshall EVENTLOG_R_READ_EVENTLOG.\n")); - return False; - } - - return True; + return proxy_eventlog_call(p, NDR_EVENTLOG_READEVENTLOGW); } static bool api_eventlog_clear_eventlog(pipes_struct *p) diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 990b03a570..aaf5d16098 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -706,98 +706,117 @@ NTSTATUS _eventlog_CloseEventLog(pipes_struct * p, } /******************************************************************** + _eventlog_ReadEventLogW ********************************************************************/ -NTSTATUS _eventlog_read_eventlog( pipes_struct * p, - EVENTLOG_Q_READ_EVENTLOG * q_u, - EVENTLOG_R_READ_EVENTLOG * r_u ) +NTSTATUS _eventlog_ReadEventLogW(pipes_struct *p, + struct eventlog_ReadEventLogW *r) { - EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); - Eventlog_entry *entry = NULL, *ee_new = NULL; - uint32 num_records_read = 0; + EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, r->in.handle ); + uint32_t num_records_read = 0; int bytes_left, record_number; - uint32 elog_read_type, elog_read_dir; + uint32_t elog_read_type, elog_read_dir; - if (info == NULL) { + if (!info) { return NT_STATUS_INVALID_HANDLE; } - info->flags = q_u->flags; + info->flags = r->in.flags; + bytes_left = r->in.number_of_bytes; - bytes_left = q_u->max_read_size; - - if ( !info->etdb ) + if (!info->etdb) { return NT_STATUS_ACCESS_DENIED; + } /* check for valid flags. Can't use the sequential and seek flags together */ - elog_read_type = q_u->flags & (EVENTLOG_SEQUENTIAL_READ|EVENTLOG_SEEK_READ); - elog_read_dir = q_u->flags & (EVENTLOG_FORWARDS_READ|EVENTLOG_BACKWARDS_READ); + elog_read_type = r->in.flags & (EVENTLOG_SEQUENTIAL_READ|EVENTLOG_SEEK_READ); + elog_read_dir = r->in.flags & (EVENTLOG_FORWARDS_READ|EVENTLOG_BACKWARDS_READ); - if ( elog_read_type == (EVENTLOG_SEQUENTIAL_READ|EVENTLOG_SEEK_READ) - || elog_read_dir == (EVENTLOG_FORWARDS_READ|EVENTLOG_BACKWARDS_READ) ) + if (r->in.flags == 0 || + elog_read_type == (EVENTLOG_SEQUENTIAL_READ|EVENTLOG_SEEK_READ) || + elog_read_dir == (EVENTLOG_FORWARDS_READ|EVENTLOG_BACKWARDS_READ)) { - DEBUG(3,("_eventlog_read_eventlog: Invalid flags [0x%x] for ReadEventLog\n", q_u->flags)); + DEBUG(3,("_eventlog_ReadEventLogW: " + "Invalid flags [0x%08x] for ReadEventLog\n", + r->in.flags)); return NT_STATUS_INVALID_PARAMETER; } /* a sequential read should ignore the offset */ - if ( elog_read_type & EVENTLOG_SEQUENTIAL_READ ) + if (elog_read_type & EVENTLOG_SEQUENTIAL_READ) { record_number = info->current_record; - else - record_number = q_u->offset; + } else { + record_number = r->in.offset; + } - while ( bytes_left > 0 ) { + if (r->in.number_of_bytes == 0) { + struct EVENTLOGRECORD *e; + e = evlog_pull_record(p->mem_ctx, ELOG_TDB_CTX(info->etdb), + record_number); + if (!e) { + return NT_STATUS_END_OF_FILE; + } + *r->out.real_size = e->Length; + return NT_STATUS_BUFFER_TOO_SMALL; + } + + while (bytes_left > 0) { - /* assume that when the record fetch fails, that we are done */ + DATA_BLOB blob; + enum ndr_err_code ndr_err; + struct EVENTLOGRECORD *e; - entry = get_eventlog_record (p->mem_ctx, ELOG_TDB_CTX(info->etdb), record_number); - if (!entry) { + e = evlog_pull_record(p->mem_ctx, ELOG_TDB_CTX(info->etdb), + record_number); + if (!e) { break; } - DEBUG( 8, ( "Retrieved record %d\n", record_number ) ); - - /* Now see if there is enough room to add */ - - if ( !(ee_new = read_package_entry( p->mem_ctx, entry )) ) - return NT_STATUS_NO_MEMORY; + ndr_err = ndr_push_struct_blob(&blob, p->mem_ctx, NULL, e, + (ndr_push_flags_fn_t)ndr_push_EVENTLOGRECORD); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return ndr_map_error2ntstatus(ndr_err); + } - if ( r_u->num_bytes_in_resp + ee_new->record.length > q_u->max_read_size ) { - r_u->bytes_in_next_record = ee_new->record.length; + if (DEBUGLEVEL >= 10) { + NDR_PRINT_DEBUG(EVENTLOGRECORD, e); + } - /* response would be too big to fit in client-size buffer */ + if (blob.length > r->in.number_of_bytes) { + *r->out.real_size = blob.length; + return NT_STATUS_BUFFER_TOO_SMALL; + } - bytes_left = 0; + if (*r->out.sent_size + blob.length > r->in.number_of_bytes) { break; } - add_record_to_resp( r_u, ee_new ); - bytes_left -= ee_new->record.length; - TALLOC_FREE(entry); - num_records_read = r_u->num_records - num_records_read; + bytes_left -= blob.length; - DEBUG( 10, ( "_eventlog_read_eventlog: read [%d] records for a total " - "of [%d] records using [%d] bytes out of a max of [%d].\n", - num_records_read, r_u->num_records, - r_u->num_bytes_in_resp, - q_u->max_read_size ) ); - - if ( info->flags & EVENTLOG_FORWARDS_READ ) + if (info->flags & EVENTLOG_FORWARDS_READ) { record_number++; - else + } else { record_number--; + } /* update the eventlog record pointer */ info->current_record = record_number; + + memcpy(&r->out.data[*(r->out.sent_size)], + blob.data, blob.length); + *(r->out.sent_size) += blob.length; + + num_records_read++; } - /* crazy by WinXP uses NT_STATUS_BUFFER_TOO_SMALL to - say when there are no more records */ + if (r->in.offset == 0 && record_number == 0 && *r->out.sent_size == 0) { + return NT_STATUS_END_OF_FILE; + } - return (num_records_read ? NT_STATUS_OK : NT_STATUS_BUFFER_TOO_SMALL); + return NT_STATUS_OK; } /******************************************************************** @@ -872,12 +891,6 @@ NTSTATUS _eventlog_OpenBackupEventLogW(pipes_struct *p, struct eventlog_OpenBack return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _eventlog_ReadEventLogW(pipes_struct *p, struct eventlog_ReadEventLogW *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _eventlog_ReportEventW(pipes_struct *p, struct eventlog_ReportEventW *r) { p->rng_fault_state = True; -- cgit From f24eecffde12937103dfce9bf91a69742eb75b29 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 16 Jan 2009 12:48:11 +0100 Subject: s3-eventlog: add my copyright. Guenther --- source3/rpc_server/srv_eventlog_lib.c | 1 + source3/rpc_server/srv_eventlog_nt.c | 1 + 2 files changed, 2 insertions(+) diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 2c70141360..d894ab0f81 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -4,6 +4,7 @@ * Copyright (C) Marcin Krzysztof Porwit 2005, * Copyright (C) Brian Moran 2005. * Copyright (C) Gerald (Jerry) Carter 2005. + * 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 diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index aaf5d16098..b4f7afc2b7 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -4,6 +4,7 @@ * Copyright (C) Marcin Krzysztof Porwit 2005, * Copyright (C) Brian Moran 2005, * Copyright (C) Gerald (Jerry) Carter 2005. + * 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 -- cgit From 94d1dbbaf01acff05dc0237470268ec85d02fdbb Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 4 Feb 2009 22:35:23 +0100 Subject: Restore correct handling of "is_data_available" for the socket transport This fixes a valgrind error reading an uninitialized variable --- source3/rpc_server/srv_pipe_hnd.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index fa38176749..30d0cf408f 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1221,6 +1221,7 @@ NTSTATUS np_write_recv(struct async_req *req, ssize_t *pnwritten) struct np_read_state { ssize_t nread; bool is_data_outstanding; + int fd; }; static void np_read_done(struct async_req *subreq); @@ -1255,6 +1256,7 @@ struct async_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev, handle->private_data, struct np_proxy_state); state->nread = len; + state->fd = p->fd; subreq = recvall_send(state, ev, p->fd, data, len, 0); if (subreq == NULL) { @@ -1279,13 +1281,24 @@ static void np_read_done(struct async_req *subreq) { struct async_req *req = talloc_get_type_abort( subreq->async.priv, struct async_req); + struct np_read_state *state = talloc_get_type_abort( + req->private_data, struct np_read_state); NTSTATUS status; + int available = 0; status = recvall_recv(subreq); if (!NT_STATUS_IS_OK(status)) { async_req_nterror(req, status); return; } + + /* + * We don't look at the ioctl result. We don't really care if there is + * data available, because this is racy anyway. + */ + ioctl(state->fd, FIONREAD, &available); + state->is_data_outstanding = (available > 0); + async_req_done(req); } -- cgit From c464b5ebc07a27d7ab01629f87fc053dd90882ed Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 16 Jan 2009 12:18:21 +0100 Subject: s3-rpcclient: fix eventlog read client to read an array of entries. Guenther --- source3/rpcclient/cmd_eventlog.c | 67 ++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 17 deletions(-) diff --git a/source3/rpcclient/cmd_eventlog.c b/source3/rpcclient/cmd_eventlog.c index 905b147ce6..e212452e5d 100644 --- a/source3/rpcclient/cmd_eventlog.c +++ b/source3/rpcclient/cmd_eventlog.c @@ -55,7 +55,7 @@ static NTSTATUS cmd_eventlog_readlog(struct rpc_pipe_client *cli, int argc, const char **argv) { - NTSTATUS status; + NTSTATUS status = NT_STATUS_OK; struct policy_handle handle; uint32_t flags = EVENTLOG_BACKWARDS_READ | @@ -67,7 +67,7 @@ static NTSTATUS cmd_eventlog_readlog(struct rpc_pipe_client *cli, uint32_t real_size = 0; if (argc < 2 || argc > 4) { - printf("Usage: %s logname [offset]\n", argv[0]); + printf("Usage: %s logname [offset] [number_of_bytes]\n", argv[0]); return NT_STATUS_OK; } @@ -75,12 +75,27 @@ static NTSTATUS cmd_eventlog_readlog(struct rpc_pipe_client *cli, offset = atoi(argv[2]); } + if (argc >= 4) { + number_of_bytes = atoi(argv[3]); + data = talloc_array(mem_ctx, uint8_t, number_of_bytes); + if (!data) { + goto done; + } + } + status = get_eventlog_handle(cli, mem_ctx, argv[1], &handle); if (!NT_STATUS_IS_OK(status)) { return status; } - while (1) { + do { + + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct EVENTLOGRECORD r; + uint32_t size = 0; + uint32_t pos = 0; + status = rpccli_eventlog_ReadEventLogW(cli, mem_ctx, &handle, flags, @@ -93,35 +108,53 @@ static NTSTATUS cmd_eventlog_readlog(struct rpc_pipe_client *cli, real_size > 0 ) { number_of_bytes = real_size; data = talloc_array(mem_ctx, uint8_t, real_size); - continue; + if (!data) { + goto done; + } + status = rpccli_eventlog_ReadEventLogW(cli, mem_ctx, + &handle, + flags, + offset, + number_of_bytes, + data, + &sent_size, + &real_size); } - number_of_bytes = 0; - - if (!NT_STATUS_IS_OK(status)) { + if (!NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) && + !NT_STATUS_IS_OK(status)) { goto done; } - { - enum ndr_err_code ndr_err; - DATA_BLOB blob; - struct eventlog_Record rec; + number_of_bytes = 0; + + size = IVAL(data, pos); - blob = data_blob_const(data, sent_size); + while (size > 0) { - ndr_err = ndr_pull_struct_blob_all(&blob, mem_ctx, NULL, - &rec, - (ndr_pull_flags_fn_t)ndr_pull_eventlog_Record); + blob = data_blob_const(data + pos, size); + /* dump_data(0, blob.data, blob.length); */ + ndr_err = ndr_pull_struct_blob_all(&blob, mem_ctx, NULL, &r, + (ndr_pull_flags_fn_t)ndr_pull_EVENTLOGRECORD); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { status = ndr_map_error2ntstatus(ndr_err); goto done; } - NDR_PRINT_DEBUG(eventlog_Record, &rec); + NDR_PRINT_DEBUG(EVENTLOGRECORD, &r); + + pos += size; + + if (pos + 4 > sent_size) { + break; + } + + size = IVAL(data, pos); } offset++; - } + + } while (NT_STATUS_IS_OK(status)); done: rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle); -- cgit From 64e3a90530e4231fc9725652535a4881b149228a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 3 Feb 2009 20:48:43 +0100 Subject: s3-eventlog: make can_write_to_eventlog static. Guenther --- source3/include/proto.h | 1 - source3/rpc_server/srv_eventlog_lib.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 68c4c8b8e3..5cef54f82c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6257,7 +6257,6 @@ TDB_CONTEXT *elog_init_tdb( char *tdbfilename ); char *elog_tdbname(TALLOC_CTX *ctx, const char *name ); int elog_tdb_size( TDB_CONTEXT * tdb, int *MaxSize, int *Retention ); bool prune_eventlog( TDB_CONTEXT * tdb ); -bool can_write_to_eventlog( TDB_CONTEXT * tdb, int32 needed ); ELOG_TDB *elog_open_tdb( const char *logname, bool force_clear, bool read_only ); int elog_close_tdb( ELOG_TDB *etdb, bool force_close ); int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ); diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index d894ab0f81..c5d2ad737e 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -270,7 +270,7 @@ bool prune_eventlog( TDB_CONTEXT * tdb ) /******************************************************************** ********************************************************************/ -bool can_write_to_eventlog( TDB_CONTEXT * tdb, int32_t needed ) +static bool can_write_to_eventlog( TDB_CONTEXT * tdb, int32_t needed ) { int calcd_size; int MaxSize, Retention; -- cgit From 858116d54e61f2d86757aecce3afba147434c7fc Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 16 Jan 2009 18:04:11 +0100 Subject: s4-smbtorture: in eventlog readlog test, print all records in a buffer. Guenther --- source4/torture/rpc/eventlog.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/source4/torture/rpc/eventlog.c b/source4/torture/rpc/eventlog.c index d5bc4e6501..2fd9d923f1 100644 --- a/source4/torture/rpc/eventlog.c +++ b/source4/torture/rpc/eventlog.c @@ -125,9 +125,10 @@ static bool test_ReadEventLog(struct torture_context *tctx, while (1) { DATA_BLOB blob; - struct eventlog_Record rec; - struct ndr_pull *ndr; + struct EVENTLOGRECORD rec; enum ndr_err_code ndr_err; + uint32_t size = 0; + uint32_t pos = 0; /* Read first for number of bytes in record */ @@ -140,6 +141,7 @@ static bool test_ReadEventLog(struct torture_context *tctx, status = dcerpc_eventlog_ReadEventLogW(p, tctx, &r); if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_END_OF_FILE)) { + /* FIXME: still need to decode then */ break; } @@ -156,17 +158,32 @@ static bool test_ReadEventLog(struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "ReadEventLog failed"); /* Decode a user-marshalled record */ + size = IVAL(r.out.data, pos); - blob.length = *r.out.sent_size; - blob.data = talloc_steal(tctx, r.out.data); + while (size > 0) { - ndr = ndr_pull_init_blob(&blob, tctx, lp_iconv_convenience(tctx->lp_ctx)); + blob = data_blob_const(r.out.data + pos, size); + dump_data(0, blob.data, blob.length); - ndr_err = ndr_pull_eventlog_Record( - ndr, NDR_SCALARS|NDR_BUFFERS, &rec); - status = ndr_map_error2ntstatus(ndr_err); + ndr_err = ndr_pull_struct_blob_all(&blob, tctx, + lp_iconv_convenience(tctx->lp_ctx), &rec, + (ndr_pull_flags_fn_t)ndr_pull_EVENTLOGRECORD); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); + torture_assert_ntstatus_ok(tctx, status, + "ReadEventLog failed parsing event log record"); + } - NDR_PRINT_DEBUG(eventlog_Record, &rec); + NDR_PRINT_DEBUG(EVENTLOGRECORD, &rec); + + pos += size; + + if (pos + 4 > *r.out.sent_size) { + break; + } + + size = IVAL(r.out.data, pos); + } torture_assert_ntstatus_ok(tctx, status, "ReadEventLog failed parsing event log record"); -- cgit From 7ade5cf776a4aa04ae578cfeb46a54bfde53700f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 4 Feb 2009 21:32:20 +0100 Subject: s3-eventlog: remove old hand marshalling for eventlog read call. Guenther --- source3/include/proto.h | 12 --- source3/include/rpc_eventlog.h | 19 ---- source3/rpc_parse/parse_eventlog.c | 183 ------------------------------------- 3 files changed, 214 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 5cef54f82c..9067dcd4dc 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5677,14 +5677,6 @@ uint32 size_of_relative_string(UNISTR *string); /* The following definitions come from rpc_parse/parse_eventlog.c */ -bool eventlog_io_q_read_eventlog(const char *desc, EVENTLOG_Q_READ_EVENTLOG *q_u, - prs_struct *ps, int depth); -bool eventlog_io_r_read_eventlog(const char *desc, - EVENTLOG_Q_READ_EVENTLOG *q_u, - EVENTLOG_R_READ_EVENTLOG *r_u, - prs_struct *ps, - int depth); - /* The following definitions come from rpc_parse/parse_misc.c */ bool smb_io_time(const char *desc, NTTIME *nttime, prs_struct *ps, int depth); @@ -6286,10 +6278,6 @@ NTSTATUS evlog_tdb_entry_to_evt_entry(TALLOC_CTX *mem_ctx, /* The following definitions come from rpc_server/srv_eventlog_nt.c */ -NTSTATUS _eventlog_read_eventlog( pipes_struct * p, - EVENTLOG_Q_READ_EVENTLOG * q_u, - EVENTLOG_R_READ_EVENTLOG * r_u ); - /* The following definitions come from rpc_server/srv_lsa_hnd.c */ bool init_pipe_handle_list(pipes_struct *p, diff --git a/source3/include/rpc_eventlog.h b/source3/include/rpc_eventlog.h index f17e448d9e..43bbc18285 100644 --- a/source3/include/rpc_eventlog.h +++ b/source3/include/rpc_eventlog.h @@ -37,14 +37,6 @@ /***********************************/ -typedef struct -{ - POLICY_HND handle; - uint32 flags; - uint32 offset; - uint32 max_read_size; -} EVENTLOG_Q_READ_EVENTLOG; - typedef struct { uint32 length; uint32 reserved1; @@ -85,16 +77,5 @@ typedef struct eventlog_entry { uint8 *end_of_data_padding; struct eventlog_entry *next; } Eventlog_entry; - -typedef struct { - uint32 num_bytes_in_resp; - uint32 bytes_in_next_record; - uint32 num_records; - Eventlog_entry *entry; - uint8 *end_of_entries_padding; - uint32 sent_size; - uint32 real_size; - NTSTATUS status; -} EVENTLOG_R_READ_EVENTLOG; #endif /* _RPC_EVENTLOG_H */ diff --git a/source3/rpc_parse/parse_eventlog.c b/source3/rpc_parse/parse_eventlog.c index 40930a2500..45bd4b591e 100644 --- a/source3/rpc_parse/parse_eventlog.c +++ b/source3/rpc_parse/parse_eventlog.c @@ -25,186 +25,3 @@ /******************************************************************** ********************************************************************/ -bool eventlog_io_q_read_eventlog(const char *desc, EVENTLOG_Q_READ_EVENTLOG *q_u, - prs_struct *ps, int depth) -{ - if(q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "eventlog_io_q_read_eventlog"); - depth++; - - if(!(prs_align(ps))) - return False; - - if(!(smb_io_pol_hnd("log handle", &(q_u->handle), ps, depth))) - return False; - - if(!(prs_uint32("read flags", ps, depth, &(q_u->flags)))) - return False; - - if(!(prs_uint32("read offset", ps, depth, &(q_u->offset)))) - return False; - - if(!(prs_uint32("read buf size", ps, depth, &(q_u->max_read_size)))) - return False; - - return True; -} - -static bool smb_io_eventlog_entry(const char *name, prs_struct *ps, int depth, Eventlog_entry *entry) -{ - if(entry == NULL) - return False; - - prs_debug(ps, depth, name, "smb_io_eventlog_entry"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!(prs_uint32("length", ps, depth, &(entry->record.length)))) - return False; - if(!(prs_uint32("reserved", ps, depth, &(entry->record.reserved1)))) - return False; - if(!(prs_uint32("record number", ps, depth, &(entry->record.record_number)))) - return False; - if(!(prs_uint32("time generated", ps, depth, &(entry->record.time_generated)))) - return False; - if(!(prs_uint32("time written", ps, depth, &(entry->record.time_written)))) - return False; - if(!(prs_uint32("event id", ps, depth, &(entry->record.event_id)))) - return False; - if(!(prs_uint16("event type", ps, depth, &(entry->record.event_type)))) - return False; - if(!(prs_uint16("num strings", ps, depth, &(entry->record.num_strings)))) - return False; - if(!(prs_uint16("event category", ps, depth, &(entry->record.event_category)))) - return False; - if(!(prs_uint16("reserved2", ps, depth, &(entry->record.reserved2)))) - return False; - if(!(prs_uint32("closing record", ps, depth, &(entry->record.closing_record_number)))) - return False; - if(!(prs_uint32("string offset", ps, depth, &(entry->record.string_offset)))) - return False; - if(!(prs_uint32("user sid length", ps, depth, &(entry->record.user_sid_length)))) - return False; - if(!(prs_uint32("user sid offset", ps, depth, &(entry->record.user_sid_offset)))) - return False; - if(!(prs_uint32("data length", ps, depth, &(entry->record.data_length)))) - return False; - if(!(prs_uint32("data offset", ps, depth, &(entry->record.data_offset)))) - return False; - if(!(prs_align(ps))) - return False; - - /* Now encoding data */ - - if(!(prs_uint8s(False, "buffer", ps, depth, entry->data, - entry->record.length - sizeof(Eventlog_record) - sizeof(entry->record.length)))) - { - return False; - } - - if(!(prs_align(ps))) - return False; - - if(!(prs_uint32("length 2", ps, depth, &(entry->record.length)))) - return False; - - return True; -} - -/** Structure of response seems to be: - DWORD num_bytes_in_resp -- MUST be the same as q_u->max_read_size - for i=0..n - EVENTLOGRECORD record - DWORD sent_size -- sum of EVENTLOGRECORD lengths if records returned, 0 otherwise - DWORD real_size -- 0 if records returned, otherwise length of next record to be returned - WERROR status */ -bool eventlog_io_r_read_eventlog(const char *desc, - EVENTLOG_Q_READ_EVENTLOG *q_u, - EVENTLOG_R_READ_EVENTLOG *r_u, - prs_struct *ps, - int depth) -{ - Eventlog_entry *entry; - uint32 record_written = 0; - uint32 record_total = 0; - - if(r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "eventlog_io_r_read_eventlog"); - depth++; - - /* First, see if we've read more logs than we can output */ - - if(r_u->num_bytes_in_resp > q_u->max_read_size) { - entry = r_u->entry; - - /* remove the size of the last entry from the list */ - - while(entry->next != NULL) - entry = entry->next; - - r_u->num_bytes_in_resp -= entry->record.length; - - /* do not output the last log entry */ - - r_u->num_records--; - } - - entry = r_u->entry; - record_total = r_u->num_records; - - if(r_u->num_bytes_in_resp != 0) - r_u->sent_size = r_u->num_bytes_in_resp; - else - r_u->real_size = r_u->bytes_in_next_record; - - if(!(prs_align(ps))) - return False; - if(!(prs_uint32("bytes in resp", ps, depth, &(q_u->max_read_size)))) - return False; - - while(entry != NULL && record_written < record_total) - { - DEBUG(11, ("eventlog_io_r_read_eventlog: writing record [%d] out of [%d].\n", record_written, record_total)); - - /* Encode the actual eventlog record record */ - - if (!(smb_io_eventlog_entry("entry", ps, depth, entry))) - return false; - - entry = entry->next; - record_written++; - - } /* end of encoding EVENTLOGRECORD */ - - /* Now pad with whitespace until the end of the response buffer */ - - if (q_u->max_read_size - r_u->num_bytes_in_resp) { - r_u->end_of_entries_padding = PRS_ALLOC_MEM(ps, uint8_t, q_u->max_read_size - r_u->num_bytes_in_resp); - if (!r_u->end_of_entries_padding) { - return False; - } - - if(!(prs_uint8s(False, "end of entries padding", ps, - depth, r_u->end_of_entries_padding, - (q_u->max_read_size - r_u->num_bytes_in_resp)))) { - return False; - } - } - - /* We had better be DWORD aligned here */ - - if(!(prs_uint32("sent size", ps, depth, &(r_u->sent_size)))) - return False; - if(!(prs_uint32("real size", ps, depth, &(r_u->real_size)))) - return False; - if(!(prs_ntstatus("status code", ps, depth, &r_u->status))) - return False; - - return True; -} -- cgit From 58ded409abe336b9bcf048912c884f0deec281dc Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 4 Feb 2009 21:33:58 +0100 Subject: s3-eventlog: remove get_eventlog_record. Guenther --- source3/rpc_server/srv_eventlog_nt.c | 134 ----------------------------------- 1 file changed, 134 deletions(-) diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index b4f7afc2b7..b378556f43 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -276,140 +276,6 @@ static int elog_size( EVENTLOG_INFO *info ) return elog_tdb_size( ELOG_TDB_CTX(info->etdb), NULL, NULL ); } -/******************************************************************** - For the given tdb, get the next eventlog record into the passed - Eventlog_entry. returns NULL if it can't get the record for some reason. - ********************************************************************/ - -static Eventlog_entry *get_eventlog_record(TALLOC_CTX *mem_ctx, - TDB_CONTEXT *tdb, - int recno) -{ - Eventlog_entry *ee = NULL; - TDB_DATA ret, key; - - int32_t srecno; - int32_t reclen; - int len; - - char *wpsource = NULL; - char *wpcomputer = NULL; - char *wpsid = NULL; - char *wpstrs = NULL; - char *puserdata = NULL; - - key.dsize = sizeof(int32_t); - - srecno = recno; - key.dptr = (unsigned char *)&srecno; - - ret = tdb_fetch( tdb, key ); - - if ( ret.dsize == 0 ) { - DEBUG( 8, - ( "Can't find a record for the key, record %d\n", - recno ) ); - return NULL; - } - - len = tdb_unpack( ret.dptr, ret.dsize, "d", &reclen ); - - DEBUG( 10, ( "Unpacking record %d, size is %d\n", srecno, len ) ); - - if ( !len ) - return NULL; - - ee = TALLOC_ARRAY(mem_ctx, Eventlog_entry, 1); - if (!ee) { - return NULL; - } - ZERO_STRUCTP(ee); - - len = tdb_unpack( ret.dptr, ret.dsize, "ddddddwwwwddddddBBdBBBd", - &ee->record.length, &ee->record.reserved1, - &ee->record.record_number, - &ee->record.time_generated, - &ee->record.time_written, &ee->record.event_id, - &ee->record.event_type, &ee->record.num_strings, - &ee->record.event_category, &ee->record.reserved2, - &ee->record.closing_record_number, - &ee->record.string_offset, - &ee->record.user_sid_length, - &ee->record.user_sid_offset, - &ee->record.data_length, &ee->record.data_offset, - &ee->data_record.source_name_len, &wpsource, - &ee->data_record.computer_name_len, &wpcomputer, - &ee->data_record.sid_padding, - &ee->record.user_sid_length, &wpsid, - &ee->data_record.strings_len, &wpstrs, - &ee->data_record.user_data_len, &puserdata, - &ee->data_record.data_padding ); - DEBUG( 10, - ( "Read record %d, len in tdb was %d\n", - ee->record.record_number, len ) ); - - /* have to do the following because the tdb_unpack allocs a buff, stuffs a pointer to the buff - into it's 2nd argment for 'B' */ - - if (wpcomputer) { - ee->data_record.computer_name = (smb_ucs2_t *)TALLOC_MEMDUP( - ee, wpcomputer, ee->data_record.computer_name_len); - if (!ee->data_record.computer_name) { - TALLOC_FREE(ee); - goto out; - } - } - if (wpsource) { - ee->data_record.source_name = (smb_ucs2_t *)TALLOC_MEMDUP( - ee, wpsource, ee->data_record.source_name_len); - if (!ee->data_record.source_name) { - TALLOC_FREE(ee); - goto out; - } - } - - if (wpsid) { - ee->data_record.sid = (smb_ucs2_t *)TALLOC_MEMDUP( - ee, wpsid, ee->record.user_sid_length); - if (!ee->data_record.sid) { - TALLOC_FREE(ee); - goto out; - } - } - if (wpstrs) { - ee->data_record.strings = (smb_ucs2_t *)TALLOC_MEMDUP( - ee, wpstrs, ee->data_record.strings_len); - if (!ee->data_record.strings) { - TALLOC_FREE(ee); - goto out; - } - } - - if (puserdata) { - ee->data_record.user_data = (char *)TALLOC_MEMDUP( - ee, puserdata, ee->data_record.user_data_len); - if (!ee->data_record.user_data) { - TALLOC_FREE(ee); - goto out; - } - } - - out: - - SAFE_FREE(wpcomputer); - SAFE_FREE(wpsource); - SAFE_FREE(wpsid); - SAFE_FREE(wpstrs); - SAFE_FREE(puserdata); - - DEBUG( 10, ( "get_eventlog_record: read back %d\n", len ) ); - DEBUG( 10, - ( "get_eventlog_record: computer_name %d is ", - ee->data_record.computer_name_len ) ); - SAFE_FREE(ret.dptr); - return ee; -} - /******************************************************************** note that this can only be called AFTER the table is constructed, since it uses the table to find the tdb handle -- cgit From 96fd6b5a01cbc9f91ea818943e28036fba7cd248 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 4 Feb 2009 21:34:35 +0100 Subject: s3-eventlog: remove read_package_entry. Guenther --- source3/rpc_server/srv_eventlog_nt.c | 92 ------------------------------------ 1 file changed, 92 deletions(-) diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index b378556f43..4a2ea2f2c0 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -350,98 +350,6 @@ done: return ret; } -/******************************************************************** - ********************************************************************/ - -static Eventlog_entry *read_package_entry( TALLOC_CTX *mem_ctx, - Eventlog_entry * entry ) -{ - uint8 *offset; - Eventlog_entry *ee_new = NULL; - - ee_new = TALLOC_ZERO_ARRAY(mem_ctx, Eventlog_entry, 1 ); - if ( ee_new == NULL ) { - return NULL; - } - - entry->data_record.sid_padding = - ( ( 4 - - ( ( entry->data_record.source_name_len + - entry->data_record.computer_name_len ) % 4 ) ) % 4 ); - entry->data_record.data_padding = - ( 4 - - ( ( entry->data_record.strings_len + - entry->data_record.user_data_len ) % 4 ) ) % 4; - entry->record.length = sizeof( Eventlog_record ); - entry->record.length += entry->data_record.source_name_len; - entry->record.length += entry->data_record.computer_name_len; - if ( entry->record.user_sid_length == 0 ) { - /* Should not pad to a DWORD boundary for writing out the sid if there is - no SID, so just propagate the padding to pad the data */ - entry->data_record.data_padding += - entry->data_record.sid_padding; - entry->data_record.sid_padding = 0; - } - DEBUG( 10, - ( "sid_padding is [%d].\n", entry->data_record.sid_padding ) ); - DEBUG( 10, - ( "data_padding is [%d].\n", - entry->data_record.data_padding ) ); - - entry->record.length += entry->data_record.sid_padding; - entry->record.length += entry->record.user_sid_length; - entry->record.length += entry->data_record.strings_len; - entry->record.length += entry->data_record.user_data_len; - entry->record.length += entry->data_record.data_padding; - /* need another copy of length at the end of the data */ - entry->record.length += sizeof( entry->record.length ); - DEBUG( 10, - ( "entry->record.length is [%d].\n", entry->record.length ) ); - entry->data = - TALLOC_ZERO_ARRAY(mem_ctx, uint8_t, - entry->record.length - - sizeof( Eventlog_record ) - - sizeof( entry->record.length )); - if ( entry->data == NULL ) { - return NULL; - } - offset = entry->data; - memcpy( offset, entry->data_record.source_name, - entry->data_record.source_name_len ); - offset += entry->data_record.source_name_len; - memcpy( offset, entry->data_record.computer_name, - entry->data_record.computer_name_len ); - offset += entry->data_record.computer_name_len; - /* SID needs to be DWORD-aligned */ - offset += entry->data_record.sid_padding; - entry->record.user_sid_offset = - sizeof( Eventlog_record ) + ( offset - entry->data ); - memcpy( offset, entry->data_record.sid, - entry->record.user_sid_length ); - offset += entry->record.user_sid_length; - /* Now do the strings */ - entry->record.string_offset = - sizeof( Eventlog_record ) + ( offset - entry->data ); - memcpy( offset, entry->data_record.strings, - entry->data_record.strings_len ); - offset += entry->data_record.strings_len; - /* Now do the data */ - entry->record.data_length = entry->data_record.user_data_len; - entry->record.data_offset = - sizeof( Eventlog_record ) + ( offset - entry->data ); - memcpy( offset, entry->data_record.user_data, - entry->data_record.user_data_len ); - offset += entry->data_record.user_data_len; - - memcpy( &( ee_new->record ), &entry->record, - sizeof( Eventlog_record ) ); - memcpy( &( ee_new->data_record ), &entry->data_record, - sizeof( Eventlog_data_record ) ); - ee_new->data = entry->data; - - return ee_new; -} - /******************************************************************** ********************************************************************/ -- cgit From abb4faf813dcc70435d4b47c94c50e0da004fa4f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 4 Feb 2009 21:35:29 +0100 Subject: s3-eventlog: remove add_record_to_resp. Guenther --- source3/rpc_server/srv_eventlog_nt.c | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 4a2ea2f2c0..697457888e 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -350,32 +350,6 @@ done: return ret; } -/******************************************************************** - ********************************************************************/ - -static bool add_record_to_resp( EVENTLOG_R_READ_EVENTLOG * r_u, - Eventlog_entry * ee_new ) -{ - Eventlog_entry *insert_point; - - insert_point = r_u->entry; - - if ( NULL == insert_point ) { - r_u->entry = ee_new; - ee_new->next = NULL; - } else { - while ( ( NULL != insert_point->next ) ) { - insert_point = insert_point->next; - } - ee_new->next = NULL; - insert_point->next = ee_new; - } - r_u->num_records++; - r_u->num_bytes_in_resp += ee_new->record.length; - - return True; -} - /******************************************************************** _eventlog_OpenEventLogW ********************************************************************/ -- cgit From 8b126e942d5251cc7be08634dd73a598f8a834eb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 3 Feb 2009 14:14:39 +0100 Subject: s3-eventlog: remove write_eventlog_tdb. Guenther --- source3/include/proto.h | 1 - source3/rpc_server/srv_eventlog_lib.c | 104 ---------------------------------- 2 files changed, 105 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 9067dcd4dc..db45d979cb 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6251,7 +6251,6 @@ int elog_tdb_size( TDB_CONTEXT * tdb, int *MaxSize, int *Retention ); bool prune_eventlog( TDB_CONTEXT * tdb ); ELOG_TDB *elog_open_tdb( const char *logname, bool force_clear, bool read_only ); int elog_close_tdb( ELOG_TDB *etdb, bool force_close ); -int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ); void fixup_eventlog_entry( Eventlog_entry * ee ); bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, struct eventlog_Record_tdb *entry, bool * eor ); size_t fixup_eventlog_record_tdb(struct eventlog_Record_tdb *r); diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index c5d2ad737e..95aca087b1 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -446,110 +446,6 @@ int elog_close_tdb( ELOG_TDB *etdb, bool force_close ) } -/******************************************************************* - write an eventlog entry. Note that we have to lock, read next - eventlog, increment, write, write the record, unlock - - coming into this, ee has the eventlog record, and the auxilliary date - (computer name, etc.) filled into the other structure. Before packing - into a record, this routine will calc the appropriate padding, etc., - and then blast out the record in a form that can be read back in -*******************************************************************/ - -#define MARGIN 512 - -int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ) -{ - int32 next_record; - uint8 *packed_ee; - TALLOC_CTX *mem_ctx = NULL; - TDB_DATA kbuf, ebuf; - uint32_t n_packed; - - if ( !ee ) - return 0; - - mem_ctx = talloc_init( "write_eventlog_tdb" ); - - if ( mem_ctx == NULL ) - return 0; - - /* discard any entries that have bogus time, which usually indicates a bogus entry as well. */ - if ( ee->record.time_generated == 0 ) - return 0; - - /* todo - check for sanity in next_record */ - - fixup_eventlog_entry( ee ); - - if ( !can_write_to_eventlog( the_tdb, ee->record.length ) ) { - DEBUG( 3, ( "Can't write to Eventlog, no room \n" ) ); - talloc_destroy( mem_ctx ); - return 0; - } - - /* alloc mem for the packed version */ - packed_ee = (uint8 *)TALLOC( mem_ctx, ee->record.length + MARGIN ); - if ( !packed_ee ) { - talloc_destroy( mem_ctx ); - return 0; - } - - /* need to read the record number and insert it into the entry here */ - - /* lock */ - tdb_lock_bystring_with_timeout( the_tdb, EVT_NEXT_RECORD, 1 ); - /* read */ - next_record = tdb_fetch_int32( the_tdb, EVT_NEXT_RECORD ); - - n_packed = - tdb_pack( (uint8 *)packed_ee, ee->record.length + MARGIN, - "ddddddwwwwddddddBBdBBBd", ee->record.length, - ee->record.reserved1, next_record, - ee->record.time_generated, ee->record.time_written, - ee->record.event_id, ee->record.event_type, - ee->record.num_strings, ee->record.event_category, - ee->record.reserved2, - ee->record.closing_record_number, - ee->record.string_offset, - ee->record.user_sid_length, - ee->record.user_sid_offset, ee->record.data_length, - ee->record.data_offset, - ee->data_record.source_name_len, - ee->data_record.source_name, - ee->data_record.computer_name_len, - ee->data_record.computer_name, - ee->data_record.sid_padding, - ee->record.user_sid_length, ee->data_record.sid, - ee->data_record.strings_len, - ee->data_record.strings, - ee->data_record.user_data_len, - ee->data_record.user_data, - ee->data_record.data_padding ); - - /*DEBUG(3,("write_eventlog_tdb: packed into %d\n",n_packed)); */ - - /* increment the record count */ - - kbuf.dsize = sizeof( int32 ); - kbuf.dptr = (uint8 * ) & next_record; - - ebuf.dsize = n_packed; - ebuf.dptr = (uint8 *)packed_ee; - - if ( tdb_store( the_tdb, kbuf, ebuf, 0 ) ) { - /* DEBUG(1,("write_eventlog_tdb: Can't write record %d to eventlog\n",next_record)); */ - tdb_unlock_bystring( the_tdb, EVT_NEXT_RECORD ); - talloc_destroy( mem_ctx ); - return 0; - } - next_record++; - tdb_store_int32( the_tdb, EVT_NEXT_RECORD, next_record ); - tdb_unlock_bystring( the_tdb, EVT_NEXT_RECORD ); - talloc_destroy( mem_ctx ); - return ( next_record - 1 ); -} - /******************************************************************* calculate the correct fields etc for an eventlog entry *******************************************************************/ -- cgit From d7e2384dba448753580c698cb3b460ba8849ccb9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 4 Feb 2009 21:42:32 +0100 Subject: s3-eventlog: remove fixup_eventlog_entry. Guenther --- source3/include/proto.h | 1 - source3/rpc_server/srv_eventlog_lib.c | 38 ----------------------------------- 2 files changed, 39 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index db45d979cb..f1580cbb55 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6251,7 +6251,6 @@ int elog_tdb_size( TDB_CONTEXT * tdb, int *MaxSize, int *Retention ); bool prune_eventlog( TDB_CONTEXT * tdb ); ELOG_TDB *elog_open_tdb( const char *logname, bool force_clear, bool read_only ); int elog_close_tdb( ELOG_TDB *etdb, bool force_close ); -void fixup_eventlog_entry( Eventlog_entry * ee ); bool parse_logentry( TALLOC_CTX *mem_ctx, char *line, struct eventlog_Record_tdb *entry, bool * eor ); size_t fixup_eventlog_record_tdb(struct eventlog_Record_tdb *r); struct eventlog_Record_tdb *evlog_pull_record_tdb(TALLOC_CTX *mem_ctx, diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 95aca087b1..57b3be43ad 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -445,44 +445,6 @@ int elog_close_tdb( ELOG_TDB *etdb, bool force_close ) return 0; } - -/******************************************************************* - calculate the correct fields etc for an eventlog entry -*******************************************************************/ - -void fixup_eventlog_entry( Eventlog_entry * ee ) -{ - /* fix up the eventlog entry structure as necessary */ - - ee->data_record.sid_padding = - ( ( 4 - - ( ( ee->data_record.source_name_len + - ee->data_record.computer_name_len ) % 4 ) ) % 4 ); - ee->data_record.data_padding = - ( 4 - - ( ( ee->data_record.strings_len + - ee->data_record.user_data_len ) % 4 ) ) % 4; - ee->record.length = sizeof( Eventlog_record ); - ee->record.length += ee->data_record.source_name_len; - ee->record.length += ee->data_record.computer_name_len; - if ( ee->record.user_sid_length == 0 ) { - /* Should not pad to a DWORD boundary for writing out the sid if there is - no SID, so just propagate the padding to pad the data */ - ee->data_record.data_padding += ee->data_record.sid_padding; - ee->data_record.sid_padding = 0; - } - /* DEBUG(10, ("sid_padding is [%d].\n", ee->data_record.sid_padding)); */ - /* DEBUG(10, ("data_padding is [%d].\n", ee->data_record.data_padding)); */ - - ee->record.length += ee->data_record.sid_padding; - ee->record.length += ee->record.user_sid_length; - ee->record.length += ee->data_record.strings_len; - ee->record.length += ee->data_record.user_data_len; - ee->record.length += ee->data_record.data_padding; - /* need another copy of length at the end of the data */ - ee->record.length += sizeof( ee->record.length ); -} - /******************************************************************** Note that it's a pretty good idea to initialize the Eventlog_entry structure to zero's before calling parse_logentry on an batch of -- cgit From a63d4c5ed1d6fc6dd253d5bf99edbef7d9d0341b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 4 Feb 2009 21:49:06 +0100 Subject: s3-eventlog: remove old eventlog server. Guenther --- source3/Makefile.in | 2 +- source3/configure.in | 4 +- source3/include/proto.h | 5 -- source3/rpc_server/srv_eventlog.c | 99 --------------------------------------- 4 files changed, 3 insertions(+), 107 deletions(-) delete mode 100644 source3/rpc_server/srv_eventlog.c diff --git a/source3/Makefile.in b/source3/Makefile.in index c4a631721c..19df505cc2 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -566,7 +566,7 @@ 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_EVENTLOG_OBJ = rpc_server/srv_eventlog.o rpc_server/srv_eventlog_nt.o \ +RPC_EVENTLOG_OBJ = rpc_server/srv_eventlog_nt.o \ $(LIB_EVENTLOG_OBJ) ../librpc/gen_ndr/srv_eventlog.o RPC_PIPE_OBJ = rpc_server/srv_pipe_hnd.o \ diff --git a/source3/configure.in b/source3/configure.in index 1a25de8992..306566f26e 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -414,7 +414,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 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_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin auth_netlogond vfs_default nss_info_template" +default_static_modules="pdb_smbpasswd pdb_tdbsam 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_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" @@ -6340,7 +6340,7 @@ SMB_MODULE(rpc_netlogon, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RP 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_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC) -SMB_MODULE(rpc_eventlog2, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog2.$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) SMB_SUBSYSTEM(RPC,smbd/server.o) diff --git a/source3/include/proto.h b/source3/include/proto.h index f1580cbb55..6987e9968b 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6238,11 +6238,6 @@ bool spoolss_io_r_xcvdataport(const char *desc, SPOOL_R_XCVDATAPORT *r_u, prs_st bool make_monitorui_buf( RPC_BUFFER *buf, const char *dllname ); bool convert_port_data_1( NT_PORT_DATA_1 *port1, RPC_BUFFER *buf ) ; -/* The following definitions come from rpc_server/srv_eventlog.c */ - -NTSTATUS rpc_eventlog2_init(void); -void eventlog2_get_pipe_fns(struct api_struct **fns, int *n_fns); - /* The following definitions come from rpc_server/srv_eventlog_lib.c */ TDB_CONTEXT *elog_init_tdb( char *tdbfilename ); diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c deleted file mode 100644 index dd00a247fd..0000000000 --- a/source3/rpc_server/srv_eventlog.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Marcin Krzysztof Porwit 2005. - * Copyright (C) Gerald Carter 2005 - 2007 - * - * 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 . - */ - -#include "includes.h" -#include "librpc/gen_ndr/srv_eventlog.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -static bool proxy_eventlog_call(pipes_struct *p, uint8 opnum) -{ - struct api_struct *fns; - int n_fns; - - eventlog_get_pipe_fns(&fns, &n_fns); - - if (opnum >= n_fns) - return False; - - if (fns[opnum].opnum != opnum) { - smb_panic("EVENTLOG function table not sorted\n"); - } - - return fns[opnum].fn(p); -} - -static bool api_eventlog_open_eventlog(pipes_struct *p) -{ - return proxy_eventlog_call(p, NDR_EVENTLOG_OPENEVENTLOGW); -} - -static bool api_eventlog_close_eventlog(pipes_struct *p) -{ - return proxy_eventlog_call( p, NDR_EVENTLOG_CLOSEEVENTLOG ); -} - -static bool api_eventlog_get_num_records(pipes_struct *p) -{ - return proxy_eventlog_call(p, NDR_EVENTLOG_GETNUMRECORDS); -} - -static bool api_eventlog_get_oldest_entry(pipes_struct *p) -{ - return proxy_eventlog_call(p, NDR_EVENTLOG_GETOLDESTRECORD); -} - -static bool api_eventlog_read_eventlog(pipes_struct *p) -{ - return proxy_eventlog_call(p, NDR_EVENTLOG_READEVENTLOGW); -} - -static bool api_eventlog_clear_eventlog(pipes_struct *p) -{ - return proxy_eventlog_call(p, NDR_EVENTLOG_CLEAREVENTLOGW); -} - -/* - \pipe\eventlog commands -*/ -struct api_struct api_eventlog_cmds[] = -{ - {"EVENTLOG_OPENEVENTLOG", EVENTLOG_OPENEVENTLOG, api_eventlog_open_eventlog }, - {"EVENTLOG_CLOSEEVENTLOG", EVENTLOG_CLOSEEVENTLOG, api_eventlog_close_eventlog }, - {"EVENTLOG_GETNUMRECORDS", EVENTLOG_GETNUMRECORDS, api_eventlog_get_num_records }, - {"EVENTLOG_GETOLDESTENTRY", EVENTLOG_GETOLDESTENTRY, api_eventlog_get_oldest_entry }, - {"EVENTLOG_READEVENTLOG", EVENTLOG_READEVENTLOG, api_eventlog_read_eventlog }, - {"EVENTLOG_CLEAREVENTLOG", EVENTLOG_CLEAREVENTLOG, api_eventlog_clear_eventlog } -}; - -NTSTATUS rpc_eventlog2_init(void) -{ - return rpc_srv_register(SMB_RPC_INTERFACE_VERSION, - "eventlog", "eventlog", &ndr_table_eventlog, - api_eventlog_cmds, - sizeof(api_eventlog_cmds)/sizeof(struct api_struct)); -} - -void eventlog2_get_pipe_fns(struct api_struct **fns, int *n_fns) -{ - *fns = api_eventlog_cmds; - *n_fns = sizeof(api_eventlog_cmds) / sizeof(struct api_struct); -} -- cgit From 8450e6677bfc2b42d7fe54fbf24c9f8ff07b40e1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 4 Feb 2009 21:50:51 +0100 Subject: s3-eventlog: w00t! remove last traces of old eventlog rpc marshalling. spoolss, I'm coming! Guenther --- source3/Makefile.in | 2 +- source3/include/includes.h | 1 - source3/include/proto.h | 2 - source3/include/rpc_eventlog.h | 81 -------------------------------------- source3/rpc_parse/parse_eventlog.c | 27 ------------- 5 files changed, 1 insertion(+), 112 deletions(-) delete mode 100644 source3/include/rpc_eventlog.h delete mode 100644 source3/rpc_parse/parse_eventlog.c diff --git a/source3/Makefile.in b/source3/Makefile.in index 19df505cc2..c1b51db571 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -578,7 +578,7 @@ RPC_SERVER_OBJ = @RPC_STATIC@ $(RPC_PIPE_OBJ) RPC_PARSE_OBJ = $(RPC_PARSE_OBJ2) \ rpc_parse/parse_spoolss.o \ - rpc_parse/parse_eventlog.o rpc_parse/parse_buffer.o + rpc_parse/parse_buffer.o 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 diff --git a/source3/include/includes.h b/source3/include/includes.h index ebd8923769..a20a17c33d 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -623,7 +623,6 @@ struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx); #include "reg_objects.h" #include "reg_db.h" #include "rpc_spoolss.h" -#include "rpc_eventlog.h" #include "rpc_perfcount.h" #include "rpc_perfcount_defs.h" #include "librpc/gen_ndr/notify.h" diff --git a/source3/include/proto.h b/source3/include/proto.h index 6987e9968b..88742c451d 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5675,8 +5675,6 @@ bool smb_io_relarraystr(const char *desc, RPC_BUFFER *buffer, int depth, uint16 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_eventlog.c */ - /* The following definitions come from rpc_parse/parse_misc.c */ bool smb_io_time(const char *desc, NTTIME *nttime, prs_struct *ps, int depth); diff --git a/source3/include/rpc_eventlog.h b/source3/include/rpc_eventlog.h deleted file mode 100644 index 43bbc18285..0000000000 --- a/source3/include/rpc_eventlog.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Marcin Krzysztof Porwit 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 . - */ - -#ifndef _RPC_EVENTLOG_H /* _RPC_EVENTLOG_H */ -#define _RPC_EVENTLOG_H - -/* opcodes */ - -#define EVENTLOG_CLEAREVENTLOG 0x00 -#define EVENTLOG_CLOSEEVENTLOG 0x02 -#define EVENTLOG_GETNUMRECORDS 0x04 -#define EVENTLOG_GETOLDESTENTRY 0x05 -#define EVENTLOG_OPENEVENTLOG 0x07 -#define EVENTLOG_READEVENTLOG 0x0a - -/* Eventlog read flags */ -/* defined in librpc/gen_ndr/eventlog.h */ - -/* Event types */ -/* defined in librpc/gen_ndr/eventlog.h */ - -/***********************************/ - -typedef struct { - uint32 length; - uint32 reserved1; - uint32 record_number; - uint32 time_generated; - uint32 time_written; - uint32 event_id; - uint16 event_type; - uint16 num_strings; - uint16 event_category; - uint16 reserved2; - uint32 closing_record_number; - uint32 string_offset; - uint32 user_sid_length; - uint32 user_sid_offset; - uint32 data_length; - uint32 data_offset; -} Eventlog_record; - -typedef struct { - uint32 source_name_len; - smb_ucs2_t *source_name; - uint32 computer_name_len; - smb_ucs2_t *computer_name; - uint32 sid_padding; - smb_ucs2_t *sid; - uint32 strings_len; - smb_ucs2_t *strings; - uint32 user_data_len; - char *user_data; - uint32 data_padding; -} Eventlog_data_record; - -typedef struct eventlog_entry { - Eventlog_record record; - Eventlog_data_record data_record; - uint8 *data; - uint8 *end_of_data_padding; - struct eventlog_entry *next; -} Eventlog_entry; - -#endif /* _RPC_EVENTLOG_H */ diff --git a/source3/rpc_parse/parse_eventlog.c b/source3/rpc_parse/parse_eventlog.c deleted file mode 100644 index 45bd4b591e..0000000000 --- a/source3/rpc_parse/parse_eventlog.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Marcin Krzysztof Porwit 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 . - */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_PARSE - -/******************************************************************** -********************************************************************/ - -- cgit From 0016c57ca147566b93d8233adfae2060331e0527 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 4 Feb 2009 23:55:54 +0100 Subject: s3-net: remove unused ENUM_HND. Guenther --- source3/utils/net_rpc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 714d79402c..e6b46ce898 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -4377,7 +4377,6 @@ static NTSTATUS rpc_share_allowedusers_internals(struct net_context *c, { int ret; bool r; - ENUM_HND hnd; uint32 i; FILE *f; @@ -4410,8 +4409,6 @@ static NTSTATUS rpc_share_allowedusers_internals(struct net_context *c, for (i=0; i Date: Thu, 5 Feb 2009 00:19:39 +0100 Subject: s3: use samr_RidWithAttribute instead of DOM_GID. Guenther --- source3/rpc_client/init_netlogon.c | 18 ++++++++++-------- source3/utils/net_rpc.c | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/source3/rpc_client/init_netlogon.c b/source3/rpc_client/init_netlogon.c index 6f7a541f72..793b9c7de5 100644 --- a/source3/rpc_client/init_netlogon.c +++ b/source3/rpc_client/init_netlogon.c @@ -144,7 +144,8 @@ static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, const DOM_SID *domain_sid, size_t num_sids, const DOM_SID *sids, - int *numgroups, DOM_GID **pgids) + int *numgroups, + struct samr_RidWithAttribute **pgids) { int i; @@ -152,13 +153,14 @@ static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, *pgids = NULL; for (i=0; i Date: Thu, 5 Feb 2009 00:12:51 +0100 Subject: s3: use struct netr_Credential in cred_step(). Guenther --- source3/libsmb/credentials.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/libsmb/credentials.c b/source3/libsmb/credentials.c index 9d33e6d93d..9ba460f869 100644 --- a/source3/libsmb/credentials.c +++ b/source3/libsmb/credentials.c @@ -146,7 +146,7 @@ static void creds_init_64(struct dcinfo *dc, static void creds_step(struct dcinfo *dc) { - DOM_CHAL time_chal; + struct netr_Credential time_chal; DEBUG(5,("\tsequence = 0x%x\n", (unsigned int)dc->sequence )); -- cgit From e28a806a6b65320e5727a4237da57f879c509d26 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 4 Feb 2009 23:49:43 +0100 Subject: s3-parsing: remove a lot of unused structures and their hand marshalling. Guenther --- source3/include/proto.h | 62 --- source3/include/rpc_misc.h | 201 ------- source3/rpc_parse/parse_misc.c | 1155 +--------------------------------------- source3/rpc_parse/parse_prs.c | 50 -- 4 files changed, 9 insertions(+), 1459 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 88742c451d..53781563df 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5679,86 +5679,25 @@ uint32 size_of_relative_string(UNISTR *string); 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); -uint32 get_enum_hnd(ENUM_HND *enh); -void init_enum_hnd(ENUM_HND *enh, uint32 hnd); -bool smb_io_enum_hnd(const char *desc, ENUM_HND *hnd, prs_struct *ps, int depth); bool smb_io_dom_sid(const char *desc, DOM_SID *sid, prs_struct *ps, int depth); -void init_dom_sid2(DOM_SID2 *sid2, const DOM_SID *sid); -bool smb_io_dom_sid2_p(const char *desc, prs_struct *ps, int depth, DOM_SID2 **sid2); -bool smb_io_dom_sid2(const char *desc, DOM_SID2 *sid, prs_struct *ps, int depth); bool smb_io_uuid(const char *desc, struct GUID *uuid, prs_struct *ps, int depth); -void init_str_hdr(STRHDR *hdr, int max_len, int len, uint32 buffer); -bool smb_io_strhdr(const char *desc, STRHDR *hdr, prs_struct *ps, int depth); -void init_uni_hdr(UNIHDR *hdr, UNISTR2 *str2); -bool smb_io_unihdr(const char *desc, UNIHDR *hdr, prs_struct *ps, int depth); -void init_buf_hdr(BUFHDR *hdr, int max_len, int len); -bool smb_io_hdrbuf_pre(const char *desc, BUFHDR *hdr, prs_struct *ps, int depth, uint32 *offset); -bool smb_io_hdrbuf_post(const char *desc, BUFHDR *hdr, prs_struct *ps, int depth, - uint32 ptr_hdrbuf, uint32 max_len, uint32 len); -bool smb_io_hdrbuf(const char *desc, BUFHDR *hdr, 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); -void init_rpc_blob_uint32(RPC_DATA_BLOB *str, uint32 val); -void init_rpc_blob_str(RPC_DATA_BLOB *str, const char *buf, int len); -void init_rpc_blob_hex(RPC_DATA_BLOB *str, const char *buf); -void init_rpc_blob_bytes(RPC_DATA_BLOB *str, uint8 *buf, size_t len); 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_string2(STRING2 *str, const char *buf, size_t max_len, size_t str_len); -bool smb_io_string2(const char *desc, STRING2 *str2, uint32 buffer, prs_struct *ps, int depth); void init_unistr2(UNISTR2 *str, const char *buf, enum unistr2_term_codes flags); -void init_unistr4(UNISTR4 *uni4, const char *buf, enum unistr2_term_codes flags); -void init_unistr4_w( TALLOC_CTX *ctx, UNISTR4 *uni4, const smb_ucs2_t *buf ); 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 prs_unistr4(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4); -bool prs_unistr4_hdr(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4); -bool prs_unistr4_str(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4); -bool prs_unistr4_array(const char *desc, prs_struct *ps, int depth, UNISTR4_ARRAY *array ); -bool init_unistr4_array( UNISTR4_ARRAY *array, uint32 count, const char **strings ); -void init_dom_rid(DOM_RID *prid, uint32 rid, uint16 type, uint32 idx); -bool smb_io_dom_rid(const char *desc, DOM_RID *rid, prs_struct *ps, int depth); -bool smb_io_dom_rid2(const char *desc, DOM_RID2 *rid, prs_struct *ps, int depth); -void init_dom_rid3(DOM_RID3 *rid3, uint32 rid, uint8 type); -bool smb_io_dom_rid3(const char *desc, DOM_RID3 *rid3, prs_struct *ps, int depth); -void init_dom_rid4(DOM_RID4 *rid4, uint16 unknown, uint16 attr, uint32 rid); -void init_clnt_srv(DOM_CLNT_SRV *logcln, const char *logon_srv, - const char *comp_name); -bool smb_io_clnt_srv(const char *desc, DOM_CLNT_SRV *logcln, prs_struct *ps, int depth); -void init_log_info(DOM_LOG_INFO *loginfo, const char *logon_srv, const char *acct_name, - uint16 sec_chan, const char *comp_name); -bool smb_io_log_info(const char *desc, DOM_LOG_INFO *loginfo, prs_struct *ps, int depth); -bool smb_io_chal(const char *desc, DOM_CHAL *chal, prs_struct *ps, int depth); -bool smb_io_cred(const char *desc, DOM_CRED *cred, prs_struct *ps, int depth); -void init_clnt_info2(DOM_CLNT_INFO2 *clnt, - const char *logon_srv, const char *comp_name, - const DOM_CRED *clnt_cred); -bool smb_io_clnt_info2(const char *desc, DOM_CLNT_INFO2 *clnt, prs_struct *ps, int depth); -void init_clnt_info(DOM_CLNT_INFO *clnt, - const char *logon_srv, const char *acct_name, - uint16 sec_chan, const char *comp_name, - const DOM_CRED *cred); -bool smb_io_clnt_info(const char *desc, DOM_CLNT_INFO *clnt, prs_struct *ps, int depth); -void init_logon_id(DOM_LOGON_ID *logonid, uint32 log_id_low, uint32 log_id_high); -bool smb_io_logon_id(const char *desc, DOM_LOGON_ID *logonid, prs_struct *ps, int depth); -void init_owf_info(OWF_INFO *hash, const uint8 data[16]); -bool smb_io_owf_info(const char *desc, OWF_INFO *hash, prs_struct *ps, int depth); -bool smb_io_gid(const char *desc, DOM_GID *gid, 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); -bool smb_io_bufhdr2(const char *desc, BUFHDR2 *hdr, prs_struct *ps, int depth); -bool smb_io_bufhdr4(const char *desc, BUFHDR4 *hdr, prs_struct *ps, int depth); -bool smb_io_rpc_blob(const char *desc, RPC_DATA_BLOB *blob, prs_struct *ps, int depth); -bool make_uni_hdr(UNIHDR *hdr, int len); -bool make_bufhdr2(BUFHDR2 *hdr, uint32 info_level, uint32 length, uint32 buffer); uint32 str_len_uni(UNISTR *source); bool policy_handle_is_valid(const POLICY_HND *hnd); @@ -5816,7 +5755,6 @@ bool prs_uint16s(bool charmode, const char *name, prs_struct *ps, int depth, uin 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_string2(bool charmode, const char *name, prs_struct *ps, int depth, STRING2 *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); diff --git a/source3/include/rpc_misc.h b/source3/include/rpc_misc.h index 3a3c61ecec..1e9d43bfa0 100644 --- a/source3/include/rpc_misc.h +++ b/source3/include/rpc_misc.h @@ -92,10 +92,6 @@ enum unistr2_term_codes { UNI_FLAGS_NONE = 0, UNI_STR_TERMINATE = 1, UNI_MAXLEN_ **********************************************************************/ typedef struct policy_handle POLICY_HND; -typedef struct { - uint32 ptr_hnd; /* pointer to enumeration handle */ - uint32 handle; /* enumeration handle */ -} ENUM_HND; #define OUR_HANDLE(hnd) (((hnd)==NULL) ? "NULL" :\ ( IVAL((hnd)->uuid.node,2) == (uint32)sys_getpid() ? "OURS" : \ @@ -103,53 +99,6 @@ typedef struct { ((unsigned int)sys_getpid() ) -/********************************************************************** - * Buffer Headers -- use by SEC_DESC_BUF in winreg and netlogon code - **********************************************************************/ - -/* TODO: replace this with an encompassing buffer structure */ -typedef struct { - uint32 buf_max_len; - uint32 buf_len; -} BUFHDR; - -/* this is a BUFHDR + a pointer to a buffer */ -typedef struct { - uint32 info_level; - uint32 length; /* uint8 chars */ - uint32 buffer; -} BUFHDR2; - -/* generic buffer ? wrapped around void*? */ -typedef struct { - uint32 size; - uint32 buffer; -} BUFHDR4; - - -/********************************************************************** - * Buffers - **********************************************************************/ - -/* buffer used by \winreg\ calls to fill in arbitrary REG_XXX values. - It *may* look like a UNISTR2 but it is *not*. This is not a goof - by the winreg developers. It is a generic buffer. buffer length - is stored in bytes (not # of uint16's) */ - -typedef struct { - uint32 buf_max_len; - uint32 offset; - uint32 buf_len; - uint16 *buffer; -} REGVAL_BUFFER; - -/* generic rpc version of the DATA_BLOB. Just a length and uint8 array */ - -typedef struct { - uint32 buf_len; - uint8 *buffer; -} RPC_DATA_BLOB; - /********************************************************************** * Buffers use by spoolss (i might be able to replace it with * an RPC_DATA_BLOB) @@ -161,22 +110,6 @@ typedef struct { } BUFFER5; -/********************************************************************** - * Unicode and basic string headers - **********************************************************************/ - -typedef struct { - uint16 str_str_len; - uint16 str_max_len; - uint32 buffer; /* non-zero */ -} STRHDR; - -typedef struct { - uint16 uni_str_len; - uint16 uni_max_len; - uint32 buffer; -} UNIHDR; - /********************************************************************** * UNICODE string variations **********************************************************************/ @@ -205,138 +138,4 @@ typedef struct { /* UNISTR3 - XXXX not sure about this structure */ UNISTR str; } UNISTR3; -typedef struct { /* Buffer wrapped around a UNISTR2 */ - uint16 length; /* number of bytes not counting NULL terminatation */ - uint16 size; /* number of bytes including NULL terminatation */ - UNISTR2 *string; -} UNISTR4; - -typedef struct { - uint32 count; - UNISTR4 *strings; -} UNISTR4_ARRAY; - - -/********************************************************************** - * String variations - **********************************************************************/ - -typedef struct { /* STRING2 - string size (in uint8 chars) and buffer */ - uint32 str_max_len; - uint32 offset; - uint32 str_str_len; - uint8 *buffer; /* uint8 characters. **NOT** necessarily null-terminated */ -} STRING2; - - - - -/********************************************************************** - * Domain SID structures - **********************************************************************/ - -typedef struct { - uint32 num_auths; /* length, bytes, including length of len :-) */ - DOM_SID sid; -} DOM_SID2; - - -/********************************************************************** - * Domain SID structures - **********************************************************************/ - -/* DOM_RID - domain RID structure for ntlsa pipe */ -typedef struct { - uint16 type; /* value is SID_NAME_USE enum */ - uint32 rid; - uint32 rid_idx; /* referenced domain index */ -} DOM_RID; - -/* DOM_RID2 - second domain RID structure for ntlsa pipe */ -typedef struct { - uint16 type; /* value is SID_NAME_USE enum */ - uint32 rid; - uint32 rid_idx; /* referenced domain index */ - uint32 unknown; -} DOM_RID2; - -typedef struct { /* DOM_RID3 - domain RID structure for samr pipe */ - uint32 rid; /* domain-relative (to a SID) id */ - uint32 type1; /* value is 0x1 */ - uint32 ptr_type; /* undocumented pointer */ - uint32 type2; /* value is 0x1 */ - uint32 unk; /* value is 0x2 */ -} DOM_RID3; - -/* DOM_RID4 - rid + user attributes */ -typedef struct domrid4_info -{ - uint32 unknown; - uint16 attr; - uint32 rid; /* user RID */ -} DOM_RID4; - -/* DOM_GID - group id + user attributes */ -typedef struct { - uint32 g_rid; /* a group RID */ - uint32 attr; -} DOM_GID; - -/********************************************************************** - * ???? - **********************************************************************/ - -/* DOM_CLNT_SRV - client / server names */ -typedef struct clnt_srv_info { - uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */ - UNISTR2 uni_logon_srv; /* logon server name */ - uint32 undoc_buffer2; /* undocumented 32 bit buffer pointer */ - UNISTR2 uni_comp_name; /* client machine name */ -} DOM_CLNT_SRV; - -/* DOM_LOG_INFO - login info */ -typedef struct log_info { - uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */ - UNISTR2 uni_logon_srv; /* logon server name */ - UNISTR2 uni_acct_name; /* account name */ - uint16 sec_chan; /* secure channel type */ - UNISTR2 uni_comp_name; /* client machine name */ -} DOM_LOG_INFO; - -/* DOM_CHAL - challenge info */ -typedef struct chal_info { - unsigned char data[8]; /* credentials */ -} DOM_CHAL; - -/* DOM_CREDs - timestamped client or server credentials */ -typedef struct cred_info { - DOM_CHAL challenge; /* credentials */ - UTIME timestamp; /* credential time-stamp */ -} DOM_CRED; - -/* DOM_CLNT_INFO - client info */ -typedef struct clnt_info { - DOM_LOG_INFO login; - DOM_CRED cred; -} DOM_CLNT_INFO; - -/* DOM_CLNT_INFO2 - client info */ -typedef struct clnt_info2 { - DOM_CLNT_SRV login; - uint32 ptr_cred; - DOM_CRED cred; -} DOM_CLNT_INFO2; - -/* DOM_LOGON_ID - logon id */ -typedef struct logon_info { - uint32 low; - uint32 high; -} DOM_LOGON_ID; - -/* OWF INFO */ -typedef struct owf_info { - uint8 data[16]; -} OWF_INFO; - - #endif /* _RPC_MISC_H */ diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c index 7d1d00a373..38d5b95376 100644 --- a/source3/rpc_parse/parse_misc.c +++ b/source3/rpc_parse/parse_misc.c @@ -25,27 +25,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_PARSE -/******************************************************************* - Reads or writes a UTIME type. -********************************************************************/ - -static bool smb_io_utime(const char *desc, UTIME *t, prs_struct *ps, int depth) -{ - if (t == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_utime"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32 ("time", ps, depth, &t->time)) - return False; - - return True; -} - /******************************************************************* Reads or writes an NTTIME structure. ********************************************************************/ @@ -88,53 +67,6 @@ bool smb_io_nttime(const char *desc, prs_struct *ps, int depth, NTTIME *nttime) return smb_io_time( desc, nttime, ps, depth ); } -/******************************************************************* - Gets an enumeration handle from an ENUM_HND structure. -********************************************************************/ - -uint32 get_enum_hnd(ENUM_HND *enh) -{ - return (enh && enh->ptr_hnd != 0) ? enh->handle : 0; -} - -/******************************************************************* - Inits an ENUM_HND structure. -********************************************************************/ - -void init_enum_hnd(ENUM_HND *enh, uint32 hnd) -{ - DEBUG(5,("smb_io_enum_hnd\n")); - - enh->ptr_hnd = (hnd != 0) ? 1 : 0; - enh->handle = hnd; -} - -/******************************************************************* - Reads or writes an ENUM_HND structure. -********************************************************************/ - -bool smb_io_enum_hnd(const char *desc, ENUM_HND *hnd, prs_struct *ps, int depth) -{ - if (hnd == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_enum_hnd"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_hnd", ps, depth, &hnd->ptr_hnd)) /* pointer */ - return False; - - if (hnd->ptr_hnd != 0) { - if(!prs_uint32("handle ", ps, depth, &hnd->handle )) /* enum handle */ - return False; - } - - return True; -} - /******************************************************************* Reads or writes a DOM_SID structure. ********************************************************************/ @@ -173,67 +105,6 @@ bool smb_io_dom_sid(const char *desc, DOM_SID *sid, prs_struct *ps, int depth) return True; } -/******************************************************************* - Inits a DOM_SID2 structure. -********************************************************************/ - -void init_dom_sid2(DOM_SID2 *sid2, const DOM_SID *sid) -{ - sid2->sid = *sid; - sid2->num_auths = sid2->sid.num_auths; -} - -/******************************************************************* - Reads or writes a DOM_SID2 structure. -********************************************************************/ - -bool smb_io_dom_sid2_p(const char *desc, prs_struct *ps, int depth, DOM_SID2 **sid2) -{ - uint32 data_p; - - /* caputure the pointer value to stream */ - - data_p = *sid2 ? 0xf000baaa : 0; - - if ( !prs_uint32("dom_sid2_p", ps, depth, &data_p )) - return False; - - /* we're done if there is no data */ - - if ( !data_p ) - return True; - - if (UNMARSHALLING(ps)) { - if ( !(*sid2 = PRS_ALLOC_MEM(ps, DOM_SID2, 1)) ) - return False; - } - - return True; -} -/******************************************************************* - Reads or writes a DOM_SID2 structure. -********************************************************************/ - -bool smb_io_dom_sid2(const char *desc, DOM_SID2 *sid, prs_struct *ps, int depth) -{ - if (sid == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_dom_sid2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_auths", ps, depth, &sid->num_auths)) - return False; - - if(!smb_io_dom_sid("sid", &sid->sid, ps, depth)) - return False; - - return True; -} - /******************************************************************* Reads or writes a struct GUID ********************************************************************/ @@ -262,163 +133,6 @@ bool smb_io_uuid(const char *desc, struct GUID *uuid, return True; } -/******************************************************************* -creates a STRHDR structure. -********************************************************************/ - -void init_str_hdr(STRHDR *hdr, int max_len, int len, uint32 buffer) -{ - hdr->str_max_len = max_len; - hdr->str_str_len = len; - hdr->buffer = buffer; -} - -/******************************************************************* - Reads or writes a STRHDR structure. -********************************************************************/ - -bool smb_io_strhdr(const char *desc, STRHDR *hdr, prs_struct *ps, int depth) -{ - if (hdr == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_strhdr"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint16("str_str_len", ps, depth, &hdr->str_str_len)) - return False; - if(!prs_uint16("str_max_len", ps, depth, &hdr->str_max_len)) - return False; - if(!prs_uint32("buffer ", ps, depth, &hdr->buffer)) - return False; - - return True; -} - -/******************************************************************* - Inits a UNIHDR structure. -********************************************************************/ - -void init_uni_hdr(UNIHDR *hdr, UNISTR2 *str2) -{ - hdr->uni_str_len = 2 * (str2->uni_str_len); - hdr->uni_max_len = 2 * (str2->uni_max_len); - hdr->buffer = (str2->uni_str_len != 0) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a UNIHDR structure. -********************************************************************/ - -bool smb_io_unihdr(const char *desc, UNIHDR *hdr, prs_struct *ps, int depth) -{ - if (hdr == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_unihdr"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint16("uni_str_len", ps, depth, &hdr->uni_str_len)) - return False; - if(!prs_uint16("uni_max_len", ps, depth, &hdr->uni_max_len)) - return False; - if(!prs_uint32("buffer ", ps, depth, &hdr->buffer)) - return False; - - return True; -} - -/******************************************************************* - Inits a BUFHDR structure. -********************************************************************/ - -void init_buf_hdr(BUFHDR *hdr, int max_len, int len) -{ - hdr->buf_max_len = max_len; - hdr->buf_len = len; -} - -/******************************************************************* - prs_uint16 wrapper. Call this and it sets up a pointer to where the - uint16 should be stored, or gets the size if reading. - ********************************************************************/ - -bool smb_io_hdrbuf_pre(const char *desc, BUFHDR *hdr, prs_struct *ps, int depth, uint32 *offset) -{ - (*offset) = prs_offset(ps); - if (ps->io) { - - /* reading. */ - - if(!smb_io_hdrbuf(desc, hdr, ps, depth)) - return False; - - } else { - - /* writing. */ - - if(!prs_set_offset(ps, prs_offset(ps) + (sizeof(uint32) * 2))) - return False; - } - - return True; -} - -/******************************************************************* - smb_io_hdrbuf wrapper. Call this and it retrospectively stores the size. - Does nothing on reading, as that is already handled by ...._pre() - ********************************************************************/ - -bool smb_io_hdrbuf_post(const char *desc, BUFHDR *hdr, prs_struct *ps, int depth, - uint32 ptr_hdrbuf, uint32 max_len, uint32 len) -{ - if (!ps->io) { - /* writing: go back and do a retrospective job. i hate this */ - - uint32 old_offset = prs_offset(ps); - - init_buf_hdr(hdr, max_len, len); - if(!prs_set_offset(ps, ptr_hdrbuf)) - return False; - if(!smb_io_hdrbuf(desc, hdr, ps, depth)) - return False; - - if(!prs_set_offset(ps, old_offset)) - return False; - } - - return True; -} - -/******************************************************************* - Reads or writes a BUFHDR structure. -********************************************************************/ - -bool smb_io_hdrbuf(const char *desc, BUFHDR *hdr, prs_struct *ps, int depth) -{ - if (hdr == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_hdrbuf"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("buf_max_len", ps, depth, &hdr->buf_max_len)) - return False; - if(!prs_uint32("buf_len ", ps, depth, &hdr->buf_len)) - return False; - - return True; -} - /******************************************************************* Inits a UNISTR structure. ********************************************************************/ @@ -457,82 +171,6 @@ bool smb_io_unistr(const char *desc, UNISTR *uni, prs_struct *ps, int depth) return True; } -/******************************************************************* - Allocate the RPC_DATA_BLOB memory. -********************************************************************/ - -static void create_rpc_blob(RPC_DATA_BLOB *str, size_t len) -{ - if (len) { - str->buffer = (uint8 *)TALLOC_ZERO(talloc_tos(), len); - if (str->buffer == NULL) - smb_panic("create_rpc_blob: talloc fail"); - str->buf_len = len; - } else { - str->buffer = NULL; - str->buf_len = 0; - } -} - -/******************************************************************* - Inits a RPC_DATA_BLOB structure from a uint32 -********************************************************************/ - -void init_rpc_blob_uint32(RPC_DATA_BLOB *str, uint32 val) -{ - ZERO_STRUCTP(str); - - /* set up string lengths. */ - create_rpc_blob(str, sizeof(uint32)); - SIVAL(str->buffer, 0, val); -} - -/******************************************************************* - Inits a RPC_DATA_BLOB structure. -********************************************************************/ - -void init_rpc_blob_str(RPC_DATA_BLOB *str, const char *buf, int len) -{ - ZERO_STRUCTP(str); - - /* set up string lengths. */ - if (len) { - create_rpc_blob(str, len*2); - rpcstr_push(str->buffer, buf, (size_t)str->buf_len, STR_TERMINATE); - } -} - -/******************************************************************* - Inits a RPC_DATA_BLOB structure from a hex string. -********************************************************************/ - -void init_rpc_blob_hex(RPC_DATA_BLOB *str, const char *buf) -{ - ZERO_STRUCTP(str); - if (buf && *buf) { - size_t len = strlen(buf); - create_rpc_blob(str, len); - str->buf_len = strhex_to_str((char *)str->buffer, str->buf_len, - buf, len); - } -} - -/******************************************************************* - Inits a RPC_DATA_BLOB structure. -********************************************************************/ - -void init_rpc_blob_bytes(RPC_DATA_BLOB *str, uint8 *buf, size_t len) -{ - ZERO_STRUCTP(str); - - /* max buffer size (allocated size) */ - if (buf != NULL && len) { - create_rpc_blob(str, len); - memcpy(str->buffer, buf, len); - } - str->buf_len = len; -} - /******************************************************************* reads or writes a BUFFER5 structure. the buf_len member tells you how large the buffer is. @@ -609,90 +247,19 @@ void copy_unistr2(UNISTR2 *str, const UNISTR2 *from) } /******************************************************************* - Creates a STRING2 structure. + Inits a UNISTR2 structure. ********************************************************************/ -void init_string2(STRING2 *str, const char *buf, size_t max_len, size_t str_len) +void init_unistr2(UNISTR2 *str, const char *buf, enum unistr2_term_codes flags) { - /* set up string lengths. */ - SMB_ASSERT(max_len >= str_len); + size_t len = 0; + uint32 num_chars = 0; - /* Ensure buf is valid if str_len was set. Coverity check. */ - if (str_len && !buf) { - return; - } - - str->str_max_len = max_len; - str->offset = 0; - str->str_str_len = str_len; - - /* store the string */ - if(str_len != 0) { - str->buffer = (uint8 *)TALLOC_ZERO(talloc_tos(), - str->str_max_len); - if (str->buffer == NULL) - smb_panic("init_string2: malloc fail"); - memcpy(str->buffer, buf, str_len); - } -} - -/******************************************************************* - Reads or writes a STRING2 structure. - XXXX NOTE: STRING2 structures need NOT be null-terminated. - the str_str_len member tells you how long the string is; - the str_max_len member tells you how large the buffer is. -********************************************************************/ - -bool smb_io_string2(const char *desc, STRING2 *str2, uint32 buffer, prs_struct *ps, int depth) -{ - if (str2 == NULL) - return False; - - if (buffer) { - - prs_debug(ps, depth, desc, "smb_io_string2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("str_max_len", ps, depth, &str2->str_max_len)) - return False; - if(!prs_uint32("offset ", ps, depth, &str2->offset)) - return False; - if(!prs_uint32("str_str_len", ps, depth, &str2->str_str_len)) - return False; - - /* buffer advanced by indicated length of string - NOT by searching for null-termination */ - if(!prs_string2(True, "buffer ", ps, depth, str2)) - return False; - - } else { - - prs_debug(ps, depth, desc, "smb_io_string2 - NULL"); - depth++; - memset((char *)str2, '\0', sizeof(*str2)); - - } - - return True; -} - -/******************************************************************* - Inits a UNISTR2 structure. -********************************************************************/ - -void init_unistr2(UNISTR2 *str, const char *buf, enum unistr2_term_codes flags) -{ - size_t len = 0; - uint32 num_chars = 0; - - if (buf) { - /* We always null terminate the copy. */ - len = strlen(buf) + 1; - if ( flags == UNI_STR_DBLTERMINATE ) - len++; + if (buf) { + /* We always null terminate the copy. */ + len = strlen(buf) + 1; + if ( flags == UNI_STR_DBLTERMINATE ) + len++; } if (buf == NULL || len == 0) { @@ -735,36 +302,6 @@ void init_unistr2(UNISTR2 *str, const char *buf, enum unistr2_term_codes flags) str->uni_max_len++; } -/******************************************************************* - Inits a UNISTR4 structure. -********************************************************************/ - -void init_unistr4(UNISTR4 *uni4, const char *buf, enum unistr2_term_codes flags) -{ - uni4->string = TALLOC_P( talloc_tos(), UNISTR2 ); - if (!uni4->string) { - smb_panic("init_unistr4: talloc fail"); - return; - } - init_unistr2( uni4->string, buf, flags ); - - uni4->length = 2 * (uni4->string->uni_str_len); - uni4->size = 2 * (uni4->string->uni_max_len); -} - -void init_unistr4_w( TALLOC_CTX *ctx, UNISTR4 *uni4, const smb_ucs2_t *buf ) -{ - uni4->string = TALLOC_P( ctx, UNISTR2 ); - if (!uni4->string) { - smb_panic("init_unistr4_w: talloc fail"); - return; - } - init_unistr2_w( ctx, uni4->string, buf ); - - uni4->length = 2 * (uni4->string->uni_str_len); - uni4->size = 2 * (uni4->string->uni_max_len); -} - /** * Inits a UNISTR2 structure. * @param ctx talloc context to allocate string on @@ -969,583 +506,6 @@ bool smb_io_unistr2(const char *desc, UNISTR2 *uni2, uint32 buffer, prs_struct * return True; } -/******************************************************************* - now read/write UNISTR4 -********************************************************************/ - -bool prs_unistr4(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4) -{ - void *ptr; - prs_debug(ps, depth, desc, "prs_unistr4"); - depth++; - - if ( !prs_uint16("length", ps, depth, &uni4->length )) - return False; - if ( !prs_uint16("size", ps, depth, &uni4->size )) - return False; - - ptr = uni4->string; - - if ( !prs_pointer( desc, ps, depth, &ptr, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) ) - return False; - - uni4->string = (UNISTR2 *)ptr; - - return True; -} - -/******************************************************************* - now read/write UNISTR4 header -********************************************************************/ - -bool prs_unistr4_hdr(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4) -{ - prs_debug(ps, depth, desc, "prs_unistr4_hdr"); - depth++; - - if ( !prs_uint16("length", ps, depth, &uni4->length) ) - return False; - if ( !prs_uint16("size", ps, depth, &uni4->size) ) - return False; - if ( !prs_io_unistr2_p(desc, ps, depth, &uni4->string) ) - return False; - - return True; -} - -/******************************************************************* - now read/write UNISTR4 string -********************************************************************/ - -bool prs_unistr4_str(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4) -{ - prs_debug(ps, depth, desc, "prs_unistr4_str"); - depth++; - - if ( !prs_io_unistr2(desc, ps, depth, uni4->string) ) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a UNISTR4_ARRAY structure. -********************************************************************/ - -bool prs_unistr4_array(const char *desc, prs_struct *ps, int depth, UNISTR4_ARRAY *array ) -{ - unsigned int i; - - prs_debug(ps, depth, desc, "prs_unistr4_array"); - depth++; - - if(!prs_uint32("count", ps, depth, &array->count)) - return False; - - if (UNMARSHALLING(ps)) { - if (array->count) { - if ( !(array->strings = TALLOC_ZERO_ARRAY( talloc_tos(), UNISTR4, array->count)) ) - return False; - } else { - array->strings = NULL; - } - } - - /* write the headers and then the actual string buffer */ - - for ( i=0; icount; i++ ) { - if ( !prs_unistr4_hdr( "string", ps, depth, &array->strings[i]) ) - return False; - } - - for (i=0;icount;i++) { - if ( !prs_unistr4_str("string", ps, depth, &array->strings[i]) ) - return False; - } - - return True; -} - -/******************************************************************** - initialise a UNISTR_ARRAY from a char** -********************************************************************/ - -bool init_unistr4_array( UNISTR4_ARRAY *array, uint32 count, const char **strings ) -{ - unsigned int i; - - array->count = count; - - /* allocate memory for the array of UNISTR4 objects */ - - if (array->count) { - if ( !(array->strings = TALLOC_ZERO_ARRAY(talloc_tos(), UNISTR4, count )) ) - return False; - } else { - array->strings = NULL; - } - - for ( i=0; istrings[i], strings[i], UNI_STR_TERMINATE ); - - return True; -} - -/******************************************************************* - Inits a DOM_RID structure. -********************************************************************/ - -void init_dom_rid(DOM_RID *prid, uint32 rid, uint16 type, uint32 idx) -{ - prid->type = type; - prid->rid = rid; - prid->rid_idx = idx; -} - -/******************************************************************* - Reads or writes a DOM_RID structure. -********************************************************************/ - -bool smb_io_dom_rid(const char *desc, DOM_RID *rid, prs_struct *ps, int depth) -{ - if (rid == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_dom_rid"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint16("type ", ps, depth, &rid->type)) - return False; - if(!prs_align(ps)) - return False; - if(!prs_uint32("rid ", ps, depth, &rid->rid)) - return False; - if(!prs_uint32("rid_idx", ps, depth, &rid->rid_idx)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a DOM_RID2 structure. -********************************************************************/ - -bool smb_io_dom_rid2(const char *desc, DOM_RID2 *rid, prs_struct *ps, int depth) -{ - if (rid == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_dom_rid2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint16("type ", ps, depth, &rid->type)) - return False; - if(!prs_align(ps)) - return False; - if(!prs_uint32("rid ", ps, depth, &rid->rid)) - return False; - if(!prs_uint32("rid_idx", ps, depth, &rid->rid_idx)) - return False; - if(!prs_uint32("unknown", ps, depth, &rid->unknown)) - return False; - - return True; -} - - -/******************************************************************* -creates a DOM_RID3 structure. -********************************************************************/ - -void init_dom_rid3(DOM_RID3 *rid3, uint32 rid, uint8 type) -{ - rid3->rid = rid; - rid3->type1 = type; - rid3->ptr_type = 0x1; /* non-zero, basically. */ - rid3->type2 = 0x1; - rid3->unk = type; -} - -/******************************************************************* -reads or writes a DOM_RID3 structure. -********************************************************************/ - -bool smb_io_dom_rid3(const char *desc, DOM_RID3 *rid3, prs_struct *ps, int depth) -{ - if (rid3 == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_dom_rid3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("rid ", ps, depth, &rid3->rid)) - return False; - if(!prs_uint32("type1 ", ps, depth, &rid3->type1)) - return False; - if(!prs_uint32("ptr_type", ps, depth, &rid3->ptr_type)) - return False; - if(!prs_uint32("type2 ", ps, depth, &rid3->type2)) - return False; - if(!prs_uint32("unk ", ps, depth, &rid3->unk)) - return False; - - return True; -} - -/******************************************************************* - Inits a DOM_RID4 structure. -********************************************************************/ - -void init_dom_rid4(DOM_RID4 *rid4, uint16 unknown, uint16 attr, uint32 rid) -{ - rid4->unknown = unknown; - rid4->attr = attr; - rid4->rid = rid; -} - -/******************************************************************* - Inits a DOM_CLNT_SRV structure. -********************************************************************/ - -void init_clnt_srv(DOM_CLNT_SRV *logcln, const char *logon_srv, - const char *comp_name) -{ - DEBUG(5,("init_clnt_srv: %d\n", __LINE__)); - - if (logon_srv != NULL) { - logcln->undoc_buffer = 1; - init_unistr2(&logcln->uni_logon_srv, logon_srv, UNI_STR_TERMINATE); - } else { - logcln->undoc_buffer = 0; - } - - if (comp_name != NULL) { - logcln->undoc_buffer2 = 1; - init_unistr2(&logcln->uni_comp_name, comp_name, UNI_STR_TERMINATE); - } else { - logcln->undoc_buffer2 = 0; - } -} - -/******************************************************************* - Inits or writes a DOM_CLNT_SRV structure. -********************************************************************/ - -bool smb_io_clnt_srv(const char *desc, DOM_CLNT_SRV *logcln, prs_struct *ps, int depth) -{ - if (logcln == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_clnt_srv"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("undoc_buffer ", ps, depth, &logcln->undoc_buffer)) - return False; - - if (logcln->undoc_buffer != 0) { - if(!smb_io_unistr2("unistr2", &logcln->uni_logon_srv, logcln->undoc_buffer, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("undoc_buffer2", ps, depth, &logcln->undoc_buffer2)) - return False; - - if (logcln->undoc_buffer2 != 0) { - if(!smb_io_unistr2("unistr2", &logcln->uni_comp_name, logcln->undoc_buffer2, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a DOM_LOG_INFO structure. -********************************************************************/ - -void init_log_info(DOM_LOG_INFO *loginfo, const char *logon_srv, const char *acct_name, - uint16 sec_chan, const char *comp_name) -{ - DEBUG(5,("make_log_info %d\n", __LINE__)); - - loginfo->undoc_buffer = 1; - - init_unistr2(&loginfo->uni_logon_srv, logon_srv, UNI_STR_TERMINATE); - init_unistr2(&loginfo->uni_acct_name, acct_name, UNI_STR_TERMINATE); - - loginfo->sec_chan = sec_chan; - - init_unistr2(&loginfo->uni_comp_name, comp_name, UNI_STR_TERMINATE); -} - -/******************************************************************* - Reads or writes a DOM_LOG_INFO structure. -********************************************************************/ - -bool smb_io_log_info(const char *desc, DOM_LOG_INFO *loginfo, prs_struct *ps, int depth) -{ - if (loginfo == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_log_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("undoc_buffer", ps, depth, &loginfo->undoc_buffer)) - return False; - - if(!smb_io_unistr2("unistr2", &loginfo->uni_logon_srv, True, ps, depth)) - return False; - if(!smb_io_unistr2("unistr2", &loginfo->uni_acct_name, True, ps, depth)) - return False; - - if(!prs_uint16("sec_chan", ps, depth, &loginfo->sec_chan)) - return False; - - if(!smb_io_unistr2("unistr2", &loginfo->uni_comp_name, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a DOM_CHAL structure. -********************************************************************/ - -bool smb_io_chal(const char *desc, DOM_CHAL *chal, prs_struct *ps, int depth) -{ - if (chal == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_chal"); - depth++; - - if(!prs_uint8s (False, "data", ps, depth, chal->data, 8)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a DOM_CRED structure. -********************************************************************/ - -bool smb_io_cred(const char *desc, DOM_CRED *cred, prs_struct *ps, int depth) -{ - if (cred == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_cred"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_chal ("", &cred->challenge, ps, depth)) - return False; - - if(!smb_io_utime("", &cred->timestamp, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a DOM_CLNT_INFO2 structure. -********************************************************************/ - -void init_clnt_info2(DOM_CLNT_INFO2 *clnt, - const char *logon_srv, const char *comp_name, - const DOM_CRED *clnt_cred) -{ - DEBUG(5,("make_clnt_info: %d\n", __LINE__)); - - init_clnt_srv(&clnt->login, logon_srv, comp_name); - - if (clnt_cred != NULL) { - clnt->ptr_cred = 1; - memcpy(&clnt->cred, clnt_cred, sizeof(clnt->cred)); - } else { - clnt->ptr_cred = 0; - } -} - -/******************************************************************* - Reads or writes a DOM_CLNT_INFO2 structure. -********************************************************************/ - -bool smb_io_clnt_info2(const char *desc, DOM_CLNT_INFO2 *clnt, prs_struct *ps, int depth) -{ - if (clnt == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_clnt_info2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_clnt_srv("", &clnt->login, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_cred", ps, depth, &clnt->ptr_cred)) - return False; - if(!smb_io_cred("", &clnt->cred, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a DOM_CLNT_INFO structure. -********************************************************************/ - -void init_clnt_info(DOM_CLNT_INFO *clnt, - const char *logon_srv, const char *acct_name, - uint16 sec_chan, const char *comp_name, - const DOM_CRED *cred) -{ - DEBUG(5,("make_clnt_info\n")); - - init_log_info(&clnt->login, logon_srv, acct_name, sec_chan, comp_name); - memcpy(&clnt->cred, cred, sizeof(clnt->cred)); -} - -/******************************************************************* - Reads or writes a DOM_CLNT_INFO structure. -********************************************************************/ - -bool smb_io_clnt_info(const char *desc, DOM_CLNT_INFO *clnt, prs_struct *ps, int depth) -{ - if (clnt == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_clnt_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_log_info("", &clnt->login, ps, depth)) - return False; - if(!smb_io_cred("", &clnt->cred, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a DOM_LOGON_ID structure. -********************************************************************/ - -void init_logon_id(DOM_LOGON_ID *logonid, uint32 log_id_low, uint32 log_id_high) -{ - DEBUG(5,("make_logon_id: %d\n", __LINE__)); - - logonid->low = log_id_low; - logonid->high = log_id_high; -} - -/******************************************************************* - Reads or writes a DOM_LOGON_ID structure. -********************************************************************/ - -bool smb_io_logon_id(const char *desc, DOM_LOGON_ID *logonid, prs_struct *ps, int depth) -{ - if (logonid == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_logon_id"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("low ", ps, depth, &logonid->low )) - return False; - if(!prs_uint32("high", ps, depth, &logonid->high)) - return False; - - return True; -} - -/******************************************************************* - Inits an OWF_INFO structure. -********************************************************************/ - -void init_owf_info(OWF_INFO *hash, const uint8 data[16]) -{ - DEBUG(5,("init_owf_info: %d\n", __LINE__)); - - if (data != NULL) - memcpy(hash->data, data, sizeof(hash->data)); - else - memset((char *)hash->data, '\0', sizeof(hash->data)); -} - -/******************************************************************* - Reads or writes an OWF_INFO structure. -********************************************************************/ - -bool smb_io_owf_info(const char *desc, OWF_INFO *hash, prs_struct *ps, int depth) -{ - if (hash == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_owf_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint8s (False, "data", ps, depth, hash->data, 16)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a DOM_GID structure. -********************************************************************/ - -bool smb_io_gid(const char *desc, DOM_GID *gid, prs_struct *ps, int depth) -{ - if (gid == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_gid"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("g_rid", ps, depth, &gid->g_rid)) - return False; - if(!prs_uint32("attr ", ps, depth, &gid->attr)) - return False; - - return True; -} - /******************************************************************* Reads or writes an POLICY_HND structure. ********************************************************************/ @@ -1653,103 +613,6 @@ bool prs_uint64(const char *name, prs_struct *ps, int depth, uint64 *data64) } } -/******************************************************************* -reads or writes a BUFHDR2 structure. -********************************************************************/ -bool smb_io_bufhdr2(const char *desc, BUFHDR2 *hdr, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "smb_io_bufhdr2"); - depth++; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("info_level", ps, depth, &(hdr->info_level))) - return False; - if (!prs_uint32("length ", ps, depth, &(hdr->length ))) - return False; - if (!prs_uint32("buffer ", ps, depth, &(hdr->buffer ))) - return False; - - return True; -} - -/******************************************************************* -reads or writes a BUFHDR4 structure. -********************************************************************/ -bool smb_io_bufhdr4(const char *desc, BUFHDR4 *hdr, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "smb_io_bufhdr4"); - depth++; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("size", ps, depth, &hdr->size)) - return False; - if (!prs_uint32("buffer", ps, depth, &hdr->buffer)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a RPC_DATA_BLOB structure. -********************************************************************/ - -bool smb_io_rpc_blob(const char *desc, RPC_DATA_BLOB *blob, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "smb_io_rpc_blob"); - depth++; - - if (!prs_align(ps)) - return False; - if ( !prs_uint32("buf_len", ps, depth, &blob->buf_len) ) - return False; - - if ( blob->buf_len == 0 ) - return True; - - if (UNMARSHALLING(ps)) { - blob->buffer = PRS_ALLOC_MEM(ps, uint8, blob->buf_len); - if (!blob->buffer) { - return False; - } - } - - if ( !prs_uint8s(True, "buffer", ps, depth, blob->buffer, blob->buf_len) ) - return False; - - return True; -} - -/******************************************************************* -creates a UNIHDR structure. -********************************************************************/ - -bool make_uni_hdr(UNIHDR *hdr, int len) -{ - if (hdr == NULL) - { - return False; - } - hdr->uni_str_len = 2 * len; - hdr->uni_max_len = 2 * len; - hdr->buffer = len != 0 ? 1 : 0; - - return True; -} - -/******************************************************************* -creates a BUFHDR2 structure. -********************************************************************/ -bool make_bufhdr2(BUFHDR2 *hdr, uint32 info_level, uint32 length, uint32 buffer) -{ - hdr->info_level = info_level; - hdr->length = length; - hdr->buffer = buffer; - - return True; -} - /******************************************************************* return the length of a UNISTR string. ********************************************************************/ diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c index 1332a8311a..e8103ad866 100644 --- a/source3/rpc_parse/parse_prs.c +++ b/source3/rpc_parse/parse_prs.c @@ -1052,56 +1052,6 @@ bool prs_buffer5(bool charmode, const char *name, prs_struct *ps, int depth, BUF return True; } -/****************************************************************** - Stream a string, length/buffer specified separately, - in uint8 chars. - ********************************************************************/ - -bool prs_string2(bool charmode, const char *name, prs_struct *ps, int depth, STRING2 *str) -{ - unsigned int i; - char *q = prs_mem_get(ps, str->str_str_len); - if (q == NULL) - return False; - - if (UNMARSHALLING(ps)) { - if (str->str_str_len > str->str_max_len) { - return False; - } - if (str->str_max_len) { - str->buffer = PRS_ALLOC_MEM(ps,unsigned char, str->str_max_len); - if (str->buffer == NULL) - return False; - } else { - str->buffer = NULL; - /* Return early to ensure Coverity isn't confused. */ - DEBUGADD(5,("%s%04x %s: \n", tab_depth(5,depth), ps->data_offset, name)); - return True; - } - } - - if (UNMARSHALLING(ps)) { - for (i = 0; i < str->str_str_len; i++) - str->buffer[i] = CVAL(q,i); - } else { - for (i = 0; i < str->str_str_len; i++) - SCVAL(q, i, str->buffer[i]); - } - - DEBUGADD(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name)); - if (charmode) - print_asc(5, (unsigned char*)str->buffer, str->str_str_len); - else { - for (i = 0; i < str->str_str_len; i++) - DEBUG(5,("%02x ", str->buffer[i])); - } - DEBUGADD(5,("\n")); - - ps->data_offset += str->str_str_len; - - return True; -} - /****************************************************************** Stream a unicode string, length/buffer specified separately, in uint16 chars. The unicode string is already in little-endian format. -- cgit From ef098bd621b544a651636db4b7d6cdd777c83d18 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 5 Feb 2009 01:05:09 +0100 Subject: s3-lsa: move remaining lsa policy access_mask defines to idl. Guenther --- librpc/gen_ndr/lsa.h | 4 ++++ librpc/idl/lsa.idl | 37 ++++++++++++++++++++++++++++ source3/include/includes.h | 1 - source3/include/rpc_lsa.h | 60 ---------------------------------------------- 4 files changed, 41 insertions(+), 61 deletions(-) delete mode 100644 source3/include/rpc_lsa.h diff --git a/librpc/gen_ndr/lsa.h b/librpc/gen_ndr/lsa.h index ee8a31138d..00fa1230e1 100644 --- a/librpc/gen_ndr/lsa.h +++ b/librpc/gen_ndr/lsa.h @@ -7,6 +7,10 @@ #ifndef _HEADER_lsarpc #define _HEADER_lsarpc +#define LSA_POLICY_ALL_ACCESS ( (STANDARD_RIGHTS_REQUIRED_ACCESS|LSA_POLICY_VIEW_LOCAL_INFORMATION|LSA_POLICY_VIEW_AUDIT_INFORMATION|LSA_POLICY_GET_PRIVATE_INFORMATION|LSA_POLICY_TRUST_ADMIN|LSA_POLICY_CREATE_ACCOUNT|LSA_POLICY_CREATE_SECRET|LSA_POLICY_CREATE_PRIVILEGE|LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS|LSA_POLICY_SET_AUDIT_REQUIREMENTS|LSA_POLICY_AUDIT_LOG_ADMIN|LSA_POLICY_SERVER_ADMIN|LSA_POLICY_LOOKUP_NAMES) ) +#define LSA_POLICY_READ ( (STANDARD_RIGHTS_READ_ACCESS|LSA_POLICY_VIEW_LOCAL_INFORMATION|LSA_POLICY_VIEW_AUDIT_INFORMATION|LSA_POLICY_GET_PRIVATE_INFORMATION) ) +#define LSA_POLICY_WRITE ( (STD_RIGHT_READ_CONTROL_ACCESS|LSA_POLICY_TRUST_ADMIN|LSA_POLICY_CREATE_ACCOUNT|LSA_POLICY_CREATE_SECRET|LSA_POLICY_CREATE_PRIVILEGE|LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS|LSA_POLICY_SET_AUDIT_REQUIREMENTS|LSA_POLICY_AUDIT_LOG_ADMIN|LSA_POLICY_SERVER_ADMIN) ) +#define LSA_POLICY_EXECUTE ( (STANDARD_RIGHTS_EXECUTE_ACCESS|LSA_POLICY_VIEW_LOCAL_INFORMATION|LSA_POLICY_LOOKUP_NAMES) ) #define LSA_ENUM_TRUST_DOMAIN_MULTIPLIER ( 60 ) #define LSA_REF_DOMAIN_LIST_MULTIPLIER ( 32 ) #define LSA_ENUM_TRUST_DOMAIN_EX_MULTIPLIER ( 82 ) diff --git a/librpc/idl/lsa.idl b/librpc/idl/lsa.idl index db5ca31720..afe613d412 100644 --- a/librpc/idl/lsa.idl +++ b/librpc/idl/lsa.idl @@ -143,6 +143,43 @@ import "misc.idl", "security.idl"; LSA_POLICY_LOOKUP_NAMES = 0x00000800 } lsa_PolicyAccessMask; + const int LSA_POLICY_ALL_ACCESS = + (STANDARD_RIGHTS_REQUIRED_ACCESS | + LSA_POLICY_VIEW_LOCAL_INFORMATION | + LSA_POLICY_VIEW_AUDIT_INFORMATION | + LSA_POLICY_GET_PRIVATE_INFORMATION | + LSA_POLICY_TRUST_ADMIN | + LSA_POLICY_CREATE_ACCOUNT | + LSA_POLICY_CREATE_SECRET | + LSA_POLICY_CREATE_PRIVILEGE | + LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS | + LSA_POLICY_SET_AUDIT_REQUIREMENTS | + LSA_POLICY_AUDIT_LOG_ADMIN | + LSA_POLICY_SERVER_ADMIN | + LSA_POLICY_LOOKUP_NAMES); + + const int LSA_POLICY_READ = + (STANDARD_RIGHTS_READ_ACCESS | + LSA_POLICY_VIEW_LOCAL_INFORMATION | + LSA_POLICY_VIEW_AUDIT_INFORMATION | + LSA_POLICY_GET_PRIVATE_INFORMATION); + + const int LSA_POLICY_WRITE = + (STD_RIGHT_READ_CONTROL_ACCESS | + LSA_POLICY_TRUST_ADMIN | + LSA_POLICY_CREATE_ACCOUNT | + LSA_POLICY_CREATE_SECRET | + LSA_POLICY_CREATE_PRIVILEGE | + LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS | + LSA_POLICY_SET_AUDIT_REQUIREMENTS | + LSA_POLICY_AUDIT_LOG_ADMIN | + LSA_POLICY_SERVER_ADMIN); + + const int LSA_POLICY_EXECUTE = + (STANDARD_RIGHTS_EXECUTE_ACCESS | + LSA_POLICY_VIEW_LOCAL_INFORMATION | + LSA_POLICY_LOOKUP_NAMES); + /* notice the screwup with the system_name - thats why MS created OpenPolicy2 */ [public] NTSTATUS lsa_OpenPolicy ( diff --git a/source3/include/includes.h b/source3/include/includes.h index a20a17c33d..4aa3c07343 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -619,7 +619,6 @@ struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx); #include "ntlmssp.h" #include "auth.h" #include "ntdomain.h" -#include "rpc_lsa.h" #include "reg_objects.h" #include "reg_db.h" #include "rpc_spoolss.h" diff --git a/source3/include/rpc_lsa.h b/source3/include/rpc_lsa.h deleted file mode 100644 index 1dc5ba4a7b..0000000000 --- a/source3/include/rpc_lsa.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB parameters and setup - Copyright (C) Andrew Tridgell 1992-1997 - Copyright (C) Luke Kenneth Casson Leighton 1996-1997 - Copyright (C) Paul Ashton 1997 - Copyright (C) Gerald (Jerry) Carter 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 . -*/ - -#ifndef _RPC_LSA_H /* _RPC_LSA_H */ -#define _RPC_LSA_H - -#define LSA_POLICY_ALL_ACCESS ( STANDARD_RIGHTS_REQUIRED_ACCESS |\ - LSA_POLICY_VIEW_LOCAL_INFORMATION |\ - LSA_POLICY_VIEW_AUDIT_INFORMATION |\ - LSA_POLICY_GET_PRIVATE_INFORMATION |\ - LSA_POLICY_TRUST_ADMIN |\ - LSA_POLICY_CREATE_ACCOUNT |\ - LSA_POLICY_CREATE_SECRET |\ - LSA_POLICY_CREATE_PRIVILEGE |\ - LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS |\ - LSA_POLICY_SET_AUDIT_REQUIREMENTS |\ - LSA_POLICY_AUDIT_LOG_ADMIN |\ - LSA_POLICY_SERVER_ADMIN |\ - LSA_POLICY_LOOKUP_NAMES ) - - -#define LSA_POLICY_READ ( STANDARD_RIGHTS_READ_ACCESS |\ - LSA_POLICY_VIEW_LOCAL_INFORMATION |\ - LSA_POLICY_VIEW_AUDIT_INFORMATION |\ - LSA_POLICY_GET_PRIVATE_INFORMATION) - -#define LSA_POLICY_WRITE ( STD_RIGHT_READ_CONTROL_ACCESS |\ - LSA_POLICY_TRUST_ADMIN |\ - LSA_POLICY_CREATE_ACCOUNT |\ - LSA_POLICY_CREATE_SECRET |\ - LSA_POLICY_CREATE_PRIVILEGE |\ - LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS |\ - LSA_POLICY_SET_AUDIT_REQUIREMENTS |\ - LSA_POLICY_AUDIT_LOG_ADMIN |\ - LSA_POLICY_SERVER_ADMIN) - -#define LSA_POLICY_EXECUTE ( STANDARD_RIGHTS_EXECUTE_ACCESS |\ - LSA_POLICY_VIEW_LOCAL_INFORMATION |\ - LSA_POLICY_LOOKUP_NAMES ) - -#endif /* _RPC_LSA_H */ -- cgit From e7c09d8b105d8182e7ae3948a664169dc13198e9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 4 Feb 2009 16:33:52 -0800 Subject: Fix bug #Bug 6090 renaming or deleting a "not matching/resolving" symlink is failing. Reported by Kukks. Make sure we correctly use LSTAT in all cases where POSIX pathnames are being used. This matters when dealing with symlinks pointing to invalid paths being renamed or deleted not all deletes and renames are done via an nt_create open. Jeremy. --- source3/smbd/filename.c | 30 +++++++++++++++++++++++---- source3/smbd/open.c | 54 +++++++++++++++++++++++++++++++------------------ source3/smbd/reply.c | 34 +++++++++++++++++++++++++------ 3 files changed, 88 insertions(+), 30 deletions(-) diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index d240ecfa64..003cb0ffd4 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -126,7 +126,9 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx, char *stream = NULL; bool component_was_mangled = False; bool name_has_wildcard = False; + bool posix_pathnames = false; NTSTATUS result; + int ret = -1; SET_STAT_INVALID(*pst); *pp_conv_path = NULL; @@ -225,7 +227,9 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx, } } - if (!lp_posix_pathnames()) { + posix_pathnames = lp_posix_pathnames(); + + if (!posix_pathnames) { stream = strchr_m(name, ':'); if (stream != NULL) { @@ -268,7 +272,13 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx, * stat the name - if it exists then we are all done! */ - if (SMB_VFS_STAT(conn,name,&st) == 0) { + if (posix_pathnames) { + ret = SMB_VFS_LSTAT(conn,name,&st); + } else { + ret = SMB_VFS_STAT(conn,name,&st); + } + + if (ret == 0) { /* Ensure we catch all names with in "/." this is disallowed under Windows. */ const char *p = strstr(name, "/."); /* mb safe. */ @@ -380,7 +390,13 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx, * Check if the name exists up to this point. */ - if (SMB_VFS_STAT(conn,name, &st) == 0) { + if (posix_pathnames) { + ret = SMB_VFS_LSTAT(conn,name, &st); + } else { + ret = SMB_VFS_STAT(conn,name, &st); + } + + if (ret == 0) { /* * It exists. it must either be a directory or this must * be the last part of the path for it to be OK. @@ -598,7 +614,13 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx, * if it exists. JRA. */ - if (SMB_VFS_STAT(conn,name, &st) == 0) { + if (posix_pathnames) { + ret = SMB_VFS_LSTAT(conn,name, &st); + } else { + ret = SMB_VFS_STAT(conn,name, &st); + } + + if (ret == 0) { *pst = st; } else { SET_STAT_INVALID(st); diff --git a/source3/smbd/open.c b/source3/smbd/open.c index bc5107447f..f7a52d7bd2 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -432,28 +432,42 @@ static NTSTATUS open_file(files_struct *fsp, access_mask, &access_granted); if (!NT_STATUS_IS_OK(status)) { - - /* Were we trying to do a stat open - * for delete and didn't get DELETE - * access (only) ? Check if the - * directory allows DELETE_CHILD. - * See here: - * http://blogs.msdn.com/oldnewthing/archive/2004/06/04/148426.aspx - * for details. */ - - if (!(NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) && - (access_mask & DELETE_ACCESS) && - (access_granted == DELETE_ACCESS) && - can_delete_file_in_directory(conn, path))) { - DEBUG(10, ("open_file: Access denied on " - "file %s\n", - path)); + if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { + if ((access_mask & DELETE_ACCESS) && + (access_granted == DELETE_ACCESS) && + can_delete_file_in_directory(conn, path)) { + /* Were we trying to do a stat open + * for delete and didn't get DELETE + * access (only) ? Check if the + * directory allows DELETE_CHILD. + * See here: + * http://blogs.msdn.com/oldnewthing/archive/2004/06/04/148426.aspx + * for details. */ + + DEBUG(10,("open_file: overrode ACCESS_DENIED " + "on file %s\n", + path )); + } else { + DEBUG(10, ("open_file: Access denied on " + "file %s\n", + path)); + return status; + } + } else if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND) && + fsp->posix_open && + S_ISLNK(psbuf->st_mode)) { + /* This is a POSIX stat open for delete + * or rename on a symlink that points + * nowhere. Allow. */ + DEBUG(10, ("open_file: allowing POSIX open " + "on bad symlink %s\n", + path )); + } else { + DEBUG(10, ("open_file: check_open_rights " + "on file %s returned %s\n", + path, nt_errstr(status) )); return status; } - - DEBUG(10,("open_file: overrode ACCESS_DENIED " - "on file %s\n", - path )); } } } diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index f2d4ff78a7..bb5fadd465 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -5616,7 +5616,13 @@ NTSTATUS rename_internals_fsp(connection_struct *conn, return map_nt_error_from_unix(errno); } } else { - if (SMB_VFS_STAT(conn,fsp->fsp_name,&sbuf) == -1) { + int ret = -1; + if (fsp->posix_open) { + ret = SMB_VFS_LSTAT(conn,fsp->fsp_name,&sbuf); + } else { + ret = SMB_VFS_STAT(conn,fsp->fsp_name,&sbuf); + } + if (ret == -1) { return map_nt_error_from_unix(errno); } } @@ -5721,6 +5727,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, const char *dname; long offset = 0; int create_options = 0; + bool posix_pathnames = lp_posix_pathnames(); ZERO_STRUCT(sbuf1); ZERO_STRUCT(sbuf2); @@ -5832,7 +5839,11 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, } ZERO_STRUCT(sbuf1); - SMB_VFS_STAT(conn, directory, &sbuf1); + if (posix_pathnames) { + SMB_VFS_LSTAT(conn, directory, &sbuf1); + } else { + SMB_VFS_STAT(conn, directory, &sbuf1); + } if (S_ISDIR(sbuf1.st_mode)) { create_options |= FILE_DIRECTORY_FILE; @@ -5849,7 +5860,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, FILE_SHARE_WRITE), FILE_OPEN, /* create_disposition*/ create_options, /* create_options */ - 0, /* file_attributes */ + posix_pathnames ? FILE_FLAG_POSIX_SEMANTICS|0777 : 0, /* file_attributes */ 0, /* oplock_request */ 0, /* allocation_size */ NULL, /* sd */ @@ -5948,7 +5959,11 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, } ZERO_STRUCT(sbuf1); - SMB_VFS_STAT(conn, fname, &sbuf1); + if (posix_pathnames) { + SMB_VFS_LSTAT(conn, fname, &sbuf1); + } else { + SMB_VFS_STAT(conn, fname, &sbuf1); + } create_options = 0; @@ -5967,7 +5982,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, FILE_SHARE_WRITE), FILE_OPEN, /* create_disposition*/ create_options, /* create_options */ - 0, /* file_attributes */ + posix_pathnames ? FILE_FLAG_POSIX_SEMANTICS|0777 : 0, /* file_attributes */ 0, /* oplock_request */ 0, /* allocation_size */ NULL, /* sd */ @@ -7167,7 +7182,14 @@ void reply_setattrE(struct smb_request *req) return; } } else { - if (SMB_VFS_STAT(conn, fsp->fsp_name, &sbuf) == -1) { + int ret = -1; + + if (fsp->posix_open) { + ret = SMB_VFS_LSTAT(conn, fsp->fsp_name, &sbuf); + } else { + ret = SMB_VFS_STAT(conn, fsp->fsp_name, &sbuf); + } + if (ret == -1) { status = map_nt_error_from_unix(errno); reply_nterror(req, status); END_PROFILE(SMBsetattrE); -- cgit From 7435b877c7969a72b6b17d3ce4df87c5629882b8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 5 Feb 2009 02:53:39 +0100 Subject: s3-lsa: fix the build. Guenther --- librpc/gen_ndr/lsa.h | 2 +- librpc/idl/lsa.idl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/librpc/gen_ndr/lsa.h b/librpc/gen_ndr/lsa.h index 00fa1230e1..03a0464d5b 100644 --- a/librpc/gen_ndr/lsa.h +++ b/librpc/gen_ndr/lsa.h @@ -9,7 +9,7 @@ #define LSA_POLICY_ALL_ACCESS ( (STANDARD_RIGHTS_REQUIRED_ACCESS|LSA_POLICY_VIEW_LOCAL_INFORMATION|LSA_POLICY_VIEW_AUDIT_INFORMATION|LSA_POLICY_GET_PRIVATE_INFORMATION|LSA_POLICY_TRUST_ADMIN|LSA_POLICY_CREATE_ACCOUNT|LSA_POLICY_CREATE_SECRET|LSA_POLICY_CREATE_PRIVILEGE|LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS|LSA_POLICY_SET_AUDIT_REQUIREMENTS|LSA_POLICY_AUDIT_LOG_ADMIN|LSA_POLICY_SERVER_ADMIN|LSA_POLICY_LOOKUP_NAMES) ) #define LSA_POLICY_READ ( (STANDARD_RIGHTS_READ_ACCESS|LSA_POLICY_VIEW_LOCAL_INFORMATION|LSA_POLICY_VIEW_AUDIT_INFORMATION|LSA_POLICY_GET_PRIVATE_INFORMATION) ) -#define LSA_POLICY_WRITE ( (STD_RIGHT_READ_CONTROL_ACCESS|LSA_POLICY_TRUST_ADMIN|LSA_POLICY_CREATE_ACCOUNT|LSA_POLICY_CREATE_SECRET|LSA_POLICY_CREATE_PRIVILEGE|LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS|LSA_POLICY_SET_AUDIT_REQUIREMENTS|LSA_POLICY_AUDIT_LOG_ADMIN|LSA_POLICY_SERVER_ADMIN) ) +#define LSA_POLICY_WRITE ( (STANDARD_RIGHTS_READ_ACCESS|LSA_POLICY_TRUST_ADMIN|LSA_POLICY_CREATE_ACCOUNT|LSA_POLICY_CREATE_SECRET|LSA_POLICY_CREATE_PRIVILEGE|LSA_POLICY_SET_DEFAULT_QUOTA_LIMITS|LSA_POLICY_SET_AUDIT_REQUIREMENTS|LSA_POLICY_AUDIT_LOG_ADMIN|LSA_POLICY_SERVER_ADMIN) ) #define LSA_POLICY_EXECUTE ( (STANDARD_RIGHTS_EXECUTE_ACCESS|LSA_POLICY_VIEW_LOCAL_INFORMATION|LSA_POLICY_LOOKUP_NAMES) ) #define LSA_ENUM_TRUST_DOMAIN_MULTIPLIER ( 60 ) #define LSA_REF_DOMAIN_LIST_MULTIPLIER ( 32 ) diff --git a/librpc/idl/lsa.idl b/librpc/idl/lsa.idl index afe613d412..ea787b2c7d 100644 --- a/librpc/idl/lsa.idl +++ b/librpc/idl/lsa.idl @@ -165,7 +165,7 @@ import "misc.idl", "security.idl"; LSA_POLICY_GET_PRIVATE_INFORMATION); const int LSA_POLICY_WRITE = - (STD_RIGHT_READ_CONTROL_ACCESS | + (STANDARD_RIGHTS_READ_ACCESS | LSA_POLICY_TRUST_ADMIN | LSA_POLICY_CREATE_ACCOUNT | LSA_POLICY_CREATE_SECRET | -- cgit From 83cf98f113541acca5a9b4d6ad084d401b64706f Mon Sep 17 00:00:00 2001 From: Aravind Srinivasan Date: Wed, 4 Feb 2009 16:05:36 -0800 Subject: Have nmbd check all available interfaces for WINS before failing When nmbd is acting as WINS, it picks the first interface's IP as WINS server's IP. If the first interface's IP is zero, we will just quit (even though we might have other interfaces with valid IPs). This patch makes nmbd look at all interfaces and pick the first interface with a valid IP as the WINS server's IP. --- source3/lib/interface.c | 7 +++++-- source3/nmbd/nmbd_become_dmb.c | 3 ++- source3/nmbd/nmbd_subnetdb.c | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/source3/lib/interface.c b/source3/lib/interface.c index 48fa4d32a9..b32ccb9c56 100644 --- a/source3/lib/interface.c +++ b/source3/lib/interface.c @@ -151,7 +151,8 @@ int iface_count_v4_nl(void) } /**************************************************************************** - Return a pointer to the in_addr of the first IPv4 interface. + Return a pointer to the in_addr of the first IPv4 interface that's + not 0.0.0.0. **************************************************************************/ const struct in_addr *first_ipv4_iface(void) @@ -159,7 +160,9 @@ const struct in_addr *first_ipv4_iface(void) struct interface *i; for (i=local_interfaces;i ;i=i->next) { - if (i->ip.ss_family == AF_INET) { + if ((i->ip.ss_family == AF_INET) && + (!is_zero_ip_v4(((struct sockaddr_in *)&i->ip)->sin_addr))) + { break; } } diff --git a/source3/nmbd/nmbd_become_dmb.c b/source3/nmbd/nmbd_become_dmb.c index a0b2ef15f8..827d56cb06 100644 --- a/source3/nmbd/nmbd_become_dmb.c +++ b/source3/nmbd/nmbd_become_dmb.c @@ -128,7 +128,8 @@ in workgroup %s on subnet %s\n", work->dmb_name = nmbname; - /* Pick the first interface IPv4 address as the domain master browser ip. */ + /* Pick the first interface IPv4 address as the domain master + * browser ip. */ nip = first_ipv4_iface(); if (!nip) { DEBUG(0,("become_domain_master_stage2: " diff --git a/source3/nmbd/nmbd_subnetdb.c b/source3/nmbd/nmbd_subnetdb.c index 61af0bb4a4..13bc931863 100644 --- a/source3/nmbd/nmbd_subnetdb.c +++ b/source3/nmbd/nmbd_subnetdb.c @@ -287,7 +287,8 @@ bool create_subnets(void) } if (lp_we_are_a_wins_server()) { - /* Pick the first interface IPv4 address as the WINS server ip. */ + /* Pick the first interface IPv4 address as the WINS server + * ip. */ const struct in_addr *nip = first_ipv4_iface(); if (!nip) { -- cgit From a66828a37fbb4250dd25c828f3bbb8535fcffea0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 5 Feb 2009 11:15:06 +0100 Subject: Don't use recvall in the proxied np_read_send We don't know how much we will get. Resort to a single recv syscall --- source3/rpc_server/srv_pipe_hnd.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 30d0cf408f..4cbe8d67a3 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1255,10 +1255,9 @@ struct async_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev, struct np_proxy_state *p = talloc_get_type_abort( handle->private_data, struct np_proxy_state); - state->nread = len; state->fd = p->fd; - subreq = recvall_send(state, ev, p->fd, data, len, 0); + subreq = async_recv(state, ev, p->fd, data, len, 0); if (subreq == NULL) { goto fail; } @@ -1283,14 +1282,21 @@ static void np_read_done(struct async_req *subreq) subreq->async.priv, struct async_req); struct np_read_state *state = talloc_get_type_abort( req->private_data, struct np_read_state); - NTSTATUS status; + ssize_t result; + int sys_errno; int available = 0; - status = recvall_recv(subreq); - if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + result = async_syscall_result_ssize_t(subreq, &sys_errno); + if (result == -1) { + async_req_nterror(req, map_nt_error_from_unix(sys_errno)); return; } + if (result == 0) { + async_req_nterror(req, NT_STATUS_END_OF_FILE); + return; + } + + state->nread = result; /* * We don't look at the ioctl result. We don't really care if there is -- cgit From d704efc536cdd0cc9ae9d235242cc4a12ed17858 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 5 Feb 2009 02:54:05 +0100 Subject: s3-svcctl: use security descriptor marshall helper in svcctl_set_secdesc(). Guenther --- source3/services/services_db.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/source3/services/services_db.c b/source3/services/services_db.c index e41524851f..6d1b5d5b95 100644 --- a/source3/services/services_db.c +++ b/source3/services/services_db.c @@ -567,7 +567,8 @@ bool svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, SEC_DESC *sec_desc, WERROR wresult; char *path = NULL; REGVAL_CTR *values = NULL; - prs_struct ps; + DATA_BLOB blob; + NTSTATUS status; bool ret = False; /* now add the security descriptor */ @@ -593,21 +594,18 @@ bool svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, SEC_DESC *sec_desc, /* stream the printer security descriptor */ - if (!prs_init( &ps, RPC_MAX_PDU_FRAG_LEN, key, MARSHALL)) { - DEBUG(0,("svcctl_set_secdesc: prs_init() failed!\n")); + status = marshall_sec_desc(ctx, sec_desc, &blob.data, &blob.length); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("svcctl_set_secdesc: ndr_push_struct_blob() failed!\n")); TALLOC_FREE( key ); return False; } - if ( sec_io_desc("sec_desc", &sec_desc, &ps, 0 ) ) { - uint32 offset = prs_offset( &ps ); - regval_ctr_addvalue( values, "Security", REG_BINARY, prs_data_p(&ps), offset ); - ret = store_reg_values( key, values ); - } + regval_ctr_addvalue( values, "Security", REG_BINARY, (const char *)blob.data, blob.length); + ret = store_reg_values( key, values ); /* cleanup */ - prs_mem_free( &ps ); TALLOC_FREE( key); return ret; -- cgit From 04dea3c95684241446def9340cf49ef5f1cbaf32 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 14 Nov 2008 23:44:06 +0100 Subject: spoolss-idl: fill in spoolss_DeletePrinter. Guenther --- librpc/idl/spoolss.idl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl index 5fdea81575..f3a4cc2c2a 100644 --- a/librpc/idl/spoolss.idl +++ b/librpc/idl/spoolss.idl @@ -393,7 +393,8 @@ import "misc.idl", "security.idl", "winreg.idl"; /******************/ /* Function: 0x06 */ - [todo] WERROR spoolss_DeletePrinter( + WERROR spoolss_DeletePrinter( + [in] policy_handle *handle ); /******************/ -- cgit From 177f7c21ee22c4467f2aebea4c0f778567f90dec Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 18 Dec 2008 01:42:39 +0100 Subject: spoolss: fix spoolss_RemoteFindNextPrinterChangeNotifyEx. Guenther --- librpc/idl/spoolss.idl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl index f3a4cc2c2a..2a2454accb 100644 --- a/librpc/idl/spoolss.idl +++ b/librpc/idl/spoolss.idl @@ -1291,7 +1291,7 @@ import "misc.idl", "security.idl", "winreg.idl"; [in,ref] policy_handle *handle, [in] uint32 change_low, [in,unique] spoolss_NotifyOptionsContainer *container, - [out, unique] spoolss_NotifyInfo *info + [out,ref] spoolss_NotifyInfo **info ); /******************/ -- cgit From 512e815d2b5cbc8bc073ff5bf949eb8bfc0d8083 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 5 Feb 2009 12:19:54 +0100 Subject: s3: re-run make samba3-idl. Guenther --- librpc/gen_ndr/spoolss.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/librpc/gen_ndr/spoolss.h b/librpc/gen_ndr/spoolss.h index a3148ecef3..49eb799079 100644 --- a/librpc/gen_ndr/spoolss.h +++ b/librpc/gen_ndr/spoolss.h @@ -911,6 +911,10 @@ struct spoolss_AddPrinter { struct spoolss_DeletePrinter { + struct { + struct policy_handle *handle;/* [ref] */ + } in; + struct { WERROR result; } out; @@ -1841,7 +1845,7 @@ struct spoolss_RemoteFindNextPrinterChangeNotifyEx { } in; struct { - struct spoolss_NotifyInfo *info;/* [unique] */ + struct spoolss_NotifyInfo **info;/* [ref] */ WERROR result; } out; -- cgit From 3f9daf434ab572044e4826d69dd6b7d6c963c547 Mon Sep 17 00:00:00 2001 From: Karolin Seeger Date: Thu, 5 Feb 2009 15:55:14 +0100 Subject: s3/libads: Change "ldap ssl:ads" parameter to "ldap ssl ads". Karolin --- source3/include/proto.h | 1 + source3/libads/ldap.c | 2 +- source3/param/loadparm.c | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 53781563df..267ee74482 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -3985,6 +3985,7 @@ bool lp_passdb_expand_explicit(void); char *lp_ldap_suffix(void); char *lp_ldap_admin_dn(void); int lp_ldap_ssl(void); +bool lp_ldap_ssl_ads(void); int lp_ldap_passwd_sync(void); bool lp_ldap_delete_dn(void); int lp_ldap_replication_sleep(void); diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index bb2b58e237..edbd69392c 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -672,7 +672,7 @@ got_connection: ldap_set_option(ads->ldap.ld, LDAP_OPT_PROTOCOL_VERSION, &version); - if (lp_parm_bool(-1, "ldap ssl", "ads", false)) { + if ( lp_ldap_ssl_ads() ) { status = ADS_ERROR(smb_ldap_start_tls(ads->ldap.ld, version)); if (!ADS_ERR_OK(status)) { goto out; diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index d672b372cf..bc7d9974f4 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -250,6 +250,7 @@ struct global { char *szLdapIdmapSuffix; char *szLdapGroupSuffix; int ldap_ssl; + bool ldap_ssl_ads; char *szLdapSuffix; char *szLdapAdminDn; int ldap_debug_level; @@ -3610,6 +3611,15 @@ static struct parm_struct parm_table[] = { .enum_list = enum_ldap_ssl, .flags = FLAG_ADVANCED, }, + { + .label = "ldap ssl ads", + .type = P_BOOL, + .p_class = P_GLOBAL, + .ptr = &Globals.ldap_ssl_ads, + .special = NULL, + .enum_list = NULL, + .flags = FLAG_ADVANCED, + }, { .label = "ldap timeout", .type = P_INTEGER, @@ -4922,6 +4932,7 @@ static void init_globals(bool first_time_only) string_set(&Globals.szLdapAdminDn, ""); Globals.ldap_ssl = LDAP_SSL_START_TLS; + Globals.ldap_ssl_ads = False; Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF; Globals.ldap_delete_dn = False; Globals.ldap_replication_sleep = 1000; /* wait 1 sec for replication */ @@ -5266,6 +5277,7 @@ FN_GLOBAL_BOOL(lp_passdb_expand_explicit, &Globals.bPassdbExpandExplicit) FN_GLOBAL_STRING(lp_ldap_suffix, &Globals.szLdapSuffix) FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn) FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl) +FN_GLOBAL_BOOL(lp_ldap_ssl_ads, &Globals.ldap_ssl_ads) FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync) FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn) FN_GLOBAL_INTEGER(lp_ldap_replication_sleep, &Globals.ldap_replication_sleep) -- cgit From 60fc7dadd6b9af645d5e1a8fba2f0b0af415d1cb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 5 Feb 2009 13:43:18 +0100 Subject: Do not ignore spoolss anymore. Guenther --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index dae5f063c3..e9d674be05 100644 --- a/.gitignore +++ b/.gitignore @@ -318,7 +318,6 @@ librpc/gen_ndr/*wzcsvc* librpc/gen_ndr/*w32time* librpc/gen_ndr/*wmi* librpc/gen_ndr/*trkwks* -librpc/gen_ndr/*_spoolss* librpc/gen_ndr/*rot* librpc/gen_ndr/*remact* librpc/gen_ndr/*oxidresolver* -- cgit From b03913cbc684d3bd5e39701e103da875330f3f32 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 14 Nov 2008 21:43:57 +0100 Subject: spoolss: move ndr spoolss helper to main librpc dir. Guenther --- .gitignore | 1 - librpc/idl/spoolss.idl | 2 +- librpc/ndr/ndr_spoolss_buf.c | 532 +++++++++++++++++++++++++++++++++++ librpc/ndr/ndr_spoolss_buf.h | 45 +++ source3/Makefile.in | 3 + source4/librpc/config.mk | 4 +- source4/librpc/ndr/ndr_spoolss_buf.c | 532 ----------------------------------- 7 files changed, 582 insertions(+), 537 deletions(-) create mode 100644 librpc/ndr/ndr_spoolss_buf.c create mode 100644 librpc/ndr/ndr_spoolss_buf.h delete mode 100644 source4/librpc/ndr/ndr_spoolss_buf.c diff --git a/.gitignore b/.gitignore index e9d674be05..703f7e38ea 100644 --- a/.gitignore +++ b/.gitignore @@ -218,7 +218,6 @@ source4/librpc/gen_ndr source4/librpc/idl-deps source4/librpc/ndr/libndr_proto.h source4/librpc/ndr/ndr_compression.h -source4/librpc/ndr/ndr_spoolss_buf.h source4/librpc/ndr/ndr_table.h source4/librpc/rpc/dcerpc_proto.h source4/librpc/rpc/dcerpc_table.h diff --git a/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl index 2a2454accb..fbe12ad64e 100644 --- a/librpc/idl/spoolss.idl +++ b/librpc/idl/spoolss.idl @@ -10,7 +10,7 @@ import "misc.idl", "security.idl", "winreg.idl"; endpoint("ncacn_np:[\\pipe\\spoolss]"), pointer_default(unique), helpstring("Spooler SubSystem"), - helper("librpc/ndr/ndr_spoolss_buf.h") + helper("../librpc/ndr/ndr_spoolss_buf.h") ] interface spoolss { typedef [v1_enum] enum winreg_Type winreg_Type; diff --git a/librpc/ndr/ndr_spoolss_buf.c b/librpc/ndr/ndr_spoolss_buf.c new file mode 100644 index 0000000000..2b95a69bb0 --- /dev/null +++ b/librpc/ndr/ndr_spoolss_buf.c @@ -0,0 +1,532 @@ +/* + Unix SMB/CIFS implementation. + + routines for marshalling/unmarshalling spoolss subcontext buffer structures + + Copyright (C) Andrew Tridgell 2003 + Copyright (C) Tim Potter 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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 . +*/ + + +#include "includes.h" +#include "librpc/gen_ndr/ndr_spoolss.h" +#include "param/param.h" + +#define NDR_SPOOLSS_PUSH_ENUM_IN(fn) do { \ + if (!r->in.buffer && r->in.offered != 0) {\ + return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\ + "SPOOLSS Buffer: r->in.offered[%u] but there's no buffer",\ + (unsigned)r->in.offered);\ + } else if (r->in.buffer && r->in.buffer->length != r->in.offered) {\ + return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\ + "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of r->in.buffer[%u]",\ + (unsigned)r->in.offered, (unsigned)r->in.buffer->length);\ + }\ + _r.in.level = r->in.level;\ + _r.in.buffer = r->in.buffer;\ + _r.in.offered = r->in.offered;\ + NDR_CHECK(ndr_push__##fn(ndr, flags, &_r));\ +} while(0) + +#define NDR_SPOOLSS_PUSH_ENUM_OUT(fn) do { \ + struct ndr_push *_ndr_info;\ + _r.in.level = r->in.level;\ + _r.in.buffer = r->in.buffer;\ + _r.in.offered = r->in.offered;\ + _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 && !r->in.buffer) {\ + return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\ + "SPOOLSS Buffer: r->out.info but there's no r->in.buffer");\ + }\ + if (r->in.buffer) {\ + DATA_BLOB _data_blob_info;\ + _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience);\ + NDR_ERR_HAVE_NO_MEMORY(_ndr_info);\ + _ndr_info->flags= ndr->flags;\ + if (r->out.info) {\ + struct __##fn __r;\ + __r.in.level = r->in.level;\ + __r.in.count = r->out.count;\ + __r.out.info = r->out.info;\ + NDR_CHECK(ndr_push___##fn(_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));\ + } else if (r->in.offered < _ndr_info->offset) {\ + return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\ + "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of out buffer[%u]!",\ + (unsigned)r->in.offered, (unsigned)_ndr_info->offset);\ + }\ + _data_blob_info = ndr_push_blob(_ndr_info);\ + _r.out.info = &_data_blob_info;\ + }\ + NDR_CHECK(ndr_push__##fn(ndr, flags, &_r));\ +} while(0) + +#define NDR_SPOOLSS_PUSH_ENUM(fn,in,out) do { \ + struct _##fn _r;\ + if (flags & NDR_IN) {\ + in;\ + NDR_SPOOLSS_PUSH_ENUM_IN(fn);\ + }\ + if (flags & NDR_OUT) {\ + out;\ + NDR_SPOOLSS_PUSH_ENUM_OUT(fn);\ + }\ +} while(0) + +#define NDR_SPOOLSS_PULL_ENUM_IN(fn) do { \ + ZERO_STRUCT(r->out);\ + NDR_CHECK(ndr_pull__##fn(ndr, flags, &_r));\ + r->in.level = _r.in.level;\ + r->in.buffer = _r.in.buffer;\ + r->in.offered = _r.in.offered;\ + r->out.needed = _r.out.needed;\ + if (!r->in.buffer && r->in.offered != 0) {\ + return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,\ + "SPOOLSS Buffer: r->in.offered[%u] but there's no buffer",\ + (unsigned)r->in.offered);\ + } else if (r->in.buffer && r->in.buffer->length != r->in.offered) {\ + return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,\ + "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of r->in.buffer[%u]",\ + (unsigned)r->in.offered, (unsigned)r->in.buffer->length);\ + }\ +} while(0) + +#define NDR_SPOOLSS_PULL_ENUM_OUT(fn) do { \ + _r.in.level = r->in.level;\ + _r.in.buffer = r->in.buffer;\ + _r.in.offered = r->in.offered;\ + _r.out.needed = r->out.needed;\ + NDR_CHECK(ndr_pull__##fn(ndr, flags, &_r));\ + 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) {\ + struct ndr_pull *_ndr_info = ndr_pull_init_blob(_r.out.info, ndr, 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 __##fn __r;\ + __r.in.level = r->in.level;\ + __r.in.count = r->out.count;\ + __r.out.info = NULL;\ + NDR_CHECK(ndr_pull___##fn(_ndr_info, flags, &__r));\ + r->out.info = __r.out.info;\ + }\ + }\ +} while(0) + +#define NDR_SPOOLSS_PULL_ENUM(fn,in,out) do { \ + struct _##fn _r;\ + if (flags & NDR_IN) {\ + out;\ + NDR_SPOOLSS_PULL_ENUM_IN(fn);\ + in;\ + }\ + if (flags & NDR_OUT) {\ + out;\ + NDR_SPOOLSS_PULL_ENUM_OUT(fn);\ + }\ +} while(0) + +#define _NDR_CHECK_UINT32(call) do {\ + enum ndr_err_code _ndr_err; \ + _ndr_err = call; \ + if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \ + return 0; \ + }\ +} 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.level = level;\ + __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 +*/ +enum ndr_err_code ndr_push_spoolss_EnumPrinters(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinters *r) +{ + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrinters,{ + _r.in.flags = r->in.flags; + _r.in.server = r->in.server; + },{ + _r.in.flags = r->in.flags; + _r.in.server = r->in.server; + }); + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_pull_spoolss_EnumPrinters(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinters *r) +{ + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrinters,{ + r->in.flags = _r.in.flags; + r->in.server = _r.in.server; + },{ + _r.in.flags = r->in.flags; + _r.in.server = r->in.server; + }); + return NDR_ERR_SUCCESS; +} + +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); +} + +/* + spoolss_EnumJobs +*/ +enum ndr_err_code ndr_push_spoolss_EnumJobs(struct ndr_push *ndr, int flags, const struct spoolss_EnumJobs *r) +{ + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumJobs,{ + _r.in.handle = r->in.handle; + _r.in.firstjob = r->in.firstjob; + _r.in.numjobs = r->in.numjobs; + },{ + _r.in.handle = r->in.handle; + _r.in.firstjob = r->in.firstjob; + _r.in.numjobs = r->in.numjobs; + }); + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_pull_spoolss_EnumJobs(struct ndr_pull *ndr, int flags, struct spoolss_EnumJobs *r) +{ + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumJobs,{ + r->in.handle = _r.in.handle; + r->in.firstjob = _r.in.firstjob; + r->in.numjobs = _r.in.numjobs; + },{ + _r.in.handle = r->in.handle; + _r.in.firstjob = r->in.firstjob; + _r.in.numjobs = r->in.numjobs; + }); + 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) +{ + NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumJobs); +} + +/* + spoolss_EnumPrinterDrivers +*/ +enum ndr_err_code ndr_push_spoolss_EnumPrinterDrivers(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterDrivers *r) +{ + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrinterDrivers,{ + _r.in.server = r->in.server; + _r.in.environment = r->in.environment; + },{ + _r.in.server = r->in.server; + _r.in.environment = r->in.environment; + }); + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_pull_spoolss_EnumPrinterDrivers(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDrivers *r) +{ + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrinterDrivers,{ + r->in.server = _r.in.server; + r->in.environment = _r.in.environment; + },{ + _r.in.server = r->in.server; + _r.in.environment = r->in.environment; + }); + return NDR_ERR_SUCCESS; +} + +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); +} + +/* + spoolss_EnumForms +*/ +enum ndr_err_code ndr_push_spoolss_EnumForms(struct ndr_push *ndr, int flags, const struct spoolss_EnumForms *r) +{ + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumForms,{ + _r.in.handle = r->in.handle; + },{ + _r.in.handle = r->in.handle; + }); + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_pull_spoolss_EnumForms(struct ndr_pull *ndr, int flags, struct spoolss_EnumForms *r) +{ + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumForms,{ + r->in.handle = _r.in.handle; + },{ + _r.in.handle = r->in.handle; + }); + return NDR_ERR_SUCCESS; +} + +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); +} + +/* + spoolss_EnumPorts +*/ +enum ndr_err_code ndr_push_spoolss_EnumPorts(struct ndr_push *ndr, int flags, const struct spoolss_EnumPorts *r) +{ + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPorts,{ + _r.in.servername= r->in.servername; + },{ + _r.in.servername= r->in.servername; + }); + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_pull_spoolss_EnumPorts(struct ndr_pull *ndr, int flags, struct spoolss_EnumPorts *r) +{ + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPorts,{ + r->in.servername= _r.in.servername; + },{ + _r.in.servername= r->in.servername; + }); + return NDR_ERR_SUCCESS; +} + +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); +} + +/* + spoolss_EnumMonitors +*/ +enum ndr_err_code ndr_push_spoolss_EnumMonitors(struct ndr_push *ndr, int flags, const struct spoolss_EnumMonitors *r) +{ + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumMonitors,{ + _r.in.servername= r->in.servername; + },{ + _r.in.servername= r->in.servername; + }); + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_pull_spoolss_EnumMonitors(struct ndr_pull *ndr, int flags, struct spoolss_EnumMonitors *r) +{ + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumMonitors,{ + r->in.servername= _r.in.servername; + },{ + _r.in.servername= r->in.servername; + }); + return NDR_ERR_SUCCESS; +} + +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); +} + +/* + spoolss_EnumPrintProcessors +*/ +enum ndr_err_code ndr_push_spoolss_EnumPrintProcessors(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcessors *r) +{ + NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrintProcessors,{ + _r.in.servername = r->in.servername; + _r.in.environment = r->in.environment; + },{ + _r.in.servername = r->in.servername; + _r.in.environment = r->in.environment; + }); + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_pull_spoolss_EnumPrintProcessors(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcessors *r) +{ + NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrintProcessors,{ + r->in.servername = _r.in.servername; + r->in.environment = _r.in.environment; + },{ + _r.in.servername = r->in.servername; + _r.in.environment = r->in.environment; + }); + 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) +{ + NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPrintProcessors); +} + +/* + spoolss_GetPrinterData +*/ +enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterData *r) +{ + struct _spoolss_GetPrinterData _r; + if (flags & NDR_IN) { + _r.in.handle = r->in.handle; + _r.in.value_name= r->in.value_name; + _r.in.offered = r->in.offered; + NDR_CHECK(ndr_push__spoolss_GetPrinterData(ndr, flags, &_r)); + } + if (flags & NDR_OUT) { + struct ndr_push *_ndr_info; + _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.needed = r->out.needed; + _r.out.result = r->out.result; + { + struct __spoolss_GetPrinterData __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.type = r->out.type; + __r.out.data = r->out.data; + NDR_CHECK(ndr_push___spoolss_GetPrinterData(_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.data = ndr_push_blob(_ndr_info); + } + NDR_CHECK(ndr_push__spoolss_GetPrinterData(ndr, flags, &_r)); + } + return NDR_ERR_SUCCESS; +} + +enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterData *r) +{ + struct _spoolss_GetPrinterData _r; + if (flags & NDR_IN) { + 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.needed = r->out.needed; + NDR_CHECK(ndr_pull__spoolss_GetPrinterData(ndr, flags, &_r)); + r->in.handle = _r.in.handle; + r->in.value_name= _r.in.value_name; + r->in.offered = _r.in.offered; + r->out.needed = _r.out.needed; + } + if (flags & NDR_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.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); + r->out.needed = _r.out.needed; + r->out.result = _r.out.result; + if (_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); + } + if (_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); + NDR_ERR_HAVE_NO_MEMORY(_ndr_data); + _ndr_data->flags= ndr->flags; + __r.in.type = r->out.type; + __r.out.data = r->out.data; + 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; + } + } + return NDR_ERR_SUCCESS; +} + +/* + spoolss_SetPrinterData +*/ +enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterData *r) +{ + struct _spoolss_SetPrinterData _r; + if (flags & NDR_IN) { + struct ndr_push *_ndr_data; + struct __spoolss_SetPrinterData __r; + DATA_BLOB _data_blob_data; + + _ndr_data = ndr_push_init_ctx(ndr, ndr->iconv_convenience); + NDR_ERR_HAVE_NO_MEMORY(_ndr_data); + _ndr_data->flags= ndr->flags; + + __r.in.type = r->in.type; + __r.out.data = r->in.data; + NDR_CHECK(ndr_push___spoolss_SetPrinterData(_ndr_data, NDR_OUT, &__r)); + _data_blob_data = ndr_push_blob(_ndr_data); + + _r.in.handle = r->in.handle; + _r.in.value_name= r->in.value_name; + _r.in.type = r->in.type; + _r.in.data = _data_blob_data; + _r.in._offered = _data_blob_data.length; + _r.out.result = r->out.result; + NDR_CHECK(ndr_push__spoolss_SetPrinterData(ndr, flags, &_r)); + } + if (flags & NDR_OUT) { + _r.in.handle = r->in.handle; + _r.in.value_name= r->in.value_name; + _r.in.type = r->in.type; + _r.in.data = data_blob(NULL,0), + _r.in._offered = r->in._offered; + _r.out.result = r->out.result; + NDR_CHECK(ndr_push__spoolss_SetPrinterData(ndr, flags, &_r)); + } + return NDR_ERR_SUCCESS; +} + +uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic, uint32_t flags) +{ + if (!devmode) return 0; + return ndr_size_spoolss_DeviceMode(devmode,ic,flags); +} diff --git a/librpc/ndr/ndr_spoolss_buf.h b/librpc/ndr/ndr_spoolss_buf.h new file mode 100644 index 0000000000..209ae51ce7 --- /dev/null +++ b/librpc/ndr/ndr_spoolss_buf.h @@ -0,0 +1,45 @@ +#ifndef ___SPACE_SRC_SAMBA_SOURCES_SAMBA_GIT_SOURCE3____SOURCE4_LIBRPC_NDR_NDR_SPOOLSS_BUF_H__ +#define ___SPACE_SRC_SAMBA_SOURCES_SAMBA_GIT_SOURCE3____SOURCE4_LIBRPC_NDR_NDR_SPOOLSS_BUF_H__ + +#undef _PRINTF_ATTRIBUTE +#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2) +/* This file was automatically generated by mkproto.pl. DO NOT EDIT */ + +/* this file contains prototypes for functions that are private + * to this subsystem or library. These functions should not be + * used outside this particular subsystem! */ + + +/* The following definitions come from /space/src/samba/SOURCES/samba.git/source3/../source4/librpc/ndr/ndr_spoolss_buf.c */ + +enum ndr_err_code ndr_push_spoolss_EnumPrinters(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinters *r); +enum ndr_err_code ndr_pull_spoolss_EnumPrinters(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinters *r); +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); +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); +enum ndr_err_code ndr_push_spoolss_EnumForms(struct ndr_push *ndr, int flags, const struct spoolss_EnumForms *r); +enum ndr_err_code ndr_pull_spoolss_EnumForms(struct ndr_pull *ndr, int flags, struct spoolss_EnumForms *r); +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); +enum ndr_err_code ndr_push_spoolss_EnumPorts(struct ndr_push *ndr, int flags, const struct spoolss_EnumPorts *r); +enum ndr_err_code ndr_pull_spoolss_EnumPorts(struct ndr_pull *ndr, int flags, struct spoolss_EnumPorts *r); +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); +enum ndr_err_code ndr_push_spoolss_EnumMonitors(struct ndr_push *ndr, int flags, const struct spoolss_EnumMonitors *r); +enum ndr_err_code ndr_pull_spoolss_EnumMonitors(struct ndr_pull *ndr, int flags, struct spoolss_EnumMonitors *r); +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); +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); +uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic, uint32_t flags); +#undef _PRINTF_ATTRIBUTE +#define _PRINTF_ATTRIBUTE(a1, a2) + +#endif /* ___SPACE_SRC_SAMBA_SOURCES_SAMBA_GIT_SOURCE3____SOURCE4_LIBRPC_NDR_NDR_SPOOLSS_BUF_H__ */ + diff --git a/source3/Makefile.in b/source3/Makefile.in index c1b51db571..8e8932bc5f 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -291,6 +291,9 @@ LIBNDR_GEN_OBJ0 = ../librpc/gen_ndr/ndr_samr.o \ LIBNDR_GEN_OBJ1 = ../librpc/gen_ndr/ndr_netlogon.o \ ../librpc/ndr/ndr_netlogon.o +LIBNDR_GEN_OBJ2 = ../librpc/gen_ndr/ndr_spoolss.o \ + ../librpc/ndr/ndr_spoolss_buf.o + LIBNDR_GEN_OBJ = ../librpc/gen_ndr/ndr_wkssvc.o \ $(LIBNDR_GEN_OBJ0) \ ../librpc/gen_ndr/ndr_dfs.o \ diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk index 2f276886e9..3e6ea313e7 100644 --- a/source4/librpc/config.mk +++ b/source4/librpc/config.mk @@ -180,9 +180,7 @@ NDR_SPOOLSS_OBJ_FILES = ../librpc/gen_ndr/ndr_spoolss.o [SUBSYSTEM::NDR_SPOOLSS_BUF] -NDR_SPOOLSS_BUF_OBJ_FILES = $(ndrsrcdir)/ndr_spoolss_buf.o - -$(eval $(call proto_header_template,$(ndrsrcdir)/ndr_spoolss_buf.h,$(NDR_SPOOLSS_BUF_OBJ_FILES:.o=.c))) +NDR_SPOOLSS_BUF_OBJ_FILES = ../librpc/ndr/ndr_spoolss_buf.o [SUBSYSTEM::NDR_WKSSVC] PUBLIC_DEPENDENCIES = LIBNDR NDR_SRVSVC NDR_SECURITY diff --git a/source4/librpc/ndr/ndr_spoolss_buf.c b/source4/librpc/ndr/ndr_spoolss_buf.c deleted file mode 100644 index 335275f680..0000000000 --- a/source4/librpc/ndr/ndr_spoolss_buf.c +++ /dev/null @@ -1,532 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - routines for marshalling/unmarshalling spoolss subcontext buffer structures - - Copyright (C) Andrew Tridgell 2003 - Copyright (C) Tim Potter 2003 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 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 . -*/ - - -#include "includes.h" -#include "librpc/gen_ndr/ndr_spoolss.h" -#include "param/param.h" - -#define NDR_SPOOLSS_PUSH_ENUM_IN(fn) do { \ - if (!r->in.buffer && r->in.offered != 0) {\ - return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\ - "SPOOLSS Buffer: r->in.offered[%u] but there's no buffer",\ - (unsigned)r->in.offered);\ - } else if (r->in.buffer && r->in.buffer->length != r->in.offered) {\ - return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\ - "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of r->in.buffer[%u]",\ - (unsigned)r->in.offered, (unsigned)r->in.buffer->length);\ - }\ - _r.in.level = r->in.level;\ - _r.in.buffer = r->in.buffer;\ - _r.in.offered = r->in.offered;\ - NDR_CHECK(ndr_push__##fn(ndr, flags, &_r));\ -} while(0) - -#define NDR_SPOOLSS_PUSH_ENUM_OUT(fn) do { \ - struct ndr_push *_ndr_info;\ - _r.in.level = r->in.level;\ - _r.in.buffer = r->in.buffer;\ - _r.in.offered = r->in.offered;\ - _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 && !r->in.buffer) {\ - return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\ - "SPOOLSS Buffer: r->out.info but there's no r->in.buffer");\ - }\ - if (r->in.buffer) {\ - DATA_BLOB _data_blob_info;\ - _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience);\ - NDR_ERR_HAVE_NO_MEMORY(_ndr_info);\ - _ndr_info->flags= ndr->flags;\ - if (r->out.info) {\ - struct __##fn __r;\ - __r.in.level = r->in.level;\ - __r.in.count = r->out.count;\ - __r.out.info = r->out.info;\ - NDR_CHECK(ndr_push___##fn(_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));\ - } else if (r->in.offered < _ndr_info->offset) {\ - return ndr_push_error(ndr, NDR_ERR_BUFSIZE,\ - "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of out buffer[%u]!",\ - (unsigned)r->in.offered, (unsigned)_ndr_info->offset);\ - }\ - _data_blob_info = ndr_push_blob(_ndr_info);\ - _r.out.info = &_data_blob_info;\ - }\ - NDR_CHECK(ndr_push__##fn(ndr, flags, &_r));\ -} while(0) - -#define NDR_SPOOLSS_PUSH_ENUM(fn,in,out) do { \ - struct _##fn _r;\ - if (flags & NDR_IN) {\ - in;\ - NDR_SPOOLSS_PUSH_ENUM_IN(fn);\ - }\ - if (flags & NDR_OUT) {\ - out;\ - NDR_SPOOLSS_PUSH_ENUM_OUT(fn);\ - }\ -} while(0) - -#define NDR_SPOOLSS_PULL_ENUM_IN(fn) do { \ - ZERO_STRUCT(r->out);\ - NDR_CHECK(ndr_pull__##fn(ndr, flags, &_r));\ - r->in.level = _r.in.level;\ - r->in.buffer = _r.in.buffer;\ - r->in.offered = _r.in.offered;\ - r->out.needed = _r.out.needed;\ - if (!r->in.buffer && r->in.offered != 0) {\ - return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,\ - "SPOOLSS Buffer: r->in.offered[%u] but there's no buffer",\ - (unsigned)r->in.offered);\ - } else if (r->in.buffer && r->in.buffer->length != r->in.offered) {\ - return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,\ - "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of r->in.buffer[%u]",\ - (unsigned)r->in.offered, (unsigned)r->in.buffer->length);\ - }\ -} while(0) - -#define NDR_SPOOLSS_PULL_ENUM_OUT(fn) do { \ - _r.in.level = r->in.level;\ - _r.in.buffer = r->in.buffer;\ - _r.in.offered = r->in.offered;\ - _r.out.needed = r->out.needed;\ - NDR_CHECK(ndr_pull__##fn(ndr, flags, &_r));\ - 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) {\ - struct ndr_pull *_ndr_info = ndr_pull_init_blob(_r.out.info, ndr, 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 __##fn __r;\ - __r.in.level = r->in.level;\ - __r.in.count = r->out.count;\ - __r.out.info = NULL;\ - NDR_CHECK(ndr_pull___##fn(_ndr_info, flags, &__r));\ - r->out.info = __r.out.info;\ - }\ - }\ -} while(0) - -#define NDR_SPOOLSS_PULL_ENUM(fn,in,out) do { \ - struct _##fn _r;\ - if (flags & NDR_IN) {\ - out;\ - NDR_SPOOLSS_PULL_ENUM_IN(fn);\ - in;\ - }\ - if (flags & NDR_OUT) {\ - out;\ - NDR_SPOOLSS_PULL_ENUM_OUT(fn);\ - }\ -} while(0) - -#define _NDR_CHECK_UINT32(call) do {\ - enum ndr_err_code _ndr_err; \ - _ndr_err = call; \ - if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \ - return 0; \ - }\ -} 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.level = level;\ - __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 -*/ -enum ndr_err_code ndr_push_spoolss_EnumPrinters(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinters *r) -{ - NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrinters,{ - _r.in.flags = r->in.flags; - _r.in.server = r->in.server; - },{ - _r.in.flags = r->in.flags; - _r.in.server = r->in.server; - }); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_EnumPrinters(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinters *r) -{ - NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrinters,{ - r->in.flags = _r.in.flags; - r->in.server = _r.in.server; - },{ - _r.in.flags = r->in.flags; - _r.in.server = r->in.server; - }); - return NDR_ERR_SUCCESS; -} - -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); -} - -/* - spoolss_EnumJobs -*/ -enum ndr_err_code ndr_push_spoolss_EnumJobs(struct ndr_push *ndr, int flags, const struct spoolss_EnumJobs *r) -{ - NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumJobs,{ - _r.in.handle = r->in.handle; - _r.in.firstjob = r->in.firstjob; - _r.in.numjobs = r->in.numjobs; - },{ - _r.in.handle = r->in.handle; - _r.in.firstjob = r->in.firstjob; - _r.in.numjobs = r->in.numjobs; - }); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_EnumJobs(struct ndr_pull *ndr, int flags, struct spoolss_EnumJobs *r) -{ - NDR_SPOOLSS_PULL_ENUM(spoolss_EnumJobs,{ - r->in.handle = _r.in.handle; - r->in.firstjob = _r.in.firstjob; - r->in.numjobs = _r.in.numjobs; - },{ - _r.in.handle = r->in.handle; - _r.in.firstjob = r->in.firstjob; - _r.in.numjobs = r->in.numjobs; - }); - 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) -{ - NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumJobs); -} - -/* - spoolss_EnumPrinterDrivers -*/ -enum ndr_err_code ndr_push_spoolss_EnumPrinterDrivers(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterDrivers *r) -{ - NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrinterDrivers,{ - _r.in.server = r->in.server; - _r.in.environment = r->in.environment; - },{ - _r.in.server = r->in.server; - _r.in.environment = r->in.environment; - }); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_EnumPrinterDrivers(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDrivers *r) -{ - NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrinterDrivers,{ - r->in.server = _r.in.server; - r->in.environment = _r.in.environment; - },{ - _r.in.server = r->in.server; - _r.in.environment = r->in.environment; - }); - return NDR_ERR_SUCCESS; -} - -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); -} - -/* - spoolss_EnumForms -*/ -enum ndr_err_code ndr_push_spoolss_EnumForms(struct ndr_push *ndr, int flags, const struct spoolss_EnumForms *r) -{ - NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumForms,{ - _r.in.handle = r->in.handle; - },{ - _r.in.handle = r->in.handle; - }); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_EnumForms(struct ndr_pull *ndr, int flags, struct spoolss_EnumForms *r) -{ - NDR_SPOOLSS_PULL_ENUM(spoolss_EnumForms,{ - r->in.handle = _r.in.handle; - },{ - _r.in.handle = r->in.handle; - }); - return NDR_ERR_SUCCESS; -} - -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); -} - -/* - spoolss_EnumPorts -*/ -enum ndr_err_code ndr_push_spoolss_EnumPorts(struct ndr_push *ndr, int flags, const struct spoolss_EnumPorts *r) -{ - NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPorts,{ - _r.in.servername= r->in.servername; - },{ - _r.in.servername= r->in.servername; - }); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_EnumPorts(struct ndr_pull *ndr, int flags, struct spoolss_EnumPorts *r) -{ - NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPorts,{ - r->in.servername= _r.in.servername; - },{ - _r.in.servername= r->in.servername; - }); - return NDR_ERR_SUCCESS; -} - -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); -} - -/* - spoolss_EnumMonitors -*/ -enum ndr_err_code ndr_push_spoolss_EnumMonitors(struct ndr_push *ndr, int flags, const struct spoolss_EnumMonitors *r) -{ - NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumMonitors,{ - _r.in.servername= r->in.servername; - },{ - _r.in.servername= r->in.servername; - }); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_EnumMonitors(struct ndr_pull *ndr, int flags, struct spoolss_EnumMonitors *r) -{ - NDR_SPOOLSS_PULL_ENUM(spoolss_EnumMonitors,{ - r->in.servername= _r.in.servername; - },{ - _r.in.servername= r->in.servername; - }); - return NDR_ERR_SUCCESS; -} - -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); -} - -/* - spoolss_EnumPrintProcessors -*/ -enum ndr_err_code ndr_push_spoolss_EnumPrintProcessors(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcessors *r) -{ - NDR_SPOOLSS_PUSH_ENUM(spoolss_EnumPrintProcessors,{ - _r.in.servername = r->in.servername; - _r.in.environment = r->in.environment; - },{ - _r.in.servername = r->in.servername; - _r.in.environment = r->in.environment; - }); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_EnumPrintProcessors(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcessors *r) -{ - NDR_SPOOLSS_PULL_ENUM(spoolss_EnumPrintProcessors,{ - r->in.servername = _r.in.servername; - r->in.environment = _r.in.environment; - },{ - _r.in.servername = r->in.servername; - _r.in.environment = r->in.environment; - }); - 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) -{ - NDR_SPOOLSS_SIZE_ENUM(spoolss_EnumPrintProcessors); -} - -/* - spoolss_GetPrinterData -*/ -enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterData *r) -{ - struct _spoolss_GetPrinterData _r; - if (flags & NDR_IN) { - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.offered = r->in.offered; - NDR_CHECK(ndr_push__spoolss_GetPrinterData(ndr, flags, &_r)); - } - if (flags & NDR_OUT) { - struct ndr_push *_ndr_info; - _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.needed = r->out.needed; - _r.out.result = r->out.result; - { - struct __spoolss_GetPrinterData __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.type = r->out.type; - __r.out.data = r->out.data; - NDR_CHECK(ndr_push___spoolss_GetPrinterData(_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.data = ndr_push_blob(_ndr_info); - } - NDR_CHECK(ndr_push__spoolss_GetPrinterData(ndr, flags, &_r)); - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterData *r) -{ - struct _spoolss_GetPrinterData _r; - if (flags & NDR_IN) { - 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.needed = r->out.needed; - NDR_CHECK(ndr_pull__spoolss_GetPrinterData(ndr, flags, &_r)); - r->in.handle = _r.in.handle; - r->in.value_name= _r.in.value_name; - r->in.offered = _r.in.offered; - r->out.needed = _r.out.needed; - } - if (flags & NDR_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.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); - r->out.needed = _r.out.needed; - r->out.result = _r.out.result; - if (_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); - } - if (_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); - NDR_ERR_HAVE_NO_MEMORY(_ndr_data); - _ndr_data->flags= ndr->flags; - __r.in.type = r->out.type; - __r.out.data = r->out.data; - 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; - } - } - return NDR_ERR_SUCCESS; -} - -/* - spoolss_SetPrinterData -*/ -enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterData *r) -{ - struct _spoolss_SetPrinterData _r; - if (flags & NDR_IN) { - struct ndr_push *_ndr_data; - struct __spoolss_SetPrinterData __r; - DATA_BLOB _data_blob_data; - - _ndr_data = ndr_push_init_ctx(ndr, ndr->iconv_convenience); - NDR_ERR_HAVE_NO_MEMORY(_ndr_data); - _ndr_data->flags= ndr->flags; - - __r.in.type = r->in.type; - __r.out.data = r->in.data; - NDR_CHECK(ndr_push___spoolss_SetPrinterData(_ndr_data, NDR_OUT, &__r)); - _data_blob_data = ndr_push_blob(_ndr_data); - - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.type = r->in.type; - _r.in.data = _data_blob_data; - _r.in._offered = _data_blob_data.length; - _r.out.result = r->out.result; - NDR_CHECK(ndr_push__spoolss_SetPrinterData(ndr, flags, &_r)); - } - if (flags & NDR_OUT) { - _r.in.handle = r->in.handle; - _r.in.value_name= r->in.value_name; - _r.in.type = r->in.type; - _r.in.data = data_blob(NULL,0), - _r.in._offered = r->in._offered; - _r.out.result = r->out.result; - NDR_CHECK(ndr_push__spoolss_SetPrinterData(ndr, flags, &_r)); - } - return NDR_ERR_SUCCESS; -} - -uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic, uint32_t flags) -{ - if (!devmode) return 0; - return ndr_size_spoolss_DeviceMode(devmode,ic,flags); -} -- cgit From c9e64100d445b7c8c447629c0535722a8e59d1f9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 14 Nov 2008 22:15:16 +0100 Subject: spoolss: fix samba4 dependency of spoolss helper. Guenther --- librpc/ndr/ndr_spoolss_buf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/librpc/ndr/ndr_spoolss_buf.c b/librpc/ndr/ndr_spoolss_buf.c index 2b95a69bb0..1cb1df3fd5 100644 --- a/librpc/ndr/ndr_spoolss_buf.c +++ b/librpc/ndr/ndr_spoolss_buf.c @@ -23,7 +23,9 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_spoolss.h" +#if (_SAMBA_BUILD_ >= 4) #include "param/param.h" +#endif #define NDR_SPOOLSS_PUSH_ENUM_IN(fn) do { \ if (!r->in.buffer && r->in.offered != 0) {\ -- cgit From afa960cbbcd609123d710c301e7a9a070c1fed70 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 5 Feb 2009 15:50:47 +0100 Subject: spoolss: add generated spoolss code. Guenther --- librpc/gen_ndr/cli_spoolss.c | 4433 +++++++++++ librpc/gen_ndr/cli_spoolss.h | 523 ++ librpc/gen_ndr/ndr_spoolss.c | 16993 +++++++++++++++++++++++++++++++++++++++++ librpc/gen_ndr/ndr_spoolss.h | 501 ++ librpc/gen_ndr/srv_spoolss.c | 8437 ++++++++++++++++++++ librpc/gen_ndr/srv_spoolss.h | 199 + 6 files changed, 31086 insertions(+) create mode 100644 librpc/gen_ndr/cli_spoolss.c create mode 100644 librpc/gen_ndr/cli_spoolss.h create mode 100644 librpc/gen_ndr/ndr_spoolss.c create mode 100644 librpc/gen_ndr/ndr_spoolss.h create mode 100644 librpc/gen_ndr/srv_spoolss.c create mode 100644 librpc/gen_ndr/srv_spoolss.h diff --git a/librpc/gen_ndr/cli_spoolss.c b/librpc/gen_ndr/cli_spoolss.c new file mode 100644 index 0000000000..1071f2a3a8 --- /dev/null +++ b/librpc/gen_ndr/cli_spoolss.c @@ -0,0 +1,4433 @@ +/* + * Unix SMB/CIFS implementation. + * client auto-generated by pidl. DO NOT MODIFY! + */ + +#include "includes.h" +#include "../librpc/gen_ndr/cli_spoolss.h" + +NTSTATUS rpccli_spoolss_EnumPrinters(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + uint32_t flags /* [in] */, + const char *server /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_PrinterInfo *info /* [out] [unique,switch_is(level),size_is(count)] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror) +{ + struct spoolss_EnumPrinters r; + NTSTATUS status; + + /* In parameters */ + r.in.flags = flags; + r.in.server = server; + r.in.level = level; + r.in.buffer = buffer; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPrinters, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ENUMPRINTERS, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPrinters, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + if (info && r.out.info) { + memcpy(info, r.out.info, count * sizeof(*info)); + } + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_OpenPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *printername /* [in] [unique,charset(UTF16)] */, + const char *datatype /* [in] [unique,charset(UTF16)] */, + struct spoolss_DevmodeContainer devmode_ctr /* [in] */, + uint32_t access_mask /* [in] */, + struct policy_handle *handle /* [out] [ref] */, + WERROR *werror) +{ + struct spoolss_OpenPrinter r; + NTSTATUS status; + + /* In parameters */ + r.in.printername = printername; + r.in.datatype = datatype; + r.in.devmode_ctr = devmode_ctr; + r.in.access_mask = access_mask; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_OpenPrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_OPENPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_OpenPrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + *handle = *r.out.handle; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_SetJob(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t job_id /* [in] */, + struct spoolss_JobInfoContainer *ctr /* [in] [unique] */, + enum spoolss_JobControl command /* [in] */, + WERROR *werror) +{ + struct spoolss_SetJob r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.job_id = job_id; + r.in.ctr = ctr; + r.in.command = command; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_SetJob, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_SETJOB, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_SetJob, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_GetJob(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t job_id /* [in] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_JobInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */, + uint32_t needed /* [out] */, + WERROR *werror) +{ + struct spoolss_GetJob r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.job_id = job_id; + r.in.level = level; + r.in.buffer = buffer; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetJob, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_GETJOB, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetJob, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + if (info && r.out.info) { + *info = *r.out.info; + } + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_EnumJobs(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t firstjob /* [in] */, + uint32_t numjobs /* [in] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_JobInfo *info /* [out] [unique,switch_is(level),size_is(count)] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror) +{ + struct spoolss_EnumJobs r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.firstjob = firstjob; + r.in.numjobs = numjobs; + r.in.level = level; + r.in.buffer = buffer; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumJobs, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ENUMJOBS, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumJobs, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + if (info && r.out.info) { + memcpy(info, r.out.info, count * sizeof(*info)); + } + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_AddPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_AddPrinter r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ADDPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_DeletePrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + WERROR *werror) +{ + struct spoolss_DeletePrinter r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_DELETEPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_SetPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t level /* [in] */, + union spoolss_SetPrinterInfo info /* [in] [switch_is(level)] */, + struct spoolss_DevmodeContainer devmode_ctr /* [in] */, + struct sec_desc_buf secdesc_ctr /* [in] */, + enum spoolss_PrinterControl command /* [in] */, + WERROR *werror) +{ + struct spoolss_SetPrinter r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.level = level; + r.in.info = info; + r.in.devmode_ctr = devmode_ctr; + r.in.secdesc_ctr = secdesc_ctr; + r.in.command = command; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_SetPrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_SETPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_SetPrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_GetPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_PrinterInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */, + uint32_t needed /* [out] */, + WERROR *werror) +{ + struct spoolss_GetPrinter r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.level = level; + r.in.buffer = buffer; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetPrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_GETPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetPrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + if (info && r.out.info) { + *info = *r.out.info; + } + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_AddPrinterDriver(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_AddPrinterDriver r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPrinterDriver, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ADDPRINTERDRIVER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPrinterDriver, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_EnumPrinterDrivers(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *server /* [in] [unique,charset(UTF16)] */, + const char *environment /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_DriverInfo *info /* [out] [unique,switch_is(level),size_is(count)] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror) +{ + struct spoolss_EnumPrinterDrivers r; + NTSTATUS status; + + /* In parameters */ + r.in.server = server; + r.in.environment = environment; + r.in.level = level; + r.in.buffer = buffer; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPrinterDrivers, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ENUMPRINTERDRIVERS, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPrinterDrivers, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + if (info && r.out.info) { + memcpy(info, r.out.info, count * sizeof(*info)); + } + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_GetPrinterDriver(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_GetPrinterDriver r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetPrinterDriver, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_GETPRINTERDRIVER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetPrinterDriver, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_GetPrinterDriverDirectory(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *server /* [in] [unique,charset(UTF16)] */, + const char *environment /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_DriverDirectoryInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */, + uint32_t needed /* [out] */, + WERROR *werror) +{ + struct spoolss_GetPrinterDriverDirectory r; + NTSTATUS status; + + /* In parameters */ + r.in.server = server; + r.in.environment = environment; + r.in.level = level; + r.in.buffer = buffer; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetPrinterDriverDirectory, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_GETPRINTERDRIVERDIRECTORY, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetPrinterDriverDirectory, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + if (info && r.out.info) { + *info = *r.out.info; + } + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_DeletePrinterDriver(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *server /* [in] [unique,charset(UTF16)] */, + const char *architecture /* [in] [charset(UTF16)] */, + const char *driver /* [in] [charset(UTF16)] */, + WERROR *werror) +{ + struct spoolss_DeletePrinterDriver r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.server = server; + r.in.architecture = architecture; + r.in.driver = driver; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinterDriver, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_DELETEPRINTERDRIVER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinterDriver, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_AddPrintProcessor(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_AddPrintProcessor r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPrintProcessor, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ADDPRINTPROCESSOR, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPrintProcessor, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_EnumPrintProcessors(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername /* [in] [unique,charset(UTF16)] */, + const char *environment /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_PrintProcessorInfo *info /* [out] [unique,switch_is(level),size_is(count)] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror) +{ + struct spoolss_EnumPrintProcessors r; + NTSTATUS status; + + /* In parameters */ + r.in.servername = servername; + r.in.environment = environment; + r.in.level = level; + r.in.buffer = buffer; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPrintProcessors, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ENUMPRINTPROCESSORS, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPrintProcessors, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + if (info && r.out.info) { + memcpy(info, r.out.info, count * sizeof(*info)); + } + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_GetPrintProcessorDirectory(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_GetPrintProcessorDirectory r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetPrintProcessorDirectory, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_GETPRINTPROCESSORDIRECTORY, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetPrintProcessorDirectory, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_StartDocPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t level /* [in] */, + union spoolss_DocumentInfo info /* [in] [switch_is(level)] */, + uint32_t job_id /* [out] */, + WERROR *werror) +{ + struct spoolss_StartDocPrinter r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.level = level; + r.in.info = info; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_StartDocPrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_STARTDOCPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_StartDocPrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_StartPagePrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + WERROR *werror) +{ + struct spoolss_StartPagePrinter r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_StartPagePrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_STARTPAGEPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_StartPagePrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_WritePrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + DATA_BLOB data /* [in] */, + uint32_t _data_size /* [in] [value(r->in.data.length)] */, + uint32_t num_written /* [out] */, + WERROR *werror) +{ + struct spoolss_WritePrinter r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.data = data; + r.in._data_size = _data_size; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_WritePrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_WRITEPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_WritePrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_EndPagePrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + WERROR *werror) +{ + struct spoolss_EndPagePrinter r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EndPagePrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ENDPAGEPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EndPagePrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_AbortPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + WERROR *werror) +{ + struct spoolss_AbortPrinter r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AbortPrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ABORTPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AbortPrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_ReadPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t data_size /* [in] */, + DATA_BLOB data /* [out] */, + uint32_t _data_size /* [out] [value(r->out.data.length)] */, + WERROR *werror) +{ + struct spoolss_ReadPrinter r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.data_size = data_size; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ReadPrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_READPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ReadPrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_EndDocPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + WERROR *werror) +{ + struct spoolss_EndDocPrinter r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EndDocPrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ENDDOCPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EndDocPrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_AddJob(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_AddJob r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddJob, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ADDJOB, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddJob, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_ScheduleJob(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_ScheduleJob r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ScheduleJob, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_SCHEDULEJOB, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ScheduleJob, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_GetPrinterData(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *value_name /* [in] [charset(UTF16)] */, + uint32_t offered /* [in] */, + enum spoolss_PrinterDataType type /* [out] */, + union spoolss_PrinterData data /* [out] [subcontext_size(offered),subcontext(4),switch_is(type)] */, + uint32_t needed /* [out] */, + WERROR *werror) +{ + struct spoolss_GetPrinterData r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.value_name = value_name; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetPrinterData, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_GETPRINTERDATA, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetPrinterData, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +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] */, + 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) +{ + struct spoolss_SetPrinterData r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.value_name = value_name; + r.in.type = type; + r.in.data = data; + r.in._offered = _offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_SetPrinterData, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_SETPRINTERDATA, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_SetPrinterData, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_WaitForPrinterChange(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_WaitForPrinterChange r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_WaitForPrinterChange, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_WAITFORPRINTERCHANGE, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_WaitForPrinterChange, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_ClosePrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in,out] [ref] */, + WERROR *werror) +{ + struct spoolss_ClosePrinter r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ClosePrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_CLOSEPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ClosePrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + *handle = *r.out.handle; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_AddForm(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t level /* [in] */, + union spoolss_AddFormInfo info /* [in] [switch_is(level)] */, + WERROR *werror) +{ + struct spoolss_AddForm r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.level = level; + r.in.info = info; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddForm, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ADDFORM, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddForm, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_DeleteForm(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *form_name /* [in] [charset(UTF16)] */, + WERROR *werror) +{ + struct spoolss_DeleteForm r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.form_name = form_name; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeleteForm, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_DELETEFORM, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeleteForm, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_GetForm(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *form_name /* [in] [charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_FormInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */, + uint32_t needed /* [out] */, + WERROR *werror) +{ + struct spoolss_GetForm r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.form_name = form_name; + r.in.level = level; + r.in.buffer = buffer; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetForm, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_GETFORM, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetForm, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + if (info && r.out.info) { + *info = *r.out.info; + } + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_SetForm(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *form_name /* [in] [charset(UTF16)] */, + uint32_t level /* [in] */, + union spoolss_AddFormInfo info /* [in] [switch_is(level)] */, + WERROR *werror) +{ + struct spoolss_SetForm r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.form_name = form_name; + r.in.level = level; + r.in.info = info; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_SetForm, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_SETFORM, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_SetForm, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_EnumForms(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_FormInfo *info /* [out] [unique,switch_is(level),size_is(count)] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror) +{ + struct spoolss_EnumForms r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.level = level; + r.in.buffer = buffer; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumForms, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ENUMFORMS, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumForms, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + if (info && r.out.info) { + memcpy(info, r.out.info, count * sizeof(*info)); + } + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_EnumPorts(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_PortInfo *info /* [out] [unique,switch_is(level),size_is(count)] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror) +{ + struct spoolss_EnumPorts r; + NTSTATUS status; + + /* In parameters */ + r.in.servername = servername; + r.in.level = level; + r.in.buffer = buffer; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPorts, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ENUMPORTS, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPorts, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + if (info && r.out.info) { + memcpy(info, r.out.info, count * sizeof(*info)); + } + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_EnumMonitors(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_MonitorInfo *info /* [out] [unique,switch_is(level),size_is(count)] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror) +{ + struct spoolss_EnumMonitors r; + NTSTATUS status; + + /* In parameters */ + r.in.servername = servername; + r.in.level = level; + r.in.buffer = buffer; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumMonitors, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ENUMMONITORS, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumMonitors, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + if (info && r.out.info) { + memcpy(info, r.out.info, count * sizeof(*info)); + } + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_AddPort(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *server_name /* [in] [unique,charset(UTF16)] */, + uint32_t unknown /* [in] */, + const char *monitor_name /* [in] [charset(UTF16)] */, + WERROR *werror) +{ + struct spoolss_AddPort r; + NTSTATUS status; + + /* In parameters */ + r.in.server_name = server_name; + r.in.unknown = unknown; + r.in.monitor_name = monitor_name; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPort, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ADDPORT, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPort, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_ConfigurePort(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_ConfigurePort r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ConfigurePort, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_CONFIGUREPORT, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ConfigurePort, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_DeletePort(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_DeletePort r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePort, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_DELETEPORT, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePort, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_CreatePrinterIC(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_CreatePrinterIC r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_CreatePrinterIC, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_CREATEPRINTERIC, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_CreatePrinterIC, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_PlayGDIScriptOnPrinterIC(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_PlayGDIScriptOnPrinterIC r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_PlayGDIScriptOnPrinterIC, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_PLAYGDISCRIPTONPRINTERIC, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_PlayGDIScriptOnPrinterIC, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_DeletePrinterIC(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_DeletePrinterIC r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinterIC, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_DELETEPRINTERIC, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinterIC, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_AddPrinterConnection(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_AddPrinterConnection r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPrinterConnection, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ADDPRINTERCONNECTION, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPrinterConnection, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_DeletePrinterConnection(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_DeletePrinterConnection r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinterConnection, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_DELETEPRINTERCONNECTION, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinterConnection, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_PrinterMessageBox(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_PrinterMessageBox r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_PrinterMessageBox, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_PRINTERMESSAGEBOX, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_PrinterMessageBox, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_AddMonitor(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_AddMonitor r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddMonitor, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ADDMONITOR, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddMonitor, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_DeleteMonitor(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_DeleteMonitor r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeleteMonitor, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_DELETEMONITOR, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeleteMonitor, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_DeletePrintProcessor(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_DeletePrintProcessor r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrintProcessor, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_DELETEPRINTPROCESSOR, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrintProcessor, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_AddPrintProvidor(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_AddPrintProvidor r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPrintProvidor, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ADDPRINTPROVIDOR, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPrintProvidor, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_DeletePrintProvidor(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_DeletePrintProvidor r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrintProvidor, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_DELETEPRINTPROVIDOR, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrintProvidor, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_EnumPrintProcDataTypes(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_EnumPrintProcDataTypes r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPrintProcDataTypes, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ENUMPRINTPROCDATATYPES, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPrintProcDataTypes, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_ResetPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_ResetPrinter r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ResetPrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_RESETPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ResetPrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_GetPrinterDriver2(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *architecture /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + uint32_t client_major_version /* [in] */, + uint32_t client_minor_version /* [in] */, + DATA_BLOB *info /* [out] [unique] */, + uint32_t needed /* [out] */, + uint32_t server_major_version /* [out] */, + uint32_t server_minor_version /* [out] */, + WERROR *werror) +{ + struct spoolss_GetPrinterDriver2 r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.architecture = architecture; + r.in.level = level; + r.in.buffer = buffer; + r.in.offered = offered; + r.in.client_major_version = client_major_version; + r.in.client_minor_version = client_minor_version; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetPrinterDriver2, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_GETPRINTERDRIVER2, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetPrinterDriver2, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + if (info && r.out.info) { + *info = *r.out.info; + } + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_FindFirstPrinterChangeNotification(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_FindFirstPrinterChangeNotification r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_FindFirstPrinterChangeNotification, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_FINDFIRSTPRINTERCHANGENOTIFICATION, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_FindFirstPrinterChangeNotification, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_FindNextPrinterChangeNotification(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_FindNextPrinterChangeNotification r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_FindNextPrinterChangeNotification, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_FINDNEXTPRINTERCHANGENOTIFICATION, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_FindNextPrinterChangeNotification, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_FindClosePrinterNotify(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + WERROR *werror) +{ + struct spoolss_FindClosePrinterNotify r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_FindClosePrinterNotify, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_FINDCLOSEPRINTERNOTIFY, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_FindClosePrinterNotify, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_RouterFindFirstPrinterChangeNotificationOld(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_RouterFindFirstPrinterChangeNotificationOld r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_RouterFindFirstPrinterChangeNotificationOld, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ROUTERFINDFIRSTPRINTERCHANGENOTIFICATIONOLD, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_RouterFindFirstPrinterChangeNotificationOld, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_ReplyOpenPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *server_name /* [in] [charset(UTF16)] */, + uint32_t printer_local /* [in] */, + enum winreg_Type type /* [in] */, + uint32_t unknown1 /* [in] */, + uint32_t unknown2 /* [in] */, + struct policy_handle *handle /* [out] [ref] */, + WERROR *werror) +{ + struct spoolss_ReplyOpenPrinter r; + NTSTATUS status; + + /* In parameters */ + r.in.server_name = server_name; + r.in.printer_local = printer_local; + r.in.type = type; + r.in.unknown1 = unknown1; + r.in.unknown2 = unknown2; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ReplyOpenPrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_REPLYOPENPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ReplyOpenPrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + *handle = *r.out.handle; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_RouterReplyPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_RouterReplyPrinter r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_RouterReplyPrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ROUTERREPLYPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_RouterReplyPrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_ReplyClosePrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in,out] [ref] */, + WERROR *werror) +{ + struct spoolss_ReplyClosePrinter r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ReplyClosePrinter, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_REPLYCLOSEPRINTER, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ReplyClosePrinter, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + *handle = *r.out.handle; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_AddPortEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_AddPortEx r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPortEx, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ADDPORTEX, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPortEx, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_RouterFindFirstPrinterChangeNotification(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_RouterFindFirstPrinterChangeNotification r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_RouterFindFirstPrinterChangeNotification, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ROUTERFINDFIRSTPRINTERCHANGENOTIFICATION, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_RouterFindFirstPrinterChangeNotification, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_SpoolerInit(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_SpoolerInit r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_SpoolerInit, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_SPOOLERINIT, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_SpoolerInit, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_ResetPrinterEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_ResetPrinterEx r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ResetPrinterEx, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_RESETPRINTEREX, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ResetPrinterEx, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t flags /* [in] */, + uint32_t options /* [in] */, + const char *str /* [in] [unique,charset(UTF16)] */, + uint32_t printer_local /* [in] */, + struct spoolss_NotifyOptionsContainer *t1 /* [in] [unique] */, + WERROR *werror) +{ + struct spoolss_RemoteFindFirstPrinterChangeNotifyEx r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.flags = flags; + r.in.options = options; + r.in.str = str; + r.in.printer_local = printer_local; + r.in.t1 = t1; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_RemoteFindFirstPrinterChangeNotifyEx, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFYEX, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_RemoteFindFirstPrinterChangeNotifyEx, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_RouterRefreshPrinterChangeNotification(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_RouterRefreshPrinterChangeNotification r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_RouterRefreshPrinterChangeNotification, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ROUTERREFRESHPRINTERCHANGENOTIFICATION, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_RouterRefreshPrinterChangeNotification, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_RemoteFindNextPrinterChangeNotifyEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t change_low /* [in] */, + struct spoolss_NotifyOptionsContainer *container /* [in] [unique] */, + struct spoolss_NotifyInfo **info /* [out] [ref] */, + WERROR *werror) +{ + struct spoolss_RemoteFindNextPrinterChangeNotifyEx r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.change_low = change_low; + r.in.container = container; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_RemoteFindNextPrinterChangeNotifyEx, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_REMOTEFINDNEXTPRINTERCHANGENOTIFYEX, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_RemoteFindNextPrinterChangeNotifyEx, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + *info = *r.out.info; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_44(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_44 r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_44, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_44, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_44, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_OpenPrinterEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *printername /* [in] [unique,charset(UTF16)] */, + const char *datatype /* [in] [unique,charset(UTF16)] */, + struct spoolss_DevmodeContainer devmode_ctr /* [in] */, + uint32_t access_mask /* [in] */, + uint32_t level /* [in] */, + union spoolss_UserLevel userlevel /* [in] [switch_is(level)] */, + struct policy_handle *handle /* [out] [ref] */, + WERROR *werror) +{ + struct spoolss_OpenPrinterEx r; + NTSTATUS status; + + /* In parameters */ + r.in.printername = printername; + r.in.datatype = datatype; + r.in.devmode_ctr = devmode_ctr; + r.in.access_mask = access_mask; + r.in.level = level; + r.in.userlevel = userlevel; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_OpenPrinterEx, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_OPENPRINTEREX, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_OpenPrinterEx, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + *handle = *r.out.handle; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_AddPrinterEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *server /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + union spoolss_PrinterInfo *info /* [in] [unique,switch_is(level)] */, + struct spoolss_DevmodeContainer devmode_ctr /* [in] */, + struct security_descriptor *secdesc /* [in] [unique] */, + uint32_t ulevel /* [in] */, + union spoolss_UserLevel userlevel /* [in] [switch_is(ulevel)] */, + WERROR *werror) +{ + struct spoolss_AddPrinterEx r; + NTSTATUS status; + + /* In parameters */ + r.in.server = server; + r.in.level = level; + r.in.info = info; + r.in.devmode_ctr = devmode_ctr; + r.in.secdesc = secdesc; + r.in.ulevel = ulevel; + r.in.userlevel = userlevel; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPrinterEx, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ADDPRINTEREX, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPrinterEx, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_47(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_47 r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_47, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_47, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_47, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_EnumPrinterData(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t enum_index /* [in] */, + const char *value_name /* [out] [ref,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] */, + uint32_t data_offered /* [in] */, + uint32_t *data_needed /* [out] [ref] */, + WERROR *werror) +{ + struct spoolss_EnumPrinterData r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.enum_index = enum_index; + r.in.value_offered = value_offered; + r.in.data_offered = data_offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPrinterData, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ENUMPRINTERDATA, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPrinterData, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + memcpy(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; + *data_needed = *r.out.data_needed; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_DeletePrinterData(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *value_name /* [in] [charset(UTF16)] */, + WERROR *werror) +{ + struct spoolss_DeletePrinterData r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.value_name = value_name; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinterData, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_DELETEPRINTERDATA, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinterData, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_4a(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_4a r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_4a, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_4A, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_4a, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_4b(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_4b r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_4b, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_4B, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_4b, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_4c(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_4c r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_4c, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_4C, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_4c, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_SetPrinterDataEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *key_name /* [in] [charset(UTF16)] */, + const char *value_name /* [in] [charset(UTF16)] */, + uint32_t type /* [in] */, + DATA_BLOB buffer /* [in] */, + uint32_t offered /* [in] */, + WERROR *werror) +{ + struct spoolss_SetPrinterDataEx r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.key_name = key_name; + r.in.value_name = value_name; + r.in.type = type; + r.in.buffer = buffer; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_SetPrinterDataEx, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_SETPRINTERDATAEX, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_SetPrinterDataEx, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_GetPrinterDataEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *key_name /* [in] [charset(UTF16)] */, + const char *value_name /* [in] [charset(UTF16)] */, + uint32_t offered /* [in] */, + uint32_t type /* [out] */, + DATA_BLOB buffer /* [out] */, + uint32_t needed /* [out] */, + WERROR *werror) +{ + struct spoolss_GetPrinterDataEx r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.key_name = key_name; + r.in.value_name = value_name; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetPrinterDataEx, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_GETPRINTERDATAEX, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetPrinterDataEx, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +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)] */, + uint32_t offered /* [in] */, + DATA_BLOB buffer /* [out] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror) +{ + struct spoolss_EnumPrinterDataEx r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.key_name = key_name; + r.in.offered = offered; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPrinterDataEx, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ENUMPRINTERDATAEX, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPrinterDataEx, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +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)] */, + uint32_t key_buffer_size /* [out] */, + uint16_t *key_buffer /* [out] */, + uint32_t needed /* [in,out] */, + WERROR *werror) +{ + struct spoolss_EnumPrinterKey r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.key_name = key_name; + r.in.needed = needed; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPrinterKey, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ENUMPRINTERKEY, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPrinterKey, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + return NT_STATUS_NOT_SUPPORTED; + memcpy(key_buffer, r.out.key_buffer, key_buffer_size * sizeof(*key_buffer)); + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_DeletePrinterDataEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *key_name /* [in] [charset(UTF16)] */, + const char *value_name /* [in] [charset(UTF16)] */, + WERROR *werror) +{ + struct spoolss_DeletePrinterDataEx r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.key_name = key_name; + r.in.value_name = value_name; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinterDataEx, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_DELETEPRINTERDATAEX, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinterDataEx, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_DeletePrinterKey(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_DeletePrinterKey r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinterKey, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_DELETEPRINTERKEY, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinterKey, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_53(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_53 r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_53, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_53, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_53, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_DeletePrinterDriverEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_DeletePrinterDriverEx r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinterDriverEx, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_DELETEPRINTERDRIVEREX, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinterDriverEx, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_55(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_55 r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_55, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_55, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_55, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_56(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_56 r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_56, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_56, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_56, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_57(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_57 r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_57, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_57, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_57, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_XcvData(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *function_name /* [in] [charset(UTF16)] */, + DATA_BLOB in_data /* [in] */, + uint32_t _in_data_length /* [in] [value(r->in.in_data.length)] */, + uint32_t offered /* [in] */, + uint32_t unknown1 /* [in] */, + DATA_BLOB out_data /* [out] */, + uint32_t needed /* [out] */, + uint32_t unknown2 /* [out] */, + WERROR *werror) +{ + struct spoolss_XcvData r; + NTSTATUS status; + + /* In parameters */ + r.in.handle = handle; + r.in.function_name = function_name; + r.in.in_data = in_data; + r.in._in_data_length = _in_data_length; + r.in.offered = offered; + r.in.unknown1 = unknown1; + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_XcvData, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_XCVDATA, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_XcvData, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + return NT_STATUS_NOT_SUPPORTED; + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_AddPrinterDriverEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_AddPrinterDriverEx r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPrinterDriverEx, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_ADDPRINTERDRIVEREX, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPrinterDriverEx, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_5a(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_5a r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_5a, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_5A, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_5a, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_5b(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_5b r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_5b, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_5B, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_5b, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_5c(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_5c r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_5c, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_5C, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_5c, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_5d(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_5d r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_5d, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_5D, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_5d, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_5e(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_5e r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_5e, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_5E, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_5e, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + +NTSTATUS rpccli_spoolss_5f(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror) +{ + struct spoolss_5f r; + NTSTATUS status; + + /* In parameters */ + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_5f, &r); + } + + status = cli->dispatch(cli, + mem_ctx, + &ndr_table_spoolss, + NDR_SPOOLSS_5F, + &r); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_5f, &r); + } + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + /* Return variables */ + + /* Return result */ + if (werror) { + *werror = r.out.result; + } + + return werror_to_ntstatus(r.out.result); +} + diff --git a/librpc/gen_ndr/cli_spoolss.h b/librpc/gen_ndr/cli_spoolss.h new file mode 100644 index 0000000000..ba7de89413 --- /dev/null +++ b/librpc/gen_ndr/cli_spoolss.h @@ -0,0 +1,523 @@ +#include "../librpc/gen_ndr/ndr_spoolss.h" +#ifndef __CLI_SPOOLSS__ +#define __CLI_SPOOLSS__ +NTSTATUS rpccli_spoolss_EnumPrinters(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + uint32_t flags /* [in] */, + const char *server /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_PrinterInfo *info /* [out] [unique,switch_is(level),size_is(count)] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_OpenPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *printername /* [in] [unique,charset(UTF16)] */, + const char *datatype /* [in] [unique,charset(UTF16)] */, + struct spoolss_DevmodeContainer devmode_ctr /* [in] */, + uint32_t access_mask /* [in] */, + struct policy_handle *handle /* [out] [ref] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_SetJob(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t job_id /* [in] */, + struct spoolss_JobInfoContainer *ctr /* [in] [unique] */, + enum spoolss_JobControl command /* [in] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_GetJob(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t job_id /* [in] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_JobInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */, + uint32_t needed /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_EnumJobs(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t firstjob /* [in] */, + uint32_t numjobs /* [in] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_JobInfo *info /* [out] [unique,switch_is(level),size_is(count)] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_AddPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_DeletePrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_SetPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t level /* [in] */, + union spoolss_SetPrinterInfo info /* [in] [switch_is(level)] */, + struct spoolss_DevmodeContainer devmode_ctr /* [in] */, + struct sec_desc_buf secdesc_ctr /* [in] */, + enum spoolss_PrinterControl command /* [in] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_GetPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_PrinterInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */, + uint32_t needed /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_AddPrinterDriver(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_EnumPrinterDrivers(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *server /* [in] [unique,charset(UTF16)] */, + const char *environment /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_DriverInfo *info /* [out] [unique,switch_is(level),size_is(count)] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_GetPrinterDriver(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_GetPrinterDriverDirectory(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *server /* [in] [unique,charset(UTF16)] */, + const char *environment /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_DriverDirectoryInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */, + uint32_t needed /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_DeletePrinterDriver(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *server /* [in] [unique,charset(UTF16)] */, + const char *architecture /* [in] [charset(UTF16)] */, + const char *driver /* [in] [charset(UTF16)] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_AddPrintProcessor(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_EnumPrintProcessors(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername /* [in] [unique,charset(UTF16)] */, + const char *environment /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_PrintProcessorInfo *info /* [out] [unique,switch_is(level),size_is(count)] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_GetPrintProcessorDirectory(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_StartDocPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t level /* [in] */, + union spoolss_DocumentInfo info /* [in] [switch_is(level)] */, + uint32_t job_id /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_StartPagePrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_WritePrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + DATA_BLOB data /* [in] */, + uint32_t _data_size /* [in] [value(r->in.data.length)] */, + uint32_t num_written /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_EndPagePrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_AbortPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_ReadPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t data_size /* [in] */, + DATA_BLOB data /* [out] */, + uint32_t _data_size /* [out] [value(r->out.data.length)] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_EndDocPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_AddJob(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_ScheduleJob(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_GetPrinterData(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *value_name /* [in] [charset(UTF16)] */, + uint32_t offered /* [in] */, + enum spoolss_PrinterDataType type /* [out] */, + union spoolss_PrinterData data /* [out] [subcontext_size(offered),subcontext(4),switch_is(type)] */, + uint32_t needed /* [out] */, + 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] */, + 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); +NTSTATUS rpccli_spoolss_WaitForPrinterChange(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_ClosePrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in,out] [ref] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_AddForm(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t level /* [in] */, + union spoolss_AddFormInfo info /* [in] [switch_is(level)] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_DeleteForm(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *form_name /* [in] [charset(UTF16)] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_GetForm(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *form_name /* [in] [charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_FormInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */, + uint32_t needed /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_SetForm(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *form_name /* [in] [charset(UTF16)] */, + uint32_t level /* [in] */, + union spoolss_AddFormInfo info /* [in] [switch_is(level)] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_EnumForms(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_FormInfo *info /* [out] [unique,switch_is(level),size_is(count)] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_EnumPorts(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_PortInfo *info /* [out] [unique,switch_is(level),size_is(count)] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_EnumMonitors(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *servername /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + union spoolss_MonitorInfo *info /* [out] [unique,switch_is(level),size_is(count)] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_AddPort(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *server_name /* [in] [unique,charset(UTF16)] */, + uint32_t unknown /* [in] */, + const char *monitor_name /* [in] [charset(UTF16)] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_ConfigurePort(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_DeletePort(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_CreatePrinterIC(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_PlayGDIScriptOnPrinterIC(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_DeletePrinterIC(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_AddPrinterConnection(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_DeletePrinterConnection(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_PrinterMessageBox(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_AddMonitor(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_DeleteMonitor(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_DeletePrintProcessor(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_AddPrintProvidor(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_DeletePrintProvidor(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_EnumPrintProcDataTypes(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_ResetPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_GetPrinterDriver2(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *architecture /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + DATA_BLOB *buffer /* [in] [unique] */, + uint32_t offered /* [in] */, + uint32_t client_major_version /* [in] */, + uint32_t client_minor_version /* [in] */, + DATA_BLOB *info /* [out] [unique] */, + uint32_t needed /* [out] */, + uint32_t server_major_version /* [out] */, + uint32_t server_minor_version /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_FindFirstPrinterChangeNotification(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_FindNextPrinterChangeNotification(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_FindClosePrinterNotify(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_RouterFindFirstPrinterChangeNotificationOld(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_ReplyOpenPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *server_name /* [in] [charset(UTF16)] */, + uint32_t printer_local /* [in] */, + enum winreg_Type type /* [in] */, + uint32_t unknown1 /* [in] */, + uint32_t unknown2 /* [in] */, + struct policy_handle *handle /* [out] [ref] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_RouterReplyPrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_ReplyClosePrinter(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in,out] [ref] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_AddPortEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_RouterFindFirstPrinterChangeNotification(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_SpoolerInit(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_ResetPrinterEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t flags /* [in] */, + uint32_t options /* [in] */, + const char *str /* [in] [unique,charset(UTF16)] */, + uint32_t printer_local /* [in] */, + struct spoolss_NotifyOptionsContainer *t1 /* [in] [unique] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_RouterRefreshPrinterChangeNotification(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_RemoteFindNextPrinterChangeNotifyEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t change_low /* [in] */, + struct spoolss_NotifyOptionsContainer *container /* [in] [unique] */, + struct spoolss_NotifyInfo **info /* [out] [ref] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_44(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_OpenPrinterEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *printername /* [in] [unique,charset(UTF16)] */, + const char *datatype /* [in] [unique,charset(UTF16)] */, + struct spoolss_DevmodeContainer devmode_ctr /* [in] */, + uint32_t access_mask /* [in] */, + uint32_t level /* [in] */, + union spoolss_UserLevel userlevel /* [in] [switch_is(level)] */, + struct policy_handle *handle /* [out] [ref] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_AddPrinterEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *server /* [in] [unique,charset(UTF16)] */, + uint32_t level /* [in] */, + union spoolss_PrinterInfo *info /* [in] [unique,switch_is(level)] */, + struct spoolss_DevmodeContainer devmode_ctr /* [in] */, + struct security_descriptor *secdesc /* [in] [unique] */, + uint32_t ulevel /* [in] */, + union spoolss_UserLevel userlevel /* [in] [switch_is(ulevel)] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_47(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_EnumPrinterData(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + uint32_t enum_index /* [in] */, + const char *value_name /* [out] [ref,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] */, + uint32_t data_offered /* [in] */, + uint32_t *data_needed /* [out] [ref] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_DeletePrinterData(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *value_name /* [in] [charset(UTF16)] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_4a(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_4b(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_4c(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_SetPrinterDataEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *key_name /* [in] [charset(UTF16)] */, + const char *value_name /* [in] [charset(UTF16)] */, + uint32_t type /* [in] */, + DATA_BLOB buffer /* [in] */, + uint32_t offered /* [in] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_GetPrinterDataEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *key_name /* [in] [charset(UTF16)] */, + const char *value_name /* [in] [charset(UTF16)] */, + uint32_t offered /* [in] */, + uint32_t type /* [out] */, + DATA_BLOB buffer /* [out] */, + uint32_t needed /* [out] */, + WERROR *werror); +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)] */, + uint32_t offered /* [in] */, + DATA_BLOB buffer /* [out] */, + uint32_t needed /* [out] */, + uint32_t count /* [out] */, + 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)] */, + uint32_t key_buffer_size /* [out] */, + uint16_t *key_buffer /* [out] */, + uint32_t needed /* [in,out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_DeletePrinterDataEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *key_name /* [in] [charset(UTF16)] */, + const char *value_name /* [in] [charset(UTF16)] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_DeletePrinterKey(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_53(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_DeletePrinterDriverEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_55(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_56(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_57(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_XcvData(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle /* [in] [ref] */, + const char *function_name /* [in] [charset(UTF16)] */, + DATA_BLOB in_data /* [in] */, + uint32_t _in_data_length /* [in] [value(r->in.in_data.length)] */, + uint32_t offered /* [in] */, + uint32_t unknown1 /* [in] */, + DATA_BLOB out_data /* [out] */, + uint32_t needed /* [out] */, + uint32_t unknown2 /* [out] */, + WERROR *werror); +NTSTATUS rpccli_spoolss_AddPrinterDriverEx(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_5a(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_5b(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_5c(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_5d(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_5e(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +NTSTATUS rpccli_spoolss_5f(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + WERROR *werror); +#endif /* __CLI_SPOOLSS__ */ diff --git a/librpc/gen_ndr/ndr_spoolss.c b/librpc/gen_ndr/ndr_spoolss.c new file mode 100644 index 0000000000..a677f532db --- /dev/null +++ b/librpc/gen_ndr/ndr_spoolss.c @@ -0,0 +1,16993 @@ +/* parser auto-generated by pidl */ + +#include "includes.h" +#include "../librpc/gen_ndr/ndr_spoolss.h" + +#include "librpc/gen_ndr/ndr_misc.h" +#include "librpc/gen_ndr/ndr_security.h" +#include "librpc/gen_ndr/ndr_winreg.h" +static enum ndr_err_code ndr_push_spoolss_Time(struct ndr_push *ndr, int ndr_flags, const struct spoolss_Time *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 2)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->year)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->month)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->day_of_week)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->day)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->hour)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->minute)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->second)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->millisecond)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_Time(struct ndr_pull *ndr, int ndr_flags, struct spoolss_Time *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 2)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->year)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->month)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->day_of_week)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->day)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->hour)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->minute)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->second)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->millisecond)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_Time(struct ndr_print *ndr, const char *name, const struct spoolss_Time *r) +{ + ndr_print_struct(ndr, name, "spoolss_Time"); + ndr->depth++; + ndr_print_uint16(ndr, "year", r->year); + ndr_print_uint16(ndr, "month", r->month); + ndr_print_uint16(ndr, "day_of_week", r->day_of_week); + ndr_print_uint16(ndr, "day", r->day); + ndr_print_uint16(ndr, "hour", r->hour); + ndr_print_uint16(ndr, "minute", r->minute); + ndr_print_uint16(ndr, "second", r->second); + ndr_print_uint16(ndr, "millisecond", r->millisecond); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_PrinterInfo0(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo0 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->printername)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->servername)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->cjobs)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->total_jobs)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->total_bytes)); + NDR_CHECK(ndr_push_spoolss_Time(ndr, NDR_SCALARS, &r->time)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->global_counter)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->total_pages)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->version)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown10)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown11)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown12)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->session_counter)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown14)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->printer_errors)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown17)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown18)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown19)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->change_id)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown21)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->status)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown23)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->c_setprinter)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->unknown25)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->unknown26)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown27)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown28)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown29)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->printername) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->printername)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->printername)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->servername) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->servername)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->servername)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PrinterInfo0(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo0 *r) +{ + uint32_t _ptr_printername; + TALLOC_CTX *_mem_save_printername_0; + uint32_t _ptr_servername; + TALLOC_CTX *_mem_save_servername_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_printername)); + if (_ptr_printername) { + NDR_PULL_ALLOC(ndr, r->printername); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->printername, _ptr_printername)); + } else { + r->printername = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_servername)); + if (_ptr_servername) { + NDR_PULL_ALLOC(ndr, r->servername); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->servername, _ptr_servername)); + } else { + r->servername = NULL; + } + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->cjobs)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->total_jobs)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->total_bytes)); + NDR_CHECK(ndr_pull_spoolss_Time(ndr, NDR_SCALARS, &r->time)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->global_counter)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->total_pages)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->version)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown10)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown11)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown12)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->session_counter)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown14)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->printer_errors)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown16)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown17)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown18)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown19)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->change_id)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown21)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->status)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown23)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->c_setprinter)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->unknown25)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->unknown26)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown27)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown28)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown29)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->printername) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->printername)); + _mem_save_printername_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->printername, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->printername)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printername_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->servername) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->servername)); + _mem_save_servername_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->servername, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->servername)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_servername_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrinterInfo0(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo0 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrinterInfo0"); + ndr->depth++; + ndr_print_ptr(ndr, "printername", r->printername); + ndr->depth++; + if (r->printername) { + ndr_print_string(ndr, "printername", r->printername); + } + ndr->depth--; + ndr_print_ptr(ndr, "servername", r->servername); + ndr->depth++; + if (r->servername) { + ndr_print_string(ndr, "servername", r->servername); + } + ndr->depth--; + ndr_print_uint32(ndr, "cjobs", r->cjobs); + ndr_print_uint32(ndr, "total_jobs", r->total_jobs); + ndr_print_uint32(ndr, "total_bytes", r->total_bytes); + ndr_print_spoolss_Time(ndr, "time", &r->time); + ndr_print_uint32(ndr, "global_counter", r->global_counter); + ndr_print_uint32(ndr, "total_pages", r->total_pages); + ndr_print_uint32(ndr, "version", r->version); + ndr_print_uint32(ndr, "unknown10", r->unknown10); + ndr_print_uint32(ndr, "unknown11", r->unknown11); + ndr_print_uint32(ndr, "unknown12", r->unknown12); + ndr_print_uint32(ndr, "session_counter", r->session_counter); + ndr_print_uint32(ndr, "unknown14", r->unknown14); + ndr_print_uint32(ndr, "printer_errors", r->printer_errors); + ndr_print_uint32(ndr, "unknown16", r->unknown16); + ndr_print_uint32(ndr, "unknown17", r->unknown17); + ndr_print_uint32(ndr, "unknown18", r->unknown18); + ndr_print_uint32(ndr, "unknown19", r->unknown19); + ndr_print_uint32(ndr, "change_id", r->change_id); + ndr_print_uint32(ndr, "unknown21", r->unknown21); + ndr_print_uint32(ndr, "status", r->status); + ndr_print_uint32(ndr, "unknown23", r->unknown23); + ndr_print_uint32(ndr, "c_setprinter", r->c_setprinter); + ndr_print_uint16(ndr, "unknown25", r->unknown25); + ndr_print_uint16(ndr, "unknown26", r->unknown26); + ndr_print_uint32(ndr, "unknown27", r->unknown27); + ndr_print_uint32(ndr, "unknown28", r->unknown28); + ndr_print_uint32(ndr, "unknown29", r->unknown29); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DeviceMode(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DeviceMode *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->devicename, 32, sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->specversion)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->driverversion)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->size)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->driverextra_data.length)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->fields)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->orientation)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->papersize)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->paperlength)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->paperwidth)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->scale)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->copies)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->defaultsource)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->printquality)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->color)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->duplex)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->yresolution)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->ttoption)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->collate)); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->formname, 32, sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->logpixels)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->bitsperpel)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->pelswidth)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->pelsheight)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->displayflags)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->displayfrequency)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->icmmethod)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->icmintent)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->mediatype)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->dithertype)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->reserved1)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->reserved2)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->panningwidth)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->panningheight)); + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + { + struct ndr_push *_ndr_driverextra_data; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_driverextra_data, 0, r->driverextra_data.length)); + NDR_CHECK(ndr_push_DATA_BLOB(_ndr_driverextra_data, NDR_SCALARS, r->driverextra_data)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_driverextra_data, 0, r->driverextra_data.length)); + } + ndr->flags = _flags_save_DATA_BLOB; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DeviceMode(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DeviceMode *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->devicename, 32, sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->specversion)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->driverversion)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->__driverextra_length)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->fields)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->orientation)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->papersize)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->paperlength)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->paperwidth)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->scale)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->copies)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->defaultsource)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->printquality)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->color)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->duplex)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->yresolution)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->ttoption)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->collate)); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->formname, 32, sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->logpixels)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->bitsperpel)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->pelswidth)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->pelsheight)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->displayflags)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->displayfrequency)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->icmmethod)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->icmintent)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->mediatype)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->dithertype)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->reserved1)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->reserved2)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->panningwidth)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->panningheight)); + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + { + struct ndr_pull *_ndr_driverextra_data; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_driverextra_data, 0, r->__driverextra_length)); + NDR_CHECK(ndr_pull_DATA_BLOB(_ndr_driverextra_data, NDR_SCALARS, &r->driverextra_data)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_driverextra_data, 0, r->__driverextra_length)); + } + ndr->flags = _flags_save_DATA_BLOB; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeviceMode(struct ndr_print *ndr, const char *name, const struct spoolss_DeviceMode *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeviceMode"); + ndr->depth++; + ndr_print_string(ndr, "devicename", r->devicename); + ndr_print_uint16(ndr, "specversion", r->specversion); + ndr_print_uint16(ndr, "driverversion", r->driverversion); + ndr_print_uint16(ndr, "size", r->size); + ndr_print_uint16(ndr, "__driverextra_length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?r->driverextra_data.length:r->__driverextra_length); + ndr_print_uint32(ndr, "fields", r->fields); + ndr_print_uint16(ndr, "orientation", r->orientation); + ndr_print_uint16(ndr, "papersize", r->papersize); + ndr_print_uint16(ndr, "paperlength", r->paperlength); + ndr_print_uint16(ndr, "paperwidth", r->paperwidth); + ndr_print_uint16(ndr, "scale", r->scale); + ndr_print_uint16(ndr, "copies", r->copies); + ndr_print_uint16(ndr, "defaultsource", r->defaultsource); + ndr_print_uint16(ndr, "printquality", r->printquality); + ndr_print_uint16(ndr, "color", r->color); + ndr_print_uint16(ndr, "duplex", r->duplex); + ndr_print_uint16(ndr, "yresolution", r->yresolution); + ndr_print_uint16(ndr, "ttoption", r->ttoption); + ndr_print_uint16(ndr, "collate", r->collate); + ndr_print_string(ndr, "formname", r->formname); + ndr_print_uint16(ndr, "logpixels", r->logpixels); + ndr_print_uint32(ndr, "bitsperpel", r->bitsperpel); + ndr_print_uint32(ndr, "pelswidth", r->pelswidth); + ndr_print_uint32(ndr, "pelsheight", r->pelsheight); + ndr_print_uint32(ndr, "displayflags", r->displayflags); + ndr_print_uint32(ndr, "displayfrequency", r->displayfrequency); + ndr_print_uint32(ndr, "icmmethod", r->icmmethod); + ndr_print_uint32(ndr, "icmintent", r->icmintent); + ndr_print_uint32(ndr, "mediatype", r->mediatype); + ndr_print_uint32(ndr, "dithertype", r->dithertype); + ndr_print_uint32(ndr, "reserved1", r->reserved1); + ndr_print_uint32(ndr, "reserved2", r->reserved2); + ndr_print_uint32(ndr, "panningwidth", r->panningwidth); + ndr_print_uint32(ndr, "panningheight", r->panningheight); + ndr_print_DATA_BLOB(ndr, "driverextra_data", r->driverextra_data); + ndr->depth--; +} + +_PUBLIC_ size_t ndr_size_spoolss_DeviceMode(const struct spoolss_DeviceMode *r, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_DeviceMode, ic); +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_EnumPrinterFlags(struct ndr_push *ndr, int ndr_flags, uint32_t r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_EnumPrinterFlags(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_EnumPrinterFlags(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), "PRINTER_ENUM_DEFAULT", PRINTER_ENUM_DEFAULT, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_LOCAL", PRINTER_ENUM_LOCAL, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_CONNECTIONS", PRINTER_ENUM_CONNECTIONS, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_FAVORITE", PRINTER_ENUM_FAVORITE, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_NAME", PRINTER_ENUM_NAME, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_REMOTE", PRINTER_ENUM_REMOTE, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_SHARED", PRINTER_ENUM_SHARED, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_NETWORK", PRINTER_ENUM_NETWORK, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_EXPAND", PRINTER_ENUM_EXPAND, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_CONTAINER", PRINTER_ENUM_CONTAINER, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_ICON1", PRINTER_ENUM_ICON1, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_ICON2", PRINTER_ENUM_ICON2, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_ICON3", PRINTER_ENUM_ICON3, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_ICON4", PRINTER_ENUM_ICON4, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_ICON5", PRINTER_ENUM_ICON5, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_ICON6", PRINTER_ENUM_ICON6, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_ICON7", PRINTER_ENUM_ICON7, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_ICON8", PRINTER_ENUM_ICON8, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ENUM_HIDE", PRINTER_ENUM_HIDE, r); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_PrinterInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo1 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_spoolss_EnumPrinterFlags(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->name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->description)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->comment)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->description) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->description)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->description)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->comment) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->comment)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->comment)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PrinterInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo1 *r) +{ + uint32_t _ptr_name; + TALLOC_CTX *_mem_save_name_0; + uint32_t _ptr_description; + TALLOC_CTX *_mem_save_description_0; + uint32_t _ptr_comment; + TALLOC_CTX *_mem_save_comment_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_spoolss_EnumPrinterFlags(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_name)); + if (_ptr_name) { + NDR_PULL_ALLOC(ndr, r->name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->name, _ptr_name)); + } else { + r->name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_description)); + if (_ptr_description) { + NDR_PULL_ALLOC(ndr, r->description); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->description, _ptr_description)); + } else { + r->description = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_comment)); + if (_ptr_comment) { + NDR_PULL_ALLOC(ndr, r->comment); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->comment, _ptr_comment)); + } else { + r->comment = NULL; + } + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->name)); + _mem_save_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_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->description) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->description)); + _mem_save_description_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->description, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->description)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_description_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->comment) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->comment)); + _mem_save_comment_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->comment, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->comment)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_comment_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrinterInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo1 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrinterInfo1"); + ndr->depth++; + ndr_print_spoolss_EnumPrinterFlags(ndr, "flags", r->flags); + ndr_print_ptr(ndr, "name", r->name); + ndr->depth++; + if (r->name) { + ndr_print_string(ndr, "name", r->name); + } + ndr->depth--; + ndr_print_ptr(ndr, "description", r->description); + ndr->depth++; + if (r->description) { + ndr_print_string(ndr, "description", r->description); + } + ndr->depth--; + ndr_print_ptr(ndr, "comment", r->comment); + ndr->depth++; + if (r->comment) { + ndr_print_string(ndr, "comment", r->comment); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_PrinterAttributes(struct ndr_push *ndr, int ndr_flags, uint32_t r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PrinterAttributes(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_PrinterAttributes(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), "PRINTER_ATTRIBUTE_QUEUED", PRINTER_ATTRIBUTE_QUEUED, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_DIRECT", PRINTER_ATTRIBUTE_DIRECT, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_DEFAULT", PRINTER_ATTRIBUTE_DEFAULT, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_SHARED", PRINTER_ATTRIBUTE_SHARED, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_NETWORK", PRINTER_ATTRIBUTE_NETWORK, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_HIDDEN", PRINTER_ATTRIBUTE_HIDDEN, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_LOCAL", PRINTER_ATTRIBUTE_LOCAL, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_ENABLE_DEVQ", PRINTER_ATTRIBUTE_ENABLE_DEVQ, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS", PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST", PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_WORK_OFFLINE", PRINTER_ATTRIBUTE_WORK_OFFLINE, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_ENABLE_BIDI", PRINTER_ATTRIBUTE_ENABLE_BIDI, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_RAW_ONLY", PRINTER_ATTRIBUTE_RAW_ONLY, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_PUBLISHED", PRINTER_ATTRIBUTE_PUBLISHED, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_FAX", PRINTER_ATTRIBUTE_FAX, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ATTRIBUTE_TS", PRINTER_ATTRIBUTE_TS, r); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_PrinterStatus(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_PrinterStatus(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_PrinterStatus(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), "PRINTER_STATUS_PAUSED", PRINTER_STATUS_PAUSED, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_ERROR", PRINTER_STATUS_ERROR, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PENDING_DELETION", PRINTER_STATUS_PENDING_DELETION, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PAPER_JAM", PRINTER_STATUS_PAPER_JAM, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PAPER_OUT", PRINTER_STATUS_PAPER_OUT, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_MANUAL_FEED", PRINTER_STATUS_MANUAL_FEED, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PAPER_PROBLEM", PRINTER_STATUS_PAPER_PROBLEM, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_OFFLINE", PRINTER_STATUS_OFFLINE, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_IO_ACTIVE", PRINTER_STATUS_IO_ACTIVE, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_BUSY", PRINTER_STATUS_BUSY, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PRINTING", PRINTER_STATUS_PRINTING, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_OUTPUT_BIN_FULL", PRINTER_STATUS_OUTPUT_BIN_FULL, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_NOT_AVAILABLE", PRINTER_STATUS_NOT_AVAILABLE, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_WAITING", PRINTER_STATUS_WAITING, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PROCESSING", PRINTER_STATUS_PROCESSING, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_INITIALIZING", PRINTER_STATUS_INITIALIZING, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_WARMING_UP", PRINTER_STATUS_WARMING_UP, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_TONER_LOW", PRINTER_STATUS_TONER_LOW, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_NO_TONER", PRINTER_STATUS_NO_TONER, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PAGE_PUNT", PRINTER_STATUS_PAGE_PUNT, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_USER_INTERVENTION", PRINTER_STATUS_USER_INTERVENTION, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_OUT_OF_MEMORY", PRINTER_STATUS_OUT_OF_MEMORY, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_DOOR_OPEN", PRINTER_STATUS_DOOR_OPEN, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_SERVER_UNKNOWN", PRINTER_STATUS_SERVER_UNKNOWN, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_POWER_SAVE", PRINTER_STATUS_POWER_SAVE, r); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_PrinterInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo2 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->servername)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->printername)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->sharename)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->portname)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->drivername)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->comment)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->location)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->devmode)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->sepfile)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->printprocessor)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->datatype)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->parameters)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->secdesc)); + NDR_CHECK(ndr_push_spoolss_PrinterAttributes(ndr, NDR_SCALARS, r->attributes)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->priority)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->defaultpriority)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->starttime)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->untiltime)); + NDR_CHECK(ndr_push_spoolss_PrinterStatus(ndr, NDR_SCALARS, r->status)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->cjobs)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->averageppm)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->servername) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->servername)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->servername)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->printername) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->printername)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->printername)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->sharename) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->sharename)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->sharename)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->portname) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->portname)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->portname)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->drivername) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->drivername)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->drivername)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->comment) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->comment)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->comment)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->location) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->location)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->location)); + } + ndr->flags = _flags_save_string; + } + if (r->devmode) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->devmode)); + { + struct ndr_push *_ndr_devmode; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_devmode, 0, -1)); + NDR_CHECK(ndr_push_spoolss_DeviceMode(_ndr_devmode, NDR_SCALARS, r->devmode)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_devmode, 0, -1)); + } + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->sepfile) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->sepfile)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->sepfile)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->printprocessor) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->printprocessor)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->printprocessor)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->datatype) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->datatype)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->datatype)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->parameters) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->parameters)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->parameters)); + } + ndr->flags = _flags_save_string; + } + if (r->secdesc) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->secdesc)); + { + struct ndr_push *_ndr_secdesc; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_secdesc, 0, -1)); + NDR_CHECK(ndr_push_security_descriptor(_ndr_secdesc, NDR_SCALARS|NDR_BUFFERS, r->secdesc)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_secdesc, 0, -1)); + } + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PrinterInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo2 *r) +{ + uint32_t _ptr_servername; + TALLOC_CTX *_mem_save_servername_0; + uint32_t _ptr_printername; + TALLOC_CTX *_mem_save_printername_0; + uint32_t _ptr_sharename; + TALLOC_CTX *_mem_save_sharename_0; + uint32_t _ptr_portname; + TALLOC_CTX *_mem_save_portname_0; + uint32_t _ptr_drivername; + TALLOC_CTX *_mem_save_drivername_0; + uint32_t _ptr_comment; + TALLOC_CTX *_mem_save_comment_0; + uint32_t _ptr_location; + TALLOC_CTX *_mem_save_location_0; + uint32_t _ptr_devmode; + TALLOC_CTX *_mem_save_devmode_0; + uint32_t _ptr_sepfile; + TALLOC_CTX *_mem_save_sepfile_0; + uint32_t _ptr_printprocessor; + TALLOC_CTX *_mem_save_printprocessor_0; + uint32_t _ptr_datatype; + TALLOC_CTX *_mem_save_datatype_0; + uint32_t _ptr_parameters; + TALLOC_CTX *_mem_save_parameters_0; + uint32_t _ptr_secdesc; + TALLOC_CTX *_mem_save_secdesc_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_servername)); + if (_ptr_servername) { + NDR_PULL_ALLOC(ndr, r->servername); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->servername, _ptr_servername)); + } else { + r->servername = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_printername)); + if (_ptr_printername) { + NDR_PULL_ALLOC(ndr, r->printername); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->printername, _ptr_printername)); + } else { + r->printername = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_sharename)); + if (_ptr_sharename) { + NDR_PULL_ALLOC(ndr, r->sharename); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->sharename, _ptr_sharename)); + } else { + r->sharename = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_portname)); + if (_ptr_portname) { + NDR_PULL_ALLOC(ndr, r->portname); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->portname, _ptr_portname)); + } else { + r->portname = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_drivername)); + if (_ptr_drivername) { + NDR_PULL_ALLOC(ndr, r->drivername); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->drivername, _ptr_drivername)); + } else { + r->drivername = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_comment)); + if (_ptr_comment) { + NDR_PULL_ALLOC(ndr, r->comment); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->comment, _ptr_comment)); + } else { + r->comment = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_location)); + if (_ptr_location) { + NDR_PULL_ALLOC(ndr, r->location); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->location, _ptr_location)); + } else { + r->location = NULL; + } + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_devmode)); + if (_ptr_devmode) { + NDR_PULL_ALLOC(ndr, r->devmode); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->devmode, _ptr_devmode)); + } else { + r->devmode = NULL; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_sepfile)); + if (_ptr_sepfile) { + NDR_PULL_ALLOC(ndr, r->sepfile); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->sepfile, _ptr_sepfile)); + } else { + r->sepfile = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_printprocessor)); + if (_ptr_printprocessor) { + NDR_PULL_ALLOC(ndr, r->printprocessor); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->printprocessor, _ptr_printprocessor)); + } else { + r->printprocessor = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_datatype)); + if (_ptr_datatype) { + NDR_PULL_ALLOC(ndr, r->datatype); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->datatype, _ptr_datatype)); + } else { + r->datatype = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_parameters)); + if (_ptr_parameters) { + NDR_PULL_ALLOC(ndr, r->parameters); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->parameters, _ptr_parameters)); + } else { + r->parameters = NULL; + } + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_secdesc)); + if (_ptr_secdesc) { + NDR_PULL_ALLOC(ndr, r->secdesc); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->secdesc, _ptr_secdesc)); + } else { + r->secdesc = NULL; + } + NDR_CHECK(ndr_pull_spoolss_PrinterAttributes(ndr, NDR_SCALARS, &r->attributes)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->priority)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->defaultpriority)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->starttime)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->untiltime)); + NDR_CHECK(ndr_pull_spoolss_PrinterStatus(ndr, NDR_SCALARS, &r->status)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->cjobs)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->averageppm)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->servername) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->servername)); + _mem_save_servername_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->servername, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->servername)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_servername_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->printername) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->printername)); + _mem_save_printername_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->printername, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->printername)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printername_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->sharename) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->sharename)); + _mem_save_sharename_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->sharename, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->sharename)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sharename_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->portname) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->portname)); + _mem_save_portname_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->portname, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->portname)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_portname_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->drivername) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->drivername)); + _mem_save_drivername_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->drivername, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->drivername)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_drivername_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->comment) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->comment)); + _mem_save_comment_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->comment, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->comment)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_comment_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->location) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->location)); + _mem_save_location_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->location, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->location)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_location_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + if (r->devmode) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->devmode)); + _mem_save_devmode_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->devmode, 0); + { + struct ndr_pull *_ndr_devmode; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_devmode, 0, -1)); + NDR_CHECK(ndr_pull_spoolss_DeviceMode(_ndr_devmode, NDR_SCALARS, r->devmode)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_devmode, 0, -1)); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_devmode_0, 0); + ndr->offset = _relative_save_offset; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->sepfile) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->sepfile)); + _mem_save_sepfile_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->sepfile, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->sepfile)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_sepfile_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->printprocessor) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->printprocessor)); + _mem_save_printprocessor_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->printprocessor, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->printprocessor)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printprocessor_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->datatype) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->datatype)); + _mem_save_datatype_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->datatype, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->datatype)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_datatype_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->parameters) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->parameters)); + _mem_save_parameters_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->parameters, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->parameters)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_parameters_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + if (r->secdesc) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->secdesc)); + _mem_save_secdesc_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->secdesc, 0); + { + struct ndr_pull *_ndr_secdesc; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_secdesc, 0, -1)); + NDR_CHECK(ndr_pull_security_descriptor(_ndr_secdesc, NDR_SCALARS|NDR_BUFFERS, r->secdesc)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_secdesc, 0, -1)); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_secdesc_0, 0); + ndr->offset = _relative_save_offset; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrinterInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo2 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrinterInfo2"); + ndr->depth++; + ndr_print_ptr(ndr, "servername", r->servername); + ndr->depth++; + if (r->servername) { + ndr_print_string(ndr, "servername", r->servername); + } + ndr->depth--; + ndr_print_ptr(ndr, "printername", r->printername); + ndr->depth++; + if (r->printername) { + ndr_print_string(ndr, "printername", r->printername); + } + ndr->depth--; + ndr_print_ptr(ndr, "sharename", r->sharename); + ndr->depth++; + if (r->sharename) { + ndr_print_string(ndr, "sharename", r->sharename); + } + ndr->depth--; + ndr_print_ptr(ndr, "portname", r->portname); + ndr->depth++; + if (r->portname) { + ndr_print_string(ndr, "portname", r->portname); + } + ndr->depth--; + ndr_print_ptr(ndr, "drivername", r->drivername); + ndr->depth++; + if (r->drivername) { + ndr_print_string(ndr, "drivername", r->drivername); + } + ndr->depth--; + ndr_print_ptr(ndr, "comment", r->comment); + ndr->depth++; + if (r->comment) { + ndr_print_string(ndr, "comment", r->comment); + } + ndr->depth--; + ndr_print_ptr(ndr, "location", r->location); + ndr->depth++; + if (r->location) { + ndr_print_string(ndr, "location", r->location); + } + ndr->depth--; + ndr_print_ptr(ndr, "devmode", r->devmode); + ndr->depth++; + if (r->devmode) { + ndr_print_spoolss_DeviceMode(ndr, "devmode", r->devmode); + } + ndr->depth--; + ndr_print_ptr(ndr, "sepfile", r->sepfile); + ndr->depth++; + if (r->sepfile) { + ndr_print_string(ndr, "sepfile", r->sepfile); + } + ndr->depth--; + ndr_print_ptr(ndr, "printprocessor", r->printprocessor); + ndr->depth++; + if (r->printprocessor) { + ndr_print_string(ndr, "printprocessor", r->printprocessor); + } + ndr->depth--; + ndr_print_ptr(ndr, "datatype", r->datatype); + ndr->depth++; + if (r->datatype) { + ndr_print_string(ndr, "datatype", r->datatype); + } + ndr->depth--; + ndr_print_ptr(ndr, "parameters", r->parameters); + ndr->depth++; + if (r->parameters) { + ndr_print_string(ndr, "parameters", r->parameters); + } + ndr->depth--; + ndr_print_ptr(ndr, "secdesc", r->secdesc); + ndr->depth++; + if (r->secdesc) { + ndr_print_security_descriptor(ndr, "secdesc", r->secdesc); + } + ndr->depth--; + ndr_print_spoolss_PrinterAttributes(ndr, "attributes", r->attributes); + ndr_print_uint32(ndr, "priority", r->priority); + ndr_print_uint32(ndr, "defaultpriority", r->defaultpriority); + ndr_print_uint32(ndr, "starttime", r->starttime); + ndr_print_uint32(ndr, "untiltime", r->untiltime); + ndr_print_spoolss_PrinterStatus(ndr, "status", r->status); + ndr_print_uint32(ndr, "cjobs", r->cjobs); + ndr_print_uint32(ndr, "averageppm", r->averageppm); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_PrinterInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo3 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->secdesc)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->secdesc) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->secdesc)); + { + struct ndr_push *_ndr_secdesc; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_secdesc, 0, -1)); + NDR_CHECK(ndr_push_security_descriptor(_ndr_secdesc, NDR_SCALARS|NDR_BUFFERS, r->secdesc)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_secdesc, 0, -1)); + } + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PrinterInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo3 *r) +{ + uint32_t _ptr_secdesc; + TALLOC_CTX *_mem_save_secdesc_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_secdesc)); + if (_ptr_secdesc) { + NDR_PULL_ALLOC(ndr, r->secdesc); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->secdesc, _ptr_secdesc)); + } else { + r->secdesc = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->secdesc) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->secdesc)); + _mem_save_secdesc_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->secdesc, 0); + { + struct ndr_pull *_ndr_secdesc; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_secdesc, 0, -1)); + NDR_CHECK(ndr_pull_security_descriptor(_ndr_secdesc, NDR_SCALARS|NDR_BUFFERS, r->secdesc)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_secdesc, 0, -1)); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_secdesc_0, 0); + ndr->offset = _relative_save_offset; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrinterInfo3(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo3 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrinterInfo3"); + ndr->depth++; + ndr_print_ptr(ndr, "secdesc", r->secdesc); + ndr->depth++; + if (r->secdesc) { + ndr_print_security_descriptor(ndr, "secdesc", r->secdesc); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_PrinterInfo4(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo4 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->printername)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->servername)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_spoolss_PrinterAttributes(ndr, NDR_SCALARS, r->attributes)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->printername) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->printername)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->printername)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->servername) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->servername)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->servername)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PrinterInfo4(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo4 *r) +{ + uint32_t _ptr_printername; + TALLOC_CTX *_mem_save_printername_0; + uint32_t _ptr_servername; + TALLOC_CTX *_mem_save_servername_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_printername)); + if (_ptr_printername) { + NDR_PULL_ALLOC(ndr, r->printername); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->printername, _ptr_printername)); + } else { + r->printername = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_servername)); + if (_ptr_servername) { + NDR_PULL_ALLOC(ndr, r->servername); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->servername, _ptr_servername)); + } else { + r->servername = NULL; + } + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_spoolss_PrinterAttributes(ndr, NDR_SCALARS, &r->attributes)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->printername) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->printername)); + _mem_save_printername_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->printername, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->printername)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printername_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->servername) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->servername)); + _mem_save_servername_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->servername, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->servername)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_servername_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrinterInfo4(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo4 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrinterInfo4"); + ndr->depth++; + ndr_print_ptr(ndr, "printername", r->printername); + ndr->depth++; + if (r->printername) { + ndr_print_string(ndr, "printername", r->printername); + } + ndr->depth--; + ndr_print_ptr(ndr, "servername", r->servername); + ndr->depth++; + if (r->servername) { + ndr_print_string(ndr, "servername", r->servername); + } + ndr->depth--; + ndr_print_spoolss_PrinterAttributes(ndr, "attributes", r->attributes); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_PrinterInfo5(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo5 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->printername)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->portname)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_spoolss_PrinterAttributes(ndr, NDR_SCALARS, r->attributes)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->device_not_selected_timeout)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->transmission_retry_timeout)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->printername) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->printername)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->printername)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->portname) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->portname)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->portname)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PrinterInfo5(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo5 *r) +{ + uint32_t _ptr_printername; + TALLOC_CTX *_mem_save_printername_0; + uint32_t _ptr_portname; + TALLOC_CTX *_mem_save_portname_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_printername)); + if (_ptr_printername) { + NDR_PULL_ALLOC(ndr, r->printername); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->printername, _ptr_printername)); + } else { + r->printername = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_portname)); + if (_ptr_portname) { + NDR_PULL_ALLOC(ndr, r->portname); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->portname, _ptr_portname)); + } else { + r->portname = NULL; + } + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_spoolss_PrinterAttributes(ndr, NDR_SCALARS, &r->attributes)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->device_not_selected_timeout)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->transmission_retry_timeout)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->printername) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->printername)); + _mem_save_printername_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->printername, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->printername)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printername_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->portname) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->portname)); + _mem_save_portname_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->portname, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->portname)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_portname_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrinterInfo5(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo5 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrinterInfo5"); + ndr->depth++; + ndr_print_ptr(ndr, "printername", r->printername); + ndr->depth++; + if (r->printername) { + ndr_print_string(ndr, "printername", r->printername); + } + ndr->depth--; + ndr_print_ptr(ndr, "portname", r->portname); + ndr->depth++; + if (r->portname) { + ndr_print_string(ndr, "portname", r->portname); + } + ndr->depth--; + ndr_print_spoolss_PrinterAttributes(ndr, "attributes", r->attributes); + ndr_print_uint32(ndr, "device_not_selected_timeout", r->device_not_selected_timeout); + ndr_print_uint32(ndr, "transmission_retry_timeout", r->transmission_retry_timeout); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_PrinterInfo6(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo6 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_spoolss_PrinterStatus(ndr, NDR_SCALARS, r->status)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PrinterInfo6(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo6 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_spoolss_PrinterStatus(ndr, NDR_SCALARS, &r->status)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrinterInfo6(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo6 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrinterInfo6"); + ndr->depth++; + ndr_print_spoolss_PrinterStatus(ndr, "status", r->status); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DsPrintAction(struct ndr_push *ndr, int ndr_flags, uint32_t r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DsPrintAction(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_DsPrintAction(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), "DSPRINT_PUBLISH", DSPRINT_PUBLISH, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "DSPRINT_UPDATE", DSPRINT_UPDATE, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "DSPRINT_UNPUBLISH", DSPRINT_UNPUBLISH, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "DSPRINT_REPUBLISH", DSPRINT_REPUBLISH, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "DSPRINT_PENDING", DSPRINT_PENDING, r); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_PrinterInfo7(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo7 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->guid)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_spoolss_DsPrintAction(ndr, NDR_SCALARS, r->action)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->guid) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->guid)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->guid)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PrinterInfo7(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterInfo7 *r) +{ + uint32_t _ptr_guid; + TALLOC_CTX *_mem_save_guid_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_guid)); + if (_ptr_guid) { + NDR_PULL_ALLOC(ndr, r->guid); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->guid, _ptr_guid)); + } else { + r->guid = NULL; + } + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_spoolss_DsPrintAction(ndr, NDR_SCALARS, &r->action)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->guid) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->guid)); + _mem_save_guid_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->guid, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->guid)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_guid_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrinterInfo7(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo7 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrinterInfo7"); + ndr->depth++; + ndr_print_ptr(ndr, "guid", r->guid); + ndr->depth++; + if (r->guid) { + ndr_print_string(ndr, "guid", r->guid); + } + ndr->depth--; + ndr_print_spoolss_DsPrintAction(ndr, "action", r->action); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DeviceModeInfo(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DeviceModeInfo *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->devmode)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->devmode) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->devmode)); + { + struct ndr_push *_ndr_devmode; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_devmode, 0, -1)); + NDR_CHECK(ndr_push_spoolss_DeviceMode(_ndr_devmode, NDR_SCALARS, r->devmode)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_devmode, 0, -1)); + } + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DeviceModeInfo(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DeviceModeInfo *r) +{ + uint32_t _ptr_devmode; + TALLOC_CTX *_mem_save_devmode_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_devmode)); + if (_ptr_devmode) { + NDR_PULL_ALLOC(ndr, r->devmode); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->devmode, _ptr_devmode)); + } else { + r->devmode = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->devmode) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->devmode)); + _mem_save_devmode_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->devmode, 0); + { + struct ndr_pull *_ndr_devmode; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_devmode, 0, -1)); + NDR_CHECK(ndr_pull_spoolss_DeviceMode(_ndr_devmode, NDR_SCALARS, r->devmode)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_devmode, 0, -1)); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_devmode_0, 0); + ndr->offset = _relative_save_offset; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeviceModeInfo(struct ndr_print *ndr, const char *name, const struct spoolss_DeviceModeInfo *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeviceModeInfo"); + ndr->depth++; + ndr_print_ptr(ndr, "devmode", r->devmode); + ndr->depth++; + if (r->devmode) { + ndr_print_spoolss_DeviceMode(ndr, "devmode", r->devmode); + } + ndr->depth--; + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrinterInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_PrinterInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr); + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 0: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_PrinterInfo0(ndr, NDR_SCALARS, &r->info0)); + break; } + + case 1: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_PrinterInfo1(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_PrinterInfo2(ndr, NDR_SCALARS, &r->info2)); + break; } + + case 3: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_PrinterInfo3(ndr, NDR_SCALARS, &r->info3)); + break; } + + case 4: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_PrinterInfo4(ndr, NDR_SCALARS, &r->info4)); + break; } + + case 5: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_PrinterInfo5(ndr, NDR_SCALARS, &r->info5)); + break; } + + case 6: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_PrinterInfo6(ndr, NDR_SCALARS, &r->info6)); + break; } + + case 7: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_PrinterInfo7(ndr, NDR_SCALARS, &r->info7)); + break; } + + case 8: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_DeviceModeInfo(ndr, NDR_SCALARS, &r->info8)); + break; } + + case 9: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_DeviceModeInfo(ndr, NDR_SCALARS, &r->info9)); + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 0: + NDR_CHECK(ndr_push_spoolss_PrinterInfo0(ndr, NDR_BUFFERS, &r->info0)); + break; + + case 1: + NDR_CHECK(ndr_push_spoolss_PrinterInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + case 2: + NDR_CHECK(ndr_push_spoolss_PrinterInfo2(ndr, NDR_BUFFERS, &r->info2)); + break; + + case 3: + NDR_CHECK(ndr_push_spoolss_PrinterInfo3(ndr, NDR_BUFFERS, &r->info3)); + break; + + case 4: + NDR_CHECK(ndr_push_spoolss_PrinterInfo4(ndr, NDR_BUFFERS, &r->info4)); + break; + + case 5: + NDR_CHECK(ndr_push_spoolss_PrinterInfo5(ndr, NDR_BUFFERS, &r->info5)); + break; + + case 6: + break; + + case 7: + NDR_CHECK(ndr_push_spoolss_PrinterInfo7(ndr, NDR_BUFFERS, &r->info7)); + break; + + case 8: + NDR_CHECK(ndr_push_spoolss_DeviceModeInfo(ndr, NDR_BUFFERS, &r->info8)); + break; + + case 9: + NDR_CHECK(ndr_push_spoolss_DeviceModeInfo(ndr, NDR_BUFFERS, &r->info9)); + break; + + default: + break; + + } + } + ndr_push_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrinterInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_PrinterInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset(ndr); + int level; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + switch (level) { + case 0: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo0(ndr, NDR_SCALARS, &r->info0)); + break; } + + case 1: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo1(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_PrinterInfo2(ndr, NDR_SCALARS, &r->info2)); + break; } + + case 3: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo3(ndr, NDR_SCALARS, &r->info3)); + break; } + + case 4: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo4(ndr, NDR_SCALARS, &r->info4)); + break; } + + case 5: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo5(ndr, NDR_SCALARS, &r->info5)); + break; } + + case 6: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo6(ndr, NDR_SCALARS, &r->info6)); + break; } + + case 7: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo7(ndr, NDR_SCALARS, &r->info7)); + break; } + + case 8: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_DeviceModeInfo(ndr, NDR_SCALARS, &r->info8)); + break; } + + case 9: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_DeviceModeInfo(ndr, NDR_SCALARS, &r->info9)); + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 0: + NDR_CHECK(ndr_pull_spoolss_PrinterInfo0(ndr, NDR_BUFFERS, &r->info0)); + break; + + case 1: + NDR_CHECK(ndr_pull_spoolss_PrinterInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + case 2: + NDR_CHECK(ndr_pull_spoolss_PrinterInfo2(ndr, NDR_BUFFERS, &r->info2)); + break; + + case 3: + NDR_CHECK(ndr_pull_spoolss_PrinterInfo3(ndr, NDR_BUFFERS, &r->info3)); + break; + + case 4: + NDR_CHECK(ndr_pull_spoolss_PrinterInfo4(ndr, NDR_BUFFERS, &r->info4)); + break; + + case 5: + NDR_CHECK(ndr_pull_spoolss_PrinterInfo5(ndr, NDR_BUFFERS, &r->info5)); + break; + + case 6: + break; + + case 7: + NDR_CHECK(ndr_pull_spoolss_PrinterInfo7(ndr, NDR_BUFFERS, &r->info7)); + break; + + case 8: + NDR_CHECK(ndr_pull_spoolss_DeviceModeInfo(ndr, NDR_BUFFERS, &r->info8)); + break; + + case 9: + NDR_CHECK(ndr_pull_spoolss_DeviceModeInfo(ndr, NDR_BUFFERS, &r->info9)); + break; + + default: + break; + + } + } + ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrinterInfo(struct ndr_print *ndr, const char *name, const union spoolss_PrinterInfo *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_PrinterInfo"); + switch (level) { + case 0: + ndr_print_spoolss_PrinterInfo0(ndr, "info0", &r->info0); + break; + + case 1: + ndr_print_spoolss_PrinterInfo1(ndr, "info1", &r->info1); + break; + + case 2: + ndr_print_spoolss_PrinterInfo2(ndr, "info2", &r->info2); + break; + + case 3: + ndr_print_spoolss_PrinterInfo3(ndr, "info3", &r->info3); + break; + + case 4: + ndr_print_spoolss_PrinterInfo4(ndr, "info4", &r->info4); + break; + + case 5: + ndr_print_spoolss_PrinterInfo5(ndr, "info5", &r->info5); + break; + + case 6: + ndr_print_spoolss_PrinterInfo6(ndr, "info6", &r->info6); + break; + + case 7: + ndr_print_spoolss_PrinterInfo7(ndr, "info7", &r->info7); + break; + + case 8: + ndr_print_spoolss_DeviceModeInfo(ndr, "info8", &r->info8); + break; + + case 9: + ndr_print_spoolss_DeviceModeInfo(ndr, "info9", &r->info9); + break; + + default: + break; + + } +} + +static enum ndr_err_code ndr_push_spoolss_DevmodeContainer(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DevmodeContainer *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, _ndr_size_spoolss_DeviceMode(r->devmode, ndr->iconv_convenience, ndr->flags))); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->devmode)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->devmode) { + { + struct ndr_push *_ndr_devmode; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_devmode, 4, _ndr_size_spoolss_DeviceMode(r->devmode, ndr->iconv_convenience, ndr->flags))); + NDR_CHECK(ndr_push_spoolss_DeviceMode(_ndr_devmode, NDR_SCALARS, r->devmode)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_devmode, 4, _ndr_size_spoolss_DeviceMode(r->devmode, ndr->iconv_convenience, ndr->flags))); + } + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DevmodeContainer(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DevmodeContainer *r) +{ + uint32_t _ptr_devmode; + TALLOC_CTX *_mem_save_devmode_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_ndr_size)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_devmode)); + if (_ptr_devmode) { + NDR_PULL_ALLOC(ndr, r->devmode); + } else { + r->devmode = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->devmode) { + _mem_save_devmode_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->devmode, 0); + { + struct ndr_pull *_ndr_devmode; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_devmode, 4, r->_ndr_size)); + NDR_CHECK(ndr_pull_spoolss_DeviceMode(_ndr_devmode, NDR_SCALARS, r->devmode)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_devmode, 4, r->_ndr_size)); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_devmode_0, 0); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DevmodeContainer(struct ndr_print *ndr, const char *name, const struct spoolss_DevmodeContainer *r) +{ + ndr_print_struct(ndr, name, "spoolss_DevmodeContainer"); + ndr->depth++; + ndr_print_uint32(ndr, "_ndr_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?_ndr_size_spoolss_DeviceMode(r->devmode, ndr->iconv_convenience, ndr->flags):r->_ndr_size); + ndr_print_ptr(ndr, "devmode", r->devmode); + ndr->depth++; + if (r->devmode) { + ndr_print_spoolss_DeviceMode(ndr, "devmode", r->devmode); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_JobInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo1 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->job_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->printer_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->server_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->user_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->document_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->data_type)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->text_status)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->status)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->priority)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->position)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->total_pages)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->pages_printed)); + NDR_CHECK(ndr_push_spoolss_Time(ndr, NDR_SCALARS, &r->time)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->printer_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->printer_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->printer_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->server_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->server_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->server_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->user_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->user_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->document_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->document_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->document_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->data_type) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->data_type)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->data_type)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->text_status) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->text_status)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->text_status)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_JobInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo1 *r) +{ + uint32_t _ptr_printer_name; + TALLOC_CTX *_mem_save_printer_name_0; + uint32_t _ptr_server_name; + TALLOC_CTX *_mem_save_server_name_0; + uint32_t _ptr_user_name; + TALLOC_CTX *_mem_save_user_name_0; + uint32_t _ptr_document_name; + TALLOC_CTX *_mem_save_document_name_0; + uint32_t _ptr_data_type; + TALLOC_CTX *_mem_save_data_type_0; + uint32_t _ptr_text_status; + TALLOC_CTX *_mem_save_text_status_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->job_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_printer_name)); + if (_ptr_printer_name) { + NDR_PULL_ALLOC(ndr, r->printer_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->printer_name, _ptr_printer_name)); + } else { + r->printer_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_server_name)); + if (_ptr_server_name) { + NDR_PULL_ALLOC(ndr, r->server_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->server_name, _ptr_server_name)); + } else { + r->server_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_user_name)); + if (_ptr_user_name) { + NDR_PULL_ALLOC(ndr, r->user_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->user_name, _ptr_user_name)); + } else { + r->user_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_document_name)); + if (_ptr_document_name) { + NDR_PULL_ALLOC(ndr, r->document_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->document_name, _ptr_document_name)); + } else { + r->document_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data_type)); + if (_ptr_data_type) { + NDR_PULL_ALLOC(ndr, r->data_type); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->data_type, _ptr_data_type)); + } else { + r->data_type = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_text_status)); + if (_ptr_text_status) { + NDR_PULL_ALLOC(ndr, r->text_status); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->text_status, _ptr_text_status)); + } else { + r->text_status = NULL; + } + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->status)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->priority)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->position)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->total_pages)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->pages_printed)); + NDR_CHECK(ndr_pull_spoolss_Time(ndr, NDR_SCALARS, &r->time)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->printer_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->printer_name)); + _mem_save_printer_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->printer_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->printer_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printer_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->server_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->server_name)); + _mem_save_server_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->server_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->server_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_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->user_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->user_name)); + _mem_save_user_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->user_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_user_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->document_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->document_name)); + _mem_save_document_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->document_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->document_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_document_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->data_type) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->data_type)); + _mem_save_data_type_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->data_type, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->data_type)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_type_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->text_status) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->text_status)); + _mem_save_text_status_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->text_status, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->text_status)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_text_status_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_JobInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfo1 *r) +{ + ndr_print_struct(ndr, name, "spoolss_JobInfo1"); + ndr->depth++; + ndr_print_uint32(ndr, "job_id", r->job_id); + ndr_print_ptr(ndr, "printer_name", r->printer_name); + ndr->depth++; + if (r->printer_name) { + ndr_print_string(ndr, "printer_name", r->printer_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "server_name", r->server_name); + ndr->depth++; + if (r->server_name) { + ndr_print_string(ndr, "server_name", r->server_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "user_name", r->user_name); + ndr->depth++; + if (r->user_name) { + ndr_print_string(ndr, "user_name", r->user_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "document_name", r->document_name); + ndr->depth++; + if (r->document_name) { + ndr_print_string(ndr, "document_name", r->document_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "data_type", r->data_type); + ndr->depth++; + if (r->data_type) { + ndr_print_string(ndr, "data_type", r->data_type); + } + ndr->depth--; + ndr_print_ptr(ndr, "text_status", r->text_status); + ndr->depth++; + if (r->text_status) { + ndr_print_string(ndr, "text_status", r->text_status); + } + ndr->depth--; + ndr_print_uint32(ndr, "status", r->status); + ndr_print_uint32(ndr, "priority", r->priority); + ndr_print_uint32(ndr, "position", r->position); + ndr_print_uint32(ndr, "total_pages", r->total_pages); + ndr_print_uint32(ndr, "pages_printed", r->pages_printed); + ndr_print_spoolss_Time(ndr, "time", &r->time); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_JobInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_JobInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr); + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 1: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_JobInfo1(ndr, NDR_SCALARS, &r->info1)); + break; } + + case 2: { + break; } + + case 3: { + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + NDR_CHECK(ndr_push_spoolss_JobInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + case 2: + break; + + case 3: + break; + + default: + break; + + } + } + ndr_push_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_JobInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_JobInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset(ndr); + int level; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + switch (level) { + case 1: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_JobInfo1(ndr, NDR_SCALARS, &r->info1)); + break; } + + case 2: { + break; } + + case 3: { + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + NDR_CHECK(ndr_pull_spoolss_JobInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + case 2: + break; + + case 3: + break; + + default: + break; + + } + } + ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_JobInfo(struct ndr_print *ndr, const char *name, const union spoolss_JobInfo *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_JobInfo"); + switch (level) { + case 1: + ndr_print_spoolss_JobInfo1(ndr, "info1", &r->info1); + break; + + case 2: + break; + + case 3: + break; + + default: + break; + + } +} + +static enum ndr_err_code ndr_push_spoolss_JobInfoContainer(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfoContainer *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->level)); + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->info, r->level)); + NDR_CHECK(ndr_push_spoolss_JobInfo(ndr, NDR_SCALARS, &r->info)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_push_spoolss_JobInfo(ndr, NDR_BUFFERS, &r->info)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_JobInfoContainer(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfoContainer *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->level)); + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->info, r->level)); + NDR_CHECK(ndr_pull_spoolss_JobInfo(ndr, NDR_SCALARS, &r->info)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_spoolss_JobInfo(ndr, NDR_BUFFERS, &r->info)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_JobInfoContainer(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfoContainer *r) +{ + ndr_print_struct(ndr, name, "spoolss_JobInfoContainer"); + ndr->depth++; + ndr_print_uint32(ndr, "level", r->level); + ndr_print_set_switch_value(ndr, &r->info, r->level); + ndr_print_spoolss_JobInfo(ndr, "info", &r->info); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_JobControl(struct ndr_push *ndr, int ndr_flags, enum spoolss_JobControl r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_JobControl(struct ndr_pull *ndr, int ndr_flags, enum spoolss_JobControl *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_JobControl(struct ndr_print *ndr, const char *name, enum spoolss_JobControl r) +{ + const char *val = NULL; + + switch (r) { + case SPOOLSS_JOB_CONTROL_PAUSE: val = "SPOOLSS_JOB_CONTROL_PAUSE"; break; + case SPOOLSS_JOB_CONTROL_RESUME: val = "SPOOLSS_JOB_CONTROL_RESUME"; break; + case SPOOLSS_JOB_CONTROL_CANCEL: val = "SPOOLSS_JOB_CONTROL_CANCEL"; break; + case SPOOLSS_JOB_CONTROL_RESTART: val = "SPOOLSS_JOB_CONTROL_RESTART"; break; + case SPOOLSS_JOB_CONTROL_DELETE: val = "SPOOLSS_JOB_CONTROL_DELETE"; break; + case SPOOLSS_JOB_CONTROL_SEND_TO_PRINTER: val = "SPOOLSS_JOB_CONTROL_SEND_TO_PRINTER"; break; + case SPOOLSS_JOB_CONTROL_LAST_PAGE_EJECTED: val = "SPOOLSS_JOB_CONTROL_LAST_PAGE_EJECTED"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + +static enum ndr_err_code ndr_push_spoolss_PrinterControl(struct ndr_push *ndr, int ndr_flags, enum spoolss_PrinterControl r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PrinterControl(struct ndr_pull *ndr, int ndr_flags, enum spoolss_PrinterControl *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrinterControl(struct ndr_print *ndr, const char *name, enum spoolss_PrinterControl r) +{ + const char *val = NULL; + + switch (r) { + case SPOOLSS_PRINTER_CONTROL_UNPAUSE: val = "SPOOLSS_PRINTER_CONTROL_UNPAUSE"; break; + case SPOOLSS_PRINTER_CONTROL_PAUSE: val = "SPOOLSS_PRINTER_CONTROL_PAUSE"; break; + case SPOOLSS_PRINTER_CONTROL_RESUME: val = "SPOOLSS_PRINTER_CONTROL_RESUME"; break; + case SPOOLSS_PRINTER_CONTROL_PURGE: val = "SPOOLSS_PRINTER_CONTROL_PURGE"; break; + case SPOOLSS_PRINTER_CONTROL_SET_STATUS: val = "SPOOLSS_PRINTER_CONTROL_SET_STATUS"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + +static enum ndr_err_code ndr_push_spoolss_SetPrinterInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_SetPrinterInfo *r) +{ + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, level)); + switch (level) { + case 0: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info0)); + break; } + + case 1: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info1)); + break; } + + case 2: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info2)); + break; } + + case 3: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info3)); + break; } + + case 4: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info4)); + break; } + + case 5: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info5)); + break; } + + case 6: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info6)); + break; } + + case 7: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info7)); + break; } + + case 8: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info8)); + break; } + + case 9: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info9)); + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 0: + if (r->info0) { + NDR_CHECK(ndr_push_spoolss_PrinterInfo0(ndr, NDR_SCALARS|NDR_BUFFERS, r->info0)); + } + break; + + case 1: + if (r->info1) { + NDR_CHECK(ndr_push_spoolss_PrinterInfo1(ndr, NDR_SCALARS|NDR_BUFFERS, r->info1)); + } + break; + + case 2: + if (r->info2) { + NDR_CHECK(ndr_push_spoolss_PrinterInfo2(ndr, NDR_SCALARS|NDR_BUFFERS, r->info2)); + } + break; + + case 3: + if (r->info3) { + NDR_CHECK(ndr_push_spoolss_PrinterInfo3(ndr, NDR_SCALARS|NDR_BUFFERS, r->info3)); + } + break; + + case 4: + if (r->info4) { + NDR_CHECK(ndr_push_spoolss_PrinterInfo4(ndr, NDR_SCALARS|NDR_BUFFERS, r->info4)); + } + break; + + case 5: + if (r->info5) { + NDR_CHECK(ndr_push_spoolss_PrinterInfo5(ndr, NDR_SCALARS|NDR_BUFFERS, r->info5)); + } + break; + + case 6: + if (r->info6) { + NDR_CHECK(ndr_push_spoolss_PrinterInfo6(ndr, NDR_SCALARS, r->info6)); + } + break; + + case 7: + if (r->info7) { + NDR_CHECK(ndr_push_spoolss_PrinterInfo7(ndr, NDR_SCALARS|NDR_BUFFERS, r->info7)); + } + break; + + case 8: + if (r->info8) { + NDR_CHECK(ndr_push_spoolss_DeviceModeInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->info8)); + } + break; + + case 9: + if (r->info9) { + NDR_CHECK(ndr_push_spoolss_DeviceModeInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->info9)); + } + break; + + default: + break; + + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_SetPrinterInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_SetPrinterInfo *r) +{ + int level; + uint32_t _level; + TALLOC_CTX *_mem_save_info0_0; + TALLOC_CTX *_mem_save_info1_0; + TALLOC_CTX *_mem_save_info2_0; + TALLOC_CTX *_mem_save_info3_0; + TALLOC_CTX *_mem_save_info4_0; + TALLOC_CTX *_mem_save_info5_0; + TALLOC_CTX *_mem_save_info6_0; + TALLOC_CTX *_mem_save_info7_0; + TALLOC_CTX *_mem_save_info8_0; + TALLOC_CTX *_mem_save_info9_0; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &_level)); + if (_level != level) { + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u for r", _level); + } + switch (level) { + case 0: { + uint32_t _ptr_info0; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info0)); + if (_ptr_info0) { + NDR_PULL_ALLOC(ndr, r->info0); + } else { + r->info0 = NULL; + } + break; } + + case 1: { + uint32_t _ptr_info1; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info1)); + if (_ptr_info1) { + NDR_PULL_ALLOC(ndr, r->info1); + } else { + r->info1 = NULL; + } + break; } + + case 2: { + uint32_t _ptr_info2; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info2)); + if (_ptr_info2) { + NDR_PULL_ALLOC(ndr, r->info2); + } else { + r->info2 = NULL; + } + break; } + + case 3: { + uint32_t _ptr_info3; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info3)); + if (_ptr_info3) { + NDR_PULL_ALLOC(ndr, r->info3); + } else { + r->info3 = NULL; + } + break; } + + case 4: { + uint32_t _ptr_info4; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info4)); + if (_ptr_info4) { + NDR_PULL_ALLOC(ndr, r->info4); + } else { + r->info4 = NULL; + } + break; } + + case 5: { + uint32_t _ptr_info5; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info5)); + if (_ptr_info5) { + NDR_PULL_ALLOC(ndr, r->info5); + } else { + r->info5 = NULL; + } + break; } + + case 6: { + uint32_t _ptr_info6; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info6)); + if (_ptr_info6) { + NDR_PULL_ALLOC(ndr, r->info6); + } else { + r->info6 = NULL; + } + break; } + + case 7: { + uint32_t _ptr_info7; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info7)); + if (_ptr_info7) { + NDR_PULL_ALLOC(ndr, r->info7); + } else { + r->info7 = NULL; + } + break; } + + case 8: { + uint32_t _ptr_info8; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info8)); + if (_ptr_info8) { + NDR_PULL_ALLOC(ndr, r->info8); + } else { + r->info8 = NULL; + } + break; } + + case 9: { + uint32_t _ptr_info9; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info9)); + if (_ptr_info9) { + NDR_PULL_ALLOC(ndr, r->info9); + } else { + r->info9 = NULL; + } + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + switch (level) { + case 0: + if (r->info0) { + _mem_save_info0_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info0, 0); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo0(ndr, NDR_SCALARS|NDR_BUFFERS, r->info0)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info0_0, 0); + } + break; + + case 1: + if (r->info1) { + _mem_save_info1_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info1, 0); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo1(ndr, NDR_SCALARS|NDR_BUFFERS, r->info1)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info1_0, 0); + } + break; + + case 2: + if (r->info2) { + _mem_save_info2_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info2, 0); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo2(ndr, NDR_SCALARS|NDR_BUFFERS, r->info2)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info2_0, 0); + } + break; + + case 3: + if (r->info3) { + _mem_save_info3_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info3, 0); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo3(ndr, NDR_SCALARS|NDR_BUFFERS, r->info3)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info3_0, 0); + } + break; + + case 4: + if (r->info4) { + _mem_save_info4_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info4, 0); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo4(ndr, NDR_SCALARS|NDR_BUFFERS, r->info4)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info4_0, 0); + } + break; + + case 5: + if (r->info5) { + _mem_save_info5_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info5, 0); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo5(ndr, NDR_SCALARS|NDR_BUFFERS, r->info5)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info5_0, 0); + } + break; + + case 6: + if (r->info6) { + _mem_save_info6_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info6, 0); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo6(ndr, NDR_SCALARS, r->info6)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info6_0, 0); + } + break; + + case 7: + if (r->info7) { + _mem_save_info7_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info7, 0); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo7(ndr, NDR_SCALARS|NDR_BUFFERS, r->info7)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info7_0, 0); + } + break; + + case 8: + if (r->info8) { + _mem_save_info8_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info8, 0); + NDR_CHECK(ndr_pull_spoolss_DeviceModeInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->info8)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info8_0, 0); + } + break; + + case 9: + if (r->info9) { + _mem_save_info9_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info9, 0); + NDR_CHECK(ndr_pull_spoolss_DeviceModeInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->info9)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info9_0, 0); + } + break; + + default: + break; + + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_SetPrinterInfo(struct ndr_print *ndr, const char *name, const union spoolss_SetPrinterInfo *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_SetPrinterInfo"); + switch (level) { + case 0: + ndr_print_ptr(ndr, "info0", r->info0); + ndr->depth++; + if (r->info0) { + ndr_print_spoolss_PrinterInfo0(ndr, "info0", r->info0); + } + ndr->depth--; + break; + + case 1: + ndr_print_ptr(ndr, "info1", r->info1); + ndr->depth++; + if (r->info1) { + ndr_print_spoolss_PrinterInfo1(ndr, "info1", r->info1); + } + ndr->depth--; + break; + + case 2: + ndr_print_ptr(ndr, "info2", r->info2); + ndr->depth++; + if (r->info2) { + ndr_print_spoolss_PrinterInfo2(ndr, "info2", r->info2); + } + ndr->depth--; + break; + + case 3: + ndr_print_ptr(ndr, "info3", r->info3); + ndr->depth++; + if (r->info3) { + ndr_print_spoolss_PrinterInfo3(ndr, "info3", r->info3); + } + ndr->depth--; + break; + + case 4: + ndr_print_ptr(ndr, "info4", r->info4); + ndr->depth++; + if (r->info4) { + ndr_print_spoolss_PrinterInfo4(ndr, "info4", r->info4); + } + ndr->depth--; + break; + + case 5: + ndr_print_ptr(ndr, "info5", r->info5); + ndr->depth++; + if (r->info5) { + ndr_print_spoolss_PrinterInfo5(ndr, "info5", r->info5); + } + ndr->depth--; + break; + + case 6: + ndr_print_ptr(ndr, "info6", r->info6); + ndr->depth++; + if (r->info6) { + ndr_print_spoolss_PrinterInfo6(ndr, "info6", r->info6); + } + ndr->depth--; + break; + + case 7: + ndr_print_ptr(ndr, "info7", r->info7); + ndr->depth++; + if (r->info7) { + ndr_print_spoolss_PrinterInfo7(ndr, "info7", r->info7); + } + ndr->depth--; + break; + + case 8: + ndr_print_ptr(ndr, "info8", r->info8); + ndr->depth++; + if (r->info8) { + ndr_print_spoolss_DeviceModeInfo(ndr, "info8", r->info8); + } + ndr->depth--; + break; + + case 9: + ndr_print_ptr(ndr, "info9", r->info9); + ndr->depth++; + if (r->info9) { + ndr_print_spoolss_DeviceModeInfo(ndr, "info9", r->info9); + } + ndr->depth--; + break; + + default: + break; + + } +} + +static enum ndr_err_code ndr_push_spoolss_DriverInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo1 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->driver_name)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->driver_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->driver_name)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DriverInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo1 *r) +{ + uint32_t _ptr_driver_name; + TALLOC_CTX *_mem_save_driver_name_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_name)); + if (_ptr_driver_name) { + NDR_PULL_ALLOC(ndr, r->driver_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->driver_name, _ptr_driver_name)); + } else { + r->driver_name = NULL; + } + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->driver_name)); + _mem_save_driver_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->driver_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_name_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DriverInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo1 *r) +{ + ndr_print_struct(ndr, name, "spoolss_DriverInfo1"); + ndr->depth++; + ndr_print_ptr(ndr, "driver_name", r->driver_name); + ndr->depth++; + if (r->driver_name) { + ndr_print_string(ndr, "driver_name", r->driver_name); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DriverOSVersion(struct ndr_push *ndr, int ndr_flags, enum spoolss_DriverOSVersion r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DriverOSVersion(struct ndr_pull *ndr, int ndr_flags, enum spoolss_DriverOSVersion *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DriverOSVersion(struct ndr_print *ndr, const char *name, enum spoolss_DriverOSVersion r) +{ + const char *val = NULL; + + switch (r) { + case SPOOLSS_DRIVER_VERSION_9X: val = "SPOOLSS_DRIVER_VERSION_9X"; break; + case SPOOLSS_DRIVER_VERSION_NT35: val = "SPOOLSS_DRIVER_VERSION_NT35"; break; + case SPOOLSS_DRIVER_VERSION_NT4: val = "SPOOLSS_DRIVER_VERSION_NT4"; break; + case SPOOLSS_DRIVER_VERSION_200X: val = "SPOOLSS_DRIVER_VERSION_200X"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + +static enum ndr_err_code ndr_push_spoolss_DriverInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo2 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_spoolss_DriverOSVersion(ndr, NDR_SCALARS, r->version)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->driver_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->architecture)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->driver_path)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->data_file)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->config_file)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->driver_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->driver_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->architecture) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->architecture)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->architecture)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_path) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->driver_path)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->driver_path)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->data_file) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->data_file)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->data_file)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->config_file) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->config_file)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->config_file)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DriverInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo2 *r) +{ + uint32_t _ptr_driver_name; + TALLOC_CTX *_mem_save_driver_name_0; + uint32_t _ptr_architecture; + TALLOC_CTX *_mem_save_architecture_0; + uint32_t _ptr_driver_path; + TALLOC_CTX *_mem_save_driver_path_0; + uint32_t _ptr_data_file; + TALLOC_CTX *_mem_save_data_file_0; + uint32_t _ptr_config_file; + TALLOC_CTX *_mem_save_config_file_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_spoolss_DriverOSVersion(ndr, NDR_SCALARS, &r->version)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_name)); + if (_ptr_driver_name) { + NDR_PULL_ALLOC(ndr, r->driver_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->driver_name, _ptr_driver_name)); + } else { + r->driver_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_architecture)); + if (_ptr_architecture) { + NDR_PULL_ALLOC(ndr, r->architecture); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->architecture, _ptr_architecture)); + } else { + r->architecture = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_path)); + if (_ptr_driver_path) { + NDR_PULL_ALLOC(ndr, r->driver_path); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->driver_path, _ptr_driver_path)); + } else { + r->driver_path = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data_file)); + if (_ptr_data_file) { + NDR_PULL_ALLOC(ndr, r->data_file); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->data_file, _ptr_data_file)); + } else { + r->data_file = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_config_file)); + if (_ptr_config_file) { + NDR_PULL_ALLOC(ndr, r->config_file); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->config_file, _ptr_config_file)); + } else { + r->config_file = NULL; + } + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->driver_name)); + _mem_save_driver_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->driver_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_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->architecture) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->architecture)); + _mem_save_architecture_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->architecture, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->architecture)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_architecture_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->driver_path) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->driver_path)); + _mem_save_driver_path_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->driver_path, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_path)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_path_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->data_file) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->data_file)); + _mem_save_data_file_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->data_file, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->data_file)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_file_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->config_file) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->config_file)); + _mem_save_config_file_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->config_file, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->config_file)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_config_file_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DriverInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo2 *r) +{ + ndr_print_struct(ndr, name, "spoolss_DriverInfo2"); + ndr->depth++; + ndr_print_spoolss_DriverOSVersion(ndr, "version", r->version); + ndr_print_ptr(ndr, "driver_name", r->driver_name); + ndr->depth++; + if (r->driver_name) { + ndr_print_string(ndr, "driver_name", r->driver_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "architecture", r->architecture); + ndr->depth++; + if (r->architecture) { + ndr_print_string(ndr, "architecture", r->architecture); + } + ndr->depth--; + ndr_print_ptr(ndr, "driver_path", r->driver_path); + ndr->depth++; + if (r->driver_path) { + ndr_print_string(ndr, "driver_path", r->driver_path); + } + ndr->depth--; + ndr_print_ptr(ndr, "data_file", r->data_file); + ndr->depth++; + if (r->data_file) { + ndr_print_string(ndr, "data_file", r->data_file); + } + ndr->depth--; + ndr_print_ptr(ndr, "config_file", r->config_file); + ndr->depth++; + if (r->config_file) { + ndr_print_string(ndr, "config_file", r->config_file); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DriverInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo3 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_spoolss_DriverOSVersion(ndr, NDR_SCALARS, r->version)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->driver_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->architecture)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->driver_path)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->data_file)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->config_file)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->help_file)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->dependent_files)); + ndr->flags = _flags_save_string_array; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->monitor_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->default_datatype)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->driver_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->driver_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->architecture) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->architecture)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->architecture)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_path) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->driver_path)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->driver_path)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->data_file) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->data_file)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->data_file)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->config_file) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->config_file)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->config_file)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->help_file) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->help_file)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->help_file)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->dependent_files) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->dependent_files)); + NDR_CHECK(ndr_push_string_array(ndr, NDR_SCALARS, r->dependent_files)); + } + ndr->flags = _flags_save_string_array; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->monitor_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->monitor_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->monitor_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->default_datatype) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->default_datatype)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->default_datatype)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DriverInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo3 *r) +{ + uint32_t _ptr_driver_name; + TALLOC_CTX *_mem_save_driver_name_0; + uint32_t _ptr_architecture; + TALLOC_CTX *_mem_save_architecture_0; + uint32_t _ptr_driver_path; + TALLOC_CTX *_mem_save_driver_path_0; + uint32_t _ptr_data_file; + TALLOC_CTX *_mem_save_data_file_0; + uint32_t _ptr_config_file; + TALLOC_CTX *_mem_save_config_file_0; + uint32_t _ptr_help_file; + TALLOC_CTX *_mem_save_help_file_0; + uint32_t _ptr_dependent_files; + TALLOC_CTX *_mem_save_dependent_files_0; + uint32_t _ptr_monitor_name; + TALLOC_CTX *_mem_save_monitor_name_0; + uint32_t _ptr_default_datatype; + TALLOC_CTX *_mem_save_default_datatype_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_spoolss_DriverOSVersion(ndr, NDR_SCALARS, &r->version)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_name)); + if (_ptr_driver_name) { + NDR_PULL_ALLOC(ndr, r->driver_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->driver_name, _ptr_driver_name)); + } else { + r->driver_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_architecture)); + if (_ptr_architecture) { + NDR_PULL_ALLOC(ndr, r->architecture); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->architecture, _ptr_architecture)); + } else { + r->architecture = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_path)); + if (_ptr_driver_path) { + NDR_PULL_ALLOC(ndr, r->driver_path); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->driver_path, _ptr_driver_path)); + } else { + r->driver_path = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data_file)); + if (_ptr_data_file) { + NDR_PULL_ALLOC(ndr, r->data_file); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->data_file, _ptr_data_file)); + } else { + r->data_file = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_config_file)); + if (_ptr_config_file) { + NDR_PULL_ALLOC(ndr, r->config_file); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->config_file, _ptr_config_file)); + } else { + r->config_file = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_help_file)); + if (_ptr_help_file) { + NDR_PULL_ALLOC(ndr, r->help_file); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->help_file, _ptr_help_file)); + } else { + r->help_file = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_dependent_files)); + if (_ptr_dependent_files) { + NDR_PULL_ALLOC(ndr, r->dependent_files); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->dependent_files, _ptr_dependent_files)); + } else { + r->dependent_files = NULL; + } + ndr->flags = _flags_save_string_array; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_monitor_name)); + if (_ptr_monitor_name) { + NDR_PULL_ALLOC(ndr, r->monitor_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->monitor_name, _ptr_monitor_name)); + } else { + r->monitor_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_default_datatype)); + if (_ptr_default_datatype) { + NDR_PULL_ALLOC(ndr, r->default_datatype); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->default_datatype, _ptr_default_datatype)); + } else { + r->default_datatype = NULL; + } + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->driver_name)); + _mem_save_driver_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->driver_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_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->architecture) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->architecture)); + _mem_save_architecture_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->architecture, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->architecture)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_architecture_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->driver_path) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->driver_path)); + _mem_save_driver_path_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->driver_path, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_path)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_path_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->data_file) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->data_file)); + _mem_save_data_file_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->data_file, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->data_file)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_file_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->config_file) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->config_file)); + _mem_save_config_file_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->config_file, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->config_file)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_config_file_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->help_file) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->help_file)); + _mem_save_help_file_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->help_file, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->help_file)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_help_file_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->dependent_files) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->dependent_files)); + _mem_save_dependent_files_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->dependent_files, 0); + NDR_CHECK(ndr_pull_string_array(ndr, NDR_SCALARS, &r->dependent_files)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dependent_files_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string_array; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->monitor_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->monitor_name)); + _mem_save_monitor_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->monitor_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->monitor_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_monitor_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->default_datatype) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->default_datatype)); + _mem_save_default_datatype_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->default_datatype, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->default_datatype)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_default_datatype_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DriverInfo3(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo3 *r) +{ + ndr_print_struct(ndr, name, "spoolss_DriverInfo3"); + ndr->depth++; + ndr_print_spoolss_DriverOSVersion(ndr, "version", r->version); + ndr_print_ptr(ndr, "driver_name", r->driver_name); + ndr->depth++; + if (r->driver_name) { + ndr_print_string(ndr, "driver_name", r->driver_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "architecture", r->architecture); + ndr->depth++; + if (r->architecture) { + ndr_print_string(ndr, "architecture", r->architecture); + } + ndr->depth--; + ndr_print_ptr(ndr, "driver_path", r->driver_path); + ndr->depth++; + if (r->driver_path) { + ndr_print_string(ndr, "driver_path", r->driver_path); + } + ndr->depth--; + ndr_print_ptr(ndr, "data_file", r->data_file); + ndr->depth++; + if (r->data_file) { + ndr_print_string(ndr, "data_file", r->data_file); + } + ndr->depth--; + ndr_print_ptr(ndr, "config_file", r->config_file); + ndr->depth++; + if (r->config_file) { + ndr_print_string(ndr, "config_file", r->config_file); + } + ndr->depth--; + ndr_print_ptr(ndr, "help_file", r->help_file); + ndr->depth++; + if (r->help_file) { + ndr_print_string(ndr, "help_file", r->help_file); + } + ndr->depth--; + ndr_print_ptr(ndr, "dependent_files", r->dependent_files); + ndr->depth++; + if (r->dependent_files) { + ndr_print_string_array(ndr, "dependent_files", r->dependent_files); + } + ndr->depth--; + ndr_print_ptr(ndr, "monitor_name", r->monitor_name); + ndr->depth++; + if (r->monitor_name) { + ndr_print_string(ndr, "monitor_name", r->monitor_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "default_datatype", r->default_datatype); + ndr->depth++; + if (r->default_datatype) { + ndr_print_string(ndr, "default_datatype", r->default_datatype); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DriverInfo4(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo4 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_spoolss_DriverOSVersion(ndr, NDR_SCALARS, r->version)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->driver_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->architecture)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->driver_path)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->data_file)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->config_file)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->help_file)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->dependent_files)); + ndr->flags = _flags_save_string_array; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->monitor_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->default_datatype)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->previous_names)); + ndr->flags = _flags_save_string_array; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->driver_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->driver_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->architecture) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->architecture)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->architecture)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_path) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->driver_path)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->driver_path)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->data_file) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->data_file)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->data_file)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->config_file) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->config_file)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->config_file)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->help_file) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->help_file)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->help_file)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->dependent_files) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->dependent_files)); + NDR_CHECK(ndr_push_string_array(ndr, NDR_SCALARS, r->dependent_files)); + } + ndr->flags = _flags_save_string_array; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->monitor_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->monitor_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->monitor_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->default_datatype) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->default_datatype)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->default_datatype)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->previous_names) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->previous_names)); + NDR_CHECK(ndr_push_string_array(ndr, NDR_SCALARS, r->previous_names)); + } + ndr->flags = _flags_save_string_array; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DriverInfo4(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo4 *r) +{ + uint32_t _ptr_driver_name; + TALLOC_CTX *_mem_save_driver_name_0; + uint32_t _ptr_architecture; + TALLOC_CTX *_mem_save_architecture_0; + uint32_t _ptr_driver_path; + TALLOC_CTX *_mem_save_driver_path_0; + uint32_t _ptr_data_file; + TALLOC_CTX *_mem_save_data_file_0; + uint32_t _ptr_config_file; + TALLOC_CTX *_mem_save_config_file_0; + uint32_t _ptr_help_file; + TALLOC_CTX *_mem_save_help_file_0; + uint32_t _ptr_dependent_files; + TALLOC_CTX *_mem_save_dependent_files_0; + uint32_t _ptr_monitor_name; + TALLOC_CTX *_mem_save_monitor_name_0; + uint32_t _ptr_default_datatype; + TALLOC_CTX *_mem_save_default_datatype_0; + uint32_t _ptr_previous_names; + TALLOC_CTX *_mem_save_previous_names_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_spoolss_DriverOSVersion(ndr, NDR_SCALARS, &r->version)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_name)); + if (_ptr_driver_name) { + NDR_PULL_ALLOC(ndr, r->driver_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->driver_name, _ptr_driver_name)); + } else { + r->driver_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_architecture)); + if (_ptr_architecture) { + NDR_PULL_ALLOC(ndr, r->architecture); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->architecture, _ptr_architecture)); + } else { + r->architecture = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_path)); + if (_ptr_driver_path) { + NDR_PULL_ALLOC(ndr, r->driver_path); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->driver_path, _ptr_driver_path)); + } else { + r->driver_path = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data_file)); + if (_ptr_data_file) { + NDR_PULL_ALLOC(ndr, r->data_file); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->data_file, _ptr_data_file)); + } else { + r->data_file = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_config_file)); + if (_ptr_config_file) { + NDR_PULL_ALLOC(ndr, r->config_file); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->config_file, _ptr_config_file)); + } else { + r->config_file = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_help_file)); + if (_ptr_help_file) { + NDR_PULL_ALLOC(ndr, r->help_file); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->help_file, _ptr_help_file)); + } else { + r->help_file = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_dependent_files)); + if (_ptr_dependent_files) { + NDR_PULL_ALLOC(ndr, r->dependent_files); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->dependent_files, _ptr_dependent_files)); + } else { + r->dependent_files = NULL; + } + ndr->flags = _flags_save_string_array; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_monitor_name)); + if (_ptr_monitor_name) { + NDR_PULL_ALLOC(ndr, r->monitor_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->monitor_name, _ptr_monitor_name)); + } else { + r->monitor_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_default_datatype)); + if (_ptr_default_datatype) { + NDR_PULL_ALLOC(ndr, r->default_datatype); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->default_datatype, _ptr_default_datatype)); + } else { + r->default_datatype = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_previous_names)); + if (_ptr_previous_names) { + NDR_PULL_ALLOC(ndr, r->previous_names); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->previous_names, _ptr_previous_names)); + } else { + r->previous_names = NULL; + } + ndr->flags = _flags_save_string_array; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->driver_name)); + _mem_save_driver_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->driver_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_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->architecture) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->architecture)); + _mem_save_architecture_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->architecture, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->architecture)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_architecture_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->driver_path) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->driver_path)); + _mem_save_driver_path_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->driver_path, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_path)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_path_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->data_file) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->data_file)); + _mem_save_data_file_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->data_file, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->data_file)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_file_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->config_file) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->config_file)); + _mem_save_config_file_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->config_file, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->config_file)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_config_file_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->help_file) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->help_file)); + _mem_save_help_file_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->help_file, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->help_file)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_help_file_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->dependent_files) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->dependent_files)); + _mem_save_dependent_files_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->dependent_files, 0); + NDR_CHECK(ndr_pull_string_array(ndr, NDR_SCALARS, &r->dependent_files)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dependent_files_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string_array; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->monitor_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->monitor_name)); + _mem_save_monitor_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->monitor_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->monitor_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_monitor_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->default_datatype) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->default_datatype)); + _mem_save_default_datatype_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->default_datatype, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->default_datatype)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_default_datatype_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->previous_names) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->previous_names)); + _mem_save_previous_names_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->previous_names, 0); + NDR_CHECK(ndr_pull_string_array(ndr, NDR_SCALARS, &r->previous_names)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_previous_names_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string_array; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DriverInfo4(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo4 *r) +{ + ndr_print_struct(ndr, name, "spoolss_DriverInfo4"); + ndr->depth++; + ndr_print_spoolss_DriverOSVersion(ndr, "version", r->version); + ndr_print_ptr(ndr, "driver_name", r->driver_name); + ndr->depth++; + if (r->driver_name) { + ndr_print_string(ndr, "driver_name", r->driver_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "architecture", r->architecture); + ndr->depth++; + if (r->architecture) { + ndr_print_string(ndr, "architecture", r->architecture); + } + ndr->depth--; + ndr_print_ptr(ndr, "driver_path", r->driver_path); + ndr->depth++; + if (r->driver_path) { + ndr_print_string(ndr, "driver_path", r->driver_path); + } + ndr->depth--; + ndr_print_ptr(ndr, "data_file", r->data_file); + ndr->depth++; + if (r->data_file) { + ndr_print_string(ndr, "data_file", r->data_file); + } + ndr->depth--; + ndr_print_ptr(ndr, "config_file", r->config_file); + ndr->depth++; + if (r->config_file) { + ndr_print_string(ndr, "config_file", r->config_file); + } + ndr->depth--; + ndr_print_ptr(ndr, "help_file", r->help_file); + ndr->depth++; + if (r->help_file) { + ndr_print_string(ndr, "help_file", r->help_file); + } + ndr->depth--; + ndr_print_ptr(ndr, "dependent_files", r->dependent_files); + ndr->depth++; + if (r->dependent_files) { + ndr_print_string_array(ndr, "dependent_files", r->dependent_files); + } + ndr->depth--; + ndr_print_ptr(ndr, "monitor_name", r->monitor_name); + ndr->depth++; + if (r->monitor_name) { + ndr_print_string(ndr, "monitor_name", r->monitor_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "default_datatype", r->default_datatype); + ndr->depth++; + if (r->default_datatype) { + ndr_print_string(ndr, "default_datatype", r->default_datatype); + } + ndr->depth--; + ndr_print_ptr(ndr, "previous_names", r->previous_names); + ndr->depth++; + if (r->previous_names) { + ndr_print_string_array(ndr, "previous_names", r->previous_names); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DriverInfo5(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo5 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_spoolss_DriverOSVersion(ndr, NDR_SCALARS, r->version)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->driver_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->architecture)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->driver_path)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->data_file)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->config_file)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->driver_attributes)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->config_version)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->driver_version)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->driver_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->driver_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->architecture) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->architecture)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->architecture)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_path) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->driver_path)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->driver_path)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->data_file) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->data_file)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->data_file)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->config_file) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->config_file)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->config_file)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DriverInfo5(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo5 *r) +{ + uint32_t _ptr_driver_name; + TALLOC_CTX *_mem_save_driver_name_0; + uint32_t _ptr_architecture; + TALLOC_CTX *_mem_save_architecture_0; + uint32_t _ptr_driver_path; + TALLOC_CTX *_mem_save_driver_path_0; + uint32_t _ptr_data_file; + TALLOC_CTX *_mem_save_data_file_0; + uint32_t _ptr_config_file; + TALLOC_CTX *_mem_save_config_file_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_spoolss_DriverOSVersion(ndr, NDR_SCALARS, &r->version)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_name)); + if (_ptr_driver_name) { + NDR_PULL_ALLOC(ndr, r->driver_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->driver_name, _ptr_driver_name)); + } else { + r->driver_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_architecture)); + if (_ptr_architecture) { + NDR_PULL_ALLOC(ndr, r->architecture); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->architecture, _ptr_architecture)); + } else { + r->architecture = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_path)); + if (_ptr_driver_path) { + NDR_PULL_ALLOC(ndr, r->driver_path); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->driver_path, _ptr_driver_path)); + } else { + r->driver_path = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data_file)); + if (_ptr_data_file) { + NDR_PULL_ALLOC(ndr, r->data_file); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->data_file, _ptr_data_file)); + } else { + r->data_file = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_config_file)); + if (_ptr_config_file) { + NDR_PULL_ALLOC(ndr, r->config_file); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->config_file, _ptr_config_file)); + } else { + r->config_file = NULL; + } + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->driver_attributes)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->config_version)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->driver_version)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->driver_name)); + _mem_save_driver_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->driver_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_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->architecture) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->architecture)); + _mem_save_architecture_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->architecture, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->architecture)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_architecture_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->driver_path) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->driver_path)); + _mem_save_driver_path_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->driver_path, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_path)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_path_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->data_file) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->data_file)); + _mem_save_data_file_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->data_file, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->data_file)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_file_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->config_file) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->config_file)); + _mem_save_config_file_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->config_file, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->config_file)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_config_file_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DriverInfo5(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo5 *r) +{ + ndr_print_struct(ndr, name, "spoolss_DriverInfo5"); + ndr->depth++; + ndr_print_spoolss_DriverOSVersion(ndr, "version", r->version); + ndr_print_ptr(ndr, "driver_name", r->driver_name); + ndr->depth++; + if (r->driver_name) { + ndr_print_string(ndr, "driver_name", r->driver_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "architecture", r->architecture); + ndr->depth++; + if (r->architecture) { + ndr_print_string(ndr, "architecture", r->architecture); + } + ndr->depth--; + ndr_print_ptr(ndr, "driver_path", r->driver_path); + ndr->depth++; + if (r->driver_path) { + ndr_print_string(ndr, "driver_path", r->driver_path); + } + ndr->depth--; + ndr_print_ptr(ndr, "data_file", r->data_file); + ndr->depth++; + if (r->data_file) { + ndr_print_string(ndr, "data_file", r->data_file); + } + ndr->depth--; + ndr_print_ptr(ndr, "config_file", r->config_file); + ndr->depth++; + if (r->config_file) { + ndr_print_string(ndr, "config_file", r->config_file); + } + ndr->depth--; + ndr_print_uint32(ndr, "driver_attributes", r->driver_attributes); + ndr_print_uint32(ndr, "config_version", r->config_version); + ndr_print_uint32(ndr, "driver_version", r->driver_version); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DriverInfo6(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo6 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 8)); + NDR_CHECK(ndr_push_spoolss_DriverOSVersion(ndr, NDR_SCALARS, r->version)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->driver_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->architecture)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->driver_path)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->data_file)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->config_file)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->help_file)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->dependent_files)); + ndr->flags = _flags_save_string_array; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->monitor_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->default_datatype)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->previous_names)); + ndr->flags = _flags_save_string_array; + } + NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->driver_data)); + NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->driver_version)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->manufacturer_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->manufacturer_url)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->hardware_id)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->provider)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->driver_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->driver_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->architecture) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->architecture)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->architecture)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_path) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->driver_path)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->driver_path)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->data_file) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->data_file)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->data_file)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->config_file) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->config_file)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->config_file)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->help_file) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->help_file)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->help_file)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->dependent_files) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->dependent_files)); + NDR_CHECK(ndr_push_string_array(ndr, NDR_SCALARS, r->dependent_files)); + } + ndr->flags = _flags_save_string_array; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->monitor_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->monitor_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->monitor_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->default_datatype) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->default_datatype)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->default_datatype)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->previous_names) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->previous_names)); + NDR_CHECK(ndr_push_string_array(ndr, NDR_SCALARS, r->previous_names)); + } + ndr->flags = _flags_save_string_array; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->manufacturer_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->manufacturer_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->manufacturer_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->manufacturer_url) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->manufacturer_url)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->manufacturer_url)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->hardware_id) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->hardware_id)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->hardware_id)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->provider) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->provider)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->provider)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DriverInfo6(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo6 *r) +{ + uint32_t _ptr_driver_name; + TALLOC_CTX *_mem_save_driver_name_0; + uint32_t _ptr_architecture; + TALLOC_CTX *_mem_save_architecture_0; + uint32_t _ptr_driver_path; + TALLOC_CTX *_mem_save_driver_path_0; + uint32_t _ptr_data_file; + TALLOC_CTX *_mem_save_data_file_0; + uint32_t _ptr_config_file; + TALLOC_CTX *_mem_save_config_file_0; + uint32_t _ptr_help_file; + TALLOC_CTX *_mem_save_help_file_0; + uint32_t _ptr_dependent_files; + TALLOC_CTX *_mem_save_dependent_files_0; + uint32_t _ptr_monitor_name; + TALLOC_CTX *_mem_save_monitor_name_0; + uint32_t _ptr_default_datatype; + TALLOC_CTX *_mem_save_default_datatype_0; + uint32_t _ptr_previous_names; + TALLOC_CTX *_mem_save_previous_names_0; + uint32_t _ptr_manufacturer_name; + TALLOC_CTX *_mem_save_manufacturer_name_0; + uint32_t _ptr_manufacturer_url; + TALLOC_CTX *_mem_save_manufacturer_url_0; + uint32_t _ptr_hardware_id; + TALLOC_CTX *_mem_save_hardware_id_0; + uint32_t _ptr_provider; + TALLOC_CTX *_mem_save_provider_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 8)); + NDR_CHECK(ndr_pull_spoolss_DriverOSVersion(ndr, NDR_SCALARS, &r->version)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_name)); + if (_ptr_driver_name) { + NDR_PULL_ALLOC(ndr, r->driver_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->driver_name, _ptr_driver_name)); + } else { + r->driver_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_architecture)); + if (_ptr_architecture) { + NDR_PULL_ALLOC(ndr, r->architecture); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->architecture, _ptr_architecture)); + } else { + r->architecture = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_path)); + if (_ptr_driver_path) { + NDR_PULL_ALLOC(ndr, r->driver_path); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->driver_path, _ptr_driver_path)); + } else { + r->driver_path = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data_file)); + if (_ptr_data_file) { + NDR_PULL_ALLOC(ndr, r->data_file); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->data_file, _ptr_data_file)); + } else { + r->data_file = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_config_file)); + if (_ptr_config_file) { + NDR_PULL_ALLOC(ndr, r->config_file); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->config_file, _ptr_config_file)); + } else { + r->config_file = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_help_file)); + if (_ptr_help_file) { + NDR_PULL_ALLOC(ndr, r->help_file); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->help_file, _ptr_help_file)); + } else { + r->help_file = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_dependent_files)); + if (_ptr_dependent_files) { + NDR_PULL_ALLOC(ndr, r->dependent_files); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->dependent_files, _ptr_dependent_files)); + } else { + r->dependent_files = NULL; + } + ndr->flags = _flags_save_string_array; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_monitor_name)); + if (_ptr_monitor_name) { + NDR_PULL_ALLOC(ndr, r->monitor_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->monitor_name, _ptr_monitor_name)); + } else { + r->monitor_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_default_datatype)); + if (_ptr_default_datatype) { + NDR_PULL_ALLOC(ndr, r->default_datatype); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->default_datatype, _ptr_default_datatype)); + } else { + r->default_datatype = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_previous_names)); + if (_ptr_previous_names) { + NDR_PULL_ALLOC(ndr, r->previous_names); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->previous_names, _ptr_previous_names)); + } else { + r->previous_names = NULL; + } + ndr->flags = _flags_save_string_array; + } + NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->driver_data)); + NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->driver_version)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_manufacturer_name)); + if (_ptr_manufacturer_name) { + NDR_PULL_ALLOC(ndr, r->manufacturer_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->manufacturer_name, _ptr_manufacturer_name)); + } else { + r->manufacturer_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_manufacturer_url)); + if (_ptr_manufacturer_url) { + NDR_PULL_ALLOC(ndr, r->manufacturer_url); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->manufacturer_url, _ptr_manufacturer_url)); + } else { + r->manufacturer_url = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_hardware_id)); + if (_ptr_hardware_id) { + NDR_PULL_ALLOC(ndr, r->hardware_id); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->hardware_id, _ptr_hardware_id)); + } else { + r->hardware_id = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_provider)); + if (_ptr_provider) { + NDR_PULL_ALLOC(ndr, r->provider); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->provider, _ptr_provider)); + } else { + r->provider = NULL; + } + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->driver_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->driver_name)); + _mem_save_driver_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->driver_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_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->architecture) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->architecture)); + _mem_save_architecture_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->architecture, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->architecture)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_architecture_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->driver_path) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->driver_path)); + _mem_save_driver_path_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->driver_path, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_path)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_path_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->data_file) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->data_file)); + _mem_save_data_file_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->data_file, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->data_file)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_file_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->config_file) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->config_file)); + _mem_save_config_file_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->config_file, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->config_file)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_config_file_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->help_file) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->help_file)); + _mem_save_help_file_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->help_file, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->help_file)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_help_file_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->dependent_files) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->dependent_files)); + _mem_save_dependent_files_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->dependent_files, 0); + NDR_CHECK(ndr_pull_string_array(ndr, NDR_SCALARS, &r->dependent_files)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dependent_files_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string_array; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->monitor_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->monitor_name)); + _mem_save_monitor_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->monitor_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->monitor_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_monitor_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->default_datatype) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->default_datatype)); + _mem_save_default_datatype_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->default_datatype, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->default_datatype)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_default_datatype_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->previous_names) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->previous_names)); + _mem_save_previous_names_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->previous_names, 0); + NDR_CHECK(ndr_pull_string_array(ndr, NDR_SCALARS, &r->previous_names)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_previous_names_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string_array; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->manufacturer_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->manufacturer_name)); + _mem_save_manufacturer_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->manufacturer_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->manufacturer_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_manufacturer_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->manufacturer_url) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->manufacturer_url)); + _mem_save_manufacturer_url_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->manufacturer_url, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->manufacturer_url)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_manufacturer_url_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->hardware_id) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->hardware_id)); + _mem_save_hardware_id_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->hardware_id, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->hardware_id)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_hardware_id_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->provider) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->provider)); + _mem_save_provider_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->provider, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->provider)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_provider_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DriverInfo6(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo6 *r) +{ + ndr_print_struct(ndr, name, "spoolss_DriverInfo6"); + ndr->depth++; + ndr_print_spoolss_DriverOSVersion(ndr, "version", r->version); + ndr_print_ptr(ndr, "driver_name", r->driver_name); + ndr->depth++; + if (r->driver_name) { + ndr_print_string(ndr, "driver_name", r->driver_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "architecture", r->architecture); + ndr->depth++; + if (r->architecture) { + ndr_print_string(ndr, "architecture", r->architecture); + } + ndr->depth--; + ndr_print_ptr(ndr, "driver_path", r->driver_path); + ndr->depth++; + if (r->driver_path) { + ndr_print_string(ndr, "driver_path", r->driver_path); + } + ndr->depth--; + ndr_print_ptr(ndr, "data_file", r->data_file); + ndr->depth++; + if (r->data_file) { + ndr_print_string(ndr, "data_file", r->data_file); + } + ndr->depth--; + ndr_print_ptr(ndr, "config_file", r->config_file); + ndr->depth++; + if (r->config_file) { + ndr_print_string(ndr, "config_file", r->config_file); + } + ndr->depth--; + ndr_print_ptr(ndr, "help_file", r->help_file); + ndr->depth++; + if (r->help_file) { + ndr_print_string(ndr, "help_file", r->help_file); + } + ndr->depth--; + ndr_print_ptr(ndr, "dependent_files", r->dependent_files); + ndr->depth++; + if (r->dependent_files) { + ndr_print_string_array(ndr, "dependent_files", r->dependent_files); + } + ndr->depth--; + ndr_print_ptr(ndr, "monitor_name", r->monitor_name); + ndr->depth++; + if (r->monitor_name) { + ndr_print_string(ndr, "monitor_name", r->monitor_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "default_datatype", r->default_datatype); + ndr->depth++; + if (r->default_datatype) { + ndr_print_string(ndr, "default_datatype", r->default_datatype); + } + ndr->depth--; + ndr_print_ptr(ndr, "previous_names", r->previous_names); + ndr->depth++; + if (r->previous_names) { + ndr_print_string_array(ndr, "previous_names", r->previous_names); + } + ndr->depth--; + ndr_print_NTTIME(ndr, "driver_data", r->driver_data); + ndr_print_hyper(ndr, "driver_version", r->driver_version); + ndr_print_ptr(ndr, "manufacturer_name", r->manufacturer_name); + ndr->depth++; + if (r->manufacturer_name) { + ndr_print_string(ndr, "manufacturer_name", r->manufacturer_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "manufacturer_url", r->manufacturer_url); + ndr->depth++; + if (r->manufacturer_url) { + ndr_print_string(ndr, "manufacturer_url", r->manufacturer_url); + } + ndr->depth--; + ndr_print_ptr(ndr, "hardware_id", r->hardware_id); + ndr->depth++; + if (r->hardware_id) { + ndr_print_string(ndr, "hardware_id", r->hardware_id); + } + ndr->depth--; + ndr_print_ptr(ndr, "provider", r->provider); + ndr->depth++; + if (r->provider) { + ndr_print_string(ndr, "provider", r->provider); + } + ndr->depth--; + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_DriverInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr); + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 1: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_DriverInfo1(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_DriverInfo2(ndr, NDR_SCALARS, &r->info2)); + break; } + + case 3: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_DriverInfo3(ndr, NDR_SCALARS, &r->info3)); + break; } + + case 4: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_DriverInfo4(ndr, NDR_SCALARS, &r->info4)); + break; } + + case 5: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_DriverInfo5(ndr, NDR_SCALARS, &r->info5)); + break; } + + case 6: { + NDR_CHECK(ndr_push_align(ndr, 8)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_DriverInfo6(ndr, NDR_SCALARS, &r->info6)); + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + NDR_CHECK(ndr_push_spoolss_DriverInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + case 2: + NDR_CHECK(ndr_push_spoolss_DriverInfo2(ndr, NDR_BUFFERS, &r->info2)); + break; + + case 3: + NDR_CHECK(ndr_push_spoolss_DriverInfo3(ndr, NDR_BUFFERS, &r->info3)); + break; + + case 4: + NDR_CHECK(ndr_push_spoolss_DriverInfo4(ndr, NDR_BUFFERS, &r->info4)); + break; + + case 5: + NDR_CHECK(ndr_push_spoolss_DriverInfo5(ndr, NDR_BUFFERS, &r->info5)); + break; + + case 6: + NDR_CHECK(ndr_push_spoolss_DriverInfo6(ndr, NDR_BUFFERS, &r->info6)); + break; + + default: + break; + + } + } + ndr_push_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_DriverInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset(ndr); + int level; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + switch (level) { + case 1: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_DriverInfo1(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_DriverInfo2(ndr, NDR_SCALARS, &r->info2)); + break; } + + case 3: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_DriverInfo3(ndr, NDR_SCALARS, &r->info3)); + break; } + + case 4: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_DriverInfo4(ndr, NDR_SCALARS, &r->info4)); + break; } + + case 5: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_DriverInfo5(ndr, NDR_SCALARS, &r->info5)); + break; } + + case 6: { + NDR_CHECK(ndr_pull_align(ndr, 8)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_DriverInfo6(ndr, NDR_SCALARS, &r->info6)); + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + NDR_CHECK(ndr_pull_spoolss_DriverInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + case 2: + NDR_CHECK(ndr_pull_spoolss_DriverInfo2(ndr, NDR_BUFFERS, &r->info2)); + break; + + case 3: + NDR_CHECK(ndr_pull_spoolss_DriverInfo3(ndr, NDR_BUFFERS, &r->info3)); + break; + + case 4: + NDR_CHECK(ndr_pull_spoolss_DriverInfo4(ndr, NDR_BUFFERS, &r->info4)); + break; + + case 5: + NDR_CHECK(ndr_pull_spoolss_DriverInfo5(ndr, NDR_BUFFERS, &r->info5)); + break; + + case 6: + NDR_CHECK(ndr_pull_spoolss_DriverInfo6(ndr, NDR_BUFFERS, &r->info6)); + break; + + default: + break; + + } + } + ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DriverInfo(struct ndr_print *ndr, const char *name, const union spoolss_DriverInfo *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_DriverInfo"); + switch (level) { + case 1: + ndr_print_spoolss_DriverInfo1(ndr, "info1", &r->info1); + break; + + case 2: + ndr_print_spoolss_DriverInfo2(ndr, "info2", &r->info2); + break; + + case 3: + ndr_print_spoolss_DriverInfo3(ndr, "info3", &r->info3); + break; + + case 4: + ndr_print_spoolss_DriverInfo4(ndr, "info4", &r->info4); + break; + + case 5: + ndr_print_spoolss_DriverInfo5(ndr, "info5", &r->info5); + break; + + case 6: + ndr_print_spoolss_DriverInfo6(ndr, "info6", &r->info6); + break; + + default: + break; + + } +} + +static enum ndr_err_code ndr_push_spoolss_DriverDirectoryInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverDirectoryInfo1 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->directory_name)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DriverDirectoryInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverDirectoryInfo1 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->directory_name)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DriverDirectoryInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_DriverDirectoryInfo1 *r) +{ + ndr_print_struct(ndr, name, "spoolss_DriverDirectoryInfo1"); + ndr->depth++; + ndr_print_string(ndr, "directory_name", r->directory_name); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverDirectoryInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_DriverDirectoryInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr); + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 1: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_DriverDirectoryInfo1(ndr, NDR_SCALARS, &r->info1)); + break; } + + default: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_DriverDirectoryInfo1(ndr, NDR_SCALARS, &r->info1)); + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + break; + + default: + break; + + } + } + ndr_push_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverDirectoryInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_DriverDirectoryInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset(ndr); + int level; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + switch (level) { + case 1: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_DriverDirectoryInfo1(ndr, NDR_SCALARS, &r->info1)); + break; } + + default: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_DriverDirectoryInfo1(ndr, NDR_SCALARS, &r->info1)); + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + break; + + default: + break; + + } + } + ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DriverDirectoryInfo(struct ndr_print *ndr, const char *name, const union spoolss_DriverDirectoryInfo *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_DriverDirectoryInfo"); + switch (level) { + case 1: + ndr_print_spoolss_DriverDirectoryInfo1(ndr, "info1", &r->info1); + break; + + default: + ndr_print_spoolss_DriverDirectoryInfo1(ndr, "info1", &r->info1); + break; + + } +} + +_PUBLIC_ size_t ndr_size_spoolss_DriverDirectoryInfo(const union spoolss_DriverDirectoryInfo *r, uint32_t level, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_union(r, flags, level, (ndr_push_flags_fn_t)ndr_push_spoolss_DriverDirectoryInfo, ic); +} + +static enum ndr_err_code ndr_push_spoolss_PrintProcessorInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrintProcessorInfo1 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->print_processor_name)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->print_processor_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->print_processor_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->print_processor_name)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PrintProcessorInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrintProcessorInfo1 *r) +{ + uint32_t _ptr_print_processor_name; + TALLOC_CTX *_mem_save_print_processor_name_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_print_processor_name)); + if (_ptr_print_processor_name) { + NDR_PULL_ALLOC(ndr, r->print_processor_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->print_processor_name, _ptr_print_processor_name)); + } else { + r->print_processor_name = NULL; + } + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->print_processor_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->print_processor_name)); + _mem_save_print_processor_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->print_processor_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->print_processor_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_print_processor_name_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrintProcessorInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_PrintProcessorInfo1 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrintProcessorInfo1"); + ndr->depth++; + ndr_print_ptr(ndr, "print_processor_name", r->print_processor_name); + ndr->depth++; + if (r->print_processor_name) { + ndr_print_string(ndr, "print_processor_name", r->print_processor_name); + } + ndr->depth--; + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrintProcessorInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_PrintProcessorInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr); + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 1: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_PrintProcessorInfo1(ndr, NDR_SCALARS, &r->info1)); + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + NDR_CHECK(ndr_push_spoolss_PrintProcessorInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + default: + break; + + } + } + ndr_push_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrintProcessorInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_PrintProcessorInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset(ndr); + int level; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + switch (level) { + case 1: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_PrintProcessorInfo1(ndr, NDR_SCALARS, &r->info1)); + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + NDR_CHECK(ndr_pull_spoolss_PrintProcessorInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + default: + break; + + } + } + ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrintProcessorInfo(struct ndr_print *ndr, const char *name, const union spoolss_PrintProcessorInfo *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_PrintProcessorInfo"); + switch (level) { + case 1: + ndr_print_spoolss_PrintProcessorInfo1(ndr, "info1", &r->info1); + break; + + default: + break; + + } +} + +static enum ndr_err_code ndr_push_spoolss_DocumentInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DocumentInfo1 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->document_name)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->output_file)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->datatype)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->document_name) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->document_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->document_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->document_name, ndr_charset_length(r->document_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + if (r->output_file) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->output_file, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->output_file, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->output_file, ndr_charset_length(r->output_file, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + if (r->datatype) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->datatype, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->datatype, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->datatype, ndr_charset_length(r->datatype, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DocumentInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DocumentInfo1 *r) +{ + uint32_t _ptr_document_name; + TALLOC_CTX *_mem_save_document_name_0; + uint32_t _ptr_output_file; + TALLOC_CTX *_mem_save_output_file_0; + uint32_t _ptr_datatype; + TALLOC_CTX *_mem_save_datatype_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_document_name)); + if (_ptr_document_name) { + NDR_PULL_ALLOC(ndr, r->document_name); + } else { + r->document_name = NULL; + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_output_file)); + if (_ptr_output_file) { + NDR_PULL_ALLOC(ndr, r->output_file); + } else { + r->output_file = NULL; + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_datatype)); + if (_ptr_datatype) { + NDR_PULL_ALLOC(ndr, r->datatype); + } else { + r->datatype = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->document_name) { + _mem_save_document_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->document_name, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->document_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->document_name)); + if (ndr_get_array_length(ndr, &r->document_name) > ndr_get_array_size(ndr, &r->document_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->document_name), ndr_get_array_length(ndr, &r->document_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->document_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->document_name, ndr_get_array_length(ndr, &r->document_name), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_document_name_0, 0); + } + if (r->output_file) { + _mem_save_output_file_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->output_file, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->output_file)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->output_file)); + if (ndr_get_array_length(ndr, &r->output_file) > ndr_get_array_size(ndr, &r->output_file)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->output_file), ndr_get_array_length(ndr, &r->output_file)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->output_file), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->output_file, ndr_get_array_length(ndr, &r->output_file), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_output_file_0, 0); + } + if (r->datatype) { + _mem_save_datatype_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->datatype, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->datatype)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->datatype)); + if (ndr_get_array_length(ndr, &r->datatype) > ndr_get_array_size(ndr, &r->datatype)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->datatype), ndr_get_array_length(ndr, &r->datatype)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->datatype), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->datatype, ndr_get_array_length(ndr, &r->datatype), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_datatype_0, 0); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DocumentInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_DocumentInfo1 *r) +{ + ndr_print_struct(ndr, name, "spoolss_DocumentInfo1"); + ndr->depth++; + ndr_print_ptr(ndr, "document_name", r->document_name); + ndr->depth++; + if (r->document_name) { + ndr_print_string(ndr, "document_name", r->document_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "output_file", r->output_file); + ndr->depth++; + if (r->output_file) { + ndr_print_string(ndr, "output_file", r->output_file); + } + ndr->depth--; + ndr_print_ptr(ndr, "datatype", r->datatype); + ndr->depth++; + if (r->datatype) { + ndr_print_string(ndr, "datatype", r->datatype); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DocumentInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_DocumentInfo *r) +{ + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, level)); + switch (level) { + case 1: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info1)); + break; } + + case 2: { + break; } + + case 3: { + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 1: + if (r->info1) { + NDR_CHECK(ndr_push_spoolss_DocumentInfo1(ndr, NDR_SCALARS|NDR_BUFFERS, r->info1)); + } + break; + + case 2: + break; + + case 3: + break; + + default: + break; + + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DocumentInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_DocumentInfo *r) +{ + int level; + uint32_t _level; + TALLOC_CTX *_mem_save_info1_0; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &_level)); + if (_level != level) { + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u for r", _level); + } + switch (level) { + case 1: { + uint32_t _ptr_info1; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info1)); + if (_ptr_info1) { + NDR_PULL_ALLOC(ndr, r->info1); + } else { + r->info1 = NULL; + } + break; } + + case 2: { + break; } + + case 3: { + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + switch (level) { + case 1: + if (r->info1) { + _mem_save_info1_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info1, 0); + NDR_CHECK(ndr_pull_spoolss_DocumentInfo1(ndr, NDR_SCALARS|NDR_BUFFERS, r->info1)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info1_0, 0); + } + break; + + case 2: + break; + + case 3: + break; + + default: + break; + + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DocumentInfo(struct ndr_print *ndr, const char *name, const union spoolss_DocumentInfo *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_DocumentInfo"); + switch (level) { + case 1: + ndr_print_ptr(ndr, "info1", r->info1); + ndr->depth++; + if (r->info1) { + ndr_print_spoolss_DocumentInfo1(ndr, "info1", r->info1); + } + ndr->depth--; + break; + + case 2: + break; + + case 3: + break; + + default: + break; + + } +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_OSVersion(struct ndr_push *ndr, int ndr_flags, const struct spoolss_OSVersion *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_spoolss_OSVersion(r, ndr->iconv_convenience, ndr->flags))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->major)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->minor)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->build)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 2)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + { + struct ndr_push *_ndr_extra_string; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_extra_string, 0, 256)); + NDR_CHECK(ndr_push_string(_ndr_extra_string, NDR_SCALARS, r->extra_string)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_extra_string, 0, 256)); + } + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_OSVersion(struct ndr_pull *ndr, int ndr_flags, struct spoolss_OSVersion *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_ndr_size)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->major)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->minor)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->build)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + { + struct ndr_pull *_ndr_extra_string; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_extra_string, 0, 256)); + NDR_CHECK(ndr_pull_string(_ndr_extra_string, NDR_SCALARS, &r->extra_string)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_extra_string, 0, 256)); + } + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_OSVersion(struct ndr_print *ndr, const char *name, const struct spoolss_OSVersion *r) +{ + ndr_print_struct(ndr, name, "spoolss_OSVersion"); + ndr->depth++; + ndr_print_uint32(ndr, "_ndr_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_spoolss_OSVersion(r, ndr->iconv_convenience, ndr->flags):r->_ndr_size); + ndr_print_uint32(ndr, "major", r->major); + ndr_print_uint32(ndr, "minor", r->minor); + ndr_print_uint32(ndr, "build", r->build); + ndr_print_uint32(ndr, "unknown", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?2:r->unknown); + ndr_print_string(ndr, "extra_string", r->extra_string); + ndr->depth--; +} + +_PUBLIC_ size_t ndr_size_spoolss_OSVersion(const struct spoolss_OSVersion *r, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_OSVersion, ic); +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_OSVersionEx(struct ndr_push *ndr, int ndr_flags, const struct spoolss_OSVersionEx *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_spoolss_OSVersionEx(r, ndr->iconv_convenience, ndr->flags))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->major)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->minor)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->build)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 2)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + { + struct ndr_push *_ndr_extra_string; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_extra_string, 0, 256)); + NDR_CHECK(ndr_push_string(_ndr_extra_string, NDR_SCALARS, r->extra_string)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_extra_string, 0, 256)); + } + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown2)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->unknown3)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_OSVersionEx(struct ndr_pull *ndr, int ndr_flags, struct spoolss_OSVersionEx *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_ndr_size)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->major)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->minor)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->build)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown1)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + { + struct ndr_pull *_ndr_extra_string; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_extra_string, 0, 256)); + NDR_CHECK(ndr_pull_string(_ndr_extra_string, NDR_SCALARS, &r->extra_string)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_extra_string, 0, 256)); + } + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown2)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->unknown3)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_OSVersionEx(struct ndr_print *ndr, const char *name, const struct spoolss_OSVersionEx *r) +{ + ndr_print_struct(ndr, name, "spoolss_OSVersionEx"); + ndr->depth++; + ndr_print_uint32(ndr, "_ndr_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_spoolss_OSVersionEx(r, ndr->iconv_convenience, ndr->flags):r->_ndr_size); + ndr_print_uint32(ndr, "major", r->major); + ndr_print_uint32(ndr, "minor", r->minor); + ndr_print_uint32(ndr, "build", r->build); + ndr_print_uint32(ndr, "unknown1", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?2:r->unknown1); + ndr_print_string(ndr, "extra_string", r->extra_string); + ndr_print_uint32(ndr, "unknown2", r->unknown2); + ndr_print_uint32(ndr, "unknown3", r->unknown3); + ndr->depth--; +} + +_PUBLIC_ size_t ndr_size_spoolss_OSVersionEx(const struct spoolss_OSVersionEx *r, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_OSVersionEx, ic); +} + +static enum ndr_err_code ndr_push_spoolss_PrinterDataType(struct ndr_push *ndr, int ndr_flags, enum spoolss_PrinterDataType r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PrinterDataType(struct ndr_pull *ndr, int ndr_flags, enum spoolss_PrinterDataType *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrinterDataType(struct ndr_print *ndr, const char *name, enum spoolss_PrinterDataType r) +{ + const char *val = NULL; + + switch (r) { + case SPOOLSS_PRINTER_DATA_TYPE_NULL: val = "SPOOLSS_PRINTER_DATA_TYPE_NULL"; break; + case SPOOLSS_PRINTER_DATA_TYPE_STRING: val = "SPOOLSS_PRINTER_DATA_TYPE_STRING"; break; + case SPOOLSS_PRINTER_DATA_TYPE_BINARY: val = "SPOOLSS_PRINTER_DATA_TYPE_BINARY"; break; + case SPOOLSS_PRINTER_DATA_TYPE_UINT32: val = "SPOOLSS_PRINTER_DATA_TYPE_UINT32"; break; + case SPOOLSS_PRINTER_DATA_TYPE_STRING_ARRAY: val = "SPOOLSS_PRINTER_DATA_TYPE_STRING_ARRAY"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrinterData(struct ndr_push *ndr, int ndr_flags, const union spoolss_PrinterData *r) +{ + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case SPOOLSS_PRINTER_DATA_TYPE_NULL: { + break; } + + case SPOOLSS_PRINTER_DATA_TYPE_STRING: { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->string)); + ndr->flags = _flags_save_string; + } + break; } + + case SPOOLSS_PRINTER_DATA_TYPE_BINARY: { + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->binary)); + ndr->flags = _flags_save_DATA_BLOB; + } + break; } + + case SPOOLSS_PRINTER_DATA_TYPE_UINT32: { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->value)); + break; } + + case SPOOLSS_PRINTER_DATA_TYPE_STRING_ARRAY: { + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string_array(ndr, NDR_SCALARS, r->string_array)); + ndr->flags = _flags_save_string_array; + } + break; } + + default: { + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->data)); + ndr->flags = _flags_save_DATA_BLOB; + } + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case SPOOLSS_PRINTER_DATA_TYPE_NULL: + break; + + case SPOOLSS_PRINTER_DATA_TYPE_STRING: + break; + + case SPOOLSS_PRINTER_DATA_TYPE_BINARY: + break; + + case SPOOLSS_PRINTER_DATA_TYPE_UINT32: + break; + + case SPOOLSS_PRINTER_DATA_TYPE_STRING_ARRAY: + break; + + default: + break; + + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrinterData(struct ndr_pull *ndr, int ndr_flags, union spoolss_PrinterData *r) +{ + int level; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + switch (level) { + case SPOOLSS_PRINTER_DATA_TYPE_NULL: { + break; } + + case SPOOLSS_PRINTER_DATA_TYPE_STRING: { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->string)); + ndr->flags = _flags_save_string; + } + break; } + + case SPOOLSS_PRINTER_DATA_TYPE_BINARY: { + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->binary)); + ndr->flags = _flags_save_DATA_BLOB; + } + break; } + + case SPOOLSS_PRINTER_DATA_TYPE_UINT32: { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->value)); + break; } + + case SPOOLSS_PRINTER_DATA_TYPE_STRING_ARRAY: { + { + uint32_t _flags_save_string_array = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string_array(ndr, NDR_SCALARS, &r->string_array)); + ndr->flags = _flags_save_string_array; + } + break; } + + default: { + { + uint32_t _flags_save_DATA_BLOB = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_REMAINING); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->data)); + ndr->flags = _flags_save_DATA_BLOB; + } + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + switch (level) { + case SPOOLSS_PRINTER_DATA_TYPE_NULL: + break; + + case SPOOLSS_PRINTER_DATA_TYPE_STRING: + break; + + case SPOOLSS_PRINTER_DATA_TYPE_BINARY: + break; + + case SPOOLSS_PRINTER_DATA_TYPE_UINT32: + break; + + case SPOOLSS_PRINTER_DATA_TYPE_STRING_ARRAY: + break; + + default: + break; + + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrinterData(struct ndr_print *ndr, const char *name, const union spoolss_PrinterData *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_PrinterData"); + switch (level) { + case SPOOLSS_PRINTER_DATA_TYPE_NULL: + break; + + case SPOOLSS_PRINTER_DATA_TYPE_STRING: + ndr_print_string(ndr, "string", r->string); + break; + + case SPOOLSS_PRINTER_DATA_TYPE_BINARY: + ndr_print_DATA_BLOB(ndr, "binary", r->binary); + break; + + case SPOOLSS_PRINTER_DATA_TYPE_UINT32: + ndr_print_uint32(ndr, "value", r->value); + break; + + case SPOOLSS_PRINTER_DATA_TYPE_STRING_ARRAY: + ndr_print_string_array(ndr, "string_array", r->string_array); + break; + + default: + ndr_print_DATA_BLOB(ndr, "data", r->data); + break; + + } +} + +_PUBLIC_ size_t ndr_size_spoolss_PrinterData(const union spoolss_PrinterData *r, uint32_t level, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_union(r, flags, level, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterData, ic); +} + +static enum ndr_err_code ndr_push_spoolss_FormFlags(struct ndr_push *ndr, int ndr_flags, enum spoolss_FormFlags r) +{ + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_FormFlags(struct ndr_pull *ndr, int ndr_flags, enum spoolss_FormFlags *r) +{ + uint32_t v; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_FormFlags(struct ndr_print *ndr, const char *name, enum spoolss_FormFlags r) +{ + const char *val = NULL; + + switch (r) { + case SPOOLSS_FORM_USER: val = "SPOOLSS_FORM_USER"; break; + case SPOOLSS_FORM_BUILTIN: val = "SPOOLSS_FORM_BUILTIN"; break; + case SPOOLSS_FORM_PRINTER: val = "SPOOLSS_FORM_PRINTER"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + +static enum ndr_err_code ndr_push_spoolss_FormSize(struct ndr_push *ndr, int ndr_flags, const struct spoolss_FormSize *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->width)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->height)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_FormSize(struct ndr_pull *ndr, int ndr_flags, struct spoolss_FormSize *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->width)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->height)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_FormSize(struct ndr_print *ndr, const char *name, const struct spoolss_FormSize *r) +{ + ndr_print_struct(ndr, name, "spoolss_FormSize"); + ndr->depth++; + ndr_print_uint32(ndr, "width", r->width); + ndr_print_uint32(ndr, "height", r->height); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_FormArea(struct ndr_push *ndr, int ndr_flags, const struct spoolss_FormArea *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->left)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->top)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->right)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->bottom)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_FormArea(struct ndr_pull *ndr, int ndr_flags, struct spoolss_FormArea *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->left)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->top)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->right)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->bottom)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_FormArea(struct ndr_print *ndr, const char *name, const struct spoolss_FormArea *r) +{ + ndr_print_struct(ndr, name, "spoolss_FormArea"); + ndr->depth++; + ndr_print_uint32(ndr, "left", r->left); + ndr_print_uint32(ndr, "top", r->top); + ndr_print_uint32(ndr, "right", r->right); + ndr_print_uint32(ndr, "bottom", r->bottom); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_FormInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_FormInfo1 *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)); + } + 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; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_FormInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_FormInfo1 *r) +{ + uint32_t _ptr_form_name; + TALLOC_CTX *_mem_save_form_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)); + } + 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; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_FormInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_FormInfo1 *r) +{ + ndr_print_struct(ndr, name, "spoolss_FormInfo1"); + 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->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); + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 1: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_FormInfo1(ndr, NDR_SCALARS, &r->info1)); + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + NDR_CHECK(ndr_push_spoolss_FormInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + default: + break; + + } + } + ndr_push_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_FormInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_FormInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset(ndr); + int level; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + switch (level) { + case 1: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_FormInfo1(ndr, NDR_SCALARS, &r->info1)); + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + NDR_CHECK(ndr_pull_spoolss_FormInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + default: + break; + + } + } + ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_FormInfo(struct ndr_print *ndr, const char *name, const union spoolss_FormInfo *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_FormInfo"); + switch (level) { + case 1: + ndr_print_spoolss_FormInfo1(ndr, "info1", &r->info1); + break; + + default: + break; + + } +} + +_PUBLIC_ size_t ndr_size_spoolss_FormInfo(const union spoolss_FormInfo *r, uint32_t level, struct smb_iconv_convenience *ic, int flags) +{ + return ndr_size_union(r, flags, level, (ndr_push_flags_fn_t)ndr_push_spoolss_FormInfo, ic); +} + +static enum ndr_err_code ndr_push_spoolss_AddFormInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_AddFormInfo1 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_spoolss_FormFlags(ndr, NDR_SCALARS, r->flags)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->form_name)); + NDR_CHECK(ndr_push_spoolss_FormSize(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_push_spoolss_FormArea(ndr, NDR_SCALARS, &r->area)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->form_name) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->form_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->form_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->form_name, ndr_charset_length(r->form_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_AddFormInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_AddFormInfo1 *r) +{ + uint32_t _ptr_form_name; + TALLOC_CTX *_mem_save_form_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)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_form_name)); + if (_ptr_form_name) { + NDR_PULL_ALLOC(ndr, r->form_name); + } else { + r->form_name = NULL; + } + NDR_CHECK(ndr_pull_spoolss_FormSize(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_spoolss_FormArea(ndr, NDR_SCALARS, &r->area)); + } + if (ndr_flags & NDR_BUFFERS) { + if (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_array_size(ndr, &r->form_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->form_name)); + if (ndr_get_array_length(ndr, &r->form_name) > ndr_get_array_size(ndr, &r->form_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->form_name), ndr_get_array_length(ndr, &r->form_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->form_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->form_name, ndr_get_array_length(ndr, &r->form_name), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_form_name_0, 0); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AddFormInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_AddFormInfo1 *r) +{ + ndr_print_struct(ndr, name, "spoolss_AddFormInfo1"); + 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->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_AddFormInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_AddFormInfo *r) +{ + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, level)); + switch (level) { + case 1: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->info1)); + break; } + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 1: + if (r->info1) { + NDR_CHECK(ndr_push_spoolss_AddFormInfo1(ndr, NDR_SCALARS|NDR_BUFFERS, r->info1)); + } + break; + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_AddFormInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_AddFormInfo *r) +{ + int level; + uint32_t _level; + TALLOC_CTX *_mem_save_info1_0; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &_level)); + if (_level != level) { + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u for r", _level); + } + switch (level) { + case 1: { + uint32_t _ptr_info1; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info1)); + if (_ptr_info1) { + NDR_PULL_ALLOC(ndr, r->info1); + } else { + r->info1 = NULL; + } + break; } + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + if (ndr_flags & NDR_BUFFERS) { + switch (level) { + case 1: + if (r->info1) { + _mem_save_info1_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->info1, 0); + NDR_CHECK(ndr_pull_spoolss_AddFormInfo1(ndr, NDR_SCALARS|NDR_BUFFERS, r->info1)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info1_0, 0); + } + break; + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AddFormInfo(struct ndr_print *ndr, const char *name, const union spoolss_AddFormInfo *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_AddFormInfo"); + switch (level) { + case 1: + ndr_print_ptr(ndr, "info1", r->info1); + ndr->depth++; + if (r->info1) { + ndr_print_spoolss_AddFormInfo1(ndr, "info1", r->info1); + } + ndr->depth--; + break; + + default: + ndr_print_bad_level(ndr, name, level); + } +} + +static enum ndr_err_code ndr_push_spoolss_PortInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfo1 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->port_name)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->port_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->port_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->port_name)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PortInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfo1 *r) +{ + uint32_t _ptr_port_name; + TALLOC_CTX *_mem_save_port_name_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_port_name)); + if (_ptr_port_name) { + NDR_PULL_ALLOC(ndr, r->port_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->port_name, _ptr_port_name)); + } else { + r->port_name = NULL; + } + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->port_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->port_name)); + _mem_save_port_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->port_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->port_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_port_name_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PortInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_PortInfo1 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PortInfo1"); + ndr->depth++; + ndr_print_ptr(ndr, "port_name", r->port_name); + ndr->depth++; + if (r->port_name) { + ndr_print_string(ndr, "port_name", r->port_name); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_PortType(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_PortType(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_PortType(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_PORT_TYPE_WRITE", SPOOLSS_PORT_TYPE_WRITE, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SPOOLSS_PORT_TYPE_READ", SPOOLSS_PORT_TYPE_READ, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SPOOLSS_PORT_TYPE_REDIRECTED", SPOOLSS_PORT_TYPE_REDIRECTED, r); + ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SPOOLSS_PORT_TYPE_NET_ATTACHED", SPOOLSS_PORT_TYPE_NET_ATTACHED, r); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_PortInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfo2 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->port_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->monitor_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->description)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_spoolss_PortType(ndr, NDR_SCALARS, r->port_type)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->reserved)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->port_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->port_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->port_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->monitor_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->monitor_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->monitor_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->description) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->description)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->description)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PortInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfo2 *r) +{ + uint32_t _ptr_port_name; + TALLOC_CTX *_mem_save_port_name_0; + uint32_t _ptr_monitor_name; + TALLOC_CTX *_mem_save_monitor_name_0; + uint32_t _ptr_description; + TALLOC_CTX *_mem_save_description_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_port_name)); + if (_ptr_port_name) { + NDR_PULL_ALLOC(ndr, r->port_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->port_name, _ptr_port_name)); + } else { + r->port_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_monitor_name)); + if (_ptr_monitor_name) { + NDR_PULL_ALLOC(ndr, r->monitor_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->monitor_name, _ptr_monitor_name)); + } else { + r->monitor_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_description)); + if (_ptr_description) { + NDR_PULL_ALLOC(ndr, r->description); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->description, _ptr_description)); + } else { + r->description = NULL; + } + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_spoolss_PortType(ndr, NDR_SCALARS, &r->port_type)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->reserved)); + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->port_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->port_name)); + _mem_save_port_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->port_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->port_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_port_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->monitor_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->monitor_name)); + _mem_save_monitor_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->monitor_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->monitor_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_monitor_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->description) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->description)); + _mem_save_description_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->description, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->description)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_description_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PortInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_PortInfo2 *r) +{ + ndr_print_struct(ndr, name, "spoolss_PortInfo2"); + ndr->depth++; + ndr_print_ptr(ndr, "port_name", r->port_name); + ndr->depth++; + if (r->port_name) { + ndr_print_string(ndr, "port_name", r->port_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "monitor_name", r->monitor_name); + ndr->depth++; + if (r->monitor_name) { + ndr_print_string(ndr, "monitor_name", r->monitor_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "description", r->description); + ndr->depth++; + if (r->description) { + ndr_print_string(ndr, "description", r->description); + } + ndr->depth--; + ndr_print_spoolss_PortType(ndr, "port_type", r->port_type); + ndr_print_uint32(ndr, "reserved", r->reserved); + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PortInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_PortInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr); + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 1: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_PortInfo1(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_PortInfo2(ndr, NDR_SCALARS, &r->info2)); + break; } + + case 3: { + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + NDR_CHECK(ndr_push_spoolss_PortInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + case 2: + NDR_CHECK(ndr_push_spoolss_PortInfo2(ndr, NDR_BUFFERS, &r->info2)); + break; + + case 3: + break; + + default: + break; + + } + } + ndr_push_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PortInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_PortInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset(ndr); + int level; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + switch (level) { + case 1: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_PortInfo1(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_PortInfo2(ndr, NDR_SCALARS, &r->info2)); + break; } + + case 3: { + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + NDR_CHECK(ndr_pull_spoolss_PortInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + case 2: + NDR_CHECK(ndr_pull_spoolss_PortInfo2(ndr, NDR_BUFFERS, &r->info2)); + break; + + case 3: + break; + + default: + break; + + } + } + ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PortInfo(struct ndr_print *ndr, const char *name, const union spoolss_PortInfo *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_PortInfo"); + switch (level) { + case 1: + ndr_print_spoolss_PortInfo1(ndr, "info1", &r->info1); + break; + + case 2: + ndr_print_spoolss_PortInfo2(ndr, "info2", &r->info2); + break; + + case 3: + break; + + default: + break; + + } +} + +static enum ndr_err_code ndr_push_spoolss_MonitorInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_MonitorInfo1 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->monitor_name)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->monitor_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->monitor_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->monitor_name)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_MonitorInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_MonitorInfo1 *r) +{ + uint32_t _ptr_monitor_name; + TALLOC_CTX *_mem_save_monitor_name_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_monitor_name)); + if (_ptr_monitor_name) { + NDR_PULL_ALLOC(ndr, r->monitor_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->monitor_name, _ptr_monitor_name)); + } else { + r->monitor_name = NULL; + } + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->monitor_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->monitor_name)); + _mem_save_monitor_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->monitor_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->monitor_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_monitor_name_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_MonitorInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_MonitorInfo1 *r) +{ + ndr_print_struct(ndr, name, "spoolss_MonitorInfo1"); + ndr->depth++; + ndr_print_ptr(ndr, "monitor_name", r->monitor_name); + ndr->depth++; + if (r->monitor_name) { + ndr_print_string(ndr, "monitor_name", r->monitor_name); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_MonitorInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_MonitorInfo2 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->monitor_name)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->environment)); + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_relative_ptr1(ndr, r->dll_name)); + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->monitor_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->monitor_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->monitor_name)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->environment) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->environment)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->environment)); + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->dll_name) { + NDR_CHECK(ndr_push_relative_ptr2(ndr, r->dll_name)); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->dll_name)); + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_MonitorInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_MonitorInfo2 *r) +{ + uint32_t _ptr_monitor_name; + TALLOC_CTX *_mem_save_monitor_name_0; + uint32_t _ptr_environment; + TALLOC_CTX *_mem_save_environment_0; + uint32_t _ptr_dll_name; + TALLOC_CTX *_mem_save_dll_name_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_monitor_name)); + if (_ptr_monitor_name) { + NDR_PULL_ALLOC(ndr, r->monitor_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->monitor_name, _ptr_monitor_name)); + } else { + r->monitor_name = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_environment)); + if (_ptr_environment) { + NDR_PULL_ALLOC(ndr, r->environment); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->environment, _ptr_environment)); + } else { + r->environment = NULL; + } + ndr->flags = _flags_save_string; + } + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_dll_name)); + if (_ptr_dll_name) { + NDR_PULL_ALLOC(ndr, r->dll_name); + NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->dll_name, _ptr_dll_name)); + } else { + r->dll_name = NULL; + } + ndr->flags = _flags_save_string; + } + } + if (ndr_flags & NDR_BUFFERS) { + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM); + if (r->monitor_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->monitor_name)); + _mem_save_monitor_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->monitor_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->monitor_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_monitor_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->environment) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->environment)); + _mem_save_environment_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->environment, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->environment)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_environment_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->dll_name) { + uint32_t _relative_save_offset; + _relative_save_offset = ndr->offset; + NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->dll_name)); + _mem_save_dll_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->dll_name, 0); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->dll_name)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dll_name_0, 0); + ndr->offset = _relative_save_offset; + } + ndr->flags = _flags_save_string; + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_MonitorInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_MonitorInfo2 *r) +{ + ndr_print_struct(ndr, name, "spoolss_MonitorInfo2"); + ndr->depth++; + ndr_print_ptr(ndr, "monitor_name", r->monitor_name); + ndr->depth++; + if (r->monitor_name) { + ndr_print_string(ndr, "monitor_name", r->monitor_name); + } + ndr->depth--; + ndr_print_ptr(ndr, "environment", r->environment); + ndr->depth++; + if (r->environment) { + ndr_print_string(ndr, "environment", r->environment); + } + ndr->depth--; + ndr_print_ptr(ndr, "dll_name", r->dll_name); + ndr->depth++; + if (r->dll_name) { + ndr_print_string(ndr, "dll_name", r->dll_name); + } + ndr->depth--; + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_MonitorInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_MonitorInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr); + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 1: { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_push_spoolss_MonitorInfo1(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_MonitorInfo2(ndr, NDR_SCALARS, &r->info2)); + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + NDR_CHECK(ndr_push_spoolss_MonitorInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + case 2: + NDR_CHECK(ndr_push_spoolss_MonitorInfo2(ndr, NDR_BUFFERS, &r->info2)); + break; + + default: + break; + + } + } + ndr_push_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_MonitorInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_MonitorInfo *r) +{ + uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset(ndr); + int level; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + switch (level) { + case 1: { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset)); + NDR_CHECK(ndr_pull_spoolss_MonitorInfo1(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_MonitorInfo2(ndr, NDR_SCALARS, &r->info2)); + break; } + + default: { + break; } + + } + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, r)); + switch (level) { + case 1: + NDR_CHECK(ndr_pull_spoolss_MonitorInfo1(ndr, NDR_BUFFERS, &r->info1)); + break; + + case 2: + NDR_CHECK(ndr_pull_spoolss_MonitorInfo2(ndr, NDR_BUFFERS, &r->info2)); + break; + + default: + break; + + } + } + ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset); + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_MonitorInfo(struct ndr_print *ndr, const char *name, const union spoolss_MonitorInfo *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_MonitorInfo"); + switch (level) { + case 1: + ndr_print_spoolss_MonitorInfo1(ndr, "info1", &r->info1); + break; + + case 2: + ndr_print_spoolss_MonitorInfo2(ndr, "info2", &r->info2); + break; + + default: + break; + + } +} + +static enum ndr_err_code ndr_push_spoolss_Field(struct ndr_push *ndr, int ndr_flags, enum spoolss_Field r) +{ + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_Field(struct ndr_pull *ndr, int ndr_flags, enum spoolss_Field *r) +{ + uint16_t v; + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_Field(struct ndr_print *ndr, const char *name, enum spoolss_Field r) +{ + const char *val = NULL; + + switch (r) { + case SPOOLSS_FIELD_SERVER_NAME: val = "SPOOLSS_FIELD_SERVER_NAME"; break; + case SPOOLSS_FIELD_PRINTER_NAME: val = "SPOOLSS_FIELD_PRINTER_NAME"; break; + case SPOOLSS_FIELD_SHARE_NAME: val = "SPOOLSS_FIELD_SHARE_NAME"; break; + case SPOOLSS_FIELD_PORT_NAME: val = "SPOOLSS_FIELD_PORT_NAME"; break; + case SPOOLSS_FIELD_DRIVER_NAME: val = "SPOOLSS_FIELD_DRIVER_NAME"; break; + case SPOOLSS_FIELD_COMMENT: val = "SPOOLSS_FIELD_COMMENT"; break; + case SPOOLSS_FIELD_LOCATION: val = "SPOOLSS_FIELD_LOCATION"; break; + case SPOOLSS_FIELD_DEVMODE: val = "SPOOLSS_FIELD_DEVMODE"; break; + case SPOOLSS_FIELD_SEPFILE: val = "SPOOLSS_FIELD_SEPFILE"; break; + case SPOOLSS_FIELD_PRINT_PROCESSOR: val = "SPOOLSS_FIELD_PRINT_PROCESSOR"; break; + case SPOOLSS_FIELD_PARAMETERS: val = "SPOOLSS_FIELD_PARAMETERS"; break; + case SPOOLSS_FIELD_DATATYPE: val = "SPOOLSS_FIELD_DATATYPE"; break; + case SPOOLSS_FIELD_SECURITY_DESCRIPTOR: val = "SPOOLSS_FIELD_SECURITY_DESCRIPTOR"; break; + case SPOOLSS_FIELD_ATTRIBUTES: val = "SPOOLSS_FIELD_ATTRIBUTES"; break; + case SPOOLSS_FIELD_PRIORITY: val = "SPOOLSS_FIELD_PRIORITY"; break; + case SPOOLSS_FIELD_DEFAULT_PRIORITY: val = "SPOOLSS_FIELD_DEFAULT_PRIORITY"; break; + case SPOOLSS_FIELD_START_TIME: val = "SPOOLSS_FIELD_START_TIME"; break; + case SPOOLSS_FIELD_UNTIL_TIME: val = "SPOOLSS_FIELD_UNTIL_TIME"; break; + case SPOOLSS_FIELD_STATUS: val = "SPOOLSS_FIELD_STATUS"; break; + case SPOOLSS_FIELD_STATUS_STRING: val = "SPOOLSS_FIELD_STATUS_STRING"; break; + case SPOOLSS_FIELD_CJOBS: val = "SPOOLSS_FIELD_CJOBS"; break; + case SPOOLSS_FIELD_AVERAGE_PPM: val = "SPOOLSS_FIELD_AVERAGE_PPM"; break; + case SPOOLSS_FIELD_TOTAL_PAGES: val = "SPOOLSS_FIELD_TOTAL_PAGES"; break; + case SPOOLSS_FIELD_PAGES_PRINTED: val = "SPOOLSS_FIELD_PAGES_PRINTED"; break; + case SPOOLSS_FIELD_TOTAL_BYTES: val = "SPOOLSS_FIELD_TOTAL_BYTES"; break; + case SPOOLSS_FIELD_BYTES_PRINTED: val = "SPOOLSS_FIELD_BYTES_PRINTED"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + +static enum ndr_err_code ndr_push_spoolss_NotifyType(struct ndr_push *ndr, int ndr_flags, enum spoolss_NotifyType r) +{ + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r)); + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_NotifyType(struct ndr_pull *ndr, int ndr_flags, enum spoolss_NotifyType *r) +{ + uint16_t v; + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &v)); + *r = v; + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_NotifyType(struct ndr_print *ndr, const char *name, enum spoolss_NotifyType r) +{ + const char *val = NULL; + + switch (r) { + case SPOOLSS_NOTIFY_PRINTER: val = "SPOOLSS_NOTIFY_PRINTER"; break; + case SPOOLSS_NOTIFY_JOB: val = "SPOOLSS_NOTIFY_JOB"; break; + } + ndr_print_enum(ndr, name, "ENUM", val, r); +} + +static enum ndr_err_code ndr_push_spoolss_NotifyOptionsArray(struct ndr_push *ndr, int ndr_flags, const struct spoolss_NotifyOptionsArray *r) +{ + uint32_t cntr_fields_1; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_spoolss_NotifyType(ndr, NDR_SCALARS, r->type)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->u1)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->u2)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->u3)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->fields)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->fields) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count)); + for (cntr_fields_1 = 0; cntr_fields_1 < r->count; cntr_fields_1++) { + NDR_CHECK(ndr_push_spoolss_Field(ndr, NDR_SCALARS, r->fields[cntr_fields_1])); + } + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_NotifyOptionsArray(struct ndr_pull *ndr, int ndr_flags, struct spoolss_NotifyOptionsArray *r) +{ + uint32_t _ptr_fields; + uint32_t cntr_fields_1; + TALLOC_CTX *_mem_save_fields_0; + TALLOC_CTX *_mem_save_fields_1; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_spoolss_NotifyType(ndr, NDR_SCALARS, &r->type)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->u1)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->u2)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->u3)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->count)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_fields)); + if (_ptr_fields) { + NDR_PULL_ALLOC(ndr, r->fields); + } else { + r->fields = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->fields) { + _mem_save_fields_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->fields, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->fields)); + NDR_PULL_ALLOC_N(ndr, r->fields, ndr_get_array_size(ndr, &r->fields)); + _mem_save_fields_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->fields, 0); + for (cntr_fields_1 = 0; cntr_fields_1 < r->count; cntr_fields_1++) { + NDR_CHECK(ndr_pull_spoolss_Field(ndr, NDR_SCALARS, &r->fields[cntr_fields_1])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_fields_1, 0); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_fields_0, 0); + } + if (r->fields) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->fields, r->count)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_NotifyOptionsArray(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyOptionsArray *r) +{ + uint32_t cntr_fields_1; + ndr_print_struct(ndr, name, "spoolss_NotifyOptionsArray"); + ndr->depth++; + ndr_print_spoolss_NotifyType(ndr, "type", r->type); + ndr_print_uint16(ndr, "u1", r->u1); + ndr_print_uint32(ndr, "u2", r->u2); + ndr_print_uint32(ndr, "u3", r->u3); + ndr_print_uint32(ndr, "count", r->count); + ndr_print_ptr(ndr, "fields", r->fields); + ndr->depth++; + if (r->fields) { + ndr->print(ndr, "%s: ARRAY(%d)", "fields", (int)r->count); + ndr->depth++; + for (cntr_fields_1=0;cntr_fields_1count;cntr_fields_1++) { + char *idx_1=NULL; + if (asprintf(&idx_1, "[%d]", cntr_fields_1) != -1) { + ndr_print_spoolss_Field(ndr, "fields", r->fields[cntr_fields_1]); + free(idx_1); + } + } + ndr->depth--; + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_NotifyOptionsContainer(struct ndr_push *ndr, int ndr_flags, const struct spoolss_NotifyOptionsContainer *r) +{ + uint32_t cntr_options_1; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->version)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->flags)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->options)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->options) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count)); + for (cntr_options_1 = 0; cntr_options_1 < r->count; cntr_options_1++) { + NDR_CHECK(ndr_push_spoolss_NotifyOptionsArray(ndr, NDR_SCALARS, &r->options[cntr_options_1])); + } + for (cntr_options_1 = 0; cntr_options_1 < r->count; cntr_options_1++) { + NDR_CHECK(ndr_push_spoolss_NotifyOptionsArray(ndr, NDR_BUFFERS, &r->options[cntr_options_1])); + } + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_NotifyOptionsContainer(struct ndr_pull *ndr, int ndr_flags, struct spoolss_NotifyOptionsContainer *r) +{ + uint32_t _ptr_options; + uint32_t cntr_options_1; + TALLOC_CTX *_mem_save_options_0; + TALLOC_CTX *_mem_save_options_1; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->version)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->flags)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->count)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_options)); + if (_ptr_options) { + NDR_PULL_ALLOC(ndr, r->options); + } else { + r->options = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->options) { + _mem_save_options_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->options, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->options)); + NDR_PULL_ALLOC_N(ndr, r->options, ndr_get_array_size(ndr, &r->options)); + _mem_save_options_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->options, 0); + for (cntr_options_1 = 0; cntr_options_1 < r->count; cntr_options_1++) { + NDR_CHECK(ndr_pull_spoolss_NotifyOptionsArray(ndr, NDR_SCALARS, &r->options[cntr_options_1])); + } + for (cntr_options_1 = 0; cntr_options_1 < r->count; cntr_options_1++) { + NDR_CHECK(ndr_pull_spoolss_NotifyOptionsArray(ndr, NDR_BUFFERS, &r->options[cntr_options_1])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_options_1, 0); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_options_0, 0); + } + if (r->options) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->options, r->count)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_NotifyOptionsContainer(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyOptionsContainer *r) +{ + uint32_t cntr_options_1; + ndr_print_struct(ndr, name, "spoolss_NotifyOptionsContainer"); + ndr->depth++; + ndr_print_uint32(ndr, "version", r->version); + ndr_print_uint32(ndr, "flags", r->flags); + ndr_print_uint32(ndr, "count", r->count); + ndr_print_ptr(ndr, "options", r->options); + ndr->depth++; + if (r->options) { + ndr->print(ndr, "%s: ARRAY(%d)", "options", (int)r->count); + ndr->depth++; + for (cntr_options_1=0;cntr_options_1count;cntr_options_1++) { + char *idx_1=NULL; + if (asprintf(&idx_1, "[%d]", cntr_options_1) != -1) { + ndr_print_spoolss_NotifyOptionsArray(ndr, "options", &r->options[cntr_options_1]); + free(idx_1); + } + } + ndr->depth--; + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_NotifyUTF16String(struct ndr_push *ndr, int ndr_flags, const struct spoolss_NotifyUTF16String *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->string)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->string) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size / 2)); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->string, r->size / 2, sizeof(uint16_t), CH_UTF16)); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_NotifyUTF16String(struct ndr_pull *ndr, int ndr_flags, struct spoolss_NotifyUTF16String *r) +{ + uint32_t _ptr_string; + TALLOC_CTX *_mem_save_string_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_string)); + if (_ptr_string) { + NDR_PULL_ALLOC(ndr, r->string); + } else { + r->string = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->string) { + _mem_save_string_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->string, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->string)); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->string, ndr_get_array_size(ndr, &r->string), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_string_0, 0); + } + if (r->string) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->string, r->size / 2)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_NotifyUTF16String(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyUTF16String *r) +{ + ndr_print_struct(ndr, name, "spoolss_NotifyUTF16String"); + ndr->depth++; + ndr_print_uint32(ndr, "size", r->size); + ndr_print_ptr(ndr, "string", r->string); + ndr->depth++; + if (r->string) { + ndr_print_string(ndr, "string", r->string); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_NotifyDOSString(struct ndr_push *ndr, int ndr_flags, const struct spoolss_NotifyDOSString *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->string)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->string) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size)); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->string, r->size, sizeof(uint8_t), CH_DOS)); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_NotifyDOSString(struct ndr_pull *ndr, int ndr_flags, struct spoolss_NotifyDOSString *r) +{ + uint32_t _ptr_string; + TALLOC_CTX *_mem_save_string_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_string)); + if (_ptr_string) { + NDR_PULL_ALLOC(ndr, r->string); + } else { + r->string = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->string) { + _mem_save_string_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->string, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->string)); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->string, ndr_get_array_size(ndr, &r->string), sizeof(uint8_t), CH_DOS)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_string_0, 0); + } + if (r->string) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->string, r->size)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_NotifyDOSString(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyDOSString *r) +{ + ndr_print_struct(ndr, name, "spoolss_NotifyDOSString"); + ndr->depth++; + ndr_print_uint32(ndr, "size", r->size); + ndr_print_ptr(ndr, "string", r->string); + ndr->depth++; + if (r->string) { + ndr_print_string(ndr, "string", r->string); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_NotifyBlobData(struct ndr_push *ndr, int ndr_flags, const struct spoolss_NotifyBlobData *r) +{ + uint32_t cntr_data_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 2)); + for (cntr_data_0 = 0; cntr_data_0 < 8; cntr_data_0++) { + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->data[cntr_data_0])); + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_NotifyBlobData(struct ndr_pull *ndr, int ndr_flags, struct spoolss_NotifyBlobData *r) +{ + uint32_t cntr_data_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 2)); + for (cntr_data_0 = 0; cntr_data_0 < 8; cntr_data_0++) { + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->data[cntr_data_0])); + } + } + if (ndr_flags & NDR_BUFFERS) { + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_NotifyBlobData(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyBlobData *r) +{ + uint32_t cntr_data_0; + ndr_print_struct(ndr, name, "spoolss_NotifyBlobData"); + ndr->depth++; + ndr->print(ndr, "%s: ARRAY(%d)", "data", (int)8); + ndr->depth++; + for (cntr_data_0=0;cntr_data_0<8;cntr_data_0++) { + char *idx_0=NULL; + if (asprintf(&idx_0, "[%d]", cntr_data_0) != -1) { + ndr_print_uint16(ndr, "data", r->data[cntr_data_0]); + free(idx_0); + } + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_NotifyBlob(struct ndr_push *ndr, int ndr_flags, const struct spoolss_NotifyBlob *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->len)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->data)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->data) { + NDR_CHECK(ndr_push_spoolss_NotifyBlobData(ndr, NDR_SCALARS, r->data)); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_NotifyBlob(struct ndr_pull *ndr, int ndr_flags, struct spoolss_NotifyBlob *r) +{ + uint32_t _ptr_data; + TALLOC_CTX *_mem_save_data_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->len)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data)); + if (_ptr_data) { + NDR_PULL_ALLOC(ndr, r->data); + } else { + r->data = NULL; + } + } + if (ndr_flags & NDR_BUFFERS) { + if (r->data) { + _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->data, 0); + NDR_CHECK(ndr_pull_spoolss_NotifyBlobData(ndr, NDR_SCALARS, r->data)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, 0); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_NotifyBlob(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyBlob *r) +{ + ndr_print_struct(ndr, name, "spoolss_NotifyBlob"); + ndr->depth++; + ndr_print_uint32(ndr, "len", r->len); + ndr_print_ptr(ndr, "data", r->data); + ndr->depth++; + if (r->data) { + ndr_print_spoolss_NotifyBlobData(ndr, "data", r->data); + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_NotifyData(struct ndr_push *ndr, int ndr_flags, const union spoolss_NotifyData *r) +{ + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, level)); + switch (level) { + case 1: { + NDR_CHECK(ndr_push_dlong(ndr, NDR_SCALARS, r->integer)); + break; } + + case 2: { + NDR_CHECK(ndr_push_spoolss_NotifyUTF16String(ndr, NDR_SCALARS, &r->utf16_string)); + break; } + + case 3: { + NDR_CHECK(ndr_push_spoolss_NotifyDOSString(ndr, NDR_SCALARS, &r->ascii_string)); + break; } + + case 4: { + NDR_CHECK(ndr_push_spoolss_NotifyBlob(ndr, NDR_SCALARS, &r->blob)); + break; } + + case 5: { + NDR_CHECK(ndr_push_spoolss_NotifyDOSString(ndr, NDR_SCALARS, &r->ascii_string)); + break; } + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 1: + break; + + case 2: + NDR_CHECK(ndr_push_spoolss_NotifyUTF16String(ndr, NDR_BUFFERS, &r->utf16_string)); + break; + + case 3: + NDR_CHECK(ndr_push_spoolss_NotifyDOSString(ndr, NDR_BUFFERS, &r->ascii_string)); + break; + + case 4: + NDR_CHECK(ndr_push_spoolss_NotifyBlob(ndr, NDR_BUFFERS, &r->blob)); + break; + + case 5: + NDR_CHECK(ndr_push_spoolss_NotifyDOSString(ndr, NDR_BUFFERS, &r->ascii_string)); + break; + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_NotifyData(struct ndr_pull *ndr, int ndr_flags, union spoolss_NotifyData *r) +{ + int level; + uint32_t _level; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &_level)); + if (_level != level) { + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u for r", _level); + } + switch (level) { + case 1: { + NDR_CHECK(ndr_pull_dlong(ndr, NDR_SCALARS, &r->integer)); + break; } + + case 2: { + NDR_CHECK(ndr_pull_spoolss_NotifyUTF16String(ndr, NDR_SCALARS, &r->utf16_string)); + break; } + + case 3: { + NDR_CHECK(ndr_pull_spoolss_NotifyDOSString(ndr, NDR_SCALARS, &r->ascii_string)); + break; } + + case 4: { + NDR_CHECK(ndr_pull_spoolss_NotifyBlob(ndr, NDR_SCALARS, &r->blob)); + break; } + + case 5: { + NDR_CHECK(ndr_pull_spoolss_NotifyDOSString(ndr, NDR_SCALARS, &r->ascii_string)); + break; } + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + if (ndr_flags & NDR_BUFFERS) { + switch (level) { + case 1: + break; + + case 2: + NDR_CHECK(ndr_pull_spoolss_NotifyUTF16String(ndr, NDR_BUFFERS, &r->utf16_string)); + break; + + case 3: + NDR_CHECK(ndr_pull_spoolss_NotifyDOSString(ndr, NDR_BUFFERS, &r->ascii_string)); + break; + + case 4: + NDR_CHECK(ndr_pull_spoolss_NotifyBlob(ndr, NDR_BUFFERS, &r->blob)); + break; + + case 5: + NDR_CHECK(ndr_pull_spoolss_NotifyDOSString(ndr, NDR_BUFFERS, &r->ascii_string)); + break; + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_NotifyData(struct ndr_print *ndr, const char *name, const union spoolss_NotifyData *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_NotifyData"); + switch (level) { + case 1: + ndr_print_dlong(ndr, "integer", r->integer); + break; + + case 2: + ndr_print_spoolss_NotifyUTF16String(ndr, "utf16_string", &r->utf16_string); + break; + + case 3: + ndr_print_spoolss_NotifyDOSString(ndr, "ascii_string", &r->ascii_string); + break; + + case 4: + ndr_print_spoolss_NotifyBlob(ndr, "blob", &r->blob); + break; + + case 5: + ndr_print_spoolss_NotifyDOSString(ndr, "ascii_string", &r->ascii_string); + break; + + default: + ndr_print_bad_level(ndr, name, level); + } +} + +static enum ndr_err_code ndr_push_spoolss_Notify(struct ndr_push *ndr, int ndr_flags, const struct spoolss_Notify *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_spoolss_NotifyType(ndr, NDR_SCALARS, r->type)); + NDR_CHECK(ndr_push_spoolss_Field(ndr, NDR_SCALARS, r->field)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->variable_type)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->job_id)); + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->data, r->variable_type)); + NDR_CHECK(ndr_push_spoolss_NotifyData(ndr, NDR_SCALARS, &r->data)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_push_spoolss_NotifyData(ndr, NDR_BUFFERS, &r->data)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_Notify(struct ndr_pull *ndr, int ndr_flags, struct spoolss_Notify *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_spoolss_NotifyType(ndr, NDR_SCALARS, &r->type)); + NDR_CHECK(ndr_pull_spoolss_Field(ndr, NDR_SCALARS, &r->field)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->variable_type)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->job_id)); + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->data, r->variable_type)); + NDR_CHECK(ndr_pull_spoolss_NotifyData(ndr, NDR_SCALARS, &r->data)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_spoolss_NotifyData(ndr, NDR_BUFFERS, &r->data)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_Notify(struct ndr_print *ndr, const char *name, const struct spoolss_Notify *r) +{ + ndr_print_struct(ndr, name, "spoolss_Notify"); + ndr->depth++; + ndr_print_spoolss_NotifyType(ndr, "type", r->type); + ndr_print_spoolss_Field(ndr, "field", r->field); + ndr_print_uint32(ndr, "variable_type", r->variable_type); + ndr_print_uint32(ndr, "job_id", r->job_id); + ndr_print_set_switch_value(ndr, &r->data, r->variable_type); + ndr_print_spoolss_NotifyData(ndr, "data", &r->data); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_NotifyInfo(struct ndr_push *ndr, int ndr_flags, const struct spoolss_NotifyInfo *r) +{ + uint32_t cntr_notifies_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count)); + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->version)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->flags)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count)); + for (cntr_notifies_0 = 0; cntr_notifies_0 < r->count; cntr_notifies_0++) { + NDR_CHECK(ndr_push_spoolss_Notify(ndr, NDR_SCALARS, &r->notifies[cntr_notifies_0])); + } + } + if (ndr_flags & NDR_BUFFERS) { + for (cntr_notifies_0 = 0; cntr_notifies_0 < r->count; cntr_notifies_0++) { + NDR_CHECK(ndr_push_spoolss_Notify(ndr, NDR_BUFFERS, &r->notifies[cntr_notifies_0])); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_NotifyInfo(struct ndr_pull *ndr, int ndr_flags, struct spoolss_NotifyInfo *r) +{ + uint32_t cntr_notifies_0; + TALLOC_CTX *_mem_save_notifies_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_array_size(ndr, &r->notifies)); + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->version)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->flags)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->count)); + NDR_PULL_ALLOC_N(ndr, r->notifies, ndr_get_array_size(ndr, &r->notifies)); + _mem_save_notifies_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->notifies, 0); + for (cntr_notifies_0 = 0; cntr_notifies_0 < r->count; cntr_notifies_0++) { + NDR_CHECK(ndr_pull_spoolss_Notify(ndr, NDR_SCALARS, &r->notifies[cntr_notifies_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_notifies_0, 0); + if (r->notifies) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->notifies, r->count)); + } + } + if (ndr_flags & NDR_BUFFERS) { + _mem_save_notifies_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->notifies, 0); + for (cntr_notifies_0 = 0; cntr_notifies_0 < r->count; cntr_notifies_0++) { + NDR_CHECK(ndr_pull_spoolss_Notify(ndr, NDR_BUFFERS, &r->notifies[cntr_notifies_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_notifies_0, 0); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_NotifyInfo(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyInfo *r) +{ + uint32_t cntr_notifies_0; + ndr_print_struct(ndr, name, "spoolss_NotifyInfo"); + ndr->depth++; + ndr_print_uint32(ndr, "version", r->version); + ndr_print_uint32(ndr, "flags", r->flags); + ndr_print_uint32(ndr, "count", r->count); + ndr->print(ndr, "%s: ARRAY(%d)", "notifies", (int)r->count); + ndr->depth++; + for (cntr_notifies_0=0;cntr_notifies_0count;cntr_notifies_0++) { + char *idx_0=NULL; + if (asprintf(&idx_0, "[%d]", cntr_notifies_0) != -1) { + ndr_print_spoolss_Notify(ndr, "notifies", &r->notifies[cntr_notifies_0]); + free(idx_0); + } + } + ndr->depth--; + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_UserLevel1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_UserLevel1 *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->client)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->user)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->build)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->major)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->minor)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->processor)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->client) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->client, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->client, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->client, ndr_charset_length(r->client, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + if (r->user) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->user, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->user, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->user, ndr_charset_length(r->user, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_UserLevel1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_UserLevel1 *r) +{ + uint32_t _ptr_client; + TALLOC_CTX *_mem_save_client_0; + uint32_t _ptr_user; + TALLOC_CTX *_mem_save_user_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_client)); + if (_ptr_client) { + NDR_PULL_ALLOC(ndr, r->client); + } else { + r->client = NULL; + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_user)); + if (_ptr_user) { + NDR_PULL_ALLOC(ndr, r->user); + } else { + r->user = NULL; + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->build)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->major)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->minor)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->processor)); + } + if (ndr_flags & NDR_BUFFERS) { + if (r->client) { + _mem_save_client_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->client, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->client)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->client)); + if (ndr_get_array_length(ndr, &r->client) > ndr_get_array_size(ndr, &r->client)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->client), ndr_get_array_length(ndr, &r->client)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->client), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->client, ndr_get_array_length(ndr, &r->client), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_client_0, 0); + } + if (r->user) { + _mem_save_user_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->user, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->user)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->user)); + if (ndr_get_array_length(ndr, &r->user) > ndr_get_array_size(ndr, &r->user)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->user), ndr_get_array_length(ndr, &r->user)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->user), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->user, ndr_get_array_length(ndr, &r->user), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_user_0, 0); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_UserLevel1(struct ndr_print *ndr, const char *name, const struct spoolss_UserLevel1 *r) +{ + ndr_print_struct(ndr, name, "spoolss_UserLevel1"); + ndr->depth++; + ndr_print_uint32(ndr, "size", r->size); + ndr_print_ptr(ndr, "client", r->client); + ndr->depth++; + if (r->client) { + ndr_print_string(ndr, "client", r->client); + } + ndr->depth--; + ndr_print_ptr(ndr, "user", r->user); + ndr->depth++; + if (r->user) { + ndr_print_string(ndr, "user", r->user); + } + ndr->depth--; + ndr_print_uint32(ndr, "build", r->build); + ndr_print_uint32(ndr, "major", r->major); + ndr_print_uint32(ndr, "minor", r->minor); + ndr_print_uint32(ndr, "processor", r->processor); + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_UserLevel(struct ndr_push *ndr, int ndr_flags, const union spoolss_UserLevel *r) +{ + if (ndr_flags & NDR_SCALARS) { + int level = ndr_push_get_switch_value(ndr, r); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, level)); + switch (level) { + case 1: { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->level1)); + break; } + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + if (ndr_flags & NDR_BUFFERS) { + int level = ndr_push_get_switch_value(ndr, r); + switch (level) { + case 1: + if (r->level1) { + NDR_CHECK(ndr_push_spoolss_UserLevel1(ndr, NDR_SCALARS|NDR_BUFFERS, r->level1)); + } + break; + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_UserLevel(struct ndr_pull *ndr, int ndr_flags, union spoolss_UserLevel *r) +{ + int level; + uint32_t _level; + TALLOC_CTX *_mem_save_level1_0; + level = ndr_pull_get_switch_value(ndr, r); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &_level)); + if (_level != level) { + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u for r", _level); + } + switch (level) { + case 1: { + uint32_t _ptr_level1; + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_level1)); + if (_ptr_level1) { + NDR_PULL_ALLOC(ndr, r->level1); + } else { + r->level1 = NULL; + } + break; } + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + if (ndr_flags & NDR_BUFFERS) { + switch (level) { + case 1: + if (r->level1) { + _mem_save_level1_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->level1, 0); + NDR_CHECK(ndr_pull_spoolss_UserLevel1(ndr, NDR_SCALARS|NDR_BUFFERS, r->level1)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_level1_0, 0); + } + break; + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_UserLevel(struct ndr_print *ndr, const char *name, const union spoolss_UserLevel *r) +{ + int level; + level = ndr_print_get_switch_value(ndr, r); + ndr_print_union(ndr, name, level, "spoolss_UserLevel"); + switch (level) { + case 1: + ndr_print_ptr(ndr, "level1", r->level1); + ndr->depth++; + if (r->level1) { + ndr_print_spoolss_UserLevel1(ndr, "level1", r->level1); + } + ndr->depth--; + break; + + default: + ndr_print_bad_level(ndr, name, level); + } +} + +_PUBLIC_ enum ndr_err_code ndr_push__spoolss_EnumPrinters(struct ndr_push *ndr, int flags, const struct _spoolss_EnumPrinters *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_spoolss_EnumPrinterFlags(ndr, NDR_SCALARS, r->in.flags)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.server)); + if (r->in.server) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.server, ndr_charset_length(r->in.server, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); + if (r->in.buffer) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->in.buffer)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); + if (r->out.info) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->out.info)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.count)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull__spoolss_EnumPrinters(struct ndr_pull *ndr, int flags, struct _spoolss_EnumPrinters *r) +{ + uint32_t _ptr_server; + uint32_t _ptr_buffer; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_server_0; + TALLOC_CTX *_mem_save_buffer_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_spoolss_EnumPrinterFlags(ndr, NDR_SCALARS, &r->in.flags)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_server)); + if (_ptr_server) { + NDR_PULL_ALLOC(ndr, r->in.server); + } else { + r->in.server = NULL; + } + if (r->in.server) { + _mem_save_server_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.server, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.server)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.server)); + if (ndr_get_array_length(ndr, &r->in.server) > ndr_get_array_size(ndr, &r->in.server)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.server), ndr_get_array_length(ndr, &r->in.server)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.server), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.server, ndr_get_array_length(ndr, &r->in.server), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_buffer)); + if (_ptr_buffer) { + NDR_PULL_ALLOC(ndr, r->in.buffer); + } else { + r->in.buffer = NULL; + } + if (r->in.buffer) { + _mem_save_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.buffer, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->in.buffer)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->out.info); + } else { + r->out.info = NULL; + } + if (r->out.info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->out.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.count)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_push___spoolss_EnumPrinters(struct ndr_push *ndr, int flags, const struct __spoolss_EnumPrinters *r) +{ + uint32_t cntr_info_0; + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.count)); + } + if (flags & NDR_OUT) { + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_push_spoolss_PrinterInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_spoolss_PrinterInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull___spoolss_EnumPrinters(struct ndr_pull *ndr, int flags, struct __spoolss_EnumPrinters *r) +{ + uint32_t cntr_info_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.count)); + } + if (flags & NDR_OUT) { + NDR_PULL_ALLOC_N(ndr, r->out.info, r->in.count); + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_spoolss_PrinterInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_EnumPrinters(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrinters *r) +{ + uint32_t cntr_info_1; + ndr_print_struct(ndr, name, "spoolss_EnumPrinters"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_EnumPrinters"); + ndr->depth++; + ndr_print_spoolss_EnumPrinterFlags(ndr, "flags", r->in.flags); + ndr_print_ptr(ndr, "server", r->in.server); + ndr->depth++; + if (r->in.server) { + ndr_print_string(ndr, "server", r->in.server); + } + ndr->depth--; + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr->depth++; + if (r->in.buffer) { + ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); + } + ndr->depth--; + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_EnumPrinters"); + ndr->depth++; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + if (r->out.info) { + ndr->print(ndr, "%s: ARRAY(%d)", "info", (int)r->out.count); + ndr->depth++; + for (cntr_info_1=0;cntr_info_1out.count;cntr_info_1++) { + char *idx_1=NULL; + if (asprintf(&idx_1, "[%d]", cntr_info_1) != -1) { + ndr_print_set_switch_value(ndr, &r->out.info[cntr_info_1], r->in.level); + ndr_print_spoolss_PrinterInfo(ndr, "info", &r->out.info[cntr_info_1]); + free(idx_1); + } + } + ndr->depth--; + } + ndr->depth--; + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_uint32(ndr, "count", r->out.count); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_OpenPrinter(struct ndr_push *ndr, int flags, const struct spoolss_OpenPrinter *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.printername)); + if (r->in.printername) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.printername, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.printername, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.printername, ndr_charset_length(r->in.printername, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.datatype)); + if (r->in.datatype) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.datatype, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.datatype, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.datatype, ndr_charset_length(r->in.datatype, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_spoolss_DevmodeContainer(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.devmode_ctr)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.access_mask)); + } + if (flags & NDR_OUT) { + if (r->out.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_OpenPrinter(struct ndr_pull *ndr, int flags, struct spoolss_OpenPrinter *r) +{ + uint32_t _ptr_printername; + uint32_t _ptr_datatype; + TALLOC_CTX *_mem_save_printername_0; + TALLOC_CTX *_mem_save_datatype_0; + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_printername)); + if (_ptr_printername) { + NDR_PULL_ALLOC(ndr, r->in.printername); + } else { + r->in.printername = NULL; + } + if (r->in.printername) { + _mem_save_printername_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.printername, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.printername)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.printername)); + if (ndr_get_array_length(ndr, &r->in.printername) > ndr_get_array_size(ndr, &r->in.printername)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.printername), ndr_get_array_length(ndr, &r->in.printername)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.printername), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.printername, ndr_get_array_length(ndr, &r->in.printername), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printername_0, 0); + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_datatype)); + if (_ptr_datatype) { + NDR_PULL_ALLOC(ndr, r->in.datatype); + } else { + r->in.datatype = NULL; + } + if (r->in.datatype) { + _mem_save_datatype_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.datatype, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.datatype)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.datatype)); + if (ndr_get_array_length(ndr, &r->in.datatype) > ndr_get_array_size(ndr, &r->in.datatype)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.datatype), ndr_get_array_length(ndr, &r->in.datatype)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.datatype), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.datatype, ndr_get_array_length(ndr, &r->in.datatype), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_datatype_0, 0); + } + NDR_CHECK(ndr_pull_spoolss_DevmodeContainer(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.devmode_ctr)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.access_mask)); + NDR_PULL_ALLOC(ndr, r->out.handle); + ZERO_STRUCTP(r->out.handle); + } + if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_OpenPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_OpenPrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_OpenPrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_OpenPrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "printername", r->in.printername); + ndr->depth++; + if (r->in.printername) { + ndr_print_string(ndr, "printername", r->in.printername); + } + ndr->depth--; + ndr_print_ptr(ndr, "datatype", r->in.datatype); + ndr->depth++; + if (r->in.datatype) { + ndr_print_string(ndr, "datatype", r->in.datatype); + } + ndr->depth--; + ndr_print_spoolss_DevmodeContainer(ndr, "devmode_ctr", &r->in.devmode_ctr); + ndr_print_uint32(ndr, "access_mask", r->in.access_mask); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_OpenPrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->out.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->out.handle); + ndr->depth--; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_SetJob(struct ndr_push *ndr, int flags, const struct spoolss_SetJob *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.job_id)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.ctr)); + if (r->in.ctr) { + NDR_CHECK(ndr_push_spoolss_JobInfoContainer(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.ctr)); + } + NDR_CHECK(ndr_push_spoolss_JobControl(ndr, NDR_SCALARS, r->in.command)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_SetJob(struct ndr_pull *ndr, int flags, struct spoolss_SetJob *r) +{ + uint32_t _ptr_ctr; + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_ctr_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.job_id)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_ctr)); + if (_ptr_ctr) { + NDR_PULL_ALLOC(ndr, r->in.ctr); + } else { + r->in.ctr = NULL; + } + if (r->in.ctr) { + _mem_save_ctr_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.ctr, 0); + NDR_CHECK(ndr_pull_spoolss_JobInfoContainer(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.ctr)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_ctr_0, 0); + } + NDR_CHECK(ndr_pull_spoolss_JobControl(ndr, NDR_SCALARS, &r->in.command)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_SetJob(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_SetJob *r) +{ + ndr_print_struct(ndr, name, "spoolss_SetJob"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_SetJob"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "job_id", r->in.job_id); + ndr_print_ptr(ndr, "ctr", r->in.ctr); + ndr->depth++; + if (r->in.ctr) { + ndr_print_spoolss_JobInfoContainer(ndr, "ctr", r->in.ctr); + } + ndr->depth--; + ndr_print_spoolss_JobControl(ndr, "command", r->in.command); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_SetJob"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_GetJob(struct ndr_push *ndr, int flags, const struct spoolss_GetJob *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.job_id)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); + if (r->in.buffer) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->in.buffer)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); + if (r->out.info) { + { + struct ndr_push *_ndr_info; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info, 4, r->in.offered)); + NDR_CHECK(ndr_push_set_switch_value(_ndr_info, r->out.info, r->in.level)); + NDR_CHECK(ndr_push_spoolss_JobInfo(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->out.info)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info, 4, r->in.offered)); + } + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_GetJob(struct ndr_pull *ndr, int flags, struct spoolss_GetJob *r) +{ + uint32_t _ptr_buffer; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_buffer_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.job_id)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_buffer)); + if (_ptr_buffer) { + NDR_PULL_ALLOC(ndr, r->in.buffer); + } else { + r->in.buffer = NULL; + } + if (r->in.buffer) { + _mem_save_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.buffer, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->in.buffer)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->out.info); + } else { + r->out.info = NULL; + } + if (r->out.info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + { + struct ndr_pull *_ndr_info; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info, 4, r->in.offered)); + NDR_CHECK(ndr_pull_set_switch_value(_ndr_info, r->out.info, r->in.level)); + NDR_CHECK(ndr_pull_spoolss_JobInfo(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->out.info)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info, 4, r->in.offered)); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_GetJob(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetJob *r) +{ + ndr_print_struct(ndr, name, "spoolss_GetJob"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_GetJob"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "job_id", r->in.job_id); + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr->depth++; + if (r->in.buffer) { + ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); + } + ndr->depth--; + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_GetJob"); + ndr->depth++; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + if (r->out.info) { + ndr_print_set_switch_value(ndr, r->out.info, r->in.level); + ndr_print_spoolss_JobInfo(ndr, "info", r->out.info); + } + ndr->depth--; + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push__spoolss_EnumJobs(struct ndr_push *ndr, int flags, const struct _spoolss_EnumJobs *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.firstjob)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.numjobs)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); + if (r->in.buffer) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->in.buffer)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); + if (r->out.info) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->out.info)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.count)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull__spoolss_EnumJobs(struct ndr_pull *ndr, int flags, struct _spoolss_EnumJobs *r) +{ + uint32_t _ptr_buffer; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_buffer_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.firstjob)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.numjobs)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_buffer)); + if (_ptr_buffer) { + NDR_PULL_ALLOC(ndr, r->in.buffer); + } else { + r->in.buffer = NULL; + } + if (r->in.buffer) { + _mem_save_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.buffer, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->in.buffer)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->out.info); + } else { + r->out.info = NULL; + } + if (r->out.info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->out.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.count)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_push___spoolss_EnumJobs(struct ndr_push *ndr, int flags, const struct __spoolss_EnumJobs *r) +{ + uint32_t cntr_info_0; + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.count)); + } + if (flags & NDR_OUT) { + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_push_spoolss_JobInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_spoolss_JobInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull___spoolss_EnumJobs(struct ndr_pull *ndr, int flags, struct __spoolss_EnumJobs *r) +{ + uint32_t cntr_info_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.count)); + } + if (flags & NDR_OUT) { + NDR_PULL_ALLOC_N(ndr, r->out.info, r->in.count); + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_pull_spoolss_JobInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_spoolss_JobInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_EnumJobs(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumJobs *r) +{ + uint32_t cntr_info_1; + ndr_print_struct(ndr, name, "spoolss_EnumJobs"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_EnumJobs"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "firstjob", r->in.firstjob); + ndr_print_uint32(ndr, "numjobs", r->in.numjobs); + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr->depth++; + if (r->in.buffer) { + ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); + } + ndr->depth--; + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_EnumJobs"); + ndr->depth++; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + if (r->out.info) { + ndr->print(ndr, "%s: ARRAY(%d)", "info", (int)r->out.count); + ndr->depth++; + for (cntr_info_1=0;cntr_info_1out.count;cntr_info_1++) { + char *idx_1=NULL; + if (asprintf(&idx_1, "[%d]", cntr_info_1) != -1) { + ndr_print_set_switch_value(ndr, &r->out.info[cntr_info_1], r->in.level); + ndr_print_spoolss_JobInfo(ndr, "info", &r->out.info[cntr_info_1]); + free(idx_1); + } + } + ndr->depth--; + } + ndr->depth--; + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_uint32(ndr, "count", r->out.count); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_AddPrinter(struct ndr_push *ndr, int flags, const struct spoolss_AddPrinter *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_AddPrinter(struct ndr_pull *ndr, int flags, struct spoolss_AddPrinter *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AddPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_AddPrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_AddPrinter"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_AddPrinter"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DeletePrinter(struct ndr_push *ndr, int flags, const struct spoolss_DeletePrinter *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DeletePrinter(struct ndr_pull *ndr, int flags, struct spoolss_DeletePrinter *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeletePrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeletePrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_DeletePrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_DeletePrinter"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_SetPrinter(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinter *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->in.info, r->in.level)); + NDR_CHECK(ndr_push_spoolss_SetPrinterInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.info)); + NDR_CHECK(ndr_push_spoolss_DevmodeContainer(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.devmode_ctr)); + NDR_CHECK(ndr_push_sec_desc_buf(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.secdesc_ctr)); + NDR_CHECK(ndr_push_spoolss_PrinterControl(ndr, NDR_SCALARS, r->in.command)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_SetPrinter(struct ndr_pull *ndr, int flags, struct spoolss_SetPrinter *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->in.info, r->in.level)); + NDR_CHECK(ndr_pull_spoolss_SetPrinterInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.info)); + NDR_CHECK(ndr_pull_spoolss_DevmodeContainer(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.devmode_ctr)); + NDR_CHECK(ndr_pull_sec_desc_buf(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.secdesc_ctr)); + NDR_CHECK(ndr_pull_spoolss_PrinterControl(ndr, NDR_SCALARS, &r->in.command)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_SetPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_SetPrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_SetPrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_SetPrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_set_switch_value(ndr, &r->in.info, r->in.level); + ndr_print_spoolss_SetPrinterInfo(ndr, "info", &r->in.info); + ndr_print_spoolss_DevmodeContainer(ndr, "devmode_ctr", &r->in.devmode_ctr); + ndr_print_sec_desc_buf(ndr, "secdesc_ctr", &r->in.secdesc_ctr); + ndr_print_spoolss_PrinterControl(ndr, "command", r->in.command); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_SetPrinter"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_GetPrinter(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinter *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); + if (r->in.buffer) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->in.buffer)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); + if (r->out.info) { + { + struct ndr_push *_ndr_info; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info, 4, r->in.offered)); + NDR_CHECK(ndr_push_set_switch_value(_ndr_info, r->out.info, r->in.level)); + NDR_CHECK(ndr_push_spoolss_PrinterInfo(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->out.info)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info, 4, r->in.offered)); + } + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_GetPrinter(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinter *r) +{ + uint32_t _ptr_buffer; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_buffer_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_buffer)); + if (_ptr_buffer) { + NDR_PULL_ALLOC(ndr, r->in.buffer); + } else { + r->in.buffer = NULL; + } + if (r->in.buffer) { + _mem_save_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.buffer, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->in.buffer)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->out.info); + } else { + r->out.info = NULL; + } + if (r->out.info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + { + struct ndr_pull *_ndr_info; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info, 4, r->in.offered)); + NDR_CHECK(ndr_pull_set_switch_value(_ndr_info, r->out.info, r->in.level)); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->out.info)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info, 4, r->in.offered)); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_GetPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_GetPrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_GetPrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr->depth++; + if (r->in.buffer) { + ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); + } + ndr->depth--; + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_GetPrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + if (r->out.info) { + ndr_print_set_switch_value(ndr, r->out.info, r->in.level); + ndr_print_spoolss_PrinterInfo(ndr, "info", r->out.info); + } + ndr->depth--; + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_AddPrinterDriver(struct ndr_push *ndr, int flags, const struct spoolss_AddPrinterDriver *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_AddPrinterDriver(struct ndr_pull *ndr, int flags, struct spoolss_AddPrinterDriver *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AddPrinterDriver(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrinterDriver *r) +{ + ndr_print_struct(ndr, name, "spoolss_AddPrinterDriver"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_AddPrinterDriver"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_AddPrinterDriver"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push__spoolss_EnumPrinterDrivers(struct ndr_push *ndr, int flags, const struct _spoolss_EnumPrinterDrivers *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.server)); + if (r->in.server) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.server, ndr_charset_length(r->in.server, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.environment)); + if (r->in.environment) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.environment, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.environment, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.environment, ndr_charset_length(r->in.environment, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); + if (r->in.buffer) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->in.buffer)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); + if (r->out.info) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->out.info)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.count)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull__spoolss_EnumPrinterDrivers(struct ndr_pull *ndr, int flags, struct _spoolss_EnumPrinterDrivers *r) +{ + uint32_t _ptr_server; + uint32_t _ptr_environment; + uint32_t _ptr_buffer; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_server_0; + TALLOC_CTX *_mem_save_environment_0; + TALLOC_CTX *_mem_save_buffer_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_server)); + if (_ptr_server) { + NDR_PULL_ALLOC(ndr, r->in.server); + } else { + r->in.server = NULL; + } + if (r->in.server) { + _mem_save_server_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.server, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.server)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.server)); + if (ndr_get_array_length(ndr, &r->in.server) > ndr_get_array_size(ndr, &r->in.server)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.server), ndr_get_array_length(ndr, &r->in.server)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.server), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.server, ndr_get_array_length(ndr, &r->in.server), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_0, 0); + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_environment)); + if (_ptr_environment) { + NDR_PULL_ALLOC(ndr, r->in.environment); + } else { + r->in.environment = NULL; + } + if (r->in.environment) { + _mem_save_environment_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.environment, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.environment)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.environment)); + if (ndr_get_array_length(ndr, &r->in.environment) > ndr_get_array_size(ndr, &r->in.environment)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.environment), ndr_get_array_length(ndr, &r->in.environment)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.environment), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.environment, ndr_get_array_length(ndr, &r->in.environment), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_environment_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_buffer)); + if (_ptr_buffer) { + NDR_PULL_ALLOC(ndr, r->in.buffer); + } else { + r->in.buffer = NULL; + } + if (r->in.buffer) { + _mem_save_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.buffer, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->in.buffer)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->out.info); + } else { + r->out.info = NULL; + } + if (r->out.info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->out.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.count)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_push___spoolss_EnumPrinterDrivers(struct ndr_push *ndr, int flags, const struct __spoolss_EnumPrinterDrivers *r) +{ + uint32_t cntr_info_0; + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.count)); + } + if (flags & NDR_OUT) { + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_push_spoolss_DriverInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_spoolss_DriverInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull___spoolss_EnumPrinterDrivers(struct ndr_pull *ndr, int flags, struct __spoolss_EnumPrinterDrivers *r) +{ + uint32_t cntr_info_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.count)); + } + if (flags & NDR_OUT) { + NDR_PULL_ALLOC_N(ndr, r->out.info, r->in.count); + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_pull_spoolss_DriverInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_spoolss_DriverInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_EnumPrinterDrivers(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrinterDrivers *r) +{ + uint32_t cntr_info_1; + ndr_print_struct(ndr, name, "spoolss_EnumPrinterDrivers"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_EnumPrinterDrivers"); + ndr->depth++; + ndr_print_ptr(ndr, "server", r->in.server); + ndr->depth++; + if (r->in.server) { + ndr_print_string(ndr, "server", r->in.server); + } + ndr->depth--; + ndr_print_ptr(ndr, "environment", r->in.environment); + ndr->depth++; + if (r->in.environment) { + ndr_print_string(ndr, "environment", r->in.environment); + } + ndr->depth--; + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr->depth++; + if (r->in.buffer) { + ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); + } + ndr->depth--; + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_EnumPrinterDrivers"); + ndr->depth++; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + if (r->out.info) { + ndr->print(ndr, "%s: ARRAY(%d)", "info", (int)r->out.count); + ndr->depth++; + for (cntr_info_1=0;cntr_info_1out.count;cntr_info_1++) { + char *idx_1=NULL; + if (asprintf(&idx_1, "[%d]", cntr_info_1) != -1) { + ndr_print_set_switch_value(ndr, &r->out.info[cntr_info_1], r->in.level); + ndr_print_spoolss_DriverInfo(ndr, "info", &r->out.info[cntr_info_1]); + free(idx_1); + } + } + ndr->depth--; + } + ndr->depth--; + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_uint32(ndr, "count", r->out.count); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_GetPrinterDriver(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterDriver *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_GetPrinterDriver(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterDriver *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_GetPrinterDriver(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinterDriver *r) +{ + ndr_print_struct(ndr, name, "spoolss_GetPrinterDriver"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_GetPrinterDriver"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_GetPrinterDriver"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_GetPrinterDriverDirectory(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterDriverDirectory *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.server)); + if (r->in.server) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.server, ndr_charset_length(r->in.server, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.environment)); + if (r->in.environment) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.environment, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.environment, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.environment, ndr_charset_length(r->in.environment, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); + if (r->in.buffer) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->in.buffer)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); + if (r->out.info) { + { + struct ndr_push *_ndr_info; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info, 4, r->in.offered)); + NDR_CHECK(ndr_push_set_switch_value(_ndr_info, r->out.info, r->in.level)); + NDR_CHECK(ndr_push_spoolss_DriverDirectoryInfo(_ndr_info, NDR_SCALARS, r->out.info)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info, 4, r->in.offered)); + } + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_GetPrinterDriverDirectory(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterDriverDirectory *r) +{ + uint32_t _ptr_server; + uint32_t _ptr_environment; + uint32_t _ptr_buffer; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_server_0; + TALLOC_CTX *_mem_save_environment_0; + TALLOC_CTX *_mem_save_buffer_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_server)); + if (_ptr_server) { + NDR_PULL_ALLOC(ndr, r->in.server); + } else { + r->in.server = NULL; + } + if (r->in.server) { + _mem_save_server_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.server, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.server)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.server)); + if (ndr_get_array_length(ndr, &r->in.server) > ndr_get_array_size(ndr, &r->in.server)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.server), ndr_get_array_length(ndr, &r->in.server)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.server), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.server, ndr_get_array_length(ndr, &r->in.server), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_0, 0); + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_environment)); + if (_ptr_environment) { + NDR_PULL_ALLOC(ndr, r->in.environment); + } else { + r->in.environment = NULL; + } + if (r->in.environment) { + _mem_save_environment_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.environment, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.environment)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.environment)); + if (ndr_get_array_length(ndr, &r->in.environment) > ndr_get_array_size(ndr, &r->in.environment)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.environment), ndr_get_array_length(ndr, &r->in.environment)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.environment), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.environment, ndr_get_array_length(ndr, &r->in.environment), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_environment_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_buffer)); + if (_ptr_buffer) { + NDR_PULL_ALLOC(ndr, r->in.buffer); + } else { + r->in.buffer = NULL; + } + if (r->in.buffer) { + _mem_save_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.buffer, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->in.buffer)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->out.info); + } else { + r->out.info = NULL; + } + if (r->out.info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + { + struct ndr_pull *_ndr_info; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info, 4, r->in.offered)); + NDR_CHECK(ndr_pull_set_switch_value(_ndr_info, r->out.info, r->in.level)); + NDR_CHECK(ndr_pull_spoolss_DriverDirectoryInfo(_ndr_info, NDR_SCALARS, r->out.info)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info, 4, r->in.offered)); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_GetPrinterDriverDirectory(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinterDriverDirectory *r) +{ + ndr_print_struct(ndr, name, "spoolss_GetPrinterDriverDirectory"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_GetPrinterDriverDirectory"); + ndr->depth++; + ndr_print_ptr(ndr, "server", r->in.server); + ndr->depth++; + if (r->in.server) { + ndr_print_string(ndr, "server", r->in.server); + } + ndr->depth--; + ndr_print_ptr(ndr, "environment", r->in.environment); + ndr->depth++; + if (r->in.environment) { + ndr_print_string(ndr, "environment", r->in.environment); + } + ndr->depth--; + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr->depth++; + if (r->in.buffer) { + ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); + } + ndr->depth--; + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_GetPrinterDriverDirectory"); + ndr->depth++; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + if (r->out.info) { + ndr_print_set_switch_value(ndr, r->out.info, r->in.level); + ndr_print_spoolss_DriverDirectoryInfo(ndr, "info", r->out.info); + } + ndr->depth--; + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DeletePrinterDriver(struct ndr_push *ndr, int flags, const struct spoolss_DeletePrinterDriver *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.server)); + if (r->in.server) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.server, ndr_charset_length(r->in.server, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.architecture, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.architecture, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.architecture, ndr_charset_length(r->in.architecture, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.driver, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.driver, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.driver, ndr_charset_length(r->in.driver, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DeletePrinterDriver(struct ndr_pull *ndr, int flags, struct spoolss_DeletePrinterDriver *r) +{ + uint32_t _ptr_server; + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_server_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_server)); + if (_ptr_server) { + NDR_PULL_ALLOC(ndr, r->in.server); + } else { + r->in.server = NULL; + } + if (r->in.server) { + _mem_save_server_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.server, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.server)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.server)); + if (ndr_get_array_length(ndr, &r->in.server) > ndr_get_array_size(ndr, &r->in.server)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.server), ndr_get_array_length(ndr, &r->in.server)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.server), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.server, ndr_get_array_length(ndr, &r->in.server), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_0, 0); + } + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.architecture)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.architecture)); + if (ndr_get_array_length(ndr, &r->in.architecture) > ndr_get_array_size(ndr, &r->in.architecture)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.architecture), ndr_get_array_length(ndr, &r->in.architecture)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.architecture), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.architecture, ndr_get_array_length(ndr, &r->in.architecture), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.driver)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.driver)); + if (ndr_get_array_length(ndr, &r->in.driver) > ndr_get_array_size(ndr, &r->in.driver)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.driver), ndr_get_array_length(ndr, &r->in.driver)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.driver), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.driver, ndr_get_array_length(ndr, &r->in.driver), sizeof(uint16_t), CH_UTF16)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeletePrinterDriver(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinterDriver *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeletePrinterDriver"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_DeletePrinterDriver"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_ptr(ndr, "server", r->in.server); + ndr->depth++; + if (r->in.server) { + ndr_print_string(ndr, "server", r->in.server); + } + ndr->depth--; + ndr_print_string(ndr, "architecture", r->in.architecture); + ndr_print_string(ndr, "driver", r->in.driver); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_DeletePrinterDriver"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_AddPrintProcessor(struct ndr_push *ndr, int flags, const struct spoolss_AddPrintProcessor *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_AddPrintProcessor(struct ndr_pull *ndr, int flags, struct spoolss_AddPrintProcessor *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AddPrintProcessor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrintProcessor *r) +{ + ndr_print_struct(ndr, name, "spoolss_AddPrintProcessor"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_AddPrintProcessor"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_AddPrintProcessor"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push__spoolss_EnumPrintProcessors(struct ndr_push *ndr, int flags, const struct _spoolss_EnumPrintProcessors *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.servername)); + if (r->in.servername) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.servername, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.servername, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.servername, ndr_charset_length(r->in.servername, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.environment)); + if (r->in.environment) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.environment, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.environment, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.environment, ndr_charset_length(r->in.environment, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); + if (r->in.buffer) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->in.buffer)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); + if (r->out.info) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->out.info)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.count)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull__spoolss_EnumPrintProcessors(struct ndr_pull *ndr, int flags, struct _spoolss_EnumPrintProcessors *r) +{ + uint32_t _ptr_servername; + uint32_t _ptr_environment; + uint32_t _ptr_buffer; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_servername_0; + TALLOC_CTX *_mem_save_environment_0; + TALLOC_CTX *_mem_save_buffer_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_servername)); + if (_ptr_servername) { + NDR_PULL_ALLOC(ndr, r->in.servername); + } else { + r->in.servername = NULL; + } + if (r->in.servername) { + _mem_save_servername_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.servername, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.servername)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.servername)); + if (ndr_get_array_length(ndr, &r->in.servername) > ndr_get_array_size(ndr, &r->in.servername)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.servername), ndr_get_array_length(ndr, &r->in.servername)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.servername), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.servername, ndr_get_array_length(ndr, &r->in.servername), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_servername_0, 0); + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_environment)); + if (_ptr_environment) { + NDR_PULL_ALLOC(ndr, r->in.environment); + } else { + r->in.environment = NULL; + } + if (r->in.environment) { + _mem_save_environment_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.environment, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.environment)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.environment)); + if (ndr_get_array_length(ndr, &r->in.environment) > ndr_get_array_size(ndr, &r->in.environment)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.environment), ndr_get_array_length(ndr, &r->in.environment)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.environment), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.environment, ndr_get_array_length(ndr, &r->in.environment), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_environment_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_buffer)); + if (_ptr_buffer) { + NDR_PULL_ALLOC(ndr, r->in.buffer); + } else { + r->in.buffer = NULL; + } + if (r->in.buffer) { + _mem_save_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.buffer, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->in.buffer)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->out.info); + } else { + r->out.info = NULL; + } + if (r->out.info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->out.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.count)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_push___spoolss_EnumPrintProcessors(struct ndr_push *ndr, int flags, const struct __spoolss_EnumPrintProcessors *r) +{ + uint32_t cntr_info_0; + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.count)); + } + if (flags & NDR_OUT) { + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_push_spoolss_PrintProcessorInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_spoolss_PrintProcessorInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull___spoolss_EnumPrintProcessors(struct ndr_pull *ndr, int flags, struct __spoolss_EnumPrintProcessors *r) +{ + uint32_t cntr_info_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.count)); + } + if (flags & NDR_OUT) { + NDR_PULL_ALLOC_N(ndr, r->out.info, r->in.count); + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_pull_spoolss_PrintProcessorInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_spoolss_PrintProcessorInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_EnumPrintProcessors(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrintProcessors *r) +{ + uint32_t cntr_info_1; + ndr_print_struct(ndr, name, "spoolss_EnumPrintProcessors"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_EnumPrintProcessors"); + ndr->depth++; + ndr_print_ptr(ndr, "servername", r->in.servername); + ndr->depth++; + if (r->in.servername) { + ndr_print_string(ndr, "servername", r->in.servername); + } + ndr->depth--; + ndr_print_ptr(ndr, "environment", r->in.environment); + ndr->depth++; + if (r->in.environment) { + ndr_print_string(ndr, "environment", r->in.environment); + } + ndr->depth--; + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr->depth++; + if (r->in.buffer) { + ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); + } + ndr->depth--; + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_EnumPrintProcessors"); + ndr->depth++; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + if (r->out.info) { + ndr->print(ndr, "%s: ARRAY(%d)", "info", (int)r->out.count); + ndr->depth++; + for (cntr_info_1=0;cntr_info_1out.count;cntr_info_1++) { + char *idx_1=NULL; + if (asprintf(&idx_1, "[%d]", cntr_info_1) != -1) { + ndr_print_set_switch_value(ndr, &r->out.info[cntr_info_1], r->in.level); + ndr_print_spoolss_PrintProcessorInfo(ndr, "info", &r->out.info[cntr_info_1]); + free(idx_1); + } + } + ndr->depth--; + } + ndr->depth--; + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_uint32(ndr, "count", r->out.count); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_GetPrintProcessorDirectory(struct ndr_push *ndr, int flags, const struct spoolss_GetPrintProcessorDirectory *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_GetPrintProcessorDirectory(struct ndr_pull *ndr, int flags, struct spoolss_GetPrintProcessorDirectory *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_GetPrintProcessorDirectory(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrintProcessorDirectory *r) +{ + ndr_print_struct(ndr, name, "spoolss_GetPrintProcessorDirectory"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_GetPrintProcessorDirectory"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_GetPrintProcessorDirectory"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_StartDocPrinter(struct ndr_push *ndr, int flags, const struct spoolss_StartDocPrinter *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->in.info, r->in.level)); + NDR_CHECK(ndr_push_spoolss_DocumentInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.info)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.job_id)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_StartDocPrinter(struct ndr_pull *ndr, int flags, struct spoolss_StartDocPrinter *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->in.info, r->in.level)); + NDR_CHECK(ndr_pull_spoolss_DocumentInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.info)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.job_id)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_StartDocPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_StartDocPrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_StartDocPrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_StartDocPrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_set_switch_value(ndr, &r->in.info, r->in.level); + ndr_print_spoolss_DocumentInfo(ndr, "info", &r->in.info); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_StartDocPrinter"); + ndr->depth++; + ndr_print_uint32(ndr, "job_id", r->out.job_id); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_StartPagePrinter(struct ndr_push *ndr, int flags, const struct spoolss_StartPagePrinter *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_StartPagePrinter(struct ndr_pull *ndr, int flags, struct spoolss_StartPagePrinter *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_StartPagePrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_StartPagePrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_StartPagePrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_StartPagePrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_StartPagePrinter"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_WritePrinter(struct ndr_push *ndr, int flags, const struct spoolss_WritePrinter *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->in.data)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.data.length)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.num_written)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_WritePrinter(struct ndr_pull *ndr, int flags, struct spoolss_WritePrinter *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->in.data)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in._data_size)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.num_written)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_WritePrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_WritePrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_WritePrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_WritePrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_DATA_BLOB(ndr, "data", r->in.data); + ndr_print_uint32(ndr, "_data_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?r->in.data.length:r->in._data_size); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_WritePrinter"); + ndr->depth++; + ndr_print_uint32(ndr, "num_written", r->out.num_written); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_EndPagePrinter(struct ndr_push *ndr, int flags, const struct spoolss_EndPagePrinter *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_EndPagePrinter(struct ndr_pull *ndr, int flags, struct spoolss_EndPagePrinter *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_EndPagePrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EndPagePrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_EndPagePrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_EndPagePrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_EndPagePrinter"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_AbortPrinter(struct ndr_push *ndr, int flags, const struct spoolss_AbortPrinter *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_AbortPrinter(struct ndr_pull *ndr, int flags, struct spoolss_AbortPrinter *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AbortPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AbortPrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_AbortPrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_AbortPrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_AbortPrinter"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_ReadPrinter(struct ndr_push *ndr, int flags, const struct spoolss_ReadPrinter *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.data_size)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->out.data)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.data.length)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_ReadPrinter(struct ndr_pull *ndr, int flags, struct spoolss_ReadPrinter *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.data_size)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->out.data)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out._data_size)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_ReadPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ReadPrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_ReadPrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_ReadPrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "data_size", r->in.data_size); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_ReadPrinter"); + ndr->depth++; + ndr_print_DATA_BLOB(ndr, "data", r->out.data); + ndr_print_uint32(ndr, "_data_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?r->out.data.length:r->out._data_size); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_EndDocPrinter(struct ndr_push *ndr, int flags, const struct spoolss_EndDocPrinter *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_EndDocPrinter(struct ndr_pull *ndr, int flags, struct spoolss_EndDocPrinter *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_EndDocPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EndDocPrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_EndDocPrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_EndDocPrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_EndDocPrinter"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_AddJob(struct ndr_push *ndr, int flags, const struct spoolss_AddJob *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_AddJob(struct ndr_pull *ndr, int flags, struct spoolss_AddJob *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AddJob(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddJob *r) +{ + ndr_print_struct(ndr, name, "spoolss_AddJob"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_AddJob"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_AddJob"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_ScheduleJob(struct ndr_push *ndr, int flags, const struct spoolss_ScheduleJob *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_ScheduleJob(struct ndr_pull *ndr, int flags, struct spoolss_ScheduleJob *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_ScheduleJob(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ScheduleJob *r) +{ + ndr_print_struct(ndr, name, "spoolss_ScheduleJob"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_ScheduleJob"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_ScheduleJob"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push__spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct _spoolss_GetPrinterData *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.value_name, ndr_charset_length(r->in.value_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_spoolss_PrinterDataType(ndr, NDR_SCALARS, r->out.type)); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->out.data)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull__spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct _spoolss_GetPrinterData *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.value_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.value_name)); + if (ndr_get_array_length(ndr, &r->in.value_name) > ndr_get_array_size(ndr, &r->in.value_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.value_name), ndr_get_array_length(ndr, &r->in.value_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.value_name, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_spoolss_PrinterDataType(ndr, NDR_SCALARS, &r->out.type)); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->out.data)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_push___spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct __spoolss_GetPrinterData *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_spoolss_PrinterDataType(ndr, NDR_SCALARS, r->in.type)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->out.data, r->in.type)); + NDR_CHECK(ndr_push_spoolss_PrinterData(ndr, NDR_SCALARS|NDR_BUFFERS, &r->out.data)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull___spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct __spoolss_GetPrinterData *r) +{ + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_spoolss_PrinterDataType(ndr, NDR_SCALARS, &r->in.type)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.data, r->in.type)); + NDR_CHECK(ndr_pull_spoolss_PrinterData(ndr, NDR_SCALARS|NDR_BUFFERS, &r->out.data)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_GetPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinterData *r) +{ + ndr_print_struct(ndr, name, "spoolss_GetPrinterData"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_GetPrinterData"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_string(ndr, "value_name", r->in.value_name); + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_GetPrinterData"); + ndr->depth++; + ndr_print_spoolss_PrinterDataType(ndr, "type", r->out.type); + ndr_print_set_switch_value(ndr, &r->out.data, r->out.type); + ndr_print_spoolss_PrinterData(ndr, "data", &r->out.data); + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push__spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct _spoolss_SetPrinterData *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.value_name, ndr_charset_length(r->in.value_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_spoolss_PrinterDataType(ndr, NDR_SCALARS, r->in.type)); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->in.data)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in._offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_push___spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct __spoolss_SetPrinterData *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_spoolss_PrinterDataType(ndr, NDR_SCALARS, r->in.type)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->out.data, r->in.type)); + NDR_CHECK(ndr_push_spoolss_PrinterData(ndr, NDR_SCALARS|NDR_BUFFERS, &r->out.data)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_SetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_SetPrinterData *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.value_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.value_name)); + if (ndr_get_array_length(ndr, &r->in.value_name) > ndr_get_array_size(ndr, &r->in.value_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.value_name), ndr_get_array_length(ndr, &r->in.value_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.value_name, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_spoolss_PrinterDataType(ndr, NDR_SCALARS, &r->in.type)); + { + struct ndr_pull *_ndr_data; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_data, 4, -1)); + NDR_CHECK(ndr_pull_set_switch_value(_ndr_data, &r->in.data, r->in.type)); + NDR_CHECK(ndr_pull_spoolss_PrinterData(_ndr_data, NDR_SCALARS|NDR_BUFFERS, &r->in.data)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_data, 4, -1)); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in._offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_SetPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_SetPrinterData *r) +{ + ndr_print_struct(ndr, name, "spoolss_SetPrinterData"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_SetPrinterData"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_string(ndr, "value_name", r->in.value_name); + ndr_print_spoolss_PrinterDataType(ndr, "type", r->in.type); + ndr_print_set_switch_value(ndr, &r->in.data, r->in.type); + ndr_print_spoolss_PrinterData(ndr, "data", &r->in.data); + ndr_print_uint32(ndr, "_offered", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_spoolss_PrinterData(&r->in.data, r->in.type, ndr->iconv_convenience, flags):r->in._offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_SetPrinterData"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_WaitForPrinterChange(struct ndr_push *ndr, int flags, const struct spoolss_WaitForPrinterChange *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_WaitForPrinterChange(struct ndr_pull *ndr, int flags, struct spoolss_WaitForPrinterChange *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_WaitForPrinterChange(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_WaitForPrinterChange *r) +{ + ndr_print_struct(ndr, name, "spoolss_WaitForPrinterChange"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_WaitForPrinterChange"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_WaitForPrinterChange"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_ClosePrinter(struct ndr_push *ndr, int flags, const struct spoolss_ClosePrinter *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + } + if (flags & NDR_OUT) { + if (r->out.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_ClosePrinter(struct ndr_pull *ndr, int flags, struct spoolss_ClosePrinter *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_PULL_ALLOC(ndr, r->out.handle); + *r->out.handle = *r->in.handle; + } + if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_ClosePrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ClosePrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_ClosePrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_ClosePrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_ClosePrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->out.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->out.handle); + ndr->depth--; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_AddForm(struct ndr_push *ndr, int flags, const struct spoolss_AddForm *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->in.info, r->in.level)); + NDR_CHECK(ndr_push_spoolss_AddFormInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.info)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_AddForm(struct ndr_pull *ndr, int flags, struct spoolss_AddForm *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->in.info, r->in.level)); + NDR_CHECK(ndr_pull_spoolss_AddFormInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.info)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AddForm(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddForm *r) +{ + ndr_print_struct(ndr, name, "spoolss_AddForm"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_AddForm"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_set_switch_value(ndr, &r->in.info, r->in.level); + ndr_print_spoolss_AddFormInfo(ndr, "info", &r->in.info); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_AddForm"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DeleteForm(struct ndr_push *ndr, int flags, const struct spoolss_DeleteForm *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.form_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.form_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.form_name, ndr_charset_length(r->in.form_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DeleteForm(struct ndr_pull *ndr, int flags, struct spoolss_DeleteForm *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.form_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.form_name)); + if (ndr_get_array_length(ndr, &r->in.form_name) > ndr_get_array_size(ndr, &r->in.form_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.form_name), ndr_get_array_length(ndr, &r->in.form_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.form_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.form_name, ndr_get_array_length(ndr, &r->in.form_name), sizeof(uint16_t), CH_UTF16)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeleteForm(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeleteForm *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeleteForm"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_DeleteForm"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_string(ndr, "form_name", r->in.form_name); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_DeleteForm"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_GetForm(struct ndr_push *ndr, int flags, const struct spoolss_GetForm *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.form_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.form_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.form_name, ndr_charset_length(r->in.form_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); + if (r->in.buffer) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->in.buffer)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); + if (r->out.info) { + { + struct ndr_push *_ndr_info; + NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info, 4, r->in.offered)); + NDR_CHECK(ndr_push_set_switch_value(_ndr_info, r->out.info, r->in.level)); + NDR_CHECK(ndr_push_spoolss_FormInfo(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->out.info)); + NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info, 4, r->in.offered)); + } + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_GetForm(struct ndr_pull *ndr, int flags, struct spoolss_GetForm *r) +{ + uint32_t _ptr_buffer; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_buffer_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.form_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.form_name)); + if (ndr_get_array_length(ndr, &r->in.form_name) > ndr_get_array_size(ndr, &r->in.form_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.form_name), ndr_get_array_length(ndr, &r->in.form_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.form_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.form_name, ndr_get_array_length(ndr, &r->in.form_name), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_buffer)); + if (_ptr_buffer) { + NDR_PULL_ALLOC(ndr, r->in.buffer); + } else { + r->in.buffer = NULL; + } + if (r->in.buffer) { + _mem_save_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.buffer, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->in.buffer)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->out.info); + } else { + r->out.info = NULL; + } + if (r->out.info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + { + struct ndr_pull *_ndr_info; + NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info, 4, r->in.offered)); + NDR_CHECK(ndr_pull_set_switch_value(_ndr_info, r->out.info, r->in.level)); + NDR_CHECK(ndr_pull_spoolss_FormInfo(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->out.info)); + NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info, 4, r->in.offered)); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_GetForm(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetForm *r) +{ + ndr_print_struct(ndr, name, "spoolss_GetForm"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_GetForm"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_string(ndr, "form_name", r->in.form_name); + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr->depth++; + if (r->in.buffer) { + ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); + } + ndr->depth--; + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_GetForm"); + ndr->depth++; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + if (r->out.info) { + ndr_print_set_switch_value(ndr, r->out.info, r->in.level); + ndr_print_spoolss_FormInfo(ndr, "info", r->out.info); + } + ndr->depth--; + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_SetForm(struct ndr_push *ndr, int flags, const struct spoolss_SetForm *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.form_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.form_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.form_name, ndr_charset_length(r->in.form_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->in.info, r->in.level)); + NDR_CHECK(ndr_push_spoolss_AddFormInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.info)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_SetForm(struct ndr_pull *ndr, int flags, struct spoolss_SetForm *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.form_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.form_name)); + if (ndr_get_array_length(ndr, &r->in.form_name) > ndr_get_array_size(ndr, &r->in.form_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.form_name), ndr_get_array_length(ndr, &r->in.form_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.form_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.form_name, ndr_get_array_length(ndr, &r->in.form_name), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->in.info, r->in.level)); + NDR_CHECK(ndr_pull_spoolss_AddFormInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.info)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_SetForm(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_SetForm *r) +{ + ndr_print_struct(ndr, name, "spoolss_SetForm"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_SetForm"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_string(ndr, "form_name", r->in.form_name); + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_set_switch_value(ndr, &r->in.info, r->in.level); + ndr_print_spoolss_AddFormInfo(ndr, "info", &r->in.info); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_SetForm"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push__spoolss_EnumForms(struct ndr_push *ndr, int flags, const struct _spoolss_EnumForms *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); + if (r->in.buffer) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->in.buffer)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); + if (r->out.info) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->out.info)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.count)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull__spoolss_EnumForms(struct ndr_pull *ndr, int flags, struct _spoolss_EnumForms *r) +{ + uint32_t _ptr_buffer; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_buffer_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_buffer)); + if (_ptr_buffer) { + NDR_PULL_ALLOC(ndr, r->in.buffer); + } else { + r->in.buffer = NULL; + } + if (r->in.buffer) { + _mem_save_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.buffer, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->in.buffer)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->out.info); + } else { + r->out.info = NULL; + } + if (r->out.info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->out.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.count)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_push___spoolss_EnumForms(struct ndr_push *ndr, int flags, const struct __spoolss_EnumForms *r) +{ + uint32_t cntr_info_0; + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.count)); + } + if (flags & NDR_OUT) { + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_push_spoolss_FormInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_spoolss_FormInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull___spoolss_EnumForms(struct ndr_pull *ndr, int flags, struct __spoolss_EnumForms *r) +{ + uint32_t cntr_info_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.count)); + } + if (flags & NDR_OUT) { + NDR_PULL_ALLOC_N(ndr, r->out.info, r->in.count); + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_pull_spoolss_FormInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_spoolss_FormInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_EnumForms(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumForms *r) +{ + uint32_t cntr_info_1; + ndr_print_struct(ndr, name, "spoolss_EnumForms"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_EnumForms"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr->depth++; + if (r->in.buffer) { + ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); + } + ndr->depth--; + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_EnumForms"); + ndr->depth++; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + if (r->out.info) { + ndr->print(ndr, "%s: ARRAY(%d)", "info", (int)r->out.count); + ndr->depth++; + for (cntr_info_1=0;cntr_info_1out.count;cntr_info_1++) { + char *idx_1=NULL; + if (asprintf(&idx_1, "[%d]", cntr_info_1) != -1) { + ndr_print_set_switch_value(ndr, &r->out.info[cntr_info_1], r->in.level); + ndr_print_spoolss_FormInfo(ndr, "info", &r->out.info[cntr_info_1]); + free(idx_1); + } + } + ndr->depth--; + } + ndr->depth--; + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_uint32(ndr, "count", r->out.count); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push__spoolss_EnumPorts(struct ndr_push *ndr, int flags, const struct _spoolss_EnumPorts *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.servername)); + if (r->in.servername) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.servername, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.servername, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.servername, ndr_charset_length(r->in.servername, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); + if (r->in.buffer) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->in.buffer)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); + if (r->out.info) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->out.info)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.count)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull__spoolss_EnumPorts(struct ndr_pull *ndr, int flags, struct _spoolss_EnumPorts *r) +{ + uint32_t _ptr_servername; + uint32_t _ptr_buffer; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_servername_0; + TALLOC_CTX *_mem_save_buffer_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_servername)); + if (_ptr_servername) { + NDR_PULL_ALLOC(ndr, r->in.servername); + } else { + r->in.servername = NULL; + } + if (r->in.servername) { + _mem_save_servername_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.servername, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.servername)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.servername)); + if (ndr_get_array_length(ndr, &r->in.servername) > ndr_get_array_size(ndr, &r->in.servername)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.servername), ndr_get_array_length(ndr, &r->in.servername)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.servername), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.servername, ndr_get_array_length(ndr, &r->in.servername), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_servername_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_buffer)); + if (_ptr_buffer) { + NDR_PULL_ALLOC(ndr, r->in.buffer); + } else { + r->in.buffer = NULL; + } + if (r->in.buffer) { + _mem_save_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.buffer, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->in.buffer)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->out.info); + } else { + r->out.info = NULL; + } + if (r->out.info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->out.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.count)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_push___spoolss_EnumPorts(struct ndr_push *ndr, int flags, const struct __spoolss_EnumPorts *r) +{ + uint32_t cntr_info_0; + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.count)); + } + if (flags & NDR_OUT) { + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_push_spoolss_PortInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_spoolss_PortInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull___spoolss_EnumPorts(struct ndr_pull *ndr, int flags, struct __spoolss_EnumPorts *r) +{ + uint32_t cntr_info_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.count)); + } + if (flags & NDR_OUT) { + NDR_PULL_ALLOC_N(ndr, r->out.info, r->in.count); + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_pull_spoolss_PortInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_spoolss_PortInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_EnumPorts(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPorts *r) +{ + uint32_t cntr_info_1; + ndr_print_struct(ndr, name, "spoolss_EnumPorts"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_EnumPorts"); + ndr->depth++; + ndr_print_ptr(ndr, "servername", r->in.servername); + ndr->depth++; + if (r->in.servername) { + ndr_print_string(ndr, "servername", r->in.servername); + } + ndr->depth--; + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr->depth++; + if (r->in.buffer) { + ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); + } + ndr->depth--; + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_EnumPorts"); + ndr->depth++; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + if (r->out.info) { + ndr->print(ndr, "%s: ARRAY(%d)", "info", (int)r->out.count); + ndr->depth++; + for (cntr_info_1=0;cntr_info_1out.count;cntr_info_1++) { + char *idx_1=NULL; + if (asprintf(&idx_1, "[%d]", cntr_info_1) != -1) { + ndr_print_set_switch_value(ndr, &r->out.info[cntr_info_1], r->in.level); + ndr_print_spoolss_PortInfo(ndr, "info", &r->out.info[cntr_info_1]); + free(idx_1); + } + } + ndr->depth--; + } + ndr->depth--; + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_uint32(ndr, "count", r->out.count); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push__spoolss_EnumMonitors(struct ndr_push *ndr, int flags, const struct _spoolss_EnumMonitors *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.servername)); + if (r->in.servername) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.servername, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.servername, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.servername, ndr_charset_length(r->in.servername, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); + if (r->in.buffer) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->in.buffer)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); + if (r->out.info) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->out.info)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.count)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull__spoolss_EnumMonitors(struct ndr_pull *ndr, int flags, struct _spoolss_EnumMonitors *r) +{ + uint32_t _ptr_servername; + uint32_t _ptr_buffer; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_servername_0; + TALLOC_CTX *_mem_save_buffer_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_servername)); + if (_ptr_servername) { + NDR_PULL_ALLOC(ndr, r->in.servername); + } else { + r->in.servername = NULL; + } + if (r->in.servername) { + _mem_save_servername_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.servername, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.servername)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.servername)); + if (ndr_get_array_length(ndr, &r->in.servername) > ndr_get_array_size(ndr, &r->in.servername)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.servername), ndr_get_array_length(ndr, &r->in.servername)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.servername), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.servername, ndr_get_array_length(ndr, &r->in.servername), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_servername_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_buffer)); + if (_ptr_buffer) { + NDR_PULL_ALLOC(ndr, r->in.buffer); + } else { + r->in.buffer = NULL; + } + if (r->in.buffer) { + _mem_save_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.buffer, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->in.buffer)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->out.info); + } else { + r->out.info = NULL; + } + if (r->out.info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->out.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.count)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_push___spoolss_EnumMonitors(struct ndr_push *ndr, int flags, const struct __spoolss_EnumMonitors *r) +{ + uint32_t cntr_info_0; + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.count)); + } + if (flags & NDR_OUT) { + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_push_spoolss_MonitorInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_push_spoolss_MonitorInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull___spoolss_EnumMonitors(struct ndr_pull *ndr, int flags, struct __spoolss_EnumMonitors *r) +{ + uint32_t cntr_info_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.count)); + } + if (flags & NDR_OUT) { + NDR_PULL_ALLOC_N(ndr, r->out.info, r->in.count); + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->out.info[cntr_info_0], r->in.level)); + NDR_CHECK(ndr_pull_spoolss_MonitorInfo(ndr, NDR_SCALARS, &r->out.info[cntr_info_0])); + } + for (cntr_info_0 = 0; cntr_info_0 < r->in.count; cntr_info_0++) { + NDR_CHECK(ndr_pull_spoolss_MonitorInfo(ndr, NDR_BUFFERS, &r->out.info[cntr_info_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_EnumMonitors(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumMonitors *r) +{ + uint32_t cntr_info_1; + ndr_print_struct(ndr, name, "spoolss_EnumMonitors"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_EnumMonitors"); + ndr->depth++; + ndr_print_ptr(ndr, "servername", r->in.servername); + ndr->depth++; + if (r->in.servername) { + ndr_print_string(ndr, "servername", r->in.servername); + } + ndr->depth--; + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr->depth++; + if (r->in.buffer) { + ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); + } + ndr->depth--; + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_EnumMonitors"); + ndr->depth++; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + if (r->out.info) { + ndr->print(ndr, "%s: ARRAY(%d)", "info", (int)r->out.count); + ndr->depth++; + for (cntr_info_1=0;cntr_info_1out.count;cntr_info_1++) { + char *idx_1=NULL; + if (asprintf(&idx_1, "[%d]", cntr_info_1) != -1) { + ndr_print_set_switch_value(ndr, &r->out.info[cntr_info_1], r->in.level); + ndr_print_spoolss_MonitorInfo(ndr, "info", &r->out.info[cntr_info_1]); + free(idx_1); + } + } + ndr->depth--; + } + ndr->depth--; + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_uint32(ndr, "count", r->out.count); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_AddPort(struct ndr_push *ndr, int flags, const struct spoolss_AddPort *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.server_name)); + if (r->in.server_name) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.server_name, ndr_charset_length(r->in.server_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.monitor_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.monitor_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.monitor_name, ndr_charset_length(r->in.monitor_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_AddPort(struct ndr_pull *ndr, int flags, struct spoolss_AddPort *r) +{ + uint32_t _ptr_server_name; + TALLOC_CTX *_mem_save_server_name_0; + if (flags & NDR_IN) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_server_name)); + if (_ptr_server_name) { + NDR_PULL_ALLOC(ndr, r->in.server_name); + } else { + r->in.server_name = NULL; + } + if (r->in.server_name) { + _mem_save_server_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.server_name, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.server_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.server_name)); + if (ndr_get_array_length(ndr, &r->in.server_name) > ndr_get_array_size(ndr, &r->in.server_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.server_name), ndr_get_array_length(ndr, &r->in.server_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.server_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.server_name, ndr_get_array_length(ndr, &r->in.server_name), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_name_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown)); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.monitor_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.monitor_name)); + if (ndr_get_array_length(ndr, &r->in.monitor_name) > ndr_get_array_size(ndr, &r->in.monitor_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.monitor_name), ndr_get_array_length(ndr, &r->in.monitor_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.monitor_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.monitor_name, ndr_get_array_length(ndr, &r->in.monitor_name), sizeof(uint16_t), CH_UTF16)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AddPort(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPort *r) +{ + ndr_print_struct(ndr, name, "spoolss_AddPort"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_AddPort"); + ndr->depth++; + ndr_print_ptr(ndr, "server_name", r->in.server_name); + ndr->depth++; + if (r->in.server_name) { + ndr_print_string(ndr, "server_name", r->in.server_name); + } + ndr->depth--; + ndr_print_uint32(ndr, "unknown", r->in.unknown); + ndr_print_string(ndr, "monitor_name", r->in.monitor_name); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_AddPort"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_ConfigurePort(struct ndr_push *ndr, int flags, const struct spoolss_ConfigurePort *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_ConfigurePort(struct ndr_pull *ndr, int flags, struct spoolss_ConfigurePort *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_ConfigurePort(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ConfigurePort *r) +{ + ndr_print_struct(ndr, name, "spoolss_ConfigurePort"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_ConfigurePort"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_ConfigurePort"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DeletePort(struct ndr_push *ndr, int flags, const struct spoolss_DeletePort *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DeletePort(struct ndr_pull *ndr, int flags, struct spoolss_DeletePort *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeletePort(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePort *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeletePort"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_DeletePort"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_DeletePort"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_CreatePrinterIC(struct ndr_push *ndr, int flags, const struct spoolss_CreatePrinterIC *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_CreatePrinterIC(struct ndr_pull *ndr, int flags, struct spoolss_CreatePrinterIC *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_CreatePrinterIC(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_CreatePrinterIC *r) +{ + ndr_print_struct(ndr, name, "spoolss_CreatePrinterIC"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_CreatePrinterIC"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_CreatePrinterIC"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_PlayGDIScriptOnPrinterIC(struct ndr_push *ndr, int flags, const struct spoolss_PlayGDIScriptOnPrinterIC *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PlayGDIScriptOnPrinterIC(struct ndr_pull *ndr, int flags, struct spoolss_PlayGDIScriptOnPrinterIC *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PlayGDIScriptOnPrinterIC(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_PlayGDIScriptOnPrinterIC *r) +{ + ndr_print_struct(ndr, name, "spoolss_PlayGDIScriptOnPrinterIC"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_PlayGDIScriptOnPrinterIC"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_PlayGDIScriptOnPrinterIC"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DeletePrinterIC(struct ndr_push *ndr, int flags, const struct spoolss_DeletePrinterIC *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DeletePrinterIC(struct ndr_pull *ndr, int flags, struct spoolss_DeletePrinterIC *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeletePrinterIC(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinterIC *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeletePrinterIC"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_DeletePrinterIC"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_DeletePrinterIC"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_AddPrinterConnection(struct ndr_push *ndr, int flags, const struct spoolss_AddPrinterConnection *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_AddPrinterConnection(struct ndr_pull *ndr, int flags, struct spoolss_AddPrinterConnection *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AddPrinterConnection(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrinterConnection *r) +{ + ndr_print_struct(ndr, name, "spoolss_AddPrinterConnection"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_AddPrinterConnection"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_AddPrinterConnection"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DeletePrinterConnection(struct ndr_push *ndr, int flags, const struct spoolss_DeletePrinterConnection *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DeletePrinterConnection(struct ndr_pull *ndr, int flags, struct spoolss_DeletePrinterConnection *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeletePrinterConnection(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinterConnection *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeletePrinterConnection"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_DeletePrinterConnection"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_DeletePrinterConnection"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_PrinterMessageBox(struct ndr_push *ndr, int flags, const struct spoolss_PrinterMessageBox *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_PrinterMessageBox(struct ndr_pull *ndr, int flags, struct spoolss_PrinterMessageBox *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_PrinterMessageBox(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_PrinterMessageBox *r) +{ + ndr_print_struct(ndr, name, "spoolss_PrinterMessageBox"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_PrinterMessageBox"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_PrinterMessageBox"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_AddMonitor(struct ndr_push *ndr, int flags, const struct spoolss_AddMonitor *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_AddMonitor(struct ndr_pull *ndr, int flags, struct spoolss_AddMonitor *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AddMonitor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddMonitor *r) +{ + ndr_print_struct(ndr, name, "spoolss_AddMonitor"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_AddMonitor"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_AddMonitor"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DeleteMonitor(struct ndr_push *ndr, int flags, const struct spoolss_DeleteMonitor *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DeleteMonitor(struct ndr_pull *ndr, int flags, struct spoolss_DeleteMonitor *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeleteMonitor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeleteMonitor *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeleteMonitor"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_DeleteMonitor"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_DeleteMonitor"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DeletePrintProcessor(struct ndr_push *ndr, int flags, const struct spoolss_DeletePrintProcessor *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DeletePrintProcessor(struct ndr_pull *ndr, int flags, struct spoolss_DeletePrintProcessor *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeletePrintProcessor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrintProcessor *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeletePrintProcessor"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_DeletePrintProcessor"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_DeletePrintProcessor"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_AddPrintProvidor(struct ndr_push *ndr, int flags, const struct spoolss_AddPrintProvidor *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_AddPrintProvidor(struct ndr_pull *ndr, int flags, struct spoolss_AddPrintProvidor *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AddPrintProvidor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrintProvidor *r) +{ + ndr_print_struct(ndr, name, "spoolss_AddPrintProvidor"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_AddPrintProvidor"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_AddPrintProvidor"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DeletePrintProvidor(struct ndr_push *ndr, int flags, const struct spoolss_DeletePrintProvidor *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DeletePrintProvidor(struct ndr_pull *ndr, int flags, struct spoolss_DeletePrintProvidor *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeletePrintProvidor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrintProvidor *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeletePrintProvidor"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_DeletePrintProvidor"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_DeletePrintProvidor"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_EnumPrintProcDataTypes(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrintProcDataTypes *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_EnumPrintProcDataTypes(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrintProcDataTypes *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_EnumPrintProcDataTypes(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrintProcDataTypes *r) +{ + ndr_print_struct(ndr, name, "spoolss_EnumPrintProcDataTypes"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_EnumPrintProcDataTypes"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_EnumPrintProcDataTypes"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_ResetPrinter(struct ndr_push *ndr, int flags, const struct spoolss_ResetPrinter *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_ResetPrinter(struct ndr_pull *ndr, int flags, struct spoolss_ResetPrinter *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_ResetPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ResetPrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_ResetPrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_ResetPrinter"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_ResetPrinter"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_GetPrinterDriver2(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterDriver2 *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.architecture)); + if (r->in.architecture) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.architecture, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.architecture, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.architecture, ndr_charset_length(r->in.architecture, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.buffer)); + if (r->in.buffer) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->in.buffer)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.client_major_version)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.client_minor_version)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info)); + if (r->out.info) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->out.info)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.server_major_version)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.server_minor_version)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_GetPrinterDriver2(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterDriver2 *r) +{ + uint32_t _ptr_architecture; + uint32_t _ptr_buffer; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_architecture_0; + TALLOC_CTX *_mem_save_buffer_0; + TALLOC_CTX *_mem_save_info_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_architecture)); + if (_ptr_architecture) { + NDR_PULL_ALLOC(ndr, r->in.architecture); + } else { + r->in.architecture = NULL; + } + if (r->in.architecture) { + _mem_save_architecture_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.architecture, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.architecture)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.architecture)); + if (ndr_get_array_length(ndr, &r->in.architecture) > ndr_get_array_size(ndr, &r->in.architecture)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.architecture), ndr_get_array_length(ndr, &r->in.architecture)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.architecture), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.architecture, ndr_get_array_length(ndr, &r->in.architecture), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_architecture_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_buffer)); + if (_ptr_buffer) { + NDR_PULL_ALLOC(ndr, r->in.buffer); + } else { + r->in.buffer = NULL; + } + if (r->in.buffer) { + _mem_save_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.buffer, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->in.buffer)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.client_major_version)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.client_minor_version)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->out.info); + } else { + r->out.info = NULL; + } + if (r->out.info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->out.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.server_major_version)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.server_minor_version)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_GetPrinterDriver2(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinterDriver2 *r) +{ + ndr_print_struct(ndr, name, "spoolss_GetPrinterDriver2"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_GetPrinterDriver2"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_ptr(ndr, "architecture", r->in.architecture); + ndr->depth++; + if (r->in.architecture) { + ndr_print_string(ndr, "architecture", r->in.architecture); + } + ndr->depth--; + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "buffer", r->in.buffer); + ndr->depth++; + if (r->in.buffer) { + ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer); + } + ndr->depth--; + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr_print_uint32(ndr, "client_major_version", r->in.client_major_version); + ndr_print_uint32(ndr, "client_minor_version", r->in.client_minor_version); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_GetPrinterDriver2"); + ndr->depth++; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + if (r->out.info) { + ndr_print_DATA_BLOB(ndr, "info", *r->out.info); + } + ndr->depth--; + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_uint32(ndr, "server_major_version", r->out.server_major_version); + ndr_print_uint32(ndr, "server_minor_version", r->out.server_minor_version); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_FindFirstPrinterChangeNotification(struct ndr_push *ndr, int flags, const struct spoolss_FindFirstPrinterChangeNotification *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_FindFirstPrinterChangeNotification(struct ndr_pull *ndr, int flags, struct spoolss_FindFirstPrinterChangeNotification *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_FindFirstPrinterChangeNotification(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_FindFirstPrinterChangeNotification *r) +{ + ndr_print_struct(ndr, name, "spoolss_FindFirstPrinterChangeNotification"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_FindFirstPrinterChangeNotification"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_FindFirstPrinterChangeNotification"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_FindNextPrinterChangeNotification(struct ndr_push *ndr, int flags, const struct spoolss_FindNextPrinterChangeNotification *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_FindNextPrinterChangeNotification(struct ndr_pull *ndr, int flags, struct spoolss_FindNextPrinterChangeNotification *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_FindNextPrinterChangeNotification(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_FindNextPrinterChangeNotification *r) +{ + ndr_print_struct(ndr, name, "spoolss_FindNextPrinterChangeNotification"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_FindNextPrinterChangeNotification"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_FindNextPrinterChangeNotification"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_FindClosePrinterNotify(struct ndr_push *ndr, int flags, const struct spoolss_FindClosePrinterNotify *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_FindClosePrinterNotify(struct ndr_pull *ndr, int flags, struct spoolss_FindClosePrinterNotify *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_FindClosePrinterNotify(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_FindClosePrinterNotify *r) +{ + ndr_print_struct(ndr, name, "spoolss_FindClosePrinterNotify"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_FindClosePrinterNotify"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_FindClosePrinterNotify"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_RouterFindFirstPrinterChangeNotificationOld(struct ndr_push *ndr, int flags, const struct spoolss_RouterFindFirstPrinterChangeNotificationOld *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_RouterFindFirstPrinterChangeNotificationOld(struct ndr_pull *ndr, int flags, struct spoolss_RouterFindFirstPrinterChangeNotificationOld *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_RouterFindFirstPrinterChangeNotificationOld(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_RouterFindFirstPrinterChangeNotificationOld *r) +{ + ndr_print_struct(ndr, name, "spoolss_RouterFindFirstPrinterChangeNotificationOld"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_RouterFindFirstPrinterChangeNotificationOld"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_RouterFindFirstPrinterChangeNotificationOld"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_ReplyOpenPrinter(struct ndr_push *ndr, int flags, const struct spoolss_ReplyOpenPrinter *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.server_name, ndr_charset_length(r->in.server_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.printer_local)); + NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, r->in.type)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown1)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown2)); + } + if (flags & NDR_OUT) { + if (r->out.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_ReplyOpenPrinter(struct ndr_pull *ndr, int flags, struct spoolss_ReplyOpenPrinter *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.server_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.server_name)); + if (ndr_get_array_length(ndr, &r->in.server_name) > ndr_get_array_size(ndr, &r->in.server_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.server_name), ndr_get_array_length(ndr, &r->in.server_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.server_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.server_name, ndr_get_array_length(ndr, &r->in.server_name), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.printer_local)); + NDR_CHECK(ndr_pull_winreg_Type(ndr, NDR_SCALARS, &r->in.type)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown1)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown2)); + NDR_PULL_ALLOC(ndr, r->out.handle); + ZERO_STRUCTP(r->out.handle); + } + if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_ReplyOpenPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ReplyOpenPrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_ReplyOpenPrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_ReplyOpenPrinter"); + ndr->depth++; + ndr_print_string(ndr, "server_name", r->in.server_name); + ndr_print_uint32(ndr, "printer_local", r->in.printer_local); + ndr_print_winreg_Type(ndr, "type", r->in.type); + ndr_print_uint32(ndr, "unknown1", r->in.unknown1); + ndr_print_uint32(ndr, "unknown2", r->in.unknown2); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_ReplyOpenPrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->out.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->out.handle); + ndr->depth--; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_RouterReplyPrinter(struct ndr_push *ndr, int flags, const struct spoolss_RouterReplyPrinter *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_RouterReplyPrinter(struct ndr_pull *ndr, int flags, struct spoolss_RouterReplyPrinter *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_RouterReplyPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_RouterReplyPrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_RouterReplyPrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_RouterReplyPrinter"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_RouterReplyPrinter"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_ReplyClosePrinter(struct ndr_push *ndr, int flags, const struct spoolss_ReplyClosePrinter *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + } + if (flags & NDR_OUT) { + if (r->out.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_ReplyClosePrinter(struct ndr_pull *ndr, int flags, struct spoolss_ReplyClosePrinter *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_PULL_ALLOC(ndr, r->out.handle); + *r->out.handle = *r->in.handle; + } + if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_ReplyClosePrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ReplyClosePrinter *r) +{ + ndr_print_struct(ndr, name, "spoolss_ReplyClosePrinter"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_ReplyClosePrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_ReplyClosePrinter"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->out.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->out.handle); + ndr->depth--; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_AddPortEx(struct ndr_push *ndr, int flags, const struct spoolss_AddPortEx *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_AddPortEx(struct ndr_pull *ndr, int flags, struct spoolss_AddPortEx *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AddPortEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPortEx *r) +{ + ndr_print_struct(ndr, name, "spoolss_AddPortEx"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_AddPortEx"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_AddPortEx"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_RouterFindFirstPrinterChangeNotification(struct ndr_push *ndr, int flags, const struct spoolss_RouterFindFirstPrinterChangeNotification *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_RouterFindFirstPrinterChangeNotification(struct ndr_pull *ndr, int flags, struct spoolss_RouterFindFirstPrinterChangeNotification *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_RouterFindFirstPrinterChangeNotification(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_RouterFindFirstPrinterChangeNotification *r) +{ + ndr_print_struct(ndr, name, "spoolss_RouterFindFirstPrinterChangeNotification"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_RouterFindFirstPrinterChangeNotification"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_RouterFindFirstPrinterChangeNotification"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_SpoolerInit(struct ndr_push *ndr, int flags, const struct spoolss_SpoolerInit *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_SpoolerInit(struct ndr_pull *ndr, int flags, struct spoolss_SpoolerInit *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_SpoolerInit(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_SpoolerInit *r) +{ + ndr_print_struct(ndr, name, "spoolss_SpoolerInit"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_SpoolerInit"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_SpoolerInit"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_ResetPrinterEx(struct ndr_push *ndr, int flags, const struct spoolss_ResetPrinterEx *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_ResetPrinterEx(struct ndr_pull *ndr, int flags, struct spoolss_ResetPrinterEx *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_ResetPrinterEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ResetPrinterEx *r) +{ + ndr_print_struct(ndr, name, "spoolss_ResetPrinterEx"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_ResetPrinterEx"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_ResetPrinterEx"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct ndr_push *ndr, int flags, const struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.flags)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.options)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.str)); + if (r->in.str) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.str, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.str, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.str, ndr_charset_length(r->in.str, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.printer_local)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.t1)); + if (r->in.t1) { + NDR_CHECK(ndr_push_spoolss_NotifyOptionsContainer(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.t1)); + } + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct ndr_pull *ndr, int flags, struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r) +{ + uint32_t _ptr_str; + uint32_t _ptr_t1; + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_str_0; + TALLOC_CTX *_mem_save_t1_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.flags)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.options)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_str)); + if (_ptr_str) { + NDR_PULL_ALLOC(ndr, r->in.str); + } else { + r->in.str = NULL; + } + if (r->in.str) { + _mem_save_str_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.str, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.str)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.str)); + if (ndr_get_array_length(ndr, &r->in.str) > ndr_get_array_size(ndr, &r->in.str)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.str), ndr_get_array_length(ndr, &r->in.str)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.str), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.str, ndr_get_array_length(ndr, &r->in.str), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_str_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.printer_local)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_t1)); + if (_ptr_t1) { + NDR_PULL_ALLOC(ndr, r->in.t1); + } else { + r->in.t1 = NULL; + } + if (r->in.t1) { + _mem_save_t1_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.t1, 0); + NDR_CHECK(ndr_pull_spoolss_NotifyOptionsContainer(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.t1)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_t1_0, 0); + } + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r) +{ + ndr_print_struct(ndr, name, "spoolss_RemoteFindFirstPrinterChangeNotifyEx"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_RemoteFindFirstPrinterChangeNotifyEx"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "flags", r->in.flags); + ndr_print_uint32(ndr, "options", r->in.options); + ndr_print_ptr(ndr, "str", r->in.str); + ndr->depth++; + if (r->in.str) { + ndr_print_string(ndr, "str", r->in.str); + } + ndr->depth--; + ndr_print_uint32(ndr, "printer_local", r->in.printer_local); + ndr_print_ptr(ndr, "t1", r->in.t1); + ndr->depth++; + if (r->in.t1) { + ndr_print_spoolss_NotifyOptionsContainer(ndr, "t1", r->in.t1); + } + ndr->depth--; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_RemoteFindFirstPrinterChangeNotifyEx"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_RouterRefreshPrinterChangeNotification(struct ndr_push *ndr, int flags, const struct spoolss_RouterRefreshPrinterChangeNotification *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_RouterRefreshPrinterChangeNotification(struct ndr_pull *ndr, int flags, struct spoolss_RouterRefreshPrinterChangeNotification *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_RouterRefreshPrinterChangeNotification(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_RouterRefreshPrinterChangeNotification *r) +{ + ndr_print_struct(ndr, name, "spoolss_RouterRefreshPrinterChangeNotification"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_RouterRefreshPrinterChangeNotification"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_RouterRefreshPrinterChangeNotification"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_RemoteFindNextPrinterChangeNotifyEx(struct ndr_push *ndr, int flags, const struct spoolss_RemoteFindNextPrinterChangeNotifyEx *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.change_low)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.container)); + if (r->in.container) { + NDR_CHECK(ndr_push_spoolss_NotifyOptionsContainer(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.container)); + } + } + if (flags & NDR_OUT) { + if (r->out.info == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.info)); + if (*r->out.info) { + NDR_CHECK(ndr_push_spoolss_NotifyInfo(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.info)); + } + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_RemoteFindNextPrinterChangeNotifyEx(struct ndr_pull *ndr, int flags, struct spoolss_RemoteFindNextPrinterChangeNotifyEx *r) +{ + uint32_t _ptr_container; + uint32_t _ptr_info; + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_container_0; + TALLOC_CTX *_mem_save_info_0; + TALLOC_CTX *_mem_save_info_1; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.change_low)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_container)); + if (_ptr_container) { + NDR_PULL_ALLOC(ndr, r->in.container); + } else { + r->in.container = NULL; + } + if (r->in.container) { + _mem_save_container_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.container, 0); + NDR_CHECK(ndr_pull_spoolss_NotifyOptionsContainer(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.container)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_container_0, 0); + } + NDR_PULL_ALLOC(ndr, r->out.info); + ZERO_STRUCTP(r->out.info); + } + if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.info); + } + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.info, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, *r->out.info); + } else { + *r->out.info = NULL; + } + if (*r->out.info) { + _mem_save_info_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.info, 0); + NDR_CHECK(ndr_pull_spoolss_NotifyInfo(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_1, 0); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_RemoteFindNextPrinterChangeNotifyEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_RemoteFindNextPrinterChangeNotifyEx *r) +{ + ndr_print_struct(ndr, name, "spoolss_RemoteFindNextPrinterChangeNotifyEx"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_RemoteFindNextPrinterChangeNotifyEx"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "change_low", r->in.change_low); + ndr_print_ptr(ndr, "container", r->in.container); + ndr->depth++; + if (r->in.container) { + ndr_print_spoolss_NotifyOptionsContainer(ndr, "container", r->in.container); + } + ndr->depth--; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_RemoteFindNextPrinterChangeNotifyEx"); + ndr->depth++; + ndr_print_ptr(ndr, "info", r->out.info); + ndr->depth++; + ndr_print_ptr(ndr, "info", *r->out.info); + ndr->depth++; + if (*r->out.info) { + ndr_print_spoolss_NotifyInfo(ndr, "info", *r->out.info); + } + ndr->depth--; + ndr->depth--; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_44(struct ndr_push *ndr, int flags, const struct spoolss_44 *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_44(struct ndr_pull *ndr, int flags, struct spoolss_44 *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_44(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_44 *r) +{ + ndr_print_struct(ndr, name, "spoolss_44"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_44"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_44"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_OpenPrinterEx(struct ndr_push *ndr, int flags, const struct spoolss_OpenPrinterEx *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.printername)); + if (r->in.printername) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.printername, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.printername, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.printername, ndr_charset_length(r->in.printername, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.datatype)); + if (r->in.datatype) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.datatype, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.datatype, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.datatype, ndr_charset_length(r->in.datatype, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_spoolss_DevmodeContainer(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.devmode_ctr)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.access_mask)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->in.userlevel, r->in.level)); + NDR_CHECK(ndr_push_spoolss_UserLevel(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.userlevel)); + } + if (flags & NDR_OUT) { + if (r->out.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->out.handle)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_OpenPrinterEx(struct ndr_pull *ndr, int flags, struct spoolss_OpenPrinterEx *r) +{ + uint32_t _ptr_printername; + uint32_t _ptr_datatype; + TALLOC_CTX *_mem_save_printername_0; + TALLOC_CTX *_mem_save_datatype_0; + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_printername)); + if (_ptr_printername) { + NDR_PULL_ALLOC(ndr, r->in.printername); + } else { + r->in.printername = NULL; + } + if (r->in.printername) { + _mem_save_printername_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.printername, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.printername)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.printername)); + if (ndr_get_array_length(ndr, &r->in.printername) > ndr_get_array_size(ndr, &r->in.printername)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.printername), ndr_get_array_length(ndr, &r->in.printername)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.printername), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.printername, ndr_get_array_length(ndr, &r->in.printername), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printername_0, 0); + } + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_datatype)); + if (_ptr_datatype) { + NDR_PULL_ALLOC(ndr, r->in.datatype); + } else { + r->in.datatype = NULL; + } + if (r->in.datatype) { + _mem_save_datatype_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.datatype, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.datatype)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.datatype)); + if (ndr_get_array_length(ndr, &r->in.datatype) > ndr_get_array_size(ndr, &r->in.datatype)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.datatype), ndr_get_array_length(ndr, &r->in.datatype)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.datatype), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.datatype, ndr_get_array_length(ndr, &r->in.datatype), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_datatype_0, 0); + } + NDR_CHECK(ndr_pull_spoolss_DevmodeContainer(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.devmode_ctr)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.access_mask)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->in.userlevel, r->in.level)); + NDR_CHECK(ndr_pull_spoolss_UserLevel(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.userlevel)); + NDR_PULL_ALLOC(ndr, r->out.handle); + ZERO_STRUCTP(r->out.handle); + } + if (flags & NDR_OUT) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->out.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_OpenPrinterEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_OpenPrinterEx *r) +{ + ndr_print_struct(ndr, name, "spoolss_OpenPrinterEx"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_OpenPrinterEx"); + ndr->depth++; + ndr_print_ptr(ndr, "printername", r->in.printername); + ndr->depth++; + if (r->in.printername) { + ndr_print_string(ndr, "printername", r->in.printername); + } + ndr->depth--; + ndr_print_ptr(ndr, "datatype", r->in.datatype); + ndr->depth++; + if (r->in.datatype) { + ndr_print_string(ndr, "datatype", r->in.datatype); + } + ndr->depth--; + ndr_print_spoolss_DevmodeContainer(ndr, "devmode_ctr", &r->in.devmode_ctr); + ndr_print_uint32(ndr, "access_mask", r->in.access_mask); + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_set_switch_value(ndr, &r->in.userlevel, r->in.level); + ndr_print_spoolss_UserLevel(ndr, "userlevel", &r->in.userlevel); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_OpenPrinterEx"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->out.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->out.handle); + ndr->depth--; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_AddPrinterEx(struct ndr_push *ndr, int flags, const struct spoolss_AddPrinterEx *r) +{ + if (flags & NDR_IN) { + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.server)); + if (r->in.server) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.server, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.server, ndr_charset_length(r->in.server, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.level)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.info)); + if (r->in.info) { + NDR_CHECK(ndr_push_set_switch_value(ndr, r->in.info, r->in.level)); + NDR_CHECK(ndr_push_spoolss_PrinterInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info)); + } + NDR_CHECK(ndr_push_spoolss_DevmodeContainer(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.devmode_ctr)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.secdesc)); + if (r->in.secdesc) { + NDR_CHECK(ndr_push_security_descriptor(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.secdesc)); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.ulevel)); + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->in.userlevel, r->in.ulevel)); + NDR_CHECK(ndr_push_spoolss_UserLevel(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.userlevel)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_AddPrinterEx(struct ndr_pull *ndr, int flags, struct spoolss_AddPrinterEx *r) +{ + uint32_t _ptr_server; + uint32_t _ptr_info; + uint32_t _ptr_secdesc; + TALLOC_CTX *_mem_save_server_0; + TALLOC_CTX *_mem_save_info_0; + TALLOC_CTX *_mem_save_secdesc_0; + if (flags & NDR_IN) { + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_server)); + if (_ptr_server) { + NDR_PULL_ALLOC(ndr, r->in.server); + } else { + r->in.server = NULL; + } + if (r->in.server) { + _mem_save_server_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.server, 0); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.server)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.server)); + if (ndr_get_array_length(ndr, &r->in.server) > ndr_get_array_size(ndr, &r->in.server)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.server), ndr_get_array_length(ndr, &r->in.server)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.server), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.server, ndr_get_array_length(ndr, &r->in.server), sizeof(uint16_t), CH_UTF16)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.level)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_PULL_ALLOC(ndr, r->in.info); + } else { + r->in.info = NULL; + } + if (r->in.info) { + _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.info, 0); + NDR_CHECK(ndr_pull_set_switch_value(ndr, r->in.info, r->in.level)); + NDR_CHECK(ndr_pull_spoolss_PrinterInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.info)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0); + } + NDR_CHECK(ndr_pull_spoolss_DevmodeContainer(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.devmode_ctr)); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_secdesc)); + if (_ptr_secdesc) { + NDR_PULL_ALLOC(ndr, r->in.secdesc); + } else { + r->in.secdesc = NULL; + } + if (r->in.secdesc) { + _mem_save_secdesc_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.secdesc, 0); + NDR_CHECK(ndr_pull_security_descriptor(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.secdesc)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_secdesc_0, 0); + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.ulevel)); + NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->in.userlevel, r->in.ulevel)); + NDR_CHECK(ndr_pull_spoolss_UserLevel(ndr, NDR_SCALARS|NDR_BUFFERS, &r->in.userlevel)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AddPrinterEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrinterEx *r) +{ + ndr_print_struct(ndr, name, "spoolss_AddPrinterEx"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_AddPrinterEx"); + ndr->depth++; + ndr_print_ptr(ndr, "server", r->in.server); + ndr->depth++; + if (r->in.server) { + ndr_print_string(ndr, "server", r->in.server); + } + ndr->depth--; + ndr_print_uint32(ndr, "level", r->in.level); + ndr_print_ptr(ndr, "info", r->in.info); + ndr->depth++; + if (r->in.info) { + ndr_print_set_switch_value(ndr, r->in.info, r->in.level); + ndr_print_spoolss_PrinterInfo(ndr, "info", r->in.info); + } + ndr->depth--; + ndr_print_spoolss_DevmodeContainer(ndr, "devmode_ctr", &r->in.devmode_ctr); + ndr_print_ptr(ndr, "secdesc", r->in.secdesc); + ndr->depth++; + if (r->in.secdesc) { + ndr_print_security_descriptor(ndr, "secdesc", r->in.secdesc); + } + ndr->depth--; + ndr_print_uint32(ndr, "ulevel", r->in.ulevel); + ndr_print_set_switch_value(ndr, &r->in.userlevel, r->in.ulevel); + ndr_print_spoolss_UserLevel(ndr, "userlevel", &r->in.userlevel); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_AddPrinterEx"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_47(struct ndr_push *ndr, int flags, const struct spoolss_47 *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_47(struct ndr_pull *ndr, int flags, struct spoolss_47 *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_47(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_47 *r) +{ + ndr_print_struct(ndr, name, "spoolss_47"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_47"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_47"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_EnumPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterData *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.enum_index)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.value_offered)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.data_offered)); + } + if (flags & NDR_OUT) { + if (r->out.value_name == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.value_offered / 2)); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->out.value_name, r->in.value_offered / 2, sizeof(uint16_t), CH_UTF16)); + if (r->out.value_needed == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.value_needed)); + if (r->out.printerdata_type == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.printerdata_type)); + if (r->out.buffer == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->out.buffer)); + if (r->out.data_needed == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.data_needed)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_EnumPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterData *r) +{ + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_value_needed_0; + TALLOC_CTX *_mem_save_printerdata_type_0; + TALLOC_CTX *_mem_save_buffer_0; + TALLOC_CTX *_mem_save_data_needed_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.enum_index)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.value_offered)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.data_offered)); + NDR_PULL_ALLOC_N(ndr, r->out.value_name, r->in.value_offered / 2); + memset(CONST_DISCARD(struct spoolss_EnumPrinterData *,r->out.value_name), 0, (r->in.value_offered / 2) * sizeof(*r->out.value_name)); + NDR_PULL_ALLOC(ndr, r->out.value_needed); + ZERO_STRUCTP(r->out.value_needed); + NDR_PULL_ALLOC(ndr, r->out.printerdata_type); + ZERO_STRUCTP(r->out.printerdata_type); + NDR_PULL_ALLOC(ndr, r->out.buffer); + ZERO_STRUCTP(r->out.buffer); + NDR_PULL_ALLOC(ndr, r->out.data_needed); + ZERO_STRUCTP(r->out.data_needed); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_array_size(ndr, &r->out.value_name)); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->out.value_name, ndr_get_array_size(ndr, &r->out.value_name), sizeof(uint16_t), CH_UTF16)); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.value_needed); + } + _mem_save_value_needed_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.value_needed, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.value_needed)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_value_needed_0, LIBNDR_FLAG_REF_ALLOC); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.printerdata_type); + } + _mem_save_printerdata_type_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.printerdata_type, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.printerdata_type)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printerdata_type_0, LIBNDR_FLAG_REF_ALLOC); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.buffer); + } + _mem_save_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.buffer, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->out.buffer)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_buffer_0, LIBNDR_FLAG_REF_ALLOC); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.data_needed); + } + _mem_save_data_needed_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.data_needed, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.data_needed)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_needed_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + if (r->out.value_name) { + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->out.value_name, r->in.value_offered / 2)); + } + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_EnumPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrinterData *r) +{ + ndr_print_struct(ndr, name, "spoolss_EnumPrinterData"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_EnumPrinterData"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "enum_index", r->in.enum_index); + ndr_print_uint32(ndr, "value_offered", r->in.value_offered); + ndr_print_uint32(ndr, "data_offered", r->in.data_offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_EnumPrinterData"); + ndr->depth++; + ndr_print_ptr(ndr, "value_name", r->out.value_name); + ndr->depth++; + ndr_print_string(ndr, "value_name", r->out.value_name); + ndr->depth--; + ndr_print_ptr(ndr, "value_needed", r->out.value_needed); + ndr->depth++; + ndr_print_uint32(ndr, "value_needed", *r->out.value_needed); + ndr->depth--; + ndr_print_ptr(ndr, "printerdata_type", r->out.printerdata_type); + ndr->depth++; + ndr_print_uint32(ndr, "printerdata_type", *r->out.printerdata_type); + ndr->depth--; + ndr_print_ptr(ndr, "buffer", r->out.buffer); + ndr->depth++; + ndr_print_DATA_BLOB(ndr, "buffer", *r->out.buffer); + ndr->depth--; + ndr_print_ptr(ndr, "data_needed", r->out.data_needed); + ndr->depth++; + ndr_print_uint32(ndr, "data_needed", *r->out.data_needed); + ndr->depth--; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DeletePrinterData(struct ndr_push *ndr, int flags, const struct spoolss_DeletePrinterData *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.value_name, ndr_charset_length(r->in.value_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DeletePrinterData(struct ndr_pull *ndr, int flags, struct spoolss_DeletePrinterData *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.value_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.value_name)); + if (ndr_get_array_length(ndr, &r->in.value_name) > ndr_get_array_size(ndr, &r->in.value_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.value_name), ndr_get_array_length(ndr, &r->in.value_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.value_name, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t), CH_UTF16)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeletePrinterData(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinterData *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeletePrinterData"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_DeletePrinterData"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_string(ndr, "value_name", r->in.value_name); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_DeletePrinterData"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_4a(struct ndr_push *ndr, int flags, const struct spoolss_4a *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_4a(struct ndr_pull *ndr, int flags, struct spoolss_4a *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_4a(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_4a *r) +{ + ndr_print_struct(ndr, name, "spoolss_4a"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_4a"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_4a"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_4b(struct ndr_push *ndr, int flags, const struct spoolss_4b *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_4b(struct ndr_pull *ndr, int flags, struct spoolss_4b *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_4b(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_4b *r) +{ + ndr_print_struct(ndr, name, "spoolss_4b"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_4b"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_4b"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_4c(struct ndr_push *ndr, int flags, const struct spoolss_4c *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_4c(struct ndr_pull *ndr, int flags, struct spoolss_4c *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_4c(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_4c *r) +{ + ndr_print_struct(ndr, name, "spoolss_4c"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_4c"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_4c"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_SetPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterDataEx *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.key_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.key_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.key_name, ndr_charset_length(r->in.key_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.value_name, ndr_charset_length(r->in.value_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.type)); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->in.buffer)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_SetPrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_SetPrinterDataEx *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.key_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.key_name)); + if (ndr_get_array_length(ndr, &r->in.key_name) > ndr_get_array_size(ndr, &r->in.key_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.key_name), ndr_get_array_length(ndr, &r->in.key_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.key_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.key_name, ndr_get_array_length(ndr, &r->in.key_name), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.value_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.value_name)); + if (ndr_get_array_length(ndr, &r->in.value_name) > ndr_get_array_size(ndr, &r->in.value_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.value_name), ndr_get_array_length(ndr, &r->in.value_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.value_name, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.type)); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->in.buffer)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_SetPrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_SetPrinterDataEx *r) +{ + ndr_print_struct(ndr, name, "spoolss_SetPrinterDataEx"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_SetPrinterDataEx"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_string(ndr, "key_name", r->in.key_name); + ndr_print_string(ndr, "value_name", r->in.value_name); + ndr_print_uint32(ndr, "type", r->in.type); + ndr_print_DATA_BLOB(ndr, "buffer", r->in.buffer); + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_SetPrinterDataEx"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_GetPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterDataEx *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.key_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.key_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.key_name, ndr_charset_length(r->in.key_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.value_name, ndr_charset_length(r->in.value_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.type)); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->out.buffer)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_GetPrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterDataEx *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.key_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.key_name)); + if (ndr_get_array_length(ndr, &r->in.key_name) > ndr_get_array_size(ndr, &r->in.key_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.key_name), ndr_get_array_length(ndr, &r->in.key_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.key_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.key_name, ndr_get_array_length(ndr, &r->in.key_name), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.value_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.value_name)); + if (ndr_get_array_length(ndr, &r->in.value_name) > ndr_get_array_size(ndr, &r->in.value_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.value_name), ndr_get_array_length(ndr, &r->in.value_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.value_name, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.type)); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->out.buffer)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_GetPrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinterDataEx *r) +{ + ndr_print_struct(ndr, name, "spoolss_GetPrinterDataEx"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_GetPrinterDataEx"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_string(ndr, "key_name", r->in.key_name); + ndr_print_string(ndr, "value_name", r->in.value_name); + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_GetPrinterDataEx"); + ndr->depth++; + ndr_print_uint32(ndr, "type", r->out.type); + ndr_print_DATA_BLOB(ndr, "buffer", r->out.buffer); + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_EnumPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterDataEx *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.key_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.key_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.key_name, ndr_charset_length(r->in.key_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->out.buffer)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.count)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_EnumPrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterDataEx *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.key_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.key_name)); + if (ndr_get_array_length(ndr, &r->in.key_name) > ndr_get_array_size(ndr, &r->in.key_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.key_name), ndr_get_array_length(ndr, &r->in.key_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.key_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.key_name, ndr_get_array_length(ndr, &r->in.key_name), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->out.buffer)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.count)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_EnumPrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrinterDataEx *r) +{ + ndr_print_struct(ndr, name, "spoolss_EnumPrinterDataEx"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_EnumPrinterDataEx"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_string(ndr, "key_name", r->in.key_name); + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_EnumPrinterDataEx"); + ndr->depth++; + ndr_print_DATA_BLOB(ndr, "buffer", r->out.buffer); + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_uint32(ndr, "count", r->out.count); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_EnumPrinterKey(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterKey *r) +{ + uint32_t cntr_key_buffer_0; + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.key_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.key_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.key_name, ndr_charset_length(r->in.key_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.needed)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.key_buffer_size)); + for (cntr_key_buffer_0 = 0; cntr_key_buffer_0 < r->out.key_buffer_size; cntr_key_buffer_0++) { + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->out.key_buffer[cntr_key_buffer_0])); + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_EnumPrinterKey(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterKey *r) +{ + uint32_t cntr_key_buffer_0; + TALLOC_CTX *_mem_save_handle_0; + TALLOC_CTX *_mem_save_key_buffer_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.key_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.key_name)); + if (ndr_get_array_length(ndr, &r->in.key_name) > ndr_get_array_size(ndr, &r->in.key_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.key_name), ndr_get_array_length(ndr, &r->in.key_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.key_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.key_name, ndr_get_array_length(ndr, &r->in.key_name), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.needed)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.key_buffer_size)); + NDR_PULL_ALLOC_N(ndr, r->out.key_buffer, r->out.key_buffer_size); + _mem_save_key_buffer_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.key_buffer, 0); + for (cntr_key_buffer_0 = 0; cntr_key_buffer_0 < r->out.key_buffer_size; cntr_key_buffer_0++) { + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->out.key_buffer[cntr_key_buffer_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_key_buffer_0, 0); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_EnumPrinterKey(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrinterKey *r) +{ + uint32_t cntr_key_buffer_0; + ndr_print_struct(ndr, name, "spoolss_EnumPrinterKey"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_EnumPrinterKey"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_string(ndr, "key_name", r->in.key_name); + ndr_print_uint32(ndr, "needed", r->in.needed); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_EnumPrinterKey"); + ndr->depth++; + ndr_print_uint32(ndr, "key_buffer_size", r->out.key_buffer_size); + ndr->print(ndr, "%s: ARRAY(%d)", "key_buffer", (int)r->out.key_buffer_size); + ndr->depth++; + for (cntr_key_buffer_0=0;cntr_key_buffer_0out.key_buffer_size;cntr_key_buffer_0++) { + char *idx_0=NULL; + if (asprintf(&idx_0, "[%d]", cntr_key_buffer_0) != -1) { + ndr_print_uint16(ndr, "key_buffer", r->out.key_buffer[cntr_key_buffer_0]); + free(idx_0); + } + } + ndr->depth--; + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DeletePrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_DeletePrinterDataEx *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.key_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.key_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.key_name, ndr_charset_length(r->in.key_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.value_name, ndr_charset_length(r->in.value_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DeletePrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_DeletePrinterDataEx *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.key_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.key_name)); + if (ndr_get_array_length(ndr, &r->in.key_name) > ndr_get_array_size(ndr, &r->in.key_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.key_name), ndr_get_array_length(ndr, &r->in.key_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.key_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.key_name, ndr_get_array_length(ndr, &r->in.key_name), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.value_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.value_name)); + if (ndr_get_array_length(ndr, &r->in.value_name) > ndr_get_array_size(ndr, &r->in.value_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.value_name), ndr_get_array_length(ndr, &r->in.value_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.value_name, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t), CH_UTF16)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeletePrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinterDataEx *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeletePrinterDataEx"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_DeletePrinterDataEx"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_string(ndr, "key_name", r->in.key_name); + ndr_print_string(ndr, "value_name", r->in.value_name); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_DeletePrinterDataEx"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DeletePrinterKey(struct ndr_push *ndr, int flags, const struct spoolss_DeletePrinterKey *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DeletePrinterKey(struct ndr_pull *ndr, int flags, struct spoolss_DeletePrinterKey *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeletePrinterKey(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinterKey *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeletePrinterKey"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_DeletePrinterKey"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_DeletePrinterKey"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_53(struct ndr_push *ndr, int flags, const struct spoolss_53 *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_53(struct ndr_pull *ndr, int flags, struct spoolss_53 *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_53(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_53 *r) +{ + ndr_print_struct(ndr, name, "spoolss_53"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_53"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_53"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_DeletePrinterDriverEx(struct ndr_push *ndr, int flags, const struct spoolss_DeletePrinterDriverEx *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_DeletePrinterDriverEx(struct ndr_pull *ndr, int flags, struct spoolss_DeletePrinterDriverEx *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_DeletePrinterDriverEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinterDriverEx *r) +{ + ndr_print_struct(ndr, name, "spoolss_DeletePrinterDriverEx"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_DeletePrinterDriverEx"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_DeletePrinterDriverEx"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_55(struct ndr_push *ndr, int flags, const struct spoolss_55 *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_55(struct ndr_pull *ndr, int flags, struct spoolss_55 *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_55(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_55 *r) +{ + ndr_print_struct(ndr, name, "spoolss_55"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_55"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_55"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_56(struct ndr_push *ndr, int flags, const struct spoolss_56 *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_56(struct ndr_pull *ndr, int flags, struct spoolss_56 *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_56(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_56 *r) +{ + ndr_print_struct(ndr, name, "spoolss_56"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_56"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_56"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_57(struct ndr_push *ndr, int flags, const struct spoolss_57 *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_57(struct ndr_pull *ndr, int flags, struct spoolss_57 *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_57(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_57 *r) +{ + ndr_print_struct(ndr, name, "spoolss_57"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_57"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_57"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_XcvData(struct ndr_push *ndr, int flags, const struct spoolss_XcvData *r) +{ + if (flags & NDR_IN) { + if (r->in.handle == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.function_name, CH_UTF16))); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.function_name, CH_UTF16))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.function_name, ndr_charset_length(r->in.function_name, CH_UTF16), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->in.in_data)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.in_data.length)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.unknown1)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->out.out_data)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.needed)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->out.unknown2)); + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_XcvData(struct ndr_pull *ndr, int flags, struct spoolss_XcvData *r) +{ + TALLOC_CTX *_mem_save_handle_0; + if (flags & NDR_IN) { + ZERO_STRUCT(r->out); + + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->in.handle); + } + _mem_save_handle_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.handle, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_policy_handle(ndr, NDR_SCALARS, r->in.handle)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_handle_0, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_array_size(ndr, &r->in.function_name)); + NDR_CHECK(ndr_pull_array_length(ndr, &r->in.function_name)); + if (ndr_get_array_length(ndr, &r->in.function_name) > ndr_get_array_size(ndr, &r->in.function_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.function_name), ndr_get_array_length(ndr, &r->in.function_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.function_name), sizeof(uint16_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.function_name, ndr_get_array_length(ndr, &r->in.function_name), sizeof(uint16_t), CH_UTF16)); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->in.in_data)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in._in_data_length)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.unknown1)); + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->out.out_data)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.needed)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->out.unknown2)); + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_XcvData(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_XcvData *r) +{ + ndr_print_struct(ndr, name, "spoolss_XcvData"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_XcvData"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); + ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_string(ndr, "function_name", r->in.function_name); + ndr_print_DATA_BLOB(ndr, "in_data", r->in.in_data); + ndr_print_uint32(ndr, "_in_data_length", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?r->in.in_data.length:r->in._in_data_length); + ndr_print_uint32(ndr, "offered", r->in.offered); + ndr_print_uint32(ndr, "unknown1", r->in.unknown1); + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_XcvData"); + ndr->depth++; + ndr_print_DATA_BLOB(ndr, "out_data", r->out.out_data); + ndr_print_uint32(ndr, "needed", r->out.needed); + ndr_print_uint32(ndr, "unknown2", r->out.unknown2); + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +_PUBLIC_ enum ndr_err_code ndr_push_spoolss_AddPrinterDriverEx(struct ndr_push *ndr, int flags, const struct spoolss_AddPrinterDriverEx *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_AddPrinterDriverEx(struct ndr_pull *ndr, int flags, struct spoolss_AddPrinterDriverEx *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_AddPrinterDriverEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrinterDriverEx *r) +{ + ndr_print_struct(ndr, name, "spoolss_AddPrinterDriverEx"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_AddPrinterDriverEx"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_AddPrinterDriverEx"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_5a(struct ndr_push *ndr, int flags, const struct spoolss_5a *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_5a(struct ndr_pull *ndr, int flags, struct spoolss_5a *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_5a(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_5a *r) +{ + ndr_print_struct(ndr, name, "spoolss_5a"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_5a"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_5a"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_5b(struct ndr_push *ndr, int flags, const struct spoolss_5b *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_5b(struct ndr_pull *ndr, int flags, struct spoolss_5b *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_5b(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_5b *r) +{ + ndr_print_struct(ndr, name, "spoolss_5b"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_5b"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_5b"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_5c(struct ndr_push *ndr, int flags, const struct spoolss_5c *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_5c(struct ndr_pull *ndr, int flags, struct spoolss_5c *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_5c(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_5c *r) +{ + ndr_print_struct(ndr, name, "spoolss_5c"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_5c"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_5c"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_5d(struct ndr_push *ndr, int flags, const struct spoolss_5d *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_5d(struct ndr_pull *ndr, int flags, struct spoolss_5d *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_5d(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_5d *r) +{ + ndr_print_struct(ndr, name, "spoolss_5d"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_5d"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_5d"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_5e(struct ndr_push *ndr, int flags, const struct spoolss_5e *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_5e(struct ndr_pull *ndr, int flags, struct spoolss_5e *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_5e(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_5e *r) +{ + ndr_print_struct(ndr, name, "spoolss_5e"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_5e"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_5e"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static enum ndr_err_code ndr_push_spoolss_5f(struct ndr_push *ndr, int flags, const struct spoolss_5f *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_spoolss_5f(struct ndr_pull *ndr, int flags, struct spoolss_5f *r) +{ + if (flags & NDR_IN) { + } + if (flags & NDR_OUT) { + NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_spoolss_5f(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_5f *r) +{ + ndr_print_struct(ndr, name, "spoolss_5f"); + ndr->depth++; + if (flags & NDR_SET_VALUES) { + ndr->flags |= LIBNDR_PRINT_SET_VALUES; + } + if (flags & NDR_IN) { + ndr_print_struct(ndr, "in", "spoolss_5f"); + ndr->depth++; + ndr->depth--; + } + if (flags & NDR_OUT) { + ndr_print_struct(ndr, "out", "spoolss_5f"); + ndr->depth++; + ndr_print_WERROR(ndr, "result", r->out.result); + ndr->depth--; + } + ndr->depth--; +} + +static const struct ndr_interface_call spoolss_calls[] = { + { + "spoolss_EnumPrinters", + sizeof(struct spoolss_EnumPrinters), + (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinters, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinters, + (ndr_print_function_t) ndr_print_spoolss_EnumPrinters, + false, + }, + { + "spoolss_OpenPrinter", + sizeof(struct spoolss_OpenPrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_OpenPrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_OpenPrinter, + (ndr_print_function_t) ndr_print_spoolss_OpenPrinter, + false, + }, + { + "spoolss_SetJob", + sizeof(struct spoolss_SetJob), + (ndr_push_flags_fn_t) ndr_push_spoolss_SetJob, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetJob, + (ndr_print_function_t) ndr_print_spoolss_SetJob, + false, + }, + { + "spoolss_GetJob", + sizeof(struct spoolss_GetJob), + (ndr_push_flags_fn_t) ndr_push_spoolss_GetJob, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetJob, + (ndr_print_function_t) ndr_print_spoolss_GetJob, + false, + }, + { + "spoolss_EnumJobs", + sizeof(struct spoolss_EnumJobs), + (ndr_push_flags_fn_t) ndr_push_spoolss_EnumJobs, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumJobs, + (ndr_print_function_t) ndr_print_spoolss_EnumJobs, + false, + }, + { + "spoolss_AddPrinter", + sizeof(struct spoolss_AddPrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinter, + (ndr_print_function_t) ndr_print_spoolss_AddPrinter, + false, + }, + { + "spoolss_DeletePrinter", + sizeof(struct spoolss_DeletePrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinter, + (ndr_print_function_t) ndr_print_spoolss_DeletePrinter, + false, + }, + { + "spoolss_SetPrinter", + sizeof(struct spoolss_SetPrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_SetPrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetPrinter, + (ndr_print_function_t) ndr_print_spoolss_SetPrinter, + false, + }, + { + "spoolss_GetPrinter", + sizeof(struct spoolss_GetPrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinter, + (ndr_print_function_t) ndr_print_spoolss_GetPrinter, + false, + }, + { + "spoolss_AddPrinterDriver", + sizeof(struct spoolss_AddPrinterDriver), + (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinterDriver, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinterDriver, + (ndr_print_function_t) ndr_print_spoolss_AddPrinterDriver, + false, + }, + { + "spoolss_EnumPrinterDrivers", + sizeof(struct spoolss_EnumPrinterDrivers), + (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinterDrivers, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinterDrivers, + (ndr_print_function_t) ndr_print_spoolss_EnumPrinterDrivers, + false, + }, + { + "spoolss_GetPrinterDriver", + sizeof(struct spoolss_GetPrinterDriver), + (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterDriver, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterDriver, + (ndr_print_function_t) ndr_print_spoolss_GetPrinterDriver, + false, + }, + { + "spoolss_GetPrinterDriverDirectory", + sizeof(struct spoolss_GetPrinterDriverDirectory), + (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterDriverDirectory, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterDriverDirectory, + (ndr_print_function_t) ndr_print_spoolss_GetPrinterDriverDirectory, + false, + }, + { + "spoolss_DeletePrinterDriver", + sizeof(struct spoolss_DeletePrinterDriver), + (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterDriver, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterDriver, + (ndr_print_function_t) ndr_print_spoolss_DeletePrinterDriver, + false, + }, + { + "spoolss_AddPrintProcessor", + sizeof(struct spoolss_AddPrintProcessor), + (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrintProcessor, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrintProcessor, + (ndr_print_function_t) ndr_print_spoolss_AddPrintProcessor, + false, + }, + { + "spoolss_EnumPrintProcessors", + sizeof(struct spoolss_EnumPrintProcessors), + (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrintProcessors, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrintProcessors, + (ndr_print_function_t) ndr_print_spoolss_EnumPrintProcessors, + false, + }, + { + "spoolss_GetPrintProcessorDirectory", + sizeof(struct spoolss_GetPrintProcessorDirectory), + (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrintProcessorDirectory, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrintProcessorDirectory, + (ndr_print_function_t) ndr_print_spoolss_GetPrintProcessorDirectory, + false, + }, + { + "spoolss_StartDocPrinter", + sizeof(struct spoolss_StartDocPrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_StartDocPrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_StartDocPrinter, + (ndr_print_function_t) ndr_print_spoolss_StartDocPrinter, + false, + }, + { + "spoolss_StartPagePrinter", + sizeof(struct spoolss_StartPagePrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_StartPagePrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_StartPagePrinter, + (ndr_print_function_t) ndr_print_spoolss_StartPagePrinter, + false, + }, + { + "spoolss_WritePrinter", + sizeof(struct spoolss_WritePrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_WritePrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_WritePrinter, + (ndr_print_function_t) ndr_print_spoolss_WritePrinter, + false, + }, + { + "spoolss_EndPagePrinter", + sizeof(struct spoolss_EndPagePrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_EndPagePrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_EndPagePrinter, + (ndr_print_function_t) ndr_print_spoolss_EndPagePrinter, + false, + }, + { + "spoolss_AbortPrinter", + sizeof(struct spoolss_AbortPrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_AbortPrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_AbortPrinter, + (ndr_print_function_t) ndr_print_spoolss_AbortPrinter, + false, + }, + { + "spoolss_ReadPrinter", + sizeof(struct spoolss_ReadPrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_ReadPrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_ReadPrinter, + (ndr_print_function_t) ndr_print_spoolss_ReadPrinter, + false, + }, + { + "spoolss_EndDocPrinter", + sizeof(struct spoolss_EndDocPrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_EndDocPrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_EndDocPrinter, + (ndr_print_function_t) ndr_print_spoolss_EndDocPrinter, + false, + }, + { + "spoolss_AddJob", + sizeof(struct spoolss_AddJob), + (ndr_push_flags_fn_t) ndr_push_spoolss_AddJob, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddJob, + (ndr_print_function_t) ndr_print_spoolss_AddJob, + false, + }, + { + "spoolss_ScheduleJob", + sizeof(struct spoolss_ScheduleJob), + (ndr_push_flags_fn_t) ndr_push_spoolss_ScheduleJob, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_ScheduleJob, + (ndr_print_function_t) ndr_print_spoolss_ScheduleJob, + false, + }, + { + "spoolss_GetPrinterData", + sizeof(struct spoolss_GetPrinterData), + (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterData, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterData, + (ndr_print_function_t) ndr_print_spoolss_GetPrinterData, + false, + }, + { + "spoolss_SetPrinterData", + sizeof(struct spoolss_SetPrinterData), + (ndr_push_flags_fn_t) ndr_push_spoolss_SetPrinterData, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetPrinterData, + (ndr_print_function_t) ndr_print_spoolss_SetPrinterData, + false, + }, + { + "spoolss_WaitForPrinterChange", + sizeof(struct spoolss_WaitForPrinterChange), + (ndr_push_flags_fn_t) ndr_push_spoolss_WaitForPrinterChange, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_WaitForPrinterChange, + (ndr_print_function_t) ndr_print_spoolss_WaitForPrinterChange, + false, + }, + { + "spoolss_ClosePrinter", + sizeof(struct spoolss_ClosePrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_ClosePrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_ClosePrinter, + (ndr_print_function_t) ndr_print_spoolss_ClosePrinter, + false, + }, + { + "spoolss_AddForm", + sizeof(struct spoolss_AddForm), + (ndr_push_flags_fn_t) ndr_push_spoolss_AddForm, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddForm, + (ndr_print_function_t) ndr_print_spoolss_AddForm, + false, + }, + { + "spoolss_DeleteForm", + sizeof(struct spoolss_DeleteForm), + (ndr_push_flags_fn_t) ndr_push_spoolss_DeleteForm, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeleteForm, + (ndr_print_function_t) ndr_print_spoolss_DeleteForm, + false, + }, + { + "spoolss_GetForm", + sizeof(struct spoolss_GetForm), + (ndr_push_flags_fn_t) ndr_push_spoolss_GetForm, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetForm, + (ndr_print_function_t) ndr_print_spoolss_GetForm, + false, + }, + { + "spoolss_SetForm", + sizeof(struct spoolss_SetForm), + (ndr_push_flags_fn_t) ndr_push_spoolss_SetForm, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetForm, + (ndr_print_function_t) ndr_print_spoolss_SetForm, + false, + }, + { + "spoolss_EnumForms", + sizeof(struct spoolss_EnumForms), + (ndr_push_flags_fn_t) ndr_push_spoolss_EnumForms, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumForms, + (ndr_print_function_t) ndr_print_spoolss_EnumForms, + false, + }, + { + "spoolss_EnumPorts", + sizeof(struct spoolss_EnumPorts), + (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPorts, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPorts, + (ndr_print_function_t) ndr_print_spoolss_EnumPorts, + false, + }, + { + "spoolss_EnumMonitors", + sizeof(struct spoolss_EnumMonitors), + (ndr_push_flags_fn_t) ndr_push_spoolss_EnumMonitors, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumMonitors, + (ndr_print_function_t) ndr_print_spoolss_EnumMonitors, + false, + }, + { + "spoolss_AddPort", + sizeof(struct spoolss_AddPort), + (ndr_push_flags_fn_t) ndr_push_spoolss_AddPort, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPort, + (ndr_print_function_t) ndr_print_spoolss_AddPort, + false, + }, + { + "spoolss_ConfigurePort", + sizeof(struct spoolss_ConfigurePort), + (ndr_push_flags_fn_t) ndr_push_spoolss_ConfigurePort, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_ConfigurePort, + (ndr_print_function_t) ndr_print_spoolss_ConfigurePort, + false, + }, + { + "spoolss_DeletePort", + sizeof(struct spoolss_DeletePort), + (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePort, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePort, + (ndr_print_function_t) ndr_print_spoolss_DeletePort, + false, + }, + { + "spoolss_CreatePrinterIC", + sizeof(struct spoolss_CreatePrinterIC), + (ndr_push_flags_fn_t) ndr_push_spoolss_CreatePrinterIC, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_CreatePrinterIC, + (ndr_print_function_t) ndr_print_spoolss_CreatePrinterIC, + false, + }, + { + "spoolss_PlayGDIScriptOnPrinterIC", + sizeof(struct spoolss_PlayGDIScriptOnPrinterIC), + (ndr_push_flags_fn_t) ndr_push_spoolss_PlayGDIScriptOnPrinterIC, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_PlayGDIScriptOnPrinterIC, + (ndr_print_function_t) ndr_print_spoolss_PlayGDIScriptOnPrinterIC, + false, + }, + { + "spoolss_DeletePrinterIC", + sizeof(struct spoolss_DeletePrinterIC), + (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterIC, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterIC, + (ndr_print_function_t) ndr_print_spoolss_DeletePrinterIC, + false, + }, + { + "spoolss_AddPrinterConnection", + sizeof(struct spoolss_AddPrinterConnection), + (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinterConnection, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinterConnection, + (ndr_print_function_t) ndr_print_spoolss_AddPrinterConnection, + false, + }, + { + "spoolss_DeletePrinterConnection", + sizeof(struct spoolss_DeletePrinterConnection), + (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterConnection, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterConnection, + (ndr_print_function_t) ndr_print_spoolss_DeletePrinterConnection, + false, + }, + { + "spoolss_PrinterMessageBox", + sizeof(struct spoolss_PrinterMessageBox), + (ndr_push_flags_fn_t) ndr_push_spoolss_PrinterMessageBox, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_PrinterMessageBox, + (ndr_print_function_t) ndr_print_spoolss_PrinterMessageBox, + false, + }, + { + "spoolss_AddMonitor", + sizeof(struct spoolss_AddMonitor), + (ndr_push_flags_fn_t) ndr_push_spoolss_AddMonitor, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddMonitor, + (ndr_print_function_t) ndr_print_spoolss_AddMonitor, + false, + }, + { + "spoolss_DeleteMonitor", + sizeof(struct spoolss_DeleteMonitor), + (ndr_push_flags_fn_t) ndr_push_spoolss_DeleteMonitor, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeleteMonitor, + (ndr_print_function_t) ndr_print_spoolss_DeleteMonitor, + false, + }, + { + "spoolss_DeletePrintProcessor", + sizeof(struct spoolss_DeletePrintProcessor), + (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrintProcessor, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrintProcessor, + (ndr_print_function_t) ndr_print_spoolss_DeletePrintProcessor, + false, + }, + { + "spoolss_AddPrintProvidor", + sizeof(struct spoolss_AddPrintProvidor), + (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrintProvidor, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrintProvidor, + (ndr_print_function_t) ndr_print_spoolss_AddPrintProvidor, + false, + }, + { + "spoolss_DeletePrintProvidor", + sizeof(struct spoolss_DeletePrintProvidor), + (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrintProvidor, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrintProvidor, + (ndr_print_function_t) ndr_print_spoolss_DeletePrintProvidor, + false, + }, + { + "spoolss_EnumPrintProcDataTypes", + sizeof(struct spoolss_EnumPrintProcDataTypes), + (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrintProcDataTypes, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrintProcDataTypes, + (ndr_print_function_t) ndr_print_spoolss_EnumPrintProcDataTypes, + false, + }, + { + "spoolss_ResetPrinter", + sizeof(struct spoolss_ResetPrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_ResetPrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_ResetPrinter, + (ndr_print_function_t) ndr_print_spoolss_ResetPrinter, + false, + }, + { + "spoolss_GetPrinterDriver2", + sizeof(struct spoolss_GetPrinterDriver2), + (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterDriver2, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterDriver2, + (ndr_print_function_t) ndr_print_spoolss_GetPrinterDriver2, + false, + }, + { + "spoolss_FindFirstPrinterChangeNotification", + sizeof(struct spoolss_FindFirstPrinterChangeNotification), + (ndr_push_flags_fn_t) ndr_push_spoolss_FindFirstPrinterChangeNotification, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_FindFirstPrinterChangeNotification, + (ndr_print_function_t) ndr_print_spoolss_FindFirstPrinterChangeNotification, + false, + }, + { + "spoolss_FindNextPrinterChangeNotification", + sizeof(struct spoolss_FindNextPrinterChangeNotification), + (ndr_push_flags_fn_t) ndr_push_spoolss_FindNextPrinterChangeNotification, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_FindNextPrinterChangeNotification, + (ndr_print_function_t) ndr_print_spoolss_FindNextPrinterChangeNotification, + false, + }, + { + "spoolss_FindClosePrinterNotify", + sizeof(struct spoolss_FindClosePrinterNotify), + (ndr_push_flags_fn_t) ndr_push_spoolss_FindClosePrinterNotify, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_FindClosePrinterNotify, + (ndr_print_function_t) ndr_print_spoolss_FindClosePrinterNotify, + false, + }, + { + "spoolss_RouterFindFirstPrinterChangeNotificationOld", + sizeof(struct spoolss_RouterFindFirstPrinterChangeNotificationOld), + (ndr_push_flags_fn_t) ndr_push_spoolss_RouterFindFirstPrinterChangeNotificationOld, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_RouterFindFirstPrinterChangeNotificationOld, + (ndr_print_function_t) ndr_print_spoolss_RouterFindFirstPrinterChangeNotificationOld, + false, + }, + { + "spoolss_ReplyOpenPrinter", + sizeof(struct spoolss_ReplyOpenPrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_ReplyOpenPrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_ReplyOpenPrinter, + (ndr_print_function_t) ndr_print_spoolss_ReplyOpenPrinter, + false, + }, + { + "spoolss_RouterReplyPrinter", + sizeof(struct spoolss_RouterReplyPrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_RouterReplyPrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_RouterReplyPrinter, + (ndr_print_function_t) ndr_print_spoolss_RouterReplyPrinter, + false, + }, + { + "spoolss_ReplyClosePrinter", + sizeof(struct spoolss_ReplyClosePrinter), + (ndr_push_flags_fn_t) ndr_push_spoolss_ReplyClosePrinter, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_ReplyClosePrinter, + (ndr_print_function_t) ndr_print_spoolss_ReplyClosePrinter, + false, + }, + { + "spoolss_AddPortEx", + sizeof(struct spoolss_AddPortEx), + (ndr_push_flags_fn_t) ndr_push_spoolss_AddPortEx, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPortEx, + (ndr_print_function_t) ndr_print_spoolss_AddPortEx, + false, + }, + { + "spoolss_RouterFindFirstPrinterChangeNotification", + sizeof(struct spoolss_RouterFindFirstPrinterChangeNotification), + (ndr_push_flags_fn_t) ndr_push_spoolss_RouterFindFirstPrinterChangeNotification, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_RouterFindFirstPrinterChangeNotification, + (ndr_print_function_t) ndr_print_spoolss_RouterFindFirstPrinterChangeNotification, + false, + }, + { + "spoolss_SpoolerInit", + sizeof(struct spoolss_SpoolerInit), + (ndr_push_flags_fn_t) ndr_push_spoolss_SpoolerInit, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_SpoolerInit, + (ndr_print_function_t) ndr_print_spoolss_SpoolerInit, + false, + }, + { + "spoolss_ResetPrinterEx", + sizeof(struct spoolss_ResetPrinterEx), + (ndr_push_flags_fn_t) ndr_push_spoolss_ResetPrinterEx, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_ResetPrinterEx, + (ndr_print_function_t) ndr_print_spoolss_ResetPrinterEx, + false, + }, + { + "spoolss_RemoteFindFirstPrinterChangeNotifyEx", + sizeof(struct spoolss_RemoteFindFirstPrinterChangeNotifyEx), + (ndr_push_flags_fn_t) ndr_push_spoolss_RemoteFindFirstPrinterChangeNotifyEx, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_RemoteFindFirstPrinterChangeNotifyEx, + (ndr_print_function_t) ndr_print_spoolss_RemoteFindFirstPrinterChangeNotifyEx, + false, + }, + { + "spoolss_RouterRefreshPrinterChangeNotification", + sizeof(struct spoolss_RouterRefreshPrinterChangeNotification), + (ndr_push_flags_fn_t) ndr_push_spoolss_RouterRefreshPrinterChangeNotification, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_RouterRefreshPrinterChangeNotification, + (ndr_print_function_t) ndr_print_spoolss_RouterRefreshPrinterChangeNotification, + false, + }, + { + "spoolss_RemoteFindNextPrinterChangeNotifyEx", + sizeof(struct spoolss_RemoteFindNextPrinterChangeNotifyEx), + (ndr_push_flags_fn_t) ndr_push_spoolss_RemoteFindNextPrinterChangeNotifyEx, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_RemoteFindNextPrinterChangeNotifyEx, + (ndr_print_function_t) ndr_print_spoolss_RemoteFindNextPrinterChangeNotifyEx, + false, + }, + { + "spoolss_44", + sizeof(struct spoolss_44), + (ndr_push_flags_fn_t) ndr_push_spoolss_44, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_44, + (ndr_print_function_t) ndr_print_spoolss_44, + false, + }, + { + "spoolss_OpenPrinterEx", + sizeof(struct spoolss_OpenPrinterEx), + (ndr_push_flags_fn_t) ndr_push_spoolss_OpenPrinterEx, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_OpenPrinterEx, + (ndr_print_function_t) ndr_print_spoolss_OpenPrinterEx, + false, + }, + { + "spoolss_AddPrinterEx", + sizeof(struct spoolss_AddPrinterEx), + (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinterEx, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinterEx, + (ndr_print_function_t) ndr_print_spoolss_AddPrinterEx, + false, + }, + { + "spoolss_47", + sizeof(struct spoolss_47), + (ndr_push_flags_fn_t) ndr_push_spoolss_47, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_47, + (ndr_print_function_t) ndr_print_spoolss_47, + false, + }, + { + "spoolss_EnumPrinterData", + sizeof(struct spoolss_EnumPrinterData), + (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinterData, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinterData, + (ndr_print_function_t) ndr_print_spoolss_EnumPrinterData, + false, + }, + { + "spoolss_DeletePrinterData", + sizeof(struct spoolss_DeletePrinterData), + (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterData, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterData, + (ndr_print_function_t) ndr_print_spoolss_DeletePrinterData, + false, + }, + { + "spoolss_4a", + sizeof(struct spoolss_4a), + (ndr_push_flags_fn_t) ndr_push_spoolss_4a, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_4a, + (ndr_print_function_t) ndr_print_spoolss_4a, + false, + }, + { + "spoolss_4b", + sizeof(struct spoolss_4b), + (ndr_push_flags_fn_t) ndr_push_spoolss_4b, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_4b, + (ndr_print_function_t) ndr_print_spoolss_4b, + false, + }, + { + "spoolss_4c", + sizeof(struct spoolss_4c), + (ndr_push_flags_fn_t) ndr_push_spoolss_4c, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_4c, + (ndr_print_function_t) ndr_print_spoolss_4c, + false, + }, + { + "spoolss_SetPrinterDataEx", + sizeof(struct spoolss_SetPrinterDataEx), + (ndr_push_flags_fn_t) ndr_push_spoolss_SetPrinterDataEx, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_SetPrinterDataEx, + (ndr_print_function_t) ndr_print_spoolss_SetPrinterDataEx, + false, + }, + { + "spoolss_GetPrinterDataEx", + sizeof(struct spoolss_GetPrinterDataEx), + (ndr_push_flags_fn_t) ndr_push_spoolss_GetPrinterDataEx, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_GetPrinterDataEx, + (ndr_print_function_t) ndr_print_spoolss_GetPrinterDataEx, + false, + }, + { + "spoolss_EnumPrinterDataEx", + sizeof(struct spoolss_EnumPrinterDataEx), + (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinterDataEx, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinterDataEx, + (ndr_print_function_t) ndr_print_spoolss_EnumPrinterDataEx, + false, + }, + { + "spoolss_EnumPrinterKey", + sizeof(struct spoolss_EnumPrinterKey), + (ndr_push_flags_fn_t) ndr_push_spoolss_EnumPrinterKey, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_EnumPrinterKey, + (ndr_print_function_t) ndr_print_spoolss_EnumPrinterKey, + false, + }, + { + "spoolss_DeletePrinterDataEx", + sizeof(struct spoolss_DeletePrinterDataEx), + (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterDataEx, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterDataEx, + (ndr_print_function_t) ndr_print_spoolss_DeletePrinterDataEx, + false, + }, + { + "spoolss_DeletePrinterKey", + sizeof(struct spoolss_DeletePrinterKey), + (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterKey, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterKey, + (ndr_print_function_t) ndr_print_spoolss_DeletePrinterKey, + false, + }, + { + "spoolss_53", + sizeof(struct spoolss_53), + (ndr_push_flags_fn_t) ndr_push_spoolss_53, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_53, + (ndr_print_function_t) ndr_print_spoolss_53, + false, + }, + { + "spoolss_DeletePrinterDriverEx", + sizeof(struct spoolss_DeletePrinterDriverEx), + (ndr_push_flags_fn_t) ndr_push_spoolss_DeletePrinterDriverEx, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeletePrinterDriverEx, + (ndr_print_function_t) ndr_print_spoolss_DeletePrinterDriverEx, + false, + }, + { + "spoolss_55", + sizeof(struct spoolss_55), + (ndr_push_flags_fn_t) ndr_push_spoolss_55, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_55, + (ndr_print_function_t) ndr_print_spoolss_55, + false, + }, + { + "spoolss_56", + sizeof(struct spoolss_56), + (ndr_push_flags_fn_t) ndr_push_spoolss_56, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_56, + (ndr_print_function_t) ndr_print_spoolss_56, + false, + }, + { + "spoolss_57", + sizeof(struct spoolss_57), + (ndr_push_flags_fn_t) ndr_push_spoolss_57, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_57, + (ndr_print_function_t) ndr_print_spoolss_57, + false, + }, + { + "spoolss_XcvData", + sizeof(struct spoolss_XcvData), + (ndr_push_flags_fn_t) ndr_push_spoolss_XcvData, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_XcvData, + (ndr_print_function_t) ndr_print_spoolss_XcvData, + false, + }, + { + "spoolss_AddPrinterDriverEx", + sizeof(struct spoolss_AddPrinterDriverEx), + (ndr_push_flags_fn_t) ndr_push_spoolss_AddPrinterDriverEx, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_AddPrinterDriverEx, + (ndr_print_function_t) ndr_print_spoolss_AddPrinterDriverEx, + false, + }, + { + "spoolss_5a", + sizeof(struct spoolss_5a), + (ndr_push_flags_fn_t) ndr_push_spoolss_5a, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_5a, + (ndr_print_function_t) ndr_print_spoolss_5a, + false, + }, + { + "spoolss_5b", + sizeof(struct spoolss_5b), + (ndr_push_flags_fn_t) ndr_push_spoolss_5b, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_5b, + (ndr_print_function_t) ndr_print_spoolss_5b, + false, + }, + { + "spoolss_5c", + sizeof(struct spoolss_5c), + (ndr_push_flags_fn_t) ndr_push_spoolss_5c, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_5c, + (ndr_print_function_t) ndr_print_spoolss_5c, + false, + }, + { + "spoolss_5d", + sizeof(struct spoolss_5d), + (ndr_push_flags_fn_t) ndr_push_spoolss_5d, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_5d, + (ndr_print_function_t) ndr_print_spoolss_5d, + false, + }, + { + "spoolss_5e", + sizeof(struct spoolss_5e), + (ndr_push_flags_fn_t) ndr_push_spoolss_5e, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_5e, + (ndr_print_function_t) ndr_print_spoolss_5e, + false, + }, + { + "spoolss_5f", + sizeof(struct spoolss_5f), + (ndr_push_flags_fn_t) ndr_push_spoolss_5f, + (ndr_pull_flags_fn_t) ndr_pull_spoolss_5f, + (ndr_print_function_t) ndr_print_spoolss_5f, + false, + }, + { NULL, 0, NULL, NULL, NULL, false } +}; + +static const char * const spoolss_endpoint_strings[] = { + "ncacn_np:[\\pipe\\spoolss]", +}; + +static const struct ndr_interface_string_array spoolss_endpoints = { + .count = 1, + .names = spoolss_endpoint_strings +}; + +static const char * const spoolss_authservice_strings[] = { + "host", +}; + +static const struct ndr_interface_string_array spoolss_authservices = { + .count = 1, + .names = spoolss_authservice_strings +}; + + +const struct ndr_interface_table ndr_table_spoolss = { + .name = "spoolss", + .syntax_id = { + {0x12345678,0x1234,0xabcd,{0xef,0x00},{0x01,0x23,0x45,0x67,0x89,0xab}}, + NDR_SPOOLSS_VERSION + }, + .helpstring = NDR_SPOOLSS_HELPSTRING, + .num_calls = 114, + .calls = spoolss_calls, + .endpoints = &spoolss_endpoints, + .authservices = &spoolss_authservices +}; + diff --git a/librpc/gen_ndr/ndr_spoolss.h b/librpc/gen_ndr/ndr_spoolss.h new file mode 100644 index 0000000000..d5b8ca9bc0 --- /dev/null +++ b/librpc/gen_ndr/ndr_spoolss.h @@ -0,0 +1,501 @@ +/* header auto-generated by pidl */ + +#include "librpc/ndr/libndr.h" +#include "../librpc/gen_ndr/spoolss.h" + +#ifndef _HEADER_NDR_spoolss +#define _HEADER_NDR_spoolss + +#include "../librpc/ndr/ndr_spoolss_buf.h" +#define NDR_SPOOLSS_UUID "12345678-1234-abcd-ef00-0123456789ab" +#define NDR_SPOOLSS_VERSION 1.0 +#define NDR_SPOOLSS_NAME "spoolss" +#define NDR_SPOOLSS_HELPSTRING "Spooler SubSystem" +extern const struct ndr_interface_table ndr_table_spoolss; +#define NDR_SPOOLSS_ENUMPRINTERS (0x00) + +#define NDR_SPOOLSS_OPENPRINTER (0x01) + +#define NDR_SPOOLSS_SETJOB (0x02) + +#define NDR_SPOOLSS_GETJOB (0x03) + +#define NDR_SPOOLSS_ENUMJOBS (0x04) + +#define NDR_SPOOLSS_ADDPRINTER (0x05) + +#define NDR_SPOOLSS_DELETEPRINTER (0x06) + +#define NDR_SPOOLSS_SETPRINTER (0x07) + +#define NDR_SPOOLSS_GETPRINTER (0x08) + +#define NDR_SPOOLSS_ADDPRINTERDRIVER (0x09) + +#define NDR_SPOOLSS_ENUMPRINTERDRIVERS (0x0a) + +#define NDR_SPOOLSS_GETPRINTERDRIVER (0x0b) + +#define NDR_SPOOLSS_GETPRINTERDRIVERDIRECTORY (0x0c) + +#define NDR_SPOOLSS_DELETEPRINTERDRIVER (0x0d) + +#define NDR_SPOOLSS_ADDPRINTPROCESSOR (0x0e) + +#define NDR_SPOOLSS_ENUMPRINTPROCESSORS (0x0f) + +#define NDR_SPOOLSS_GETPRINTPROCESSORDIRECTORY (0x10) + +#define NDR_SPOOLSS_STARTDOCPRINTER (0x11) + +#define NDR_SPOOLSS_STARTPAGEPRINTER (0x12) + +#define NDR_SPOOLSS_WRITEPRINTER (0x13) + +#define NDR_SPOOLSS_ENDPAGEPRINTER (0x14) + +#define NDR_SPOOLSS_ABORTPRINTER (0x15) + +#define NDR_SPOOLSS_READPRINTER (0x16) + +#define NDR_SPOOLSS_ENDDOCPRINTER (0x17) + +#define NDR_SPOOLSS_ADDJOB (0x18) + +#define NDR_SPOOLSS_SCHEDULEJOB (0x19) + +#define NDR_SPOOLSS_GETPRINTERDATA (0x1a) + +#define NDR_SPOOLSS_SETPRINTERDATA (0x1b) + +#define NDR_SPOOLSS_WAITFORPRINTERCHANGE (0x1c) + +#define NDR_SPOOLSS_CLOSEPRINTER (0x1d) + +#define NDR_SPOOLSS_ADDFORM (0x1e) + +#define NDR_SPOOLSS_DELETEFORM (0x1f) + +#define NDR_SPOOLSS_GETFORM (0x20) + +#define NDR_SPOOLSS_SETFORM (0x21) + +#define NDR_SPOOLSS_ENUMFORMS (0x22) + +#define NDR_SPOOLSS_ENUMPORTS (0x23) + +#define NDR_SPOOLSS_ENUMMONITORS (0x24) + +#define NDR_SPOOLSS_ADDPORT (0x25) + +#define NDR_SPOOLSS_CONFIGUREPORT (0x26) + +#define NDR_SPOOLSS_DELETEPORT (0x27) + +#define NDR_SPOOLSS_CREATEPRINTERIC (0x28) + +#define NDR_SPOOLSS_PLAYGDISCRIPTONPRINTERIC (0x29) + +#define NDR_SPOOLSS_DELETEPRINTERIC (0x2a) + +#define NDR_SPOOLSS_ADDPRINTERCONNECTION (0x2b) + +#define NDR_SPOOLSS_DELETEPRINTERCONNECTION (0x2c) + +#define NDR_SPOOLSS_PRINTERMESSAGEBOX (0x2d) + +#define NDR_SPOOLSS_ADDMONITOR (0x2e) + +#define NDR_SPOOLSS_DELETEMONITOR (0x2f) + +#define NDR_SPOOLSS_DELETEPRINTPROCESSOR (0x30) + +#define NDR_SPOOLSS_ADDPRINTPROVIDOR (0x31) + +#define NDR_SPOOLSS_DELETEPRINTPROVIDOR (0x32) + +#define NDR_SPOOLSS_ENUMPRINTPROCDATATYPES (0x33) + +#define NDR_SPOOLSS_RESETPRINTER (0x34) + +#define NDR_SPOOLSS_GETPRINTERDRIVER2 (0x35) + +#define NDR_SPOOLSS_FINDFIRSTPRINTERCHANGENOTIFICATION (0x36) + +#define NDR_SPOOLSS_FINDNEXTPRINTERCHANGENOTIFICATION (0x37) + +#define NDR_SPOOLSS_FINDCLOSEPRINTERNOTIFY (0x38) + +#define NDR_SPOOLSS_ROUTERFINDFIRSTPRINTERCHANGENOTIFICATIONOLD (0x39) + +#define NDR_SPOOLSS_REPLYOPENPRINTER (0x3a) + +#define NDR_SPOOLSS_ROUTERREPLYPRINTER (0x3b) + +#define NDR_SPOOLSS_REPLYCLOSEPRINTER (0x3c) + +#define NDR_SPOOLSS_ADDPORTEX (0x3d) + +#define NDR_SPOOLSS_ROUTERFINDFIRSTPRINTERCHANGENOTIFICATION (0x3e) + +#define NDR_SPOOLSS_SPOOLERINIT (0x3f) + +#define NDR_SPOOLSS_RESETPRINTEREX (0x40) + +#define NDR_SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFYEX (0x41) + +#define NDR_SPOOLSS_ROUTERREFRESHPRINTERCHANGENOTIFICATION (0x42) + +#define NDR_SPOOLSS_REMOTEFINDNEXTPRINTERCHANGENOTIFYEX (0x43) + +#define NDR_SPOOLSS_44 (0x44) + +#define NDR_SPOOLSS_OPENPRINTEREX (0x45) + +#define NDR_SPOOLSS_ADDPRINTEREX (0x46) + +#define NDR_SPOOLSS_47 (0x47) + +#define NDR_SPOOLSS_ENUMPRINTERDATA (0x48) + +#define NDR_SPOOLSS_DELETEPRINTERDATA (0x49) + +#define NDR_SPOOLSS_4A (0x4a) + +#define NDR_SPOOLSS_4B (0x4b) + +#define NDR_SPOOLSS_4C (0x4c) + +#define NDR_SPOOLSS_SETPRINTERDATAEX (0x4d) + +#define NDR_SPOOLSS_GETPRINTERDATAEX (0x4e) + +#define NDR_SPOOLSS_ENUMPRINTERDATAEX (0x4f) + +#define NDR_SPOOLSS_ENUMPRINTERKEY (0x50) + +#define NDR_SPOOLSS_DELETEPRINTERDATAEX (0x51) + +#define NDR_SPOOLSS_DELETEPRINTERKEY (0x52) + +#define NDR_SPOOLSS_53 (0x53) + +#define NDR_SPOOLSS_DELETEPRINTERDRIVEREX (0x54) + +#define NDR_SPOOLSS_55 (0x55) + +#define NDR_SPOOLSS_56 (0x56) + +#define NDR_SPOOLSS_57 (0x57) + +#define NDR_SPOOLSS_XCVDATA (0x58) + +#define NDR_SPOOLSS_ADDPRINTERDRIVEREX (0x59) + +#define NDR_SPOOLSS_5A (0x5a) + +#define NDR_SPOOLSS_5B (0x5b) + +#define NDR_SPOOLSS_5C (0x5c) + +#define NDR_SPOOLSS_5D (0x5d) + +#define NDR_SPOOLSS_5E (0x5e) + +#define NDR_SPOOLSS_5F (0x5f) + +#define NDR_SPOOLSS_CALL_COUNT (96) +void ndr_print_spoolss_Time(struct ndr_print *ndr, const char *name, const struct spoolss_Time *r); +void ndr_print_spoolss_PrinterInfo0(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo0 *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); +void ndr_print_spoolss_DeviceMode(struct ndr_print *ndr, const char *name, const struct spoolss_DeviceMode *r); +size_t ndr_size_spoolss_DeviceMode(const struct spoolss_DeviceMode *r, struct smb_iconv_convenience *ic, int flags); +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); +void ndr_print_spoolss_PrinterInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo1 *r); +void ndr_print_spoolss_PrinterAttributes(struct ndr_print *ndr, const char *name, uint32_t r); +void ndr_print_spoolss_PrinterStatus(struct ndr_print *ndr, const char *name, uint32_t r); +void ndr_print_spoolss_PrinterInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo2 *r); +void ndr_print_spoolss_PrinterInfo3(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo3 *r); +void ndr_print_spoolss_PrinterInfo4(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo4 *r); +void ndr_print_spoolss_PrinterInfo5(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo5 *r); +void ndr_print_spoolss_PrinterInfo6(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo6 *r); +void ndr_print_spoolss_DsPrintAction(struct ndr_print *ndr, const char *name, uint32_t r); +void ndr_print_spoolss_PrinterInfo7(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo7 *r); +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); +void ndr_print_spoolss_DevmodeContainer(struct ndr_print *ndr, const char *name, const struct spoolss_DevmodeContainer *r); +void ndr_print_spoolss_JobInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfo1 *r); +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); +void ndr_print_spoolss_JobInfoContainer(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfoContainer *r); +void ndr_print_spoolss_JobControl(struct ndr_print *ndr, const char *name, enum spoolss_JobControl r); +void ndr_print_spoolss_PrinterControl(struct ndr_print *ndr, const char *name, enum spoolss_PrinterControl r); +void ndr_print_spoolss_SetPrinterInfo(struct ndr_print *ndr, const char *name, const union spoolss_SetPrinterInfo *r); +void ndr_print_spoolss_DriverInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo1 *r); +void ndr_print_spoolss_DriverOSVersion(struct ndr_print *ndr, const char *name, enum spoolss_DriverOSVersion r); +void ndr_print_spoolss_DriverInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo2 *r); +void ndr_print_spoolss_DriverInfo3(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo3 *r); +void ndr_print_spoolss_DriverInfo4(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo4 *r); +void ndr_print_spoolss_DriverInfo5(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo5 *r); +void ndr_print_spoolss_DriverInfo6(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo6 *r); +enum ndr_err_code ndr_push_spoolss_DriverInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_DriverInfo *r); +enum ndr_err_code ndr_pull_spoolss_DriverInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_DriverInfo *r); +void ndr_print_spoolss_DriverInfo(struct ndr_print *ndr, const char *name, const union spoolss_DriverInfo *r); +void ndr_print_spoolss_DriverDirectoryInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_DriverDirectoryInfo1 *r); +enum ndr_err_code ndr_push_spoolss_DriverDirectoryInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_DriverDirectoryInfo *r); +enum ndr_err_code ndr_pull_spoolss_DriverDirectoryInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_DriverDirectoryInfo *r); +void ndr_print_spoolss_DriverDirectoryInfo(struct ndr_print *ndr, const char *name, const union spoolss_DriverDirectoryInfo *r); +size_t ndr_size_spoolss_DriverDirectoryInfo(const union spoolss_DriverDirectoryInfo *r, uint32_t level, struct smb_iconv_convenience *ic, int flags); +void ndr_print_spoolss_PrintProcessorInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_PrintProcessorInfo1 *r); +enum ndr_err_code ndr_push_spoolss_PrintProcessorInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_PrintProcessorInfo *r); +enum ndr_err_code ndr_pull_spoolss_PrintProcessorInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_PrintProcessorInfo *r); +void ndr_print_spoolss_PrintProcessorInfo(struct ndr_print *ndr, const char *name, const union spoolss_PrintProcessorInfo *r); +void ndr_print_spoolss_DocumentInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_DocumentInfo1 *r); +void ndr_print_spoolss_DocumentInfo(struct ndr_print *ndr, const char *name, const union spoolss_DocumentInfo *r); +enum ndr_err_code ndr_push_spoolss_OSVersion(struct ndr_push *ndr, int ndr_flags, const struct spoolss_OSVersion *r); +enum ndr_err_code ndr_pull_spoolss_OSVersion(struct ndr_pull *ndr, int ndr_flags, struct spoolss_OSVersion *r); +void ndr_print_spoolss_OSVersion(struct ndr_print *ndr, const char *name, const struct spoolss_OSVersion *r); +size_t ndr_size_spoolss_OSVersion(const struct spoolss_OSVersion *r, struct smb_iconv_convenience *ic, int flags); +enum ndr_err_code ndr_push_spoolss_OSVersionEx(struct ndr_push *ndr, int ndr_flags, const struct spoolss_OSVersionEx *r); +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); +size_t ndr_size_spoolss_PrinterData(const union spoolss_PrinterData *r, uint32_t level, struct smb_iconv_convenience *ic, int flags); +void ndr_print_spoolss_FormFlags(struct ndr_print *ndr, const char *name, enum spoolss_FormFlags r); +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); +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); +size_t ndr_size_spoolss_FormInfo(const union spoolss_FormInfo *r, uint32_t level, struct smb_iconv_convenience *ic, int flags); +void ndr_print_spoolss_AddFormInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_AddFormInfo1 *r); +void ndr_print_spoolss_AddFormInfo(struct ndr_print *ndr, const char *name, const union spoolss_AddFormInfo *r); +void ndr_print_spoolss_PortInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_PortInfo1 *r); +void ndr_print_spoolss_PortType(struct ndr_print *ndr, const char *name, uint32_t r); +void ndr_print_spoolss_PortInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_PortInfo2 *r); +enum ndr_err_code ndr_push_spoolss_PortInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_PortInfo *r); +enum ndr_err_code ndr_pull_spoolss_PortInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_PortInfo *r); +void ndr_print_spoolss_PortInfo(struct ndr_print *ndr, const char *name, const union spoolss_PortInfo *r); +void ndr_print_spoolss_MonitorInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_MonitorInfo1 *r); +void ndr_print_spoolss_MonitorInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_MonitorInfo2 *r); +enum ndr_err_code ndr_push_spoolss_MonitorInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_MonitorInfo *r); +enum ndr_err_code ndr_pull_spoolss_MonitorInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_MonitorInfo *r); +void ndr_print_spoolss_MonitorInfo(struct ndr_print *ndr, const char *name, const union spoolss_MonitorInfo *r); +void ndr_print_spoolss_Field(struct ndr_print *ndr, const char *name, enum spoolss_Field r); +void ndr_print_spoolss_NotifyType(struct ndr_print *ndr, const char *name, enum spoolss_NotifyType r); +void ndr_print_spoolss_NotifyOptionsArray(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyOptionsArray *r); +void ndr_print_spoolss_NotifyOptionsContainer(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyOptionsContainer *r); +void ndr_print_spoolss_NotifyUTF16String(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyUTF16String *r); +void ndr_print_spoolss_NotifyDOSString(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyDOSString *r); +void ndr_print_spoolss_NotifyBlobData(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyBlobData *r); +void ndr_print_spoolss_NotifyBlob(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyBlob *r); +void ndr_print_spoolss_NotifyData(struct ndr_print *ndr, const char *name, const union spoolss_NotifyData *r); +void ndr_print_spoolss_Notify(struct ndr_print *ndr, const char *name, const struct spoolss_Notify *r); +void ndr_print_spoolss_NotifyInfo(struct ndr_print *ndr, const char *name, const struct spoolss_NotifyInfo *r); +void ndr_print_spoolss_UserLevel1(struct ndr_print *ndr, const char *name, const struct spoolss_UserLevel1 *r); +void ndr_print_spoolss_UserLevel(struct ndr_print *ndr, const char *name, const union spoolss_UserLevel *r); +enum ndr_err_code ndr_push__spoolss_EnumPrinters(struct ndr_push *ndr, int flags, const struct _spoolss_EnumPrinters *r); +enum ndr_err_code ndr_pull__spoolss_EnumPrinters(struct ndr_pull *ndr, int flags, struct _spoolss_EnumPrinters *r); +void ndr_print__spoolss_EnumPrinters(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_EnumPrinters *r); +enum ndr_err_code ndr_push___spoolss_EnumPrinters(struct ndr_push *ndr, int flags, const struct __spoolss_EnumPrinters *r); +enum ndr_err_code ndr_pull___spoolss_EnumPrinters(struct ndr_pull *ndr, int flags, struct __spoolss_EnumPrinters *r); +void ndr_print___spoolss_EnumPrinters(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_EnumPrinters *r); +enum ndr_err_code ndr_push_spoolss_EnumPrinters(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinters *r); +enum ndr_err_code ndr_pull_spoolss_EnumPrinters(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinters *r); +void ndr_print_spoolss_EnumPrinters(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrinters *r); +enum ndr_err_code ndr_push_spoolss_OpenPrinter(struct ndr_push *ndr, int flags, const struct spoolss_OpenPrinter *r); +enum ndr_err_code ndr_pull_spoolss_OpenPrinter(struct ndr_pull *ndr, int flags, struct spoolss_OpenPrinter *r); +void ndr_print_spoolss_OpenPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_OpenPrinter *r); +void ndr_print_spoolss_SetJob(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_SetJob *r); +void ndr_print_spoolss_GetJob(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetJob *r); +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); +void ndr_print__spoolss_EnumJobs(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_EnumJobs *r); +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); +void ndr_print___spoolss_EnumJobs(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_EnumJobs *r); +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); +void ndr_print_spoolss_EnumJobs(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumJobs *r); +void ndr_print_spoolss_AddPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrinter *r); +void ndr_print_spoolss_DeletePrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinter *r); +void ndr_print_spoolss_SetPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_SetPrinter *r); +enum ndr_err_code ndr_push_spoolss_GetPrinter(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinter *r); +enum ndr_err_code ndr_pull_spoolss_GetPrinter(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinter *r); +void ndr_print_spoolss_GetPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinter *r); +void ndr_print_spoolss_AddPrinterDriver(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrinterDriver *r); +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); +void ndr_print__spoolss_EnumPrinterDrivers(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_EnumPrinterDrivers *r); +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); +void ndr_print___spoolss_EnumPrinterDrivers(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_EnumPrinterDrivers *r); +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); +void ndr_print_spoolss_EnumPrinterDrivers(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrinterDrivers *r); +void ndr_print_spoolss_GetPrinterDriver(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinterDriver *r); +enum ndr_err_code ndr_push_spoolss_GetPrinterDriverDirectory(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterDriverDirectory *r); +enum ndr_err_code ndr_pull_spoolss_GetPrinterDriverDirectory(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterDriverDirectory *r); +void ndr_print_spoolss_GetPrinterDriverDirectory(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinterDriverDirectory *r); +void ndr_print_spoolss_DeletePrinterDriver(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinterDriver *r); +void ndr_print_spoolss_AddPrintProcessor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrintProcessor *r); +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); +void ndr_print__spoolss_EnumPrintProcessors(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_EnumPrintProcessors *r); +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); +void ndr_print___spoolss_EnumPrintProcessors(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_EnumPrintProcessors *r); +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); +void ndr_print_spoolss_EnumPrintProcessors(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrintProcessors *r); +void ndr_print_spoolss_GetPrintProcessorDirectory(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrintProcessorDirectory *r); +void ndr_print_spoolss_StartDocPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_StartDocPrinter *r); +void ndr_print_spoolss_StartPagePrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_StartPagePrinter *r); +void ndr_print_spoolss_WritePrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_WritePrinter *r); +void ndr_print_spoolss_EndPagePrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EndPagePrinter *r); +void ndr_print_spoolss_AbortPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AbortPrinter *r); +void ndr_print_spoolss_ReadPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ReadPrinter *r); +void ndr_print_spoolss_EndDocPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EndDocPrinter *r); +void ndr_print_spoolss_AddJob(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddJob *r); +void ndr_print_spoolss_ScheduleJob(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ScheduleJob *r); +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); +void ndr_print__spoolss_GetPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_GetPrinterData *r); +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); +void ndr_print___spoolss_GetPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_GetPrinterData *r); +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); +void ndr_print_spoolss_GetPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinterData *r); +enum ndr_err_code ndr_push__spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct _spoolss_SetPrinterData *r); +enum ndr_err_code ndr_pull__spoolss_SetPrinterData(struct ndr_pull *ndr, int flags, struct _spoolss_SetPrinterData *r); +void ndr_print__spoolss_SetPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_SetPrinterData *r); +enum ndr_err_code ndr_push___spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct __spoolss_SetPrinterData *r); +enum ndr_err_code ndr_pull___spoolss_SetPrinterData(struct ndr_pull *ndr, int flags, struct __spoolss_SetPrinterData *r); +void ndr_print___spoolss_SetPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_SetPrinterData *r); +enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterData *r); +void ndr_print_spoolss_SetPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_SetPrinterData *r); +void ndr_print_spoolss_WaitForPrinterChange(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_WaitForPrinterChange *r); +enum ndr_err_code ndr_push_spoolss_ClosePrinter(struct ndr_push *ndr, int flags, const struct spoolss_ClosePrinter *r); +enum ndr_err_code ndr_pull_spoolss_ClosePrinter(struct ndr_pull *ndr, int flags, struct spoolss_ClosePrinter *r); +void ndr_print_spoolss_ClosePrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ClosePrinter *r); +void ndr_print_spoolss_AddForm(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddForm *r); +void ndr_print_spoolss_DeleteForm(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeleteForm *r); +void ndr_print_spoolss_GetForm(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetForm *r); +void ndr_print_spoolss_SetForm(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_SetForm *r); +enum ndr_err_code ndr_push__spoolss_EnumForms(struct ndr_push *ndr, int flags, const struct _spoolss_EnumForms *r); +enum ndr_err_code ndr_pull__spoolss_EnumForms(struct ndr_pull *ndr, int flags, struct _spoolss_EnumForms *r); +void ndr_print__spoolss_EnumForms(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_EnumForms *r); +enum ndr_err_code ndr_push___spoolss_EnumForms(struct ndr_push *ndr, int flags, const struct __spoolss_EnumForms *r); +enum ndr_err_code ndr_pull___spoolss_EnumForms(struct ndr_pull *ndr, int flags, struct __spoolss_EnumForms *r); +void ndr_print___spoolss_EnumForms(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_EnumForms *r); +enum ndr_err_code ndr_push_spoolss_EnumForms(struct ndr_push *ndr, int flags, const struct spoolss_EnumForms *r); +enum ndr_err_code ndr_pull_spoolss_EnumForms(struct ndr_pull *ndr, int flags, struct spoolss_EnumForms *r); +void ndr_print_spoolss_EnumForms(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumForms *r); +enum ndr_err_code ndr_push__spoolss_EnumPorts(struct ndr_push *ndr, int flags, const struct _spoolss_EnumPorts *r); +enum ndr_err_code ndr_pull__spoolss_EnumPorts(struct ndr_pull *ndr, int flags, struct _spoolss_EnumPorts *r); +void ndr_print__spoolss_EnumPorts(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_EnumPorts *r); +enum ndr_err_code ndr_push___spoolss_EnumPorts(struct ndr_push *ndr, int flags, const struct __spoolss_EnumPorts *r); +enum ndr_err_code ndr_pull___spoolss_EnumPorts(struct ndr_pull *ndr, int flags, struct __spoolss_EnumPorts *r); +void ndr_print___spoolss_EnumPorts(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_EnumPorts *r); +enum ndr_err_code ndr_push_spoolss_EnumPorts(struct ndr_push *ndr, int flags, const struct spoolss_EnumPorts *r); +enum ndr_err_code ndr_pull_spoolss_EnumPorts(struct ndr_pull *ndr, int flags, struct spoolss_EnumPorts *r); +void ndr_print_spoolss_EnumPorts(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPorts *r); +enum ndr_err_code ndr_push__spoolss_EnumMonitors(struct ndr_push *ndr, int flags, const struct _spoolss_EnumMonitors *r); +enum ndr_err_code ndr_pull__spoolss_EnumMonitors(struct ndr_pull *ndr, int flags, struct _spoolss_EnumMonitors *r); +void ndr_print__spoolss_EnumMonitors(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_EnumMonitors *r); +enum ndr_err_code ndr_push___spoolss_EnumMonitors(struct ndr_push *ndr, int flags, const struct __spoolss_EnumMonitors *r); +enum ndr_err_code ndr_pull___spoolss_EnumMonitors(struct ndr_pull *ndr, int flags, struct __spoolss_EnumMonitors *r); +void ndr_print___spoolss_EnumMonitors(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_EnumMonitors *r); +enum ndr_err_code ndr_push_spoolss_EnumMonitors(struct ndr_push *ndr, int flags, const struct spoolss_EnumMonitors *r); +enum ndr_err_code ndr_pull_spoolss_EnumMonitors(struct ndr_pull *ndr, int flags, struct spoolss_EnumMonitors *r); +void ndr_print_spoolss_EnumMonitors(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumMonitors *r); +void ndr_print_spoolss_AddPort(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPort *r); +void ndr_print_spoolss_ConfigurePort(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ConfigurePort *r); +void ndr_print_spoolss_DeletePort(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePort *r); +void ndr_print_spoolss_CreatePrinterIC(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_CreatePrinterIC *r); +void ndr_print_spoolss_PlayGDIScriptOnPrinterIC(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_PlayGDIScriptOnPrinterIC *r); +void ndr_print_spoolss_DeletePrinterIC(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinterIC *r); +void ndr_print_spoolss_AddPrinterConnection(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrinterConnection *r); +void ndr_print_spoolss_DeletePrinterConnection(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinterConnection *r); +void ndr_print_spoolss_PrinterMessageBox(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_PrinterMessageBox *r); +void ndr_print_spoolss_AddMonitor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddMonitor *r); +void ndr_print_spoolss_DeleteMonitor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeleteMonitor *r); +void ndr_print_spoolss_DeletePrintProcessor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrintProcessor *r); +void ndr_print_spoolss_AddPrintProvidor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrintProvidor *r); +void ndr_print_spoolss_DeletePrintProvidor(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrintProvidor *r); +void ndr_print_spoolss_EnumPrintProcDataTypes(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrintProcDataTypes *r); +void ndr_print_spoolss_ResetPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ResetPrinter *r); +void ndr_print_spoolss_GetPrinterDriver2(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinterDriver2 *r); +void ndr_print_spoolss_FindFirstPrinterChangeNotification(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_FindFirstPrinterChangeNotification *r); +void ndr_print_spoolss_FindNextPrinterChangeNotification(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_FindNextPrinterChangeNotification *r); +enum ndr_err_code ndr_push_spoolss_FindClosePrinterNotify(struct ndr_push *ndr, int flags, const struct spoolss_FindClosePrinterNotify *r); +enum ndr_err_code ndr_pull_spoolss_FindClosePrinterNotify(struct ndr_pull *ndr, int flags, struct spoolss_FindClosePrinterNotify *r); +void ndr_print_spoolss_FindClosePrinterNotify(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_FindClosePrinterNotify *r); +void ndr_print_spoolss_RouterFindFirstPrinterChangeNotificationOld(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_RouterFindFirstPrinterChangeNotificationOld *r); +enum ndr_err_code ndr_push_spoolss_ReplyOpenPrinter(struct ndr_push *ndr, int flags, const struct spoolss_ReplyOpenPrinter *r); +enum ndr_err_code ndr_pull_spoolss_ReplyOpenPrinter(struct ndr_pull *ndr, int flags, struct spoolss_ReplyOpenPrinter *r); +void ndr_print_spoolss_ReplyOpenPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ReplyOpenPrinter *r); +void ndr_print_spoolss_RouterReplyPrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_RouterReplyPrinter *r); +enum ndr_err_code ndr_push_spoolss_ReplyClosePrinter(struct ndr_push *ndr, int flags, const struct spoolss_ReplyClosePrinter *r); +enum ndr_err_code ndr_pull_spoolss_ReplyClosePrinter(struct ndr_pull *ndr, int flags, struct spoolss_ReplyClosePrinter *r); +void ndr_print_spoolss_ReplyClosePrinter(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ReplyClosePrinter *r); +void ndr_print_spoolss_AddPortEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPortEx *r); +void ndr_print_spoolss_RouterFindFirstPrinterChangeNotification(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_RouterFindFirstPrinterChangeNotification *r); +void ndr_print_spoolss_SpoolerInit(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_SpoolerInit *r); +void ndr_print_spoolss_ResetPrinterEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_ResetPrinterEx *r); +enum ndr_err_code ndr_push_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct ndr_push *ndr, int flags, const struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r); +enum ndr_err_code ndr_pull_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct ndr_pull *ndr, int flags, struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r); +void ndr_print_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r); +void ndr_print_spoolss_RouterRefreshPrinterChangeNotification(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_RouterRefreshPrinterChangeNotification *r); +enum ndr_err_code ndr_push_spoolss_RemoteFindNextPrinterChangeNotifyEx(struct ndr_push *ndr, int flags, const struct spoolss_RemoteFindNextPrinterChangeNotifyEx *r); +enum ndr_err_code ndr_pull_spoolss_RemoteFindNextPrinterChangeNotifyEx(struct ndr_pull *ndr, int flags, struct spoolss_RemoteFindNextPrinterChangeNotifyEx *r); +void ndr_print_spoolss_RemoteFindNextPrinterChangeNotifyEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_RemoteFindNextPrinterChangeNotifyEx *r); +void ndr_print_spoolss_44(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_44 *r); +enum ndr_err_code ndr_push_spoolss_OpenPrinterEx(struct ndr_push *ndr, int flags, const struct spoolss_OpenPrinterEx *r); +enum ndr_err_code ndr_pull_spoolss_OpenPrinterEx(struct ndr_pull *ndr, int flags, struct spoolss_OpenPrinterEx *r); +void ndr_print_spoolss_OpenPrinterEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_OpenPrinterEx *r); +void ndr_print_spoolss_AddPrinterEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrinterEx *r); +void ndr_print_spoolss_47(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_47 *r); +void ndr_print_spoolss_EnumPrinterData(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrinterData *r); +void ndr_print_spoolss_DeletePrinterData(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinterData *r); +void ndr_print_spoolss_4a(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_4a *r); +void ndr_print_spoolss_4b(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_4b *r); +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_EnumPrinterKey(struct ndr_push *ndr, int flags, const struct spoolss_EnumPrinterKey *r); +enum ndr_err_code ndr_pull_spoolss_EnumPrinterKey(struct ndr_pull *ndr, int flags, struct spoolss_EnumPrinterKey *r); +void ndr_print_spoolss_EnumPrinterKey(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_EnumPrinterKey *r); +void ndr_print_spoolss_DeletePrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinterDataEx *r); +void ndr_print_spoolss_DeletePrinterKey(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinterKey *r); +void ndr_print_spoolss_53(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_53 *r); +void ndr_print_spoolss_DeletePrinterDriverEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_DeletePrinterDriverEx *r); +void ndr_print_spoolss_55(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_55 *r); +void ndr_print_spoolss_56(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_56 *r); +void ndr_print_spoolss_57(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_57 *r); +void ndr_print_spoolss_XcvData(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_XcvData *r); +enum ndr_err_code ndr_push_spoolss_AddPrinterDriverEx(struct ndr_push *ndr, int flags, const struct spoolss_AddPrinterDriverEx *r); +enum ndr_err_code ndr_pull_spoolss_AddPrinterDriverEx(struct ndr_pull *ndr, int flags, struct spoolss_AddPrinterDriverEx *r); +void ndr_print_spoolss_AddPrinterDriverEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_AddPrinterDriverEx *r); +void ndr_print_spoolss_5a(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_5a *r); +void ndr_print_spoolss_5b(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_5b *r); +void ndr_print_spoolss_5c(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_5c *r); +void ndr_print_spoolss_5d(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_5d *r); +void ndr_print_spoolss_5e(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_5e *r); +void ndr_print_spoolss_5f(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_5f *r); +#endif /* _HEADER_NDR_spoolss */ diff --git a/librpc/gen_ndr/srv_spoolss.c b/librpc/gen_ndr/srv_spoolss.c new file mode 100644 index 0000000000..abf49766a4 --- /dev/null +++ b/librpc/gen_ndr/srv_spoolss.c @@ -0,0 +1,8437 @@ +/* + * Unix SMB/CIFS implementation. + * server auto-generated by pidl. DO NOT MODIFY! + */ + +#include "includes.h" +#include "../librpc/gen_ndr/srv_spoolss.h" + +static bool api_spoolss_EnumPrinters(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_EnumPrinters *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ENUMPRINTERS]; + + r = talloc(talloc_tos(), struct spoolss_EnumPrinters); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPrinters, r); + } + + ZERO_STRUCT(r->out); + r->out.info = talloc_zero_array(r, union spoolss_PrinterInfo, r->out.count); + if (r->out.info == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + + r->out.count = talloc_zero(r, uint32_t); + if (r->out.count == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_EnumPrinters(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPrinters, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_OpenPrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_OpenPrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_OPENPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_OpenPrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_OpenPrinter, r); + } + + ZERO_STRUCT(r->out); + r->out.handle = talloc_zero(r, struct policy_handle); + if (r->out.handle == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_OpenPrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_OpenPrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_SetJob(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_SetJob *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_SETJOB]; + + r = talloc(talloc_tos(), struct spoolss_SetJob); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_SetJob, r); + } + + r->out.result = _spoolss_SetJob(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_SetJob, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_GetJob(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_GetJob *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_GETJOB]; + + r = talloc(talloc_tos(), struct spoolss_GetJob); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetJob, r); + } + + ZERO_STRUCT(r->out); + r->out.info = talloc_zero(r, union spoolss_JobInfo); + if (r->out.info == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_GetJob(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetJob, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_EnumJobs(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_EnumJobs *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ENUMJOBS]; + + r = talloc(talloc_tos(), struct spoolss_EnumJobs); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumJobs, r); + } + + ZERO_STRUCT(r->out); + r->out.info = talloc_zero_array(r, union spoolss_JobInfo, r->out.count); + if (r->out.info == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + + r->out.count = talloc_zero(r, uint32_t); + if (r->out.count == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_EnumJobs(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumJobs, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_AddPrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_AddPrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ADDPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_AddPrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPrinter, r); + } + + r->out.result = _spoolss_AddPrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_DeletePrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_DeletePrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_DELETEPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_DeletePrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinter, r); + } + + r->out.result = _spoolss_DeletePrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_SetPrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_SetPrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_SETPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_SetPrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_SetPrinter, r); + } + + r->out.result = _spoolss_SetPrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_SetPrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_GetPrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_GetPrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_GETPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_GetPrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetPrinter, r); + } + + ZERO_STRUCT(r->out); + r->out.info = talloc_zero(r, union spoolss_PrinterInfo); + if (r->out.info == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_GetPrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetPrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_AddPrinterDriver(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_AddPrinterDriver *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ADDPRINTERDRIVER]; + + r = talloc(talloc_tos(), struct spoolss_AddPrinterDriver); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPrinterDriver, r); + } + + r->out.result = _spoolss_AddPrinterDriver(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPrinterDriver, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_EnumPrinterDrivers(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_EnumPrinterDrivers *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ENUMPRINTERDRIVERS]; + + r = talloc(talloc_tos(), struct spoolss_EnumPrinterDrivers); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPrinterDrivers, r); + } + + ZERO_STRUCT(r->out); + r->out.info = talloc_zero_array(r, union spoolss_DriverInfo, r->out.count); + if (r->out.info == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + + r->out.count = talloc_zero(r, uint32_t); + if (r->out.count == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_EnumPrinterDrivers(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPrinterDrivers, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_GetPrinterDriver(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_GetPrinterDriver *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_GETPRINTERDRIVER]; + + r = talloc(talloc_tos(), struct spoolss_GetPrinterDriver); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetPrinterDriver, r); + } + + r->out.result = _spoolss_GetPrinterDriver(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetPrinterDriver, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_GetPrinterDriverDirectory(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_GetPrinterDriverDirectory *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_GETPRINTERDRIVERDIRECTORY]; + + r = talloc(talloc_tos(), struct spoolss_GetPrinterDriverDirectory); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetPrinterDriverDirectory, r); + } + + ZERO_STRUCT(r->out); + r->out.info = talloc_zero(r, union spoolss_DriverDirectoryInfo); + if (r->out.info == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_GetPrinterDriverDirectory(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetPrinterDriverDirectory, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_DeletePrinterDriver(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_DeletePrinterDriver *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_DELETEPRINTERDRIVER]; + + r = talloc(talloc_tos(), struct spoolss_DeletePrinterDriver); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinterDriver, r); + } + + r->out.result = _spoolss_DeletePrinterDriver(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinterDriver, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_AddPrintProcessor(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_AddPrintProcessor *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ADDPRINTPROCESSOR]; + + r = talloc(talloc_tos(), struct spoolss_AddPrintProcessor); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPrintProcessor, r); + } + + r->out.result = _spoolss_AddPrintProcessor(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPrintProcessor, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_EnumPrintProcessors(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_EnumPrintProcessors *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ENUMPRINTPROCESSORS]; + + r = talloc(talloc_tos(), struct spoolss_EnumPrintProcessors); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPrintProcessors, r); + } + + ZERO_STRUCT(r->out); + r->out.info = talloc_zero_array(r, union spoolss_PrintProcessorInfo, r->out.count); + if (r->out.info == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + + r->out.count = talloc_zero(r, uint32_t); + if (r->out.count == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_EnumPrintProcessors(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPrintProcessors, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_GetPrintProcessorDirectory(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_GetPrintProcessorDirectory *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_GETPRINTPROCESSORDIRECTORY]; + + r = talloc(talloc_tos(), struct spoolss_GetPrintProcessorDirectory); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetPrintProcessorDirectory, r); + } + + r->out.result = _spoolss_GetPrintProcessorDirectory(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetPrintProcessorDirectory, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_StartDocPrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_StartDocPrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_STARTDOCPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_StartDocPrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_StartDocPrinter, r); + } + + ZERO_STRUCT(r->out); + r->out.job_id = talloc_zero(r, uint32_t); + if (r->out.job_id == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_StartDocPrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_StartDocPrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_StartPagePrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_StartPagePrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_STARTPAGEPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_StartPagePrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_StartPagePrinter, r); + } + + r->out.result = _spoolss_StartPagePrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_StartPagePrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_WritePrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_WritePrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_WRITEPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_WritePrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_WritePrinter, r); + } + + ZERO_STRUCT(r->out); + r->out.num_written = talloc_zero(r, uint32_t); + if (r->out.num_written == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_WritePrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_WritePrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_EndPagePrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_EndPagePrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ENDPAGEPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_EndPagePrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EndPagePrinter, r); + } + + r->out.result = _spoolss_EndPagePrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EndPagePrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_AbortPrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_AbortPrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ABORTPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_AbortPrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AbortPrinter, r); + } + + r->out.result = _spoolss_AbortPrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AbortPrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_ReadPrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_ReadPrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_READPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_ReadPrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ReadPrinter, r); + } + + ZERO_STRUCT(r->out); + r->out.data = talloc_zero(r, DATA_BLOB); + if (r->out.data == NULL) { + talloc_free(r); + return false; + } + + r->out._data_size = talloc_zero(r, uint32_t); + if (r->out._data_size == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_ReadPrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ReadPrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_EndDocPrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_EndDocPrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ENDDOCPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_EndDocPrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EndDocPrinter, r); + } + + r->out.result = _spoolss_EndDocPrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EndDocPrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_AddJob(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_AddJob *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ADDJOB]; + + r = talloc(talloc_tos(), struct spoolss_AddJob); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddJob, r); + } + + r->out.result = _spoolss_AddJob(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddJob, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_ScheduleJob(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_ScheduleJob *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_SCHEDULEJOB]; + + r = talloc(talloc_tos(), struct spoolss_ScheduleJob); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ScheduleJob, r); + } + + r->out.result = _spoolss_ScheduleJob(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ScheduleJob, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_GetPrinterData(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_GetPrinterData *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_GETPRINTERDATA]; + + r = talloc(talloc_tos(), struct spoolss_GetPrinterData); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetPrinterData, r); + } + + ZERO_STRUCT(r->out); + r->out.type = talloc_zero(r, enum spoolss_PrinterDataType); + 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); + return false; + } + + r->out.result = _spoolss_GetPrinterData(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetPrinterData, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_SetPrinterData(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_SetPrinterData *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_SETPRINTERDATA]; + + r = talloc(talloc_tos(), struct spoolss_SetPrinterData); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_SetPrinterData, r); + } + + r->out.result = _spoolss_SetPrinterData(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_SetPrinterData, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_WaitForPrinterChange(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_WaitForPrinterChange *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_WAITFORPRINTERCHANGE]; + + r = talloc(talloc_tos(), struct spoolss_WaitForPrinterChange); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_WaitForPrinterChange, r); + } + + r->out.result = _spoolss_WaitForPrinterChange(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_WaitForPrinterChange, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_ClosePrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_ClosePrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_CLOSEPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_ClosePrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ClosePrinter, r); + } + + ZERO_STRUCT(r->out); + r->out.handle = r->in.handle; + r->out.result = _spoolss_ClosePrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ClosePrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_AddForm(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_AddForm *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ADDFORM]; + + r = talloc(talloc_tos(), struct spoolss_AddForm); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddForm, r); + } + + r->out.result = _spoolss_AddForm(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddForm, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_DeleteForm(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_DeleteForm *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_DELETEFORM]; + + r = talloc(talloc_tos(), struct spoolss_DeleteForm); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeleteForm, r); + } + + r->out.result = _spoolss_DeleteForm(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeleteForm, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_GetForm(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_GetForm *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_GETFORM]; + + r = talloc(talloc_tos(), struct spoolss_GetForm); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetForm, r); + } + + ZERO_STRUCT(r->out); + r->out.info = talloc_zero(r, union spoolss_FormInfo); + if (r->out.info == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_GetForm(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetForm, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_SetForm(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_SetForm *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_SETFORM]; + + r = talloc(talloc_tos(), struct spoolss_SetForm); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_SetForm, r); + } + + r->out.result = _spoolss_SetForm(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_SetForm, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_EnumForms(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_EnumForms *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ENUMFORMS]; + + r = talloc(talloc_tos(), struct spoolss_EnumForms); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumForms, r); + } + + ZERO_STRUCT(r->out); + r->out.info = talloc_zero_array(r, union spoolss_FormInfo, r->out.count); + if (r->out.info == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + + r->out.count = talloc_zero(r, uint32_t); + if (r->out.count == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_EnumForms(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumForms, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_EnumPorts(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_EnumPorts *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ENUMPORTS]; + + r = talloc(talloc_tos(), struct spoolss_EnumPorts); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPorts, r); + } + + ZERO_STRUCT(r->out); + r->out.info = talloc_zero_array(r, union spoolss_PortInfo, r->out.count); + if (r->out.info == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + + r->out.count = talloc_zero(r, uint32_t); + if (r->out.count == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_EnumPorts(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPorts, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_EnumMonitors(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_EnumMonitors *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ENUMMONITORS]; + + r = talloc(talloc_tos(), struct spoolss_EnumMonitors); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumMonitors, r); + } + + ZERO_STRUCT(r->out); + r->out.info = talloc_zero_array(r, union spoolss_MonitorInfo, r->out.count); + if (r->out.info == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + + r->out.count = talloc_zero(r, uint32_t); + if (r->out.count == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_EnumMonitors(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumMonitors, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_AddPort(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_AddPort *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ADDPORT]; + + r = talloc(talloc_tos(), struct spoolss_AddPort); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPort, r); + } + + r->out.result = _spoolss_AddPort(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPort, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_ConfigurePort(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_ConfigurePort *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_CONFIGUREPORT]; + + r = talloc(talloc_tos(), struct spoolss_ConfigurePort); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ConfigurePort, r); + } + + r->out.result = _spoolss_ConfigurePort(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ConfigurePort, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_DeletePort(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_DeletePort *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_DELETEPORT]; + + r = talloc(talloc_tos(), struct spoolss_DeletePort); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePort, r); + } + + r->out.result = _spoolss_DeletePort(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePort, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_CreatePrinterIC(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_CreatePrinterIC *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_CREATEPRINTERIC]; + + r = talloc(talloc_tos(), struct spoolss_CreatePrinterIC); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_CreatePrinterIC, r); + } + + r->out.result = _spoolss_CreatePrinterIC(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_CreatePrinterIC, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_PlayGDIScriptOnPrinterIC(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_PlayGDIScriptOnPrinterIC *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_PLAYGDISCRIPTONPRINTERIC]; + + r = talloc(talloc_tos(), struct spoolss_PlayGDIScriptOnPrinterIC); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_PlayGDIScriptOnPrinterIC, r); + } + + r->out.result = _spoolss_PlayGDIScriptOnPrinterIC(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_PlayGDIScriptOnPrinterIC, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_DeletePrinterIC(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_DeletePrinterIC *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_DELETEPRINTERIC]; + + r = talloc(talloc_tos(), struct spoolss_DeletePrinterIC); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinterIC, r); + } + + r->out.result = _spoolss_DeletePrinterIC(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinterIC, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_AddPrinterConnection(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_AddPrinterConnection *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ADDPRINTERCONNECTION]; + + r = talloc(talloc_tos(), struct spoolss_AddPrinterConnection); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPrinterConnection, r); + } + + r->out.result = _spoolss_AddPrinterConnection(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPrinterConnection, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_DeletePrinterConnection(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_DeletePrinterConnection *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_DELETEPRINTERCONNECTION]; + + r = talloc(talloc_tos(), struct spoolss_DeletePrinterConnection); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinterConnection, r); + } + + r->out.result = _spoolss_DeletePrinterConnection(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinterConnection, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_PrinterMessageBox(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_PrinterMessageBox *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_PRINTERMESSAGEBOX]; + + r = talloc(talloc_tos(), struct spoolss_PrinterMessageBox); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_PrinterMessageBox, r); + } + + r->out.result = _spoolss_PrinterMessageBox(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_PrinterMessageBox, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_AddMonitor(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_AddMonitor *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ADDMONITOR]; + + r = talloc(talloc_tos(), struct spoolss_AddMonitor); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddMonitor, r); + } + + r->out.result = _spoolss_AddMonitor(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddMonitor, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_DeleteMonitor(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_DeleteMonitor *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_DELETEMONITOR]; + + r = talloc(talloc_tos(), struct spoolss_DeleteMonitor); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeleteMonitor, r); + } + + r->out.result = _spoolss_DeleteMonitor(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeleteMonitor, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_DeletePrintProcessor(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_DeletePrintProcessor *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_DELETEPRINTPROCESSOR]; + + r = talloc(talloc_tos(), struct spoolss_DeletePrintProcessor); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrintProcessor, r); + } + + r->out.result = _spoolss_DeletePrintProcessor(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrintProcessor, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_AddPrintProvidor(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_AddPrintProvidor *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ADDPRINTPROVIDOR]; + + r = talloc(talloc_tos(), struct spoolss_AddPrintProvidor); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPrintProvidor, r); + } + + r->out.result = _spoolss_AddPrintProvidor(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPrintProvidor, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_DeletePrintProvidor(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_DeletePrintProvidor *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_DELETEPRINTPROVIDOR]; + + r = talloc(talloc_tos(), struct spoolss_DeletePrintProvidor); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrintProvidor, r); + } + + r->out.result = _spoolss_DeletePrintProvidor(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrintProvidor, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_EnumPrintProcDataTypes(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_EnumPrintProcDataTypes *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ENUMPRINTPROCDATATYPES]; + + r = talloc(talloc_tos(), struct spoolss_EnumPrintProcDataTypes); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPrintProcDataTypes, r); + } + + r->out.result = _spoolss_EnumPrintProcDataTypes(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPrintProcDataTypes, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_ResetPrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_ResetPrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_RESETPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_ResetPrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ResetPrinter, r); + } + + r->out.result = _spoolss_ResetPrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ResetPrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_GetPrinterDriver2(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_GetPrinterDriver2 *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_GETPRINTERDRIVER2]; + + r = talloc(talloc_tos(), struct spoolss_GetPrinterDriver2); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetPrinterDriver2, r); + } + + ZERO_STRUCT(r->out); + r->out.info = talloc_zero(r, DATA_BLOB); + if (r->out.info == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + + r->out.server_major_version = talloc_zero(r, uint32_t); + if (r->out.server_major_version == NULL) { + talloc_free(r); + return false; + } + + r->out.server_minor_version = talloc_zero(r, uint32_t); + if (r->out.server_minor_version == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_GetPrinterDriver2(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetPrinterDriver2, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_FindFirstPrinterChangeNotification(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_FindFirstPrinterChangeNotification *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_FINDFIRSTPRINTERCHANGENOTIFICATION]; + + r = talloc(talloc_tos(), struct spoolss_FindFirstPrinterChangeNotification); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_FindFirstPrinterChangeNotification, r); + } + + r->out.result = _spoolss_FindFirstPrinterChangeNotification(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_FindFirstPrinterChangeNotification, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_FindNextPrinterChangeNotification(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_FindNextPrinterChangeNotification *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_FINDNEXTPRINTERCHANGENOTIFICATION]; + + r = talloc(talloc_tos(), struct spoolss_FindNextPrinterChangeNotification); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_FindNextPrinterChangeNotification, r); + } + + r->out.result = _spoolss_FindNextPrinterChangeNotification(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_FindNextPrinterChangeNotification, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_FindClosePrinterNotify(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_FindClosePrinterNotify *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_FINDCLOSEPRINTERNOTIFY]; + + r = talloc(talloc_tos(), struct spoolss_FindClosePrinterNotify); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_FindClosePrinterNotify, r); + } + + r->out.result = _spoolss_FindClosePrinterNotify(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_FindClosePrinterNotify, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_RouterFindFirstPrinterChangeNotificationOld(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_RouterFindFirstPrinterChangeNotificationOld *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ROUTERFINDFIRSTPRINTERCHANGENOTIFICATIONOLD]; + + r = talloc(talloc_tos(), struct spoolss_RouterFindFirstPrinterChangeNotificationOld); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_RouterFindFirstPrinterChangeNotificationOld, r); + } + + r->out.result = _spoolss_RouterFindFirstPrinterChangeNotificationOld(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_RouterFindFirstPrinterChangeNotificationOld, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_ReplyOpenPrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_ReplyOpenPrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_REPLYOPENPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_ReplyOpenPrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ReplyOpenPrinter, r); + } + + ZERO_STRUCT(r->out); + r->out.handle = talloc_zero(r, struct policy_handle); + if (r->out.handle == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_ReplyOpenPrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ReplyOpenPrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_RouterReplyPrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_RouterReplyPrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ROUTERREPLYPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_RouterReplyPrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_RouterReplyPrinter, r); + } + + r->out.result = _spoolss_RouterReplyPrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_RouterReplyPrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_ReplyClosePrinter(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_ReplyClosePrinter *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_REPLYCLOSEPRINTER]; + + r = talloc(talloc_tos(), struct spoolss_ReplyClosePrinter); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ReplyClosePrinter, r); + } + + ZERO_STRUCT(r->out); + r->out.handle = r->in.handle; + r->out.result = _spoolss_ReplyClosePrinter(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ReplyClosePrinter, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_AddPortEx(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_AddPortEx *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ADDPORTEX]; + + r = talloc(talloc_tos(), struct spoolss_AddPortEx); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPortEx, r); + } + + r->out.result = _spoolss_AddPortEx(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPortEx, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_RouterFindFirstPrinterChangeNotification(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_RouterFindFirstPrinterChangeNotification *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ROUTERFINDFIRSTPRINTERCHANGENOTIFICATION]; + + r = talloc(talloc_tos(), struct spoolss_RouterFindFirstPrinterChangeNotification); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_RouterFindFirstPrinterChangeNotification, r); + } + + r->out.result = _spoolss_RouterFindFirstPrinterChangeNotification(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_RouterFindFirstPrinterChangeNotification, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_SpoolerInit(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_SpoolerInit *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_SPOOLERINIT]; + + r = talloc(talloc_tos(), struct spoolss_SpoolerInit); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_SpoolerInit, r); + } + + r->out.result = _spoolss_SpoolerInit(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_SpoolerInit, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_ResetPrinterEx(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_ResetPrinterEx *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_RESETPRINTEREX]; + + r = talloc(talloc_tos(), struct spoolss_ResetPrinterEx); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_ResetPrinterEx, r); + } + + r->out.result = _spoolss_ResetPrinterEx(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_ResetPrinterEx, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_RemoteFindFirstPrinterChangeNotifyEx(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFYEX]; + + r = talloc(talloc_tos(), struct spoolss_RemoteFindFirstPrinterChangeNotifyEx); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_RemoteFindFirstPrinterChangeNotifyEx, r); + } + + r->out.result = _spoolss_RemoteFindFirstPrinterChangeNotifyEx(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_RemoteFindFirstPrinterChangeNotifyEx, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_RouterRefreshPrinterChangeNotification(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_RouterRefreshPrinterChangeNotification *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ROUTERREFRESHPRINTERCHANGENOTIFICATION]; + + r = talloc(talloc_tos(), struct spoolss_RouterRefreshPrinterChangeNotification); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_RouterRefreshPrinterChangeNotification, r); + } + + r->out.result = _spoolss_RouterRefreshPrinterChangeNotification(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_RouterRefreshPrinterChangeNotification, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_RemoteFindNextPrinterChangeNotifyEx(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_RemoteFindNextPrinterChangeNotifyEx *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_REMOTEFINDNEXTPRINTERCHANGENOTIFYEX]; + + r = talloc(talloc_tos(), struct spoolss_RemoteFindNextPrinterChangeNotifyEx); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_RemoteFindNextPrinterChangeNotifyEx, r); + } + + ZERO_STRUCT(r->out); + r->out.info = talloc_zero(r, struct spoolss_NotifyInfo *); + if (r->out.info == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_RemoteFindNextPrinterChangeNotifyEx(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_RemoteFindNextPrinterChangeNotifyEx, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_44(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_44 *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_44]; + + r = talloc(talloc_tos(), struct spoolss_44); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_44, r); + } + + r->out.result = _spoolss_44(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_44, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_OpenPrinterEx(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_OpenPrinterEx *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_OPENPRINTEREX]; + + r = talloc(talloc_tos(), struct spoolss_OpenPrinterEx); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_OpenPrinterEx, r); + } + + ZERO_STRUCT(r->out); + r->out.handle = talloc_zero(r, struct policy_handle); + if (r->out.handle == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_OpenPrinterEx(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_OpenPrinterEx, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_AddPrinterEx(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_AddPrinterEx *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ADDPRINTEREX]; + + r = talloc(talloc_tos(), struct spoolss_AddPrinterEx); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPrinterEx, r); + } + + r->out.result = _spoolss_AddPrinterEx(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPrinterEx, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_47(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_47 *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_47]; + + r = talloc(talloc_tos(), struct spoolss_47); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_47, r); + } + + r->out.result = _spoolss_47(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_47, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_EnumPrinterData(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_EnumPrinterData *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ENUMPRINTERDATA]; + + r = talloc(talloc_tos(), struct spoolss_EnumPrinterData); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPrinterData, r); + } + + ZERO_STRUCT(r->out); + r->out.value_name = talloc_zero_array(r, const char, r->in.value_offered / 2); + if (r->out.value_name == NULL) { + talloc_free(r); + return false; + } + + r->out.value_needed = talloc_zero(r, uint32_t); + if (r->out.value_needed == NULL) { + talloc_free(r); + return false; + } + + r->out.printerdata_type = talloc_zero(r, uint32_t); + if (r->out.printerdata_type == NULL) { + talloc_free(r); + return false; + } + + r->out.buffer = talloc_zero(r, DATA_BLOB); + if (r->out.buffer == NULL) { + talloc_free(r); + return false; + } + + r->out.data_needed = talloc_zero(r, uint32_t); + if (r->out.data_needed == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_EnumPrinterData(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPrinterData, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_DeletePrinterData(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_DeletePrinterData *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_DELETEPRINTERDATA]; + + r = talloc(talloc_tos(), struct spoolss_DeletePrinterData); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinterData, r); + } + + r->out.result = _spoolss_DeletePrinterData(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinterData, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_4a(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_4a *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_4A]; + + r = talloc(talloc_tos(), struct spoolss_4a); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_4a, r); + } + + r->out.result = _spoolss_4a(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_4a, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_4b(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_4b *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_4B]; + + r = talloc(talloc_tos(), struct spoolss_4b); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_4b, r); + } + + r->out.result = _spoolss_4b(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_4b, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_4c(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_4c *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_4C]; + + r = talloc(talloc_tos(), struct spoolss_4c); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_4c, r); + } + + r->out.result = _spoolss_4c(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_4c, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_SetPrinterDataEx(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_SetPrinterDataEx *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_SETPRINTERDATAEX]; + + r = talloc(talloc_tos(), struct spoolss_SetPrinterDataEx); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_SetPrinterDataEx, r); + } + + r->out.result = _spoolss_SetPrinterDataEx(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_SetPrinterDataEx, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_GetPrinterDataEx(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_GetPrinterDataEx *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_GETPRINTERDATAEX]; + + r = talloc(talloc_tos(), struct spoolss_GetPrinterDataEx); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_GetPrinterDataEx, r); + } + + ZERO_STRUCT(r->out); + r->out.type = talloc_zero(r, uint32_t); + if (r->out.type == NULL) { + talloc_free(r); + return false; + } + + r->out.buffer = talloc_zero(r, DATA_BLOB); + if (r->out.buffer == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_GetPrinterDataEx(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_GetPrinterDataEx, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_EnumPrinterDataEx(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_EnumPrinterDataEx *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ENUMPRINTERDATAEX]; + + r = talloc(talloc_tos(), struct spoolss_EnumPrinterDataEx); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPrinterDataEx, r); + } + + ZERO_STRUCT(r->out); + r->out.buffer = talloc_zero(r, DATA_BLOB); + if (r->out.buffer == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + 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) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPrinterDataEx, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_EnumPrinterKey(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_EnumPrinterKey *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ENUMPRINTERKEY]; + + r = talloc(talloc_tos(), struct spoolss_EnumPrinterKey); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_EnumPrinterKey, r); + } + + ZERO_STRUCT(r->out); + r->out.needed = r->in.needed; + r->out.key_buffer_size = talloc_zero(r, uint32_t); + if (r->out.key_buffer_size == NULL) { + talloc_free(r); + return false; + } + + r->out.key_buffer = talloc_zero_array(r, uint16_t, r->out.key_buffer_size); + if (r->out.key_buffer == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_EnumPrinterKey(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_EnumPrinterKey, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_DeletePrinterDataEx(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_DeletePrinterDataEx *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_DELETEPRINTERDATAEX]; + + r = talloc(talloc_tos(), struct spoolss_DeletePrinterDataEx); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinterDataEx, r); + } + + r->out.result = _spoolss_DeletePrinterDataEx(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinterDataEx, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_DeletePrinterKey(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_DeletePrinterKey *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_DELETEPRINTERKEY]; + + r = talloc(talloc_tos(), struct spoolss_DeletePrinterKey); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinterKey, r); + } + + r->out.result = _spoolss_DeletePrinterKey(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinterKey, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_53(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_53 *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_53]; + + r = talloc(talloc_tos(), struct spoolss_53); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_53, r); + } + + r->out.result = _spoolss_53(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_53, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_DeletePrinterDriverEx(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_DeletePrinterDriverEx *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_DELETEPRINTERDRIVEREX]; + + r = talloc(talloc_tos(), struct spoolss_DeletePrinterDriverEx); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_DeletePrinterDriverEx, r); + } + + r->out.result = _spoolss_DeletePrinterDriverEx(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_DeletePrinterDriverEx, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_55(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_55 *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_55]; + + r = talloc(talloc_tos(), struct spoolss_55); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_55, r); + } + + r->out.result = _spoolss_55(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_55, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_56(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_56 *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_56]; + + r = talloc(talloc_tos(), struct spoolss_56); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_56, r); + } + + r->out.result = _spoolss_56(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_56, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_57(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_57 *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_57]; + + r = talloc(talloc_tos(), struct spoolss_57); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_57, r); + } + + r->out.result = _spoolss_57(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_57, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_XcvData(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_XcvData *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_XCVDATA]; + + r = talloc(talloc_tos(), struct spoolss_XcvData); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_XcvData, r); + } + + ZERO_STRUCT(r->out); + r->out.out_data = talloc_zero(r, DATA_BLOB); + if (r->out.out_data == NULL) { + talloc_free(r); + return false; + } + + r->out.needed = talloc_zero(r, uint32_t); + if (r->out.needed == NULL) { + talloc_free(r); + return false; + } + + r->out.unknown2 = talloc_zero(r, uint32_t); + if (r->out.unknown2 == NULL) { + talloc_free(r); + return false; + } + + r->out.result = _spoolss_XcvData(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_XcvData, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_AddPrinterDriverEx(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_AddPrinterDriverEx *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_ADDPRINTERDRIVEREX]; + + r = talloc(talloc_tos(), struct spoolss_AddPrinterDriverEx); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_AddPrinterDriverEx, r); + } + + r->out.result = _spoolss_AddPrinterDriverEx(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_AddPrinterDriverEx, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_5a(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_5a *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_5A]; + + r = talloc(talloc_tos(), struct spoolss_5a); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_5a, r); + } + + r->out.result = _spoolss_5a(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_5a, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_5b(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_5b *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_5B]; + + r = talloc(talloc_tos(), struct spoolss_5b); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_5b, r); + } + + r->out.result = _spoolss_5b(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_5b, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_5c(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_5c *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_5C]; + + r = talloc(talloc_tos(), struct spoolss_5c); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_5c, r); + } + + r->out.result = _spoolss_5c(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_5c, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_5d(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_5d *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_5D]; + + r = talloc(talloc_tos(), struct spoolss_5d); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_5d, r); + } + + r->out.result = _spoolss_5d(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_5d, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_5e(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_5e *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_5E]; + + r = talloc(talloc_tos(), struct spoolss_5e); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_5e, r); + } + + r->out.result = _spoolss_5e(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_5e, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + +static bool api_spoolss_5f(pipes_struct *p) +{ + const struct ndr_interface_call *call; + struct ndr_pull *pull; + struct ndr_push *push; + enum ndr_err_code ndr_err; + DATA_BLOB blob; + struct spoolss_5f *r; + + call = &ndr_table_spoolss.calls[NDR_SPOOLSS_5F]; + + r = talloc(talloc_tos(), struct spoolss_5f); + if (r == NULL) { + return false; + } + + if (!prs_data_blob(&p->in_data.data, &blob, r)) { + talloc_free(r); + return false; + } + + pull = ndr_pull_init_blob(&blob, r, NULL); + if (pull == NULL) { + talloc_free(r); + return false; + } + + pull->flags |= LIBNDR_FLAG_REF_ALLOC; + ndr_err = call->ndr_pull(pull, NDR_IN, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_IN_DEBUG(spoolss_5f, r); + } + + r->out.result = _spoolss_5f(p, r); + + if (p->rng_fault_state) { + talloc_free(r); + /* Return true here, srv_pipe_hnd.c will take care */ + return true; + } + + if (DEBUGLEVEL >= 10) { + NDR_PRINT_OUT_DEBUG(spoolss_5f, r); + } + + push = ndr_push_init_ctx(r, NULL); + if (push == NULL) { + talloc_free(r); + return false; + } + + ndr_err = call->ndr_push(push, NDR_OUT, r); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + talloc_free(r); + return false; + } + + blob = ndr_push_blob(push); + if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) { + talloc_free(r); + return false; + } + + talloc_free(r); + + return true; +} + + +/* Tables */ +static struct api_struct api_spoolss_cmds[] = +{ + {"SPOOLSS_ENUMPRINTERS", NDR_SPOOLSS_ENUMPRINTERS, api_spoolss_EnumPrinters}, + {"SPOOLSS_OPENPRINTER", NDR_SPOOLSS_OPENPRINTER, api_spoolss_OpenPrinter}, + {"SPOOLSS_SETJOB", NDR_SPOOLSS_SETJOB, api_spoolss_SetJob}, + {"SPOOLSS_GETJOB", NDR_SPOOLSS_GETJOB, api_spoolss_GetJob}, + {"SPOOLSS_ENUMJOBS", NDR_SPOOLSS_ENUMJOBS, api_spoolss_EnumJobs}, + {"SPOOLSS_ADDPRINTER", NDR_SPOOLSS_ADDPRINTER, api_spoolss_AddPrinter}, + {"SPOOLSS_DELETEPRINTER", NDR_SPOOLSS_DELETEPRINTER, api_spoolss_DeletePrinter}, + {"SPOOLSS_SETPRINTER", NDR_SPOOLSS_SETPRINTER, api_spoolss_SetPrinter}, + {"SPOOLSS_GETPRINTER", NDR_SPOOLSS_GETPRINTER, api_spoolss_GetPrinter}, + {"SPOOLSS_ADDPRINTERDRIVER", NDR_SPOOLSS_ADDPRINTERDRIVER, api_spoolss_AddPrinterDriver}, + {"SPOOLSS_ENUMPRINTERDRIVERS", NDR_SPOOLSS_ENUMPRINTERDRIVERS, api_spoolss_EnumPrinterDrivers}, + {"SPOOLSS_GETPRINTERDRIVER", NDR_SPOOLSS_GETPRINTERDRIVER, api_spoolss_GetPrinterDriver}, + {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", NDR_SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_GetPrinterDriverDirectory}, + {"SPOOLSS_DELETEPRINTERDRIVER", NDR_SPOOLSS_DELETEPRINTERDRIVER, api_spoolss_DeletePrinterDriver}, + {"SPOOLSS_ADDPRINTPROCESSOR", NDR_SPOOLSS_ADDPRINTPROCESSOR, api_spoolss_AddPrintProcessor}, + {"SPOOLSS_ENUMPRINTPROCESSORS", NDR_SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_EnumPrintProcessors}, + {"SPOOLSS_GETPRINTPROCESSORDIRECTORY", NDR_SPOOLSS_GETPRINTPROCESSORDIRECTORY, api_spoolss_GetPrintProcessorDirectory}, + {"SPOOLSS_STARTDOCPRINTER", NDR_SPOOLSS_STARTDOCPRINTER, api_spoolss_StartDocPrinter}, + {"SPOOLSS_STARTPAGEPRINTER", NDR_SPOOLSS_STARTPAGEPRINTER, api_spoolss_StartPagePrinter}, + {"SPOOLSS_WRITEPRINTER", NDR_SPOOLSS_WRITEPRINTER, api_spoolss_WritePrinter}, + {"SPOOLSS_ENDPAGEPRINTER", NDR_SPOOLSS_ENDPAGEPRINTER, api_spoolss_EndPagePrinter}, + {"SPOOLSS_ABORTPRINTER", NDR_SPOOLSS_ABORTPRINTER, api_spoolss_AbortPrinter}, + {"SPOOLSS_READPRINTER", NDR_SPOOLSS_READPRINTER, api_spoolss_ReadPrinter}, + {"SPOOLSS_ENDDOCPRINTER", NDR_SPOOLSS_ENDDOCPRINTER, api_spoolss_EndDocPrinter}, + {"SPOOLSS_ADDJOB", NDR_SPOOLSS_ADDJOB, api_spoolss_AddJob}, + {"SPOOLSS_SCHEDULEJOB", NDR_SPOOLSS_SCHEDULEJOB, api_spoolss_ScheduleJob}, + {"SPOOLSS_GETPRINTERDATA", NDR_SPOOLSS_GETPRINTERDATA, api_spoolss_GetPrinterData}, + {"SPOOLSS_SETPRINTERDATA", NDR_SPOOLSS_SETPRINTERDATA, api_spoolss_SetPrinterData}, + {"SPOOLSS_WAITFORPRINTERCHANGE", NDR_SPOOLSS_WAITFORPRINTERCHANGE, api_spoolss_WaitForPrinterChange}, + {"SPOOLSS_CLOSEPRINTER", NDR_SPOOLSS_CLOSEPRINTER, api_spoolss_ClosePrinter}, + {"SPOOLSS_ADDFORM", NDR_SPOOLSS_ADDFORM, api_spoolss_AddForm}, + {"SPOOLSS_DELETEFORM", NDR_SPOOLSS_DELETEFORM, api_spoolss_DeleteForm}, + {"SPOOLSS_GETFORM", NDR_SPOOLSS_GETFORM, api_spoolss_GetForm}, + {"SPOOLSS_SETFORM", NDR_SPOOLSS_SETFORM, api_spoolss_SetForm}, + {"SPOOLSS_ENUMFORMS", NDR_SPOOLSS_ENUMFORMS, api_spoolss_EnumForms}, + {"SPOOLSS_ENUMPORTS", NDR_SPOOLSS_ENUMPORTS, api_spoolss_EnumPorts}, + {"SPOOLSS_ENUMMONITORS", NDR_SPOOLSS_ENUMMONITORS, api_spoolss_EnumMonitors}, + {"SPOOLSS_ADDPORT", NDR_SPOOLSS_ADDPORT, api_spoolss_AddPort}, + {"SPOOLSS_CONFIGUREPORT", NDR_SPOOLSS_CONFIGUREPORT, api_spoolss_ConfigurePort}, + {"SPOOLSS_DELETEPORT", NDR_SPOOLSS_DELETEPORT, api_spoolss_DeletePort}, + {"SPOOLSS_CREATEPRINTERIC", NDR_SPOOLSS_CREATEPRINTERIC, api_spoolss_CreatePrinterIC}, + {"SPOOLSS_PLAYGDISCRIPTONPRINTERIC", NDR_SPOOLSS_PLAYGDISCRIPTONPRINTERIC, api_spoolss_PlayGDIScriptOnPrinterIC}, + {"SPOOLSS_DELETEPRINTERIC", NDR_SPOOLSS_DELETEPRINTERIC, api_spoolss_DeletePrinterIC}, + {"SPOOLSS_ADDPRINTERCONNECTION", NDR_SPOOLSS_ADDPRINTERCONNECTION, api_spoolss_AddPrinterConnection}, + {"SPOOLSS_DELETEPRINTERCONNECTION", NDR_SPOOLSS_DELETEPRINTERCONNECTION, api_spoolss_DeletePrinterConnection}, + {"SPOOLSS_PRINTERMESSAGEBOX", NDR_SPOOLSS_PRINTERMESSAGEBOX, api_spoolss_PrinterMessageBox}, + {"SPOOLSS_ADDMONITOR", NDR_SPOOLSS_ADDMONITOR, api_spoolss_AddMonitor}, + {"SPOOLSS_DELETEMONITOR", NDR_SPOOLSS_DELETEMONITOR, api_spoolss_DeleteMonitor}, + {"SPOOLSS_DELETEPRINTPROCESSOR", NDR_SPOOLSS_DELETEPRINTPROCESSOR, api_spoolss_DeletePrintProcessor}, + {"SPOOLSS_ADDPRINTPROVIDOR", NDR_SPOOLSS_ADDPRINTPROVIDOR, api_spoolss_AddPrintProvidor}, + {"SPOOLSS_DELETEPRINTPROVIDOR", NDR_SPOOLSS_DELETEPRINTPROVIDOR, api_spoolss_DeletePrintProvidor}, + {"SPOOLSS_ENUMPRINTPROCDATATYPES", NDR_SPOOLSS_ENUMPRINTPROCDATATYPES, api_spoolss_EnumPrintProcDataTypes}, + {"SPOOLSS_RESETPRINTER", NDR_SPOOLSS_RESETPRINTER, api_spoolss_ResetPrinter}, + {"SPOOLSS_GETPRINTERDRIVER2", NDR_SPOOLSS_GETPRINTERDRIVER2, api_spoolss_GetPrinterDriver2}, + {"SPOOLSS_FINDFIRSTPRINTERCHANGENOTIFICATION", NDR_SPOOLSS_FINDFIRSTPRINTERCHANGENOTIFICATION, api_spoolss_FindFirstPrinterChangeNotification}, + {"SPOOLSS_FINDNEXTPRINTERCHANGENOTIFICATION", NDR_SPOOLSS_FINDNEXTPRINTERCHANGENOTIFICATION, api_spoolss_FindNextPrinterChangeNotification}, + {"SPOOLSS_FINDCLOSEPRINTERNOTIFY", NDR_SPOOLSS_FINDCLOSEPRINTERNOTIFY, api_spoolss_FindClosePrinterNotify}, + {"SPOOLSS_ROUTERFINDFIRSTPRINTERCHANGENOTIFICATIONOLD", NDR_SPOOLSS_ROUTERFINDFIRSTPRINTERCHANGENOTIFICATIONOLD, api_spoolss_RouterFindFirstPrinterChangeNotificationOld}, + {"SPOOLSS_REPLYOPENPRINTER", NDR_SPOOLSS_REPLYOPENPRINTER, api_spoolss_ReplyOpenPrinter}, + {"SPOOLSS_ROUTERREPLYPRINTER", NDR_SPOOLSS_ROUTERREPLYPRINTER, api_spoolss_RouterReplyPrinter}, + {"SPOOLSS_REPLYCLOSEPRINTER", NDR_SPOOLSS_REPLYCLOSEPRINTER, api_spoolss_ReplyClosePrinter}, + {"SPOOLSS_ADDPORTEX", NDR_SPOOLSS_ADDPORTEX, api_spoolss_AddPortEx}, + {"SPOOLSS_ROUTERFINDFIRSTPRINTERCHANGENOTIFICATION", NDR_SPOOLSS_ROUTERFINDFIRSTPRINTERCHANGENOTIFICATION, api_spoolss_RouterFindFirstPrinterChangeNotification}, + {"SPOOLSS_SPOOLERINIT", NDR_SPOOLSS_SPOOLERINIT, api_spoolss_SpoolerInit}, + {"SPOOLSS_RESETPRINTEREX", NDR_SPOOLSS_RESETPRINTEREX, api_spoolss_ResetPrinterEx}, + {"SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFYEX", NDR_SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFYEX, api_spoolss_RemoteFindFirstPrinterChangeNotifyEx}, + {"SPOOLSS_ROUTERREFRESHPRINTERCHANGENOTIFICATION", NDR_SPOOLSS_ROUTERREFRESHPRINTERCHANGENOTIFICATION, api_spoolss_RouterRefreshPrinterChangeNotification}, + {"SPOOLSS_REMOTEFINDNEXTPRINTERCHANGENOTIFYEX", NDR_SPOOLSS_REMOTEFINDNEXTPRINTERCHANGENOTIFYEX, api_spoolss_RemoteFindNextPrinterChangeNotifyEx}, + {"SPOOLSS_44", NDR_SPOOLSS_44, api_spoolss_44}, + {"SPOOLSS_OPENPRINTEREX", NDR_SPOOLSS_OPENPRINTEREX, api_spoolss_OpenPrinterEx}, + {"SPOOLSS_ADDPRINTEREX", NDR_SPOOLSS_ADDPRINTEREX, api_spoolss_AddPrinterEx}, + {"SPOOLSS_47", NDR_SPOOLSS_47, api_spoolss_47}, + {"SPOOLSS_ENUMPRINTERDATA", NDR_SPOOLSS_ENUMPRINTERDATA, api_spoolss_EnumPrinterData}, + {"SPOOLSS_DELETEPRINTERDATA", NDR_SPOOLSS_DELETEPRINTERDATA, api_spoolss_DeletePrinterData}, + {"SPOOLSS_4A", NDR_SPOOLSS_4A, api_spoolss_4a}, + {"SPOOLSS_4B", NDR_SPOOLSS_4B, api_spoolss_4b}, + {"SPOOLSS_4C", NDR_SPOOLSS_4C, api_spoolss_4c}, + {"SPOOLSS_SETPRINTERDATAEX", NDR_SPOOLSS_SETPRINTERDATAEX, api_spoolss_SetPrinterDataEx}, + {"SPOOLSS_GETPRINTERDATAEX", NDR_SPOOLSS_GETPRINTERDATAEX, api_spoolss_GetPrinterDataEx}, + {"SPOOLSS_ENUMPRINTERDATAEX", NDR_SPOOLSS_ENUMPRINTERDATAEX, api_spoolss_EnumPrinterDataEx}, + {"SPOOLSS_ENUMPRINTERKEY", NDR_SPOOLSS_ENUMPRINTERKEY, api_spoolss_EnumPrinterKey}, + {"SPOOLSS_DELETEPRINTERDATAEX", NDR_SPOOLSS_DELETEPRINTERDATAEX, api_spoolss_DeletePrinterDataEx}, + {"SPOOLSS_DELETEPRINTERKEY", NDR_SPOOLSS_DELETEPRINTERKEY, api_spoolss_DeletePrinterKey}, + {"SPOOLSS_53", NDR_SPOOLSS_53, api_spoolss_53}, + {"SPOOLSS_DELETEPRINTERDRIVEREX", NDR_SPOOLSS_DELETEPRINTERDRIVEREX, api_spoolss_DeletePrinterDriverEx}, + {"SPOOLSS_55", NDR_SPOOLSS_55, api_spoolss_55}, + {"SPOOLSS_56", NDR_SPOOLSS_56, api_spoolss_56}, + {"SPOOLSS_57", NDR_SPOOLSS_57, api_spoolss_57}, + {"SPOOLSS_XCVDATA", NDR_SPOOLSS_XCVDATA, api_spoolss_XcvData}, + {"SPOOLSS_ADDPRINTERDRIVEREX", NDR_SPOOLSS_ADDPRINTERDRIVEREX, api_spoolss_AddPrinterDriverEx}, + {"SPOOLSS_5A", NDR_SPOOLSS_5A, api_spoolss_5a}, + {"SPOOLSS_5B", NDR_SPOOLSS_5B, api_spoolss_5b}, + {"SPOOLSS_5C", NDR_SPOOLSS_5C, api_spoolss_5c}, + {"SPOOLSS_5D", NDR_SPOOLSS_5D, api_spoolss_5d}, + {"SPOOLSS_5E", NDR_SPOOLSS_5E, api_spoolss_5e}, + {"SPOOLSS_5F", NDR_SPOOLSS_5F, api_spoolss_5f}, +}; + +void spoolss_get_pipe_fns(struct api_struct **fns, int *n_fns) +{ + *fns = api_spoolss_cmds; + *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct); +} + +NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *_r) +{ + if (cli->pipes_struct == NULL) { + return NT_STATUS_INVALID_PARAMETER; + } + + switch (opnum) + { + case NDR_SPOOLSS_ENUMPRINTERS: { + struct spoolss_EnumPrinters *r = (struct spoolss_EnumPrinters *)_r; + ZERO_STRUCT(r->out); + r->out.info = talloc_zero_array(mem_ctx, union spoolss_PrinterInfo, r->out.count); + if (r->out.info == 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; + } + + r->out.count = talloc_zero(mem_ctx, uint32_t); + if (r->out.count == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_EnumPrinters(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_OPENPRINTER: { + struct spoolss_OpenPrinter *r = (struct spoolss_OpenPrinter *)_r; + ZERO_STRUCT(r->out); + r->out.handle = talloc_zero(mem_ctx, struct policy_handle); + if (r->out.handle == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_OpenPrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_SETJOB: { + struct spoolss_SetJob *r = (struct spoolss_SetJob *)_r; + r->out.result = _spoolss_SetJob(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_GETJOB: { + struct spoolss_GetJob *r = (struct spoolss_GetJob *)_r; + ZERO_STRUCT(r->out); + r->out.info = talloc_zero(mem_ctx, union spoolss_JobInfo); + if (r->out.info == 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; + } + + r->out.result = _spoolss_GetJob(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ENUMJOBS: { + struct spoolss_EnumJobs *r = (struct spoolss_EnumJobs *)_r; + ZERO_STRUCT(r->out); + r->out.info = talloc_zero_array(mem_ctx, union spoolss_JobInfo, r->out.count); + if (r->out.info == 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; + } + + r->out.count = talloc_zero(mem_ctx, uint32_t); + if (r->out.count == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_EnumJobs(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ADDPRINTER: { + struct spoolss_AddPrinter *r = (struct spoolss_AddPrinter *)_r; + r->out.result = _spoolss_AddPrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_DELETEPRINTER: { + struct spoolss_DeletePrinter *r = (struct spoolss_DeletePrinter *)_r; + r->out.result = _spoolss_DeletePrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_SETPRINTER: { + struct spoolss_SetPrinter *r = (struct spoolss_SetPrinter *)_r; + r->out.result = _spoolss_SetPrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_GETPRINTER: { + struct spoolss_GetPrinter *r = (struct spoolss_GetPrinter *)_r; + ZERO_STRUCT(r->out); + r->out.info = talloc_zero(mem_ctx, union spoolss_PrinterInfo); + if (r->out.info == 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; + } + + r->out.result = _spoolss_GetPrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ADDPRINTERDRIVER: { + struct spoolss_AddPrinterDriver *r = (struct spoolss_AddPrinterDriver *)_r; + r->out.result = _spoolss_AddPrinterDriver(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ENUMPRINTERDRIVERS: { + struct spoolss_EnumPrinterDrivers *r = (struct spoolss_EnumPrinterDrivers *)_r; + ZERO_STRUCT(r->out); + r->out.info = talloc_zero_array(mem_ctx, union spoolss_DriverInfo, r->out.count); + if (r->out.info == 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; + } + + r->out.count = talloc_zero(mem_ctx, uint32_t); + if (r->out.count == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_EnumPrinterDrivers(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_GETPRINTERDRIVER: { + struct spoolss_GetPrinterDriver *r = (struct spoolss_GetPrinterDriver *)_r; + r->out.result = _spoolss_GetPrinterDriver(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_GETPRINTERDRIVERDIRECTORY: { + struct spoolss_GetPrinterDriverDirectory *r = (struct spoolss_GetPrinterDriverDirectory *)_r; + ZERO_STRUCT(r->out); + r->out.info = talloc_zero(mem_ctx, union spoolss_DriverDirectoryInfo); + if (r->out.info == 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; + } + + r->out.result = _spoolss_GetPrinterDriverDirectory(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_DELETEPRINTERDRIVER: { + struct spoolss_DeletePrinterDriver *r = (struct spoolss_DeletePrinterDriver *)_r; + r->out.result = _spoolss_DeletePrinterDriver(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ADDPRINTPROCESSOR: { + struct spoolss_AddPrintProcessor *r = (struct spoolss_AddPrintProcessor *)_r; + r->out.result = _spoolss_AddPrintProcessor(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ENUMPRINTPROCESSORS: { + struct spoolss_EnumPrintProcessors *r = (struct spoolss_EnumPrintProcessors *)_r; + ZERO_STRUCT(r->out); + r->out.info = talloc_zero_array(mem_ctx, union spoolss_PrintProcessorInfo, r->out.count); + if (r->out.info == 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; + } + + r->out.count = talloc_zero(mem_ctx, uint32_t); + if (r->out.count == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_EnumPrintProcessors(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_GETPRINTPROCESSORDIRECTORY: { + struct spoolss_GetPrintProcessorDirectory *r = (struct spoolss_GetPrintProcessorDirectory *)_r; + r->out.result = _spoolss_GetPrintProcessorDirectory(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_STARTDOCPRINTER: { + struct spoolss_StartDocPrinter *r = (struct spoolss_StartDocPrinter *)_r; + ZERO_STRUCT(r->out); + r->out.job_id = talloc_zero(mem_ctx, uint32_t); + if (r->out.job_id == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_StartDocPrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_STARTPAGEPRINTER: { + struct spoolss_StartPagePrinter *r = (struct spoolss_StartPagePrinter *)_r; + r->out.result = _spoolss_StartPagePrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_WRITEPRINTER: { + struct spoolss_WritePrinter *r = (struct spoolss_WritePrinter *)_r; + ZERO_STRUCT(r->out); + r->out.num_written = talloc_zero(mem_ctx, uint32_t); + if (r->out.num_written == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_WritePrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ENDPAGEPRINTER: { + struct spoolss_EndPagePrinter *r = (struct spoolss_EndPagePrinter *)_r; + r->out.result = _spoolss_EndPagePrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ABORTPRINTER: { + struct spoolss_AbortPrinter *r = (struct spoolss_AbortPrinter *)_r; + r->out.result = _spoolss_AbortPrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_READPRINTER: { + struct spoolss_ReadPrinter *r = (struct spoolss_ReadPrinter *)_r; + ZERO_STRUCT(r->out); + r->out.data = talloc_zero(mem_ctx, DATA_BLOB); + if (r->out.data == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out._data_size = talloc_zero(mem_ctx, uint32_t); + if (r->out._data_size == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_ReadPrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ENDDOCPRINTER: { + struct spoolss_EndDocPrinter *r = (struct spoolss_EndDocPrinter *)_r; + r->out.result = _spoolss_EndDocPrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ADDJOB: { + struct spoolss_AddJob *r = (struct spoolss_AddJob *)_r; + r->out.result = _spoolss_AddJob(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_SCHEDULEJOB: { + struct spoolss_ScheduleJob *r = (struct spoolss_ScheduleJob *)_r; + r->out.result = _spoolss_ScheduleJob(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + 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); + 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; + } + + r->out.result = _spoolss_GetPrinterData(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_SETPRINTERDATA: { + struct spoolss_SetPrinterData *r = (struct spoolss_SetPrinterData *)_r; + r->out.result = _spoolss_SetPrinterData(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_WAITFORPRINTERCHANGE: { + struct spoolss_WaitForPrinterChange *r = (struct spoolss_WaitForPrinterChange *)_r; + r->out.result = _spoolss_WaitForPrinterChange(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_CLOSEPRINTER: { + struct spoolss_ClosePrinter *r = (struct spoolss_ClosePrinter *)_r; + ZERO_STRUCT(r->out); + r->out.handle = r->in.handle; + r->out.result = _spoolss_ClosePrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ADDFORM: { + struct spoolss_AddForm *r = (struct spoolss_AddForm *)_r; + r->out.result = _spoolss_AddForm(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_DELETEFORM: { + struct spoolss_DeleteForm *r = (struct spoolss_DeleteForm *)_r; + r->out.result = _spoolss_DeleteForm(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_GETFORM: { + struct spoolss_GetForm *r = (struct spoolss_GetForm *)_r; + ZERO_STRUCT(r->out); + r->out.info = talloc_zero(mem_ctx, union spoolss_FormInfo); + if (r->out.info == 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; + } + + r->out.result = _spoolss_GetForm(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_SETFORM: { + struct spoolss_SetForm *r = (struct spoolss_SetForm *)_r; + r->out.result = _spoolss_SetForm(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ENUMFORMS: { + struct spoolss_EnumForms *r = (struct spoolss_EnumForms *)_r; + ZERO_STRUCT(r->out); + r->out.info = talloc_zero_array(mem_ctx, union spoolss_FormInfo, r->out.count); + if (r->out.info == 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; + } + + r->out.count = talloc_zero(mem_ctx, uint32_t); + if (r->out.count == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_EnumForms(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ENUMPORTS: { + struct spoolss_EnumPorts *r = (struct spoolss_EnumPorts *)_r; + ZERO_STRUCT(r->out); + r->out.info = talloc_zero_array(mem_ctx, union spoolss_PortInfo, r->out.count); + if (r->out.info == 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; + } + + r->out.count = talloc_zero(mem_ctx, uint32_t); + if (r->out.count == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_EnumPorts(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ENUMMONITORS: { + struct spoolss_EnumMonitors *r = (struct spoolss_EnumMonitors *)_r; + ZERO_STRUCT(r->out); + r->out.info = talloc_zero_array(mem_ctx, union spoolss_MonitorInfo, r->out.count); + if (r->out.info == 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; + } + + r->out.count = talloc_zero(mem_ctx, uint32_t); + if (r->out.count == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_EnumMonitors(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ADDPORT: { + struct spoolss_AddPort *r = (struct spoolss_AddPort *)_r; + r->out.result = _spoolss_AddPort(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_CONFIGUREPORT: { + struct spoolss_ConfigurePort *r = (struct spoolss_ConfigurePort *)_r; + r->out.result = _spoolss_ConfigurePort(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_DELETEPORT: { + struct spoolss_DeletePort *r = (struct spoolss_DeletePort *)_r; + r->out.result = _spoolss_DeletePort(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_CREATEPRINTERIC: { + struct spoolss_CreatePrinterIC *r = (struct spoolss_CreatePrinterIC *)_r; + r->out.result = _spoolss_CreatePrinterIC(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_PLAYGDISCRIPTONPRINTERIC: { + struct spoolss_PlayGDIScriptOnPrinterIC *r = (struct spoolss_PlayGDIScriptOnPrinterIC *)_r; + r->out.result = _spoolss_PlayGDIScriptOnPrinterIC(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_DELETEPRINTERIC: { + struct spoolss_DeletePrinterIC *r = (struct spoolss_DeletePrinterIC *)_r; + r->out.result = _spoolss_DeletePrinterIC(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ADDPRINTERCONNECTION: { + struct spoolss_AddPrinterConnection *r = (struct spoolss_AddPrinterConnection *)_r; + r->out.result = _spoolss_AddPrinterConnection(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_DELETEPRINTERCONNECTION: { + struct spoolss_DeletePrinterConnection *r = (struct spoolss_DeletePrinterConnection *)_r; + r->out.result = _spoolss_DeletePrinterConnection(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_PRINTERMESSAGEBOX: { + struct spoolss_PrinterMessageBox *r = (struct spoolss_PrinterMessageBox *)_r; + r->out.result = _spoolss_PrinterMessageBox(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ADDMONITOR: { + struct spoolss_AddMonitor *r = (struct spoolss_AddMonitor *)_r; + r->out.result = _spoolss_AddMonitor(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_DELETEMONITOR: { + struct spoolss_DeleteMonitor *r = (struct spoolss_DeleteMonitor *)_r; + r->out.result = _spoolss_DeleteMonitor(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_DELETEPRINTPROCESSOR: { + struct spoolss_DeletePrintProcessor *r = (struct spoolss_DeletePrintProcessor *)_r; + r->out.result = _spoolss_DeletePrintProcessor(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ADDPRINTPROVIDOR: { + struct spoolss_AddPrintProvidor *r = (struct spoolss_AddPrintProvidor *)_r; + r->out.result = _spoolss_AddPrintProvidor(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_DELETEPRINTPROVIDOR: { + struct spoolss_DeletePrintProvidor *r = (struct spoolss_DeletePrintProvidor *)_r; + r->out.result = _spoolss_DeletePrintProvidor(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ENUMPRINTPROCDATATYPES: { + struct spoolss_EnumPrintProcDataTypes *r = (struct spoolss_EnumPrintProcDataTypes *)_r; + r->out.result = _spoolss_EnumPrintProcDataTypes(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_RESETPRINTER: { + struct spoolss_ResetPrinter *r = (struct spoolss_ResetPrinter *)_r; + r->out.result = _spoolss_ResetPrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_GETPRINTERDRIVER2: { + struct spoolss_GetPrinterDriver2 *r = (struct spoolss_GetPrinterDriver2 *)_r; + ZERO_STRUCT(r->out); + r->out.info = talloc_zero(mem_ctx, DATA_BLOB); + if (r->out.info == 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; + } + + r->out.server_major_version = talloc_zero(mem_ctx, uint32_t); + if (r->out.server_major_version == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.server_minor_version = talloc_zero(mem_ctx, uint32_t); + if (r->out.server_minor_version == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_GetPrinterDriver2(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_FINDFIRSTPRINTERCHANGENOTIFICATION: { + struct spoolss_FindFirstPrinterChangeNotification *r = (struct spoolss_FindFirstPrinterChangeNotification *)_r; + r->out.result = _spoolss_FindFirstPrinterChangeNotification(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_FINDNEXTPRINTERCHANGENOTIFICATION: { + struct spoolss_FindNextPrinterChangeNotification *r = (struct spoolss_FindNextPrinterChangeNotification *)_r; + r->out.result = _spoolss_FindNextPrinterChangeNotification(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_FINDCLOSEPRINTERNOTIFY: { + struct spoolss_FindClosePrinterNotify *r = (struct spoolss_FindClosePrinterNotify *)_r; + r->out.result = _spoolss_FindClosePrinterNotify(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ROUTERFINDFIRSTPRINTERCHANGENOTIFICATIONOLD: { + struct spoolss_RouterFindFirstPrinterChangeNotificationOld *r = (struct spoolss_RouterFindFirstPrinterChangeNotificationOld *)_r; + r->out.result = _spoolss_RouterFindFirstPrinterChangeNotificationOld(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_REPLYOPENPRINTER: { + struct spoolss_ReplyOpenPrinter *r = (struct spoolss_ReplyOpenPrinter *)_r; + ZERO_STRUCT(r->out); + r->out.handle = talloc_zero(mem_ctx, struct policy_handle); + if (r->out.handle == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_ReplyOpenPrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ROUTERREPLYPRINTER: { + struct spoolss_RouterReplyPrinter *r = (struct spoolss_RouterReplyPrinter *)_r; + r->out.result = _spoolss_RouterReplyPrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_REPLYCLOSEPRINTER: { + struct spoolss_ReplyClosePrinter *r = (struct spoolss_ReplyClosePrinter *)_r; + ZERO_STRUCT(r->out); + r->out.handle = r->in.handle; + r->out.result = _spoolss_ReplyClosePrinter(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ADDPORTEX: { + struct spoolss_AddPortEx *r = (struct spoolss_AddPortEx *)_r; + r->out.result = _spoolss_AddPortEx(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ROUTERFINDFIRSTPRINTERCHANGENOTIFICATION: { + struct spoolss_RouterFindFirstPrinterChangeNotification *r = (struct spoolss_RouterFindFirstPrinterChangeNotification *)_r; + r->out.result = _spoolss_RouterFindFirstPrinterChangeNotification(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_SPOOLERINIT: { + struct spoolss_SpoolerInit *r = (struct spoolss_SpoolerInit *)_r; + r->out.result = _spoolss_SpoolerInit(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_RESETPRINTEREX: { + struct spoolss_ResetPrinterEx *r = (struct spoolss_ResetPrinterEx *)_r; + r->out.result = _spoolss_ResetPrinterEx(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFYEX: { + struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r = (struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *)_r; + r->out.result = _spoolss_RemoteFindFirstPrinterChangeNotifyEx(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ROUTERREFRESHPRINTERCHANGENOTIFICATION: { + struct spoolss_RouterRefreshPrinterChangeNotification *r = (struct spoolss_RouterRefreshPrinterChangeNotification *)_r; + r->out.result = _spoolss_RouterRefreshPrinterChangeNotification(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_REMOTEFINDNEXTPRINTERCHANGENOTIFYEX: { + struct spoolss_RemoteFindNextPrinterChangeNotifyEx *r = (struct spoolss_RemoteFindNextPrinterChangeNotifyEx *)_r; + ZERO_STRUCT(r->out); + r->out.info = talloc_zero(mem_ctx, struct spoolss_NotifyInfo *); + if (r->out.info == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_RemoteFindNextPrinterChangeNotifyEx(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_44: { + struct spoolss_44 *r = (struct spoolss_44 *)_r; + r->out.result = _spoolss_44(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_OPENPRINTEREX: { + struct spoolss_OpenPrinterEx *r = (struct spoolss_OpenPrinterEx *)_r; + ZERO_STRUCT(r->out); + r->out.handle = talloc_zero(mem_ctx, struct policy_handle); + if (r->out.handle == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_OpenPrinterEx(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ADDPRINTEREX: { + struct spoolss_AddPrinterEx *r = (struct spoolss_AddPrinterEx *)_r; + r->out.result = _spoolss_AddPrinterEx(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_47: { + struct spoolss_47 *r = (struct spoolss_47 *)_r; + r->out.result = _spoolss_47(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ENUMPRINTERDATA: { + struct spoolss_EnumPrinterData *r = (struct spoolss_EnumPrinterData *)_r; + ZERO_STRUCT(r->out); + r->out.value_name = talloc_zero_array(mem_ctx, const char, r->in.value_offered / 2); + if (r->out.value_name == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.value_needed = talloc_zero(mem_ctx, uint32_t); + if (r->out.value_needed == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.printerdata_type = talloc_zero(mem_ctx, uint32_t); + if (r->out.printerdata_type == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.buffer = talloc_zero(mem_ctx, DATA_BLOB); + if (r->out.buffer == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.data_needed = talloc_zero(mem_ctx, uint32_t); + if (r->out.data_needed == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_EnumPrinterData(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_DELETEPRINTERDATA: { + struct spoolss_DeletePrinterData *r = (struct spoolss_DeletePrinterData *)_r; + r->out.result = _spoolss_DeletePrinterData(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_4A: { + struct spoolss_4a *r = (struct spoolss_4a *)_r; + r->out.result = _spoolss_4a(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_4B: { + struct spoolss_4b *r = (struct spoolss_4b *)_r; + r->out.result = _spoolss_4b(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_4C: { + struct spoolss_4c *r = (struct spoolss_4c *)_r; + r->out.result = _spoolss_4c(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_SETPRINTERDATAEX: { + struct spoolss_SetPrinterDataEx *r = (struct spoolss_SetPrinterDataEx *)_r; + r->out.result = _spoolss_SetPrinterDataEx(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + 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); + if (r->out.type == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.buffer = talloc_zero(mem_ctx, DATA_BLOB); + if (r->out.buffer == 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; + } + + r->out.result = _spoolss_GetPrinterDataEx(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ENUMPRINTERDATAEX: { + struct spoolss_EnumPrinterDataEx *r = (struct spoolss_EnumPrinterDataEx *)_r; + ZERO_STRUCT(r->out); + r->out.buffer = talloc_zero(mem_ctx, DATA_BLOB); + if (r->out.buffer == 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; + } + + 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; + } + + case NDR_SPOOLSS_ENUMPRINTERKEY: { + struct spoolss_EnumPrinterKey *r = (struct spoolss_EnumPrinterKey *)_r; + ZERO_STRUCT(r->out); + r->out.needed = r->in.needed; + r->out.key_buffer_size = talloc_zero(mem_ctx, uint32_t); + if (r->out.key_buffer_size == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.key_buffer = talloc_zero_array(mem_ctx, uint16_t, r->out.key_buffer_size); + if (r->out.key_buffer == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_EnumPrinterKey(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_DELETEPRINTERDATAEX: { + struct spoolss_DeletePrinterDataEx *r = (struct spoolss_DeletePrinterDataEx *)_r; + r->out.result = _spoolss_DeletePrinterDataEx(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_DELETEPRINTERKEY: { + struct spoolss_DeletePrinterKey *r = (struct spoolss_DeletePrinterKey *)_r; + r->out.result = _spoolss_DeletePrinterKey(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_53: { + struct spoolss_53 *r = (struct spoolss_53 *)_r; + r->out.result = _spoolss_53(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_DELETEPRINTERDRIVEREX: { + struct spoolss_DeletePrinterDriverEx *r = (struct spoolss_DeletePrinterDriverEx *)_r; + r->out.result = _spoolss_DeletePrinterDriverEx(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_55: { + struct spoolss_55 *r = (struct spoolss_55 *)_r; + r->out.result = _spoolss_55(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_56: { + struct spoolss_56 *r = (struct spoolss_56 *)_r; + r->out.result = _spoolss_56(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_57: { + struct spoolss_57 *r = (struct spoolss_57 *)_r; + r->out.result = _spoolss_57(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_XCVDATA: { + struct spoolss_XcvData *r = (struct spoolss_XcvData *)_r; + ZERO_STRUCT(r->out); + r->out.out_data = talloc_zero(mem_ctx, DATA_BLOB); + if (r->out.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; + } + + r->out.unknown2 = talloc_zero(mem_ctx, uint32_t); + if (r->out.unknown2 == NULL) { + return NT_STATUS_NO_MEMORY; + } + + r->out.result = _spoolss_XcvData(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_ADDPRINTERDRIVEREX: { + struct spoolss_AddPrinterDriverEx *r = (struct spoolss_AddPrinterDriverEx *)_r; + r->out.result = _spoolss_AddPrinterDriverEx(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_5A: { + struct spoolss_5a *r = (struct spoolss_5a *)_r; + r->out.result = _spoolss_5a(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_5B: { + struct spoolss_5b *r = (struct spoolss_5b *)_r; + r->out.result = _spoolss_5b(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_5C: { + struct spoolss_5c *r = (struct spoolss_5c *)_r; + r->out.result = _spoolss_5c(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_5D: { + struct spoolss_5d *r = (struct spoolss_5d *)_r; + r->out.result = _spoolss_5d(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_5E: { + struct spoolss_5e *r = (struct spoolss_5e *)_r; + r->out.result = _spoolss_5e(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + case NDR_SPOOLSS_5F: { + struct spoolss_5f *r = (struct spoolss_5f *)_r; + r->out.result = _spoolss_5f(cli->pipes_struct, r); + return NT_STATUS_OK; + } + + default: + return NT_STATUS_NOT_IMPLEMENTED; + } +} + +NTSTATUS rpc_spoolss_init(void) +{ + return rpc_srv_register(SMB_RPC_INTERFACE_VERSION, "spoolss", "spoolss", &ndr_table_spoolss, api_spoolss_cmds, sizeof(api_spoolss_cmds) / sizeof(struct api_struct)); +} diff --git a/librpc/gen_ndr/srv_spoolss.h b/librpc/gen_ndr/srv_spoolss.h new file mode 100644 index 0000000000..82e9faf993 --- /dev/null +++ b/librpc/gen_ndr/srv_spoolss.h @@ -0,0 +1,199 @@ +#include "../librpc/gen_ndr/ndr_spoolss.h" +#ifndef __SRV_SPOOLSS__ +#define __SRV_SPOOLSS__ +WERROR _spoolss_EnumPrinters(pipes_struct *p, struct spoolss_EnumPrinters *r); +WERROR _spoolss_OpenPrinter(pipes_struct *p, struct spoolss_OpenPrinter *r); +WERROR _spoolss_SetJob(pipes_struct *p, struct spoolss_SetJob *r); +WERROR _spoolss_GetJob(pipes_struct *p, struct spoolss_GetJob *r); +WERROR _spoolss_EnumJobs(pipes_struct *p, struct spoolss_EnumJobs *r); +WERROR _spoolss_AddPrinter(pipes_struct *p, struct spoolss_AddPrinter *r); +WERROR _spoolss_DeletePrinter(pipes_struct *p, struct spoolss_DeletePrinter *r); +WERROR _spoolss_SetPrinter(pipes_struct *p, struct spoolss_SetPrinter *r); +WERROR _spoolss_GetPrinter(pipes_struct *p, struct spoolss_GetPrinter *r); +WERROR _spoolss_AddPrinterDriver(pipes_struct *p, struct spoolss_AddPrinterDriver *r); +WERROR _spoolss_EnumPrinterDrivers(pipes_struct *p, struct spoolss_EnumPrinterDrivers *r); +WERROR _spoolss_GetPrinterDriver(pipes_struct *p, struct spoolss_GetPrinterDriver *r); +WERROR _spoolss_GetPrinterDriverDirectory(pipes_struct *p, struct spoolss_GetPrinterDriverDirectory *r); +WERROR _spoolss_DeletePrinterDriver(pipes_struct *p, struct spoolss_DeletePrinterDriver *r); +WERROR _spoolss_AddPrintProcessor(pipes_struct *p, struct spoolss_AddPrintProcessor *r); +WERROR _spoolss_EnumPrintProcessors(pipes_struct *p, struct spoolss_EnumPrintProcessors *r); +WERROR _spoolss_GetPrintProcessorDirectory(pipes_struct *p, struct spoolss_GetPrintProcessorDirectory *r); +WERROR _spoolss_StartDocPrinter(pipes_struct *p, struct spoolss_StartDocPrinter *r); +WERROR _spoolss_StartPagePrinter(pipes_struct *p, struct spoolss_StartPagePrinter *r); +WERROR _spoolss_WritePrinter(pipes_struct *p, struct spoolss_WritePrinter *r); +WERROR _spoolss_EndPagePrinter(pipes_struct *p, struct spoolss_EndPagePrinter *r); +WERROR _spoolss_AbortPrinter(pipes_struct *p, struct spoolss_AbortPrinter *r); +WERROR _spoolss_ReadPrinter(pipes_struct *p, struct spoolss_ReadPrinter *r); +WERROR _spoolss_EndDocPrinter(pipes_struct *p, struct spoolss_EndDocPrinter *r); +WERROR _spoolss_AddJob(pipes_struct *p, struct spoolss_AddJob *r); +WERROR _spoolss_ScheduleJob(pipes_struct *p, struct spoolss_ScheduleJob *r); +WERROR _spoolss_GetPrinterData(pipes_struct *p, struct spoolss_GetPrinterData *r); +WERROR _spoolss_SetPrinterData(pipes_struct *p, struct spoolss_SetPrinterData *r); +WERROR _spoolss_WaitForPrinterChange(pipes_struct *p, struct spoolss_WaitForPrinterChange *r); +WERROR _spoolss_ClosePrinter(pipes_struct *p, struct spoolss_ClosePrinter *r); +WERROR _spoolss_AddForm(pipes_struct *p, struct spoolss_AddForm *r); +WERROR _spoolss_DeleteForm(pipes_struct *p, struct spoolss_DeleteForm *r); +WERROR _spoolss_GetForm(pipes_struct *p, struct spoolss_GetForm *r); +WERROR _spoolss_SetForm(pipes_struct *p, struct spoolss_SetForm *r); +WERROR _spoolss_EnumForms(pipes_struct *p, struct spoolss_EnumForms *r); +WERROR _spoolss_EnumPorts(pipes_struct *p, struct spoolss_EnumPorts *r); +WERROR _spoolss_EnumMonitors(pipes_struct *p, struct spoolss_EnumMonitors *r); +WERROR _spoolss_AddPort(pipes_struct *p, struct spoolss_AddPort *r); +WERROR _spoolss_ConfigurePort(pipes_struct *p, struct spoolss_ConfigurePort *r); +WERROR _spoolss_DeletePort(pipes_struct *p, struct spoolss_DeletePort *r); +WERROR _spoolss_CreatePrinterIC(pipes_struct *p, struct spoolss_CreatePrinterIC *r); +WERROR _spoolss_PlayGDIScriptOnPrinterIC(pipes_struct *p, struct spoolss_PlayGDIScriptOnPrinterIC *r); +WERROR _spoolss_DeletePrinterIC(pipes_struct *p, struct spoolss_DeletePrinterIC *r); +WERROR _spoolss_AddPrinterConnection(pipes_struct *p, struct spoolss_AddPrinterConnection *r); +WERROR _spoolss_DeletePrinterConnection(pipes_struct *p, struct spoolss_DeletePrinterConnection *r); +WERROR _spoolss_PrinterMessageBox(pipes_struct *p, struct spoolss_PrinterMessageBox *r); +WERROR _spoolss_AddMonitor(pipes_struct *p, struct spoolss_AddMonitor *r); +WERROR _spoolss_DeleteMonitor(pipes_struct *p, struct spoolss_DeleteMonitor *r); +WERROR _spoolss_DeletePrintProcessor(pipes_struct *p, struct spoolss_DeletePrintProcessor *r); +WERROR _spoolss_AddPrintProvidor(pipes_struct *p, struct spoolss_AddPrintProvidor *r); +WERROR _spoolss_DeletePrintProvidor(pipes_struct *p, struct spoolss_DeletePrintProvidor *r); +WERROR _spoolss_EnumPrintProcDataTypes(pipes_struct *p, struct spoolss_EnumPrintProcDataTypes *r); +WERROR _spoolss_ResetPrinter(pipes_struct *p, struct spoolss_ResetPrinter *r); +WERROR _spoolss_GetPrinterDriver2(pipes_struct *p, struct spoolss_GetPrinterDriver2 *r); +WERROR _spoolss_FindFirstPrinterChangeNotification(pipes_struct *p, struct spoolss_FindFirstPrinterChangeNotification *r); +WERROR _spoolss_FindNextPrinterChangeNotification(pipes_struct *p, struct spoolss_FindNextPrinterChangeNotification *r); +WERROR _spoolss_FindClosePrinterNotify(pipes_struct *p, struct spoolss_FindClosePrinterNotify *r); +WERROR _spoolss_RouterFindFirstPrinterChangeNotificationOld(pipes_struct *p, struct spoolss_RouterFindFirstPrinterChangeNotificationOld *r); +WERROR _spoolss_ReplyOpenPrinter(pipes_struct *p, struct spoolss_ReplyOpenPrinter *r); +WERROR _spoolss_RouterReplyPrinter(pipes_struct *p, struct spoolss_RouterReplyPrinter *r); +WERROR _spoolss_ReplyClosePrinter(pipes_struct *p, struct spoolss_ReplyClosePrinter *r); +WERROR _spoolss_AddPortEx(pipes_struct *p, struct spoolss_AddPortEx *r); +WERROR _spoolss_RouterFindFirstPrinterChangeNotification(pipes_struct *p, struct spoolss_RouterFindFirstPrinterChangeNotification *r); +WERROR _spoolss_SpoolerInit(pipes_struct *p, struct spoolss_SpoolerInit *r); +WERROR _spoolss_ResetPrinterEx(pipes_struct *p, struct spoolss_ResetPrinterEx *r); +WERROR _spoolss_RemoteFindFirstPrinterChangeNotifyEx(pipes_struct *p, struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r); +WERROR _spoolss_RouterRefreshPrinterChangeNotification(pipes_struct *p, struct spoolss_RouterRefreshPrinterChangeNotification *r); +WERROR _spoolss_RemoteFindNextPrinterChangeNotifyEx(pipes_struct *p, struct spoolss_RemoteFindNextPrinterChangeNotifyEx *r); +WERROR _spoolss_44(pipes_struct *p, struct spoolss_44 *r); +WERROR _spoolss_OpenPrinterEx(pipes_struct *p, struct spoolss_OpenPrinterEx *r); +WERROR _spoolss_AddPrinterEx(pipes_struct *p, struct spoolss_AddPrinterEx *r); +WERROR _spoolss_47(pipes_struct *p, struct spoolss_47 *r); +WERROR _spoolss_EnumPrinterData(pipes_struct *p, struct spoolss_EnumPrinterData *r); +WERROR _spoolss_DeletePrinterData(pipes_struct *p, struct spoolss_DeletePrinterData *r); +WERROR _spoolss_4a(pipes_struct *p, struct spoolss_4a *r); +WERROR _spoolss_4b(pipes_struct *p, struct spoolss_4b *r); +WERROR _spoolss_4c(pipes_struct *p, struct spoolss_4c *r); +WERROR _spoolss_SetPrinterDataEx(pipes_struct *p, struct spoolss_SetPrinterDataEx *r); +WERROR _spoolss_GetPrinterDataEx(pipes_struct *p, struct spoolss_GetPrinterDataEx *r); +WERROR _spoolss_EnumPrinterDataEx(pipes_struct *p, struct spoolss_EnumPrinterDataEx *r); +WERROR _spoolss_EnumPrinterKey(pipes_struct *p, struct spoolss_EnumPrinterKey *r); +WERROR _spoolss_DeletePrinterDataEx(pipes_struct *p, struct spoolss_DeletePrinterDataEx *r); +WERROR _spoolss_DeletePrinterKey(pipes_struct *p, struct spoolss_DeletePrinterKey *r); +WERROR _spoolss_53(pipes_struct *p, struct spoolss_53 *r); +WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p, struct spoolss_DeletePrinterDriverEx *r); +WERROR _spoolss_55(pipes_struct *p, struct spoolss_55 *r); +WERROR _spoolss_56(pipes_struct *p, struct spoolss_56 *r); +WERROR _spoolss_57(pipes_struct *p, struct spoolss_57 *r); +WERROR _spoolss_XcvData(pipes_struct *p, struct spoolss_XcvData *r); +WERROR _spoolss_AddPrinterDriverEx(pipes_struct *p, struct spoolss_AddPrinterDriverEx *r); +WERROR _spoolss_5a(pipes_struct *p, struct spoolss_5a *r); +WERROR _spoolss_5b(pipes_struct *p, struct spoolss_5b *r); +WERROR _spoolss_5c(pipes_struct *p, struct spoolss_5c *r); +WERROR _spoolss_5d(pipes_struct *p, struct spoolss_5d *r); +WERROR _spoolss_5e(pipes_struct *p, struct spoolss_5e *r); +WERROR _spoolss_5f(pipes_struct *p, struct spoolss_5f *r); +void spoolss_get_pipe_fns(struct api_struct **fns, int *n_fns); +NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *r); +WERROR _spoolss_EnumPrinters(pipes_struct *p, struct spoolss_EnumPrinters *r); +WERROR _spoolss_OpenPrinter(pipes_struct *p, struct spoolss_OpenPrinter *r); +WERROR _spoolss_SetJob(pipes_struct *p, struct spoolss_SetJob *r); +WERROR _spoolss_GetJob(pipes_struct *p, struct spoolss_GetJob *r); +WERROR _spoolss_EnumJobs(pipes_struct *p, struct spoolss_EnumJobs *r); +WERROR _spoolss_AddPrinter(pipes_struct *p, struct spoolss_AddPrinter *r); +WERROR _spoolss_DeletePrinter(pipes_struct *p, struct spoolss_DeletePrinter *r); +WERROR _spoolss_SetPrinter(pipes_struct *p, struct spoolss_SetPrinter *r); +WERROR _spoolss_GetPrinter(pipes_struct *p, struct spoolss_GetPrinter *r); +WERROR _spoolss_AddPrinterDriver(pipes_struct *p, struct spoolss_AddPrinterDriver *r); +WERROR _spoolss_EnumPrinterDrivers(pipes_struct *p, struct spoolss_EnumPrinterDrivers *r); +WERROR _spoolss_GetPrinterDriver(pipes_struct *p, struct spoolss_GetPrinterDriver *r); +WERROR _spoolss_GetPrinterDriverDirectory(pipes_struct *p, struct spoolss_GetPrinterDriverDirectory *r); +WERROR _spoolss_DeletePrinterDriver(pipes_struct *p, struct spoolss_DeletePrinterDriver *r); +WERROR _spoolss_AddPrintProcessor(pipes_struct *p, struct spoolss_AddPrintProcessor *r); +WERROR _spoolss_EnumPrintProcessors(pipes_struct *p, struct spoolss_EnumPrintProcessors *r); +WERROR _spoolss_GetPrintProcessorDirectory(pipes_struct *p, struct spoolss_GetPrintProcessorDirectory *r); +WERROR _spoolss_StartDocPrinter(pipes_struct *p, struct spoolss_StartDocPrinter *r); +WERROR _spoolss_StartPagePrinter(pipes_struct *p, struct spoolss_StartPagePrinter *r); +WERROR _spoolss_WritePrinter(pipes_struct *p, struct spoolss_WritePrinter *r); +WERROR _spoolss_EndPagePrinter(pipes_struct *p, struct spoolss_EndPagePrinter *r); +WERROR _spoolss_AbortPrinter(pipes_struct *p, struct spoolss_AbortPrinter *r); +WERROR _spoolss_ReadPrinter(pipes_struct *p, struct spoolss_ReadPrinter *r); +WERROR _spoolss_EndDocPrinter(pipes_struct *p, struct spoolss_EndDocPrinter *r); +WERROR _spoolss_AddJob(pipes_struct *p, struct spoolss_AddJob *r); +WERROR _spoolss_ScheduleJob(pipes_struct *p, struct spoolss_ScheduleJob *r); +WERROR _spoolss_GetPrinterData(pipes_struct *p, struct spoolss_GetPrinterData *r); +WERROR _spoolss_SetPrinterData(pipes_struct *p, struct spoolss_SetPrinterData *r); +WERROR _spoolss_WaitForPrinterChange(pipes_struct *p, struct spoolss_WaitForPrinterChange *r); +WERROR _spoolss_ClosePrinter(pipes_struct *p, struct spoolss_ClosePrinter *r); +WERROR _spoolss_AddForm(pipes_struct *p, struct spoolss_AddForm *r); +WERROR _spoolss_DeleteForm(pipes_struct *p, struct spoolss_DeleteForm *r); +WERROR _spoolss_GetForm(pipes_struct *p, struct spoolss_GetForm *r); +WERROR _spoolss_SetForm(pipes_struct *p, struct spoolss_SetForm *r); +WERROR _spoolss_EnumForms(pipes_struct *p, struct spoolss_EnumForms *r); +WERROR _spoolss_EnumPorts(pipes_struct *p, struct spoolss_EnumPorts *r); +WERROR _spoolss_EnumMonitors(pipes_struct *p, struct spoolss_EnumMonitors *r); +WERROR _spoolss_AddPort(pipes_struct *p, struct spoolss_AddPort *r); +WERROR _spoolss_ConfigurePort(pipes_struct *p, struct spoolss_ConfigurePort *r); +WERROR _spoolss_DeletePort(pipes_struct *p, struct spoolss_DeletePort *r); +WERROR _spoolss_CreatePrinterIC(pipes_struct *p, struct spoolss_CreatePrinterIC *r); +WERROR _spoolss_PlayGDIScriptOnPrinterIC(pipes_struct *p, struct spoolss_PlayGDIScriptOnPrinterIC *r); +WERROR _spoolss_DeletePrinterIC(pipes_struct *p, struct spoolss_DeletePrinterIC *r); +WERROR _spoolss_AddPrinterConnection(pipes_struct *p, struct spoolss_AddPrinterConnection *r); +WERROR _spoolss_DeletePrinterConnection(pipes_struct *p, struct spoolss_DeletePrinterConnection *r); +WERROR _spoolss_PrinterMessageBox(pipes_struct *p, struct spoolss_PrinterMessageBox *r); +WERROR _spoolss_AddMonitor(pipes_struct *p, struct spoolss_AddMonitor *r); +WERROR _spoolss_DeleteMonitor(pipes_struct *p, struct spoolss_DeleteMonitor *r); +WERROR _spoolss_DeletePrintProcessor(pipes_struct *p, struct spoolss_DeletePrintProcessor *r); +WERROR _spoolss_AddPrintProvidor(pipes_struct *p, struct spoolss_AddPrintProvidor *r); +WERROR _spoolss_DeletePrintProvidor(pipes_struct *p, struct spoolss_DeletePrintProvidor *r); +WERROR _spoolss_EnumPrintProcDataTypes(pipes_struct *p, struct spoolss_EnumPrintProcDataTypes *r); +WERROR _spoolss_ResetPrinter(pipes_struct *p, struct spoolss_ResetPrinter *r); +WERROR _spoolss_GetPrinterDriver2(pipes_struct *p, struct spoolss_GetPrinterDriver2 *r); +WERROR _spoolss_FindFirstPrinterChangeNotification(pipes_struct *p, struct spoolss_FindFirstPrinterChangeNotification *r); +WERROR _spoolss_FindNextPrinterChangeNotification(pipes_struct *p, struct spoolss_FindNextPrinterChangeNotification *r); +WERROR _spoolss_FindClosePrinterNotify(pipes_struct *p, struct spoolss_FindClosePrinterNotify *r); +WERROR _spoolss_RouterFindFirstPrinterChangeNotificationOld(pipes_struct *p, struct spoolss_RouterFindFirstPrinterChangeNotificationOld *r); +WERROR _spoolss_ReplyOpenPrinter(pipes_struct *p, struct spoolss_ReplyOpenPrinter *r); +WERROR _spoolss_RouterReplyPrinter(pipes_struct *p, struct spoolss_RouterReplyPrinter *r); +WERROR _spoolss_ReplyClosePrinter(pipes_struct *p, struct spoolss_ReplyClosePrinter *r); +WERROR _spoolss_AddPortEx(pipes_struct *p, struct spoolss_AddPortEx *r); +WERROR _spoolss_RouterFindFirstPrinterChangeNotification(pipes_struct *p, struct spoolss_RouterFindFirstPrinterChangeNotification *r); +WERROR _spoolss_SpoolerInit(pipes_struct *p, struct spoolss_SpoolerInit *r); +WERROR _spoolss_ResetPrinterEx(pipes_struct *p, struct spoolss_ResetPrinterEx *r); +WERROR _spoolss_RemoteFindFirstPrinterChangeNotifyEx(pipes_struct *p, struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r); +WERROR _spoolss_RouterRefreshPrinterChangeNotification(pipes_struct *p, struct spoolss_RouterRefreshPrinterChangeNotification *r); +WERROR _spoolss_RemoteFindNextPrinterChangeNotifyEx(pipes_struct *p, struct spoolss_RemoteFindNextPrinterChangeNotifyEx *r); +WERROR _spoolss_44(pipes_struct *p, struct spoolss_44 *r); +WERROR _spoolss_OpenPrinterEx(pipes_struct *p, struct spoolss_OpenPrinterEx *r); +WERROR _spoolss_AddPrinterEx(pipes_struct *p, struct spoolss_AddPrinterEx *r); +WERROR _spoolss_47(pipes_struct *p, struct spoolss_47 *r); +WERROR _spoolss_EnumPrinterData(pipes_struct *p, struct spoolss_EnumPrinterData *r); +WERROR _spoolss_DeletePrinterData(pipes_struct *p, struct spoolss_DeletePrinterData *r); +WERROR _spoolss_4a(pipes_struct *p, struct spoolss_4a *r); +WERROR _spoolss_4b(pipes_struct *p, struct spoolss_4b *r); +WERROR _spoolss_4c(pipes_struct *p, struct spoolss_4c *r); +WERROR _spoolss_SetPrinterDataEx(pipes_struct *p, struct spoolss_SetPrinterDataEx *r); +WERROR _spoolss_GetPrinterDataEx(pipes_struct *p, struct spoolss_GetPrinterDataEx *r); +WERROR _spoolss_EnumPrinterDataEx(pipes_struct *p, struct spoolss_EnumPrinterDataEx *r); +WERROR _spoolss_EnumPrinterKey(pipes_struct *p, struct spoolss_EnumPrinterKey *r); +WERROR _spoolss_DeletePrinterDataEx(pipes_struct *p, struct spoolss_DeletePrinterDataEx *r); +WERROR _spoolss_DeletePrinterKey(pipes_struct *p, struct spoolss_DeletePrinterKey *r); +WERROR _spoolss_53(pipes_struct *p, struct spoolss_53 *r); +WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p, struct spoolss_DeletePrinterDriverEx *r); +WERROR _spoolss_55(pipes_struct *p, struct spoolss_55 *r); +WERROR _spoolss_56(pipes_struct *p, struct spoolss_56 *r); +WERROR _spoolss_57(pipes_struct *p, struct spoolss_57 *r); +WERROR _spoolss_XcvData(pipes_struct *p, struct spoolss_XcvData *r); +WERROR _spoolss_AddPrinterDriverEx(pipes_struct *p, struct spoolss_AddPrinterDriverEx *r); +WERROR _spoolss_5a(pipes_struct *p, struct spoolss_5a *r); +WERROR _spoolss_5b(pipes_struct *p, struct spoolss_5b *r); +WERROR _spoolss_5c(pipes_struct *p, struct spoolss_5c *r); +WERROR _spoolss_5d(pipes_struct *p, struct spoolss_5d *r); +WERROR _spoolss_5e(pipes_struct *p, struct spoolss_5e *r); +WERROR _spoolss_5f(pipes_struct *p, struct spoolss_5f *r); +NTSTATUS rpc_spoolss_init(void); +#endif /* __SRV_SPOOLSS__ */ -- cgit