The branch, v4-9-test has been updated via 10d1b4d ctdb-recoverd: Set recovery lock handle at start of attempt via e6bcccb ctdb-recoverd: Handle cancellation when releasing recovery lock via a9c7c64 ctdb-recoverd: Return early when the recovery lock is not held via 4913040 ctdb-recoverd: Store recovery lock handle via 54820e3 ctdb-recoverd: Use talloc() to allocate recovery lock handle via 773a647 ctdb-recoverd: Rename hold_reclock_state to ctdb_recovery_lock_handle via 7bd0e80 ctdb-recoverd: Re-check master on failure to take recovery lock via 3819f79 ctdb-recoverd: Clean up taking of recovery lock via 7187d7d ctdb-cluster-mutex: Block signals around fork via de45241 ctdb-cluster-mutex: Reset SIGTERM handler in cluster mutex child via 0420955 ctdb-doc: Remove PIDFILE option from ctdbd_wrapper man page via ff7b231 s3-rpcclient: Use spoolss_init_spoolss_UserLevel1 in winspool cmds via 06c566c s3-rpc_client: Advertise Windows 7 client info via 78fbf10 s3-spoolss: Make spoolss client os_major,os_minor and os_build configurable. from cab67cb VERSION: Bump version up to 4.9.1...
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-9-test - Log ----------------------------------------------------------------- commit 10d1b4d9a2e24f5bd6d5009f9ee6b4a8e1114af6 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Sep 3 13:30:57 2018 +1000 ctdb-recoverd: Set recovery lock handle at start of attempt This allows the attempt to be cancelled if an election is lost and an unlock is done before the attempt is completed. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13617 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> Autobuild-User(master): Martin Schwenke <mart...@samba.org> Autobuild-Date(master): Tue Sep 18 02:18:30 CEST 2018 on sn-devel-144 (cherry picked from commit 486022ef8f43251258f255ffa15f1a01bc6aa2b7) Autobuild-User(v4-9-test): Karolin Seeger <ksee...@samba.org> Autobuild-Date(v4-9-test): Thu Sep 20 12:35:23 CEST 2018 on sn-devel-144 commit e6bcccbca29a98af134a5f9e3ef620ef48411240 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Sep 3 13:01:19 2018 +1000 ctdb-recoverd: Handle cancellation when releasing recovery lock If the recovery lock is in the process of being taken then free the cluster mutex handle but leave the recovery lock handle in place. This allows ctdb_recovery_lock() to fail. Note that this isn't yet live because rec->recovery_lock_handle is still only set at the completion of the attempt to take the lock. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13617 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> (cherry picked from commit b1dc5687844e90b0e3c39cb46a1116c86118fbf4) commit a9c7c64116ad0031aa132bceee08cec9adc37ad8 Author: Martin Schwenke <mar...@meltin.net> Date: Tue Sep 11 15:05:19 2018 +1000 ctdb-recoverd: Return early when the recovery lock is not held This makes upcoming changes simpler. Update to modern debug macro while touching relevant line. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13617 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> (cherry picked from commit a755d060c13b65dfb6d73979aaf111c489882bfb) commit 491304027110a89a14415cfab62dc50d38b9131d Author: Martin Schwenke <mar...@meltin.net> Date: Mon Sep 3 12:39:32 2018 +1000 ctdb-recoverd: Store recovery lock handle ... not just cluster mutex handle. This makes the recovery lock handle long-lived and with allow the releasing code to cancel an in-progress attempt to take the recovery lock. The cluster mutex handle is now allocated off the recovery lock handle. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13617 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> (cherry picked from commit c52216740bd81b68876de06e104822bbbca86df9) commit 54820e3d4024d5ffb0be36db026845a8c4dd6e5c Author: Martin Schwenke <mar...@meltin.net> Date: Mon Sep 3 11:43:44 2018 +1000 ctdb-recoverd: Use talloc() to allocate recovery lock handle At the moment this is still local and is freed after the mutex is successfully taken. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13617 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> (cherry picked from commit a53b264aee7d620ee8ecf9114b0014c5bb678484) commit 773a64741d63e9ff24f681e243afe72b2dd3a561 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Sep 3 11:30:06 2018 +1000 ctdb-recoverd: Rename hold_reclock_state to ctdb_recovery_lock_handle This will be a longer lived structure. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13617 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> (cherry picked from commit af22f03dbe9040f5f743eb85bb50d411269bbab4) commit 7bd0e802455d567374084339d3835197eac5212e Author: Martin Schwenke <mar...@meltin.net> Date: Sun Sep 9 08:30:50 2018 +1000 ctdb-recoverd: Re-check master on failure to take recovery lock If the master changed while trying to take the lock then fail gracefully. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13617 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> (cherry picked from commit c516e58ce92c420dc993bd9b7f1433641bd764bd) commit 3819f795254558db298022bd6ff7900e7b883229 Author: Martin Schwenke <mar...@meltin.net> Date: Sun Sep 9 08:27:46 2018 +1000 ctdb-recoverd: Clean up taking of recovery lock No functional changes, just coding style cleanups and debug message tweaks. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13617 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> (cherry picked from commit 59fc01646c7d65ba90b0a1a34c3795ff842351c5) commit 7187d7dbdcc46200196107b23355d62f820497c4 Author: Martin Schwenke <mar...@meltin.net> Date: Wed Sep 12 17:51:47 2018 +1000 ctdb-cluster-mutex: Block signals around fork If SIGTERM is received and the tevent signal handler setup in the recovery daemon is still enabled then the signal is handled and a corresponding event is queued. The child never runs an event loop so the signal is effectively ignored. Resetting the SIGTERM handler isn't enough. A signal can arrive before that. Block SIGTERM before forking and then immediately unblock it in the parent. In the child, unblock SIGTERM after the signal handler is reset. An explicit unblock is needed because according to sigprocmask(2) "the signal mask is preserved across execve(2)". BUG: https://bugzilla.samba.org/show_bug.cgi?id=13617 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> (cherry picked from commit e789d0da57fc3fc6d22bfa00577a2e65034ca27a) commit de45241352425862d186fc9d052af6786522196d Author: Martin Schwenke <mar...@meltin.net> Date: Wed Sep 12 14:18:00 2018 +1000 ctdb-cluster-mutex: Reset SIGTERM handler in cluster mutex child If SIGTERM is received and the tevent signal handler setup in the recovery daemon is still enabled then the signal is handled and a corresponding event is queued. The child never runs an event loop so the signal is effectively ignored. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13617 Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> (cherry picked from commit 5a6b139884f08ee2ee10f9d16fe56ad8fb5352a6) commit 042095582f8bb5c3a20a6cad08187b95fbc29416 Author: Ralph Wuerthner <ralph.wuerth...@de.ibm.com> Date: Tue Sep 11 10:00:52 2018 +0200 ctdb-doc: Remove PIDFILE option from ctdbd_wrapper man page BUG: https://bugzilla.samba.org/show_bug.cgi?id=13610 Signed-off-by: Ralph Wuerthner <ralph.wuerth...@de.ibm.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Ralph Böhme <s...@samba.org> Autobuild-User(master): Martin Schwenke <mart...@samba.org> Autobuild-Date(master): Wed Sep 12 21:50:57 CEST 2018 on sn-devel-144 (cherry picked from commit e52abc8a44de6791dceb6f43af1db472a3d9ec37) commit ff7b23144273cf4a28f90f44fd1e7757cbe79590 Author: Günther Deschner <g...@samba.org> Date: Fri Aug 31 18:22:04 2018 +0200 s3-rpcclient: Use spoolss_init_spoolss_UserLevel1 in winspool cmds Use spoolss initialization function to set client version information for iremotewinspool printer operations Signed-off-by: Guenther Deschner <g...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit 06c566c5bae97ebb37fa5d0d8eaf760e26d61128 Author: Justin Stephenson <jstep...@redhat.com> Date: Fri Aug 31 13:28:58 2018 -0400 s3-rpc_client: Advertise Windows 7 client info Client printing operations currently fail against Windows Server 2016 with Access Denied if a client os build number lower than 6000 is advertised. Increase the default build number, major, and minor versions to values associated with client OS versoins Windows 7 and Windows Server 2008 R2. The build number value specifically needs to be increased to allow these operations to succeed. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13597 Signed-off-by: Justin Stephenson <jstep...@redhat.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit 78fbf101a1a17e433ca7067383beee2da4a297fc Author: Günther Deschner <g...@samba.org> Date: Fri Aug 31 17:36:19 2018 +0200 s3-spoolss: Make spoolss client os_major,os_minor and os_build configurable. Similar to spoolss server options, make the client advertised OS version values configurable to allow overriding the defaults provided to the print server. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13597 Signed-off-by: Guenther Deschner <g...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> ----------------------------------------------------------------------- Summary of changes: ctdb/doc/ctdbd_wrapper.1.xml | 6 -- ctdb/server/ctdb_cluster_mutex.c | 32 ++++++ ctdb/server/ctdb_recoverd.c | 120 +++++++++++++++------- docs-xml/smbdotconf/printing/spoolssosversion.xml | 39 +++++++ source3/rpc_client/cli_spoolss.c | 29 +++--- source3/rpc_client/init_spoolss.c | 31 ++++++ source3/rpc_client/init_spoolss.h | 3 + source3/rpcclient/cmd_iremotewinspool.c | 16 +-- 8 files changed, 210 insertions(+), 66 deletions(-) Changeset truncated at 500 lines: diff --git a/ctdb/doc/ctdbd_wrapper.1.xml b/ctdb/doc/ctdbd_wrapper.1.xml index a1b92e3..2c68c47 100644 --- a/ctdb/doc/ctdbd_wrapper.1.xml +++ b/ctdb/doc/ctdbd_wrapper.1.xml @@ -20,7 +20,6 @@ <refsynopsisdiv> <cmdsynopsis> <command>ctdbd_wrapper</command> - <arg choice="req"><replaceable>PIDFILE</replaceable></arg> <group choice="req"> <arg choice="plain">start</arg> <arg choice="plain">stop</arg> @@ -35,11 +34,6 @@ </para> <para> - <replaceable>PIDFILE</replaceable> specifies the location of the - file containing the PID of the main CTDB daemon. - </para> - - <para> See <citerefentry><refentrytitle>ctdb</refentrytitle> <manvolnum>7</manvolnum></citerefentry> for an overview of CTDB. </para> diff --git a/ctdb/server/ctdb_cluster_mutex.c b/ctdb/server/ctdb_cluster_mutex.c index 804c6d5..330d5fd 100644 --- a/ctdb/server/ctdb_cluster_mutex.c +++ b/ctdb/server/ctdb_cluster_mutex.c @@ -196,6 +196,7 @@ ctdb_cluster_mutex(TALLOC_CTX *mem_ctx, { struct ctdb_cluster_mutex_handle *h; char **args; + sigset_t sigset_term; int ret; h = talloc(mem_ctx, struct ctdb_cluster_mutex_handle); @@ -225,15 +226,41 @@ ctdb_cluster_mutex(TALLOC_CTX *mem_ctx, return NULL; } + sigemptyset(&sigset_term); + sigaddset(&sigset_term, SIGTERM); + ret = sigprocmask(SIG_BLOCK, &sigset_term, NULL); + if (ret != 0) { + DBG_WARNING("Failed to block SIGTERM (%d)\n", errno); + } + h->child = ctdb_fork(ctdb); if (h->child == (pid_t)-1) { close(h->fd[0]); close(h->fd[1]); talloc_free(h); + ret = sigprocmask(SIG_UNBLOCK, &sigset_term, NULL); + if (ret != 0) { + DBG_WARNING("Failed to unblock SIGTERM (%d)\n", errno); + } return NULL; } if (h->child == 0) { + struct sigaction sa = { + .sa_handler = SIG_DFL, + }; + + ret = sigaction(SIGTERM, &sa, NULL); + if (ret != 0) { + DBG_WARNING("Failed to reset signal handler (%d)\n", + errno); + } + + ret = sigprocmask(SIG_UNBLOCK, &sigset_term, NULL); + if (ret != 0) { + DBG_WARNING("Failed to unblock SIGTERM (%d)\n", errno); + } + /* Make stdout point to the pipe */ close(STDOUT_FILENO); dup2(h->fd[1], STDOUT_FILENO); @@ -248,6 +275,11 @@ ctdb_cluster_mutex(TALLOC_CTX *mem_ctx, /* Parent */ + ret = sigprocmask(SIG_UNBLOCK, &sigset_term, NULL); + if (ret != 0) { + DBG_WARNING("Failed to unblock SIGTERM (%d)\n", errno); + } + DEBUG(DEBUG_DEBUG, (__location__ " Created PIPE FD:%d\n", h->fd[0])); set_close_on_exec(h->fd[0]); diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index 3e85186..673c99c 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -239,6 +239,8 @@ struct ctdb_banning_state { struct timeval last_reported_time; }; +struct ctdb_recovery_lock_handle; + /* private state of recovery daemon */ @@ -260,7 +262,7 @@ struct ctdb_recoverd { uint32_t *force_rebalance_nodes; struct ctdb_node_capabilities *caps; bool frozen_on_inactive; - struct ctdb_cluster_mutex_handle *recovery_lock_handle; + struct ctdb_recovery_lock_handle *recovery_lock_handle; }; #define CONTROL_TIMEOUT() timeval_current_ofs(ctdb->tunable.recover_timeout, 0) @@ -881,18 +883,19 @@ static bool ctdb_recovery_have_lock(struct ctdb_recoverd *rec) return (rec->recovery_lock_handle != NULL); } -struct hold_reclock_state { +struct ctdb_recovery_lock_handle { bool done; bool locked; double latency; + struct ctdb_cluster_mutex_handle *h; }; static void take_reclock_handler(char status, double latency, void *private_data) { - struct hold_reclock_state *s = - (struct hold_reclock_state *) private_data; + struct ctdb_recovery_lock_handle *s = + (struct ctdb_recovery_lock_handle *) private_data; switch (status) { case '0': @@ -932,41 +935,68 @@ static bool ctdb_recovery_lock(struct ctdb_recoverd *rec) { struct ctdb_context *ctdb = rec->ctdb; struct ctdb_cluster_mutex_handle *h; - struct hold_reclock_state s = { - .done = false, - .locked = false, - .latency = 0, + struct ctdb_recovery_lock_handle *s; + + s = talloc_zero(rec, struct ctdb_recovery_lock_handle); + if (s == NULL) { + DBG_ERR("Memory allocation error\n"); + return false; }; - h = ctdb_cluster_mutex(rec, ctdb, ctdb->recovery_lock, 0, - take_reclock_handler, &s, - lost_reclock_handler, rec); + h = ctdb_cluster_mutex(s, + ctdb, + ctdb->recovery_lock, + 0, + take_reclock_handler, + s, + lost_reclock_handler, + rec); if (h == NULL) { + talloc_free(s); return false; } - while (!s.done) { + rec->recovery_lock_handle = s; + s->h = h; + + while (! s->done) { tevent_loop_once(ctdb->ev); } - if (! s.locked) { - talloc_free(h); + if (! s->locked) { + TALLOC_FREE(rec->recovery_lock_handle); return false; } - rec->recovery_lock_handle = h; - ctdb_ctrl_report_recd_lock_latency(ctdb, CONTROL_TIMEOUT(), - s.latency); + ctdb_ctrl_report_recd_lock_latency(ctdb, + CONTROL_TIMEOUT(), + s->latency); return true; } static void ctdb_recovery_unlock(struct ctdb_recoverd *rec) { - if (rec->recovery_lock_handle != NULL) { - DEBUG(DEBUG_NOTICE, ("Releasing recovery lock\n")); - TALLOC_FREE(rec->recovery_lock_handle); + if (rec->recovery_lock_handle == NULL) { + return; + } + + if (! rec->recovery_lock_handle->done) { + /* + * Taking of recovery lock still in progress. Free + * the cluster mutex handle to release it but leave + * the recovery lock handle in place to allow taking + * of the lock to fail. + */ + D_NOTICE("Cancelling recovery lock\n"); + TALLOC_FREE(rec->recovery_lock_handle->h); + rec->recovery_lock_handle->done = true; + rec->recovery_lock_handle->locked = false; + return; } + + D_NOTICE("Releasing recovery lock\n"); + TALLOC_FREE(rec->recovery_lock_handle); } static void ban_misbehaving_nodes(struct ctdb_recoverd *rec, bool *self_ban) @@ -1315,31 +1345,47 @@ static int do_recovery(struct ctdb_recoverd *rec, goto fail; } - if (ctdb->recovery_lock != NULL) { + if (ctdb->recovery_lock != NULL) { if (ctdb_recovery_have_lock(rec)) { - DEBUG(DEBUG_NOTICE, ("Already holding recovery lock\n")); + D_NOTICE("Already holding recovery lock\n"); } else { - DEBUG(DEBUG_NOTICE, ("Attempting to take recovery lock (%s)\n", - ctdb->recovery_lock)); - if (!ctdb_recovery_lock(rec)) { - if (ctdb->runstate == CTDB_RUNSTATE_FIRST_RECOVERY) { - /* If ctdb is trying first recovery, it's - * possible that current node does not know - * yet who the recmaster is. + bool ok; + + D_NOTICE("Attempting to take recovery lock (%s)\n", + ctdb->recovery_lock); + + ok = ctdb_recovery_lock(rec); + if (! ok) { + D_ERR("Unable to take recovery lock\n"); + + if (pnn != rec->recmaster) { + D_NOTICE("Recovery master changed to %u," + " aborting recovery\n", + rec->recmaster); + rec->need_recovery = false; + goto fail; + } + + if (ctdb->runstate == + CTDB_RUNSTATE_FIRST_RECOVERY) { + /* + * First recovery? Perhaps + * current node does not yet + * know who the recmaster is. */ - DEBUG(DEBUG_ERR, ("Unable to get recovery lock" - " - retrying recovery\n")); + D_ERR("Retrying recovery\n"); goto fail; } - DEBUG(DEBUG_ERR,("Unable to get recovery lock - aborting recovery " - "and ban ourself for %u seconds\n", - ctdb->tunable.recovery_ban_period)); - ctdb_ban_node(rec, pnn, ctdb->tunable.recovery_ban_period); + D_ERR("Abort recovery, " + "ban this node for %u seconds\n", + ctdb->tunable.recovery_ban_period); + ctdb_ban_node(rec, + pnn, + ctdb->tunable.recovery_ban_period); goto fail; } - DEBUG(DEBUG_NOTICE, - ("Recovery lock taken successfully by recovery daemon\n")); + D_NOTICE("Recovery lock taken successfully\n"); } } diff --git a/docs-xml/smbdotconf/printing/spoolssosversion.xml b/docs-xml/smbdotconf/printing/spoolssosversion.xml index 0ef4489..1b57b69 100644 --- a/docs-xml/smbdotconf/printing/spoolssosversion.xml +++ b/docs-xml/smbdotconf/printing/spoolssosversion.xml @@ -39,3 +39,42 @@ <value type="default">2195</value> <value type="example">7601</value> </samba:parameter> + +<samba:parameter name="spoolss_client: os_major" + context="G" + type="integer" + xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> +<description> + <para>Windows might require a new os version number. This option allows + to modify the build number. The complete default version number is: + 6.1.7007 (Windows 7 and Windows Server 2008 R2). + </para> +</description> +<value type="default">6</value> +</samba:parameter> + +<samba:parameter name="spoolss_client: os_minor" + context="G" + type="integer" + xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> +<description> + <para>Windows might require a new os version number. This option allows + to modify the build number. The complete default version number is: + 6.1.7007 (Windows 7 and Windows Server 2008 R2). + </para> +</description> +<value type="default">1</value> +</samba:parameter> + +<samba:parameter name="spoolss_client: os_build" + context="G" + type="integer" + xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> +<description> + <para>Windows might require a new os version number. This option allows + to modify the build number. The complete default version number is: + 6.1.7007 (Windows 7 and Windows Server 2008 R2). + </para> +</description> +<value type="default">7007</value> +</samba:parameter> diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index 7f6ed8e..36ca806 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -28,6 +28,7 @@ #include "rpc_client/cli_spoolss.h" #include "auth/gensec/gensec.h" #include "auth/credentials/credentials.h" +#include "rpc_client/init_spoolss.h" /********************************************************************** convencience wrapper around rpccli_spoolss_OpenPrinterEx @@ -49,14 +50,12 @@ WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli, ZERO_STRUCT(devmode_ctr); - level1.size = 28; - level1.client = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name()); - W_ERROR_HAVE_NO_MEMORY(level1.client); - level1.user = cli_credentials_get_username(creds); - level1.build = 1381; - level1.major = 2; - level1.minor = 0; - level1.processor = 0; + werror = spoolss_init_spoolss_UserLevel1(mem_ctx, + cli_credentials_get_username(creds), + &level1); + if (!W_ERROR_IS_OK(werror)) { + return werror; + } userlevel_ctr.level = 1; userlevel_ctr.user_info.level1 = &level1; @@ -229,14 +228,12 @@ WERROR rpccli_spoolss_addprinterex(struct rpc_pipe_client *cli, ZERO_STRUCT(devmode_ctr); ZERO_STRUCT(secdesc_ctr); - level1.size = 28; - level1.build = 1381; - level1.major = 2; - level1.minor = 0; - level1.processor = 0; - level1.client = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name()); - W_ERROR_HAVE_NO_MEMORY(level1.client); - level1.user = cli_credentials_get_username(creds); + result = spoolss_init_spoolss_UserLevel1(mem_ctx, + cli_credentials_get_username(creds), + &level1); + if (!W_ERROR_IS_OK(result)) { + return result; + } userlevel_ctr.level = 1; userlevel_ctr.user_info.level1 = &level1; diff --git a/source3/rpc_client/init_spoolss.c b/source3/rpc_client/init_spoolss.c index 9a4dab6..c341b82 100644 --- a/source3/rpc_client/init_spoolss.c +++ b/source3/rpc_client/init_spoolss.c @@ -446,3 +446,34 @@ const char *spoolss_get_short_filesys_environment(const char *environment) return NULL; } } + +/* Windows 7 and Windows Server 2008 R2 */ +#define GLOBAL_SPOOLSS_CLIENT_OS_MAJOR_DEFAULT 6 +#define GLOBAL_SPOOLSS_CLIENT_OS_MINOR_DEFAULT 1 +#define GLOBAL_SPOOLSS_CLIENT_OS_BUILD_DEFAULT 7007 + +WERROR spoolss_init_spoolss_UserLevel1(TALLOC_CTX *mem_ctx, + const char *username, + struct spoolss_UserLevel1 *r) +{ + ZERO_STRUCTP(r); + + r->size = 28; + r->client = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name()); + W_ERROR_HAVE_NO_MEMORY(r->client); + r->user = talloc_strdup(mem_ctx, username); + W_ERROR_HAVE_NO_MEMORY(r->user); + r->processor = 0; + + r->major = lp_parm_int(GLOBAL_SECTION_SNUM, + "spoolss_client", "os_major", + GLOBAL_SPOOLSS_CLIENT_OS_MAJOR_DEFAULT); + r->minor = lp_parm_int(GLOBAL_SECTION_SNUM, + "spoolss_client", "os_minor", + GLOBAL_SPOOLSS_CLIENT_OS_MINOR_DEFAULT); + r->build = lp_parm_int(GLOBAL_SECTION_SNUM, + "spoolss_client", "os_build", + GLOBAL_SPOOLSS_CLIENT_OS_BUILD_DEFAULT); + + return WERR_OK; +} diff --git a/source3/rpc_client/init_spoolss.h b/source3/rpc_client/init_spoolss.h index 376eaef..062e37b 100644 --- a/source3/rpc_client/init_spoolss.h +++ b/source3/rpc_client/init_spoolss.h @@ -48,5 +48,8 @@ WERROR spoolss_create_default_devmode(TALLOC_CTX *mem_ctx, WERROR spoolss_create_default_secdesc(TALLOC_CTX *mem_ctx, struct spoolss_security_descriptor **secdesc); const char *spoolss_get_short_filesys_environment(const char *environment); +WERROR spoolss_init_spoolss_UserLevel1(TALLOC_CTX *mem_ctx, + const char *username, + struct spoolss_UserLevel1 *r); #endif /* _RPC_CLIENT_INIT_SPOOLSS_H_ */ diff --git a/source3/rpcclient/cmd_iremotewinspool.c b/source3/rpcclient/cmd_iremotewinspool.c index c6148ec..7f0cecf 100644 --- a/source3/rpcclient/cmd_iremotewinspool.c +++ b/source3/rpcclient/cmd_iremotewinspool.c @@ -24,6 +24,7 @@ #include "libsmb/libsmb.h" #include "auth/gensec/gensec.h" #include "auth/credentials/credentials.h" +#include "rpc_client/init_spoolss.h" /**************************************************************************** ****************************************************************************/ @@ -33,6 +34,7 @@ static WERROR cmd_iremotewinspool_async_open_printer(struct rpc_pipe_client *cli int argc, const char **argv) { NTSTATUS status; + WERROR werror; struct policy_handle hnd; struct spoolss_DevmodeContainer devmode_ctr; struct spoolss_UserLevelCtr client_info_ctr; @@ -59,13 +61,13 @@ static WERROR cmd_iremotewinspool_async_open_printer(struct rpc_pipe_client *cli ZERO_STRUCT(devmode_ctr); - level1.size = 40; - level1.client = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name()); - W_ERROR_HAVE_NO_MEMORY(level1.client); - level1.user = cli_credentials_get_username(creds); - level1.build = 1381; - level1.major = 3; - level1.minor = 0; + werror = spoolss_init_spoolss_UserLevel1(mem_ctx, + cli_credentials_get_username(creds), + &level1); + if (!W_ERROR_IS_OK(werror)) { + return werror; + } + level1.processor = PROCESSOR_ARCHITECTURE_AMD64; client_info_ctr.level = 1; -- Samba Shared Repository