2 Unix SMB/Netbios implementation.
4 SMB parameters and setup
5 Copyright (C) Andrew Tridgell 1992-2000,
6 Copyright (C) Jean Francois Micouleau 1998-2000.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef NT_PRINTING_H_
23 #define NT_PRINTING_H_
26 #include "../librpc/gen_ndr/srv_spoolss.h"
28 /* container for a single registry key */
32 struct regval_ctr *values;
35 /* container for all printer data */
42 typedef struct nt_printer_info_level_2
46 uint32 default_priority;
59 struct spoolss_DeviceMode *devmode;
61 fstring printprocessor;
64 NT_PRINTER_DATA *data;
65 struct sec_desc_buf *secdesc_buf;
69 } NT_PRINTER_INFO_LEVEL_2;
71 typedef struct nt_printer_info_level
73 NT_PRINTER_INFO_LEVEL_2 *info_2;
74 } NT_PRINTER_INFO_LEVEL;
88 #ifndef SAMBA_PRINTER_PORT_NAME
89 #define SAMBA_PRINTER_PORT_NAME "Samba Printer Port"
92 /* DOS header format */
93 #define DOS_HEADER_SIZE 64
94 #define DOS_HEADER_MAGIC_OFFSET 0
95 #define DOS_HEADER_MAGIC 0x5A4D
96 #define DOS_HEADER_LFANEW_OFFSET 60
98 /* New Executable format (Win or OS/2 1.x segmented) */
99 #define NE_HEADER_SIZE 64
100 #define NE_HEADER_SIGNATURE_OFFSET 0
101 #define NE_HEADER_SIGNATURE 0x454E
102 #define NE_HEADER_TARGET_OS_OFFSET 54
103 #define NE_HEADER_TARGOS_WIN 0x02
104 #define NE_HEADER_MINOR_VER_OFFSET 62
105 #define NE_HEADER_MAJOR_VER_OFFSET 63
107 /* Portable Executable format */
108 #define PE_HEADER_SIZE 24
109 #define PE_HEADER_SIGNATURE_OFFSET 0
110 #define PE_HEADER_SIGNATURE 0x00004550
111 #define PE_HEADER_MACHINE_OFFSET 4
112 #define PE_HEADER_MACHINE_I386 0x14c
113 #define PE_HEADER_NUMBER_OF_SECTIONS 6
114 #define PE_HEADER_OPTIONAL_HEADER_SIZE 20
115 #define PE_HEADER_SECT_HEADER_SIZE 40
116 #define PE_HEADER_SECT_NAME_OFFSET 0
117 #define PE_HEADER_SECT_SIZE_DATA_OFFSET 16
118 #define PE_HEADER_SECT_PTR_DATA_OFFSET 20
120 /* Microsoft file version format */
121 #define VS_SIGNATURE "VS_VERSION_INFO"
122 #define VS_MAGIC_VALUE 0xfeef04bd
123 #define VS_MAJOR_OFFSET 8
124 #define VS_MINOR_OFFSET 12
125 #define VS_VERSION_INFO_UNICODE_SIZE (sizeof(VS_SIGNATURE)*2+4+VS_MINOR_OFFSET+4) /* not true size! */
126 #define VS_VERSION_INFO_SIZE (sizeof(VS_SIGNATURE)+4+VS_MINOR_OFFSET+4) /* not true size! */
127 #define VS_NE_BUF_SIZE 4096 /* Must be > 2*VS_VERSION_INFO_SIZE */
129 /* Notify spoolss clients that something has changed. The
130 notification data is either stored in two uint32 values or a
131 variable length array. */
133 #define SPOOLSS_NOTIFY_MSG_UNIX_JOBID 0x0001 /* Job id is unix */
135 typedef struct spoolss_notify_msg {
136 fstring printer; /* Name of printer notified */
137 uint32 type; /* Printer or job notify */
138 uint32 field; /* Notify field changed */
139 uint32 id; /* Job id */
140 uint32 len; /* Length of data, 0 for two uint32 value */
146 } SPOOLSS_NOTIFY_MSG;
151 SPOOLSS_NOTIFY_MSG *msgs;
152 } SPOOLSS_NOTIFY_MSG_GROUP;
157 SPOOLSS_NOTIFY_MSG_GROUP *msg_groups;
158 } SPOOLSS_NOTIFY_MSG_CTR;
160 #define SPLHND_PRINTER 1
161 #define SPLHND_SERVER 2
162 #define SPLHND_PORTMON_TCP 3
163 #define SPLHND_PORTMON_LOCAL 4
165 /* structure to store the printer handles */
166 /* and a reference to what it's pointing to */
167 /* and the notify info asked about */
168 /* that's the central struct */
169 typedef struct _Printer{
170 struct _Printer *prev, *next;
171 bool document_started;
173 uint32 jobid; /* jobid in printing backend */
178 uint32 access_granted;
182 fstring localmachine;
184 struct spoolss_NotifyOption *option;
185 struct policy_handle client_hnd;
186 bool client_connected;
188 /* are we in a FindNextPrinterChangeNotify() call? */
190 struct messaging_context *msg_ctx;
197 /* devmode sent in the OpenPrinter() call */
198 struct spoolss_DeviceMode *devmode;
200 /* TODO cache the printer info2 structure */
201 struct spoolss_PrinterInfo2 *info2;
206 * The printer attributes.
207 * I #defined all of them (grabbed form MSDN)
209 * ( SHARED | NETWORK | RAW_ONLY )
210 * RAW_ONLY _MUST_ be present otherwise NT will send an EMF file
213 #define PRINTER_ATTRIBUTE_SAMBA (PRINTER_ATTRIBUTE_RAW_ONLY|\
214 PRINTER_ATTRIBUTE_SHARED|\
215 PRINTER_ATTRIBUTE_LOCAL)
216 #define PRINTER_ATTRIBUTE_NOT_SAMBA (PRINTER_ATTRIBUTE_NETWORK)
218 #define DRIVER_ANY_VERSION 0xffffffff
219 #define DRIVER_MAX_VERSION 4
221 struct print_architecture_table_node {
222 const char *long_archi;
223 const char *short_archi;
227 bool nt_printing_init(struct messaging_context *msg_ctx);
229 WERROR spoolss_create_default_devmode(TALLOC_CTX *mem_ctx,
230 const char *devicename,
231 struct spoolss_DeviceMode **devmode);
233 WERROR spoolss_create_default_secdesc(TALLOC_CTX *mem_ctx,
234 struct spoolss_security_descriptor **secdesc);
236 WERROR spoolss_map_to_os2_driver(TALLOC_CTX *mem_ctx, const char **pdrivername);
238 const char *get_short_archi(const char *long_archi);
240 bool print_access_check(struct auth_serversupplied_info *server_info,
241 struct messaging_context *msg_ctx, int snum,
244 WERROR nt_printer_publish(TALLOC_CTX *mem_ctx,
245 struct auth_serversupplied_info *server_info,
246 struct messaging_context *msg_ctx,
247 struct spoolss_PrinterInfo2 *pinfo2,
250 bool is_printer_published(TALLOC_CTX *mem_ctx,
251 struct auth_serversupplied_info *server_info,
252 char *servername, char *printer, struct GUID *guid,
253 struct spoolss_PrinterInfo2 **info2);
255 WERROR check_published_printers(void);
257 bool driver_info_ctr_to_info8(struct spoolss_AddDriverInfoCtr *r,
258 struct spoolss_DriverInfo8 *_info8);
260 bool printer_driver_in_use(TALLOC_CTX *mem_ctx,
261 struct auth_serversupplied_info *server_info,
262 struct messaging_context *msg_ctx,
263 const struct spoolss_DriverInfo8 *r);
264 bool printer_driver_files_in_use(TALLOC_CTX *mem_ctx,
265 struct auth_serversupplied_info *server_info,
266 struct messaging_context *msg_ctx,
267 struct spoolss_DriverInfo8 *r);
268 bool delete_driver_files(struct auth_serversupplied_info *server_info,
269 const struct spoolss_DriverInfo8 *r);
271 WERROR move_driver_to_download_area(struct pipes_struct *p,
272 struct spoolss_AddDriverInfoCtr *r,
275 WERROR clean_up_driver_struct(TALLOC_CTX *mem_ctx,
276 struct pipes_struct *rpc_pipe,
277 struct spoolss_AddDriverInfoCtr *r);
279 void map_printer_permissions(struct security_descriptor *sd);
281 void map_job_permissions(struct security_descriptor *sd);
283 bool print_time_access_check(struct auth_serversupplied_info *server_info,
284 struct messaging_context *msg_ctx,
285 const char *servicename);
287 void nt_printer_remove(TALLOC_CTX *mem_ctx,
288 struct auth_serversupplied_info *server_info,
289 struct messaging_context *msg_ctx,
290 const char *printer);
292 #endif /* NT_PRINTING_H_ */