registry: create and use shared libcli/registry/util_reg.h header.
[ab/samba.git/.git] / source3 / rpc_server / spoolss / srv_spoolss_nt.c
index a303a7a321bc450c76bf0ba86e605cfba6218cb4..56a27134421c96061049ba3a6735ea0859322a4e 100644 (file)
@@ -33,6 +33,7 @@
 #include "../librpc/gen_ndr/srv_spoolss.h"
 #include "../librpc/gen_ndr/ndr_spoolss_c.h"
 #include "rpc_client/init_spoolss.h"
+#include "rpc_client/cli_pipe.h"
 #include "librpc/gen_ndr/messaging.h"
 #include "../libcli/security/security.h"
 #include "librpc/gen_ndr/ndr_security.h"
@@ -42,6 +43,9 @@
 #include "secrets.h"
 #include "../librpc/gen_ndr/netlogon.h"
 #include "rpc_misc.h"
+#include "printing/notify.h"
+#include "serverid.h"
+#include "../libcli/registry/util_reg.h"
 
 /* macros stolen from s4 spoolss server */
 #define SPOOLSS_BUFFER_UNION(fn,info,level) \
@@ -1706,7 +1710,7 @@ WERROR _spoolss_OpenPrinterEx(struct pipes_struct *p,
                return WERR_INVALID_PARAM;
        }
 
-       if (r->in.level < 0 || r->in.level > 3) {
+       if (r->in.level > 3) {
                return WERR_INVALID_PARAM;
        }
        if ((r->in.level == 1 && !r->in.userlevel.level1) ||
@@ -2489,7 +2493,7 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe,
        struct sockaddr_storage rm_addr;
        char addr[INET6_ADDRSTRLEN];
 
-       if ( is_zero_addr((struct sockaddr *)client_ss) ) {
+       if ( is_zero_addr(client_ss) ) {
                DEBUG(2,("spoolss_connect_to_client: resolving %s\n",
                        remote_machine));
                if ( !resolve_name( remote_machine, &rm_addr, 0x20, false) ) {
@@ -2733,6 +2737,12 @@ WERROR _spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct pipes_struct *p,
        DEBUG(10,("_spoolss_RemoteFindFirstPrinterChangeNotifyEx: "
                "client_address is %s\n", p->client_id->addr));
 
+       if (!lp_print_notify_backchannel(snum)) {
+               DEBUG(10, ("_spoolss_RemoteFindFirstPrinterChangeNotifyEx: "
+                       "backchannel disabled\n"));
+               return WERR_SERVER_UNAVAILABLE;
+       }
+
        if (!interpret_string_addr(&client_ss, p->client_id->addr,
                                   AI_NUMERICHOST)) {
                return WERR_SERVER_UNAVAILABLE;
@@ -3644,7 +3654,9 @@ static WERROR printer_notify_info(struct pipes_struct *p,
        if ( !option )
                return WERR_BADFID;
 
-       get_printer_snum(p, hnd, &snum, NULL);
+       if (!get_printer_snum(p, hnd, &snum, NULL)) {
+               return WERR_BADFID;
+       }
 
        /* Maybe we should use the SYSTEM session_info here... */
        result = winreg_get_printer(mem_ctx,
@@ -3741,7 +3753,7 @@ WERROR _spoolss_RouterRefreshPrinterChangeNotify(struct pipes_struct *p,
         *      We are now using the change value, and
         *      I should check for PRINTER_NOTIFY_OPTIONS_REFRESH but as
         *      I don't have a global notification system, I'm sending back all the
-        *      informations even when _NOTHING_ has changed.
+        *      information even when _NOTHING_ has changed.
         */
 
        /* We need to keep track of the change value to send back in
@@ -8001,8 +8013,8 @@ WERROR _spoolss_AddPrinterDriverEx(struct pipes_struct *p,
                goto done;
 
        DEBUG(5,("Moving driver to final destination\n"));
-       if( !W_ERROR_IS_OK(err = move_driver_to_download_area(p, r->in.info_ctr,
-                                                             &err)) ) {
+       err = move_driver_to_download_area(p, r->in.info_ctr);
+       if (!W_ERROR_IS_OK(err)) {
                goto done;
        }