Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/printing/printspoolss.c

    r746 r988  
    1919
    2020#include "includes.h"
     21#include "system/filesys.h"
    2122#include "printing.h"
    2223#include "rpc_client/rpc_client.h"
     
    2627#include "../libcli/security/security.h"
    2728
     29struct print_file_data {
     30        char *svcname;
     31        char *docname;
     32        char *filename;
     33        struct policy_handle handle;
     34        uint32_t jobid;
     35        uint16_t rap_jobid;
     36};
     37
     38uint16_t print_spool_rap_jobid(struct print_file_data *print_file)
     39{
     40        if (print_file == NULL) {
     41                return 0;
     42        }
     43
     44        return print_file->rap_jobid;
     45}
     46
    2847void print_spool_terminate(struct connection_struct *conn,
    2948                           struct print_file_data *print_file);
     
    4059NTSTATUS print_spool_open(files_struct *fsp,
    4160                          const char *fname,
    42                           uint16_t current_vuid)
     61                          uint64_t current_vuid)
    4362{
    4463        NTSTATUS status;
     
    4766        struct dcerpc_binding_handle *b = NULL;
    4867        struct spoolss_DevmodeContainer devmode_ctr;
    49         union spoolss_DocumentInfo info;
     68        struct spoolss_DocumentInfoCtr info_ctr;
     69        struct spoolss_DocumentInfo1 *info1;
    5070        int fd = -1;
    5171        WERROR werr;
     72        mode_t mask;
    5273
    5374        tmp_ctx = talloc_new(fsp);
     
    6182                goto done;
    6283        }
    63         pf->svcname = talloc_strdup(pf, lp_servicename(SNUM(fsp->conn)));
     84        pf->svcname = lp_servicename(pf, SNUM(fsp->conn));
    6485
    6586        /* the document name is derived from the file name.
     
    101122
    102123        pf->filename = talloc_asprintf(pf, "%s/%sXXXXXX",
    103                                         lp_pathname(SNUM(fsp->conn)),
     124                                        lp_path(talloc_tos(),
     125                                                SNUM(fsp->conn)),
    104126                                        PRINT_SPOOL_PREFIX);
    105127        if (!pf->filename) {
     
    108130        }
    109131        errno = 0;
     132        mask = umask(S_IRWXO | S_IRWXG);
    110133        fd = mkstemp(pf->filename);
     134        umask(mask);
    111135        if (fd == -1) {
    112136                if (errno == EACCES) {
     
    131155
    132156        status = rpc_pipe_open_interface(fsp->conn,
    133                                          &ndr_table_spoolss.syntax_id,
     157                                         &ndr_table_spoolss,
    134158                                         fsp->conn->session_info,
    135                                          &fsp->conn->sconn->client_id,
     159                                         fsp->conn->sconn->remote_address,
    136160                                         fsp->conn->sconn->msg_ctx,
    137161                                         &fsp->conn->spoolss_pipe);
     
    155179        }
    156180
    157         info.info1 = talloc(tmp_ctx, struct spoolss_DocumentInfo1);
    158         if (!info.info1) {
    159                 status = NT_STATUS_NO_MEMORY;
    160                 goto done;
    161         }
    162         info.info1->document_name = pf->docname;
    163         info.info1->output_file = pf->filename;
    164         info.info1->datatype = "RAW";
    165 
    166         status = dcerpc_spoolss_StartDocPrinter(b, tmp_ctx, &pf->handle,
    167                                                 1, info, &pf->jobid, &werr);
     181        info1 = talloc(tmp_ctx, struct spoolss_DocumentInfo1);
     182        if (info1 == NULL) {
     183                status = NT_STATUS_NO_MEMORY;
     184                goto done;
     185        }
     186        info1->document_name = pf->docname;
     187        info1->output_file = pf->filename;
     188        info1->datatype = "RAW";
     189
     190        info_ctr.level = 1;
     191        info_ctr.info.info1 = info1;
     192
     193        status = dcerpc_spoolss_StartDocPrinter(b, tmp_ctx,
     194                                                &pf->handle,
     195                                                &info_ctr,
     196                                                &pf->jobid,
     197                                                &werr);
    168198        if (!NT_STATUS_IS_OK(status)) {
    169199                goto done;
     
    183213
    184214        /* setup a full fsp */
    185         status = create_synthetic_smb_fname(fsp, pf->filename, NULL,
    186                                             NULL, &fsp->fsp_name);
    187         if (!NT_STATUS_IS_OK(status)) {
     215        fsp->fsp_name = synthetic_smb_fname(fsp, pf->filename, NULL, NULL);
     216        if (fsp->fsp_name == NULL) {
     217                status = NT_STATUS_NO_MEMORY;
    188218                goto done;
    189219        }
     
    195225
    196226        fsp->file_id = vfs_file_id_from_sbuf(fsp->conn, &fsp->fsp_name->st);
    197         fsp->mode = fsp->fsp_name->st.st_ex_mode;
    198227        fsp->fh->fd = fd;
    199228
     
    220249                }
    221250                /* We need to delete the job from spoolss too */
    222                 if (pf->jobid) {
     251                if (pf && pf->jobid) {
    223252                        print_spool_terminate(fsp->conn, pf);
    224253                }
     
    230259int print_spool_write(files_struct *fsp,
    231260                      const char *data, uint32_t size,
    232                       SMB_OFF_T offset, uint32_t *written)
     261                      off_t offset, uint32_t *written)
    233262{
    234263        SMB_STRUCT_STAT st;
     
    315344
    316345        status = rpc_pipe_open_interface(conn,
    317                                          &ndr_table_spoolss.syntax_id,
     346                                         &ndr_table_spoolss,
    318347                                         conn->session_info,
    319                                          &conn->sconn->client_id,
     348                                         conn->sconn->remote_address,
    320349                                         conn->sconn->msg_ctx,
    321350                                         &conn->spoolss_pipe);
Note: See TracChangeset for help on using the changeset viewer.