s3: Replace calls to check_access by allow_access
[nivanova/samba.git] / source3 / rpc_server / srv_spoolss_nt.c
index 64e13e6d65d7cef5496084320d62a49968943038..287c720c59edf9bf26f16a1ba2cb2983748948cf 100644 (file)
@@ -341,7 +341,7 @@ static WERROR delete_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token,
 
        /* go ahead and re-read the services immediately */
        become_root();
-       reload_services(msg_ctx, false);
+       reload_services(msg_ctx, smbd_server_fd(), false);
        unbecome_root();
 
        if ( lp_servicenumber( sharename )  > 0 )
@@ -1642,7 +1642,8 @@ WERROR _spoolss_OpenPrinterEx(struct pipes_struct *p,
 
                /* check smb.conf parameters and the the sec_desc */
 
-               if ( !check_access(get_client_fd(), lp_hostsallow(snum), lp_hostsdeny(snum)) ) {
+               if (!allow_access(lp_hostsdeny(snum), lp_hostsallow(snum),
+                                 p->client_id->name, p->client_id->addr)) {
                        DEBUG(3, ("access DENIED (hosts allow/deny) for printer open\n"));
                        ZERO_STRUCTP(r->out.handle);
                        return WERR_ACCESS_DENIED;
@@ -2450,9 +2451,9 @@ WERROR _spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct pipes_struct *p,
                return WERR_BADFID;
 
        DEBUG(10,("_spoolss_RemoteFindFirstPrinterChangeNotifyEx: "
-               "client_address is %s\n", p->client_address));
+               "client_address is %s\n", p->client_id->addr));
 
-       if (!interpret_string_addr(&client_ss, p->client_address,
+       if (!interpret_string_addr(&client_ss, p->client_id->addr,
                                   AI_NUMERICHOST)) {
                return WERR_SERVER_UNAVAILABLE;
        }
@@ -3096,7 +3097,8 @@ static void construct_info_data(struct spoolss_Notify *info_data,
  *
  ********************************************************************/
 
-static bool construct_notify_printer_info(Printer_entry *print_hnd,
+static bool construct_notify_printer_info(struct messaging_context *msg_ctx,
+                                         Printer_entry *print_hnd,
                                          struct spoolss_NotifyInfo *info,
                                          struct spoolss_PrinterInfo2 *pinfo2,
                                          int snum,
@@ -3142,9 +3144,8 @@ static bool construct_notify_printer_info(Printer_entry *print_hnd,
                           notify_info_data_table[j].name, snum,
                           pinfo2->printername));
 
-               notify_info_data_table[j].fn(server_messaging_context(),
-                                            snum, current_data, queue,
-                                            pinfo2, mem_ctx);
+               notify_info_data_table[j].fn(msg_ctx, snum, current_data,
+                                            queue, pinfo2, mem_ctx);
 
                info->count++;
        }
@@ -3158,7 +3159,8 @@ static bool construct_notify_printer_info(Printer_entry *print_hnd,
  *
  ********************************************************************/
 
-static bool construct_notify_jobs_info(print_queue_struct *queue,
+static bool construct_notify_jobs_info(struct messaging_context *msg_ctx,
+                                      print_queue_struct *queue,
                                       struct spoolss_NotifyInfo *info,
                                       struct spoolss_PrinterInfo2 *pinfo2,
                                       int snum,
@@ -3196,9 +3198,8 @@ static bool construct_notify_jobs_info(print_queue_struct *queue,
                current_data=&(info->notifies[info->count]);
 
                construct_info_data(current_data, type, field, id);
-               notify_info_data_table[j].fn(server_messaging_context(),
-                                            snum, current_data, queue,
-                                            pinfo2, mem_ctx);
+               notify_info_data_table[j].fn(msg_ctx, snum, current_data,
+                                            queue, pinfo2, mem_ctx);
                info->count++;
        }
 
@@ -3293,7 +3294,8 @@ static WERROR printserver_notify_info(struct pipes_struct *p,
                        }
 
 
-                       construct_notify_printer_info(Printer, info,
+                       construct_notify_printer_info(p->msg_ctx,
+                                                     Printer, info,
                                                      pinfo2, snum,
                                                      &option_type, snum,
                                                      mem_ctx);
@@ -3377,7 +3379,8 @@ static WERROR printer_notify_info(struct pipes_struct *p,
 
                switch (option_type.type) {
                case PRINTER_NOTIFY_TYPE:
-                       if (construct_notify_printer_info(Printer, info,
+                       if (construct_notify_printer_info(p->msg_ctx,
+                                                         Printer, info,
                                                          pinfo2, snum,
                                                          &option_type, id,
                                                          mem_ctx)) {
@@ -3391,7 +3394,8 @@ static WERROR printer_notify_info(struct pipes_struct *p,
                                                   &status);
 
                        for (j=0; j<count; j++) {
-                               construct_notify_jobs_info(&queue[j], info,
+                               construct_notify_jobs_info(p->msg_ctx,
+                                                          &queue[j], info,
                                                           pinfo2, snum,
                                                           &option_type,
                                                           queue[j].job,
@@ -3618,6 +3622,7 @@ static WERROR construct_printer_info1(TALLOC_CTX *mem_ctx,
 ********************************************************************/
 
 static WERROR construct_printer_info2(TALLOC_CTX *mem_ctx,
+                                     struct messaging_context *msg_ctx,
                                      const struct spoolss_PrinterInfo2 *info2,
                                      struct spoolss_PrinterInfo2 *r,
                                      int snum)
@@ -3625,7 +3630,7 @@ static WERROR construct_printer_info2(TALLOC_CTX *mem_ctx,
        int count;
        print_status_struct status;
 
-       count = print_queue_length(server_messaging_context(), snum, &status);
+       count = print_queue_length(msg_ctx, snum, &status);
 
        r->servername           = talloc_strdup(mem_ctx, info2->servername);
        W_ERROR_HAVE_NO_MEMORY(r->servername);
@@ -3756,6 +3761,7 @@ static WERROR construct_printer_info5(TALLOC_CTX *mem_ctx,
  ********************************************************************/
 
 static WERROR construct_printer_info6(TALLOC_CTX *mem_ctx,
+                                     struct messaging_context *msg_ctx,
                                      const struct spoolss_PrinterInfo2 *info2,
                                      struct spoolss_PrinterInfo6 *r,
                                      int snum)
@@ -3763,7 +3769,7 @@ static WERROR construct_printer_info6(TALLOC_CTX *mem_ctx,
        int count;
        print_status_struct status;
 
-       count = print_queue_length(server_messaging_context(), snum, &status);
+       count = print_queue_length(msg_ctx, snum, &status);
 
        r->status = nt_printq_status(status.status);
 
@@ -3903,7 +3909,7 @@ static WERROR enum_all_printers_info_level(TALLOC_CTX *mem_ctx,
                                                         &info[count].info1, snum);
                        break;
                case 2:
-                       result = construct_printer_info2(info, info2,
+                       result = construct_printer_info2(info, msg_ctx, info2,
                                                         &info[count].info2, snum);
                        break;
                case 4:
@@ -4311,7 +4317,7 @@ WERROR _spoolss_GetPrinter(struct pipes_struct *p,
                                                 &r->out.info->info1, snum);
                break;
        case 2:
-               result = construct_printer_info2(p->mem_ctx, info2,
+               result = construct_printer_info2(p->mem_ctx, p->msg_ctx, info2,
                                                 &r->out.info->info2, snum);
                break;
        case 3:
@@ -4327,7 +4333,7 @@ WERROR _spoolss_GetPrinter(struct pipes_struct *p,
                                                 &r->out.info->info5, snum);
                break;
        case 6:
-               result = construct_printer_info6(p->mem_ctx, info2,
+               result = construct_printer_info6(p->mem_ctx, p->msg_ctx, info2,
                                                 &r->out.info->info6, snum);
                break;
        case 7:
@@ -5285,7 +5291,8 @@ WERROR _spoolss_StartDocPrinter(struct pipes_struct *p,
                return WERR_BADFID;
        }
 
-       werr = print_job_start(p->server_info, p->msg_ctx, snum,
+       werr = print_job_start(p->server_info, p->msg_ctx,
+                               p->client_id->name, snum,
                                info_1->document_name, info_1->output_file,
                                Printer->devmode, &Printer->jobid);
 
@@ -5360,7 +5367,6 @@ WERROR _spoolss_WritePrinter(struct pipes_struct *p,
        buffer_written = print_job_write(server_event_context(),p->msg_ctx,
                                                   snum, Printer->jobid,
                                                   (const char *)r->in.data.data,
-                                                  (SMB_OFF_T)-1,
                                                   (size_t)r->in._data_size);
        if (buffer_written == (ssize_t)-1) {
                *r->out.num_written = 0;
@@ -5719,7 +5725,7 @@ static bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token,
 
        /* reload our services immediately */
        become_root();
-       reload_services(msg_ctx, false);
+       reload_services(msg_ctx, smbd_server_fd(), false);
        unbecome_root();
 
        numlines = 0;
@@ -6106,7 +6112,7 @@ static WERROR update_printer(struct pipes_struct *p,
        {
                /* add_printer_hook() will call reload_services() */
                if (!add_printer_hook(tmp_ctx, p->server_info->ptok,
-                                     printer, p->client_address,
+                                     printer, p->client_id->addr,
                                      p->msg_ctx)) {
                        result = WERR_ACCESS_DENIED;
                        goto done;
@@ -6690,6 +6696,7 @@ WERROR _spoolss_ScheduleJob(struct pipes_struct *p,
 ****************************************************************/
 
 static WERROR spoolss_setjob_1(TALLOC_CTX *mem_ctx,
+                              struct messaging_context *msg_ctx,
                               const char *printer_name,
                               uint32_t job_id,
                               struct spoolss_SetJobInfo1 *r)
@@ -6704,8 +6711,7 @@ static WERROR spoolss_setjob_1(TALLOC_CTX *mem_ctx,
                return WERR_OK;
        }
 
-       if (!print_job_set_name(server_event_context(),
-                               server_messaging_context(),
+       if (!print_job_set_name(server_event_context(), msg_ctx,
                                printer_name, job_id, r->document_name)) {
                return WERR_BADFID;
        }
@@ -6770,7 +6776,8 @@ WERROR _spoolss_SetJob(struct pipes_struct *p,
 
        switch (r->in.ctr->level) {
        case 1:
-               errcode = spoolss_setjob_1(p->mem_ctx, lp_const_servicename(snum),
+               errcode = spoolss_setjob_1(p->mem_ctx, p->msg_ctx,
+                                          lp_const_servicename(snum),
                                           r->in.job_id,
                                           r->in.ctr->info.info1);
                break;
@@ -7414,7 +7421,7 @@ static WERROR spoolss_addprinterex_level_2(struct pipes_struct *p,
 
        if (*lp_addprinter_cmd() ) {
                if ( !add_printer_hook(p->mem_ctx, p->server_info->ptok,
-                                      info2, p->client_address,
+                                      info2, p->client_id->addr,
                                       p->msg_ctx) ) {
                        return WERR_ACCESS_DENIED;
                }