The branch, v3-6-test has been updated
       via  54afca7 s3-waf: fix spoolssd compile.
       via  52882e7 s3-rpc_server: Fixed rpc_pipe_open_internal documentation.
       via  cfe3e48 s3-rpc_server: Only allow embedded, daemon and external 
server type.
       via  1c5609b s3-spoolssd: Start the spoolss service correctly.
       via  ba5938e s3-spoolssd: Register spoolssd endpoints.
       via  3fe8a94 s3-epmap: Make rpc_ep_setup_register an internal function.
       via  84dc7f8 s3-spoolssd: Fixed logfile creation.
       via  86c2e7f s3-spoolssd: Added missing include.
       via  56c5813 s3-spoolssd: Pass down event and messanging context.
       via  3df906d s3-spoolssd: Fixed reopening of logs.
       via  8bb609e s3:spoolssd Start spoolss from smbd
       via  953f9b9 s3:spoolssd Initialize the spoolss rpc interfaces
       via  ef2e27c s3:spoolssd Add spoolss own signal handlers
       via  e63d8bf s3:spoolssd handle smb.conf reloads directly
       via  e9dd62b s3:spoolssd Create our own log file
       via  be4e2cf s3:spoolssd Add skeleton for spoolss daemon
       via  7dbe832 s3:printing Make print_queue_receive public
      from  bbf0762 s3: Use cli_ntcreate to when listing snapshots

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 54afca72d33d3ab291f41d101c3ed5ff88abefb7
Author: Günther Deschner <g...@samba.org>
Date:   Mon Mar 28 16:42:21 2011 +0200

    s3-waf: fix spoolssd compile.
    
    Guenther
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit 6a27928cedf31e7e76572775a7f6d4a9e2f01c95)

commit 52882e79724e1bca0e847666c7a216e475627401
Author: Andreas Schneider <a...@samba.org>
Date:   Tue Mar 29 12:51:45 2011 +0200

    s3-rpc_server: Fixed rpc_pipe_open_internal documentation.
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit 2cb797456a3fa016dff31b92bf846b316d47b8a2)

commit cfe3e4886a168df63a78954ed5a80cae7819fca3
Author: Andreas Schneider <a...@samba.org>
Date:   Tue Mar 29 10:58:05 2011 +0200

    s3-rpc_server: Only allow embedded, daemon and external server type.
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit 8dc58057382806d0ac5702321e5b0d4a5186bf6b)

commit 1c5609b31a709a22edc60742cf60ca5c93fcf681
Author: Andreas Schneider <a...@samba.org>
Date:   Tue Mar 29 10:52:32 2011 +0200

    s3-spoolssd: Start the spoolss service correctly.
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit 991fa3a5fecc05a01b2d3696fe23cba109de10c0)

commit ba5938e6588ff7eaa4d8ba78caa860a1cfdab28d
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Mar 28 14:18:23 2011 +0200

    s3-spoolssd: Register spoolssd endpoints.
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit 28b204601556105ad57d7ac69210eb75f248f764)

commit 3fe8a9468299f1bf57e8ed96ffb3dfd7f26e0c0b
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Mar 28 14:18:00 2011 +0200

    s3-epmap: Make rpc_ep_setup_register an internal function.
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit 8c635b669c557cfe6fb5de2bd90302ada54b0fb9)

commit 84dc7f83d362da5b6393bbd9a579d289b0fc4745
Author: Andreas Schneider <a...@samba.org>
Date:   Mon Mar 28 14:30:29 2011 +0200

    s3-spoolssd: Fixed logfile creation.
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit 80fe8fa8d0d2ec787e4d70a3553c1d4e066f4163)

commit 86c2e7f9dcd53050db56624af88540910b402627
Author: Andreas Schneider <a...@samba.org>
Date:   Thu Mar 24 10:22:57 2011 +0100

    s3-spoolssd: Added missing include.
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit a956c57cf939d0a4cdd5793b129e1fa87e63fffd)

commit 56c5813241e5815af782ac006b72aeb5cefd911e
Author: Andreas Schneider <a...@samba.org>
Date:   Thu Jan 20 18:59:40 2011 +0100

    s3-spoolssd: Pass down event and messanging context.
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit c1b7c0c2b78417aac4365a03e858397324728605)

commit 3df906dc8f2c64336121bf4e9e9670dcbc7929cf
Author: Andreas Schneider <a...@samba.org>
Date:   Wed Aug 25 10:15:47 2010 +0200

    s3-spoolssd: Fixed reopening of logs.
    
    Everytime the log was reopened a .spoolssd has been appended which
    resulted in long file names.
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit 851f95b121f2fc16ef5cc532b8ad818f5c32e69f)

commit 8bb609eedd4698353aa8d394fec3677d2202244d
Author: Simo Sorce <sso...@redhat.com>
Date:   Thu May 20 08:33:14 2010 -0400

    s3:spoolssd Start spoolss from smbd
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit fe0e079bc12ebe2e9204ca492337dc754e13832b)

commit 953f9b93730410027c0cdbf0e09edb658e2c93a7
Author: Simo Sorce <i...@samba.org>
Date:   Tue Jun 15 18:39:27 2010 -0400

    s3:spoolssd Initialize the spoolss rpc interfaces
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit 043942720c8bbf8f00476da097a266f162f2edd9)

commit ef2e27cbb10ab5aa23fd86d4e228c6b4d7fafe3c
Author: Simo Sorce <i...@samba.org>
Date:   Wed Jun 16 13:03:32 2010 -0400

    s3:spoolssd Add spoolss own signal handlers
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit 0c130105f5b70803daf784bd9a3c86ed34295338)

commit e63d8bf32489a1fddbaccbc40f392dc3c2a9e083
Author: Simo Sorce <i...@samba.org>
Date:   Wed Jun 16 15:36:06 2010 -0400

    s3:spoolssd handle smb.conf reloads directly
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit 0b7b8414ddb94ea05c633ec655493db4ffcad3cd)

commit e9dd62bc6f8b85ddfcab5e22d2655d7e2d1f6067
Author: Simo Sorce <i...@samba.org>
Date:   Tue Jun 15 18:38:44 2010 -0400

    s3:spoolssd Create our own log file
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit 2d333ae8bc42a5aab7df6985b1432e3a480e74dc)

commit be4e2cf95c786a36d4d90ea1892f73de872db328
Author: Simo Sorce <sso...@redhat.com>
Date:   Thu May 20 08:48:18 2010 -0400

    s3:spoolssd Add skeleton for spoolss daemon
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit 99941eb92b2fa5b6c80649abc36b159802241088)

commit 7dbe832bb074d86035d25ed12180e59394640853
Author: Simo Sorce <sso...@redhat.com>
Date:   Thu May 20 08:49:50 2010 -0400

    s3:printing Make print_queue_receive public
    
    Signed-off-by: Günther Deschner <g...@samba.org>
    (cherry picked from commit 1d33474dad5a101666044f58a00f33bd6a134080)

-----------------------------------------------------------------------

Summary of changes:
 source3/Makefile.in               |    2 +-
 source3/include/printing.h        |    5 +
 source3/printing/printing.c       |    2 +-
 source3/printing/spoolssd.c       |  242 +++++++++++++++++++++++++++++++++++++
 source3/rpc_server/rpc_ep_setup.c |   32 +++--
 source3/rpc_server/rpc_ep_setup.h |   24 ++++
 source3/rpc_server/rpc_ncacn_np.c |   26 +++-
 source3/smbd/server.c             |   17 +++
 source3/wscript_build             |    2 +-
 9 files changed, 331 insertions(+), 21 deletions(-)
 create mode 100644 source3/printing/spoolssd.c


Changeset truncated at 500 lines:

diff --git a/source3/Makefile.in b/source3/Makefile.in
index 05f1ccd..34f5f82 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -886,7 +886,7 @@ SMBD_OBJ_SRV = smbd/server_reload.o \
                smbd/posix_acls.o lib/sysacls.o \
               smbd/process.o smbd/service.o smbd/error.o \
               rpc_server/epmd.o \
-              printing/printspoolss.o \
+              printing/printspoolss.o printing/spoolssd.o \
               lib/sysquotas.o lib/sysquotas_linux.o \
               lib/sysquotas_xfs.o lib/sysquotas_4A.o \
               lib/sysquotas_nfs.o \
diff --git a/source3/include/printing.h b/source3/include/printing.h
index 3752b9c..084c699 100644
--- a/source3/include/printing.h
+++ b/source3/include/printing.h
@@ -251,4 +251,9 @@ void release_print_db( struct tdb_print_db *pdb);
 void close_all_print_db(void);
 TDB_DATA get_printer_notify_pid_list(TDB_CONTEXT *tdb, const char 
*printer_name, bool cleanlist);
 
+void print_queue_receive(struct messaging_context *msg,
+                               void *private_data,
+                               uint32_t msg_type,
+                               struct server_id server_id,
+                               DATA_BLOB *data);
 #endif /* PRINTING_H_ */
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index b1aff3e..177048d 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -1560,7 +1560,7 @@ static void print_queue_update_with_lock( struct 
tevent_context *ev,
 /****************************************************************************
 this is the receive function of the background lpq updater
 ****************************************************************************/
-static void print_queue_receive(struct messaging_context *msg,
+void print_queue_receive(struct messaging_context *msg,
                                void *private_data,
                                uint32_t msg_type,
                                struct server_id server_id,
diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c
new file mode 100644
index 0000000..94694fc
--- /dev/null
+++ b/source3/printing/spoolssd.c
@@ -0,0 +1,242 @@
+/*
+   Unix SMB/Netbios implementation.
+   SPOOLSS Daemon
+   Copyright (C) Simo Sorce 2010
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "includes.h"
+#include "serverid.h"
+
+#include "librpc/gen_ndr/messaging.h"
+#include "include/printing.h"
+#include "printing/nt_printing_migrate.h"
+#include "librpc/gen_ndr/srv_winreg.h"
+#include "librpc/gen_ndr/srv_spoolss.h"
+#include "rpc_server/rpc_server.h"
+#include "rpc_server/rpc_ep_setup.h"
+
+#define SPOOLSS_PIPE_NAME "spoolss"
+#define DAEMON_NAME "spoolssd"
+
+void start_spoolssd(struct tevent_context *ev_ctx,
+                   struct messaging_context *msg_ctx);
+
+static void spoolss_reopen_logs(void)
+{
+       char *lfile = lp_logfile();
+       int rc;
+
+       if (lfile == NULL || lfile[0] == '\0') {
+               rc = asprintf(&lfile, "%s/log.%s", get_dyn_LOGFILEBASE(), 
DAEMON_NAME);
+               if (rc > 0) {
+                       lp_set_logfile(lfile);
+                       SAFE_FREE(lfile);
+               }
+       } else {
+               if (strstr(lfile, DAEMON_NAME) == NULL) {
+                       rc = asprintf(&lfile, "%s.%s", lp_logfile(), 
DAEMON_NAME);
+                       if (rc > 0) {
+                               lp_set_logfile(lfile);
+                               SAFE_FREE(lfile);
+                       }
+               }
+       }
+
+       reopen_logs();
+}
+
+static void smb_conf_updated(struct messaging_context *msg,
+                            void *private_data,
+                            uint32_t msg_type,
+                            struct server_id server_id,
+                            DATA_BLOB *data)
+{
+       struct tevent_context *ev_ctx = talloc_get_type_abort(private_data,
+                                                            struct 
tevent_context);
+
+       DEBUG(10, ("Got message saying smb.conf was updated. Reloading.\n"));
+       change_to_root_user();
+       reload_printers(ev_ctx, msg);
+       spoolss_reopen_logs();
+}
+
+static void spoolss_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");
+}
+
+static void spoolss_setup_sig_term_handler(struct tevent_context *ev_ctx)
+{
+       struct tevent_signal *se;
+
+       se = tevent_add_signal(ev_ctx,
+                              ev_ctx,
+                              SIGTERM, 0,
+                              spoolss_sig_term_handler,
+                              NULL);
+       if (!se) {
+               exit_server("failed to setup SIGTERM handler");
+       }
+}
+
+static void spoolss_sig_hup_handler(struct tevent_context *ev,
+                                   struct tevent_signal *se,
+                                   int signum,
+                                   int count,
+                                   void *siginfo,
+                                   void *private_data)
+{
+       struct messaging_context *msg_ctx = talloc_get_type_abort(private_data,
+                                                                 struct 
messaging_context);
+
+       change_to_root_user();
+       DEBUG(1,("Reloading printers after SIGHUP\n"));
+       reload_printers(ev, msg_ctx);
+       spoolss_reopen_logs();
+}
+
+static void spoolss_setup_sig_hup_handler(struct tevent_context *ev_ctx,
+                                         struct messaging_context *msg_ctx)
+{
+       struct tevent_signal *se;
+
+       se = tevent_add_signal(ev_ctx,
+                              ev_ctx,
+                              SIGHUP, 0,
+                              spoolss_sig_hup_handler,
+                              msg_ctx);
+       if (!se) {
+               exit_server("failed to setup SIGHUP handler");
+       }
+}
+
+static bool spoolss_init_cb(void *ptr)
+{
+       struct messaging_context *msg_ctx = talloc_get_type_abort(
+               ptr, struct messaging_context);
+
+       return nt_printing_tdb_migrate(msg_ctx);
+}
+
+static bool spoolss_shutdown_cb(void *ptr)
+{
+       srv_spoolss_cleanup();
+
+       return true;
+}
+
+void start_spoolssd(struct tevent_context *ev_ctx,
+                   struct messaging_context *msg_ctx)
+{
+       struct rpc_srv_callbacks spoolss_cb;
+       pid_t pid;
+       NTSTATUS status;
+       int ret;
+
+       DEBUG(1, ("Forking SPOOLSS Daemon\n"));
+
+       pid = sys_fork();
+
+       if (pid == -1) {
+               DEBUG(0, ("Failed to fork SPOOLSS [%s], aborting ...\n",
+                          strerror(errno)));
+               exit(1);
+       }
+
+       if (pid) {
+               /* parent */
+               return;
+       }
+
+       /* child */
+       close_low_fds(false);
+
+       status = reinit_after_fork(msg_ctx,
+                                  ev_ctx,
+                                  procid_self(), true);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0,("reinit_after_fork() failed\n"));
+               smb_panic("reinit_after_fork() failed");
+       }
+
+       spoolss_reopen_logs();
+
+       spoolss_setup_sig_term_handler(ev_ctx);
+       spoolss_setup_sig_hup_handler(ev_ctx, msg_ctx);
+
+       if (!serverid_register(procid_self(),
+                               FLAG_MSG_GENERAL|FLAG_MSG_SMBD
+                               |FLAG_MSG_PRINT_GENERAL)) {
+               exit(1);
+       }
+
+       if (!locking_init()) {
+               exit(1);
+       }
+
+       messaging_register(msg_ctx, NULL,
+                          MSG_PRINTER_UPDATE, print_queue_receive);
+       messaging_register(msg_ctx, ev_ctx,
+                          MSG_SMB_CONF_UPDATED, smb_conf_updated);
+
+       /*
+        * Initialize spoolss with an init function to convert printers first.
+        * static_init_rpc will try to initialize the spoolss server too but you
+        * can't register it twice.
+        */
+       spoolss_cb.init = spoolss_init_cb;
+       spoolss_cb.shutdown = spoolss_shutdown_cb;
+       spoolss_cb.private_data = msg_ctx;
+
+       status = rpc_winreg_init(NULL);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0, ("Failed to register winreg rpc inteface! (%s)\n",
+                         nt_errstr(status)));
+               exit(1);
+       }
+
+       status = rpc_spoolss_init(&spoolss_cb);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0, ("Failed to register spoolss rpc inteface! (%s)\n",
+                         nt_errstr(status)));
+               exit(1);
+       }
+
+       if (!setup_named_pipe_socket(SPOOLSS_PIPE_NAME, ev_ctx)) {
+               exit(1);
+       }
+
+       status = rpc_ep_setup_register(ev_ctx, msg_ctx, &ndr_table_spoolss, 
NULL, 0);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0, ("Failed to register spoolss endpoint! (%s)\n",
+                         nt_errstr(status)));
+               exit(1);
+       }
+
+       DEBUG(1, ("SPOOLSS Daemon Started (%d)\n", getpid()));
+
+       /* loop forever */
+       ret = tevent_loop_wait(ev_ctx);
+
+       /* should not be reached */
+       DEBUG(0,("background_queue: tevent_loop_wait() exited with %d - %s\n",
+                ret, (ret == 0) ? "out of events" : strerror(errno)));
+       exit(1);
+}
diff --git a/source3/rpc_server/rpc_ep_setup.c 
b/source3/rpc_server/rpc_ep_setup.c
index 9bed63d..d517bb8 100644
--- a/source3/rpc_server/rpc_ep_setup.c
+++ b/source3/rpc_server/rpc_ep_setup.c
@@ -149,11 +149,11 @@ struct rpc_ep_regsiter_state {
        uint32_t wait_time;
 };
 
-static NTSTATUS rpc_ep_setup_register(struct tevent_context *ev_ctx,
-                                     struct messaging_context *msg_ctx,
-                                     const struct ndr_interface_table *iface,
-                                     const char *ncalrpc,
-                                     uint16_t port)
+NTSTATUS rpc_ep_setup_register(struct tevent_context *ev_ctx,
+                              struct messaging_context *msg_ctx,
+                              const struct ndr_interface_table *iface,
+                              const char *ncalrpc,
+                              uint16_t port)
 {
        struct rpc_ep_regsiter_state *state;
        struct tevent_req *req;
@@ -1103,14 +1103,24 @@ bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
                return false;
        }
 
-       spoolss_cb.init         = spoolss_init_cb;
-       spoolss_cb.shutdown     = spoolss_shutdown_cb;
-       spoolss_cb.private_data = ep_ctx;
-       if (!NT_STATUS_IS_OK(rpc_spoolss_init(&spoolss_cb))) {
-               return false;
+       rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
+                                          "rpc_server",
+                                          "spoolss",
+                                          "embedded");
+       if (StrCaseCmp(rpcsrv_type, "embedded") == 0) {
+               spoolss_cb.init         = spoolss_init_cb;
+               spoolss_cb.shutdown     = spoolss_shutdown_cb;
+               spoolss_cb.private_data = ep_ctx;
+               if (!NT_STATUS_IS_OK(rpc_spoolss_init(&spoolss_cb))) {
+                       return false;
+               }
+       } else if (StrCaseCmp(rpcsrv_type, "daemon") == 0 ||
+                  StrCaseCmp(rpcsrv_type, "external") == 0) {
+               if (!NT_STATUS_IS_OK(rpc_spoolss_init(NULL))) {
+                       return false;
+               }
        }
 
-
        svcctl_cb.init         = svcctl_init_cb;
        svcctl_cb.shutdown     = svcctl_shutdown_cb;
        svcctl_cb.private_data = ep_ctx;
diff --git a/source3/rpc_server/rpc_ep_setup.h 
b/source3/rpc_server/rpc_ep_setup.h
index 272910a..b96de36 100644
--- a/source3/rpc_server/rpc_ep_setup.h
+++ b/source3/rpc_server/rpc_ep_setup.h
@@ -22,6 +22,30 @@
 #ifndef _SMBD_RPC_CALLBACKS_H
 #define _SMBD_RPC_CALLBACKS_H
 
+/**
+ * @brief Register an endpoint at the endpoint mapper.
+ *
+ * This just sets up a register and monitor loop to try to regsiter the
+ * endpoint at the endpoint mapper.
+ *
+ * @param[in] ev_ctx    The event context to setup the loop.
+ *
+ * @param[in] msg_ctx   The messaging context to use for the connnection.
+ *
+ * @param[in] iface     The interface table to register.
+ *
+ * @param[in] ncalrpc   The name of the ncalrpc pipe or NULL.
+ *
+ * @param[in] port      The tcpip port or 0.
+ *
+ * @return              NT_STATUS_OK on success or a corresponding error code.
+ */
+NTSTATUS rpc_ep_setup_register(struct tevent_context *ev_ctx,
+                              struct messaging_context *msg_ctx,
+                              const struct ndr_interface_table *iface,
+                              const char *ncalrpc,
+                              uint16_t port);
+
 bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
                     struct messaging_context *msg_ctx);
 
diff --git a/source3/rpc_server/rpc_ncacn_np.c 
b/source3/rpc_server/rpc_ncacn_np.c
index 41985e4..df9799b 100644
--- a/source3/rpc_server/rpc_ncacn_np.c
+++ b/source3/rpc_server/rpc_ncacn_np.c
@@ -510,18 +510,24 @@ NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
 }
 
 /**
- * @brief Create a new RPC client context which uses a local dispatch function.
+ * @internal
+ *
+ * @brief Create a new RPC client context which uses a local transport.
+ *
+ * This creates a local transport. It is a shortcut to directly call the server
+ * functions and avoid marschalling.
  *
  * @param[in]  mem_ctx  The memory context to use.
  *
  * @param[in]  abstract_syntax Normally the syntax_id of the autogenerated
  *                             ndr_table_<name>.
  *
- * @param[in]  dispatch The corresponding autogenerated dispatch function
- *                      rpc_<name>_dispatch.
- *
  * @param[in]  serversupplied_info The server supplied authentication function.
  *
+ * @param[in]  client_id The client address information.
+ *
+ * @param[in]  msg_ctx  The messaging context to use.
+ *
  * @param[out] presult  A pointer to store the connected rpc client pipe.
  *
  * @return              NT_STATUS_OK on success, a corresponding NT status if 
an
@@ -533,8 +539,8 @@ NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
  *
  *   status = rpc_pipe_open_internal(tmp_ctx,
  *                                   &ndr_table_winreg.syntax_id,
- *                                   rpc_winreg_dispatch,
  *                                   p->session_info,
+ *                                   client_id,
  *                                   &winreg_pipe);
  * @endcode
  */
@@ -875,7 +881,8 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
                if (!NT_STATUS_IS_OK(status)) {
                        goto done;
                }
-       } else {
+       } else if (StrCaseCmp(server_type, "daemon") == 0 ||
+                  StrCaseCmp(server_type, "external") == 0) {
                /* It would be nice to just use rpc_pipe_open_ncalrpc() but
                 * for now we need to use the special proxy setup to connect
                 * to spoolssd. */
@@ -887,7 +894,12 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
                if (!NT_STATUS_IS_OK(status)) {
                        goto done;
                }
-       }
+       } else {
+               status = NT_STATUS_NOT_IMPLEMENTED;
+               DEBUG(0, ("Wrong servertype specified in config file: %s",
+                         nt_errstr(status)));
+               goto done;
+        }
 
        status = NT_STATUS_OK;
 done:
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 5d2abc0..e8c1169 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -40,6 +40,9 @@
 extern void start_epmd(struct tevent_context *ev_ctx,
                       struct messaging_context *msg_ctx);
 
+extern void start_spoolssd(struct event_context *ev_ctx,
+                          struct messaging_context *msg_ctx);
+
 #ifdef WITH_DFS
 extern int dcelogin_atmost_once;
 #endif /* WITH_DFS */
@@ -1242,6 +1245,20 @@ extern void build_options(bool screen);
                                       smbd_messaging_context());
        }
 
+       if (is_daemon && !_lp_disable_spoolss()) {
+               const char *rpcsrv_type;
+
+               /* start spoolss daemon */
+               /* start as a separate daemon only if enabled */
+               rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
+                                                  "rpc_server", "spoolss",
+                                                  "embedded");
+               if (StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+                       start_spoolssd(smbd_event_context(),
+                                      smbd_messaging_context());
+               }
+       }
+
        if (!is_daemon) {
                /* inetd mode */
                TALLOC_FREE(frame);
diff --git a/source3/wscript_build b/source3/wscript_build
index b5aa2b7..781074c 100644
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -356,7 +356,7 @@ SMBD_SRC_SRV = '''smbd/server_reload.c smbd/files.c 
smbd/connection.c
                smbd/vfs.c smbd/perfcount.c smbd/statcache.c smbd/seal.c
                smbd/posix_acls.c lib/sysacls.c
                smbd/process.c smbd/service.c smbd/error.c
-               printing/printspoolss.c
+               printing/printspoolss.c printing/spoolssd.c
                lib/sysquotas.c lib/sysquotas_linux.c
                lib/sysquotas_xfs.c lib/sysquotas_4A.c
                lib/sysquotas_nfs.c


-- 
Samba Shared Repository

Reply via email to