Annotation of /trunk/samba/patches/samba-3.0.24-spoolss.patch
Parent Directory | Revision Log
Revision 153 -
(hide annotations)
(download)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 6649 byte(s)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 6649 byte(s)
-import
1 | niro | 153 | Index: samba-3.0.24/source/rpc_server/srv_spoolss_nt.c |
2 | =================================================================== | ||
3 | --- samba-3.0.24.orig/source/rpc_server/srv_spoolss_nt.c 2007-02-04 12:59:21.000000000 -0600 | ||
4 | +++ samba-3.0.24/source/rpc_server/srv_spoolss_nt.c 2007-02-15 11:02:09.000000000 -0600 | ||
5 | @@ -5848,6 +5848,12 @@ | ||
6 | goto done; | ||
7 | } | ||
8 | |||
9 | + if (!secdesc_ctr) { | ||
10 | + DEBUG(10,("update_printer_sec: secdesc_ctr is NULL !\n")); | ||
11 | + result = WERR_INVALID_PARAM; | ||
12 | + goto done; | ||
13 | + } | ||
14 | + | ||
15 | /* Check the user has permissions to change the security | ||
16 | descriptor. By experimentation with two NT machines, the user | ||
17 | requires Full Access to the printer to change security | ||
18 | @@ -9378,6 +9384,15 @@ | ||
19 | |||
20 | /* housekeeping information in the reply */ | ||
21 | |||
22 | + /* Fix from Martin Zielinski <mz@seh.de> - ensure | ||
23 | + * the hand marshalled container size is a multiple | ||
24 | + * of 4 bytes for RPC alignment. | ||
25 | + */ | ||
26 | + | ||
27 | + if (needed % 4) { | ||
28 | + needed += 4-(needed % 4); | ||
29 | + } | ||
30 | + | ||
31 | r_u->needed = needed; | ||
32 | r_u->returned = num_entries; | ||
33 | |||
34 | Index: samba-3.0.24/source/printing/nt_printing.c | ||
35 | =================================================================== | ||
36 | --- samba-3.0.24.orig/source/printing/nt_printing.c 2007-02-04 13:09:01.000000000 -0600 | ||
37 | +++ samba-3.0.24/source/printing/nt_printing.c 2007-02-15 11:02:09.000000000 -0600 | ||
38 | @@ -2984,11 +2984,15 @@ | ||
39 | return True; | ||
40 | } | ||
41 | |||
42 | +/***************************************************************** | ||
43 | + ****************************************************************/ | ||
44 | + | ||
45 | static void store_printer_guid(NT_PRINTER_INFO_LEVEL_2 *info2, | ||
46 | struct uuid guid) | ||
47 | { | ||
48 | int i; | ||
49 | REGVAL_CTR *ctr=NULL; | ||
50 | + UNISTR2 unistr_guid; | ||
51 | |||
52 | /* find the DsSpooler key */ | ||
53 | if ((i = lookup_printerkey(info2->data, SPOOL_DSSPOOLER_KEY)) < 0) | ||
54 | @@ -2996,8 +3000,18 @@ | ||
55 | ctr = info2->data->keys[i].values; | ||
56 | |||
57 | regval_ctr_delvalue(ctr, "objectGUID"); | ||
58 | - regval_ctr_addvalue(ctr, "objectGUID", REG_BINARY, | ||
59 | - (char *) &guid, sizeof(struct uuid)); | ||
60 | + | ||
61 | + /* We used to store this as a REG_BINARY but that causes | ||
62 | + Vista to whine */ | ||
63 | + | ||
64 | + ZERO_STRUCT( unistr_guid ); | ||
65 | + init_unistr2( &unistr_guid, smb_uuid_string_static(guid), | ||
66 | + UNI_STR_TERMINATE ); | ||
67 | + | ||
68 | + regval_ctr_addvalue(ctr, "objectGUID", REG_SZ, | ||
69 | + (char *)unistr_guid.buffer, | ||
70 | + unistr_guid.uni_max_len*2); | ||
71 | + | ||
72 | } | ||
73 | |||
74 | static WERROR nt_printer_publish_ads(ADS_STRUCT *ads, | ||
75 | @@ -3254,6 +3268,7 @@ | ||
76 | REGISTRY_VALUE *guid_val; | ||
77 | WERROR win_rc; | ||
78 | int i; | ||
79 | + BOOL ret = False; | ||
80 | |||
81 | win_rc = get_a_printer(print_hnd, &printer, 2, lp_servicename(snum)); | ||
82 | |||
83 | @@ -3267,12 +3282,36 @@ | ||
84 | return False; | ||
85 | } | ||
86 | |||
87 | - /* fetching printer guids really ought to be a separate function.. */ | ||
88 | - if (guid && regval_size(guid_val) == sizeof(struct uuid)) | ||
89 | - memcpy(guid, regval_data_p(guid_val), sizeof(struct uuid)); | ||
90 | + /* fetching printer guids really ought to be a separate function. */ | ||
91 | + | ||
92 | + if ( guid ) { | ||
93 | + fstring guid_str; | ||
94 | + | ||
95 | + /* We used to store the guid as REG_BINARY, then swapped | ||
96 | + to REG_SZ for Vista compatibility so check for both */ | ||
97 | + | ||
98 | + switch ( regval_type(guid_val) ){ | ||
99 | + case REG_SZ: | ||
100 | + rpcstr_pull( guid_str, regval_data_p(guid_val), | ||
101 | + sizeof(guid_str)-1, -1, STR_TERMINATE ); | ||
102 | + ret = smb_string_to_uuid( guid_str, guid ); | ||
103 | + break; | ||
104 | + case REG_BINARY: | ||
105 | + if ( regval_size(guid_val) != sizeof(struct uuid) ) { | ||
106 | + ret = False; | ||
107 | + break; | ||
108 | + } | ||
109 | + memcpy(guid, regval_data_p(guid_val), sizeof(struct uuid)); | ||
110 | + break; | ||
111 | + default: | ||
112 | + DEBUG(0,("is_printer_published: GUID value stored as " | ||
113 | + "invaluid type (%d)\n", regval_type(guid_val) )); | ||
114 | + break; | ||
115 | + } | ||
116 | + } | ||
117 | |||
118 | free_a_printer(&printer, 2); | ||
119 | - return True; | ||
120 | + return ret; | ||
121 | } | ||
122 | #else | ||
123 | WERROR nt_printer_publish(Printer_entry *print_hnd, int snum, int action) | ||
124 | @@ -3539,13 +3578,43 @@ | ||
125 | break; | ||
126 | } | ||
127 | |||
128 | - /* add the new value */ | ||
129 | + DEBUG(8,("specific: [%s:%s], len: %d\n", keyname, valuename, size)); | ||
130 | + | ||
131 | + /* Vista doesn't like unknown REG_BINARY values in DsSpooler. | ||
132 | + Thanks to Martin Zielinski for the hint. */ | ||
133 | + | ||
134 | + if ( type == REG_BINARY && | ||
135 | + strequal( keyname, SPOOL_DSSPOOLER_KEY ) && | ||
136 | + strequal( valuename, "objectGUID" ) ) | ||
137 | + { | ||
138 | + struct uuid guid; | ||
139 | + UNISTR2 unistr_guid; | ||
140 | + | ||
141 | + ZERO_STRUCT( unistr_guid ); | ||
142 | + | ||
143 | + /* convert the GUID to a UNICODE string */ | ||
144 | + | ||
145 | + memcpy( &guid, data_p, sizeof(struct uuid) ); | ||
146 | + | ||
147 | + init_unistr2( &unistr_guid, smb_uuid_string_static(guid), | ||
148 | + UNI_STR_TERMINATE ); | ||
149 | + | ||
150 | + regval_ctr_addvalue( printer_data->keys[key_index].values, | ||
151 | + valuename, REG_SZ, | ||
152 | + (const char *)unistr_guid.buffer, | ||
153 | + unistr_guid.uni_str_len*2 ); | ||
154 | + | ||
155 | + } else { | ||
156 | + /* add the value */ | ||
157 | + | ||
158 | + regval_ctr_addvalue( printer_data->keys[key_index].values, | ||
159 | + valuename, type, (const char *)data_p, | ||
160 | + size ); | ||
161 | + } | ||
162 | |||
163 | - regval_ctr_addvalue( printer_data->keys[key_index].values, valuename, type, (const char *)data_p, size ); | ||
164 | |||
165 | SAFE_FREE(data_p); /* 'B' option to tdbpack does a malloc() */ | ||
166 | |||
167 | - DEBUG(8,("specific: [%s:%s], len: %d\n", keyname, valuename, size)); | ||
168 | } | ||
169 | |||
170 | return len; | ||
171 | Index: samba-3.0.24/source/rpc_server/srv_spoolss.c | ||
172 | =================================================================== | ||
173 | --- samba-3.0.24.orig/source/rpc_server/srv_spoolss.c 2006-04-19 21:29:27.000000000 -0500 | ||
174 | +++ samba-3.0.24/source/rpc_server/srv_spoolss.c 2007-02-15 11:02:09.000000000 -0600 | ||
175 | @@ -1477,6 +1477,15 @@ | ||
176 | ZERO_STRUCT(r_u); | ||
177 | |||
178 | if(!spoolss_io_q_addprinterdriverex("", &q_u, data, 0)) { | ||
179 | + if (q_u.level != 3 && q_u.level != 6) { | ||
180 | + /* Clever hack from Martin Zielinski <mz@seh.de> | ||
181 | + * to allow downgrade from level 8 (Vista). | ||
182 | + */ | ||
183 | + DEBUG(3,("api_spoolss_addprinterdriverex: unknown SPOOL_Q_ADDPRINTERDRIVEREX level %u.\n", | ||
184 | + (unsigned int)q_u.level )); | ||
185 | + setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG)); | ||
186 | + return True; | ||
187 | + } | ||
188 | DEBUG(0,("spoolss_io_q_addprinterdriverex: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVEREX.\n")); | ||
189 | return False; | ||
190 | } | ||
191 | Index: samba-3.0.24/source/rpc_parse/parse_spoolss.c | ||
192 | =================================================================== | ||
193 | --- samba-3.0.24.orig/source/rpc_parse/parse_spoolss.c 2007-02-15 11:02:19.000000000 -0600 | ||
194 | +++ samba-3.0.24/source/rpc_parse/parse_spoolss.c 2007-02-15 11:02:25.000000000 -0600 | ||
195 | @@ -3893,7 +3893,16 @@ | ||
196 | } | ||
197 | case 3: | ||
198 | { | ||
199 | - ptr_sec_desc = q_u->info.info_3->secdesc_ptr; | ||
200 | + /* FIXME ! Our parsing here is wrong I think, | ||
201 | + * but for a level3 it makes no sense for | ||
202 | + * ptr_sec_desc to be NULL. JRA. Based on | ||
203 | + * a Vista sniff from Martin Zielinski <mz@seh.de>. | ||
204 | + */ | ||
205 | + if (UNMARSHALLING(ps)) { | ||
206 | + ptr_sec_desc = 1; | ||
207 | + } else { | ||
208 | + ptr_sec_desc = q_u->info.info_3->secdesc_ptr; | ||
209 | + } | ||
210 | break; | ||
211 | } | ||
212 | } |