Changeset 988 for vendor/current/source3/printing/printspoolss.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/printing/printspoolss.c
r746 r988 19 19 20 20 #include "includes.h" 21 #include "system/filesys.h" 21 22 #include "printing.h" 22 23 #include "rpc_client/rpc_client.h" … … 26 27 #include "../libcli/security/security.h" 27 28 29 struct 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 38 uint16_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 28 47 void print_spool_terminate(struct connection_struct *conn, 29 48 struct print_file_data *print_file); … … 40 59 NTSTATUS print_spool_open(files_struct *fsp, 41 60 const char *fname, 42 uint 16_t current_vuid)61 uint64_t current_vuid) 43 62 { 44 63 NTSTATUS status; … … 47 66 struct dcerpc_binding_handle *b = NULL; 48 67 struct spoolss_DevmodeContainer devmode_ctr; 49 union spoolss_DocumentInfo info; 68 struct spoolss_DocumentInfoCtr info_ctr; 69 struct spoolss_DocumentInfo1 *info1; 50 70 int fd = -1; 51 71 WERROR werr; 72 mode_t mask; 52 73 53 74 tmp_ctx = talloc_new(fsp); … … 61 82 goto done; 62 83 } 63 pf->svcname = talloc_strdup(pf, lp_servicename(SNUM(fsp->conn)));84 pf->svcname = lp_servicename(pf, SNUM(fsp->conn)); 64 85 65 86 /* the document name is derived from the file name. … … 101 122 102 123 pf->filename = talloc_asprintf(pf, "%s/%sXXXXXX", 103 lp_pathname(SNUM(fsp->conn)), 124 lp_path(talloc_tos(), 125 SNUM(fsp->conn)), 104 126 PRINT_SPOOL_PREFIX); 105 127 if (!pf->filename) { … … 108 130 } 109 131 errno = 0; 132 mask = umask(S_IRWXO | S_IRWXG); 110 133 fd = mkstemp(pf->filename); 134 umask(mask); 111 135 if (fd == -1) { 112 136 if (errno == EACCES) { … … 131 155 132 156 status = rpc_pipe_open_interface(fsp->conn, 133 &ndr_table_spoolss .syntax_id,157 &ndr_table_spoolss, 134 158 fsp->conn->session_info, 135 &fsp->conn->sconn->client_id,159 fsp->conn->sconn->remote_address, 136 160 fsp->conn->sconn->msg_ctx, 137 161 &fsp->conn->spoolss_pipe); … … 155 179 } 156 180 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); 168 198 if (!NT_STATUS_IS_OK(status)) { 169 199 goto done; … … 183 213 184 214 /* 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; 188 218 goto done; 189 219 } … … 195 225 196 226 fsp->file_id = vfs_file_id_from_sbuf(fsp->conn, &fsp->fsp_name->st); 197 fsp->mode = fsp->fsp_name->st.st_ex_mode;198 227 fsp->fh->fd = fd; 199 228 … … 220 249 } 221 250 /* We need to delete the job from spoolss too */ 222 if (pf ->jobid) {251 if (pf && pf->jobid) { 223 252 print_spool_terminate(fsp->conn, pf); 224 253 } … … 230 259 int print_spool_write(files_struct *fsp, 231 260 const char *data, uint32_t size, 232 SMB_OFF_Toffset, uint32_t *written)261 off_t offset, uint32_t *written) 233 262 { 234 263 SMB_STRUCT_STAT st; … … 315 344 316 345 status = rpc_pipe_open_interface(conn, 317 &ndr_table_spoolss .syntax_id,346 &ndr_table_spoolss, 318 347 conn->session_info, 319 &conn->sconn->client_id,348 conn->sconn->remote_address, 320 349 conn->sconn->msg_ctx, 321 350 &conn->spoolss_pipe);
Note:
See TracChangeset
for help on using the changeset viewer.